summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-08-09 17:14:54 (UTC)
committer kergoth <kergoth>2003-08-09 17:14:54 (UTC)
commita7e015198a8c5ad3b6e144a9032b059086253e00 (patch) (side-by-side diff)
treeb712b6f11310d88744fe393a92b3160b741a7efe
parentbeba0e73306815337bf04dee39502233595e9739 (diff)
downloadopie-a7e015198a8c5ad3b6e144a9032b059086253e00.zip
opie-a7e015198a8c5ad3b6e144a9032b059086253e00.tar.gz
opie-a7e015198a8c5ad3b6e144a9032b059086253e00.tar.bz2
Merge from BRANCH_1_0
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/appearance2/appearance.cpp13
-rw-r--r--noncore/settings/appearance2/colorlistitem.h7
-rw-r--r--noncore/settings/appearance2/decolistitem.h3
-rw-r--r--noncore/settings/backup/backuprestore.cpp9
-rw-r--r--noncore/settings/language/language.cpp2
-rw-r--r--noncore/settings/mediummount/mainwindow.cc1
-rw-r--r--noncore/settings/mediummount/mediumglobal.cc2
-rw-r--r--noncore/settings/mediummount/mediumwidget.cc2
-rw-r--r--noncore/settings/networksettings/interfaces/interface.cpp68
-rw-r--r--noncore/settings/networksettings/interfaces/interface.h12
-rw-r--r--noncore/settings/networksettings/interfaces/interfaceadvanced.ui2
-rw-r--r--noncore/settings/networksettings/interfaces/interfaceinformation.ui267
-rw-r--r--noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp24
-rw-r--r--noncore/settings/networksettings/interfaces/interfaceinformationimp.h2
-rw-r--r--noncore/settings/networksettings/interfaces/interfaces.cpp60
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.cpp4
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp23
-rw-r--r--noncore/settings/networksettings/mainwindowimp.h15
-rw-r--r--noncore/settings/networksettings/module.h39
-rw-r--r--noncore/settings/networksettings/ppp/TODO10
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp158
-rw-r--r--noncore/settings/networksettings/ppp/accounts.h40
-rw-r--r--noncore/settings/networksettings/ppp/chooserwidget.cpp85
-rw-r--r--noncore/settings/networksettings/ppp/chooserwidget.h73
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp166
-rw-r--r--noncore/settings/networksettings/ppp/connect.h2
-rw-r--r--noncore/settings/networksettings/ppp/conwindow.cpp27
-rw-r--r--noncore/settings/networksettings/ppp/devices.cpp212
-rw-r--r--noncore/settings/networksettings/ppp/devices.h95
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp4
-rw-r--r--noncore/settings/networksettings/ppp/general.cpp293
-rw-r--r--noncore/settings/networksettings/ppp/general.h34
-rw-r--r--noncore/settings/networksettings/ppp/interfaceinformationppp.cpp20
-rw-r--r--noncore/settings/networksettings/ppp/interfaceppp.cpp70
-rw-r--r--noncore/settings/networksettings/ppp/interfaceppp.h16
-rw-r--r--noncore/settings/networksettings/ppp/kpppwidget.cpp89
-rw-r--r--noncore/settings/networksettings/ppp/modem.cpp85
-rw-r--r--noncore/settings/networksettings/ppp/modem.h23
-rw-r--r--noncore/settings/networksettings/ppp/modemcmds.cpp129
-rw-r--r--noncore/settings/networksettings/ppp/modemcmds.h3
-rw-r--r--noncore/settings/networksettings/ppp/modeminfo.cpp24
-rw-r--r--noncore/settings/networksettings/ppp/ppp.pro5
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.cpp19
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.h6
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp397
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.h47
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp117
-rw-r--r--noncore/settings/networksettings/ppp/runtests.cpp12
-rw-r--r--noncore/settings/networksettings/wlan/keyedit.cpp1
-rw-r--r--noncore/settings/networksettings/wlan/wlan.ui96
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.cpp35
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp2
-rw-r--r--noncore/settings/usermanager/userdialog.cpp2
-rw-r--r--noncore/settings/usermanager/userdialog.h1
-rw-r--r--noncore/settings/usermanager/usermanager.cpp2
-rw-r--r--noncore/settings/usermanager/usermanager.pro2
-rw-r--r--noncore/styles/flat/flat.cpp128
-rw-r--r--noncore/styles/flat/flat.h6
-rw-r--r--noncore/todayplugins/stockticker/stockticker/inputDialog.cpp1
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp2
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h2
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp622
-rw-r--r--noncore/todayplugins/weather/weatherconfig.h1
-rw-r--r--noncore/tools/clock/clock.cpp7
-rw-r--r--noncore/tools/euroconv/main.cpp2
-rw-r--r--noncore/tools/formatter/formatter.cpp3
66 files changed, 2410 insertions, 1321 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp
index c376ec7..00128d3 100644
--- a/noncore/settings/appearance2/appearance.cpp
+++ b/noncore/settings/appearance2/appearance.cpp
@@ -39,188 +39,188 @@
#include <qmessagebox.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#if QT_VERSION >= 300
#include <qstylefactory.h>
#endif
#include <qtoolbutton.h>
#include <qwindowsstyle.h>
#include <qlistview.h>
#include <qheader.h>
#include <qvbox.h>
#include <qwhatsthis.h>
#include <qpe/config.h>
#include <qpe/global.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpemessagebox.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpestyle.h>
#include <qpe/lightstyle.h>
#include <qpe/qlibrary.h>
#include <qpe/styleinterface.h>
#include <opie/ofontselector.h>
#include <opie/odevice.h>
#include <opie/ofiledialog.h>
#include <opie/otabwidget.h>
#include "appearance.h"
#include "editScheme.h"
#include "stylelistitem.h"
#include "decolistitem.h"
#include "colorlistitem.h"
#include "exceptlistitem.h"
#include "sample.h"
using namespace Opie;
class DefaultWindowDecoration : public WindowDecorationInterface
{
public:
DefaultWindowDecoration() : ref(0) {}
QString name() const {
return "Default";
}
- QPixmap icon() const {
+QPixmap icon() const {
return QPixmap();
}
QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) {
*iface = 0;
if ( uuid == IID_QUnknown )
*iface = this;
else if ( uuid == IID_WindowDecoration )
*iface = this;
if ( *iface )
(*iface)->addRef();
return QS_OK;
}
Q_REFCOUNT
private:
ulong ref;
};
QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg )
{
QWidget* tab = new QWidget( parent, "StyleTab" );
QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 );
m_style_list = new QListBox( tab, "m_style_list" );
vertLayout->addWidget( m_style_list );
QWhatsThis::add( m_style_list, tr( "Styles control the way items such as buttons and scroll bars appear in all applications.\n\nClick here to select an available style." ) );
m_style_settings = new QPushButton ( tr( "Settings..." ), tab );
connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( )));
vertLayout-> addWidget ( m_style_settings );
QWhatsThis::add( m_style_settings, tr( "Click here to configure the currently selected style.\n\nNote: This option is not available for all styles." ) );
QString s = cfg. readEntry ( "Style", "Light" );
#if QT_VERSION >= 300
m_style_list->insertStringList(QStyleFactory::styles());
#else
m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( )));
m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( )));
m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( )));
#endif
{
QString path = QPEApplication::qpeDir ( );
path.append( "/plugins/styles/" );
QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
QString libstr = path;
libstr.append( "/" );
libstr.append( *it );
QLibrary *lib = new QLibrary ( libstr );
StyleInterface *iface;
if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) {
StyleListItem *slit = new StyleListItem ( lib, iface );
m_style_list-> insertItem ( slit );
if ( slit-> key ( ) == s )
m_style_list-> setCurrentItem ( slit );
}
else
delete lib;
}
}
m_original_style = m_style_list-> currentItem ( );
styleClicked ( m_original_style );
connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) );
return tab;
}
QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg )
{
QWidget* tab = new QWidget( parent, "DecoTab" );
QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 );
m_deco_list = new QListBox( tab, "m_deco_list" );
vertLayout->addWidget( m_deco_list );
QWhatsThis::add( m_deco_list, tr( "Window decorations control the way the application title bar and its buttons appear.\n\nClick here to select an available decoration." ) );
- QString s = cfg. readEntry ( "Decoration" );
+ QString s = cfg. readEntry ( "Decoration", "libflat.so" );
m_deco_list-> insertItem ( new DecoListItem ( "QPE" ));
{
QString path = QPEApplication::qpeDir();
path.append( "/plugins/decorations/" );
QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
QString libstr = path;
libstr.append( "/" );
libstr.append( *it );
QLibrary *lib = new QLibrary ( libstr );
WindowDecorationInterface *iface;
if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) {
DecoListItem *dlit = new DecoListItem ( lib, iface );
m_deco_list-> insertItem ( dlit );
if ( dlit-> key ( ) == s )
m_deco_list-> setCurrentItem ( dlit );
}
else
delete lib;
}
}
m_original_deco = m_deco_list-> currentItem ( );
if ( m_deco_list-> currentItem ( ) < 0 )
m_deco_list-> setCurrentItem ( 0 );
decoClicked ( m_original_deco );
connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) );
return tab;
}
QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg )
{
QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" );
QString styleStr = cfg. readEntry ( "FontStyle", "Regular" );
int size = cfg. readNumEntry ( "FontSize", 10 );
m_fontselect = new OFontSelector ( false, parent, "FontTab" );
m_fontselect-> setSelectedFont ( familyStr, styleStr, size );
QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) );
connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )),
@@ -357,152 +357,153 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg )
vertLayout-> addSpacing ( 3 );
QFrame *f = new QFrame ( tab );
f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken );
vertLayout-> addWidget ( f );
vertLayout-> addSpacing ( 3 );
QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 );
int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1;
bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" );
QLabel* label = new QLabel( tr( "Tab style:" ), tab );
gridLayout-> addWidget ( label, 0, 0 );
QWhatsThis::add( label, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) );
QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" );
btngrp-> hide ( );
btngrp-> setExclusive ( true );
m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" );
m_tabstyle_list-> insertItem ( tr( "Tabs" ));
m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" ));
m_tabstyle_list-> insertItem ( tr( "Drop down list" ));
m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" ));
m_tabstyle_list-> setCurrentItem ( style );
gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 );
QWhatsThis::add( m_tabstyle_list, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) );
m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" );
btngrp-> insert ( m_tabstyle_top );
gridLayout-> addWidget( m_tabstyle_top, 1, 1 );
QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) );
m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" );
btngrp-> insert ( m_tabstyle_bottom );
gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 );
QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) );
m_tabstyle_top-> setChecked ( tabtop );
m_tabstyle_bottom-> setChecked ( !tabtop );
m_original_tabstyle = style;
m_original_tabpos = tabtop;
vertLayout-> addSpacing ( 3 );
QHBoxLayout *rotLay = new QHBoxLayout ( vertLayout, 3 );
-
+
QLabel* rotlabel = new QLabel( tr( "Rotation direction:" ), tab );
m_rotdir_cw = new QRadioButton( tab, "rotdir_cw" );
QPixmap cw1 = Resource::loadIconSet("redo"). pixmap( );
m_rotdir_ccw = new QRadioButton( tab, "rotdir_ccw" );
QImage ccwImage = cw1. convertToImage( ). mirror( 1, 0 );
QPixmap ccw1;
m_rotdir_flip = new QRadioButton( tab, "rotdir_flip" );
QPixmap flip1 = Resource::loadIconSet("pass"). pixmap( );
QButtonGroup* rotbtngrp = new QButtonGroup( tab, "rotbuttongroup" );
rotbtngrp-> hide ( );
rotbtngrp-> setExclusive ( true );
rotbtngrp-> insert ( m_rotdir_cw );
rotbtngrp-> insert ( m_rotdir_ccw );
rotbtngrp-> insert ( m_rotdir_flip );
ccw1. convertFromImage( ccwImage );
m_rotdir_cw-> setPixmap( cw1 );
- m_rotdir_ccw-> setPixmap( ccw1 );
- m_rotdir_flip-> setPixmap( flip1 );
+ m_rotdir_ccw-> setPixmap( ccw1 );
+ m_rotdir_flip-> setPixmap( flip1 );
rotLay-> addWidget ( rotlabel, 0 );
rotLay-> addWidget ( m_rotdir_cw, 0 );
rotLay-> addWidget ( m_rotdir_ccw, 0 );
rotLay-> addWidget ( m_rotdir_flip, 0 );
int rotDirection = cfg.readNumEntry( "rotatedir" );
ODirection rot = CW;
if (rotDirection == -1) {
rot = ODevice::inst ( )-> direction ( );
} else {
rot = (ODirection)rotDirection;
}
m_rotdir_cw-> setChecked ( rot == CW );
m_rotdir_ccw-> setChecked ( rot == CCW );
m_rotdir_flip-> setChecked ( rot == Flip );
return tab;
}
Appearance::Appearance( QWidget* parent, const char* name, WFlags )
: QDialog ( parent, name, true, WStyle_ContextHelp )
{
setCaption( tr( "Appearance Settings" ) );
Config config( "qpe" );
config.setGroup( "Appearance" );
QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 );
m_sample = new SampleWindow ( this );
- m_sample-> setDecoration ( new DefaultWindowDecoration ( ));
+
+ m_sample-> setDecoration ( new DefaultWindowDecoration ( ) );
QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) );
OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom );
QWidget *styletab;
m_color_list = 0;
tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" ));
tw-> addTab ( createFontTab ( tw, config ), "font", tr( "Font" ));
tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) );
tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) );
tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) );
top-> addWidget ( tw, 10 );
top-> addWidget ( m_sample, 1 );
tw-> setCurrentTab ( styletab );
connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * )));
m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false;
}
Appearance::~Appearance()
{
}
void Appearance::tabChanged ( QWidget *w )
{
if ( w == m_advtab ) {
m_sample-> hide ( );
updateGeometry ( ); // shouldn't be necessary ...
}
else
m_sample-> show ( );
}
void Appearance::accept ( )
{
bool newtabpos = m_tabstyle_top-> isChecked ( );
int newtabstyle = m_tabstyle_list-> currentItem ( );
Config config ( "qpe" );
config. setGroup ( "Appearance" );
if ( m_style_changed ) {
StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( ));
if ( item )
config.writeEntry( "Style", item-> key ( ));
diff --git a/noncore/settings/appearance2/colorlistitem.h b/noncore/settings/appearance2/colorlistitem.h
index 10e4468..f8d5c45 100644
--- a/noncore/settings/appearance2/colorlistitem.h
+++ b/noncore/settings/appearance2/colorlistitem.h
@@ -79,62 +79,63 @@ public:
for ( int i = 0; i < s_colorcount; i++ )
cfg. writeEntry ( s_colorlut [i]. m_key, m_colors [i]. name ( ));
return true;
}
QColor color ( QColorGroup::ColorRole role )
{
int i = r2i ( role );
return i >= 0 ? m_colors [i] : QColor ( );
}
void setColor ( QColorGroup::ColorRole role, QColor c )
{
int i = r2i ( role );
if ( i >= 0 ) {
m_colors [i] = c;
buildPalette ( );
}
}
QString label ( QColorGroup::ColorRole role )
{
int i = r2i ( role );
return i >= 0 ? qApp-> translate ( "Appearance", s_colorlut [i]. m_label ) : QString::null;
}
private:
QPalette m_palette;
QColor *m_colors;
static struct colorlut {
QColorGroup::ColorRole m_role;
const char * m_key;
const char * m_def;
const char * m_label;
} const s_colorlut [];
static const int s_colorcount;
static int r2i ( QColorGroup::ColorRole role )
{
for ( int i = 0; i < s_colorcount; i++ ) {
if ( s_colorlut [i]. m_role == role )
return i;
}
return -1;
}
};
+// from etc/colors/Liquid.scheme
const ColorListItem::colorlut ColorListItem::s_colorlut [] = {
{ QColorGroup::Base, "Base", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Base" ) },
- { QColorGroup::Background, "Background", "#E5E1D5", QT_TRANSLATE_NOOP( "Appearance", "Background" ) },
- { QColorGroup::Button, "Button", "#D6CDBB", QT_TRANSLATE_NOOP( "Appearance", "Button" ) },
+ { QColorGroup::Background, "Background", "#E0E0E0", QT_TRANSLATE_NOOP( "Appearance", "Background" ) },
+ { QColorGroup::Button, "Button", "#96c8fa", QT_TRANSLATE_NOOP( "Appearance", "Button" ) },
{ QColorGroup::ButtonText, "ButtonText", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Button Text" ) },
- { QColorGroup::Highlight, "Highlight", "#800000", QT_TRANSLATE_NOOP( "Appearance", "Highlight" ) },
+ { QColorGroup::Highlight, "Highlight", "#73adef", QT_TRANSLATE_NOOP( "Appearance", "Highlight" ) },
{ QColorGroup::HighlightedText, "HighlightedText", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Highlighted Text" ) },
{ QColorGroup::Text, "Text", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Text" ) }
};
const int ColorListItem::s_colorcount = sizeof( s_colorlut ) / sizeof ( s_colorlut [0] );
#endif
diff --git a/noncore/settings/appearance2/decolistitem.h b/noncore/settings/appearance2/decolistitem.h
index d190ceb..da7924c 100644
--- a/noncore/settings/appearance2/decolistitem.h
+++ b/noncore/settings/appearance2/decolistitem.h
@@ -58,49 +58,50 @@ public:
}
bool hasSettings ( ) const
{
// return ( m_settings_if );
return false;
}
QWidget *settings ( QWidget * /*parent*/ )
{
// return m_settings_if ? m_settings_if-> create ( parent ) : 0;
return 0;
}
bool setSettings ( bool /*accepted*/ )
{
// if ( !m_settings_if )
// return false;
// if ( accepted )
// return m_settings_if-> accept ( );
// else {
// m_settings_if-> reject ( );
// return false;
// }
return false;
}
QString key ( )
{
if ( m_lib )
return QFileInfo ( m_lib-> library ( )). fileName ( );
else
return text ( );
}
WindowDecorationInterface *interface ( )
{
return m_window_if;
}
private:
QLibrary *m_lib;
WindowDecorationInterface *m_window_if;
// WindowDecorationSettingsInterface *m_settings_if;
};
-#endif \ No newline at end of file
+#endif
+
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp
index 4ff6be1..922523b 100644
--- a/noncore/settings/backup/backuprestore.cpp
+++ b/noncore/settings/backup/backuprestore.cpp
@@ -26,108 +26,99 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
#define HEADER_NAME 0
#define HEADER_BACKUP 1
#define BACKUP_LOCATION 2
#define EXTENSION ".bck"
const QString tempFileName = "/tmp/backup.err";
BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name)
: BackupAndRestoreBase(parent, name){
this->showMaximized();
backupList->header()->hide();
restoreList->header()->hide();
connect(backupButton, SIGNAL(clicked()),
this, SLOT(backupPressed()));
connect(restoreButton, SIGNAL(clicked()),
this, SLOT(restore()));
connect(backupList, SIGNAL(clicked( QListViewItem * )),
this, SLOT(selectItem(QListViewItem*)));
connect(restoreSource, SIGNAL(activated( int )),
this, SLOT(sourceDirChanged(int)));
connect(updateList, SIGNAL(clicked()),
this, SLOT( fileListUpdate()));
applicationSettings = new QListViewItem(backupList, "Application Settings", "",
QDir::homeDirPath() + "/Settings/");
selectItem(applicationSettings);
applicationSettings = new QListViewItem(backupList, "Application Data", "",
QDir::homeDirPath() + "/Applications/");
selectItem(applicationSettings);
documents= new QListViewItem(backupList, "Documents", "",
QDir::homeDirPath() + "/Documents/");
selectItem(documents);
scanForApplicationSettings();
Config config("BackupAndRestore");
config.setGroup("General");
int totalLocations = config.readNumEntry("totalLocations",0);
//todo make less static here and use Storage class to get infos
if(totalLocations == 0){
-
-/* Ramses has a CF-Slot, but that one is internal and you have to dismount the
- * the case. There's also almost always a WLAN card inserted there
-*/
-
backupLocations.insert("Documents", "/root/Documents");
-#if defined(QT_QWS_RAMSES)
- backupLocations.insert("MMC", "/mnt/card");
-#else
backupLocations.insert("CF", "/mnt/cf");
backupLocations.insert("SD", "/mnt/card");
-#endif
}
else{
for(int i = 0; i < totalLocations; i++){
backupLocations.insert(config.readEntry(QString("backupLocationName_%1").arg(i)),
config.readEntry(QString("backupLocation_%1").arg(i)));
}
}
QMap<QString, QString>::Iterator it;
for( it = backupLocations.begin(); it != backupLocations.end(); ++it ){
storeToLocation->insertItem(it.key());
restoreSource->insertItem(it.key());
}
// Read the list of items to ignore.
QList<QString> dontBackupList;
dontBackupList.setAutoDelete(true);
config.setGroup("DontBackup");
int total = config.readNumEntry("Total", 0);
for(int i = 0; i < total; i++){
dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), "")));
}
QList<QListViewItem> list;
getAllItems(backupList->firstChild(), list);
for(uint i = 0; i < list.count(); i++){
QString text = list.at(i)->text(HEADER_NAME);
for(uint i2 = 0; i2 < dontBackupList.count(); i2++){
if(*dontBackupList.at(i2) == text){
selectItem(list.at(i));
break;
}
}
}
}
BackupAndRestore::~BackupAndRestore(){
QList<QListViewItem> list;
getAllItems(backupList->firstChild(), list);
Config config("BackupAndRestore");
config.setGroup("DontBackup");
config.clearGroup();
int count = 0;
for(uint i = 0; i < list.count(); i++){
if(list.at(i)->text(HEADER_BACKUP) == ""){
config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME));
diff --git a/noncore/settings/language/language.cpp b/noncore/settings/language/language.cpp
index 8985fd5..d30a041 100644
--- a/noncore/settings/language/language.cpp
+++ b/noncore/settings/language/language.cpp
@@ -70,83 +70,83 @@ LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl
langAvail.append(name);
Config conf( desktopFile.filePath(), Config::File );
QString langName = conf.readEntry( "Name" );
QString ownName = conf.readEntryDirect( "Name[" + name + "]" );
if ( ownName.isEmpty() )
ownName = conf.readEntryDirect( "Name" );
if ( !ownName.isEmpty() && ownName != langName )
langName = langName + " [" + ownName + "]";
languages->insertItem( langName );
}
}
if ( langAvail. find ( "en" ) == -1 ) {
langAvail. prepend ( "" ); // no tr
languages-> insertItem ( QString ( "English [%1] (%2)" /* no tr (!) */ ). arg ( tr ( "English" )). arg ( tr( "default" )), 0 );
}
dl = new QPEDialogListener(this);
reset();
}
LanguageSettings::~LanguageSettings()
{}
void LanguageSettings::accept()
{
applyLanguage();
QDialog::accept();
}
void LanguageSettings::applyLanguage()
{
setLanguage ( langAvail. at ( languages-> currentItem ( )));
}
void LanguageSettings::reject()
{
reset();
QDialog::reject();
}
void LanguageSettings::reset()
{
QString l = getenv("LANG");
Config config("locale");
config.setGroup("Language");
l = config.readEntry( "Language", l );
+ actualLanguage = l;
if (l.isEmpty())
l = "en";
- actualLanguage = l;
int n = langAvail.find( l );
languages->setCurrentItem( n );
}
QString LanguageSettings::actualLanguage;
void LanguageSettings::setLanguage(const QString& lang)
{
if ( lang != actualLanguage ) {
Config config("locale");
config.setGroup( "Language" );
if ( lang. isEmpty ( ))
config. removeEntry ( "Language" );
else
config.writeEntry( "Language", lang );
config.write();
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
QCopEnvelope e("QPE/System", "language(QString)");
e << lang;
#endif
}
}
void LanguageSettings::done(int r)
{
QDialog::done(r);
close();
}
diff --git a/noncore/settings/mediummount/mainwindow.cc b/noncore/settings/mediummount/mainwindow.cc
index 6b37cff..eec786c 100644
--- a/noncore/settings/mediummount/mainwindow.cc
+++ b/noncore/settings/mediummount/mainwindow.cc
@@ -1,64 +1,65 @@
#include <qtabwidget.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qpe/storage.h>
#include "mediumwidget.h"
#include "mediumglobal.h"
#include "mainwindow.h"
using namespace MediumMountSetting;
+/* TRANSLATOR MediumMountSetting::MainWindow */
MainWindow::MainWindow( QWidget *parent, const char *name, bool modal, WFlags )
: QDialog( parent, name, modal, WStyle_ContextHelp )
{
setCaption ( tr( "Medium Mount Settings" ));
m_lay = new QVBoxLayout( this );
m_tab = new QTabWidget( this );
m_lay->addWidget( m_tab );
init();
}
MainWindow::~MainWindow()
{
}
void MainWindow::init()
{
m_global = new MediumGlobalWidget( m_tab, "test drive" );
m_tab->addTab( m_global, tr("Global") );
StorageInfo storage;
const QList<FileSystem> &fs = storage.fileSystems();
QListIterator<FileSystem> it( fs );
MediumMountWidget *wid;
for( ; it.current(); ++it ){
if( (*it)->isRemovable() ){
wid = new MediumMountWidget((*it)->path(), QPixmap(), m_tab );
m_mediums.append( wid );
m_tab->addTab( wid, (*it)->name() );
}
}
}
void MainWindow::accept()
{
m_global->writeConfig();
MediumMountWidget *confWidget;
for ( confWidget = m_mediums.first(); confWidget != 0;
confWidget = m_mediums.next() ) {
confWidget->writeConfig();
}
diff --git a/noncore/settings/mediummount/mediumglobal.cc b/noncore/settings/mediummount/mediumglobal.cc
index 75e3839..ab0b3af 100644
--- a/noncore/settings/mediummount/mediumglobal.cc
+++ b/noncore/settings/mediummount/mediumglobal.cc
@@ -1,65 +1,67 @@
#include <qlineedit.h>
#include <qcheckbox.h>
#include <qlabel.h>
#include <qabstractlayout.h> // spacer item
#include <qlayout.h>
#include <qframe.h>
#include <qgroupbox.h>
#include <qwhatsthis.h>
#include <qpe/config.h>
#include "mediumglobal.h"
using namespace MediumMountSetting;
+/* TRANSLATOR MediumMountSetting::MediumGlobalWidget */
+
MediumGlobalWidget::MediumGlobalWidget(QWidget *wid, const char *name )
: QWidget( wid, name, WStyle_ContextHelp )
{
m_config = 0;
initGUI();
readConfig();
}
void MediumGlobalWidget::initGUI()
{
m_layout = new QVBoxLayout(this );
m_layout->setMargin( 4 );
// m_layout->setSpacing( 10 );
m_label = new QLabel( this );
m_label->setTextFormat( Qt::RichText );
m_label->setText( tr("") );
QWhatsThis::add( this, tr("If a medium gets inserted into this device Opie "
"tries to search the medium for Documents. On "
"large mediums this can take some time. You can choose "
"if Opie should scan for Documents globally or on a "
"per medium level. You're also able to reconfigure "
"each medium.") );
m_layout->addWidget( m_label );
m_check = new QCheckBox( tr("Enable medium checking" ), this );
connect( m_check, SIGNAL(stateChanged(int) ),
this, SLOT(slotEnableChecking() ) );
m_layout->addWidget(m_check );
m_frame = new QFrame(this, "Frame" );
m_frame->setFrameShape( QFrame::Box );
m_frame->setFrameShadow( QFrame::Sunken );
m_box = new QVBoxLayout( m_frame );
m_box->setMargin( 5 );
m_useglobal = new QCheckBox( tr("Use global settings"), m_frame );
connect( m_useglobal, SIGNAL( stateChanged(int) ),
this, SLOT( slotGlobalChanged() ) );
m_box->addWidget( m_useglobal );
m_global = new QGroupBox( tr("Which media files"), m_frame );
m_frameLay = new QGridLayout(m_global, 4, 3 );
m_frameLay->setMargin( 10 );
diff --git a/noncore/settings/mediummount/mediumwidget.cc b/noncore/settings/mediummount/mediumwidget.cc
index eadf502..981e1dd 100644
--- a/noncore/settings/mediummount/mediumwidget.cc
+++ b/noncore/settings/mediummount/mediumwidget.cc
@@ -1,72 +1,74 @@
#include <qcheckbox.h>
#include <qgroupbox.h>
#include <qhbox.h>
#include <qlabel.h>
#include <qabstractlayout.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qpixmap.h>
#include <qpushbutton.h>
#include <qvbox.h>
#include <qwhatsthis.h>
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
#include "mediumwidget.h"
using namespace MediumMountSetting;
+/* TRANSLATOR MediumMountSetting::MediumMountWidget */
+
MediumMountWidget::MediumMountWidget(const QString &path,
const QPixmap &pix,
QWidget *parent,
const char *name )
: QWidget( parent, name )
{
if(parent == 0){
resize(QApplication::desktop()->width(), QApplication::desktop()->height() );
}else{
resize(parent->width(), parent->height() );
}
m_path = path;
initGUI();
m_label->setPixmap(pix );
m_config = 0;
readConfig();
}
// now we fire up the GUI
// if I would know what I'm doing ;)
void MediumMountWidget::initGUI()
{
//main layout
m_box = new QVBoxLayout( this , 5, 5 );
//m_box->setSpacing( 5 );
//m_box->addStretch( -1 );
// picture + text
m_infoBox = new QHBox(this, "infobox" );
//m_infoBox->setSpacing( 4 );
m_label = new QLabel(m_infoBox );
m_desc = new QLabel(m_infoBox );
m_desc->setTextFormat( Qt::RichText );
QWhatsThis::add( this, tr("Configure this medium. The changes will"
" go into effect when the application gets"
" closed. To update the Document Tab you need"
" to remove and insert this medium."));
m_desc->setText("" );
m_box->addWidget( m_infoBox ); // add the widget to the layout
// groupbox
m_group = new QGroupBox(tr("Which media files"), this, "MediaFiles" );
m_checks = new QGridLayout( m_group, 4, 3 );
//m_checks->setMargin( 12 );
diff --git a/noncore/settings/networksettings/interfaces/interface.cpp b/noncore/settings/networksettings/interfaces/interface.cpp
index cc45525..69b55d1 100644
--- a/noncore/settings/networksettings/interfaces/interface.cpp
+++ b/noncore/settings/networksettings/interfaces/interface.cpp
@@ -1,302 +1,302 @@
/**
* $Author$
* $Date$
- */
+ */
#include "interface.h"
#include <qdatetime.h>
#include <qfile.h>
#include <qdir.h>
#include <qfileinfo.h>
#include <qtextstream.h>
#define IFCONFIG "/sbin/ifconfig"
#define DHCP_INFO_DIR "/etc/dhcpc"
#include <stdio.h>
#include <stdlib.h>
Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), hardwareName("Unknown"), moduleOwner(NULL), status(newSatus), attached(false), dhcp(false), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"){
refresh();
}
/**
* Set status
* @param newStatus - the new status
* emit updateInterface
- */
+ */
void Interface::setStatus(bool newStatus){
if(status != newStatus){
status = newStatus;
refresh();
}
};
/**
* Set if attached or not (802.11 card pulled out for example)
* @param isAttached - if attached
* emit updateInterface
- */
+ */
void Interface::setAttached(bool isAttached){
attached = isAttached;
emit(updateInterface(this));
};
-
+
/**
* Set Hardware name
* @param name - the new name
* emit updateInterface
- */
+ */
void Interface::setHardwareName(const QString &name){
hardwareName = name;
emit(updateInterface(this));
};
-
+
/**
* Set Module owner
* @param owner - the new owner
* emit updateInterface
- */
+ */
void Interface::setModuleOwner(Module *owner){
moduleOwner = owner;
emit(updateInterface(this));
};
/**
* Try to start the interface.
- */
+ */
void Interface::start(){
- // check to see if we are already running.
+ // check to see if we are already running.
if(true == status){
emit (updateMessage("Unable to start interface,\n already started"));
return;
}
-
+
int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1());
// See if it was successfull...
if(ret != 0){
emit (updateMessage("Starting interface failed"));
return;
}
status = true;
refresh();
emit (updateMessage("Start successfull"));
}
/**
* Try to stop the interface.
*/
void Interface::stop(){
- // check to see if we are already stopped.
+ // check to see if we are already stopped.
if(false == status){
emit (updateMessage("Unable to stop interface,\n already stopped"));
return;
}
-
+
int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1());
if(ret != 0){
emit (updateMessage("Stopping interface failed"));
return;
}
status = false;
refresh();
emit (updateMessage("Stop successfull"));
}
/**
* Try to restart the interface.
- */
+ */
void Interface::restart(){
stop();
start();
}
/**
* Try to refresh the information about the interface.
* First call ifconfig, then check the dhcp-info file
* @return bool true if successfull.
*/
bool Interface::refresh(){
// See if we are up.
if(status == false){
macAddress = "";
ip = "0.0.0.0";
subnetMask = "0.0.0.0";
broadcast = "";
dhcp = false;
dhcpServerIp = "";
leaseObtained = "";
leaseExpires = "";
emit(updateInterface(this));
return true;
}
-
+
QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name());
- int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1());
+ int ret = system(QString("LANG=C %1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1());
if(ret != 0){
qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1());
return false;
}
-
+
QFile file(fileName);
if (!file.open(IO_ReadOnly)){
qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
return false;
}
// Set to the defaults
macAddress = "";
ip = "0.0.0.0";
subnetMask = "0.0.0.0";
broadcast = "";
-
+
QTextStream stream( &file );
QString line;
while ( !stream.eof() ) {
line = stream.readLine();
if(line.contains("HWaddr")){
int mac = line.find("HWaddr");
macAddress = line.mid(mac+7, line.length());
}
if(line.contains("inet addr")){
int ipl = line.find("inet addr");
int space = line.find(" ", ipl+10);
ip = line.mid(ipl+10, space-ipl-10);
}
if(line.contains("Mask")){
int mask = line.find("Mask");
subnetMask = line.mid(mask+5, line.length());
}
if(line.contains("Bcast")){
int mask = line.find("Bcast");
int space = line.find(" ", mask+6);
broadcast = line.mid(mask+6, space-mask-6);
}
}
file.close();
QFile::remove(fileName);
// DHCP TESTING
// reset DHCP info
dhcpServerIp = "";
leaseObtained = "";
leaseExpires = "";
dhcp = false;
-
+
QString dhcpDirectory(DHCP_INFO_DIR);
QDir d(dhcpDirectory);
if(!d.exists(dhcpDirectory))
dhcpDirectory = "/var/run";
-
- // See if we have
+
+ // See if we have
QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name()));
// If there is no DHCP information then exit now with no errors.
if(!QFile::exists(dhcpFile)){
emit(updateInterface(this));
return true;
}
-
+
file.setName(dhcpFile);
if (!file.open(IO_ReadOnly)){
qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
return false;
}
-
+
// leaseTime and renewalTime and used if pid and deamon exe can be accessed.
int leaseTime = 0;
int renewalTime = 0;
-
+
stream.setDevice( &file );
while ( !stream.eof() ) {
line = stream.readLine();
if(line.contains("DHCPSIADDR="))
dhcpServerIp = line.mid(11, line.length());
if(line.contains("LEASETIME="))
leaseTime = line.mid(10, line.length()).toInt();
if(line.contains("RENEWALTIME="))
renewalTime = line.mid(12, line.length()).toInt();
}
file.close();
//qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
//qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
-
+
// Get the pid of the deamond
dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name()));
file.setName(dhcpFile);
if (!file.open(IO_ReadOnly)){
qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
return false;
}
int pid = -1;
stream.setDevice( &file );
while ( !stream.eof() ) {
line = stream.readLine();
pid = line.toInt();
}
file.close();
if( pid == -1){
qDebug("Interface: Could not get pid of dhcpc deamon.");
return false;
}
- // Get the start running time of the deamon
+ // Get the start running time of the deamon
fileName = (QString("/proc/%1/stat").arg(pid));
file.setName(fileName);
stream.setDevice( &file );
if (!file.open(IO_ReadOnly)){
qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
return false;
}
while ( !stream.eof() ) {
line = stream.readLine();
}
file.close();
long time = 0;
- // Grab the start time
+ // Grab the start time
// pid com state ppid pgrp session tty_nr tpgid flags
sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u "
// minflt cminflt majflt cmajflt utime stime cutime cstime priority
"%*u %*u %*u %*u %*u %*u %*d %*d %*d "
// nice 0 itrealvalue starttime
"%*d %*d %*d %lu", (long*) &time);
time = time/100;
-
+
QDateTime datetime(QDateTime::currentDateTime());
// Get the uptime of the computer.
QFile f("/proc/uptime");
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
int sec = 0;
t >> sec;
datetime = datetime.addSecs((-1*sec));
f.close();
}
else{
qDebug("Interface: Can't open /proc/uptime to retrive uptime.");
return false;
}
-
+
datetime = datetime.addSecs(time);
//qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1());
-
- // Calculate the start and renew times
+
+ // Calculate the start and renew times
leaseObtained = datetime.toString();
-
- // Calculate the start and renew times
+
+ // Calculate the start and renew times
datetime = datetime.addSecs(leaseTime);
leaseExpires = datetime.toString();
-
+
dhcp = true;
-
+
emit(updateInterface(this));
return true;
}
// interface.cpp
diff --git a/noncore/settings/networksettings/interfaces/interface.h b/noncore/settings/networksettings/interfaces/interface.h
index 7e98deb..ec82851 100644
--- a/noncore/settings/networksettings/interfaces/interface.h
+++ b/noncore/settings/networksettings/interfaces/interface.h
@@ -1,73 +1,73 @@
#ifndef INTERFACE_H
#define INTERFACE_H
#include <qstring.h>
#include <qobject.h>
class Module;
class Interface : public QObject{
Q_OBJECT
signals:
void updateInterface(Interface *i);
void updateMessage(const QString &message);
-
+
public:
Interface(QObject * parent=0, const char * name= "unknown", bool status = false);
-
+
QString getInterfaceName() const { QString n(this->name()); return n; };
void setInterfaceName( const QString &n ) { this->setName(n); };
-
+
bool getStatus() const { return status; };
void setStatus(bool newStatus);
bool isAttached() const { return attached; };
void setAttached(bool isAttached=false);
-
+
QString getHardwareName() const { return hardwareName; };
void setHardwareName(const QString &name="Unknown");
-
+
Module* getModuleOwner() const { return moduleOwner; };
void setModuleOwner(Module *owner=NULL);
// inet information.
QString getMacAddress() const { return macAddress; };
QString getIp() const { return ip; };
QString getSubnetMask() const { return subnetMask; };
QString getBroadcast() const { return broadcast; };
bool isDhcp() const { return dhcp; };
QString getDhcpServerIp() const { return dhcpServerIp; };
QString getLeaseObtained() const { return leaseObtained; };
QString getLeaseExpires() const { return leaseExpires; };
public slots:
virtual bool refresh();
virtual void start();
virtual void stop();
virtual void restart();
-private:
+protected:
// Interface information
QString hardwareName;
Module *moduleOwner;
bool status;
bool attached;
// Network information
bool dhcp;
QString dhcpServerIp;
QString leaseObtained;
QString leaseExpires;
QString macAddress;
QString ip;
QString broadcast;
QString subnetMask;
};
#endif
// interface.h
diff --git a/noncore/settings/networksettings/interfaces/interfaceadvanced.ui b/noncore/settings/networksettings/interfaces/interfaceadvanced.ui
index 2e106cb..12dbb1d 100644
--- a/noncore/settings/networksettings/interfaces/interfaceadvanced.ui
+++ b/noncore/settings/networksettings/interfaces/interfaceadvanced.ui
@@ -1,69 +1,69 @@
<!DOCTYPE UI><UI>
<class>InterfaceAdvanced</class>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>InterfaceAdvanced</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
<width>214</width>
<height>290</height>
</rect>
</property>
<property stdset="1">
<name>maximumSize</name>
<size>
- <width>240</width>
+ <width>32767</width>
<height>32767</height>
</size>
</property>
<property stdset="1">
<name>caption</name>
<string>Advanced Interface Information</string>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget row="0" column="1" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>interfaceName</cstring>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>Panel</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
<enum>Sunken</enum>
</property>
<property stdset="1">
<name>text</name>
<string>eth0</string>
</property>
</widget>
<widget row="1" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel3</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>IP Address</string>
</property>
</widget>
<widget row="0" column="0" >
<class>QLabel</class>
diff --git a/noncore/settings/networksettings/interfaces/interfaceinformation.ui b/noncore/settings/networksettings/interfaces/interfaceinformation.ui
index 763ad90..207200e 100644
--- a/noncore/settings/networksettings/interfaces/interfaceinformation.ui
+++ b/noncore/settings/networksettings/interfaces/interfaceinformation.ui
@@ -1,321 +1,338 @@
<!DOCTYPE UI><UI>
<class>InterfaceInformation</class>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>InterfaceInformation</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
<width>219</width>
- <height>255</height>
+ <height>323</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Interface Information</string>
</property>
- <grid>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <vbox>
<property stdset="1">
<name>margin</name>
- <number>11</number>
+ <number>4</number>
</property>
<property stdset="1">
<name>spacing</name>
- <number>6</number>
+ <number>3</number>
</property>
- <widget row="4" column="0" rowspan="1" colspan="2" >
- <class>QLayoutWidget</class>
- <property stdset="1">
- <name>name</name>
- <cstring>Layout1</cstring>
- </property>
- <grid>
- <property stdset="1">
- <name>margin</name>
- <number>0</number>
- </property>
- <property stdset="1">
- <name>spacing</name>
- <number>6</number>
- </property>
- <widget row="1" column="0" >
- <class>QPushButton</class>
- <property stdset="1">
- <name>name</name>
- <cstring>refreshButton</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>&amp;Refresh</string>
- </property>
- </widget>
- <widget row="0" column="1" >
- <class>QPushButton</class>
- <property stdset="1">
- <name>name</name>
- <cstring>stopButton</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>S&amp;top</string>
- </property>
- </widget>
- <widget row="1" column="1" >
- <class>QPushButton</class>
- <property stdset="1">
- <name>name</name>
- <cstring>restartButton</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>R&amp;estart</string>
- </property>
- </widget>
- <widget row="0" column="0" >
- <class>QPushButton</class>
- <property stdset="1">
- <name>name</name>
- <cstring>startButton</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>&amp;Start</string>
- </property>
- </widget>
- </grid>
- </widget>
- <widget row="0" column="0" >
- <class>Line</class>
- <property stdset="1">
- <name>name</name>
- <cstring>Line1</cstring>
- </property>
- <property stdset="1">
- <name>orientation</name>
- <enum>Horizontal</enum>
- </property>
- </widget>
- <widget row="0" column="0" >
+ <widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel22</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>IP Address</string>
</property>
</widget>
- <widget row="1" column="0" >
+ <widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
- <cstring>TextLabel23</cstring>
+ <cstring>ipAddressLabel</cstring>
</property>
<property stdset="1">
- <name>text</name>
- <string>Subnet Mask</string>
+ <name>frameShape</name>
+ <enum>Panel</enum>
</property>
- </widget>
- <widget row="2" column="0" >
- <class>QLabel</class>
<property stdset="1">
- <name>name</name>
- <cstring>TextLabel21</cstring>
+ <name>frameShadow</name>
+ <enum>Sunken</enum>
</property>
<property stdset="1">
<name>text</name>
- <string>MAC Address</string>
+ <string>0.0.0.0</string>
</property>
</widget>
- <widget row="3" column="0" >
- <class>QLabel</class>
+ <widget>
+ <class>Line</class>
<property stdset="1">
<name>name</name>
- <cstring>TextLabel24</cstring>
+ <cstring>Line1</cstring>
</property>
<property stdset="1">
- <name>frameShape</name>
- <enum>MShape</enum>
+ <name>orientation</name>
+ <enum>Horizontal</enum>
</property>
+ </widget>
+ <widget>
+ <class>QLabel</class>
<property stdset="1">
- <name>frameShadow</name>
- <enum>MShadow</enum>
+ <name>name</name>
+ <cstring>TextLabel23</cstring>
</property>
<property stdset="1">
<name>text</name>
- <string>Broadcast</string>
+ <string>Subnet Mask</string>
</property>
</widget>
- <widget row="1" column="1" >
+ <widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>subnetMaskLabel</cstring>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>Panel</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
<enum>Sunken</enum>
</property>
<property stdset="1">
<name>text</name>
<string>0.0.0.0</string>
</property>
</widget>
- <widget row="2" column="1" >
+ <widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>macAddressLabel</cstring>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>Panel</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
<enum>Sunken</enum>
</property>
<property stdset="1">
<name>text</name>
<string>00:00:00:00:00:00</string>
</property>
</widget>
- <widget row="3" column="1" >
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel21</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>MAC Address</string>
+ </property>
+ </widget>
+ <widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>broadcastLabel</cstring>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>Panel</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
<enum>Sunken</enum>
</property>
<property stdset="1">
<name>text</name>
<string></string>
</property>
</widget>
- <widget row="0" column="1" >
+ <widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
- <cstring>ipAddressLabel</cstring>
+ <cstring>TextLabel24</cstring>
</property>
<property stdset="1">
<name>frameShape</name>
- <enum>Panel</enum>
+ <enum>MShape</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
- <enum>Sunken</enum>
+ <enum>MShadow</enum>
</property>
<property stdset="1">
<name>text</name>
- <string>0.0.0.0</string>
+ <string>Broadcast</string>
</property>
</widget>
- <spacer row="7" column="1" >
- <property>
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
<name>name</name>
- <cstring>Spacer18</cstring>
+ <cstring>Layout1</cstring>
</property>
+ <grid>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget row="1" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>refreshButton</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>&amp;Refresh</string>
+ </property>
+ </widget>
+ <widget row="0" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>stopButton</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>S&amp;top</string>
+ </property>
+ </widget>
+ <widget row="1" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>restartButton</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>R&amp;estart</string>
+ </property>
+ </widget>
+ <widget row="0" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>startButton</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>&amp;Start</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget>
+ <class>Line</class>
<property stdset="1">
- <name>orientation</name>
- <enum>Vertical</enum>
+ <name>name</name>
+ <cstring>Line5</cstring>
</property>
<property stdset="1">
- <name>sizeType</name>
- <enum>Expanding</enum>
- </property>
- <property>
- <name>sizeHint</name>
- <size>
- <width>20</width>
- <height>20</height>
- </size>
+ <name>orientation</name>
+ <enum>Horizontal</enum>
</property>
- </spacer>
- <widget row="6" column="0" rowspan="1" colspan="2" >
+ </widget>
+ <widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout2</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<spacer>
<property>
<name>name</name>
<cstring>Spacer10</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>advancedButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;View Advanced Information</string>
</property>
</widget>
</hbox>
</widget>
- <widget row="5" column="0" rowspan="1" colspan="2" >
- <class>Line</class>
- <property stdset="1">
+ <spacer>
+ <property>
<name>name</name>
- <cstring>Line5</cstring>
+ <cstring>Spacer18</cstring>
</property>
<property stdset="1">
<name>orientation</name>
- <enum>Horizontal</enum>
+ <enum>Vertical</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget>
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>CheckBoxSilent</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>be &amp;silent</string>
</property>
</widget>
- </grid>
+ </vbox>
</widget>
<tabstops>
<tabstop>startButton</tabstop>
<tabstop>stopButton</tabstop>
<tabstop>refreshButton</tabstop>
<tabstop>restartButton</tabstop>
<tabstop>advancedButton</tabstop>
</tabstops>
</UI>
diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
index e00dcce..37c3a91 100644
--- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
@@ -1,79 +1,93 @@
#include "interfaceinformationimp.h"
#include "interfaceadvanced.h"
+#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qgroupbox.h>
#include <qmessagebox.h>
-#ifdef QWS
+#include <qpe/config.h>
+
+#ifdef QWS
#else
#define showMaximized show
#endif
/**
* Constructor for the InterfaceInformationImp class. This class pretty much
* just display's information about the interface that is passed to it.
- */
+ */
InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f), interface(i){
connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
connect(i, SIGNAL(updateMessage(const QString &)), this, SLOT(showMessage(const QString &)));
updateInterface(interface);
connect(startButton, SIGNAL(clicked()), interface, SLOT(start()));
connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop()));
connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart()));
connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh()));
connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced()));
+ Config cfg("networksettings", Config::User);
+ cfg.setGroup("interface");
+ CheckBoxSilent->setChecked( cfg.readBoolEntry("silent", false) );
+}
+
+InterfaceInformationImp::~InterfaceInformationImp()
+{
+ Config cfg("networksettings", Config::User);
+ cfg.setGroup("interface");
+ cfg.writeEntry("silent", CheckBoxSilent->isChecked() );
}
/**
* Update the interface information and buttons.
* @param Intarface *i the interface to update (should be the one we already
* know about).
- */
+ */
void InterfaceInformationImp::updateInterface(Interface *){
if(interface->getStatus()){
startButton->setEnabled(false);
stopButton->setEnabled(true);
restartButton->setEnabled(true);
}
else{
startButton->setEnabled(true);
stopButton->setEnabled(false);
restartButton->setEnabled(false);
}
macAddressLabel->setText(interface->getMacAddress());
ipAddressLabel->setText(interface->getIp());
subnetMaskLabel->setText(interface->getSubnetMask());
broadcastLabel->setText(interface->getBroadcast());
}
/**
* Create the advanced widget. Fill it with the current interface's information.
* Display it.
- */
+ */
void InterfaceInformationImp::advanced(){
InterfaceAdvanced *a = new InterfaceAdvanced(this, "InterfaceAdvanced", Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog);
a->interfaceName->setText(interface->getInterfaceName());
a->macAddressLabel->setText(interface->getMacAddress());
a->ipAddressLabel->setText(interface->getIp());
a->subnetMaskLabel->setText(interface->getSubnetMask());
a->broadcastLabel->setText(interface->getBroadcast());
a->dhcpServerLabel->setText(interface->getDhcpServerIp());
a->leaseObtainedLabel->setText(interface->getLeaseObtained());
a->leaseExpiresLabel->setText(interface->getLeaseExpires());
a->dhcpInformation->setEnabled(interface->isDhcp());
a->showMaximized();
}
/**
* Messages from the interface if start/stop went as planned.
* Purly for user feedback.
* @param message the message to display.
- */
+ */
void InterfaceInformationImp::showMessage(const QString &message){
+ if (CheckBoxSilent->isChecked()) return;
QMessageBox::information(this, "Message", message, QMessageBox::Ok);
}
// infoimp.cpp
diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.h b/noncore/settings/networksettings/interfaces/interfaceinformationimp.h
index 65cdfe0..9c93d1d 100644
--- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.h
+++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.h
@@ -1,28 +1,28 @@
#ifndef INTERFACEINFORMATIONIMP_H
#define INTERFACEINFORMATIONIMP_H
#include "interfaceinformation.h"
#include "interface.h"
class InterfaceInformationImp : public InterfaceInformation {
Q_OBJECT
public:
InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0);
- ~InterfaceInformationImp(){};
+ ~InterfaceInformationImp();
private slots:
void advanced();
void updateInterface(Interface *i);
void showMessage(const QString &message);
private:
Interface *interface;
};
#endif
// addserviceimp.h
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp
index 71d0cf5..436e449 100644
--- a/noncore/settings/networksettings/interfaces/interfaces.cpp
+++ b/noncore/settings/networksettings/interfaces/interfaces.cpp
@@ -1,50 +1,51 @@
#include "interfaces.h"
+#include <qcheckbox.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qregexp.h>
// The three stanza's
#define AUTO "auto"
#define IFACE "iface"
#define MAPPING "mapping"
/**
* Constructor. Reads in the interfaces file and then split the file up by
* the \n for interfaces variable.
* @param useInterfacesFile if an interface file other then the default is
* desired to be used it should be passed in.
*/
Interfaces::Interfaces(QString useInterfacesFile){
acceptedFamily.append(INTERFACES_FAMILY_INET);
acceptedFamily.append(INTERFACES_FAMILY_IPX);
acceptedFamily.append(INTERFACES_FAMILY_INET6);
interfacesFile = useInterfacesFile;
QFile file(interfacesFile);
if (!file.open(IO_ReadOnly)){
qDebug("Interfaces: Can't open file: %s for reading.", interfacesFile.latin1() );
currentIface = interfaces.end();
currentMapping = interfaces.end();
return;
}
QTextStream stream( &file );
QString line;
while ( !stream.eof() ) {
line += stream.readLine();
line += "\n";
}
file.close();
interfaces = QStringList::split("\n", line, true);
currentIface = interfaces.end();
currentMapping = interfaces.end();
}
/**
* Get a list of all interfaces in the interface file. Usefull for
* hardware that is not currently connected such as an 802.11b card
* not plugged in, but configured for when it is plugged in.
* @return Return string list of interfaces.
**/
@@ -106,111 +107,113 @@ bool Interfaces::setAuto(const QString &interface, bool setAuto){
if((*it).contains(interface)){
(*it) = (*it).replace(QRegExp(interface), "");
// if AUTO is the only thing left clear the line
if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == AUTO)
(*it) = "";
changed = true;
// Don't break because we want to make sure we remove all cases.
}
}
}
}
// In the case where there is no AUTO field add one.
if(!changed && setAuto)
interfaces.append(QString(AUTO" %1").arg(interface));
return true;
}
/**
* Set the current interface to interface. This needs to be done before you
* can call getFamily(), getMethod, and get/setOption().
* @param interface the name of the interface to set. All whitespace is
* removed from the interface name.
* @return bool true if it is successfull.
*/
bool Interfaces::setInterface(QString interface){
interface = interface.simplifyWhiteSpace();
interface = interface.replace(QRegExp(" "), "");
return setStanza(IFACE, interface, currentIface);
}
/**
* A quick helper funtion to see if the current interface is set.
* @return bool true if set, false otherwise.
*/
bool Interfaces::isInterfaceSet() const {
return (interfaces.end() != currentIface);
}
/**
* Add a new interface of with the settings - family and method
* @param interface the name of the interface to set. All whitespace is
* removed from the interface name.
* @param family the family of this interface inet or inet, ipx or inet6
* Must of one of the families defined in interfaces.h
* @param method for the family. see interfaces man page for family methods.
* @return true if successfull.
*/
bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){
+ qDebug("Interfaces::addInterface(%s)",interface.latin1());
if(0 == acceptedFamily.contains(family))
return false;
QString newInterface = interface.simplifyWhiteSpace();
newInterface = newInterface.replace(QRegExp(" "), "");
interfaces.append("");
interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method));
return true;
}
/**
* Copies interface with name interface to name newInterface
* @param newInterface name of the new interface.
* @return bool true if successfull
*/
bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){
+ qDebug("copy interface %s to %s", interface.latin1(), newInterface.latin1());
if(!setInterface(interface))
return false;
// Store the old interface and bump past the stanza line.
QStringList::Iterator it = currentIface;
it++;
// Add the new interface
bool error;
addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
if(!setInterface(newInterface))
return false;
QStringList::Iterator newIface = currentIface;
newIface++;
// Copy all of the lines
for ( ; it != interfaces.end(); ++it ){
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
break;
newIface = interfaces.insert(newIface, *it);
}
return true;
}
/**
* Remove the currently selected interface and all of its options.
* @return bool if successfull or not.
*/
bool Interfaces::removeInterface(){
return removeStanza(currentIface);
}
/**
* Gets the hardware name of the interface that is currently selected.
* @return QString name of the hardware interface (eth0, usb2, wlan1...).
* @param error set to true if any error occurs, false otherwise.
*/
QString Interfaces::getInterfaceName(bool &error){
if(currentIface == interfaces.end()){
error = true;
return QString();
}
QString line = (*currentIface);
line = line.mid(QString(IFACE).length() +1, line.length());
line = line.simplifyWhiteSpace();
int findSpace = line.find(" ");
@@ -227,158 +230,168 @@ QString Interfaces::getInterfaceName(bool &error){
* @return QString name of the family (inet, inet6, ipx).
* @param error set to true if any error occurs, false otherwise.
*/
QString Interfaces::getInterfaceFamily(bool &error){
QString name = getInterfaceName(error);
if(error)
return QString();
QString line = (*currentIface);
line = line.mid(QString(IFACE).length() +1, line.length());
line = line.mid(name.length()+1, line.length());
line = line.simplifyWhiteSpace();
int findSpace = line.find(" ");
if( findSpace < 0){
error = true;
return QString();
}
error = false;
return line.mid(0, findSpace);
}
/**
* Gets the method of the interface that is currently selected.
* @return QString name of the method such as staic or dhcp.
* See the man page of interfaces for possible methods depending on the family.
* @param error set to true if any error occurs, false otherwise.
*/
QString Interfaces::getInterfaceMethod(bool &error){
QString name = getInterfaceName(error);
if(error)
return QString();
QString family = getInterfaceFamily(error);
if(error)
return QString();
QString line = (*currentIface);
line = line.mid(QString(IFACE).length()+1, line.length());
line = line.mid(name.length()+1, line.length());
line = line.mid(family.length()+1, line.length());
line = line.simplifyWhiteSpace();
error = false;
return line;
}
/**
* Sets the interface name to newName.
* @param newName the new name of the interface. All whitespace is removed.
* @return bool true if successfull.
*/
bool Interfaces::setInterfaceName(const QString &newName){
+ qDebug("setInterfaceName %s", newName.latin1());
if(currentIface == interfaces.end())
return false;
QString name = newName.simplifyWhiteSpace();
name = name.replace(QRegExp(" "), "");
bool returnValue = false;
- (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
+ QString tmp = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
+ qDebug("setting %s",tmp.latin1());
+
+ (*currentIface) = tmp;
return !returnValue;
}
/**
* Sets the interface family to newName.
* @param newName the new name of the interface. Must be one of the families
* defined in the interfaces.h file.
* @return bool true if successfull.
*/
bool Interfaces::setInterfaceFamily(const QString &newName){
if(currentIface == interfaces.end())
return false;
if(acceptedFamily.contains(newName)==0)
return false;
bool returnValue = false;
(*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue));
return !returnValue;
}
/**
* Sets the interface method to newName
* @param newName the new name of the interface
* @return bool true if successfull.
*/
bool Interfaces::setInterfaceMethod(const QString &newName){
if(currentIface == interfaces.end())
return false;
bool returnValue = false;
(*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName);
return !returnValue;
}
/**
* Get a value for an option in the currently selected interface. For example
* calling getInterfaceOption("address") on the following stanza would
* return 192.168.1.1.
* iface eth0 static
* address 192.168.1.1
* @param option the options to get the value.
* @param error set to true if any error occurs, false otherwise.
* @return QString the options value. QString::null if error == true
*/
QString Interfaces::getInterfaceOption(const QString &option, bool &error){
return getOption(currentIface, option, error);
}
/**
* Set a value for an option in the currently selected interface. If option
* doesn't exist then it is added along with the value.
+ * If value isEmpty() then we will remove the option
+ *
* @param option the options to set the value.
* @param value the value that option should be set to.
* @param error set to true if any error occurs, false otherwise.
* @return QString the options value. QString::null if error == true
*/
bool Interfaces::setInterfaceOption(const QString &option, const QString &value){
- return setOption(currentIface, option, value);
+ if( value.stripWhiteSpace().isEmpty() )
+ return removeInterfaceOption( option );
+
+ qDebug("iface >%s< option >%s< value >%s<", (*currentIface).latin1(), option.latin1(),value.latin1());
+ return setOption(currentIface, option, value);
}
/**
* Removes a value for an option in the currently selected interface.
* @param option the options to set the value.
* @param error set to true if any error occurs, false otherwise.
* @return QString the options value. QString::null if error == true
*/
bool Interfaces::removeInterfaceOption(const QString &option){
return removeOption(currentIface, option);
}
/**
* Removes a value for an option in the currently selected interface.
* @param option the options to set the value.
* @param value the value that option should be set to.
* @param error set to true if any error occurs, false otherwise.
* @return QString the options value. QString::null if error == true
*/
bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){
return removeOption(currentIface, option, value);
}
/**
* Removes all of the options from the currently selected interface.
* @return bool error if if successfull
*/
bool Interfaces::removeAllInterfaceOptions(){
return removeAllOptions(currentIface);
}
/**
* Set the current map to interface's map. This needs to be done before you
* can call addMapping(), set/getMap(), and get/setScript().
* @param interface the name of the interface to set. All whitespace is
* removed from the interface name.
* @return bool true if it is successfull.
*/
bool Interfaces::setMapping(const QString &interface){
QString interfaceName = interface.simplifyWhiteSpace();
interfaceName = interfaceName.replace(QRegExp(" "), "");
return setStanza(MAPPING, interfaceName, currentMapping);
}
/**
* Adds a new Mapping to the interfaces file with interfaces.
* @param interface the name(s) of the interfaces to set to this mapping
*/
@@ -447,184 +460,205 @@ QString Interfaces::getScript(bool &error){
/**
* Helper function used to parse through the QStringList and put pointers in
* the correct place.
* @param stanza The stanza (auto, iface, mapping) to look for.
* @param option string that must be in the stanza's main line.
* @param interator interator to place at location of stanza if successfull.
* @return bool true if the stanza is found.
*/
bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){
bool found = false;
iterator = interfaces.end();
for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
QString line = (*it).simplifyWhiteSpace();
if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){
uint point = line.find(option);
bool valid = true;
if(point > 0){
// There are more chars in the line. check +1
if(line.at(point-1) != ' ')
valid = false;
}
point += option.length();
if(point < line.length()-1){
// There are more chars in the line. check -1
if(line.at(point) != ' ')
valid = false;
}
if(valid){
if(found == true){
qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
}
found = true;
iterator = it;
}
}
}
return found;
}
/**
* Sets a value of an option in a stanza
* @param start the start of the stanza
* @param option the option to use when setting value.
* @return bool true if successfull, false otherwise.
*/
bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){
if(start == interfaces.end())
return false;
-
+ qDebug("setting option");
bool found = false;
+ bool replaced = false;
+ QStringList::Iterator insertAt = NULL;
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
- if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
- if(!found && value != ""){
- // Got to the end of the stanza without finding it, so append it.
- interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
- }
- found = true;
- break;
- }
+ qDebug(" Interfaces::setOption got line >%s<",(*it).latin1());
+ // FIXME: was not completly stupid just wrong sice all options got inserted bevore the iface line
+ // but since it works with an empty interfaces file I (tille) will not do anything more
+ if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) ){
+ if (found) break;
+// && it != start){
+// if(!found && value != ""){
+// // Got to the end of the stanza without finding it, so append it.
+// qDebug(" Got to the end of the stanza without finding it, so append it.");
+// interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
+// }
+ qDebug("found 1");
+// interfaces.insert(++it, QString("\t%1 %2").arg(option).arg(value));
+ found = true;
+ insertAt = it;
+
+ }
if((*it).contains(option) && it != start && (*it).at(0) != '#'){
// Found it in stanza so replace it.
+ qDebug("found 2");
if(found)
qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
found = true;
+ replaced = true;
(*it) = QString("\t%1 %2").arg(option).arg(value);
}
}
if(!found){
+ qDebug("! found insert anyway");
QStringList::Iterator p = start;
interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
found = true;
}
+
+ if(found && !replaced){
+ qDebug("found iface but not the option so insert it here...");
+ interfaces.insert(++insertAt, QString("\t%1 %2").arg(option).arg(value));
+ }
return found;
}
/**
* Removes a stanza and all of its options
* @param stanza the stanza to remove
* @return bool true if successfull.
*/
bool Interfaces::removeStanza(QStringList::Iterator &stanza){
if(stanza == interfaces.end())
return false;
(*stanza) = "";
return removeAllOptions(stanza);
}
/**
* Removes a option in a stanza
* @param start the start of the stanza
* @param option the option to remove
* @return bool true if successfull, false otherwise.
*/
bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){
if(start == interfaces.end())
return false;
bool found = false;
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
// got to the end without finding it
break;
}
if((*it).contains(option) && it != start && (*it).at(0) != '#'){
// Found it in stanza so replace it.
if(found)
qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
found = true;
- (*it) = "";
+ it = interfaces.remove( it ); // we really want to remove the line
+ --it; // we do ++it later in the head of the for loop
}
}
return found;
}
/**
* Removes a option in a stanza
* @param start the start of the stanza
* @param option the option to use when setting value.
* @return bool true if successfull, false otherwise.
*/
bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){
if(start == interfaces.end())
return false;
bool found = false;
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
// got to the end without finding it
break;
}
if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){
// Found it in stanza so replace it.
if(found)
qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
found = true;
- (*it) = "";
+ it = interfaces.remove( it ); // we really want to remove the line
+ --it; // we do ++it later in the head of the for loop
}
}
return found;
}
/**
* Removes all options in a stanza
* @param start the start of the stanza
* @return bool true if successfull, false otherwise.
*/
bool Interfaces::removeAllOptions(const QStringList::Iterator &start){
if(start == interfaces.end())
return false;
QStringList::Iterator it = start;
it = ++it;
for (; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
break;
}
it = interfaces.remove(it);
it = --it;
}
// Leave a space between this interface and the next.
interfaces.insert(it, QString(""));
return true;
}
/**
* Gets a value of an option in a stanza
* @param start the start of the stanza
* @param option the option to use when getting the value.
* @param bool true if errors false otherwise.
* @return QString the value of option QString::null() if error == true.
*/
QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){
if(start == interfaces.end()){
error = false;
return QString();
}
QString value;
bool found = false;
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
break;
}
if((*it).contains(option) && (*it).at(0) != '#'){
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
index b40d101..e844d8a 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
@@ -1,167 +1,171 @@
#include "interfacesetupimp.h"
#include "interface.h"
#include <qcheckbox.h>
#include <qlineedit.h>
#include <qspinbox.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qmessagebox.h>
#include <opie/oprocess.h>
#ifdef QWS
#include <opie/owait.h>
#include <qpe/global.h>
#include <qapplication.h>
#endif
#define DNSSCRIPT "changedns"
/**
* Constuctor. Set up the connection. A profile must be set.
*/
InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){
if (j == 0) {
delInterfaces = true;
interfaces = new Interfaces;
}
}
/**
* Destructor
*/
InterfaceSetupImp::~InterfaceSetupImp(){
if(delInterfaces) {
delete interfaces;
}
}
/**
* Save the current settings, then write out the interfaces file and close.
*/
bool InterfaceSetupImp::saveChanges(){
bool error;
QString iface = interfaces->getInterfaceName(error);
+ qDebug("InterfaceSetupImp::saveChanges saves interface %s", iface.latin1() );
if(!saveSettings())
return false;
interfaces->write();
if (interface->getStatus()) {
QString ifup;
ifup += "ifdown ";
ifup += iface;
ifup += "; ifup ";
ifup += iface;
ifup += ";";
OProcess restart;
restart << "sh";
restart << "-c";
restart << ifup;
OWait *owait = new OWait();
Global::statusMessage( tr( "Restarting interface" ) );
owait->show();
qApp->processEvents();
if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) {
qWarning("unstable to spawn ifdown/ifup");
}
owait->hide();
delete owait;
interface->refresh();
}
return true;
}
/**
* Save the settings for the current Interface.
* @return bool true if successfull, false otherwise
*/
bool InterfaceSetupImp::saveSettings(){
// eh can't really do anything about it other then return. :-D
if(!interfaces->isInterfaceSet())
return true;
bool error = false;
// Loopback case
if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
return true;
}
if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){
QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok);
return false;
}
// DHCP
if(dhcpCheckBox->isChecked()) {
interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP);
interfaces->removeInterfaceOption("address");
interfaces->removeInterfaceOption("netmask");
interfaces->removeInterfaceOption("gateway");
interfaces->removeInterfaceOption("up "DNSSCRIPT" -a ");
interfaces->removeInterfaceOption("down "DNSSCRIPT" -r ");
} else{
interfaces->setInterfaceMethod("static");
interfaces->setInterfaceOption("address", ipAddressEdit->text());
interfaces->setInterfaceOption("netmask", subnetMaskEdit->text());
interfaces->setInterfaceOption("gateway", gatewayEdit->text());
if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){
QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text();
interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns);
interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns);
+ }else{
+ interfaces->removeInterfaceOption("up "DNSSCRIPT" -a ");
+ interfaces->removeInterfaceOption("down "DNSSCRIPT" -r");
}
}
// IP Information
interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
return true;
}
/**
* The Profile has changed.
* @param QString profile the new profile.
*/
void InterfaceSetupImp::setProfile(const QString &profile){
/*
bool error = false;
if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
staticGroupBox->hide();
dhcpCheckBox->hide();
leaseTime->hide();
leaseHoursLabel->hide();
}
*/
QString newInterfaceName = interface->getInterfaceName();
if(profile.length() > 0)
newInterfaceName += "_" + profile;
// See if we have to make a interface.
if(!interfaces->setInterface(newInterfaceName)){
// Add making for this new interface if need too
if(profile != ""){
interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName);
if(!interfaces->setMapping(interface->getInterfaceName())){
interfaces->addMapping(interface->getInterfaceName());
if(!interfaces->setMapping(interface->getInterfaceName())){
qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface.");
return;
}
}
interfaces->setMap("map", newInterfaceName);
interfaces->setScript("getprofile.sh");
}
else{
interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
if(!interfaces->setInterface(newInterfaceName)){
qDebug("InterfaceSetupImp: Added interface, but still can't setInterface.");
return;
}
}
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 2d714ca..f74cf87 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,128 +1,137 @@
#include "mainwindowimp.h"
#include "addconnectionimp.h"
#include "interfaceinformationimp.h"
#include "interfacesetupimp.h"
#include "interfaces.h"
#include "module.h"
#include <qpushbutton.h>
#include <qlistbox.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qheader.h>
#include <qlabel.h>
#include <qpe/qcopenvelope_qws.h>
#include <qtabwidget.h> // in order to disable the profiles tab
+#include <qpe/qpeapplication.h>
#include <qmessagebox.h>
#ifdef QWS
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#else
#include <klibloader.h>
#define QLibrary KLibrary
#include <kconfig.h>
#define Config KConfig
#include <kapplication.h>
#include <kstandarddirs.h>
#include <kiconloader.h>
#define showMaximized show
#endif
#if QT_VERSION < 300
#include <qlist.h>
#else
#include <qptrlist.h>
#endif
#include <qdir.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qregexp.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
#define _PROCNETDEV "/proc/net/dev"
-MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){
+MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME){
connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
//FIXME: disable profiles for the moment:
-// tabWidget->setTabEnabled( tab, false );
+ tabWidget->setTabEnabled( tab, false );
// Load connections.
// /usr/local/kde/lib/libinterfaces.la
#ifdef QWS
loadModules(QPEApplication::qpeDir() + "plugins/networksettings");
#else
loader = KLibLoader::self();
loadModules(QString("/usr/")+KStandardDirs::kde_default("lib"));
#endif
getAllInterfaces();
Interfaces i;
QStringList list = i.getInterfaceList();
QMap<QString, Interface*>::Iterator it;
for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
+ /*
+ * we skipped it in getAllInterfaces now
+ * we need to ignore it as well
+ */
+ if (m_handledIfaces.contains( *ni) ) {
+ qDebug("Not up iface handled by module");
+ continue;
+ }
bool found = false;
for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
if(it.key() == (*ni))
found = true;
}
if(!found){
if(!(*ni).contains("_")){
Interface *i = new Interface(this, *ni, false);
i->setAttached(false);
i->setHardwareName(tr("Disconnected"));
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
}
}
}
//getInterfaceList();
connectionList->header()->hide();
Config cfg("NetworkSetup");
profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
for ( QStringList::Iterator it = profiles.begin();
it != profiles.end(); ++it)
profilesList->insertItem((*it));
currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
QFile file(scheme);
if ( file.open(IO_ReadOnly) ) { // file opened successfully
QTextStream stream( &file ); // use a text stream
while ( !stream.eof() ) { // until end of file...
QString line = stream.readLine(); // line of text excluding '\n'
if(line.contains("SCHEME")){
line = line.mid(7, line.length());
currentProfileLabel->setText(line);
break;
}
}
file.close();
}
makeChannel();
}
/**
* Deconstructor. Save profiles. Delete loaded libraries.
*/
@@ -151,96 +160,100 @@ MainWindowImp::~MainWindowImp(){
#else
// klibloader automaticly deletes the libraries for us...
#endif
}
/**
* Query the kernel for all of the interfaces.
*/
void MainWindowImp::getAllInterfaces(){
int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
if(sockfd == -1)
return;
struct ifreq ifr;
QStringList ifaces;
QFile procFile(QString(_PROCNETDEV));
int result;
Interface *i;
if (! procFile.exists()) {
struct ifreq ifrs[100];
struct ifconf ifc;
ifc.ifc_len = sizeof(ifrs);
ifc.ifc_req = ifrs;
result = ioctl(sockfd, SIOCGIFCONF, &ifc);
for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) {
struct ifreq *pifr = &ifrs[i];
ifaces += pifr->ifr_name;
}
} else {
procFile.open(IO_ReadOnly);
QString line;
QTextStream procTs(&procFile);
int loc = -1;
procTs.readLine(); // eat a line
procTs.readLine(); // eat a line
while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) {
if((loc = line.find(":")) != -1) {
ifaces += line.left(loc);
}
}
}
for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) {
int flags = 0;
+ if ( m_handledIfaces.contains( (*it) ) ) {
+ qDebug(" %s is handled by a module", (*it).latin1() );
+ continue;
+ }
// int family;
i = NULL;
strcpy(ifr.ifr_name, (*it).latin1());
struct ifreq ifcopy;
ifcopy = ifr;
result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy);
flags = ifcopy.ifr_flags;
i = new Interface(this, ifr.ifr_name, false);
i->setAttached(true);
if ((flags & IFF_UP) == IFF_UP)
i->setStatus(true);
else
i->setStatus(false);
if ((flags & IFF_BROADCAST) == IFF_BROADCAST)
i->setHardwareName("Ethernet");
else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT)
i->setHardwareName("Point to Point");
else if ((flags & IFF_MULTICAST) == IFF_MULTICAST)
i->setHardwareName("Multicast");
else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
i->setHardwareName("Loopback");
else
i->setHardwareName("Unknown");
qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name);
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
connect(i, SIGNAL(updateInterface(Interface *)),
this, SLOT(updateInterface(Interface *)));
}
// now lets ask the plugins too ;)
QMap<Module*, QLibrary*>::Iterator it;
QList<Interface> ilist;
for( it = libraries.begin(); it != libraries.end(); ++it ){
if(it.key()){
ilist = it.key()->getInterfaces();
for( i = ilist.first(); i != 0; i = ilist.next() ){
qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() );
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
connect(i, SIGNAL(updateInterface(Interface *)),
this, SLOT(updateInterface(Interface *)));
}
}
}
@@ -262,96 +275,97 @@ void MainWindowImp::loadModules(const QString &path){
// Don't want sym links
d.setFilter( QDir::Files | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) ) {
#ifdef QWS
if(fi->fileName().contains(".so")){
#else
if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){
#endif
loadPlugin(path + "/" + fi->fileName());
qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1());
}
++it;
}
}
/**
* Attempt to load a function and resolve a function.
* @param pluginFileName - the name of the file in which to attempt to load
* @param resolveString - function pointer to resolve
* @return pointer to the function with name resolveString or NULL
*/
Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){
#ifdef DEBUG
qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1());
#endif
#ifdef QWS
QLibrary *lib = new QLibrary(pluginFileName);
void *functionPointer = lib->resolve(resolveString);
if( !functionPointer ){
#ifdef DEBUG
qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1());
#endif
delete lib;
return NULL;
}
// Try to get an object.
Module *object = ((Module* (*)()) functionPointer)();
if(object == NULL){
#ifdef DEBUG
qDebug("MainWindowImp: Couldn't create object, but did load library!");
#endif
delete lib;
return NULL;
}
+ m_handledIfaces += object->handledInterfaceNames();
// Store for deletion later
libraries.insert(object, lib);
return object;
#else
QLibrary *lib = loader->library(pluginFileName);
if( !lib || !lib->hasSymbol(resolveString) ){
qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
return NULL;
}
// Try to get an object.
Module *object = ((Module* (*)()) lib->symbol(resolveString))();
if(object == NULL){
#ifdef DEBUG
qDebug("MainWindowImp: Couldn't create object, but did load library!");
#endif
return NULL;
}
#ifdef DEBUG
qDebug("MainWindowImp::loadPlugin:: Found object, storing.");
#endif
// Store for deletion later
libraries.insert(object, lib);
return object;
#endif
}
/**
* The Add button was clicked. Bring up the add dialog and if OK is hit
* load the plugin and append it to the list
*/
void MainWindowImp::addClicked(){
QMap<Module*, QLibrary*>::Iterator it;
QMap<QString, QString> list;
QMap<QString, Module*> newInterfaceOwners;
for( it = libraries.begin(); it != libraries.end(); ++it ){
if(it.key()){
(it.key())->possibleNewInterfaces(list);
}
}
// See if the list has anything that we can add.
if(list.count() == 0){
QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
return;
}
AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
addNewConnection.addConnections(list);
@@ -381,130 +395,130 @@ void MainWindowImp::addClicked(){
void MainWindowImp::removeClicked(){
QListViewItem *item = connectionList->currentItem();
if(!item) {
QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
return;
}
Interface *i = interfaceItems[item];
if(i->getModuleOwner() == NULL){
QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok);
}
else{
if(!i->getModuleOwner()->remove(i))
QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok);
else{
delete item;
// QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok);
}
}
}
/**
* Pull up the configure about the currently selected interface.
* Report an error if no interface is selected.
* If the interface has a module owner then request its configure.
*/
void MainWindowImp::configureClicked(){
QListViewItem *item = connectionList->currentItem();
if(!item){
QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok);
return;
}
QString currentProfileText = currentProfileLabel->text();
if(currentProfileText.upper() == "ALL");
currentProfileText = "";
Interface *i = interfaceItems[item];
if(i->getModuleOwner()){
QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
if(moduleConfigure != NULL){
i->getModuleOwner()->setProfile(currentProfileText);
moduleConfigure->showMaximized();
return;
}
}
- InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose );
+ InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp );
configure->setProfile(currentProfileText);
configure->showMaximized();
}
/**
* Pull up the information about the currently selected interface.
* Report an error if no interface is selected.
* If the interface has a module owner then request its configure.
*/
void MainWindowImp::informationClicked(){
QListViewItem *item = connectionList->currentItem();
if(!item){
QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
return;
}
Interface *i = interfaceItems[item];
// if(!i->isAttached()){
// QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok);
// return;
// }
if(i->getModuleOwner()){
QWidget *moduleInformation = i->getModuleOwner()->information(i);
if(moduleInformation != NULL){
moduleInformation->showMaximized();
#ifdef DEBUG
qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed.");
#endif
return;
}
}
- InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog);
+ InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp);
information->showMaximized();
}
/**
* Update this interface. If no QListViewItem exists create one.
* @param Interface* pointer to the interface that needs to be updated.
*/
void MainWindowImp::updateInterface(Interface *i){
if(!advancedUserMode){
if(i->getInterfaceName() == "lo")
return;
}
QListViewItem *item = NULL;
// Find the interface, making it if needed.
if(items.find(i) == items.end()){
item = new QListViewItem(connectionList, "", "", "");
// See if you can't find a module owner for this interface
QMap<Module*, QLibrary*>::Iterator it;
for( it = libraries.begin(); it != libraries.end(); ++it ){
if(it.key()->isOwner(i))
i->setModuleOwner(it.key());
}
items.insert(i, item);
interfaceItems.insert(item, i);
}
else
item = items[i];
// Update the icons and information
#ifdef QWS
item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
#else
item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down")));
#endif
QString typeName = "lan";
if(i->getInterfaceName() == "lo")
typeName = "lo";
if(i->getInterfaceName().contains("irda"))
typeName = "irda";
if(i->getInterfaceName().contains("wlan"))
typeName = "wlan";
if(i->getInterfaceName().contains("usb"))
typeName = "usb";
if(!i->isAttached())
@@ -594,72 +608,71 @@ void MainWindowImp::removeProfile(){
}
}
}
/**
* A new profile has been selected, change.
* @param newProfile the new profile.
*/
void MainWindowImp::changeProfile(){
if(profilesList->currentItem() == -1){
QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok);
return;
}
QString newProfile = profilesList->text(profilesList->currentItem());
if(newProfile != currentProfileLabel->text()){
currentProfileLabel->setText(newProfile);
QFile::remove(scheme);
QFile file(scheme);
if ( file.open(IO_ReadWrite) ) {
QTextStream stream( &file );
stream << QString("SCHEME=%1").arg(newProfile);
file.close();
}
// restart all up devices?
if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){
// Go through them one by one
QMap<Interface*, QListViewItem*>::Iterator it;
for( it = items.begin(); it != items.end(); ++it ){
if(it.key()->getStatus() == true)
it.key()->restart();
}
}
}
// TODO change the profile in the modules
}
void MainWindowImp::makeChannel()
{
channel = new QCopChannel( "QPE/Application/networksettings", this );
connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
this, SLOT(receive(const QCString&, const QByteArray&)) );
}
void MainWindowImp::receive(const QCString &msg, const QByteArray &arg)
{
bool found = false;
qDebug("MainWindowImp::receive QCop msg >"+msg+"<");
-
if (msg == "raise") {
raise();
return;
}
QString dest = msg.left(msg.find("("));
QCString param = msg.right(msg.length() - msg.find("(") - 1);
param = param.left( param.length() - 1 );
qDebug("dest >%s< param >"+param+"<",dest.latin1());
QMap<Module*, QLibrary*>::Iterator it;
for( it = libraries.begin(); it != libraries.end(); ++it ){
qDebug("plugin >%s<", it.key()->type().latin1() );
if(it.key()->type() == dest){
it.key()->receive( param, arg );
found = true;
}
}
if (found) QPEApplication::setKeepRunning();
else qDebug("Huh what do ya want");
}
diff --git a/noncore/settings/networksettings/mainwindowimp.h b/noncore/settings/networksettings/mainwindowimp.h
index a553f75..451835b 100644
--- a/noncore/settings/networksettings/mainwindowimp.h
+++ b/noncore/settings/networksettings/mainwindowimp.h
@@ -1,73 +1,74 @@
#ifndef MAINWINOWIMP_H
#define MAINWINOWIMP_H
#include "mainwindow.h"
#include <qmap.h>
#include <qstringlist.h>
class Module;
class Interface;
class QLibrary;
class KProcess;
class QCopChannel;
-#ifdef QWS
+#ifdef QWS
class QLibrary;
#else
class KLibrary;
class KLibLoader;
#define QLibrary KLibrary
#endif
class MainWindowImp : public MainWindow {
Q_OBJECT
public:
MainWindowImp(QWidget *parent=0, const char *name=0);
~MainWindowImp();
-
+
QCopChannel *channel;
private slots:
void getAllInterfaces();
-
+
void addClicked();
void removeClicked();
void configureClicked();
void informationClicked();
-
+
void addProfile();
void removeProfile();
void changeProfile();
-
+
void updateInterface(Interface *i);
void newProfileChanged(const QString& newText);
void receive (const QCString &, const QByteArray &);
private:
void makeChannel();
void loadModules(const QString &path);
-
+
Module* loadPlugin(const QString &pluginFileName,
const QString &resolveString = "create_plugin");
// For our local list of names
QMap<QString, Interface*> interfaceNames;
QMap<Module*, QLibrary*> libraries;
QMap<Interface*, QListViewItem*> items;
QMap<QListViewItem*, Interface*> interfaceItems;
-
+ QStringList m_handledIfaces;
+
QMap<KProcess*, QString> threads;
QStringList profiles;
bool advancedUserMode;
QString scheme;
#ifndef QWS
KLibLoader *loader;
#endif
};
#endif // MAINWINOWIMP_H
diff --git a/noncore/settings/networksettings/module.h b/noncore/settings/networksettings/module.h
index db74394..f7d8046 100644
--- a/noncore/settings/networksettings/module.h
+++ b/noncore/settings/networksettings/module.h
@@ -1,102 +1,113 @@
#ifndef NETCONF_MODULE_H
#define NETCONF_MODULE_H
#include <qobject.h>
#if QT_VERSION < 300
#include <qlist.h>
#else
#include <qptrlist.h>
#endif
#include <qmap.h>
#include "interface.h"
class QWidget;
class QTabWidget;
class Module : QObject{
signals:
void updateInterface(Interface *i);
-
+
public:
Module(){};
/**
* The type of the plugin
* and the name of the dcop call
*/
virtual const QString type() = 0;
/**
* The current profile has been changed and the module should do any
* neccesary changes also.
* @param newProfile what the profile should be changed to.
- */
+ */
virtual void setProfile(const QString &newProfile) = 0;
-
+
/**
* get the icon name for this device.
* @param Interface* can be used in determining the icon.
- * @return QString the icon name (minus .png, .gif etc)
- */
+ * @return QString the icon name (minus .png, .gif etc)
+ */
virtual QString getPixmapName(Interface *) = 0;
/**
* Check to see if the interface i is owned by this module.
* @param Interface* interface to check against
* @return bool true if i is owned by this module, false otherwise.
*/
virtual bool isOwner(Interface *){ return false; };
-
+
/**
* Create and return the WLANConfigure Module
* @param Interface *i the interface to configure.
* @return QWidget* pointer to this modules configure.
*/
virtual QWidget *configure(Interface *){ return NULL; } ;
-
+
/**
* Create, and return the Information Module
* @param Interface *i the interface to get info on.
* @return QWidget* pointer to this modules info.
*/
virtual QWidget *information(Interface *){ return NULL; };
-
+
/**
* Get all active (up or down) interfaces
* @return QList<Interface> A list of interfaces that exsist that havn't
* been called by isOwner()
- */
+ */
virtual QList<Interface> getInterfaces() = 0;
-
+
/**
* Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp),
* modem ppp)
*/
virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0;
-
+
/**
* Attempts to create a new interface from name
* @return Interface* NULL if it was unable to be created.
* @param name the type of interface to create
- */
+ */
virtual Interface *addNewInterface(const QString &name) = 0;
-
+
/**
* Attempts to remove the interface, doesn't delete i
* @return bool true if successfull, false otherwise.
*/
virtual bool remove(Interface* i) = 0;
/**
- * get dcop calls
+ * get dcop calls
*/
virtual void receive(const QCString &msg, const QByteArray &arg) = 0;
+ QStringList handledInterfaceNames()const { return m_inter; }
+protected:
+ /**
+ * set which interfaceNames should not be shown cause they're handled
+ * internally of this module.. An already running ppp link or
+ * a tunnel...
+ */
+ void setHandledInterfaceNames( const QStringList& in) { m_inter = in; }
+
+private:
+ QStringList m_inter;
};
#endif
// module.h
diff --git a/noncore/settings/networksettings/ppp/TODO b/noncore/settings/networksettings/ppp/TODO
index 80fc5a6..14a1b3f 100644
--- a/noncore/settings/networksettings/ppp/TODO
+++ b/noncore/settings/networksettings/ppp/TODO
@@ -1,9 +1,3 @@
-- ask for password is non is set
-
-- stop pppd, i.e. fix interfaceinformationppp
-
-- update modem attribute inputs when modem has changed
-- impl. PPPData::copyaccount & PPPData::deleteAccount
-
+- impl. PPPData::copyaccount
- check if the same interface device combination allready exists
-- fix layout of edit account, i.e. get it shown maximised
+- check if a deleted account or device exists in a config and ask the user
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index fa1c43b..28d8732 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -1,342 +1,308 @@
/*
* kPPP: A pppd front end for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* based on EzPPP:
* Copyright (C) 1997 Jay Painter
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <qdir.h>
#include <stdlib.h>
#include <qlayout.h>
#include <qtabwidget.h>
#include <qtabdialog.h>
#include <qwhatsthis.h>
#include <qmessagebox.h>
#include <qapplication.h>
#include <qbuttongroup.h>
#include <qmessagebox.h>
#include <qvgroupbox.h>
#include "accounts.h"
#include "authwidget.h"
#include "pppdata.h"
#include "edit.h"
void parseargs(char* buf, char** args);
-AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name )
- : QWidget( parent, name )//, _pppdata(pd)
+
+AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f )
+ : ChooserWidget( pd, parent, name, f )
{
- _pppdata = pd;
- QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
- accountlist_l = new QListBox(this);
-
- connect(accountlist_l, SIGNAL(highlighted(int)),
- this, SLOT(slotListBoxSelect(int)));
- connect(accountlist_l, SIGNAL(selected(int)),
- this, SLOT(editaccount()));
- l1->addWidget(accountlist_l, 10);
-
- edit_b = new QPushButton(tr("&Edit..."), this);
- connect(edit_b, SIGNAL(clicked()), SLOT(editaccount()));
- QWhatsThis::add(edit_b, tr("Allows you to modify the selected account"));
- l1->addWidget(edit_b);
- new_b = new QPushButton(tr("&New..."), this);
- connect(new_b, SIGNAL(clicked()), SLOT(newaccount()));
- l1->addWidget(new_b);
+ QWhatsThis::add(edit_b, tr("Allows you to modify the selected account"));
QWhatsThis::add(new_b, tr("Create a new dialup connection\n"
"to the Internet"));
-
- copy_b = new QPushButton(tr("Co&py"), this);
- connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount()));
- l1->addWidget(copy_b);
QWhatsThis::add(copy_b,
tr("Makes a copy of the selected account. All\n"
"settings of the selected account are copied\n"
"to a new account, that you can modify to fit your\n"
"needs"));
-
- delete_b = new QPushButton(tr("De&lete"), this);
- connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount()));
- l1->addWidget(delete_b);
QWhatsThis::add(delete_b,
tr("<p>Deletes the selected account\n\n"
"<font color=\"red\"><b>Use with care!</b></font>"));
- QHBoxLayout *l12 = new QHBoxLayout;
- l1->addStretch(1);
- l1->addLayout(l12);
- int currAccId = _pppdata->currentAccountID();
- qDebug("currentAccountID %i", currAccId);
- //load up account list from gppdata to the list box
- if(_pppdata->count() > 0) {
- for(int i=0; i <= _pppdata->count()-1; i++) {
- _pppdata->setAccountbyIndex(i);
- accountlist_l->insertItem(_pppdata->accname());
- }
- }
- _pppdata->setAccountbyIndex( currAccId );
+ copy_b->setEnabled( false ); //FIXME
+ // delete_b->setEnabled( false ); //FIXME
- qDebug("setting listview index to %i",_pppdata->currentAccountID() );
- accountlist_l->setCurrentItem( _pppdata->currentAccountID() );
- slotListBoxSelect( _pppdata->currentAccountID() );
+ listListbox->insertStringList(_pppdata->getAccountList());
- l1->activate();
+ for (uint i = 0; i < listListbox->count(); i++){
+ if ( listListbox->text(i) == _pppdata->accname() )
+ listListbox->setCurrentItem( i );
+ }
}
void AccountWidget::slotListBoxSelect(int idx) {
- delete_b->setEnabled((bool)(idx != -1));
- edit_b->setEnabled((bool)(idx != -1));
- copy_b->setEnabled((bool)(idx != -1));
- if(idx!=-1) {
- qDebug("setting account to %i", idx);
- QString account = _pppdata->accname();
- _pppdata->setAccountbyIndex(accountlist_l->currentItem());
- }
+ bool ok = _pppdata->setAccount( listListbox->text(idx) );
+ ok = (bool)(idx != -1);
+ delete_b->setEnabled(ok);
+ edit_b->setEnabled(ok);
+//FIXME copy_b->setEnabled(ok);
}
-void AccountWidget::editaccount() {
- _pppdata->setAccount(accountlist_l->text(accountlist_l->currentItem()));
+void AccountWidget::edit() {
+ _pppdata->setAccount(listListbox->text(listListbox->currentItem()));
int result = doTab();
if(result == QDialog::Accepted) {
- accountlist_l->changeItem(_pppdata->accname(),accountlist_l->currentItem());
+ listListbox->changeItem(_pppdata->accname(),listListbox->currentItem());
// emit resetaccounts();
_pppdata->save();
}
}
-void AccountWidget::newaccount() {
+void AccountWidget::create() {
- if(accountlist_l->count() == MAX_ACCOUNTS) {
- QMessageBox::information(this, "sorry",
- tr("Maximum number of accounts reached."));
- return;
- }
+// if(listListbox->count() == MAX_ACCOUNTS) {
+// QMessageBox::information(this, "sorry",
+// tr("Maximum number of accounts reached."));
+// return;
+// }
int result;
if (_pppdata->newaccount() == -1){
qDebug("_pppdata->newaccount() == -1");
return;
}
result = doTab();
if(result == QDialog::Accepted) {
- accountlist_l->insertItem(_pppdata->accname());
- accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()),true);
+ listListbox->insertItem(_pppdata->accname());
+ listListbox->setSelected(listListbox->findItem(_pppdata->accname()),true);
_pppdata->save();
} else
_pppdata->deleteAccount();
}
-void AccountWidget::copyaccount() {
- if(accountlist_l->count() == MAX_ACCOUNTS) {
- QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached."));
- return;
- }
+void AccountWidget::copy() {
+// if(listListbox->count() == MAX_ACCOUNTS) {
+// QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached."));
+// return;
+// }
- if(accountlist_l->currentItem()<0) {
+ if(listListbox->currentItem()<0) {
QMessageBox::information(this, "sorry", tr("No account selected."));
return;
}
- _pppdata->copyaccount(accountlist_l->currentItem());
+ _pppdata->copyaccount(listListbox->currentText());
- accountlist_l->insertItem(_pppdata->accname());
+ listListbox->insertItem(_pppdata->accname());
// emit resetaccounts();
_pppdata->save();
}
-void AccountWidget::deleteaccount() {
+void AccountWidget::remove() {
QString s = tr("Are you sure you want to delete\nthe account \"%1\"?")
- .arg(accountlist_l->text(accountlist_l->currentItem()));
+ .arg(listListbox->text(listListbox->currentItem()));
if(QMessageBox::warning(this,tr("Confirm"),s,
QMessageBox::Yes,QMessageBox::No
) != QMessageBox::Yes)
return;
- if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem())))
- accountlist_l->removeItem(accountlist_l->currentItem());
+ if(_pppdata->deleteAccount(listListbox->text(listListbox->currentItem())))
+ listListbox->removeItem(listListbox->currentItem());
- emit resetaccounts();
- _pppdata->save();
- slotListBoxSelect(accountlist_l->currentItem());
+// emit resetaccounts();
+// _pppdata->save();
+
+
+ slotListBoxSelect(listListbox->currentItem());
}
int AccountWidget::doTab(){
- QDialog *dlg = new QDialog( 0, "newAccount", true );
+ QDialog *dlg = new QDialog( 0, "newAccount", true, Qt::WStyle_ContextHelp );
QVBoxLayout *layout = new QVBoxLayout( dlg );
layout->setSpacing( 0 );
layout->setMargin( 1 );
- tabWindow = new QTabWidget( dlg, "tabWindow" );
+ QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" );
layout->addWidget( tabWindow );
bool isnewaccount;
if(_pppdata->accname().isEmpty()) {
dlg->setCaption(tr("New Account"));
isnewaccount = true;
} else {
QString tit = tr("Edit Account: ");
tit += _pppdata->accname();
dlg->setCaption(tit);
isnewaccount = false;
}
// // DIAL WIDGET
dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup");
tabWindow->addTab( dial_w, tr("Dial") );
// // AUTH WIDGET
auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script"));
tabWindow->addTab( auth_w, tr("Authentication") );
// // IP WIDGET
ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup"));
tabWindow->addTab( ip_w, tr("IP") );
// // GATEWAY WIDGET
gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup"));
tabWindow->addTab( gateway_w, tr("Gateway") );
// // DNS WIDGET
dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") );
tabWindow->addTab( dns_w, tr("DNS") );
// // EXECUTE WIDGET
ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs"));
tabWindow->addTab( exec_w, tr("Execute") );
int result = 0;
bool ok = false;
while (!ok){
dlg->showMaximized();
result = dlg->exec();
ok = true;
if(result == QDialog::Accepted) {
if (!auth_w->check()){
ok = false;
} else if(!dial_w->save()) {
QMessageBox::critical(this, "error", tr( "You must enter a unique account name"));
ok = false;
}else{
ip_w->save();
dns_w->save();
gateway_w->save();
auth_w->save();
exec_w->save();
}
}
}
delete dlg;
return result;
}
-QString AccountWidget::prettyPrintVolume(unsigned int n) {
- int idx = 0;
- const QString quant[] = {tr("Byte"), tr("KB"),
- tr("MB"), tr("GB"), QString::null};
+// QString AccountWidget::prettyPrintVolume(unsigned int n) {
+// int idx = 0;
+// const QString quant[] = {tr("Byte"), tr("KB"),
+// tr("MB"), tr("GB"), QString::null};
- float n1 = n;
- while(n >= 1024 && quant[idx] != QString::null) {
- idx++;
- n /= 1024;
- }
+// float n1 = n;
+// while(n >= 1024 && quant[idx] != QString::null) {
+// idx++;
+// n /= 1024;
+// }
- int i = idx;
- while(i--)
- n1 = n1 / 1024.0;
+// int i = idx;
+// while(i--)
+// n1 = n1 / 1024.0;
- QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 );
- s += " " + quant[idx];
- return s;
-}
+// QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 );
+// s += " " + quant[idx];
+// return s;
+// }
/////////////////////////////////////////////////////////////////////////////
//
// Queries the user what to reset: costs, volume or both
//
/////////////////////////////////////////////////////////////////////////////
// QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) {
// // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
// setCaption(tr("Reset Accounting"));
// QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
// QVGroupBox *f = new QVGroupBox(tr("What to Reset"), this);
// QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
// // costs = new QCheckBox(tr("Reset the accumulated phone costs"), f);
// // costs->setChecked(true);
// // l1->addWidget(costs);
// // QWhatsThis::add(costs, tr("Check this to set the phone costs\n"
// // "to zero. Typically you'll want to\n"
// // "do this once a month."));
// // volume = new QCheckBox(tr("Reset volume accounting"), f);
// // volume->setChecked(true);
// // l1->addWidget(volume);
// // QWhatsThis::add(volume, tr("Check this to set the volume accounting\n"
// // "to zero. Typically you'll want to do this\n"
// // "once a month."));
// l1->activate();
// // this activates the f-layout and sets minimumSize()
// f->show();
// tl->addWidget(f);
// QButtonGroup *bbox = new QButtonGroup(this);
// // bbox->addStretch(1);
// QPushButton *ok = new QPushButton( bbox, tr("OK") );
// bbox->insert(ok);
// ok->setDefault(true);
// QPushButton *cancel = new QPushButton( bbox, tr("Cancel") );
// bbox->insert(cancel);
// connect(ok, SIGNAL(clicked()),
// this, SLOT(accepted()));
// connect(cancel, SIGNAL(clicked()),
// this, SLOT(reject()));
diff --git a/noncore/settings/networksettings/ppp/accounts.h b/noncore/settings/networksettings/ppp/accounts.h
index 8c16a7c..7f31513 100644
--- a/noncore/settings/networksettings/ppp/accounts.h
+++ b/noncore/settings/networksettings/ppp/accounts.h
@@ -1,86 +1,80 @@
/* -*- C++ -*-
* kPPP: A pppd front end for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* based on EzPPP:
* Copyright (C) 1997 Jay Painter
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _ACCOUNTS_H_
#define _ACCOUNTS_H_
-#include <qwidget.h>
#include <qdialog.h>
#include <qpushbutton.h>
#include <qlistbox.h>
-//#include "acctselect.h"
+#include "chooserwidget.h"
-class QDialog;
class QCheckBox;
class QLineEdit;
class QTabWidget;
+class ModemWidget;
+class ModemWidget2;
+
+
class DialWidget;
class AuthWidget;
class IPWidget;
class DNSWidget;
class GatewayWidget;
class PPPData;
-class AccountWidget : public QWidget {
+
+class AccountWidget : public ChooserWidget {
+
Q_OBJECT
public:
- AccountWidget( PPPData *pd, QWidget *parent=0, const char *name=0 );
+ AccountWidget( PPPData *pd, QWidget *parent=0, const char *name=0, WFlags f=0 );
~AccountWidget() {}
-private slots:
- void editaccount();
- void copyaccount();
- void newaccount();
- void deleteaccount();
- void slotListBoxSelect(int);
-private:
+private slots:
+ virtual void edit();
+ virtual void copy();
+ virtual void remove();
+ virtual void create();
+ virtual void slotListBoxSelect(int);
int doTab();
-signals:
- void resetaccounts();
+ signals:
+ void resetaccounts();
private:
- QString prettyPrintVolume(unsigned int);
-
- PPPData *_pppdata;
- QTabWidget *tabWindow;
DialWidget *dial_w;
IPWidget *ip_w;
DNSWidget *dns_w;
GatewayWidget *gateway_w;
AuthWidget *auth_w;
- QListBox *accountlist_l;
- QPushButton *edit_b;
- QPushButton *copy_b;
- QPushButton *new_b;
- QPushButton *delete_b;
};
#endif
diff --git a/noncore/settings/networksettings/ppp/chooserwidget.cpp b/noncore/settings/networksettings/ppp/chooserwidget.cpp
new file mode 100644
index 0000000..a32b2b8
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/chooserwidget.cpp
@@ -0,0 +1,85 @@
+/*
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <qdir.h>
+#include <stdlib.h>
+#include <qlayout.h>
+#include <qtabwidget.h>
+#include <qtabdialog.h>
+#include <qwhatsthis.h>
+#include <qmessagebox.h>
+
+#include <qapplication.h>
+#include <qbuttongroup.h>
+#include <qmessagebox.h>
+#include <qvgroupbox.h>
+#include <qwidget.h>
+
+#include "accounts.h"
+#include "authwidget.h"
+#include "pppdata.h"
+#include "edit.h"
+
+void parseargs(char* buf, char** args);
+
+ChooserWidget::ChooserWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f )
+ : QWidget( parent, name, f )
+{
+ _pppdata = pd;
+ QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
+ listListbox = new QListBox(this);
+
+ connect(listListbox, SIGNAL(highlighted(int)),
+ this, SLOT(slotListBoxSelect(int)));
+ connect(listListbox, SIGNAL(selected(int)),this, SLOT(edit()));
+ l1->addWidget(listListbox, 10);
+
+ edit_b = new QPushButton(tr("&Edit..."), this);
+ connect(edit_b, SIGNAL(clicked()), SLOT(edit()));
+ l1->addWidget(edit_b);
+
+ new_b = new QPushButton(tr("&New..."), this);
+ connect(new_b, SIGNAL(clicked()), SLOT(create()));
+ l1->addWidget(new_b);
+
+
+ copy_b = new QPushButton(tr("Co&py"), this);
+ connect(copy_b, SIGNAL(clicked()), SLOT(copy()));
+ l1->addWidget(copy_b);
+
+ delete_b = new QPushButton(tr("De&lete"), this);
+ connect(delete_b, SIGNAL(clicked()), SLOT(remove()));
+ l1->addWidget(delete_b);
+
+
+ QHBoxLayout *l12 = new QHBoxLayout;
+ l1->addStretch(1);
+ l1->addLayout(l12);
+
+ l1->activate();
+
+}
+
diff --git a/noncore/settings/networksettings/ppp/chooserwidget.h b/noncore/settings/networksettings/ppp/chooserwidget.h
new file mode 100644
index 0000000..ac3f4cb
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/chooserwidget.h
@@ -0,0 +1,73 @@
+/* -*- C++ -*-
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _CHOOSERWIDGET_H_
+#define _CHOOSERWIDGET_H_
+
+#include <qwidget.h>
+#include <qdialog.h>
+#include <qpushbutton.h>
+#include <qlistbox.h>
+//#include "acctselect.h"
+
+class QDialog;
+class QCheckBox;
+class QLineEdit;
+class QTabWidget;
+class DialWidget;
+class AuthWidget;
+class IPWidget;
+class DNSWidget;
+class GatewayWidget;
+class PPPData;
+
+class ChooserWidget : public QWidget {
+ Q_OBJECT
+public:
+ ChooserWidget( PPPData *pd, QWidget *parent=0, const char *name=0, WFlags f=0 );
+ ~ChooserWidget() {}
+
+private slots:
+ virtual void edit() = 0;
+ virtual void copy() = 0;
+ virtual void create()= 0;
+ virtual void remove()= 0;
+ virtual void slotListBoxSelect(int) = 0;
+
+
+protected:
+ PPPData *_pppdata;
+
+ QListBox *listListbox;
+ QPushButton *edit_b;
+ QPushButton *copy_b;
+ QPushButton *new_b;
+ QPushButton *delete_b;
+};
+
+
+#endif
+
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
index 2400d7b..e3fab24 100644
--- a/noncore/settings/networksettings/ppp/connect.cpp
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -1,1299 +1,1323 @@
/*
* kPPP: A pppd front end for the KDE project
*
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
* Copyright (C) 1998-2001 Harri Porten <porten@kde.org>
*
* based on EzPPP:
* Copyright (C) 1997 Jay Painter
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
//#include <config.h>
#include <qlayout.h>
#include <qregexp.h>
#include <qapplication.h>
//#include <kdebug.h>
//#include <klocale.h>
-#define i18n QObject::tr
#include <qmessagebox.h>
#include <qpushbutton.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <assert.h>
#ifdef _XPG4_2
#define __xnet_connect connect
#endif
#include <errno.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef __linux__
#include "runtests.h"
#endif
#include "auth.h"
#include "connect.h"
//#include "docking.h"
#include "interfaceppp.h"
#include "modem.h"
#include "kpppconfig.h"
#include "pppdata.h"
#include "kpppwidget.h"
//#include "requester.h"
//#include "utils.h"
#define execute_command system
QString old_hostname;
bool modified_hostname;
ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name)
: QWidget(parent, name),
myreadbuffer(""),
main_timer_ID(0),
vmain(0),
substate(-1),
scriptindex(0),
loopnest(0),
loopend(false),
semaphore(false),
expecting(false),
readbuffer(""),
scanvar(""),
scanning(false),
pausing(false),
dialnumber(0),
_ifaceppp(ifp)
{
modified_hostname = false;
QVBoxLayout *tl = new QVBoxLayout(this, 8, 10);
- QString tit = i18n("Connecting to: ");
+ QString tit = QObject::tr("Connecting to: ");
setCaption(tit);
QHBoxLayout *l0 = new QHBoxLayout(10);
tl->addLayout(l0);
l0->addSpacing(10);
messg = new QLabel(this, "messg");
messg->setFrameStyle(QFrame::Panel|QFrame::Sunken);
messg->setAlignment(AlignCenter);
- messg->setText(i18n("Unable to create modem lock file."));
+ messg->setText(QObject::tr("Unable to create modem lock file."));
messg->setMinimumHeight(messg->sizeHint().height() + 5);
// int messw = (messg->sizeHint().width() * 12) / 10;
// messw = QMAX(messw,280);
// messg->setMinimumWidth(messw);
if (_ifaceppp->getStatus())
- messg->setText(i18n("Online"));
+ messg->setText(QObject::tr("Online"));
else
- messg->setText(i18n("Offline"));
+ messg->setText(QObject::tr("Offline"));
l0->addSpacing(10);
l0->addWidget(messg);
l0->addSpacing(10);
QHBoxLayout *l1 = new QHBoxLayout(10);
tl->addLayout(l1);
l1->addStretch(1);
- debug = new QPushButton(i18n("Log"), this);
+ debug = new QPushButton(QObject::tr("Log"), this);
debug->setToggleButton(true);
debug->setEnabled( false ); // FIXME: disable the log button
connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow()));
- cancel = new QPushButton(i18n("Cancel"), this);
+ cancel = new QPushButton(QObject::tr("Cancel"), this);
cancel->setFocus();
connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton()));
// int maxw = QMAX(cancel->sizeHint().width(),
// debug->sizeHint().width());
// maxw = QMAX(maxw,65);
// debug->setFixedWidth(maxw);
// cancel->setFixedWidth(maxw);
l1->addWidget(debug);
l1->addWidget(cancel);
// setFixedSize(sizeHint());
pausetimer = new QTimer(this);
connect(pausetimer, SIGNAL(timeout()), SLOT(pause()));
qApp->processEvents();
timeout_timer = new QTimer(this);
connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out()));
inittimer = new QTimer(this);
connect(inittimer, SIGNAL(timeout()), SLOT(init()));
if_timeout_timer = new QTimer(this);
connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out()));
connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot()));
prompt = new PWEntry( this, "pw" );
if_timer = new QTimer(this);
connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot()));
}
ConnectWidget::~ConnectWidget() {
}
void ConnectWidget::preinit() {
// this is all just to keep the GUI nice and snappy ....
// you have to see to believe ...
- messg->setText(i18n("Looking for modem..."));
+ messg->setText(QObject::tr("Looking for modem..."));
inittimer->start(100);
}
void ConnectWidget::init() {
_ifaceppp->data()->setpppdError(0);
inittimer->stop();
vmain = 0;
substate = -1;
expecting = false;
pausing = false;
scriptindex = 0;
myreadbuffer = "";
scanning = false;
scanvar = "";
firstrunID = true;
firstrunPW = true;
// stats->totalbytes = 0;
dialnumber = 0;
// p_kppp->con_speed = "";
// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect());
comlist = &_ifaceppp->data()->scriptType();
arglist = &_ifaceppp->data()->script();
- QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname());
+ QString tit = QObject::tr("Connecting to: %1").arg(_ifaceppp->data()->accname());
setCaption(tit);
qApp->processEvents();
// run the "before-connect" command
if (!_ifaceppp->data()->command_before_connect().isEmpty()) {
- messg->setText(i18n("Running pre-startup command..."));
- emit debugMessage(i18n("Running pre-startup command..."));
+ messg->setText(QObject::tr("Running pre-startup command..."));
+ emit debugMessage(QObject::tr("Running pre-startup command..."));
qApp->processEvents();
QApplication::flushX();
pid_t id = execute_command(_ifaceppp->data()->command_before_connect());
// int i, status;
// do {
// qApp->processEvents();
// i = waitpid(id, &status, WNOHANG);
// usleep(100000);
// } while (i == 0 && errno == 0);
}
int lock = _ifaceppp->modem()->lockdevice();
if (lock == 1) {
- messg->setText(i18n("Modem device is locked."));
+ messg->setText(QObject::tr("Modem device is locked."));
vmain = 20; // wait until cancel is pressed
return;
}
if (lock == -1) {
- messg->setText(i18n("Unable to create modem lock file."));
+ messg->setText(QObject::tr("Unable to create modem lock file."));
vmain = 20; // wait until cancel is pressed
return;
}
if(_ifaceppp->modem()->opentty()) {
messg->setText(_ifaceppp->modem()->modemMessage());
qApp->processEvents();
if(_ifaceppp->modem()->hangup()) {
qApp->processEvents();
semaphore = false;
_ifaceppp->modem()->stop();
_ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char)));
// if we are stuck anywhere we will time out
timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
// this timer will run the script etc.
main_timer_ID = startTimer(10);
return;
}
}
// initialization failed
messg->setText(_ifaceppp->modem()->modemMessage());
vmain = 20; // wait until cancel is pressed
_ifaceppp->modem()->unlockdevice();
}
void ConnectWidget::timerEvent(QTimerEvent *) {
if (semaphore || pausing)
return;
if(vmain == 0) {
#ifdef DEBUG_WO_DIALING
vmain = 10;
return;
#endif
assert(PPPData::NumInitStrings > 0);
// first init string ?
if(substate == -1) {
- messg->setText(i18n("Initializing modem..."));
- emit debugMessage(i18n("Initializing modem..."));
+ messg->setText(QObject::tr("Initializing modem..."));
+ emit debugMessage(QObject::tr("Initializing modem..."));
substate = 0;
}
QString initStr = _ifaceppp->data()->modemInitStr(substate);
if (!initStr.isEmpty()) {
// send a carriage return and then wait a bit so that the modem will
// let us issue commands.
if(_ifaceppp->data()->modemPreInitDelay() > 0) {
usleep(_ifaceppp->data()->modemPreInitDelay() * 5000);
writeline("");
usleep(_ifaceppp->data()->modemPreInitDelay() * 5000);
}
setExpect(_ifaceppp->data()->modemInitResp());
writeline(initStr);
usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
}
substate++;
/*
* FIXME after 3.0: Make it possible to disable ATS11 since it
* seems to be incompatible with some ISDN adapters (e.g. DataBox
* Speed Dragon). Even better would be to detect this when doing
* a "Modem Query"
*/
if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration())
vmain = 5;
else
vmain = 3;
return;
}
if (vmain == 5) {
if(!expecting) {
QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration());
- QString msg = i18n("Setting ") + sToneDuration;
+ QString msg = QObject::tr("Setting ") + sToneDuration;
messg->setText(msg);
emit debugMessage(msg);
setExpect(_ifaceppp->data()->modemInitResp());
writeline(sToneDuration);
}
vmain = 3;
return;
}
if(vmain == 3) {
if(!expecting) {
// done with all init strings ?
if(substate < PPPData::NumInitStrings) {
vmain = 0;
return;
}
substate = -1;
// skip setting the volume if command is empty
if(_ifaceppp->data()->volumeInitString().isEmpty()) {
vmain = 4;
return;
}
- messg->setText(i18n("Setting speaker volume..."));
- emit debugMessage(i18n("Setting speaker volume..."));
+ messg->setText(QObject::tr("Setting speaker volume..."));
+ emit debugMessage(QObject::tr("Setting speaker volume..."));
setExpect(_ifaceppp->data()->modemInitResp());
QString vol("AT");
vol += _ifaceppp->data()->volumeInitString();
writeline(vol);
usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
vmain = 4;
return;
}
}
if(vmain == 4) {
if(!expecting) {
if(!_ifaceppp->data()->waitForDialTone()) {
- QString msg = i18n("Turning off dial tone waiting...");
+ QString msg = QObject::tr("Turning off dial tone waiting...");
messg->setText(msg);
emit debugMessage(msg);
setExpect(_ifaceppp->data()->modemInitResp());
writeline(_ifaceppp->data()->modemNoDialToneDetectionStr());
}
vmain = 1;
return;
}
}
// dial the number and wait to connect
if(vmain == 1) {
if(!expecting) {
timeout_timer->stop();
timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
QStringList &plist = _ifaceppp->data()->phonenumbers();
QString bmarg= _ifaceppp->data()->dialPrefix();
bmarg += *plist.at(dialnumber);
- QString bm = i18n("Dialing %1").arg(bmarg);
+ QString bm = QObject::tr("Dialing %1").arg(bmarg);
messg->setText(bm);
emit debugMessage(bm);
QString pn = _ifaceppp->data()->modemDialStr();
pn += _ifaceppp->data()->dialPrefix();
pn += *plist.at(dialnumber);
if(++dialnumber >= plist.count())
dialnumber = 0;
writeline(pn);
setExpect(_ifaceppp->data()->modemConnectResp());
vmain = 100;
return;
}
}
// wait for connect, but redial if BUSY or wait for user cancel
// if NO CARRIER or NO DIALTONE
if(vmain == 100) {
if(!expecting) {
myreadbuffer = _ifaceppp->data()->modemConnectResp();
setExpect("\n");
vmain = 101;
return;
}
if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) {
timeout_timer->stop();
timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
- messg->setText(i18n("Line busy. Hanging up..."));
+ messg->setText(QObject::tr("Line busy. Hanging up..."));
emit debugPutChar('\n');
_ifaceppp->modem()->hangup();
if(_ifaceppp->data()->busyWait() > 0) {
- QString bm = i18n("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait());
+ QString bm = QObject::tr("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait());
messg->setText(bm);
emit debugMessage(bm);
pausing = true;
pausetimer->start(_ifaceppp->data()->busyWait()*1000, true);
timeout_timer->stop();
}
_ifaceppp->modem()->setDataMode(false);
vmain = 0;
substate = -1;
return;
}
if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) {
timeout_timer->stop();
- messg->setText(i18n("No Dialtone"));
+ messg->setText(QObject::tr("No Dialtone"));
vmain = 20;
_ifaceppp->modem()->unlockdevice();
return;
}
if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) {
timeout_timer->stop();
- messg->setText(i18n("No Carrier"));
+ messg->setText(QObject::tr("No Carrier"));
vmain = 20;
_ifaceppp->modem()->unlockdevice();
return;
}
}
// wait for newline after CONNECT response (so we get the speed)
if(vmain == 101) {
if(!expecting) {
_ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands
emit startAccounting();
// p_kppp->con_win->startClock();
vmain = 2;
scriptTimeout=_ifaceppp->data()->modemTimeout()*1000;
return;
}
}
// execute the script
if(vmain == 2) {
if(!expecting && !pausing && !scanning) {
timeout_timer->stop();
timeout_timer->start(scriptTimeout);
if((unsigned) scriptindex < comlist->count()) {
scriptCommand = *(comlist->at(scriptindex));
scriptArgument = *(arglist->at(scriptindex));
} else {
qDebug( "End of script" );
vmain = 10;
return;
}
if (scriptCommand == "Scan") {
- QString bm = i18n("Scanning %1").arg(scriptArgument);
+ QString bm = QObject::tr("Scanning %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
setScan(scriptArgument);
scriptindex++;
return;
}
if (scriptCommand == "Save") {
- QString bm = i18n("Saving %1").arg(scriptArgument);
+ QString bm = QObject::tr("Saving %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
if (scriptArgument.lower() == "password") {
_ifaceppp->data()->setPassword(scanvar);
// p_kppp->setPW_Edit(scanvar);
if(_ifaceppp->data()->storePassword())
_ifaceppp->data()->setStoredPassword(scanvar);
firstrunPW = true;
}
scriptindex++;
return;
}
if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") {
- QString bm = i18n("Sending %1");
+ QString bm = QObject::tr("Sending %1");
// replace %USERNAME% and %PASSWORD%
QString arg = scriptArgument;
QRegExp re1("%USERNAME%");
QRegExp re2("%PASSWORD%");
arg = arg.replace(re1, _ifaceppp->data()->storedUsername());
arg = arg.replace(re2, _ifaceppp->data()->storedPassword());
if (scriptCommand == "Send")
bm = bm.arg(scriptArgument);
else {
for(uint i = 0; i < scriptArgument.length(); i++)
bm = bm.arg("*");
}
messg->setText(bm);
emit debugMessage(bm);
writeline(scriptArgument);
scriptindex++;
return;
}
if (scriptCommand == "Expect") {
- QString bm = i18n("Expecting %1").arg(scriptArgument);
+ QString bm = QObject::tr("Expecting %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
// The incrementing of the scriptindex MUST be before the
// call to setExpect otherwise the expect will miss a string that is
// already in the buffer.
scriptindex++;
setExpect(scriptArgument);
return;
}
if (scriptCommand == "Pause") {
- QString bm = i18n("Pause %1 seconds").arg(scriptArgument);
+ QString bm = QObject::tr("Pause %1 seconds").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
pausing = true;
pausetimer->start(scriptArgument.toInt()*1000, true);
timeout_timer->stop();
scriptindex++;
return;
}
if (scriptCommand == "Timeout") {
timeout_timer->stop();
- QString bm = i18n("Timeout %1 seconds").arg(scriptArgument);
+ QString bm = QObject::tr("Timeout %1 seconds").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
scriptTimeout=scriptArgument.toInt()*1000;
timeout_timer->start(scriptTimeout);
scriptindex++;
return;
}
if (scriptCommand == "Hangup") {
- messg->setText(i18n("Hangup"));
- emit debugMessage(i18n("Hangup"));
+ messg->setText(QObject::tr("Hangup"));
+ emit debugMessage(QObject::tr("Hangup"));
writeline(_ifaceppp->data()->modemHangupStr());
setExpect(_ifaceppp->data()->modemHangupResp());
scriptindex++;
return;
}
if (scriptCommand == "Answer") {
timeout_timer->stop();
- messg->setText(i18n("Answer"));
- emit debugMessage(i18n("Answer"));
+ messg->setText(QObject::tr("Answer"));
+ emit debugMessage(QObject::tr("Answer"));
setExpect(_ifaceppp->data()->modemRingResp());
vmain = 150;
return;
}
if (scriptCommand == "ID") {
- QString bm = i18n("ID %1").arg(scriptArgument);
+ QString bm = QObject::tr("ID %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
QString idstring = _ifaceppp->data()->password();
if(!idstring.isEmpty() && firstrunID) {
// the user entered an Id on the main kppp dialog
writeline(idstring);
firstrunID = false;
scriptindex++;
}
else {
// the user didn't enter and Id on the main kppp dialog
// let's query for an ID
/* if not around yet, then post window... */
if (prompt->Consumed()) {
if (!(prompt->isVisible())) {
prompt->setPrompt(scriptArgument);
prompt->setEchoModeNormal();
prompt->show();
}
} else {
/* if prompt withdrawn ... then, */
if(!(prompt->isVisible())) {
writeline(prompt->text());
prompt->setConsumed();
scriptindex++;
return;
}
/* replace timeout value */
}
}
}
if (scriptCommand == "Password") {
- QString bm = i18n("Password %1").arg(scriptArgument);
+ QString bm = QObject::tr("Password %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
QString pwstring = _ifaceppp->data()->password();
if(!pwstring.isEmpty() && firstrunPW) {
// the user entered a password on the main kppp dialog
writeline(pwstring);
firstrunPW = false;
scriptindex++;
}
else {
// the user didn't enter a password on the main kppp dialog
// let's query for a password
/* if not around yet, then post window... */
if (prompt->Consumed()) {
if (!(prompt->isVisible())) {
prompt->setPrompt(scriptArgument);
prompt->setEchoModePassword();
prompt->show();
}
} else {
/* if prompt withdrawn ... then, */
if(!(prompt->isVisible())) {
// p_kppp->setPW_Edit(prompt->text());
writeline(prompt->text());
prompt->setConsumed();
scriptindex++;
return;
}
/* replace timeout value */
}
}
}
if (scriptCommand == "Prompt") {
- QString bm = i18n("Prompting %1");
+ QString bm = QObject::tr("Prompting %1");
// if the scriptindex (aka the prompt text) includes a ## marker
// this marker should get substituted with the contents of our stored
// variable (from the subsequent scan).
QString ts = scriptArgument;
int vstart = ts.find( "##" );
if( vstart != -1 ) {
ts.remove( vstart, 2 );
ts.insert( vstart, scanvar );
}
bm = bm.arg(ts);
messg->setText(bm);
emit debugMessage(bm);
/* if not around yet, then post window... */
if (prompt->Consumed()) {
if (!(prompt->isVisible())) {
prompt->setPrompt( ts );
prompt->setEchoModeNormal();
prompt->show();
}
} else {
/* if prompt withdrawn ... then, */
if (!(prompt->isVisible())) {
writeline(prompt->text());
prompt->setConsumed();
scriptindex++;
return;
}
/* replace timeout value */
}
}
if (scriptCommand == "PWPrompt") {
- QString bm = i18n("PW Prompt %1").arg(scriptArgument);
+ QString bm = QObject::tr("PW Prompt %1").arg(scriptArgument);
messg->setText(bm);
emit debugMessage(bm);
/* if not around yet, then post window... */
if (prompt->Consumed()) {
if (!(prompt->isVisible())) {
prompt->setPrompt(scriptArgument);
prompt->setEchoModePassword();
prompt->show();
}
} else {
/* if prompt withdrawn ... then, */
if (!(prompt->isVisible())) {
writeline(prompt->text());
prompt->setConsumed();
scriptindex++;
return;
}
/* replace timeout value */
}
}
if (scriptCommand == "LoopStart") {
- QString bm = i18n("Loop Start %1").arg(scriptArgument);
+ QString bm = QObject::tr("Loop Start %1").arg(scriptArgument);
// The incrementing of the scriptindex MUST be before the
// call to setExpect otherwise the expect will miss a string that is
// already in the buffer.
scriptindex++;
if ( loopnest > (MAXLOOPNEST-2) ) {
- bm += i18n("ERROR: Nested too deep, ignored.");
+ bm += QObject::tr("ERROR: Nested too deep, ignored.");
vmain=20;
cancelbutton();
- QMessageBox::critical(0, "error", i18n("Loops nested too deeply!"));
+ QMessageBox::critical(0, "error", QObject::tr("Loops nested too deeply!"));
} else {
setExpect(scriptArgument);
loopstartindex[loopnest] = scriptindex;
loopstr[loopnest] = scriptArgument;
loopend = false;
loopnest++;
}
messg->setText(bm);
emit debugMessage(bm);
}
if (scriptCommand == "LoopEnd") {
- QString bm = i18n("Loop End %1").arg(scriptArgument);
+ QString bm = QObject::tr("Loop End %1").arg(scriptArgument);
if ( loopnest <= 0 ) {
- bm = i18n("LoopEnd without matching Start! Line: %1").arg(bm);
+ bm = QObject::tr("LoopEnd without matching Start! Line: %1").arg(bm);
vmain=20;
cancelbutton();
QMessageBox::critical(0, "error", bm);
return;
} else {
// NB! The incrementing of the scriptindex MUST be before the
// call to setExpect otherwise the expect will miss a string
// that is already in the buffer.
scriptindex++;
setExpect(scriptArgument);
loopnest--;
loopend = true;
}
messg->setText(bm);
emit debugMessage(bm);
}
}
}
// this is a subroutine for the "Answer" script option
if(vmain == 150) {
if(!expecting) {
writeline(_ifaceppp->data()->modemAnswerStr());
setExpect(_ifaceppp->data()->modemAnswerResp());
vmain = 2;
scriptindex++;
return;
}
}
if(vmain == 30) {
// if (termwindow->isVisible())
// return;
// if (termwindow->pressedContinue())
// vmain = 10;
// else
cancelbutton();
}
if(vmain == 10) {
if(!expecting) {
int result;
timeout_timer->stop();
if_timeout_timer->stop(); // better be sure.
// stop reading of data
_ifaceppp->modem()->stop();
if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) {
// if (termwindow) {
// delete termwindow;
// termwindow = 0L;
// this->show();
// } else {
// termwindow = new LoginTerm(0L, 0L);
// hide();
// termwindow->show();
// vmain = 30;
// return;
// }
}
// Close the tty. This prevents the QTimer::singleShot() in
// Modem::readtty() from re-enabling the socket notifier.
// The port is still held open by the helper process.
/* Er, there _is_ not QTimer::singleShot() in Modem::readtty(),
and closing the thing prevents pppd from using it later. */
//_ifaceppp->modem()->closetty();
killTimer( main_timer_ID );
if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000);
qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000);
// find out PPP interface and notify the stats module
// stats->setUnit(pppInterfaceNumber());
qApp->flushX();
semaphore = true;
result = execppp();
- emit debugMessage(i18n("Starting pppd..."));
+ emit debugMessage(QObject::tr("Starting pppd..."));
qDebug("execppp() returned with return-code %i", result );
if(result) {
if(!_ifaceppp->data()->autoDNS())
adddns( _ifaceppp );
// O.K we are done here, let's change over to the if_waiting loop
// where we wait for the ppp if (interface) to come up.
emit if_waiting_signal();
} else {
// starting pppd wasn't successful. Error messages were
// handled by execppp();
if_timeout_timer->stop();
this->hide();
messg->setText("");
// p_kppp->quit_b->setFocus();
// p_kppp->show();
qApp->processEvents();
_ifaceppp->modem()->hangup();
emit stopAccounting();
// p_kppp->con_win->stopClock();
_ifaceppp->modem()->closetty();
_ifaceppp->modem()->unlockdevice();
}
return;
}
}
// this is a "wait until cancel" entry
if(vmain == 20) {
}
}
void ConnectWidget::set_con_speed_string() {
// Here we are trying to determine the speed at which we are connected.
// Usually the modem responds after connect with something like
// CONNECT 115200, so all we need to do is find the number after CONNECT
// or whatever the modemConnectResp() is.
// p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer);
}
void ConnectWidget::readChar(unsigned char c) {
if(semaphore)
return;
readbuffer += c;
myreadbuffer += c;
// While in scanning mode store each char to the scan buffer
// for use in the prompt command
if( scanning )
scanbuffer += c;
// add to debug window
emit debugPutChar(c);
checkBuffers();
}
void ConnectWidget::checkBuffers() {
// Let's check if we are finished with scanning:
// The scanstring have to be in the buffer and the latest character
// was a carriage return or an linefeed (depending on modem setup)
if( scanning && scanbuffer.contains(scanstr) &&
( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) {
scanning = false;
int vstart = scanbuffer.find( scanstr ) + scanstr.length();
scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart);
scanvar = scanvar.stripWhiteSpace();
// Show the Variabel content in the debug window
- QString sv = i18n("Scan Var: %1").arg(scanvar);
+ QString sv = QObject::tr("Scan Var: %1").arg(scanvar);
emit debugMessage(sv);
}
if(expecting) {
if(readbuffer.contains(expectstr)) {
expecting = false;
// keep everything after the expected string
readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length());
- QString ts = i18n("Found: %1").arg(expectstr);
+ QString ts = QObject::tr("Found: %1").arg(expectstr);
emit debugMessage(ts);
if (loopend) {
loopend=false;
}
}
if (loopend && readbuffer.contains(loopstr[loopnest])) {
expecting = false;
readbuffer = "";
- QString ts = i18n("Looping: %1").arg(loopstr[loopnest]);
+ QString ts = QObject::tr("Looping: %1").arg(loopstr[loopnest]);
emit debugMessage(ts);
scriptindex = loopstartindex[loopnest];
loopend = false;
loopnest++;
}
// notify event loop if expected string was found
if(!expecting)
timerEvent((QTimerEvent *) 0);
}
}
void ConnectWidget::pause() {
pausing = false;
pausetimer->stop();
}
void ConnectWidget::cancelbutton() {
_ifaceppp->modem()->stop();
killTimer(main_timer_ID);
timeout_timer->stop();
if_timer->stop();
if_timeout_timer->stop();
// if (termwindow) {
// delete termwindow;
// termwindow = 0L;
// this->show();
// }
- messg->setText(i18n("One moment please..."));
+ messg->setText(QObject::tr("One moment please..."));
// just to be sure
_ifaceppp->modem()->removeSecret(AUTH_PAP);
_ifaceppp->modem()->removeSecret(AUTH_CHAP);
removedns(_ifaceppp);
qApp->processEvents();
_ifaceppp->modem()->killPPPDaemon();
_ifaceppp->modem()->hangup();
// p_kppp->quit_b->setFocus();
// p_kppp->show();
// emit stopAccounting(); // just to be sure
// p_kppp->con_win->stopClock();
_ifaceppp->modem()->closetty();
_ifaceppp->modem()->unlockdevice();
//abort prompt window...
if (prompt->isVisible()) {
- prompt->hide();
+ prompt->hide();
}
prompt->setConsumed();
- messg->setText(tr("offline"));
+ _ifaceppp->setStatus( false );
+ _ifaceppp->refresh();
+// messg->setText(tr("offline"));
+ refresh();
}
void ConnectWidget::script_timed_out() {
if(vmain == 20) { // we are in the 'wait for the user to cancel' state
timeout_timer->stop();
emit stopAccounting();
// p_kppp->con_win->stopClock();
return;
}
if (prompt->isVisible())
prompt->hide();
prompt->setConsumed();
- messg->setText(i18n("Script timed out!"));
+ messg->setText(QObject::tr("Script timed out!"));
_ifaceppp->modem()->hangup();
emit stopAccounting();
// p_kppp->con_win->stopClock();
vmain = 0; // let's try again.
substate = -1;
}
void ConnectWidget::setScan(const QString &n) {
scanning = true;
scanstr = n;
scanbuffer = "";
- QString ts = i18n("Scanning: %1").arg(n);
+ QString ts = QObject::tr("Scanning: %1").arg(n);
emit debugMessage(ts);
}
void ConnectWidget::setExpect(const QString &n) {
expecting = true;
expectstr = n;
- QString ts = i18n("Expecting: %1").arg(n);
+ QString ts = QObject::tr("Expecting: %1").arg(n);
ts.replace(QRegExp("\n"), "<LF>");
emit debugMessage(ts);
// check if the expected string is in the read buffer already.
checkBuffers();
}
void ConnectWidget::if_waiting_timed_out() {
if_timer->stop();
if_timeout_timer->stop();
qDebug("if_waiting_timed_out()");
_ifaceppp->data()->setpppdError(E_IF_TIMEOUT);
// let's kill the stuck pppd
_ifaceppp->modem()->killPPPDaemon();
emit stopAccounting();
// p_kppp->con_win->stopClock();
// killing ppp will generate a SIGCHLD which will be caught in pppdie()
// in main.cpp what happens next will depend on the boolean
// reconnect_on_disconnect which is set in ConnectWidget::init();
}
void ConnectWidget::pppdDied()
{
if_timer->stop();
if_timeout_timer->stop();
}
void ConnectWidget::if_waiting_slot() {
- messg->setText(i18n("Logging on to network..."));
+ messg->setText(QObject::tr("Logging on to network..."));
// if(!stats->ifIsUp()) {
// if(_ifaceppp->data()->pppdError() != 0) {
// // we are here if pppd died immediately after starting it.
// pppdDied();
// // error message handled in main.cpp: sigPPPDDied()
// return;
// }
// if_timer->start(100, TRUE); // single shot
// return;
// }
// O.K the ppp interface is up and running
// give it a few time to come up completly (0.2 seconds)
if_timeout_timer->stop();
if_timer->stop();
usleep(200000);
if(_ifaceppp->data()->autoDNS())
addpeerdns( _ifaceppp );
// Close the debugging window. If we are connected, we
// are not really interested in debug output
emit closeDebugWindow();
// p_kppp->statdlg->take_stats(); // start taking ppp statistics
auto_hostname(_ifaceppp);
if(!_ifaceppp->data()->command_on_connect().isEmpty()) {
- messg->setText(i18n("Running startup command..."));
+ messg->setText(QObject::tr("Running startup command..."));
// make sure that we don't get any async errors
qApp->flushX();
execute_command(_ifaceppp->data()->command_on_connect());
- messg->setText(i18n("Done"));
+ messg->setText(QObject::tr("Done"));
}
// remove the authentication file
_ifaceppp->modem()->removeSecret(AUTH_PAP);
_ifaceppp->modem()->removeSecret(AUTH_CHAP);
- emit debugMessage(i18n("Done"));
+ emit debugMessage(QObject::tr("Done"));
set_con_speed_string();
// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed);
- this->hide();
- messg->setText("");
+// this->hide();
+// messg->setText("");
_ifaceppp->setStatus( true );
+
+ m_refreshTimer = new QTimer( this );
+ connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
+ m_refreshTimer->start( 3000 );
+ //_ifaceppp->refresh();
// emit _ifaceppp->updateInterface(_ifaceppp);
// prepare the con_win so as to have the right size for
// accounting / non-accounting mode
// if(p_kppp->acct != 0)
// p_kppp->con_win->accounting(p_kppp->acct->running());
// else
// p_kppp->con_win->accounting(false);
// if (_ifaceppp->data()->get_dock_into_panel()) {
// // DockWidget::dock_widget->show();
// // DockWidget::dock_widget->take_stats();
// // this->hide();
// }
// else {
// // p_kppp->con_win->show();
// if(_ifaceppp->data()->get_iconify_on_connect()) {
// // p_kppp->con_win->showMinimized();
// }
// }
_ifaceppp->modem()->closetty();
}
+void ConnectWidget::refresh() {
+ _ifaceppp->refresh();
+ if ( _ifaceppp->getStatus() ) {
+ messg->setText(QObject::tr("Online"));
+ } else {
+ messg->setText(QObject::tr("Offline"));
+ }
+}
+
bool ConnectWidget::execppp() {
QString command;
command = "pppd";
// as of version 2.3.6 pppd falls back to the real user rights when
// opening a device given in a command line. To avoid permission conflicts
// we'll simply leave this argument away. pppd will then use the default tty
// which is the serial port we connected stdin/stdout to in opener.cpp.
// command += " ";
// command += _ifaceppp->data()->modemDevice();
command += " " + _ifaceppp->data()->speed();
command += " -detach";
if(_ifaceppp->data()->ipaddr() != "0.0.0.0" ||
_ifaceppp->data()->gateway() != "0.0.0.0") {
if(_ifaceppp->data()->ipaddr() != "0.0.0.0") {
command += " ";
command += _ifaceppp->data()->ipaddr();
command += ":";
}
else {
command += " ";
command += ":";
}
if(_ifaceppp->data()->gateway() != "0.0.0.0")
command += _ifaceppp->data()->gateway();
}
if(_ifaceppp->data()->subnetmask() != "0.0.0.0")
command += " netmask " + _ifaceppp->data()->subnetmask();
if(_ifaceppp->data()->flowcontrol() != "None") {
if(_ifaceppp->data()->flowcontrol() == "CRTSCTS")
command += " crtscts";
else
command += " xonxoff";
}
if(_ifaceppp->data()->defaultroute())
command += " defaultroute";
if(_ifaceppp->data()->autoDNS())
command += " usepeerdns";
- QStringList &arglist = _ifaceppp->data()->pppdArgument();
- for ( QStringList::Iterator it = arglist.begin();
- it != arglist.end();
- ++it )
- {
- command += " " + *it;
- }
// PAP settings
if(_ifaceppp->data()->authMethod() == AUTH_PAP) {
command += " -chap user ";
- command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";
+ command = command + _ifaceppp->data()->storedUsername();
}
// CHAP settings
if(_ifaceppp->data()->authMethod() == AUTH_CHAP) {
command += " -pap user ";
- command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";
+ command = command + _ifaceppp->data()->storedUsername();
}
// PAP/CHAP settings
if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) {
- command += " user ";
- command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";
+ QString tmpName = _ifaceppp->data()->storedUsername();
+ if ( !tmpName.isEmpty() ) {
+ command += " user ";
+ command = command + tmpName;
+ }
}
// check for debug
if(_ifaceppp->data()->getPPPDebug())
command += " debug";
+ QStringList &arglist = _ifaceppp->data()->pppdArgument();
+ for ( QStringList::Iterator it = arglist.begin();
+ it != arglist.end();
+ ++it )
+ {
+ command += " " + *it;
+ }
+
+ command += " call opie-kppp logfd 11";
+
if (command.length() > MAX_CMDLEN) {
- QMessageBox::critical(this, "error", i18n(
+ QMessageBox::critical(this, "error", QObject::tr(
"pppd command + command-line arguments exceed "
"2024 characters in length."
));
return false; // nonsensically long command which would bust my buffer buf.
}
+ qWarning("Command IS: %s",command.latin1() );
+
qApp->flushX();
return _ifaceppp->modem()->execPPPDaemon(command);
}
void ConnectWidget::closeEvent( QCloseEvent *e ) {
e->ignore();
emit cancelbutton();
}
void ConnectWidget::setMsg(const QString &msg) {
messg->setText(msg);
}
void ConnectWidget::writeline(const QString &s) {
_ifaceppp->modem()->writeLine(s.local8Bit());
}
// Set the hostname and domain from DNS Server
void auto_hostname(InterfacePPP *_ifaceppp) {
struct in_addr local_ip;
struct hostent *hostname_entry;
QString new_hostname;
int dot;
char tmp_str[100]; // buffer overflow safe
gethostname(tmp_str, sizeof(tmp_str));
tmp_str[sizeof(tmp_str)-1]=0; // panic
old_hostname=tmp_str; // copy to QString
// if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) {
if ( _ifaceppp->data()->autoname()) {
// local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii());
hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET);
if (hostname_entry != 0L) {
new_hostname=hostname_entry->h_name;
dot=new_hostname.find('.');
new_hostname=new_hostname.remove(dot,new_hostname.length()-dot);
_ifaceppp->modem()->setHostname(new_hostname);
modified_hostname = TRUE;
new_hostname=hostname_entry->h_name;
new_hostname.remove(0,dot+1);
add_domain(new_hostname, _ifaceppp);
diff --git a/noncore/settings/networksettings/ppp/connect.h b/noncore/settings/networksettings/ppp/connect.h
index e7ae5e0..b225ff5 100644
--- a/noncore/settings/networksettings/ppp/connect.h
+++ b/noncore/settings/networksettings/ppp/connect.h
@@ -17,136 +17,138 @@
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _CONNECT_H_
#define _CONNECT_H_
#include <qtimer.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qevent.h>
#include "kpppconfig.h"
#include "pwentry.h"
#define MAXLOOPNEST (MAX_SCRIPT_ENTRIES/2)
class InterfacePPP;
class PPPData;
class ConnectWidget : public QWidget {
Q_OBJECT
public:
ConnectWidget(InterfacePPP*, QWidget *parent, const char *name);
~ConnectWidget();
public:
void set_con_speed_string();
void setMsg(const QString &);
void pppdDied();
protected:
void timerEvent(QTimerEvent *);
void closeEvent( QCloseEvent *e );
private slots:
void readChar(unsigned char);
void pause();
void if_waiting_slot();
+ void refresh();
public slots:
void init();
void preinit();
void script_timed_out();
void if_waiting_timed_out();
void cancelbutton();
signals:
void if_waiting_signal();
void debugMessage(const QString &);
void toggleDebugWindow();
void closeDebugWindow();
void debugPutChar(unsigned char);
void startAccounting();
void stopAccounting();
public:
QString myreadbuffer; // we want to keep every thing in order to fish for the
// connection speed later on
QPushButton *debug;
int main_timer_ID;
private:
int vmain;
int substate;
int scriptindex;
QString scriptCommand, scriptArgument;
QStringList *comlist, *arglist;
// static const int maxloopnest=(MAX_SCRIPT_ENTRIES/2);
int loopnest;
int loopstartindex[MAXLOOPNEST];
bool loopend;
QString loopstr[MAXLOOPNEST];
bool semaphore;
QTimer *inittimer;
QTimer *timeout_timer;
bool execppp();
void writeline(const QString &);
void checkBuffers();
void setExpect(const QString &);
bool expecting;
QString expectstr;
QString readbuffer;
void setScan(const QString &);
QString scanvar;
QString scanstr;
QString scanbuffer;
bool scanning;
bool pausing;
PWEntry *prompt;
// LoginTerm *termwindow;
int scriptTimeout;
QTimer *pausetimer;
QTimer *if_timer;
QTimer *if_timeout_timer;
+ QTimer *m_refreshTimer;
QLabel *messg;
QPushButton *cancel;
bool firstrunID;
bool firstrunPW;
unsigned int dialnumber; // the current number to dial
InterfacePPP *_ifaceppp;
};
// non-member function to kill&wait on the pppd child process
extern void killppp(PPPData*);
void adddns(InterfacePPP*);
void addpeerdns(InterfacePPP*);
void removedns(InterfacePPP*);
void add_domain(const QString & newdomain, InterfacePPP*);
void auto_hostname(InterfacePPP*);
#endif
diff --git a/noncore/settings/networksettings/ppp/conwindow.cpp b/noncore/settings/networksettings/ppp/conwindow.cpp
index 9136ca0..7641bbe 100644
--- a/noncore/settings/networksettings/ppp/conwindow.cpp
+++ b/noncore/settings/networksettings/ppp/conwindow.cpp
@@ -1,146 +1,141 @@
/*
* kPPP: A pppd front end for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <qtooltip.h>
#include <qdialog.h>
#include "conwindow.h"
-//#include "docking.h"
#include "pppdata.h"
-// #include "pppstats.h"
-// #include <klocale.h>
-#define i18n QObject::tr
-// #include <kglobal.h>
ConWindow::ConWindow(PPPData *pd, QWidget *parent, const char *name,
QDialog *mainwidget )
: QWidget(parent, name, 0),
minutes(0),
seconds(0),
hours(0),
days(0),
tl1(0),
_pppdata(pd)
{
- info1 = new QLabel(i18n("Connected at:"), this);
+ info1 = new QLabel(QObject::tr("Connected at:"), this);
info2 = new QLabel("", this);
- timelabel1 = new QLabel(i18n("Time connected:"), this);
+ timelabel1 = new QLabel(QObject::tr("Time connected:"), this);
timelabel2 = new QLabel("000:00:00", this);
- vollabel = new QLabel(i18n("Volume:"), this);
+ vollabel = new QLabel(QObject::tr("Volume:"), this);
volinfo = new QLabel("", this);
// now the stuff for accounting
- session_bill_l = new QLabel(i18n("Session Bill:"), this);
+ session_bill_l = new QLabel(QObject::tr("Session Bill:"), this);
session_bill = new QLabel("", this);
- total_bill_l = new QLabel(i18n("Total Bill:"), this);
+ total_bill_l = new QLabel(QObject::tr("Total Bill:"), this);
total_bill = new QLabel("", this);
this->setCaption("kppp");
cancelbutton = new QPushButton(this);
- cancelbutton->setText(i18n("Disconnect"));
+ cancelbutton->setText(QObject::tr("Disconnect"));
connect(cancelbutton, SIGNAL(clicked()), mainwidget, SLOT(disconnect()));
// statsbutton = new QPushButton(this);
-// statsbutton->setText(i18n("Details"));
+// statsbutton->setText(QObject::tr("Details"));
// statsbutton->setFocus();
// connect(statsbutton, SIGNAL(clicked()), mainwidget, SLOT(showStats()));
clocktimer = new QTimer(this);
connect(clocktimer, SIGNAL(timeout()), SLOT(timeclick()));
// read window position from config file
// int p_x, p_y;
// PPPData::data()->winPosConWin(p_x, p_y);
// setGeometry(p_x, p_y, 320, 110);
}
ConWindow::~ConWindow() {
stopClock();
}
// save window position when window was closed
bool ConWindow::event(QEvent *e) {
if (e->type() == QEvent::Hide)
{
// PPPData::data()->setWinPosConWin(x(), y());
return true;
}
else
return QWidget::event(e);
}
QString ConWindow::prettyPrintVolume(unsigned int n) {
int idx = 0;
- const QString quant[] = {i18n("Byte"), i18n("KB"),
- i18n("MB"), i18n("GB"), QString::null};
+ const QString quant[] = {QObject::tr("Byte"), QObject::tr("KB"),
+ QObject::tr("MB"), QObject::tr("GB"), QString::null};
float n1 = n;
while(n >= 1024 && quant[idx] != QString::null) {
idx++;
n /= 1024;
}
int i = idx;
while(i--)
n1 = n1 / 1024.0;
QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 );
s += " " + quant[idx];
return s;
}
// void ConWindow::accounting(bool on) {
// // cache accounting settings
// accountingEnabled = on;
// // volumeAccountingEnabled = PPPData::data()->VolAcctEnabled();
// // delete old layout
// if(tl1 != 0)
// delete tl1;
// // add layout now
// tl1 = new QVBoxLayout(this, 10, 10);
// tl1->addSpacing(5);
// QHBoxLayout *tl = new QHBoxLayout;
// tl1->addLayout(tl);
// tl->addSpacing(20);
// QGridLayout *l1;
// int vol_lines = 0;
// // if(_pppdata->VolAcctEnabled())
// // vol_lines = 1;
// if(accountingEnabled)
// l1 = new QGridLayout(4 + vol_lines, 2, 5);
// else
// l1 = new QGridLayout(2 + vol_lines, 2, 5);
// tl->addLayout(l1);
// l1->setColStretch(0, 0);
// l1->setColStretch(1, 1);
// info2->setAlignment(AlignRight|AlignVCenter);
// timelabel2->setAlignment(AlignRight|AlignVCenter);
// session_bill->setAlignment(AlignRight|AlignVCenter);
@@ -214,104 +209,104 @@ QString ConWindow::prettyPrintVolume(unsigned int n) {
// tl1->addSpacing(5);
// setFixedSize(sizeHint());
// /*
// do not overwrite position read from config
// setGeometry((QApplication::desktop()->width() - width()) / 2,
// (QApplication::desktop()->height() - height())/2,
// width(),
// height());
// */
// }
// void ConWindow::dock() {
// // DockWidget::dock_widget->show();
// this->hide();
// }
void ConWindow::startClock() {
minutes = 0;
seconds = 0;
hours = 0;
QString title ;
title = _pppdata->accname();
if(_pppdata->get_show_clock_on_caption()){
title += " 00:00" ;
}
this->setCaption(title);
timelabel2->setText("00:00:00");
clocktimer->start(1000);
}
void ConWindow::setConnectionSpeed(const QString &speed) {
info2->setText(speed);
}
void ConWindow::stopClock() {
clocktimer->stop();
}
void ConWindow::timeclick() {
-// QString tooltip = i18n("Connection: %1\n"
+// QString tooltip = QObject::tr("Connection: %1\n"
// "Connected at: %2\n"
// "Time connected: %3")
// .arg(_pppdata->accname()).arg(info2->text())
// .arg(time_string2);
// if(accountingEnabled)
-// tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2")
+// tooltip += QObject::tr("\nSession Bill: %1\nTotal Bill: %2")
// .arg(session_bill->text()).arg(total_bill->text());
// // volume accounting
// if(volumeAccountingEnabled) {
// volinfo->setEnabled(TRUE);
// int bytes = _pppdata->totalBytes();
// volinfo->setText(prettyPrintVolume(bytes));
// }
// seconds++;
// if(seconds >= 60 ) {
// minutes ++;
// seconds = 0;
// }
// if (minutes >= 60){
// minutes = 0;
// hours ++;
// }
// if( hours >= 24){
// days ++;
// hours = 0;
// }
// time_string.sprintf("%02d:%02d",hours,minutes);
// time_string2 = "";
// if (days)
// time_string2.sprintf("%d d %02d:%02d:%02d",
// days,hours,minutes,seconds);
// else
// time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds);
// caption_string = _pppdata->accname();
// caption_string += " ";
// caption_string += time_string;
// timelabel2->setText(time_string2);
// if(_pppdata->get_show_clock_on_caption() && (seconds == 1)){
// // we update the Caption only once per minute not every second
// // otherwise I get a flickering icon
// this->setCaption(caption_string);
// }
diff --git a/noncore/settings/networksettings/ppp/devices.cpp b/noncore/settings/networksettings/ppp/devices.cpp
new file mode 100644
index 0000000..e94904b
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/devices.cpp
@@ -0,0 +1,212 @@
+/*
+ * kPPP: A pppd front end for the KDE project
+ *
+ * $Id$
+ *
+ * Copyright (C) 1997 Bernd Johannes Wuebben
+ * wuebben@math.cornell.edu
+ *
+ * based on EzPPP:
+ * Copyright (C) 1997 Jay Painter
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <qdir.h>
+#include <stdlib.h>
+#include <qlayout.h>
+#include <qtabwidget.h>
+#include <qtabdialog.h>
+#include <qwhatsthis.h>
+#include <qmessagebox.h>
+
+#include <qapplication.h>
+#include <qbuttongroup.h>
+#include <qmessagebox.h>
+#include <qvgroupbox.h>
+
+#include "interfaceppp.h"
+#include "devices.h"
+#include "authwidget.h"
+#include "pppdata.h"
+#include "edit.h"
+#include "general.h"
+
+void parseargs(char* buf, char** args);
+
+DevicesWidget::DevicesWidget( InterfacePPP* ip, QWidget *parent, const char *name, WFlags f )
+ : ChooserWidget(ip->data(), parent, name, f)
+{
+ _ifaceppp = ip;
+ QWhatsThis::add(edit_b, tr("Allows you to modify the selected device"));
+ QWhatsThis::add(new_b, tr("Create a new device") );
+
+ QWhatsThis::add(copy_b,
+ tr("Makes a copy of the selected device. All\n"
+ "settings of the selected device are copied\n"
+ "to a new device, that you can modify to fit your\n"
+ "needs"));
+ QWhatsThis::add(delete_b,
+ tr("<p>Deletes the selected device\n\n"
+ "<font color=\"red\"><b>Use with care!</b></font>"));
+
+ copy_b->setEnabled( false ); //FIXME
+// delete_b->setEnabled( false ); //FIXME
+
+ QStringList tmp = _pppdata->getDevicesNamesList();
+ qDebug("DevicesWidget::DevicesWidget got devices %s",tmp.join("--").latin1());
+ listListbox->insertStringList(tmp);
+
+ for (uint i = 0; i < listListbox->count(); i++){
+ qDebug("listListbox->text(i) %s == _pppdata->devname() %s",listListbox->text(i).latin1(), _pppdata->devname().latin1());
+ if ( listListbox->text(i) == _pppdata->devname() )
+ listListbox->setCurrentItem( i );
+ }
+}
+
+
+
+void DevicesWidget::slotListBoxSelect(int idx) {
+ bool ok = _pppdata->setDevice( listListbox->text(idx) );
+ delete_b->setEnabled((bool)(idx != -1));
+ edit_b->setEnabled((bool)(idx != -1));
+//FIXME copy_b->setEnabled((bool)(idx != -1));
+}
+
+void DevicesWidget::edit() {
+ _pppdata->setDevice(listListbox->text(listListbox->currentItem()));
+
+ int result = doTab();
+
+ if(result == QDialog::Accepted) {
+ listListbox->changeItem(_pppdata->devname(),listListbox->currentItem());
+ _pppdata->save();
+ }
+}
+
+
+void DevicesWidget::create() {
+
+// if(listListbox->count() == MAX_ACCOUNTS) {
+// QMessageBox::information(this, "sorry",
+// tr("Maximum number of accounts reached."));
+// return;
+// }
+
+ int result;
+ if (_pppdata->newdevice() == -1){
+ return;
+ }
+ result = doTab();
+
+ if(result == QDialog::Accepted) {
+ listListbox->insertItem(_pppdata->devname());
+ listListbox->setSelected(listListbox->findItem(_pppdata->devname()),true );
+
+ _pppdata->save();
+ } else
+ _pppdata->deleteDevice();
+}
+
+
+void DevicesWidget::copy() {
+// if(listListbox->count() == MAX_ACCOUNTS) {
+// QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached."));
+// return;
+// }
+
+ if(listListbox->currentItem()<0) {
+ QMessageBox::information(this, "sorry", tr("No devices selected."));
+ return;
+ }
+
+ _pppdata->copydevice(listListbox->currentText());
+
+ listListbox->insertItem(_pppdata->devname());
+ _pppdata->save();
+}
+
+
+void DevicesWidget::remove() {
+
+ QString s = tr("Are you sure you want to delete\nthe device \"%1\"?")
+ .arg(listListbox->text(listListbox->currentItem()));
+
+ if(QMessageBox::warning(this,tr("Confirm"),s,
+ QMessageBox::Yes,QMessageBox::No
+ ) != QMessageBox::Yes)
+ return;
+
+ if(_pppdata->deleteDevice(listListbox->text(listListbox->currentItem())))
+ listListbox->removeItem(listListbox->currentItem());
+
+
+// _pppdata->save();
+
+
+ slotListBoxSelect(listListbox->currentItem());
+
+}
+
+
+int DevicesWidget::doTab(){
+ QDialog *dlg = new QDialog( 0, "newDevice", true, Qt::WStyle_ContextHelp );
+ QVBoxLayout *layout = new QVBoxLayout( dlg );
+ layout->setSpacing( 0 );
+ layout->setMargin( 1 );
+
+ QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" );
+ layout->addWidget( tabWindow );
+
+ bool isnew;
+
+ if(_pppdata->devname().isEmpty()) {
+ dlg->setCaption(tr("New Device"));
+ isnew = true;
+ } else {
+ QString tit = tr("Edit Device: ");
+ tit += _pppdata->devname();
+ dlg->setCaption(tit);
+ isnew = false;
+ }
+
+ modem1 = new ModemWidget( _pppdata, tabWindow, "modem1" );
+ tabWindow->addTab( modem1, tr("&Device") );
+ modem2 = new ModemWidget2( _pppdata, _ifaceppp, tabWindow, "modem2" );
+ tabWindow->addTab( modem2, tr("&Modem") );
+
+ int result = 0;
+ bool ok = false;
+
+ while (!ok){
+ dlg->showMaximized();
+ result = dlg->exec();
+ ok = true;
+
+ if(result == QDialog::Accepted) {
+ if (!modem1->save()){
+ QMessageBox::critical(this, "error", tr( "You must enter a unique device name"));
+ ok = false;
+ }else{
+ modem2->save();
+ }
+ }
+ }
+
+ delete dlg;
+
+ return result;
+}
+
diff --git a/noncore/settings/networksettings/ppp/devices.h b/noncore/settings/networksettings/ppp/devices.h
index d46d5b4..c2679c8 100644
--- a/noncore/settings/networksettings/ppp/devices.h
+++ b/noncore/settings/networksettings/ppp/devices.h
@@ -1,60 +1,51 @@
#ifndef _DEVICES_H_
#define _DEVICES_H_
#include "kpppconfig.h"
-static const char *devices[] = {
-#ifdef __FreeBSD__
- "/dev/cuaa0",
- "/dev/cuaa1",
- "/dev/cuaa2",
- "/dev/cuaa3",
- "/dev/cuaa4",
-#elif defined(__NetBSD__)
- "/dev/tty00", /* "normal" modem lines */
- "/dev/tty01",
- "/dev/tty02",
- "/dev/tty03",
- "/dev/dty00", /* Dial out devices */
- "/dev/dty01",
- "/dev/dty02",
- "/dev/dty03",
- "/dev/ttyU0", /* USB stuff modems */
- "/dev/ttyU1",
- "/dev/ttyU2",
- "/dev/ttyU3",
- "/dev/dtyU0", /* USB stuff, too (dial out device) */
- "/dev/dtyU1",
- "/dev/dtyU2",
- "/dev/dtyU3",
-#elif defined (__linux__)
- "/dev/modem",
- "/dev/ttyS0",
- "/dev/ttyS1",
- "/dev/ttyS2",
- "/dev/ttyS3",
-#ifdef ISDNSUPPORT
- "/dev/ttyI0",
- "/dev/ttyI1",
- "/dev/ttyI2",
- "/dev/ttyI3",
-#endif
- "/dev/usb/ttyACM0", /* USB stuff modems */
- "/dev/usb/ttyACM1",
- "/dev/usb/ttyACM2",
- "/dev/usb/ttyACM3",
- "/dev/ircomm0",
- "/dev/rfcomm0",
- "/dev/rfcomm1",
-#elif defined(__svr4__)
- "/dev/cua/a",
- "/dev/cua/b",
- "/dev/ttya",
- "/dev/ttyb",
-#endif
- 0};
+#include <qwidget.h>
+#include <qdialog.h>
+#include <qpushbutton.h>
+#include <qlistbox.h>
+#include "chooserwidget.h"
+
+class QCheckBox;
+class QLineEdit;
+class QTabWidget;
+class DialWidget;
+class AuthWidget;
+class IPWidget;
+class DNSWidget;
+class GatewayWidget;
+class InterfacePPP;
+class PPPData;
+class ModemWidget;
+class ModemWidget2;
+
+class DevicesWidget : public ChooserWidget {
+ Q_OBJECT
+public:
+ DevicesWidget( InterfacePPP* ip, QWidget *parent=0, const char *name=0, WFlags f=0 );
+ ~DevicesWidget() {}
+
+
+private slots:
+ virtual void edit();
+ virtual void copy();
+ virtual void remove();
+ virtual void create();
+ virtual void slotListBoxSelect(int);
+ int doTab();
+
+// signals:
+// void resetaccounts();
+
+private:
+ ModemWidget *modem1;
+ ModemWidget2 *modem2;
+ InterfacePPP *_ifaceppp;
+
+};
-// default device number from the list above
-const int DEV_DEFAULT = 0;
#endif
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp
index 0c96253..ceac90c 100644
--- a/noncore/settings/networksettings/ppp/edit.cpp
+++ b/noncore/settings/networksettings/ppp/edit.cpp
@@ -31,99 +31,99 @@
#include <qregexp.h>
#include <qapplication.h>
#include <qbuttongroup.h>
#include <qvgroupbox.h>
#include <qhbox.h>
#include <qdialog.h>
#include <qpe/resource.h>
#include "edit.h"
#include "pppdata.h"
#include "iplined.h"
#include "auth.h"
DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount
, const char *name )
: QWidget(parent, name), _pppdata(pd)
{
const int GRIDROWS = 6;
QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );
connect_label = new QLabel(tr("Connection name:"), this);
tl->addWidget(connect_label, 0, 0);
connectname_l = new QLineEdit(this);
// connectname_l->setMaxLength(ACCNAME_SIZE);
tl->addWidget(connectname_l, 0, 1);
QString tmp = tr("Type in a unique name for this connection");
QWhatsThis::add(connect_label,tmp);
QWhatsThis::add(connectname_l,tmp);
number_label = new QLabel(tr("Phone number:"), this);
number_label->setAlignment(AlignTop|AlignLeft);
tl->addWidget(number_label, 1, 0);
QHBoxLayout *lpn = new QHBoxLayout(5);
tl->addLayout(lpn, 1, 1);
numbers = new QListBox(this);
// numbers->setMinimumSize(120, 70);
lpn->addWidget(numbers);
QVBoxLayout *lpn1 = new QVBoxLayout;
lpn->addLayout(lpn1);
add = new QPushButton(tr("&Add..."), this);
del = new QPushButton(tr("&Remove"), this);
up = new QPushButton(this);
- up->setPixmap( Resource::loadPixmap("inline/up") );
+ up->setPixmap( Resource::loadPixmap("up") );
down = new QPushButton(this);
- down->setPixmap( Resource::loadPixmap("inline/down") );
+ down->setPixmap( Resource::loadPixmap("down") );
lpn1->addWidget(add);
lpn1->addWidget(del);
lpn1->addStretch(1);
lpn1->addWidget(up);
lpn1->addWidget(down);
connect(add, SIGNAL(clicked()),
this, SLOT(addNumber()));
connect(del, SIGNAL(clicked()),
this, SLOT(delNumber()));
connect(up, SIGNAL(clicked()),
this, SLOT(upNumber()));
connect(down, SIGNAL(clicked()),
this, SLOT(downNumber()));
connect(numbers, SIGNAL(highlighted(int)),
this, SLOT(selectionChanged(int)));
numbersChanged();
tmp = tr("<p>Specifies the phone numbers to dial. You\n"
"can supply multiple numbers here, simply\n"
"click on \"Add\". You can arrange the\n"
"order the numbers are tried by using the\n"
"arrow buttons.\n\n"
"When a number is busy or fails, <i>kppp</i> will \n"
"try the next number and so on");
QWhatsThis::add(number_label,tmp);
QWhatsThis::add(numbers,tmp);
pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this);
connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton()));
tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter);
// Set defaults if editing an existing connection
if(!isnewaccount) {
connectname_l->setText(_pppdata->accname());
// insert the phone numbers into the listbox
QString n = _pppdata->phonenumber();
QString tmp = "";
uint idx = 0;
while(idx != n.length()) {
if(n[idx] == ':') {
if(tmp.length() > 0)
numbers->insertItem(tmp);
tmp = "";
} else
tmp += n[idx];
idx++;
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp
index f735e49..5540946 100644
--- a/noncore/settings/networksettings/ppp/general.cpp
+++ b/noncore/settings/networksettings/ppp/general.cpp
@@ -1,441 +1,518 @@
/*
* kPPP: A pppd front end for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* based on EzPPP:
* Copyright (C) 1997 Jay Painter
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <termios.h>
#include <string.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qslider.h>
#include <qspinbox.h>
#include <qwhatsthis.h>
-
+#include <qpe/config.h>
// #include <qgroupbox.h>
+
#include "general.h"
#include "interfaceppp.h"
//#include "miniterm.h"
#include "modeminfo.h"
#include "modemcmds.h"
-#include "devices.h"
+//#include "devices.h"
#include "pppdata.h"
//#include <klocale.h>
-#define i18n QObject::tr
-ModemWidget::ModemWidget( InterfacePPP *ifppp, QWidget *parent, const char *name )
- : QWidget(parent, name), _ifaceppp(ifppp)
+
+ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name )
+ : QWidget(parent, name), _pppdata(pd)
{
int k;
QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint());
QLabel *label1;
- label1 = new QLabel(i18n("Modem de&vice:"), this);
+
+ label1 = new QLabel(tr("Modem &name:"), this);
tl->addWidget(label1, 0, 0);
+ modemname = new QLineEdit(this, "modemName");
+ modemname->setText( _pppdata->devname() );
+ label1->setBuddy(modemname);
+ tl->addWidget(modemname, 0, 1);
+
+ label1 = new QLabel(tr("Modem de&vice:"), this);
+ tl->addWidget(label1, 1, 0);
+
modemdevice = new QComboBox(false, this);
+ modemdevice->setEditable( true );
+ modemdevice->setDuplicatesEnabled ( false );
+ modemdevice->setInsertionPolicy( QComboBox::AtTop );
label1->setBuddy(modemdevice);
- for(k = 0; devices[k]; k++)
- modemdevice->insertItem(devices[k]);
+ Config cfg("NetworkSetupPPP");
+ cfg.setGroup("Devices_General");
+ QStringList devs = cfg.readListEntry("devices",',');
+ if (devs.isEmpty()) devs << "/dev/modem" << "/dev/ircomm0" << "/dev/ttyS0";
+ modemdevice->insertStringList( devs );
+ tl->addWidget(modemdevice, 1, 1);
+
+// connect(modemdevice, SIGNAL(activated(int)),
+// SLOT(setmodemdc(int)));
+// connect(modemdevice, SIGNAL(textChanged( const QString & ) ),
+// SLOT( setmodemdc( const QString &) ) );
- tl->addWidget(modemdevice, 0, 1);
- connect(modemdevice, SIGNAL(activated(int)),
- SLOT(setmodemdc(int)));
- QString tmp = i18n("This specifies the serial port your modem is attached \n"
+ QString tmp = tr("This specifies the serial port your modem is attached \n"
"to. On Linux/x86, typically this is either /dev/ttyS0 \n"
"(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n"
"\n"
"If you have an internal ISDN card with AT command\n"
"emulation (most cards under Linux support this), you\n"
"should select one of the /dev/ttyIx devices.");
QWhatsThis::add(label1,tmp);
QWhatsThis::add(modemdevice,tmp);
- label1 = new QLabel(i18n("&Flow control:"), this);
- tl->addWidget(label1, 1, 0);
+ label1 = new QLabel(tr("&Flow control:"), this);
+ tl->addWidget(label1, 2, 0);
flowcontrol = new QComboBox(false, this);
label1->setBuddy(flowcontrol);
- flowcontrol->insertItem(i18n("Hardware [CRTSCTS]"));
- flowcontrol->insertItem(i18n("Software [XON/XOFF]"));
- flowcontrol->insertItem(i18n("None"));
- tl->addWidget(flowcontrol, 1, 1);
- connect(flowcontrol, SIGNAL(activated(int)),
- SLOT(setflowcontrol(int)));
-
- tmp = i18n("<p>Specifies how the serial port and modem\n"
+ flowcontrol->insertItem(tr("Hardware [CRTSCTS]"));
+ flowcontrol->insertItem(tr("Software [XON/XOFF]"));
+ flowcontrol->insertItem(tr("None"));
+ tl->addWidget(flowcontrol, 2, 1);
+// connect(flowcontrol, SIGNAL(activated(int)),
+// SLOT(setflowcontrol(int)));
+
+ tmp = tr("<p>Specifies how the serial port and modem\n"
"communicate. You should not change this unless\n"
"you know what you are doing.\n"
"\n"
"<b>Default</b>: CRTSCTS");
QWhatsThis::add(label1,tmp);
QWhatsThis::add(flowcontrol,tmp);
- QLabel *labelenter = new QLabel(i18n("&Line termination:"), this);
- tl->addWidget(labelenter, 2, 0);
+ QLabel *labelenter = new QLabel(tr("&Line termination:"), this);
+ tl->addWidget(labelenter, 3, 0);
enter = new QComboBox(false, this);
labelenter->setBuddy(enter);
enter->insertItem("CR");
enter->insertItem("LF");
enter->insertItem("CR/LF");
- tl->addWidget(enter, 2, 1);
- connect(enter, SIGNAL(activated(int)), SLOT(setenter(int)));
- tmp = i18n("<p>Specifies how AT commands are sent to your\n"
+ tl->addWidget(enter, 3, 1);
+// connect(enter, SIGNAL(activated(int)), SLOT(setenter(int)));
+ tmp = tr("<p>Specifies how AT commands are sent to your\n"
"modem. Most modems will work fine with the\n"
"default <i>CR/LF</i>. If your modem does not react\n"
"to the init string, you should try different\n"
"settings here\n"
"\n"
"<b>Default</b>: CR/LF");
QWhatsThis::add(labelenter,tmp);
QWhatsThis::add(enter, tmp);
- QLabel *baud_label = new QLabel(i18n("Co&nnection speed:"), this);
- tl->addWidget(baud_label, 3, 0);
+ QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this);
+ tl->addWidget(baud_label, 4, 0);
baud_c = new QComboBox(this);
baud_label->setBuddy(baud_c);
static const char *baudrates[] = {
#ifdef B460800
"460800",
#endif
#ifdef B230400
"230400",
#endif
#ifdef B115200
"115200",
#endif
#ifdef B57600
"57600",
#endif
"38400",
"19200",
"9600",
"2400",
0};
for(k = 0; baudrates[k]; k++)
baud_c->insertItem(baudrates[k]);
baud_c->setCurrentItem(3);
- connect(baud_c, SIGNAL(activated(int)),
- this, SLOT(speed_selection(int)));
- tl->addWidget(baud_c, 3, 1);
+// connect(baud_c, SIGNAL(activated(int)),
+// this, SLOT(speed_selection(int)));
+ tl->addWidget(baud_c, 4, 1);
- tmp = i18n("Specifies the speed your modem and the serial\n"
+ tmp = tr("Specifies the speed your modem and the serial\n"
"port talk to each other. You should begin with\n"
"the default of 38400 bits/sec. If everything\n"
"works you can try to increase this value, but to\n"
"no more than 115200 bits/sec (unless you know\n"
"that your serial port supports higher speeds).");
QWhatsThis::add(baud_label,tmp);
QWhatsThis::add(baud_c,tmp);
for(int i=0; i <= enter->count()-1; i++) {
- if(_ifaceppp->data()->enter() == enter->text(i))
+ if(_pppdata->enter() == enter->text(i))
enter->setCurrentItem(i);
}
- tl->addRowSpacing(4, 10);
+ tl->addRowSpacing(5, 10);
//Modem Lock File
- modemlockfile = new QCheckBox(i18n("&Use lock file"), this);
+ modemlockfile = new QCheckBox(tr("&Use lock file"), this);
- modemlockfile->setChecked(_ifaceppp->data()->modemLockFile());
- connect(modemlockfile, SIGNAL(toggled(bool)),
- SLOT(modemlockfilechanged(bool)));
- tl->addMultiCellWidget(modemlockfile, 5, 5, 0, 1);
+ modemlockfile->setChecked(_pppdata->modemLockFile());
+// connect(modemlockfile, SIGNAL(toggled(bool)),
+// SLOT(modemlockfilechanged(bool)));
+ tl->addMultiCellWidget(modemlockfile, 6, 6, 0, 1);
// l12->addStretch(1);
QWhatsThis::add(modemlockfile,
- i18n("<p>To prevent other programs from accessing the\n"
+ tr("<p>To prevent other programs from accessing the\n"
"modem while a connection is established, a\n"
"file can be created to indicate that the modem\n"
"is in use. On Linux an example file would be\n"
"<tt>/var/lock/LCK..ttyS1</tt>\n"
"Here you can select whether this locking will\n"
"be done.\n"
"\n"
"<b>Default</b>: On"));
// Modem Timeout Line Edit Box
QHBoxLayout *timeoutLayout = new QHBoxLayout( this );
QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" );
modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" );
// modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this);
-// modemtimeout->setLabel(i18n("Modem &timeout:"));
+// modemtimeout->setLabel(tr("Modem &timeout:"));
// modemtimeout->setRange(1, 120, 1);
- modemtimeout->setSuffix(i18n(" sec"));
- modemtimeout->setValue( _ifaceppp->data()->modemTimeout() );
- connect(modemtimeout, SIGNAL(valueChanged(int)),
- SLOT(modemtimeoutchanged(int)));
+ modemtimeout->setSuffix(tr(" sec"));
+ modemtimeout->setValue( _pppdata->modemTimeout() );
+// connect(modemtimeout, SIGNAL(valueChanged(int)),
+// SLOT(modemtimeoutchanged(int)));
timeoutLayout->addWidget(timeoutlabel);
timeoutLayout->addWidget(modemtimeout);
- tl->addMultiCellLayout(timeoutLayout, 6, 6, 0, 1);
+ tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1);
QWhatsThis::add(modemtimeout,
- i18n("This specifies how long <i>kppp</i> waits for a\n"
+ tr("This specifies how long <i>kppp</i> waits for a\n"
"<i>CONNECT</i> response from your modem. The\n"
"recommended value is 30 seconds."));
//set stuff from gpppdata
for(int i=0; i <= enter->count()-1; i++) {
- if(_ifaceppp->data()->enter() == enter->text(i))
+ if(_pppdata->enter() == enter->text(i))
enter->setCurrentItem(i);
}
for(int i=0; i <= modemdevice->count()-1; i++) {
- if(_ifaceppp->data()->modemDevice() == modemdevice->text(i))
+ if(_pppdata->modemDevice() == modemdevice->text(i))
modemdevice->setCurrentItem(i);
}
for(int i=0; i <= flowcontrol->count()-1; i++) {
- if(_ifaceppp->data()->flowcontrol() == flowcontrol->text(i))
+ if(_pppdata->flowcontrol() == flowcontrol->text(i))
flowcontrol->setCurrentItem(i);
}
//set the modem speed
for(int i=0; i < baud_c->count(); i++)
- if(baud_c->text(i) == _ifaceppp->data()->speed())
+ if(baud_c->text(i) == _pppdata->speed())
baud_c->setCurrentItem(i);
- tl->setRowStretch(7, 1);
+ tl->setRowStretch(1, 1);
}
+ModemWidget::~ModemWidget()
+{
+ QStringList devs;
-void ModemWidget::speed_selection(int) {
- _ifaceppp->data()->setSpeed(baud_c->text(baud_c->currentItem()));
-}
+ for (int i=0;i<modemdevice->count();i++)
+ {
+ QString s = modemdevice->text(i);
+ s.simplifyWhiteSpace();
+ if (! s.isEmpty() ) devs << s;
+ }
-void ModemWidget::setenter(int ) {
- _ifaceppp->data()->setEnter(enter->text(enter->currentItem()));
-}
+ QString edited = modemdevice->currentText();
+ if ( !( edited ).isEmpty() ) {
+ edited.simplifyWhiteSpace();
+ if ( devs.contains( edited ) == 0 ) {
+ devs << edited;
+ }
+ _pppdata->setModemDevice( edited );
+ }
+
+ Config cfg("NetworkSetupPPP");
+ cfg.setGroup("Devices_General");
+ cfg.writeEntry("devices",devs,',');
-void ModemWidget::setmodemdc(int i) {
- _ifaceppp->data()->setModemDevice(modemdevice->text(i));
}
+// void ModemWidget::speed_selection(int) {
+// _pppdata->setSpeed(baud_c->text(baud_c->currentItem()));
+// }
-void ModemWidget::setflowcontrol(int i) {
- _ifaceppp->data()->setFlowcontrol(flowcontrol->text(i));
-}
+// void ModemWidget::setenter(int ) {
+// _pppdata->setEnter(enter->text(enter->currentItem()));
+// }
-void ModemWidget::modemlockfilechanged(bool set) {
- _ifaceppp->data()->setModemLockFile(set);
-}
+// void ModemWidget::setmodemdc(int i) {
+// _pppdata->setModemDevice(modemdevice->text(i));
+// }
-void ModemWidget::modemtimeoutchanged(int n) {
- _ifaceppp->data()->setModemTimeout(n);
-}
+// void ModemWidget::setmodemdc( const QString &string ) {
+// _pppdata->setModemDevice( string );
+// }
+
+// void ModemWidget::setflowcontrol(int i) {
+// _pppdata->setFlowcontrol(flowcontrol->text(i));
+// }
-ModemWidget2::ModemWidget2( InterfacePPP* ifp, QWidget *parent,
+// void ModemWidget::modemlockfilechanged(bool set) {
+// _pppdata->setModemLockFile(set);
+// }
+
+
+// void ModemWidget::modemtimeoutchanged(int n) {
+// _pppdata->setModemTimeout(n);
+// }
+
+
+
+bool ModemWidget::save()
+{
+ //first check to make sure that the device name is unique!
+ if(modemname->text().isEmpty() ||
+ !_pppdata->isUniqueDevname(modemname->text()))
+ return false;
+
+ qDebug("ModemWidget::save saving modem1 data");
+ _pppdata->setDevname( modemname->text() );
+ _pppdata->setModemDevice( modemdevice->currentText() );
+ _pppdata->setFlowcontrol(flowcontrol->currentText());
+ _pppdata->setFlowcontrol(flowcontrol->currentText());
+ _pppdata->setSpeed(baud_c->currentText());
+ _pppdata->setModemLockFile( modemlockfile->isChecked());
+ _pppdata->setModemTimeout( modemtimeout->value() );
+ return true;
+
+}
+
+ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent,
const char *name)
- : QWidget(parent, name), _ifaceppp(ifp)
+ : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip)
{
QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
- waitfordt = new QCheckBox(i18n("&Wait for dial tone before dialing"), this);
- waitfordt->setChecked(_ifaceppp->data()->waitForDialTone());
- connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool)));
+ waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this);
+ waitfordt->setChecked(_pppdata->waitForDialTone());
+// connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool)));
l1->addWidget(waitfordt);
QWhatsThis::add(waitfordt,
- i18n("<p>Normally the modem waits for a dial tone\n"
+ tr("<p>Normally the modem waits for a dial tone\n"
"from your phone line, indicating that it can\n"
"start to dial a number. If your modem does not\n"
"recognize this sound, or your local phone system\n"
"does not emit such a tone, uncheck this option\n"
"\n"
"<b>Default:</b>: On"));
QHBoxLayout *waitLayout = new QHBoxLayout( this );
QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" );
busywait = new QSpinBox( 0, 300, 5, this, "busyWait" );
// busywait = new KIntNumInput(_pppdata->busyWait(), this);
-// busywait->setLabel(i18n("B&usy wait:"));
+// busywait->setLabel(tr("B&usy wait:"));
// busywait->setRange(0, 300, 5, true);
- busywait->setSuffix(i18n(" sec"));
- connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int)));
+ busywait->setSuffix(tr(" sec"));
+// connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int)));
waitLayout->addWidget(waitLabel);
waitLayout->addWidget(busywait);
l1->addLayout( waitLayout );
QWhatsThis::add(busywait,
- i18n("Specifies the number of seconds to wait before\n"
+ tr("Specifies the number of seconds to wait before\n"
"redial if all dialed numbers are busy. This is\n"
"necessary because some modems get stuck if the\n"
"same number is busy too often.\n"
"\n"
"The default is 0 seconds, you should not change\n"
"this unless you need to."));
l1->addSpacing(10);
QHBoxLayout *hbl = new QHBoxLayout;
hbl->setSpacing(2);//KDialog::spacingHint());
- QLabel *volumeLabel = new QLabel(i18n("Modem &volume:"), this);
+ QLabel *volumeLabel = new QLabel(tr("Modem &volume:"), this);
hbl->addWidget(volumeLabel);
- volume = new QSlider(0, 2, 1, _ifaceppp->data()->volume(),
+ volume = new QSlider(0, 2, 1, _pppdata->volume(),
QSlider::Horizontal, this);
volumeLabel->setBuddy(volume);
volume->setTickmarks(QSlider::Below);
hbl->addWidget(volume);
l1->addLayout(hbl);
- connect(volume, SIGNAL(valueChanged(int)),
- this, SLOT(volumeChanged(int)));
- QString tmp = i18n("Most modems have a speaker which makes\n"
+// connect(volume, SIGNAL(valueChanged(int)),
+// this, SLOT(volumeChanged(int)));
+ QString tmp = tr("Most modems have a speaker which makes\n"
"a lot of noise when dialing. Here you can\n"
"either turn this completely off or select a\n"
"lower volume.\n"
"\n"
"If this does not work for your modem,\n"
"you must modify the modem volume command.");
QWhatsThis::add(volumeLabel,tmp);
QWhatsThis::add(volume, tmp);
l1->addSpacing(20);
#if 0
- chkbox1 = new QCheckBox(i18n("Modem asserts CD line"), this);
- chkbox1->setChecked(_ifaceppp->data()->UseCDLine());
+ chkbox1 = new QCheckBox(tr("Modem asserts CD line"), this);
+ chkbox1->setChecked(_pppdata->UseCDLine());
connect(chkbox1,SIGNAL(toggled(bool)),
this,SLOT(use_cdline_toggled(bool)));
l12->addWidget(chkbox1);
l12->addStretch(1);
l1->addStretch(1);
QWhatsThis::add(chkbox1,
- i18n("This controls how <i>kppp</i> detects that the modem\n"
+ tr("This controls how <i>kppp</i> detects that the modem\n"
"is not responding. Unless you are having\n"
"problems with this, do not modify this setting.\n"
"\n"
"<b>Default</b>: Off"));
#endif
- modemcmds = new QPushButton(i18n("Mod&em Commands..."), this);
+ modemcmds = new QPushButton(tr("Mod&em Commands..."), this);
QWhatsThis::add(modemcmds,
- i18n("Allows you to change the AT command for\n"
+ tr("Allows you to change the AT command for\n"
"your modem."));
- modeminfo_button = new QPushButton(i18n("&Query Modem..."), this);
+ modeminfo_button = new QPushButton(tr("&Query Modem..."), this);
QWhatsThis::add(modeminfo_button,
- i18n("Most modems support the ATI command set to\n"
+ tr("Most modems support the ATI command set to\n"
"find out vendor and revision of your modem.\n"
"\n"
"Press this button to query your modem for\n"
"this information. It can be useful to help\n"
"you setup the modem"));
-// terminal_button = new QPushButton(i18n("&Terminal..."), this);
+// terminal_button = new QPushButton(tr("&Terminal..."), this);
// QWhatsThis::add(terminal_button,
-// i18n("Opens the built-in terminal program. You\n"
+// tr("Opens the built-in terminal program. You\n"
// "can use this if you want to play around\n"
// "with your modem's AT command set"));
QHBoxLayout *hbox = new QHBoxLayout();
l1->addLayout(hbox);
hbox->addStretch(1);
QVBoxLayout *vbox = new QVBoxLayout();
hbox->addLayout(vbox);
vbox->addWidget(modemcmds);
vbox->addWidget(modeminfo_button);
// vbox->addWidget(terminal_button);
hbox->addStretch(1);
l1->addStretch(1);
connect(modemcmds, SIGNAL(clicked()),
SLOT(modemcmdsbutton()));
connect(modeminfo_button, SIGNAL(clicked()),
SLOT(query_modem()));
// connect(terminal_button, SIGNAL(clicked()),
// SLOT(terminal()));
}
void ModemWidget2::modemcmdsbutton() {
- ModemCommands mc(_ifaceppp->data(), this);
+ ModemCommands mc(_ifaceppp->data(), this, "commands" , true, Qt::WStyle_ContextHelp);
mc.showMaximized();
mc.exec();
}
void ModemWidget2::query_modem() {
ModemTransfer mt(_ifaceppp->modem(), this);
mt.exec();
}
// void ModemWidget2::terminal() {
// MiniTerm terminal(NULL,NULL);
// terminal.exec();
// }
-#if 0
-void ModemWidget2::use_cdline_toggled(bool on) {
- _ifaceppp->data()->setUseCDLine(on);
-}
-#endif
+// #if 0
+// void ModemWidget2::use_cdline_toggled(bool on) {
+// _pppdata->setUseCDLine(on);
+// }
+// #endif
-void ModemWidget2::waitfordtchanged(bool b) {
- _ifaceppp->data()->setWaitForDialTone((int)b);
-}
+// void ModemWidget2::waitfordtchanged(bool b) {
+// _pppdata->setWaitForDialTone((int)b);
+// }
-void ModemWidget2::busywaitchanged(int n) {
- _ifaceppp->data()->setbusyWait(n);
-}
+// void ModemWidget2::busywaitchanged(int n) {
+// _pppdata->setbusyWait(n);
+// }
-void ModemWidget2::volumeChanged(int v) {
- _ifaceppp->data()->setVolume(v);
+// void ModemWidget2::volumeChanged(int v) {
+// _pppdata->setVolume(v);
+// }
+
+bool ModemWidget2::save()
+{
+ _pppdata->setWaitForDialTone(waitfordt->isChecked());
+ _pppdata->setbusyWait(busywait->value());
+ _pppdata->setVolume(volume->value());
+ return true;
}
diff --git a/noncore/settings/networksettings/ppp/general.h b/noncore/settings/networksettings/ppp/general.h
index 3e59b46..f43f241 100644
--- a/noncore/settings/networksettings/ppp/general.h
+++ b/noncore/settings/networksettings/ppp/general.h
@@ -1,100 +1,108 @@
/*
*
* kPPP: A pppd front end for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _GENERAL_H_
#define _GENERAL_H_
#include <qwidget.h>
class QSlider;
class QSpinBox;
class QCombobox;
class QLabel;
class QCheckBox;
class QComboBox;
class PPPData;
class InterfacePPP;
+class QLineEdit;
class ModemWidget : public QWidget {
Q_OBJECT
public:
- ModemWidget( InterfacePPP*, QWidget *parent=0, const char *name=0 );
+ ModemWidget(PPPData*, QWidget *parent=0, const char *name=0 );
+ ~ModemWidget();
-private slots:
- void setmodemdc(int);
- void setflowcontrol(int);
- void modemtimeoutchanged(int);
- void modemlockfilechanged(bool);
- void setenter(int);
- void speed_selection(int);
+ bool save();
+
+/* private slots: */
+/* void setmodemdc(int); */
+/* void setmodemdc(const QString &); */
+/* void setflowcontrol(int); */
+/* void modemtimeoutchanged(int); */
+/* void modemlockfilechanged(bool); */
+/* void setenter(int); */
+/* void speed_selection(int); */
private:
QComboBox *enter;
/* QLabel *label1; */
/* QLabel *label2; */
/* QLabel *labeltmp; */
/* QLabel *labelenter; */
+ QLineEdit *modemname;
QComboBox *modemdevice;
QComboBox *flowcontrol;
QComboBox *baud_c;
QLabel *baud_label;
QSpinBox *modemtimeout;
QCheckBox *modemlockfile;
- InterfacePPP *_ifaceppp;
+ PPPData *_pppdata;
};
class ModemWidget2 : public QWidget {
Q_OBJECT
public:
- ModemWidget2( InterfacePPP*, QWidget *parent=0, const char *name=0 );
+ ModemWidget2( PPPData*, InterfacePPP*, QWidget *parent=0, const char *name=0 );
+ bool save();
private slots:
- void waitfordtchanged(bool);
- void busywaitchanged(int);
+/* void waitfordtchanged(bool); */
+/* void busywaitchanged(int); */
// void use_cdline_toggled(bool);
void modemcmdsbutton();
// void terminal();
void query_modem();
- void volumeChanged(int);
+ // void volumeChanged(int);
private:
QLabel *labeltmp;
QPushButton *modemcmds;
QPushButton *modeminfo_button;
// QPushButton *terminal_button;
// QFrame *fline;
QCheckBox *waitfordt;
QSpinBox *busywait;
QCheckBox *chkbox1;
QSlider *volume;
+ PPPData *_pppdata;
InterfacePPP *_ifaceppp;
};
#endif
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
index 553daa2..6b158b9 100644
--- a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
+++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
@@ -1,37 +1,41 @@
#include "interfaceinformationppp.h"
-
#include <qpushbutton.h>
#include <qlabel.h>
-//#include <qgroupbox.h>
#include <qmessagebox.h>
#include <qabstractlayout.h>
#include "connect.h"
#include "conwindow.h"
#ifdef QWS
#else
#define showMaximized show
#endif
/**
* Constructor for the InterfaceInformationImp class. This class pretty much
* just display's information about the interface that is passed to it.
*/
InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f)
- :InterfaceInformationImp(parent, name, i, f)
+ :InterfaceInformationImp(parent, name, i, Qt::WStyle_ContextHelp)
{
- qDebug("InterfaceInformationPPP::InterfaceInformationPPP");
+ qDebug("InterfaceInformationPPP::InterfaceInformationPPP %s", name);
con = new ConnectWidget( (InterfacePPP*)i, this, "con" );
con->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding,
QSizePolicy::Fixed) );
- QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
- InterfaceInformationLayout->addItem( spacer, 7, 0 );
- InterfaceInformationLayout->addMultiCellWidget( con, 8, 8, 0, 1 );
- // InterfaceInformationLayout->addWidget( con, 7, 0 );
+
+ macAddressLabel->hide();
+ subnetMaskLabel->hide();
+ broadcastLabel->hide();
+ TextLabel23->hide();
+ TextLabel21->hide();
+ TextLabel24->hide();
+
+ InterfaceInformationLayout->addWidget( con, 1, 0 );
connect(i, SIGNAL(begin_connect()),con, SLOT(preinit()));
+ connect(i, SIGNAL(hangup_now() ), con, SLOT(cancelbutton() ) );
}
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.cpp b/noncore/settings/networksettings/ppp/interfaceppp.cpp
index 9ec30bc..f443f3c 100644
--- a/noncore/settings/networksettings/ppp/interfaceppp.cpp
+++ b/noncore/settings/networksettings/ppp/interfaceppp.cpp
@@ -1,142 +1,174 @@
#include <qmessagebox.h>
-#define i18n QObject::tr
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qlabel.h>
#include "auth.h"
#include "interfaceppp.h"
#include "modem.h"
#include "pppdata.h"
InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status)
: Interface(parent, name, status),
_modemPtr(0),
_dataPtr(0)
{
qDebug("InterfacePPP::InterfacePPP(");
}
-PPPData* InterfacePPP::data()
+PPPData* InterfacePPP::data()const
{
if (!_dataPtr){
qDebug("creating new Data obj");
_dataPtr = new PPPData();
- _dataPtr->setModemDevice( getInterfaceName() );
+ _dataPtr->setDevice( getInterfaceName() );
_dataPtr->setAccount( getHardwareName() );
}
return _dataPtr;
}
-Modem* InterfacePPP::modem()
+Modem* InterfacePPP::modem()const
{
if (!_modemPtr){
qDebug("creating new modem obj");
_modemPtr = new Modem( data() );
}
return _modemPtr;
}
bool InterfacePPP::refresh()
{
qDebug("InterfacePPP::refresh()");
- updateInterface(this);
- QMessageBox::information(0,"Not Implemented","This feature is not yet implemneted... ;-(");
- return false;
+ QString old = getInterfaceName();
+ setInterfaceName( modem()->pppDevice() );
+
+ (void)Interface::refresh();
+
+ setInterfaceName( old );
+ emit updateInterface(this);
+
+ return true;
}
void InterfacePPP::start()
{
qDebug("InterfacePPP::start");
-// should work...
-// if (data()->password().isEmpty() ){
-// //FIXME: ask for password
-// qDebug("using dummy password");
-// QMessageBox::critical( 0, "no password", "you should be prompted for a password, but you are not! ;-)");
-// }
+ if (data()->password().isEmpty() && !data()->storedUsername().isEmpty() ) {
+
+ QDialog mb( 0, "Dialog", true );
+ mb.setCaption( tr( "No password" ) );
+ QVBoxLayout layout( &mb );
+ QLabel text ( &mb );
+ text.setText( tr("Username defined but no password\n Please enter a password") );
+ QLineEdit lineedit( &mb );
+ lineedit.setEchoMode( QLineEdit::Password );
+ layout.addWidget( &text );
+ layout.addWidget( &lineedit );
+ if ( mb.exec() == QDialog::Accepted ) {
+ data()->setPassword( lineedit.text() );
+ }
+ }
QFileInfo info(pppdPath());
if(!info.exists()){
QMessageBox::warning(0, tr("Error"),
- i18n("<qt>Cannot find the PPP daemon!<br>"
+ QObject::tr("<qt>Cannot find the PPP daemon!<br>"
"Make sure that pppd is installed and "
"that you have entered the correct path.</qt>"));
return;
}
//#if 0
if(!info.isExecutable()){
QString string;
- string = i18n( "<qt>Cannot execute:<br> %1<br>"
+ string = QObject::tr( "<qt>Cannot execute:<br> %1<br>"
"Please make sure that you have given "
"setuid permission and that "
"pppd is executable.<br>").arg(pppdPath());
QMessageBox::warning(0, tr("Error"), string);
return;
}
//#endif
QFileInfo info2(data()->modemDevice());
if(!info2.exists()){
QString string;
- string = i18n( "<qt>Cannot find:<br> %1<br>"
+ string = QObject::tr( "<qt>Cannot find:<br> %1<br>"
"Please make sure you have setup "
"your modem device properly "
"and/or adjust the location of the modem device on "
"the modem tab of "
"the setup dialog.</qt>").arg(data()->modemDevice());
QMessageBox::warning(0, tr("Error"), string);
return;
}
// if this is a PAP or CHAP account, ensure that username is
// supplied
if(data()->authMethod() == AUTH_PAP ||
data()->authMethod() == AUTH_CHAP ||
data()->authMethod() == AUTH_PAPCHAP ) {
if(false){ //FIXME: ID_Edit->text().isEmpty()) {
QMessageBox::warning(0,tr("Error"),
- i18n("<qt>You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!</qt>"));
+ QObject::tr("<qt>You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!</qt>"));
// FIXME: return;
} else {
if(!modem()->setSecret(data()->authMethod(),
PPPData::encodeWord(data()->storedUsername()),
PPPData::encodeWord(data()->password()))
) {
QString s;
- s = i18n("<qt>Cannot create PAP/CHAP authentication<br>"
+ s = QObject::tr("<qt>Cannot create PAP/CHAP authentication<br>"
"file \"%1\"</qt>").arg(PAP_AUTH_FILE);
QMessageBox::warning(0, tr("Error"), s);
return;
}
}
}
if (data()->phonenumber().isEmpty()) {
- QString s = i18n("You must specify a telephone number!");
+ QString s = QObject::tr("You must specify a telephone number!");
QMessageBox::warning(0, tr("Error"), s);
return;
}
// SEGFAULTS:
// setStatus( true );
// emit updateInterface((Interface*) this);
emit begin_connect();
qDebug("InterfacePPP::start END");
}
void InterfacePPP::stop()
{
qDebug("InterfacePPP::stop");
+ // emit hangup_now();
+ status = false; // not connected
+ setStatus( false );
+ emit hangup_now();
+ refresh();
}
void InterfacePPP::save()
{
data()->save();
emit updateInterface((Interface*) this);
}
+QString InterfacePPP::pppDev()const {
+ return modem()->pppDevice();
+}
+pid_t InterfacePPP::pppPID()const{
+ return modem()->pppPID();
+}
+void InterfacePPP::setPPPDpid( pid_t pid) {
+ setStatus( true );
+ modem()->setPPPDPid( pid );
+}
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.h b/noncore/settings/networksettings/ppp/interfaceppp.h
index 6eb6a69..39495c2 100644
--- a/noncore/settings/networksettings/ppp/interfaceppp.h
+++ b/noncore/settings/networksettings/ppp/interfaceppp.h
@@ -1,34 +1,40 @@
-#ifndef INTERFACEPPP_H
+#ifndef INTERFACEPPP_H
#define INTERFACEPPP_H
+#include <sys/types.h>
+
#include "interface.h"
class PPPData;
class Modem;
class InterfacePPP : public Interface
{
Q_OBJECT
public:
InterfacePPP(QObject *parent=0, const char *name="PPP", bool status=false);
- PPPData* data();
- Modem* modem();
+ PPPData* data()const;
+ Modem* modem()const;
+ QString pppDev()const; // returns the ppp device.... /dev/ppp0...
+ pid_t pppPID()const;
signals:
void begin_connect();
+ void hangup_now();
public slots:
virtual bool refresh();
virtual void start();
virtual void stop();
void save();
+ void setPPPDpid( pid_t ); // sets the pppd pid for modem...
private:
- Modem *_modemPtr;
- PPPData *_dataPtr;
+ mutable Modem *_modemPtr;
+ mutable PPPData *_dataPtr;
};
#endif
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp
index 7b5c74d..e466358 100644
--- a/noncore/settings/networksettings/ppp/kpppwidget.cpp
+++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp
@@ -1,337 +1,326 @@
/*
*
* kPPP: A pppd front end for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* Copyright (C) 1998-2002 Harri Porten <porten@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "kpppwidget.h"
#include <qapplication.h>
#include <qcombobox.h>
#include <qdir.h>
#include <qevent.h>
#include <qdialog.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qregexp.h>
#include <qtabwidget.h>
#include <qdialog.h>
#include <qwhatsthis.h>
#include <qcheckbox.h>
// #include <kaboutdata.h>
// #include <kapplication.h>
#include <qbuttongroup.h>
-//#include <kcmdlineargs.h>
-//#include <kconfig.h>
-//#include <kdebug.h>
-#define i18n QObject::tr
-//#include <kiconloader.h> // For BarIcon
-//#include <klocale.h>
#include <qmessagebox.h>
-// #include <kseparator.h>
-// #include <kstandarddirs.h>
-// #include <kwin.h>
-// #include <khelpmenu.h>
#include <qpushbutton.h>
-//#include <kguiitem.h>
#include <stdlib.h>
#include <errno.h>
#include <signal.h>
#include "runtests.h"
//#include "main.h"
#include "auth.h"
#include "modem.h"
//#include "ppplog.h"
//#include "opener.h"
//#include "requester.h"
//#include "pppstats.h"
#include "pppdata.h"
#include "general.h"
#include "interface.h"
#define execute_command system
KPPPWidget *p_kppp = 0;
KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *name, bool modal, WFlags fl )
- : QDialog(parent, name, modal, fl), _pppdata(pd)
+ : QDialog(parent, name, modal, Qt::WStyle_ContextHelp ), _pppdata(pd)
{
// tabWindow = 0;
p_kppp = this;
// before doing anything else, run a few tests
if (!_pppdata->setModemDevice( i->getInterfaceName() ))
_pppdata->setModemDevice("/dev/modem");
qDebug("PPPConfigWidget::PPPConfigWidget");
qDebug(" interface->getHardwareName >%s<", i->getHardwareName().latin1());
if (!_pppdata->setAccount( i->getHardwareName() ))
_pppdata->setAccount( 0 );
qDebug(" _pppdata->accname >%s<",_pppdata->accname().latin1());
qDebug(" _pppdata->currentAccountID() >%i<",_pppdata->currentAccountID());
int result = runTests();
if(result == TEST_CRITICAL)
exit(4);
// installEventFilter(this);
QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
QGridLayout *l1 = new QGridLayout(3, 4);
tl->addLayout(l1);
l1->addColSpacing(0, 10);
l1->addColSpacing(3, 10);
l1->setColStretch(1, 3);
l1->setColStretch(2, 4);
- label1 = new QLabel(i18n("C&onnect to: "), this);
+ label1 = new QLabel(QObject::tr("C&onnect to: "), this);
l1->addWidget(label1, 0, 1);
connectto_c = new QComboBox(false, this);
label1->setBuddy(connectto_c);
connect(connectto_c, SIGNAL(activated(int)),
SLOT(newdefaultaccount(int)));
l1->addWidget(connectto_c, 0, 2);
- ID_Label = new QLabel(i18n("&Login ID:"), this);
+ ID_Label = new QLabel(QObject::tr("&Login ID:"), this);
l1->addWidget(ID_Label, 1, 1);
// the entry line for usernames
ID_Edit = new QLineEdit(this);
ID_Label->setBuddy(ID_Edit);
l1->addWidget(ID_Edit, 1, 2);
connect(ID_Edit, SIGNAL(returnPressed()),
this, SLOT(enterPressedInID()));
- QString tmp = i18n("<p>Type in the username that you got from your\n"
+ QString tmp = QObject::tr("<p>Type in the username that you got from your\n"
"ISP. This is especially important for PAP\n"
"and CHAP. You may omit this when you use\n"
"terminal-based or script-based authentication.\n"
"\n"
"<b>Important</b>: case is important here:\n"
"<i>myusername</i> is not the same as <i>MyUserName</i>!");
QWhatsThis::add(ID_Label,tmp);
QWhatsThis::add(ID_Edit,tmp);
- PW_Label = new QLabel(i18n("&Password:"), this);
+ PW_Label = new QLabel(QObject::tr("&Password:"), this);
l1->addWidget(PW_Label, 2, 1);
PW_Edit= new QLineEdit(this);
PW_Label->setBuddy(PW_Edit);
PW_Edit->setEchoMode(QLineEdit::Password);
l1->addWidget(PW_Edit, 2, 2);
connect(PW_Edit, SIGNAL(returnPressed()),
this, SLOT(enterPressedInPW()));
- tmp = i18n("<p>Type in the password that you got from your\n"
+ tmp = QObject::tr("<p>Type in the password that you got from your\n"
"ISP. This is especially important for PAP\n"
"and CHAP. You may omit this when you use\n"
"terminal-based or script-based authentication.\n"
"\n"
"<b>Important</b>: case is important here:\n"
"<i>mypassword</i> is not the same as <i>MyPassword</i>!");
QWhatsThis::add(PW_Label,tmp);
QWhatsThis::add(PW_Edit,tmp);
QHBoxLayout *l3 = new QHBoxLayout;
tl->addSpacing(5);
tl->addLayout(l3);
tl->addSpacing(5);
l3->addSpacing(10);
- log = new QCheckBox(i18n("Show lo&g window"), this);
+ log = new QCheckBox(QObject::tr("Show lo&g window"), this);
connect(log, SIGNAL(toggled(bool)),
this, SLOT(log_window_toggled(bool)));
log->setChecked(_pppdata->get_show_log_window());
l3->addWidget(log);
QWhatsThis::add(log,
- i18n("<p>This controls whether a log window is shown.\n"
+ QObject::tr("<p>This controls whether a log window is shown.\n"
"A log window shows the communication between\n"
"<i>kppp</i> and your modem. This will help you\n"
"in tracking down problems.\n"
"\n"
"Turn it off if <i>kppp</i> routinely connects without\n"
"problems"));
// fline = new QSeparator( KSeparator::HLine, this);
// tl->addWidget(fline);
QHBoxLayout *l2 = new QHBoxLayout(this);
tl->addLayout(l2);
int minw = 0;
- quit_b = new QPushButton(i18n("&Quit"), this);
- // quit_b-> setGuiItem (KGuiItem(i18n("&Quit"), "exit" ) );
+ quit_b = new QPushButton(QObject::tr("&Quit"), this);
+ // quit_b-> setGuiItem (KGuiItem(QObject::tr("&Quit"), "exit" ) );
connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton()));
if(quit_b->sizeHint().width() > minw)
minw = quit_b->sizeHint().width();
- setup_b = new QPushButton(i18n("&Setup..."), this);
-// setup_b->setGuiItem (KGuiItem(i18n("&Setup...")) );
+ setup_b = new QPushButton(QObject::tr("&Setup..."), this);
+// setup_b->setGuiItem (KGuiItem(QObject::tr("&Setup...")) );
connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton()));
if(setup_b->sizeHint().width() > minw)
minw = setup_b->sizeHint().width();
// if(_pppdata->access() != KConfig::ReadWrite)
// setup_b->setEnabled(false);
-// help_b = new QPushButton(i18n("&Help"), this);
+// help_b = new QPushButton(QObject::tr("&Help"), this);
// connect( help_b, SIGNAL(clicked()), SLOT(helpbutton()));
// KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true);
// help_b->setPopup((QPopupMenu*)helpMenu->menu());
-// help_b->setGuiItem (KGuiItem(i18n("&Help"), "help" ) );
+// help_b->setGuiItem (KGuiItem(QObject::tr("&Help"), "help" ) );
// if(help_b->sizeHint().width() > minw)
// minw = help_b->sizeHint().width();
- connect_b = new QPushButton(i18n("&Connect"), this);
+ connect_b = new QPushButton(QObject::tr("&Connect"), this);
connect_b->setDefault(true);
connect_b->setFocus();
connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect()));
if(connect_b->sizeHint().width() > minw)
minw = connect_b->sizeHint().width();
quit_b->setFixedWidth(minw);
setup_b->setFixedWidth(minw);
// help_b->setFixedWidth(help_b->sizeHint().width());
connect_b->setFixedWidth(minw);
l2->addWidget(quit_b);
l2->addWidget(setup_b);
// l2->addWidget(help_b);
l2->addSpacing(20);
l2->addWidget(connect_b);
setFixedSize(sizeHint());
(void)new Modem(_pppdata);
// we also connect cmld_start to the beginConnect so that I can run
// the dialer through a command line argument
connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect()));
// stats = new PPPStats;
// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
// constructor of con_win reads position from config file
con_win = new ConWindow(_pppdata, 0, "conw", this);
// KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon());
// statdlg = new PPPStatsDlg(0, "stats", this, stats);
// statdlg->hide();
// load up the accounts combo box
// resetaccounts();
con = new ConnectWidget(_pppdata, 0, "con");
//KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() );
connect(this, SIGNAL(begin_connect()),con, SLOT(preinit()));
// Is this the best we can do here? it's not right.
// QRect desk = QApplication::desktop()->screenGeometry(
// QApplication::desktop()->screenNumber(topLevelWidget()));
// con->setGeometry(desk.center().x()-175, desk.center().y()-55, 350,110);
// connect the ConnectWidgets various signals
connect(con, SIGNAL(startAccounting()),
this, SLOT(startAccounting()));
connect(con, SIGNAL(stopAccounting()),
this, SLOT(stopAccounting()));
connect(qApp, SIGNAL(saveYourself()),
this, SLOT(saveMyself()));
connect(qApp, SIGNAL(shutDown()),
this, SLOT(shutDown()));
// KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
// m_strCmdlAccount = args->getOption("c");
// m_bQuitOnDisconnect = args->isSet("q");
// if(!m_strCmdlAccount.isEmpty()) {
// m_bCmdlAccount = true;
// kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl;
// }
// if(m_bCmdlAccount){
// bool result = _pppdata->setAccount(m_strCmdlAccount);
// if (!result){
// QString string;
-// string = i18n("No such Account:\n%1").arg(m_strCmdlAccount);
+// string = QObject::tr("No such Account:\n%1").arg(m_strCmdlAccount);
// KMessageBox::error(this, string);
// m_bCmdlAccount = false;
// this->show();
// } else {
// beginConnect();
// }
// } else
// expandbutton();
// show();
//#define KPPP_SHOW_NEWS
#ifdef KPPP_SHOW_NEWS
// keep user informed about recent changes
if(!m_bCmdlAccount)
showNews();
#endif
}
KPPPWidget::~KPPPWidget()
{
p_kppp = 0;
// delete stats;
}
// bool KPPPWidget::eventFilter(QObject *o, QEvent *e) {
// if(e->type() == QEvent::User) {
// switch(((SignalEvent*)e)->sigType()) {
// case SIGINT:
// qDebug( "Received a SIGINT" );
// interruptConnection();
// break;
// case SIGCHLD:
// sigChld();
// break;
// case SIGUSR1:
// sigPPPDDied();
// break;
// }
// return true;
// }
// if(o == connect_b) {
// if(e->type() == QEvent::KeyPress) {
// if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) {
// beginConnect();
// return true;
// }
@@ -437,452 +426,452 @@ void KPPPWidget::sigPPPDDied() {
qDebug( "Received a SIGUSR1" );
// if we are not connected pppdpid is -1 so have have to check for that
// in the followin line to make sure that we don't raise a false alarm
// such as would be the case when the log file viewer exits.
if(_pppdata->pppdRunning() || _pppdata->pppdError()) {
qDebug( "It was pppd that died" );
// when we killpppd() on Cancel in ConnectWidget
// we set pppid to -1 so we won't
// enter this block
// just to be sure
Modem::modem->removeSecret(AUTH_PAP);
Modem::modem->removeSecret(AUTH_CHAP);
_pppdata->setpppdRunning(false);
qDebug( "Executing command on disconnect since pppd has died." );
QApplication::flushX();
execute_command(_pppdata->command_on_disconnect());
// stopAccounting();
con_win->stopClock();
// DockWidget::dock_widget->stop_stats();
// DockWidget::dock_widget->hide();
if(!_pppdata->pppdError())
_pppdata->setpppdError(E_PPPD_DIED);
removedns();
Modem::modem->unlockdevice();
//
con->pppdDied();
if(!_pppdata->automatic_redial()) {
quit_b->setFocus();
show();
con_win->stopClock();
// stopAccounting();
con_win->hide();
con->hide();
_pppdata->setpppdRunning(false);
// // not in a signal handler !!! KNotifyClient::beep();
QString msg;
if (_pppdata->pppdError() == E_IF_TIMEOUT)
- msg = i18n("Timeout expired while waiting for the PPP interface "
+ msg = QObject::tr("Timeout expired while waiting for the PPP interface "
"to come up!");
else {
- msg = i18n("<p>The pppd daemon died unexpectedly!</p>");
+ msg = QObject::tr("<p>The pppd daemon died unexpectedly!</p>");
Modem::modem->pppdExitStatus();
if (Modem::modem->lastStatus != 99) { // more recent pppds only
- msg += i18n("<p>Exit status: %1").arg(Modem::modem->lastStatus);
- msg += i18n("</p><p>See 'man pppd' for an explanation of the error "
+ msg += QObject::tr("<p>Exit status: %1").arg(Modem::modem->lastStatus);
+ msg += QObject::tr("</p><p>See 'man pppd' for an explanation of the error "
"codes or take a look at the kppp FAQ on "
" <a href=http://devel-home.kde.org/~kppp/index.html>"
"http://devel-home.kde.org/~kppp/index.html</a></p>");
}
}
-// if(QMessageBox::warning(0, msg, i18n("Error"), i18n("&OK"), i18n("&Details...")) == QMessageBox::No)
+// if(QMessageBox::warning(0, msg, QObject::tr("Error"), QObject::tr("&OK"), QObject::tr("&Details...")) == QMessageBox::No)
// // PPPL_ShowLog();
// } else { /* reconnect on disconnect */
if (false){
qDebug( "Trying to reconnect... " );
if(_pppdata->authMethod() == AUTH_PAP ||
_pppdata->authMethod() == AUTH_CHAP ||
_pppdata->authMethod() == AUTH_PAPCHAP)
Modem::modem->setSecret(_pppdata->authMethod(),
encodeWord(_pppdata->storedUsername()),
encodeWord(_pppdata->password()));
con_win->hide();
con_win->stopClock();
// stopAccounting();
_pppdata->setpppdRunning(false);
// not in a signal handler !!! KNotifyClient::beep();
emit cmdl_start();
}
}
_pppdata->setpppdError(0);
}
}
// void KPPPWidget::sigChld() {
// qDebug( "sigchld()" );
// // pid_t id = wait(0L);
// // if(id == helperPid && helperPid != -1) {
// // kdDebug(5002) << "It was the setuid child that died" << endl;
// // helperPid = -1;
-// QString msg = i18n("kppp's helper process just died.\n"
+// QString msg = QObject::tr("kppp's helper process just died.\n"
// "Since a further execution would be pointless, "
// "kppp will shut down now.");
// QMessageBox::warning(0L,"error", msg);
// //remove_pidfile();
// exit(1);
// // }
// }
void KPPPWidget::newdefaultaccount(int i) {
_pppdata->setDefaultAccount(connectto_c->text(i));
_pppdata->save();
ID_Edit->setText(_pppdata->storedUsername());
PW_Edit->setText(_pppdata->storedPassword());
}
void KPPPWidget::beginConnect() {
// make sure to connect to the account that is selected in the combo box
// (exeption: an account given by a command line argument)
// if(!m_bCmdlAccount) {
// _pppdata->setAccount(connectto_c->currentText());
// _pppdata->setPassword(PW_Edit->text());
// } else {
_pppdata->setPassword(_pppdata->storedPassword());
// }
QFileInfo info(pppdPath());
if(!info.exists()){
- QMessageBox::warning(this, "error", i18n("Cannot find the PPP daemon!\n"
+ QMessageBox::warning(this, "error", QObject::tr("Cannot find the PPP daemon!\n"
"Make sure that pppd is installed and "
"that you have entered the correct path."));
return;
}
#if 0
if(!info.isExecutable()){
QString string;
- string = i18n("kppp cannot execute:\n %1\n"
+ string = QObject::tr("kppp cannot execute:\n %1\n"
"Please make sure that you have given kppp "
"setuid permission and that "
"pppd is executable.").arg(_pppdata->pppdPath());
KMessageBox::error(this, string);
return;
}
#endif
QFileInfo info2(_pppdata->modemDevice());
if(!info2.exists()){
QString string;
- string = i18n("kppp can not find:\n %1\nPlease make sure you have setup "
+ string = QObject::tr("kppp can not find:\n %1\nPlease make sure you have setup "
"your modem device properly "
"and/or adjust the location of the modem device on "
"the modem tab of "
"the setup dialog.").arg(_pppdata->modemDevice());
QMessageBox::warning(this, "error", string);
return;
}
// if this is a PAP or CHAP account, ensure that username is
// supplied
if(_pppdata->authMethod() == AUTH_PAP ||
_pppdata->authMethod() == AUTH_CHAP ||
_pppdata->authMethod() == AUTH_PAPCHAP ) {
if(ID_Edit->text().isEmpty()) {
QMessageBox::warning(this,"error",
- i18n("You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!"));
+ QObject::tr("You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!"));
return;
} else {
if(!Modem::modem->setSecret(_pppdata->authMethod(),
encodeWord(_pppdata->storedUsername()),
encodeWord(_pppdata->password()))) {
QString s;
- s = i18n("Cannot create PAP/CHAP authentication\n"
+ s = QObject::tr("Cannot create PAP/CHAP authentication\n"
"file \"%1\"").arg(PAP_AUTH_FILE);
QMessageBox::warning(this, "error", s);
return;
}
}
}
if (_pppdata->phonenumber().isEmpty()) {
- QString s = i18n("You must specify a telephone number!");
+ QString s = QObject::tr("You must specify a telephone number!");
QMessageBox::warning(this, "error", s);
return;
}
this->hide();
- QString tit = i18n("Connecting to: %1").arg(_pppdata->accname());
+ QString tit = QObject::tr("Connecting to: %1").arg(_pppdata->accname());
// con->setCaption(tit);
// con->show();
emit begin_connect();
}
void KPPPWidget::disconnect() {
if (!_pppdata->command_before_disconnect().isEmpty()) {
con_win->hide();
con->show();
- con->setCaption(i18n("Disconnecting..."));
- con->setMsg(i18n("Executing command before disconnection."));
+ con->setCaption(QObject::tr("Disconnecting..."));
+ con->setMsg(QObject::tr("Executing command before disconnection."));
qApp->processEvents();
QApplication::flushX();
// pid_t id =
execute_command(_pppdata->command_before_disconnect());
// int i, status;
// do {
// kapp->processEvents();
// i = waitpid(id, &status, WNOHANG);
// usleep(500000);
// } while (i == 0 && errno == 0);
con->hide();
}
qApp->processEvents();
// statdlg->stop_stats();
Modem::modem->killPPPDaemon();
QApplication::flushX();
execute_command(_pppdata->command_on_disconnect());
Modem::modem->removeSecret(AUTH_PAP);
Modem::modem->removeSecret(AUTH_CHAP);
removedns();
Modem::modem->unlockdevice();
con_win->stopClock();
// p_kppp->stopAccounting();
con_win->hide();
// DockWidget::dock_widget->stop_stats();
// DockWidget::dock_widget->hide();
// if(m_bQuitOnDisconnect)
// kapp->exit(0);
// else {
this->quit_b->setFocus();
this->show();
// }
}
// void KPPPWidget::helpbutton() {
// kapp->invokeHelp();
// }
void KPPPWidget::quitbutton() {
if(_pppdata->pppdRunning()) {
int ok = QMessageBox::warning(this,
- i18n("Exiting kPPP will close your PPP Session."),
- i18n("Quit kPPP?"));
+ QObject::tr("Exiting kPPP will close your PPP Session."),
+ QObject::tr("Quit kPPP?"));
if(ok == QMessageBox::Yes) {
Modem::modem->killPPPDaemon();
QApplication::flushX();
execute_command(_pppdata->command_on_disconnect());
removedns();
Modem::modem->unlockdevice();
}
} else {
if (!_pppdata->accname().isEmpty() && !_pppdata->storePassword())
_pppdata->setStoredPassword("");
}
_pppdata->save();
qApp->quit();
}
// void KPPPWidget::rulesetLoadError() {
// QMessageBox::warning(this,"error", ruleset_load_errmsg);
// }
// void KPPPWidget::startAccounting() {
// // volume accounting
// stats->totalbytes = 0;
// kdDebug() << "AcctEnabled: " << _pppdata->AcctEnabled() << endl;
// // load the ruleset
// if(!_pppdata->AcctEnabled())
// return;
// QString d = AccountingBase::getAccountingFile(_pppdata->accountingFile());
// // if(::access(d.data(), X_OK) != 0)
// acct = new Accounting(this, stats);
// // else
// // acct = new ExecutableAccounting(this);
// // connect to the accounting object
// connect(acct, SIGNAL(changed(QString, QString)),
// con_win, SLOT(slotAccounting(QString, QString)));
// // if(!acct->loadRuleSet(_pppdata->accountingFile())) {
-// // QString s= i18n("Can not load the accounting "
+// // QString s= QObject::tr("Can not load the accounting "
// // "ruleset \"%1\"!").arg(_pppdata->accountingFile());
// // starting the messagebox with a timer will prevent us
// // from blocking the calling function ConnectWidget::timerEvent
// ruleset_load_errmsg = s;
// QTimer::singleShot(0, this, SLOT(rulesetLoadError()));
// return;
// }
// //else
// // acct->slotStart();
// }
// void KPPPWidget::stopAccounting() {
// // store volume accounting
// // if(stats->totalbytes != 0)
// // _pppdata->setTotalBytes(stats->totalbytes);
// if(!_pppdata->AcctEnabled())
// return;
// // if(acct != 0) {
// // acct->slotStop();
// // delete acct;
// // acct = 0;
// // }
// }
// void KPPPWidget::showStats() {
// if(statdlg) {
// statdlg->show();
// statdlg->raise();
// }
// }
void KPPPWidget::usernameChanged(const QString &) {
// store username for later use
_pppdata->setStoredUsername(ID_Edit->text());
}
void KPPPWidget::passwordChanged(const QString &) {
// store the password if so requested
if(_pppdata->storePassword())
_pppdata->setStoredPassword(PW_Edit->text());
else
_pppdata->setStoredPassword("");
}
void KPPPWidget::setPW_Edit(const QString &pw) {
PW_Edit->setText(pw);
}
// void KPPPWidget::resetCosts(const QString &s) {
// AccountingBase::resetCosts(s);
// }
// void KPPPWidget::resetVolume(const QString &s) {
// AccountingBase::resetVolume(s);
// }
/**
* pppd's getword() function knows about escape characters.
* If we write the username and password to the secrets file
* we'll therefore have to escape back slashes.
*/
QString KPPPWidget::encodeWord(const QString &s) {
QString r = s;
r.replace(QRegExp("\\"), "\\\\");
return r;
}
// void KPPPWidget::setQuitOnDisconnect (bool b)
// {
// m_bQuitOnDisconnect = b;
// }
void KPPPWidget::showNews() {
#ifdef KPPP_SHOW_NEWS
/*
* Introduce the QuickHelp feature to new users of this version
*/
#define QUICKHELP_HINT "Hint_QuickHelp"
if(_pppdata->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) {
QDialog dlg(0, 0, true);
- dlg.setCaption(i18n("Recent Changes in KPPP"));
+ dlg.setCaption(QObject::tr("Recent Changes in KPPP"));
QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10);
QHBoxLayout *l1 = new QHBoxLayout(10);
QVBoxLayout *l2 = new QVBoxLayout(10);
tl->addLayout(l1);
QLabel *icon = new QLabel(&dlg);
icon->setPixmap(BarIcon("exclamation"));
icon->setFixedSize(icon->sizeHint());
l1->addWidget(icon);
l1->addLayout(l2);
- QLabel *l = new QLabel(i18n("From version 1.4.8 on, kppp has a new feature\n"
+ QLabel *l = new QLabel(QObject::tr("From version 1.4.8 on, kppp has a new feature\n"
"called \"Quickhelp\". It's similar to a tooltip,\n"
"but you can activate it whenever you want.\n"
"\n"
"To activate it, simply click on a control like\n"
"a button or a label with the right mouse button.\n"
"If the item supports Quickhelp, a popup menu\n"
"will appear leading to Quickhelp.\n"
"\n"
"To test it, right-click somewhere in this text."),
&dlg);
- QCheckBox *cb = new QCheckBox(i18n("Don't show this hint again"), &dlg);
+ QCheckBox *cb = new QCheckBox(QObject::tr("Don't show this hint again"), &dlg);
cb->setFixedSize(cb->sizeHint());
KButtonBox *bbox = new KButtonBox(&dlg);
bbox->addStretch(1);
- QPushButton *ok = bbox->addButton(i18n("OK"));
+ QPushButton *ok = bbox->addButton(QObject::tr("OK"));
ok->setDefault(true);
dlg.connect(ok, SIGNAL(clicked()),
&dlg, SLOT(accept()));
bbox->addStretch(1);
bbox->layout();
l2->addWidget(l);
l2->addWidget(cb);
tl->addWidget(bbox);
- QString tmp = i18n("This is an example of <b>QuickHelp</b>.\n"
+ QString tmp = QObject::tr("This is an example of <b>QuickHelp</b>.\n"
"This window will stay open until you\n"
"click a mouse button or a press a key.\n");
QWhatsThis::add(cb,tmp);
QWhatsThis::add(l, tmp);
dlg.exec();
if(cb->isChecked()) {
_pppdata->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1);
_pppdata->save();
}
}
#endif
}
//#include "kpppwidget.moc"
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp
index d23fee4..3dbc8c3 100644
--- a/noncore/settings/networksettings/ppp/modem.cpp
+++ b/noncore/settings/networksettings/ppp/modem.cpp
@@ -6,309 +6,306 @@
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* This file was added by Harri Porten <porten@tu-harburg.de>
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <setjmp.h>
#include <regex.h>
#include <qregexp.h>
#include <assert.h>
#include <string.h>
#ifdef HAVE_RESOLV_H
# include <arpa/nameser.h>
# include <resolv.h>
#endif
#ifndef _PATH_RESCONF
#define _PATH_RESCONF "/etc/resolv.conf"
#endif
#define strlcpy strcpy
#include "auth.h"
#include "modem.h"
#include "pppdata.h"
-//#include <klocale.h>
-#define i18n QObject::tr
#define qError qDebug
-//#include <kdebug.h>
-//#include <config.h>
+
#define MY_ASSERT(x) if (!(x)) { \
qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \
exit(1); }
static sigjmp_buf jmp_buffer;
//Modem *Modem::modem = 0;
const char* pppdPath() {
// wasting a few bytes
static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)];
static char *pppdPath = 0L;
char *p;
if(pppdPath == 0L) {
const char *c = PPPDSEARCHPATH;
while(*c != '\0') {
while(*c == ':')
c++;
p = buffer;
while(*c != '\0' && *c != ':')
*p++ = *c++;
*p = '\0';
strcat(p, "/");
strcat(p, PPPDNAME);
if(access(buffer, F_OK) == 0)
return (pppdPath = buffer);
}
}
return pppdPath;
}
Modem::Modem( PPPData* pd )
{
_pppdata = pd;
modemfd = -1;
_pppdExitStatus = -1;
pppdPid = -1;
- sn = 0L;
+ sn = m_modemDebug = 0L;
data_mode = false;
modem_is_locked = false;
lockfile[0] = '\0';
device = "/dev/modem";
}
Modem::~Modem()
{
}
speed_t Modem::modemspeed() {
// convert the string modem speed int the gpppdata object to a t_speed type
// to set the modem. The constants here should all be ifdef'd because
// other systems may not have them
int i = _pppdata->speed().toInt()/100;
switch(i) {
case 24:
return B2400;
break;
case 96:
return B9600;
break;
case 192:
return B19200;
break;
case 384:
return B38400;
break;
#ifdef B57600
case 576:
return B57600;
break;
#endif
#ifdef B115200
case 1152:
return B115200;
break;
#endif
#ifdef B230400
case 2304:
return B230400;
break;
#endif
#ifdef B460800
case 4608:
return B460800;
break;
#endif
default:
return B38400;
break;
}
}
bool Modem::opentty() {
// int flags;
//begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) {
close(modemfd);
device = _pppdata->modemDevice();
if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) {
qDebug("error opening modem device !");
- errmsg = i18n("Unable to open modem.");
+ errmsg = QObject::tr("Unable to open modem.");
return false;
}
//bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) {
//}
#if 0
if(_pppdata->UseCDLine()) {
if(ioctl(modemfd, TIOCMGET, &flags) == -1) {
- errmsg = i18n("Unable to detect state of CD line.");
+ errmsg = QObject::tr("Unable to detect state of CD line.");
::close(modemfd);
modemfd = -1;
return false;
}
if ((flags&TIOCM_CD) == 0) {
- errmsg = i18n("The modem is not ready.");
+ errmsg = QObject::tr("The modem is not ready.");
::close(modemfd);
modemfd = -1;
return false;
}
}
#endif
tcdrain (modemfd);
tcflush (modemfd, TCIOFLUSH);
if(tcgetattr(modemfd, &tty) < 0){
// this helps in some cases
tcsendbreak(modemfd, 0);
sleep(1);
if(tcgetattr(modemfd, &tty) < 0){
- errmsg = i18n("The modem is busy.");
+ errmsg = QObject::tr("The modem is busy.");
::close(modemfd);
modemfd = -1;
return false;
}
}
memset(&initial_tty,'\0',sizeof(initial_tty));
initial_tty = tty;
tty.c_cc[VMIN] = 0; // nonblocking
tty.c_cc[VTIME] = 0;
tty.c_oflag = 0;
tty.c_lflag = 0;
tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB);
tty.c_cflag |= CS8 | CREAD;
tty.c_cflag |= CLOCAL; // ignore modem status lines
tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ;
tty.c_lflag &= ~ICANON; // non-canonical mode
tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE);
if(_pppdata->flowcontrol() != "None") {
if(_pppdata->flowcontrol() == "CRTSCTS") {
tty.c_cflag |= CRTSCTS;
}
else {
tty.c_iflag |= IXON | IXOFF;
tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */
tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */
}
}
else {
tty.c_cflag &= ~CRTSCTS;
tty.c_iflag &= ~(IXON | IXOFF);
}
cfsetospeed(&tty, modemspeed());
cfsetispeed(&tty, modemspeed());
tcdrain(modemfd);
if(tcsetattr(modemfd, TCSANOW, &tty) < 0){
- errmsg = i18n("The modem is busy.");
+ errmsg = QObject::tr("The modem is busy.");
::close(modemfd);
modemfd=-1;
return false;
}
- errmsg = i18n("Modem Ready.");
+ errmsg = QObject::tr("Modem Ready.");
return true;
}
bool Modem::closetty() {
if(modemfd >=0 ) {
stop();
/* discard data not read or transmitted */
tcflush(modemfd, TCIOFLUSH);
if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){
- errmsg = i18n("Can't restore tty settings: tcsetattr()\n");
+ errmsg = QObject::tr("Can't restore tty settings: tcsetattr()\n");
::close(modemfd);
modemfd = -1;
return false;
}
::close(modemfd);
modemfd = -1;
}
return true;
}
void Modem::readtty(int) {
char buffer[200];
unsigned char c;
int len;
// read data in chunks of up to 200 bytes
if((len = ::read(modemfd, buffer, 200)) > 0) {
// split buffer into single characters for further processing
for(int i = 0; i < len; i++) {
c = buffer[i] & 0x7F;
emit charWaiting(c);
}
}
}
void Modem::notify(const QObject *receiver, const char *member) {
connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member);
startNotifier();
}
void Modem::stop() {
disconnect(SIGNAL(charWaiting(unsigned char)));
stopNotifier();
}
void Modem::startNotifier() {
if(modemfd >= 0) {
if(sn == 0) {
sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this);
connect(sn, SIGNAL(activated(int)), SLOT(readtty(int)));
qDebug("QSocketNotifier started!");
} else {
qDebug("QSocketNotifier re-enabled!");
@@ -368,97 +365,97 @@ bool Modem::writeLine(const char *buf) {
int wr = write(modemfd, &b[len-l], l);
if(wr < 0) {
// TODO do something meaningful with the error code (or ignore it
qError( "write() in Modem::writeLine failed" );
delete[] b;
return false;
}
l -= wr;
}
delete[] b;
return true;
}
bool Modem::hangup() {
// this should really get the modem to hang up and go into command mode
// If anyone sees a fault in the following please let me know, since
// this is probably the most imporant snippet of code in the whole of
// kppp. If people complain about kppp being stuck, this piece of code
// is most likely the reason.
struct termios temptty;
if(modemfd >= 0) {
// is this Escape & HangupStr stuff really necessary ? (Harri)
if (data_mode) escape_to_command_mode();
// Then hangup command
writeLine(_pppdata->modemHangupStr().local8Bit());
usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 sec
#ifndef DEBUG_WO_DIALING
if (sigsetjmp(jmp_buffer, 1) == 0) {
// set alarm in case tcsendbreak() hangs
signal(SIGALRM, alarm_handler);
alarm(2);
tcsendbreak(modemfd, 0);
alarm(0);
signal(SIGALRM, SIG_IGN);
} else {
// we reach this point if the alarm handler got called
closetty();
close(modemfd);
modemfd = -1;
- errmsg = i18n("The modem does not respond.");
+ errmsg = QObject::tr("The modem does not respond.");
return false;
}
#ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init.
tcgetattr(modemfd, &temptty);
cfsetospeed(&temptty, B0);
cfsetispeed(&temptty, B0);
tcsetattr(modemfd, TCSAFLUSH, &temptty);
#else
int modemstat;
ioctl(modemfd, TIOCMGET, &modemstat);
modemstat &= ~TIOCM_DTR;
ioctl(modemfd, TIOCMSET, &modemstat);
ioctl(modemfd, TIOCMGET, &modemstat);
modemstat |= TIOCM_DTR;
ioctl(modemfd, TIOCMSET, &modemstat);
#endif
usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 secs
cfsetospeed(&temptty, modemspeed());
cfsetispeed(&temptty, modemspeed());
tcsetattr(modemfd, TCSAFLUSH, &temptty);
#endif
return true;
} else
return false;
}
void Modem::escape_to_command_mode() {
// Send Properly bracketed escape code to put the modem back into command state.
// A modem will accept AT commands only when it is in command state.
// When a modem sends the host the CONNECT string, that signals
// that the modem is now in the connect state (no long accepts AT commands.)
// Need to send properly timed escape sequence to put modem in command state.
// Escape codes and guard times are controlled by S2 and S12 values.
//
tcflush(modemfd, TCIOFLUSH);
// +3 because quiet time must be greater than guard time.
usleep((_pppdata->modemEscapeGuardTime()+3)*20000);
QCString tmp = _pppdata->modemEscapeStr().local8Bit();
write(modemfd, tmp.data(), tmp.length());
tcflush(modemfd, TCIOFLUSH);
usleep((_pppdata->modemEscapeGuardTime()+3)*20000);
data_mode = false;
@@ -510,97 +507,97 @@ QString Modem::parseModemSpeed(const QString &s) {
//
// Now extract the digits only from the match, which will
// then be converted to an int.
//
if ((idx = rrx[RXMAX-1].match( sub,0,&len )) > -1) {
// if ((idx = rrx[RXMAX-1].search( sub )) > -1) {
// len = rrx[RXMAX-1].matchedLength();
sub = sub.mid(idx, len);
result = sub.toInt();
if(result > 0) {
rx = result;
break;
}
}
}
}
for(i = 0; i < TXMAX; i++) {
int len, idx, result;
if((idx = trx[i].match(s,0,&len)) > -1) {
// if((idx = trx[i].search(s)) > -1) {
// len = trx[i].matchedLength();
//
// trx[i] has been matched, idx contains the start of the match
// and len contains how long the match is. Extract the match.
//
QString sub = s.mid(idx, len);
//
// Now extract the digits only from the match, which will then
// be converted to an int.
//
if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) {
// if((idx = rrx[RXMAX-1].search(sub)) > -1) {
// len = rrx[RXMAX-1].matchedLength();
sub = sub.mid(idx, len);
result = sub.toInt();
if(result > 0) {
tx = result;
break;
}
}
}
}
if(rx == -1 && tx == -1)
- result = i18n("Unknown speed");
+ result = QObject::tr("Unknown speed");
else if(tx == -1)
result.setNum(rx);
else if(rx == -1) // should not happen
result.setNum(tx);
else
result.sprintf("%d/%d", rx, tx);
qDebug( "The parsed result is: %s", result.latin1());
return result;
}
// Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if
// a lock file can't be created ( permission problem )
int Modem::lockdevice() {
int fd;
char newlock[80]=""; // safe
if(!_pppdata->modemLockFile()) {
qDebug("The user doesn't want a lockfile.");
return 0;
}
if (modem_is_locked)
return 1;
QString lockfile = LOCK_DIR"/LCK..";
lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/
if(access(QFile::encodeName(lockfile), F_OK) == 0) {
// if ((fd = Requester::rq->
if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) {
// Mario: it's not necessary to read more than lets say 32 bytes. If
// file has more than 32 bytes, skip the rest
char oldlock[33]; // safe
int sz = read(fd, &oldlock, 32);
close (fd);
if (sz <= 0)
return 1;
oldlock[sz] = '\0';
qDebug( "Device is locked by: %s", oldlock);
int oldpid;
int match = sscanf(oldlock, "%d", &oldpid);
// found a pid in lockfile ?
@@ -832,192 +829,252 @@ int checkForInterface()
// work, pppd seems to hint it does. But BSD doesn't, and the following
// code should compile.
#if (defined(HAVE_NET_IF_PPP_H) || defined(HAVE_LINUX_IF_PPP_H)) && !defined(__svr4__)
int s, ok;
struct ifreq ifr;
// extern char *no_ppp_msg;
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
return 1; /* can't tell */
strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name));
ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0;
close(s);
if (ok == -1) {
// This is ifdef'd FreeBSD, because FreeBSD is the only BSD that supports
// KLDs, the old LKM interface couldn't handle loading devices
// dynamically, and thus can't load ppp support on the fly
#ifdef __FreeBSD__
// If we failed to load ppp support and don't have it already.
if (kldload("if_ppp") == -1) {
return -1;
}
return 0;
#else
return -1;
#endif
}
return 0;
#else
// We attempt to use the SunOS/SysVr4 method and stat /dev/ppp
struct stat buf;
memset(&buf, 0, sizeof(buf));
return stat("/dev/ppp", &buf);
#endif
}
bool Modem::execpppd(const char *arguments) {
char buf[MAX_CMDLEN];
char *args[MaxArgs];
pid_t pgrpid;
if(modemfd<0)
return false;
_pppdExitStatus = -1;
+ (void)::pipe( m_pppdLOG );
+
switch(pppdPid = fork())
{
case -1:
fprintf(stderr,"In parent: fork() failed\n");
+ ::close( m_pppdLOG[0] );
+ ::close( m_pppdLOG[1] );
return false;
break;
case 0:
// let's parse the arguments the user supplied into UNIX suitable form
// that is a list of pointers each pointing to exactly one word
strlcpy(buf, arguments);
parseargs(buf, args);
// become a session leader and let /dev/ttySx
// be the controlling terminal.
pgrpid = setsid();
#ifdef TIOCSCTTY
if(ioctl(modemfd, TIOCSCTTY, 0)<0)
fprintf(stderr, "ioctl() failed.\n");
#elif defined (TIOCSPGRP)
if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0)
fprintf(stderr, "ioctl() failed.\n");
#endif
if(tcsetpgrp(modemfd, pgrpid)<0)
fprintf(stderr, "tcsetpgrp() failed.\n");
+ ::close( m_pppdLOG[0] );
+ ::setenv( "LANG", "C", 1 ); // overwrite
+ dup2(m_pppdLOG[1], 11 ); // for logfd 11
dup2(modemfd, 0);
dup2(modemfd, 1);
+
switch (checkForInterface()) {
case 1:
fprintf(stderr, "Cannot determine if kernel supports ppp.\n");
break;
case -1:
fprintf(stderr, "Kernel does not support ppp, oops.\n");
break;
case 0:
fprintf(stderr, "Kernel supports ppp alright.\n");
break;
}
execve(pppdPath(), args, 0L);
_exit(0);
break;
default:
qDebug("In parent: pppd pid %d\n",pppdPid);
close(modemfd);
+
+ ::close( m_pppdLOG[1] );
+ // set it to nonblocking io
+ int flag = ::fcntl( m_pppdLOG[0], F_GETFL );
+
+ if ( !(flag & O_NONBLOCK) ) {
+ qDebug("Setting nonblocking io");
+ flag |= O_NONBLOCK;
+ ::fcntl(m_pppdLOG[0], F_SETFL, flag );
+ }
+
+ delete m_modemDebug;
+ m_modemDebug = new QSocketNotifier(m_pppdLOG[0], QSocketNotifier::Read, this );
+ connect(m_modemDebug, SIGNAL(activated(int) ),
+ this, SLOT(slotModemDebug(int) ) );
+
modemfd = -1;
+ m_pppdDev = QString::fromLatin1("ppp0");
return true;
break;
}
}
bool Modem::killpppd() {
+ qDebug("In killpppd and pid is %d", pppdPid );
if(pppdPid > 0) {
+ delete m_modemDebug;
+ m_modemDebug = 0;
qDebug("In killpppd(): Sending SIGTERM to %d\n", pppdPid);
if(kill(pppdPid, SIGTERM) < 0) {
qDebug("Error terminating %d. Sending SIGKILL\n", pppdPid);
if(kill(pppdPid, SIGKILL) < 0) {
qDebug("Error killing %d\n", pppdPid);
return false;
}
}
}
return true;
}
void Modem::parseargs(char* buf, char** args) {
int nargs = 0;
int quotes;
while(nargs < MaxArgs-1 && *buf != '\0') {
quotes = 0;
// Strip whitespace. Use nulls, so that the previous argument is
// terminated automatically.
while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) )
*buf++ = '\0';
// detect begin of quoted argument
if (*buf == '"' || *buf == '\'') {
quotes = *buf;
*buf++ = '\0';
}
// save the argument
if(*buf != '\0') {
*args++ = buf;
nargs++;
}
if (!quotes)
while ((*buf != '\0') && (*buf != '\n') &&
(*buf != '\t') && (*buf != ' '))
buf++;
else {
while ((*buf != '\0') && (*buf != quotes))
buf++;
*buf++ = '\0';
}
}
*args = 0L;
}
bool Modem::execPPPDaemon(const QString & arguments)
{
if(execpppd(arguments)) {
_pppdata->setpppdRunning(true);
return true;
} else
return false;
}
void Modem::killPPPDaemon()
{
_pppdata->setpppdRunning(false);
killpppd();
}
int Modem::pppdExitStatus()
{
return _pppdExitStatus;
}
int Modem::openResolv(int flags)
{
int fd;
if ((fd = open(_PATH_RESCONF, flags)) == -1) {
qDebug("error opening resolv.conf!");
fd = open(DEVNULL, O_RDONLY);
}
return fd;
}
bool Modem::setHostname(const QString & name)
{
return sethostname(name, name.length()) == 0;
}
+QString Modem::pppDevice()const {
+ return m_pppdDev;
+}
+void Modem::setPPPDevice( const QString& dev ) {
+ m_pppdDev = dev;
+}
+pid_t Modem::pppPID()const {
+ return pppdPid;
+}
+void Modem::setPPPDPid( pid_t pid ) {
+ qDebug("Modem setting pid");
+ _pppdExitStatus = -1;
+ pppdPid = pid;
+ modemfd = -1;
+}
+void Modem::slotModemDebug(int fd) {
+ char buf[2049];
+ int len;
+
+ // read in pppd data look for Using interface
+ // then read the interface
+ // we limit to 10 device now 0-9
+ if((len = ::read(fd, buf, 2048)) > 0) {
+ buf[len+1] = '\0';
+ char *found;
+ if ( (found = ::strstr(buf, "Using interface ") ) ) {
+ found += 16;
+ m_pppdDev = QString::fromLatin1(found, 5 );
+ m_pppdDev = m_pppdDev.simplifyWhiteSpace();
+ }
+ }
+}
diff --git a/noncore/settings/networksettings/ppp/modem.h b/noncore/settings/networksettings/ppp/modem.h
index 103cbeb..8ecc354 100644
--- a/noncore/settings/networksettings/ppp/modem.h
+++ b/noncore/settings/networksettings/ppp/modem.h
@@ -1,120 +1,131 @@
/*
* kPPP: A pppd Front End for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
- *
+ *
* This file was added by Harri Porten <porten@tu-harburg.de>
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _MODEM_H_
#define _MODEM_H_
#include <qdir.h>
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>
#include <qsocketnotifier.h>
class PPPData;
void alarm_handler(int);
const char *pppdPath();
class Modem : public QObject {
Q_OBJECT
public:
Modem(PPPData*);
~Modem();
const QString getDevice() {return device;};
- void setDevice(const QString dev) {device = dev;};
+ void setDevice(const QString dev) {device = dev;};
+
+ void save();
bool opentty();
bool closetty();
bool hangup();
bool writeChar(unsigned char);
bool writeLine(const char *);
bool dataMode() const { return data_mode; }
void setDataMode(bool set) { data_mode = set; }
- const QString modemMessage();
+ const QString modemMessage();
speed_t modemspeed();
static QString parseModemSpeed(const QString &);
void notify(const QObject *, const char *);
void stop();
void flush();
int lockdevice();
void unlockdevice();
bool setSecret(int,const char*,const char*);
bool removeSecret(int);
void killPPPDaemon();
int pppdExitStatus();
bool execPPPDaemon(const QString & arguments);
int openResolv(int flags);
bool setHostname(const QString & name);
-
+
+ QString pppDevice()const;
+ void setPPPDevice( const QString& );
+ pid_t pppPID()const;
+ void setPPPDPid( pid_t );
+
public:
enum Auth { PAP = 1, CHAP };
// static Modem *modem;
int lastStatus;
signals:
void charWaiting(unsigned char);
private slots:
void startNotifier();
void stopNotifier();
- void readtty(int);
+ void readtty(int);
+ void slotModemDebug(int);
private:
enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 };
enum { Original=0x100, New=0x200, Old=0x400 } Version;
const char* authFile(Auth method, int version = Original );
bool createAuthFile(Auth method,const char *username,const char *password);
bool removeAuthFile(Auth method);
bool execpppd(const char *arguments);
bool killpppd();
void parseargs(char* buf, char** args);
void escape_to_command_mode();
int openLockfile(QString,int);
private:
QString device;
- QString lockfile;
+ QString lockfile;
int modemfd;
int pppdPid;
int _pppdExitStatus;
QSocketNotifier *sn;
+ QSocketNotifier *m_modemDebug;
bool data_mode;
QString errmsg;
struct termios initial_tty;
struct termios tty;
bool modem_is_locked;
PPPData *_pppdata;
+ int m_pppdLOG[2];
+ QString m_pppdDev;
};
#endif
diff --git a/noncore/settings/networksettings/ppp/modemcmds.cpp b/noncore/settings/networksettings/ppp/modemcmds.cpp
index 1d9db6e..e797795 100644
--- a/noncore/settings/networksettings/ppp/modemcmds.cpp
+++ b/noncore/settings/networksettings/ppp/modemcmds.cpp
@@ -1,318 +1,333 @@
/*
* kPPP: A front end for pppd for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* based on EzPPP:
* Copyright (C) 1997 Jay Painter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with dummyWidget program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <qlayout.h>
#include <qslider.h>
#include <qbuttongroup.h>
+#include <qscrollview.h>
+#include <qapplication.h>
#include <stdlib.h>
-//#include <kapplication.h> // for getMiniIcon()
-//#include <klocale.h>
-#define i18n QObject::tr
#include "modemcmds.h"
#include "pppdata.h"
-//#include <kwin.h>
#define ADJUSTEDIT(e) //e->setText("XXXXXXXXqy"); e->setMinimumSize(e->sizeHint()); /*e->setFixedHeight(e->sizeHint().height());*/ e->setText(""); e->setMaxLength(MODEMSTR_SIZE);
// a little trick to make the label look like a disabled lineedit
#define FORMATSLIDERLABEL(l) //l->setFixedWidth(l->sizeHint().width()); l->setFixedHeight(QLineEdit(dummyWidget).sizeHint().height()); l->setAlignment(AlignCenter); l->setFrameStyle(QFrame::WinPanel|QFrame::Sunken); l->setLineWidth(2);
-ModemCommands::ModemCommands(PPPData *pd, QWidget *parent, const char *name)
- : QDialog(parent, name, true ), _pppdata(pd)
+ModemCommands::ModemCommands(PPPData *pd, QWidget *parent, const char *name , bool modal, WFlags f)
+ : QDialog( parent, name, modal, f ), _pppdata(pd)
{
- setCaption(i18n("Edit Modem Commands"));
+ setCaption(QObject::tr("Edit Modem Commands"));
const int GRIDROWS = 22;
int row = 0;
+ QVBoxLayout *main = new QVBoxLayout( this );
+ QScrollView *sv = new QScrollView( this );
+ QWidget *mainW = new QWidget( sv->viewport() );
+ sv->setResizePolicy( QScrollView::AutoOneFit );
+ sv->setHScrollBarMode( QScrollView::AlwaysOff );
+ sv->setFrameShape( QFrame::NoFrame );
+ sv->addChild( mainW );
+ main->addWidget( sv );
+ // evil hack
+ mainW->setMaximumWidth( QApplication::desktop()->width() - 10 );
+
// toplevel layout
- QVBoxLayout *tl = new QVBoxLayout(this, 10, 4);
+ QVBoxLayout *tl = new QVBoxLayout( mainW, 10, 4);
// add grid + frame
QGridLayout *l1 = new QGridLayout(GRIDROWS, 4);
tl->addLayout(l1);
- box = new QGroupBox(this, "box");
+ box = new QGroupBox(mainW, "box");
+ box->setMargin( 0 );
l1->addMultiCellWidget(box, row++, GRIDROWS, 0, 3);
// put slider and label into a separate H-Box
QHBoxLayout *l2 = new QHBoxLayout;
l1->addLayout(l2, row, 2);
- lpreinitslider = new QLabel("MMMM", this);
+ lpreinitslider = new QLabel("MMMM", mainW);
FORMATSLIDERLABEL(lpreinitslider);
QSlider *preinitslider = new QSlider(0, 300, 1, 0,
- QSlider::Horizontal, this);
+ QSlider::Horizontal, mainW);
// preinitslider->setFixedHeight(preinitslider->sizeHint().height());
connect(preinitslider, SIGNAL(valueChanged(int)),
lpreinitslider, SLOT(setNum(int)));
l2->addWidget(lpreinitslider, 0);
l2->addWidget(preinitslider, 1);
- lpreinit = new QLabel(i18n("Pre-init delay (sec/100):"), this);
+ lpreinit = new QLabel(QObject::tr("Pre-init delay (sec/100):"), mainW);
l1->addWidget(lpreinit, row++, 1);
for(int i = 0; i < PPPData::NumInitStrings; i++) {
- initstr[i] = new QLineEdit(this);
- QLabel *initLabel = new QLabel(i18n("Initialization string %1:").arg(i + 1),
- this);
+ initstr[i] = new QLineEdit(mainW);
+ QLabel *initLabel = new QLabel(QObject::tr("Initialization string %1:").arg(i + 1),
+ mainW);
ADJUSTEDIT(initstr[i]);
l1->addWidget(initLabel, row, 1);
l1->addWidget(initstr[i], row++, 2);
}
QHBoxLayout *l3 = new QHBoxLayout;
l1->addLayout(l3, row, 2);
- linitslider = new QLabel("MMMM", this);
+ linitslider = new QLabel("MMMM", mainW);
FORMATSLIDERLABEL(linitslider);
QSlider *initslider = new QSlider(1, 300, 1, 0,
- QSlider::Horizontal, this);
+ QSlider::Horizontal, mainW);
// initslider->setFixedHeight(initslider->sizeHint().height());
connect(initslider, SIGNAL(valueChanged(int)),
linitslider, SLOT(setNum(int)));
l3->addWidget(linitslider, 0);
l3->addWidget(initslider, 1);
- label3 = new QLabel(i18n("Post-init delay (sec/100):"), this);
+ label3 = new QLabel(QObject::tr("Post-init delay (sec/100):"), mainW);
l1->addWidget(label3, row++, 1);
/* Set ATS11 (Dial tone duration) between 0-255 (Default ~ 70) */
QHBoxLayout *l4 = new QHBoxLayout;
l1->addLayout(l4, row, 2);
- ldurationslider = new QLabel("MMMM", this);
+ ldurationslider = new QLabel("MMMM", mainW);
FORMATSLIDERLABEL(ldurationslider);
QSlider *durationslider = new QSlider(1, 255, 1, 0,
- QSlider::Horizontal, this);
+ QSlider::Horizontal, mainW);
// durationslider->setFixedHeight(durationslider->sizeHint().height());
connect(durationslider, SIGNAL(valueChanged(int)),
ldurationslider, SLOT(setNum(int)));
l4->addWidget(ldurationslider, 0);
l4->addWidget(durationslider, 1);
- lduration = new QLabel(i18n("Dialing speed (sec/100):"), this);
+ lduration = new QLabel(QObject::tr("Dialing speed (sec/100):"), mainW);
l1->addWidget(lduration, row++, 1);
- initresp = new QLineEdit(this);
- label2 = new QLabel(i18n("Init response:"), this);
+ initresp = new QLineEdit(mainW);
+ label2 = new QLabel(QObject::tr("Init response:"), mainW);
ADJUSTEDIT(initresp);
l1->addWidget(label2, row, 1);
l1->addWidget(initresp, row++, 2);
- nodetectdialtone = new QLineEdit(this);
- lnodetectdialtone = new QLabel(i18n("No dial tone detection:"), this);
+ nodetectdialtone = new QLineEdit(mainW);
+ lnodetectdialtone = new QLabel(QObject::tr("No dial tone detection:"), mainW);
ADJUSTEDIT(nodetectdialtone);
l1->addWidget(lnodetectdialtone, row, 1);
l1->addWidget(nodetectdialtone, row++, 2);
- dialstr = new QLineEdit(this);
- label4 = new QLabel(i18n("Dial string:"),this);
+ dialstr = new QLineEdit(mainW);
+ label4 = new QLabel(QObject::tr("Dial string:"),mainW);
ADJUSTEDIT(dialstr);
l1->addWidget(label4, row, 1);
l1->addWidget(dialstr, row++, 2);
- connectresp = new QLineEdit(this);
- label5 = new QLabel(i18n("Connect response:"), this);
+ connectresp = new QLineEdit(mainW);
+ label5 = new QLabel(QObject::tr("Connect response:"), mainW);
ADJUSTEDIT(connectresp);
l1->addWidget(label5, row, 1);
l1->addWidget(connectresp, row++, 2);
- busyresp = new QLineEdit(this);
- label6 = new QLabel(i18n("Busy response:"), this);
+ busyresp = new QLineEdit(mainW);
+ label6 = new QLabel(QObject::tr("Busy response:"), mainW);
ADJUSTEDIT(busyresp);
l1->addWidget(label6, row, 1);
l1->addWidget(busyresp, row++, 2);
- nocarrierresp = new QLineEdit(this);
- label7 = new QLabel(i18n("No carrier response:"), this);
+ nocarrierresp = new QLineEdit(mainW);
+ label7 = new QLabel(QObject::tr("No carrier response:"), mainW);
ADJUSTEDIT(nocarrierresp);
l1->addWidget(label7, row, 1);
l1->addWidget(nocarrierresp, row++, 2);
- nodialtoneresp = new QLineEdit(this);
- label8 = new QLabel(i18n("No dial tone response:"), this);
+ nodialtoneresp = new QLineEdit(mainW);
+ label8 = new QLabel(QObject::tr("No dial tone response:"), mainW);
ADJUSTEDIT(nodialtoneresp);
l1->addWidget(label8, row, 1);
l1->addWidget(nodialtoneresp, row++, 2);
- hangupstr = new QLineEdit(this);
- label9 = new QLabel(i18n("Hangup string:"), this);
+ hangupstr = new QLineEdit(mainW);
+ label9 = new QLabel(QObject::tr("Hangup string:"), mainW);
ADJUSTEDIT(hangupstr);
l1->addWidget(label9, row, 1);
l1->addWidget(hangupstr, row++, 2);
- hangupresp = new QLineEdit(this);
- label10 = new QLabel(i18n("Hangup response:"), this);
+ hangupresp = new QLineEdit(mainW);
+ label10 = new QLabel(QObject::tr("Hangup response:"), mainW);
ADJUSTEDIT(hangupresp);
l1->addWidget(label10, row, 1);
l1->addWidget(hangupresp, row++, 2);
- answerstr = new QLineEdit(this);
- label11 = new QLabel(i18n("Answer string:"), this);
+ answerstr = new QLineEdit(mainW);
+ label11 = new QLabel(QObject::tr("Answer string:"), mainW);
ADJUSTEDIT(answerstr);
l1->addWidget(label11, row, 1);
l1->addWidget(answerstr, row++, 2);
- ringresp = new QLineEdit(this);
- label12 = new QLabel(i18n("Ring response:"), this);
+ ringresp = new QLineEdit(mainW);
+ label12 = new QLabel(QObject::tr("Ring response:"), mainW);
ADJUSTEDIT(ringresp);
l1->addWidget(label12, row, 1);
l1->addWidget(ringresp, row++, 2);
- answerresp = new QLineEdit(this);
- label13 = new QLabel(i18n("Answer response:"), this);
+ answerresp = new QLineEdit(mainW);
+ label13 = new QLabel(QObject::tr("Answer response:"), mainW);
ADJUSTEDIT(answerresp);
l1->addWidget(label13, row, 1);
l1->addWidget(answerresp, row++, 2);
- escapestr = new QLineEdit(this);
- label14 = new QLabel(i18n("Escape string:"), this);
+ escapestr = new QLineEdit(mainW);
+ label14 = new QLabel(QObject::tr("Escape string:"), mainW);
ADJUSTEDIT(escapestr);
l1->addWidget(label14, row, 1);
l1->addWidget(escapestr, row++, 2);
- escaperesp = new QLineEdit(this);
- label15 = new QLabel(i18n("Escape response:"), this);
+ escaperesp = new QLineEdit(mainW);
+ label15 = new QLabel(QObject::tr("Escape response:"), mainW);
ADJUSTEDIT(escaperesp);
l1->addWidget(label15, row, 1);
l1->addWidget(escaperesp, row++, 2);
QHBoxLayout *l5 = new QHBoxLayout;
l1->addLayout(l5, row, 2);
- lslider = new QLabel("MMMM", this);
+ lslider = new QLabel("MMMM", mainW);
FORMATSLIDERLABEL(lslider);
QSlider *slider = new QSlider(0, 255, 1, 0,
- QSlider::Horizontal, this);
+ QSlider::Horizontal, mainW);
// slider->setFixedHeight(slider->sizeHint().height());
connect(slider, SIGNAL(valueChanged(int)),
lslider, SLOT(setNum(int)));
l5->addWidget(lslider, 0);
l5->addWidget(slider, 1);
- label16 = new QLabel(i18n("Guard time (sec/50):"), this);
+ label16 = new QLabel(QObject::tr("Guard time (sec/50):"), mainW);
l1->addWidget(label16, row++, 1);
- QLabel *l = new QLabel(i18n("Volume off/low/high:"), this);
+ QLabel *l = new QLabel(QObject::tr("Volume off/low/high:"), mainW);
l1->addWidget(l, row, 1);
QHBoxLayout *l6 = new QHBoxLayout;
l1->addLayout(l6, row++, 2);
- volume_off = new QLineEdit(this);
+ volume_off = new QLineEdit(mainW);
// volume_off->setFixedHeight(volume_off->sizeHint().height());
// volume_off->setMinimumWidth((int)(volume_off->sizeHint().width() / 2));
- volume_medium = new QLineEdit(this);
+ volume_medium = new QLineEdit(mainW);
// volume_medium->setFixedHeight(volume_medium->sizeHint().height());
// volume_medium->setMinimumWidth((int)(volume_medium->sizeHint().width() / 2));
- volume_high = new QLineEdit(this);
+ volume_high = new QLineEdit(mainW);
// volume_high->setFixedHeight(volume_high->sizeHint().height());
// volume_high->setMinimumWidth((int)(volume_high->sizeHint().width() / 2));
l6->addWidget(volume_off);
l6->addWidget(volume_medium);
l6->addWidget(volume_high);
initstr[0]->setFocus();
l1->addColSpacing(0, 10);
l1->addColSpacing(3, 10);
l1->addRowSpacing(0, 5);
l1->addRowSpacing(GRIDROWS, 5);
//set stuff from gpppdata
preinitslider->setValue(_pppdata->modemPreInitDelay());
lpreinitslider->setNum(_pppdata->modemPreInitDelay());
for(int i = 0; i < PPPData::NumInitStrings; i++)
initstr[i]->setText(_pppdata->modemInitStr(i));
initslider->setValue(_pppdata->modemInitDelay());
linitslider->setNum(_pppdata->modemInitDelay());
initresp->setText(_pppdata->modemInitResp());
durationslider->setValue(_pppdata->modemToneDuration());
ldurationslider->setNum(_pppdata->modemToneDuration());
nodetectdialtone->setText(_pppdata->modemNoDialToneDetectionStr());
dialstr->setText(_pppdata->modemDialStr());
connectresp->setText(_pppdata->modemConnectResp());
busyresp->setText(_pppdata->modemBusyResp());
nocarrierresp->setText(_pppdata->modemNoCarrierResp());
nodialtoneresp->setText(_pppdata->modemNoDialtoneResp());
escapestr->setText(_pppdata->modemEscapeStr());
escaperesp->setText(_pppdata->modemEscapeResp());
hangupstr->setText(_pppdata->modemHangupStr());
hangupresp->setText(_pppdata->modemHangupResp());
answerstr->setText(_pppdata->modemAnswerStr());
ringresp->setText(_pppdata->modemRingResp());
answerresp->setText(_pppdata->modemAnswerResp());
slider->setValue(_pppdata->modemEscapeGuardTime());
lslider->setNum(_pppdata->modemEscapeGuardTime());
volume_off->setText(_pppdata->volumeOff());
volume_medium->setText(_pppdata->volumeMedium());
volume_high->setText(_pppdata->volumeHigh());
}
void ModemCommands::slotOk() {
_pppdata->setModemPreInitDelay(lpreinitslider->text().toInt());
for(int i = 0; i < PPPData::NumInitStrings; i++)
_pppdata->setModemInitStr(i, initstr[i]->text());
_pppdata->setModemInitResp(initresp->text());
_pppdata->setModemInitDelay(linitslider->text().toInt());
_pppdata->setModemToneDuration(ldurationslider->text().toInt());
_pppdata->setModemNoDialToneDetectionStr(nodetectdialtone->text());
_pppdata->setModemDialStr(dialstr->text());
_pppdata->setModemConnectResp(connectresp->text());
_pppdata->setModemBusyResp(busyresp->text());
_pppdata->setModemNoCarrierResp(nocarrierresp->text());
_pppdata->setModemNoDialtoneResp(nodialtoneresp->text());
_pppdata->setModemEscapeStr(escapestr->text());
_pppdata->setModemEscapeResp(escaperesp->text());
_pppdata->setModemEscapeGuardTime(lslider->text().toInt());
_pppdata->setModemHangupStr(hangupstr->text());
_pppdata->setModemHangupResp(hangupresp->text());
_pppdata->setModemAnswerStr(answerstr->text());
_pppdata->setModemRingResp(ringresp->text());
_pppdata->setModemAnswerResp(answerresp->text());
_pppdata->setVolumeHigh(volume_high->text());
_pppdata->setVolumeMedium(volume_medium->text());
_pppdata->setVolumeOff(volume_off->text());
_pppdata->save();
- accept();
+ QDialog::accept();
+}
+
+void ModemCommands::accept()
+{
+ slotOk();
}
void ModemCommands::slotCancel() {
reject();
}
//#include "modemcmds.moc"
diff --git a/noncore/settings/networksettings/ppp/modemcmds.h b/noncore/settings/networksettings/ppp/modemcmds.h
index ef69fec..81d67f4 100644
--- a/noncore/settings/networksettings/ppp/modemcmds.h
+++ b/noncore/settings/networksettings/ppp/modemcmds.h
@@ -1,98 +1,99 @@
/*
*
* kPPP: A front end for pppd for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* based on EzPPP:
* Copyright (C) 1997 Jay Painter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef _MODEMCMDS_H_
#define _MODEMCMDS_H_
#include <qgroupbox.h>
#include <qdialog.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include "pppdata.h"
class ModemCommands : public QDialog {
Q_OBJECT
public:
- ModemCommands(PPPData*, QWidget *parent=0, const char *name=0);
+ ModemCommands(PPPData*, QWidget *parent=0, const char *name=0, bool modal=0, WFlags f = 0);
~ModemCommands() {}
private slots:
+ virtual void accept();
void slotCancel();
void slotOk();
private:
PPPData *_pppdata;
QGroupBox *box;
QLineEdit *initstr[int(PPPData::NumInitStrings)];
QLineEdit *initresp;
QLabel *label2;
QLabel *lpreinitslider;
QLabel *lpreinit;
QLabel *linitslider;
QLabel *label3;
QLabel *ldurationslider;
QLabel *lduration;
QLineEdit *nodetectdialtone;
QLabel *lnodetectdialtone;
QLineEdit *dialstr;
QLabel *label4;
QLineEdit *connectresp;
QLabel *label5;
QLineEdit *busyresp;
QLabel *label6;
QLineEdit *nocarrierresp;
QLabel *label7;
QLineEdit *nodialtoneresp;
QLabel *label8;
QLineEdit *hangupstr;
QLabel *label9;
QLineEdit *hangupresp;
QLabel *label10;
QLineEdit *answerstr;
QLabel *label11;
diff --git a/noncore/settings/networksettings/ppp/modeminfo.cpp b/noncore/settings/networksettings/ppp/modeminfo.cpp
index 0bec186..dbb26db 100644
--- a/noncore/settings/networksettings/ppp/modeminfo.cpp
+++ b/noncore/settings/networksettings/ppp/modeminfo.cpp
@@ -1,296 +1,294 @@
/*
* kPPP: A front end for pppd for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* This file contributed by: Markus Wuebben, mwuebben@fiwi02.wiwi.uni-tuebingen.de
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <unistd.h>
#include <qregexp.h>
#include <qlayout.h>
// #include <kwin.h>
// #include <kmessagebox.h>
// #include <kapplication.h>
#include <qmessagebox.h>
#include <qapplication.h>
#include "modeminfo.h"
#include "modem.h"
-//#include <klocale.h>
-#define i18n QObject::tr
ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name)
: QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder),
_modem(mo)
{
- setCaption(i18n("ATI Query"));
+ setCaption(QObject::tr("ATI Query"));
// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
progressBar = new QProgressBar(this, "bar");
progressBar->setTotalSteps(8);
statusBar = new QLabel(this,"sBar");
statusBar->setFrameStyle(QFrame::Panel|QFrame::Sunken);
statusBar->setAlignment(AlignCenter);
// This is a rather complicated case. Since we do not know which
// message is the widest in the national language, we'd to
// search all these messages. This is a little overkill, so I take
// the longest english message, translate it and give it additional
// 20 percent space. Hope this is enough.
- statusBar->setText(i18n("Unable to create modem lock file."));
+ statusBar->setText(QObject::tr("Unable to create modem lock file."));
statusBar->setFixedWidth((statusBar->sizeHint().width() * 12) / 10);
statusBar->setFixedHeight(statusBar->sizeHint().height() + 4);
// set original text
- statusBar->setText(i18n("Looking for modem..."));
+ statusBar->setText(QObject::tr("Looking for modem..."));
progressBar->setFixedHeight(statusBar->minimumSize().height());
tl->addWidget(progressBar);
tl->addWidget(statusBar);
- cancel = new QPushButton(i18n("Cancel"), this);
+ cancel = new QPushButton(QObject::tr("Cancel"), this);
cancel->setFocus();
connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton()));
QHBoxLayout *l1 = new QHBoxLayout;
tl->addLayout(l1);
l1->addStretch(1);
l1->addWidget(cancel);
setFixedSize(sizeHint());
step = 0;
////////////////////////////////////////////////
timeout_timer = new QTimer(this);
connect(timeout_timer, SIGNAL(timeout()), SLOT(time_out_slot()));
scripttimer = new QTimer(this);
connect(scripttimer, SIGNAL(timeout()), SLOT(do_script()));
timeout_timer->start(15000,TRUE); // 15 secs single shot
QTimer::singleShot(500, this, SLOT(init()));
}
void ModemTransfer::ati_done() {
scripttimer->stop();
timeout_timer->stop();
_modem->closetty();
_modem->unlockdevice();
hide();
// open the result window
ModemInfo *mi = new ModemInfo(this);
for(int i = 0; i < NUM_OF_ATI; i++)
mi->setAtiString(i, ati_query_strings[i]);
mi->showMaximized();
mi->exec();
delete mi;
accept();
}
void ModemTransfer::time_out_slot() {
timeout_timer->stop();
scripttimer->stop();
- QMessageBox::warning(this, tr("Error"), i18n("Modem Query timed out."));
+ QMessageBox::warning(this, tr("Error"), QObject::tr("Modem Query timed out."));
reject();
}
void ModemTransfer::init() {
qApp->processEvents();
int lock = _modem->lockdevice();
if (lock == 1) {
- statusBar->setText(i18n("Modem device is locked."));
+ statusBar->setText(QObject::tr("Modem device is locked."));
return;
}
if (lock == -1) {
- statusBar->setText(i18n("Unable to create modem lock file."));
+ statusBar->setText(QObject::tr("Unable to create modem lock file."));
return;
}
if(_modem->opentty()) {
if(_modem->hangup()) {
usleep(100000); // wait 0.1 secs
_modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ...
- statusBar->setText(i18n("Modem Ready"));
+ statusBar->setText(QObject::tr("Modem Ready"));
qApp->processEvents();
usleep(100000); // wait 0.1 secs
qApp->processEvents();
scripttimer->start(1000); // this one does the ati query
// clear modem buffer
_modem->flush();
_modem->notify(this, SLOT(readChar(unsigned char)));
return;
}
}
// opentty() or hangup() failed
statusBar->setText(_modem->modemMessage());
step = 99; // wait until cancel is pressed
_modem->unlockdevice();
}
void ModemTransfer::do_script() {
QString msg;
QString query;
switch(step) {
case 0:
readtty();
statusBar->setText("ATI...");
progressBar->setProgress( progressBar->progress() + 1);
_modem->writeLine("ATI\n");
break;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
readtty();
msg.sprintf("ATI %d ...", step);
query.sprintf("ATI%d\n", step);
statusBar->setText(msg);
progressBar->setProgress( progressBar->progress() + 1);
_modem->writeLine(query.local8Bit());
break;
default:
readtty();
ati_done();
}
step++;
}
void ModemTransfer::readChar(unsigned char c) {
if(readbuffer.length() < 255)
readbuffer += c;
}
void ModemTransfer::readtty() {
if (step == 0)
return;
readbuffer.replace(QRegExp("[\n\r]")," "); // remove stray \n and \r
readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white
// space
if(step <= NUM_OF_ATI)
ati_query_strings[step-1] = readbuffer.copy();
readbuffer = "";
}
void ModemTransfer::cancelbutton() {
scripttimer->stop();
_modem->stop();
timeout_timer->stop();
- statusBar->setText(i18n("One moment please..."));
+ statusBar->setText(QObject::tr("One moment please..."));
qApp->processEvents();
_modem->hangup();
_modem->closetty();
_modem->unlockdevice();
reject();
}
void ModemTransfer::closeEvent( QCloseEvent *e ) {
cancelbutton();
e->accept();
}
ModemInfo::ModemInfo(QWidget *parent, const char* name)
: QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder)
{
QString label_text;
- setCaption(i18n("Modem Query Results"));
+ setCaption(QObject::tr("Modem Query Results"));
// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5);
tl->addLayout(l1, 1);
for(int i = 0 ; i < NUM_OF_ATI ; i++) {
label_text = "";
if ( i == 0)
label_text.sprintf("ATI :");
else
label_text.sprintf("ATI %d:", i );
ati_label[i] = new QLabel(label_text, this);
l1->addWidget(ati_label[i], i, 0);
ati_label_result[i] = new QLineEdit(this);
ati_label_result[i]->setMinimumWidth(fontMetrics().width('H') * 24);
l1->addWidget(ati_label_result[i], i, 1);
}
//tl->addSpacing(1);
QHBoxLayout *l2 = new QHBoxLayout;
- QPushButton *ok = new QPushButton(i18n("Close"), this);
+ QPushButton *ok = new QPushButton(QObject::tr("Close"), this);
ok->setDefault(TRUE);
ok->setFocus();
tl->addLayout(l2);
l2->addStretch(1);
connect(ok, SIGNAL(clicked()), SLOT(accept()));
l2->addWidget(ok);
setMinimumSize(sizeHint());
}
void ModemInfo::setAtiString(int i, QString s) {
if(i < NUM_OF_ATI)
ati_label_result[i]->setText(s);
}
//#include "modeminfo.moc"
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro
index fc89f35..84acd0e 100644
--- a/noncore/settings/networksettings/ppp/ppp.pro
+++ b/noncore/settings/networksettings/ppp/ppp.pro
@@ -1,18 +1,17 @@
#TEMPLATE = app
#
TEMPLATE = lib
#CONFIG += qt warn_on release
CONFIG += qt warn_on debug
DESTDIR = $(OPIEDIR)/plugins/networksettings
-HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h interfaceinformationppp.h interfaceppp.h authwidget.h
-SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp interfaceinformationppp.cpp interfaceppp.cpp authwidget.cpp
+HEADERS = pppmodule.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h interfaceinformationppp.h interfaceppp.h authwidget.h chooserwidget.h devices.h
+SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp interfaceinformationppp.cpp interfaceppp.cpp authwidget.cpp chooserwidget.cpp devices.cpp
INCLUDEPATH += $(OPIEDIR)/include ../ ../interfaces/
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -L../interfaces/ -linterfaces
-INTERFACES =
TARGET = kppp
VERSION = 1.0.0
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp
index 5fa7d3f..97baf31 100644
--- a/noncore/settings/networksettings/ppp/pppconfig.cpp
+++ b/noncore/settings/networksettings/ppp/pppconfig.cpp
@@ -1,70 +1,75 @@
#include <qlayout.h>
#include <qmessagebox.h>
#include <qtabwidget.h>
#include "accounts.h"
+#include "devices.h"
#include "general.h"
#include "interfaceppp.h"
#include "modem.h"
#include "pppconfig.h"
#include "pppdata.h"
#include "runtests.h"
PPPConfigWidget::PPPConfigWidget( InterfacePPP* iface, QWidget *parent,
const char *name,
bool modal, WFlags fl )
: QDialog(parent, name, modal, fl)
{
setCaption(tr("Configure Modem"));
int result = runTests();
if(result == TEST_CRITICAL){
QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") );
return;
}
interface = iface;
qDebug("PPPConfigWidget::PPPConfigWidget");
qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1());
qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1());
- qDebug(" _pppdata->currentAccountID() >%i<",interface->data()->currentAccountID());
+
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setSpacing( 0 );
layout->setMargin( 1 );
tabWindow = new QTabWidget( this, "tabWidget" );
layout->addWidget( tabWindow );
- accounts = new AccountWidget( interface->data(), tabWindow, "accounts" );
+ accounts = new AccountWidget( interface->data(), tabWindow, "accounts", Qt::WStyle_ContextHelp );
tabWindow->addTab( accounts, tr("&Accounts") );
- modem1 = new ModemWidget( interface, tabWindow, "modem1" );
- tabWindow->addTab( modem1, tr("&Device") );
- modem2 = new ModemWidget2( interface, tabWindow, "modem2" );
- tabWindow->addTab( modem2, tr("&Modem") );
+ devices = new DevicesWidget( interface, tabWindow, "devices", Qt::WStyle_ContextHelp );
+ tabWindow->addTab( devices, tr("&Devices") );
+
+//OLD:
+// modem1 = new ModemWidget( interface, tabWindow, "modem1" );
+// tabWindow->addTab( modem1, tr("&Device") );
+// modem2 = new ModemWidget2( interface, tabWindow, "modem2" );
+// tabWindow->addTab( modem2, tr("&Modem") );
}
PPPConfigWidget::~PPPConfigWidget()
{
}
void PPPConfigWidget::accept()
{
qDebug("PPPConfigWidget::accept");
qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1());
qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1());
- interface->setInterfaceName( interface->data()->modemDevice() );
+ interface->setInterfaceName( interface->data()->devname() );
interface->setHardwareName( interface->data()->accname() );
interface->save();
QDialog::accept();
}
void PPPConfigWidget::reject()
{
interface->data()->cancel();
QDialog::reject();
}
diff --git a/noncore/settings/networksettings/ppp/pppconfig.h b/noncore/settings/networksettings/ppp/pppconfig.h
index 9bab6fe..4d7912f 100644
--- a/noncore/settings/networksettings/ppp/pppconfig.h
+++ b/noncore/settings/networksettings/ppp/pppconfig.h
@@ -1,37 +1,43 @@
#ifndef _PPPCONFIG_H_
#define _PPPCONFIG_H_
#include <qdialog.h>
class QTabWidget;
//class Interface;
class InterfacePPP;
class AccountWidget;
class GeneralWidget;
+class DevicesWidget;
+
+//OLD:
class ModemWidget;
class ModemWidget2;
class PPPConfigWidget : public QDialog {
Q_OBJECT
public:
PPPConfigWidget( InterfacePPP*, QWidget *parent=0, const char *name=0,
bool modal = false, WFlags fl = 0 );
~PPPConfigWidget();
protected slots:
virtual void accept();
virtual void reject();
private:
InterfacePPP *interface;
QTabWidget *tabWindow;
AccountWidget *accounts;
GeneralWidget *general;
+ DevicesWidget* devices;
+
+ //OLD:
ModemWidget *modem1;
ModemWidget2 *modem2;
};
#endif
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp
index 8f45e54..f4727c1 100644
--- a/noncore/settings/networksettings/ppp/pppdata.cpp
+++ b/noncore/settings/networksettings/ppp/pppdata.cpp
@@ -1,165 +1,176 @@
/*
* kPPP: A pppd front end for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* based on EzPPP:
* Copyright (C) 1997 Jay Painter
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "pppdata.h"
#include "runtests.h"
-#include "devices.h"
+//#include "devices.h"
//#include <klocale.h>
-#define i18n QObject::tr
#include <qpe/config.h>
#include <qmessagebox.h>
#include <qapplication.h>
// #include <klocale.h>
// #include <kconfig.h>
// #include <kmessagebox.h>
// #include <kapplication.h>
#include <assert.h>
#define SEPARATOR -sseepp-
#define SEP QString("%1SEPARATOR%1")
PPPData::PPPData()
- : modemDeviceGroup(-1),
- passwd(""),
+ : passwd(""),
+ _modemName(""),
highcount(-1), // start out with no entries
- caccount(-1), // set the current account index also
+ highcountdev(-1), // start out with no entries
+// caccount(-1), // set the current account index also
suidprocessid(-1), // process ID of setuid child
pppdisrunning(false),
pppderror(0)
{
- highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1;
+ highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1;
+ highcountdev = readNumConfig(GENERAL_GRP, NUMDEVICES_KEY, 0) - 1;
+ Config cfg = config();
+ cfg.setGroup(GENERAL_GRP);
+ accountList = cfg.readListEntry(ACCOUNT_LIST, ',' );
+ deviceList = cfg.readListEntry(DEVICESNAMES_LIST, ',' );
+ qDebug("PPPData::PPPData has a accountList %s", accountList.join("---").latin1());
+ qDebug("PPPData::PPPData has a deviceList %s", deviceList.join("---").latin1());
- if (highcount > MAX_ACCOUNTS)
- highcount = MAX_ACCOUNTS;
+// if (highcount > MAX_ACCOUNTS)
+// highcount = MAX_ACCOUNTS;
- if(highcount >= 0 && defaultAccount().isEmpty()) {
- setAccountbyIndex(0);
- setDefaultAccount(accname());
- } else if(!setAccount(defaultAccount()))
- setDefaultAccount(accname());
+ // if(highcount >= 0 && defaultAccount().isEmpty()) {
+// setAccountbyIndex(0);
+// setDefaultAccount(accname());
+// } else if(!setAccount(defaultAccount()))
+ setDefaultAccount(accname());
// start out with internal debugging disabled
// the user is still free to specify `debug' on his own
setPPPDebug(false);
::pppdVersion(&pppdVer, &pppdMod, &pppdPatch);
}
Config PPPData::config()
{
return Config("NetworkSetupPPP");
}
//
// save configuration
//
void PPPData::save()
{
qDebug("PPPData saving data");
writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count());
+ writeConfig(GENERAL_GRP, NUMDEVICES_KEY, highcountdev + 1);
QString key;
QStringList keys;
Config cfg = config();
+ cfg.setGroup(GENERAL_GRP);
+ cfg.writeEntry(ACCOUNT_LIST, accountList, ',' );
+ cfg.writeEntry(DEVICESNAMES_LIST, deviceList, ',' );
+
for( QMap<QString,QString>::Iterator it = stringEntries.begin();
it != stringEntries.end(); ++it ){
QString val = it.data();
key = it.key();
// qDebug("saving %s -> %s", key.latin1(), val.latin1() );
keys = QStringList::split( "SEPARATOR", key );
- qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() );
+ //qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() );
cfg.setGroup(keys[0]);
cfg.writeEntry(keys[1], val);
- }
+ }
for( QMap<QString,int>::Iterator it = intEntries.begin();
it != intEntries.end(); ++it ){
int val = it.data();
key = it.key();
// qDebug("saving %s -> %i", key.latin1(), val );
keys = QStringList::split( "SEPARATOR", key );
- qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val );
+ //qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val );
cfg.setGroup(keys[0]);
cfg.writeEntry(keys[1], val);
- }
+ }
for( QMap<QString,QStringList>::Iterator it = listEntries.begin();
it != listEntries.end(); ++it ){
QStringList val = it.data();
key = it.key();
QChar sep = sepEntries[key];
// qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() );
keys = QStringList::split( "SEPARATOR", key );
- qDebug("group >%s< key >%s<values >%s<", keys[0].latin1(), keys[1].latin1(), val.join(sep).latin1() );
cfg.setGroup(keys[0]);
cfg.writeEntry(keys[1], val, sep);
- }
+ }
}
//
// cancel changes
//
void PPPData::cancel() {
stringEntries.clear();
intEntries.clear();
listEntries.clear();
}
// functions to read/write date to configuration file
QString PPPData::readConfig(const QString &group, const QString &key,
const QString &defvalue = "")
{
// qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1());
QString idx = SEP.arg(group).arg(key);
if (stringEntries.find(idx) != stringEntries.end())
return stringEntries[idx];
Config cfg = config();
cfg.setGroup(group);
return cfg.readEntry(key, defvalue);
}
int PPPData::readNumConfig(const QString &group, const QString &key,
int defvalue)
{
QString idx = SEP.arg(group).arg(key);
if (intEntries.find(idx) != intEntries.end())
return intEntries[idx];
Config cfg = config();
cfg.setGroup(group);
return cfg.readNumEntry(key, defvalue);
// if (config) {
// config->setGroup(group);
// return config->readNumEntry(key, defvalue);
// } else
// return defvalue;
}
bool PPPData::readListConfig(const QString &group, const QString &key,
QStringList &list, char sep) {
list.clear();
@@ -299,111 +310,123 @@ bool PPPData::automatic_redial() {
void PPPData::set_automatic_redial(bool set) {
writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set);
}
// bool PPPData::get_iconify_on_connect() {
// return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE);
// }
// void PPPData::set_iconify_on_connect(bool set) {
// writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set);
// }
// bool PPPData::get_dock_into_panel() {
// return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false);
// }
// void PPPData::set_dock_into_panel(bool set) {
// writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set);
// }
QString PPPData::pppdVersion() {
return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch);
}
bool PPPData::pppdVersionMin(int ver, int mod, int patch) {
// check if pppd version fulfills minimum requirement
return (pppdVer > ver
|| (pppdVer == ver && pppdMod > mod)
|| (pppdVer == ver && pppdMod == mod && pppdPatch >= patch));
}
int PPPData::pppdTimeout() {
return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT);
}
void PPPData::setpppdTimeout(int n) {
writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n);
}
const QString PPPData::modemDevice() {
- return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]);
+ return readConfig (modemGroup(), MODEMDEV_KEY, "/dev/modem" );
}
+// const QString PPPData::modemName()
+// {
+// return readConfig(modemGroup(), MODEMNAME_KEY);
+// }
+
+// bool PPPData::setModemName(const QString &n) {
+// qDebug("Setting modem name to >%s<", n.latin1());
+// _modemName = n;
+// writeConfig(cgroup, MODEMNAME_KEY, n);
+// return true; //FIXME
+// }
+
+// bool PPPData::changeModemName(const QString &n) {
+// qDebug("Setting modem name to >%s<", n.latin1());
+// _modemName = n;
+// writeConfig(modemGroup(), MODEMNAME_KEY, n);
+// return true; //FIXME
+// }
+
bool PPPData::setModemDevice(const QString &n) {
qDebug("Setting modem dev to >%s<", n.latin1());
- bool ret = false;
- for (int i = 0; devices[i]; i++)
- if (devices[i] == n){
- modemDeviceGroup = i;
- writeConfig(modemGroup(), MODEMDEV_KEY, n);
- ret = true;
- }
- qDebug(ret?"SUCCESS":"FAILURE");
- return ret;
+ writeConfig(modemGroup(), MODEMDEV_KEY, n);
+ return true; //FIXME
}
const QString PPPData::flowcontrol() {
return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS");
}
void PPPData::setFlowcontrol(const QString &n) {
writeConfig(modemGroup(), FLOWCONTROL_KEY, n);
}
const QString PPPData::speed() {
QString s = readConfig(modemGroup(), SPEED_KEY, "57600");
// undo the damage of a bug in former versions. It left an empty Speed=
// entry in kppprc. kppp did set the serial port to 57600 as default but
// pppd wouldn't receive the speed via the command line.
if(s.toUInt() == 0)
s = "57600";
return s;
}
void PPPData::setSpeed(const QString &n) {
writeConfig(modemGroup(), SPEED_KEY, n);
}
#if 0
void PPPData::setUseCDLine(const int n) {
writeConfig(modemGroup(),USECDLINE_KEY,n);
}
int PPPData::UseCDLine() {
return readNumConfig(modemGroup(),USECDLINE_KEY,0);
}
#endif
const QString PPPData::modemEscapeStr() {
return readConfig(modemGroup(),ESCAPESTR_KEY,"+++");
}
void PPPData::setModemEscapeStr(const QString &n) {
writeConfig(modemGroup(),ESCAPESTR_KEY,n);
}
@@ -672,243 +695,268 @@ void PPPData::setWaitForDialTone(int i) {
void PPPData::setModemAnswerStr(const QString &n) {
writeConfig(modemGroup(), ANSWERSTR_KEY, n);
}
const QString PPPData::modemRingResp() {
return readConfig(modemGroup(), RINGRESP_KEY, "RING");
}
void PPPData::setModemRingResp(const QString &n) {
writeConfig(modemGroup(), RINGRESP_KEY, n);
}
const QString PPPData::modemAnswerResp() {
return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT");
}
void PPPData::setModemAnswerResp(const QString &n) {
writeConfig(modemGroup(), ANSWERRESP_KEY, n);
}
const QString PPPData::enter() {
return readConfig(modemGroup(), ENTER_KEY, "CR");
}
void PPPData::setEnter(const QString &n) {
writeConfig(modemGroup(), ENTER_KEY, n);
}
//
// functions to set/return account information
//
//returns number of accounts
int PPPData::count() const {
return highcount + 1;
}
bool PPPData::setAccount(const QString &aname) {
qDebug("setting account to >%s<", aname.latin1());
- for(int i = 0; i <= highcount; i++) {
- setAccountbyIndex(i);
- if(accname() == aname) {
- caccount = i;
- qDebug("SUCCESS");
- return true;
+ for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) {
+ cgroup = *it;
+ qDebug("PPPData::setAccount %s", cgroup.latin1());
+ qDebug( "iterator %s", (*it).latin1() );
+ if(accname() == aname) {
+ qDebug("SUCCESS");
+ return true;
+ }
+
}
- }
- qDebug("FAILURE");
- return false;
+ qDebug("FAILURE");
+ return false;
}
-
+/*
bool PPPData::setAccountbyIndex(int i) {
if(i >= 0 && i <= highcount) {
+ QString tmp;
+ tmp.sprintf("%s%i", ACCOUNT_GRP, i);
+ if (_deleted.find(tmp)!=_deleted.end()) return false;
caccount = i;
- cgroup.sprintf("%s%i", ACCOUNT_GRP, i);
+ cgroup = tmp;
return true;
}
return false;
}
-
+*/
bool PPPData::isUniqueAccname(const QString &n) {
- int current = caccount;
- for(int i=0; i <= highcount; i++) {
- setAccountbyIndex(i);
- if(accname() == n && i != current) {
- setAccountbyIndex(current);
- return false;
- }
+ QString save_cgroup = cgroup;
+ for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) {
+ cgroup = *it;
+ qDebug("PPPData::setAccount %s", cgroup.latin1());
+ qDebug( "%s \n", (*it).latin1() );
+ if(accname() == n && cgroup != save_cgroup) {
+ cgroup = save_cgroup;
+ qDebug("SUCCESS");
+ return false;
+ }
+
}
- setAccountbyIndex(current);
+ cgroup = save_cgroup;
return true;
}
-bool PPPData::deleteAccount() {
- //FIXME: PPPData::deleteAccount
-// if(caccount < 0)
- return false;
-
-// QMap <QString, QString> map;
-// QMap <QString, QString>::Iterator it;
-
-// // set all entries of the current account to ""
-// map = config->entryMap(cgroup);
-// it = map.begin();
-// while (it != map.end()) {
-// config->writeEntry(it.key(), "");
-// it++;
-// }
+bool PPPData::isUniqueDevname(const QString &n) {
+ QString save_mName = _modemName;
+ qDebug("PPPData::isUniqueDevname checking if %s is unique", n.latin1());
+ for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) {
+ _modemName = *it;
+ qDebug("PPPData::isUniqueDevname %s == %s", n.latin1() , devname().latin1());
+ if(devname() == n && _modemName != save_mName) {
+ _modemName = save_mName;
+ qDebug("NOT UNIQUE");
+ return false;
+ }
-// // shift the succeeding accounts
-// for(int i = caccount+1; i <= highcount; i++) {
-// setAccountbyIndex(i);
-// map = config->entryMap(cgroup);
-// it = map.begin();
-// setAccountbyIndex(i-1);
-// config->setGroup(cgroup);
-// while (it != map.end()) {
-// config->writeEntry(it.key(), *it);
-// it++;
-// }
-// }
+ }
+ _modemName = save_mName;
+ return true;
+}
-// // make sure the top account is cleared
-// setAccountbyIndex(highcount);
-// map = config->entryMap(cgroup);
-// it = map.begin();
-// config->setGroup(cgroup);
-// while (it.key() != QString::null) {
-// config->writeEntry(it.key(), "");
-// it++;
-// }
-// highcount--;
-// if(caccount > highcount)
-// caccount = highcount;
+bool PPPData::deleteAccount() {
+ // FIXME: check if this account exists in a config...
+ Config cfg = PPPData::config();
+ cfg.setGroup(cgroup);
+ cfg.clearGroup();
+ accountList.remove(cgroup);
-// setAccountbyIndex(caccount);
+ QString key;
+ QStringList keys;
+ for( QMap<QString,QString>::Iterator it = stringEntries.begin();
+ it != stringEntries.end(); ++it ){
+ QString val = it.data();
+ key = it.key();
+ keys = QStringList::split( "SEPARATOR", key );
+ if(keys[0]==cgroup){
+ stringEntries.remove( it );
+ qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() );
+ }
+ }
+ for( QMap<QString,int>::Iterator it = intEntries.begin();
+ it != intEntries.end(); ++it ){
+ int val = it.data();
+ key = it.key();
+ keys = QStringList::split( "SEPARATOR", key );
+ if(keys[0]==cgroup){
+ intEntries.remove( it );
+ qDebug("deleting >%s< key >%s< value >%i<", keys[0].latin1(), keys[1].latin1(), val );
+ }
+ }
+ for( QMap<QString,QStringList>::Iterator it = listEntries.begin();
+ it != listEntries.end(); ++it ){
+ QStringList val = it.data();
+ key = it.key();
+ if(keys[0]==cgroup){
+ listEntries.remove( it );
+ sepEntries.remove( key );
+ qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.join("").latin1() );
+ }
+ }
-// return true;
+ return true;
}
bool PPPData::deleteAccount(const QString &aname) {
if(!setAccount(aname))
return false;
deleteAccount();
return true;
}
int PPPData::newaccount() {
qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS);
// if(!config) open();
- if (highcount >= MAX_ACCOUNTS) return -1;
+// if (highcount >= MAX_ACCOUNTS) return -1;
- highcount++;
- setAccountbyIndex(highcount);
+ QString tmp;
+ tmp.sprintf("%s%i", ACCOUNT_GRP, ++highcount);
+ cgroup = QString(tmp);
+ accountList << tmp;
+ qDebug("PPPData::newaccount() Group: >%s<",cgroup.latin1());
setpppdArgumentDefaults();
- qDebug("PPPData::newaccount -> %i",caccount);
- return caccount;
+ return highcount;
}
-int PPPData::copyaccount(int i) {
+int PPPData::copyaccount(const QString&) {
// FIXME: PPPData::copyaccount
// if(highcount >= MAX_ACCOUNTS)
return -1;
// setAccountbyIndex(i);
// QMap <QString, QString> map = config->entryMap(cgroup);
// QMap <QString, QString>::ConstIterator it = map.begin();
-// QString newname = i18n("%1_copy").arg(accname());
+// QString newname = QObject::tr("%1_copy").arg(accname());
// newaccount();
// while (it != map.end()) {
// config->writeEntry(it.key(), *it);
// it++;
// }
// setAccname(newname);
// return caccount;
}
const QString PPPData::accname() {
return readConfig(cgroup, NAME_KEY);
}
void PPPData::setAccname(const QString &n) {
if(!cgroup.isNull()) {
// are we manipulating the default account's name ? then change it, too.
bool def = accname() == defaultAccount();
writeConfig(cgroup, NAME_KEY, n);
if (def)
setDefaultAccount(n);
}
+ writeConfig(cgroup, NAME_KEY, n);
}
#define SEPARATOR_CHAR '&'
QStringList &PPPData::phonenumbers() {
readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR);
return phonelist;
}
const QString PPPData::phonenumber() {
return readConfig(cgroup, PHONENUMBER_KEY);
}
void PPPData::setPhonenumber(const QString &n) {
writeConfig(cgroup, PHONENUMBER_KEY, n);
}
const QString PPPData::dialPrefix() {
return readConfig(cgroup, DIAL_PREFIX_KEY, "");
}
void PPPData::setDialPrefix(const QString &s) {
writeConfig(cgroup, DIAL_PREFIX_KEY, s);
}
int PPPData::authMethod() {
return readNumConfig(cgroup, AUTH_KEY, 0);
}
void PPPData::setAuthMethod(int value) {
writeConfig(cgroup, AUTH_KEY, value);
}
const QString PPPData::storedUsername() {
return readConfig(cgroup, STORED_USERNAME_KEY, "");
}
void PPPData::setStoredUsername(const QString &b) {
@@ -1131,172 +1179,317 @@ void PPPData::setScript(QStringList &list) {
// const QString PPPData::accountingFile() {
// return readConfig(cgroup, ACCTFILE_KEY);
// }
// void PPPData::setAccountingFile(const QString &n) {
// writeConfig(cgroup, ACCTFILE_KEY, n);
// }
// const QString PPPData::totalCosts() {
// return readConfig(cgroup, TOTALCOSTS_KEY);
// }
// void PPPData::setTotalCosts(const QString &n) {
// writeConfig(cgroup, TOTALCOSTS_KEY, n);
// }
// int PPPData::totalBytes() {
// return readNumConfig(cgroup, TOTALBYTES_KEY, 0);
// }
// void PPPData::setTotalBytes(int n) {
// writeConfig(cgroup, TOTALBYTES_KEY, n);
// }
QStringList &PPPData::pppdArgument() {
static QStringList arglist;
while(arglist.count() > MAX_PPPD_ARGUMENTS)
arglist.remove(arglist.last());
readListConfig(cgroup, PPPDARG_KEY, arglist);
return arglist;
}
void PPPData::setpppdArgument(QStringList &args) {
writeListConfig(cgroup, PPPDARG_KEY, args);
}
void PPPData::setpppdArgumentDefaults() {
QStringList arg;
+ arg << "lcp-echo-failure 0";
setpppdArgument(arg);
}
// // graphing widget
// void PPPData::setGraphingOptions(bool enable,
// QColor bg,
// QColor text,
// QColor in,
// QColor out)
// {
// if(config) {
// config->setGroup(GRAPH_GRP);
// config->writeEntry(GENABLED, enable);
// // config->writeEntry(GCOLOR_BG, bg);
// // config->writeEntry(GCOLOR_TEXT, text);
// // config->writeEntry(GCOLOR_IN, in);
// // config->writeEntry(GCOLOR_OUT, out);
// }
// }
// void PPPData::graphingOptions(bool &enable,
// QColor &bg,
// QColor &text,
// QColor &in,
// QColor &out)
// {
// QColor c;
// if(config) {
// config->setGroup(GRAPH_GRP);
// enable = config->readBoolEntry(GENABLED, true);
// bg = Qt::white;
// //bg = config->readColorEntry(GCOLOR_BG, &c);
// text = Qt::black;
// //text = config->readColorEntry(GCOLOR_TEXT, &c);
// in = Qt::blue;
// //in = config->readColorEntry(GCOLOR_IN, &c);
// out = Qt::red;
// //out = config->readColorEntry(GCOLOR_OUT, &c);
// }
// }
// bool PPPData::graphingEnabled() {
// return (bool) readNumConfig(GRAPH_GRP, GENABLED, true);
// }
//
//functions to change/set the child pppd process info
//
bool PPPData::pppdRunning() const {
return pppdisrunning;
}
void PPPData::setpppdRunning(bool set) {
pppdisrunning = set;
}
int PPPData::pppdError() const {
return pppderror;
}
void PPPData::setpppdError(int err) {
pppderror = err;
}
QString PPPData::modemGroup()
{
- if (modemDeviceGroup<0){
- qDebug("wrong modem %i\n using 0",modemDeviceGroup);
- modemDeviceGroup = 0; //FIXME!
- }
- return QString("%1_%1").arg(MODEM_GRP).arg(modemDeviceGroup);
+ if (_modemName.isEmpty())
+ _modemName = deviceList[0];
+ return _modemName;
}
QMap<QString,QString> PPPData::getConfiguredInterfaces()
{
QMap<QString,QString> ifaces;
Config config = PPPData::config();
config.setGroup(ACCLIST_GRP);
int count = config.readNumEntry( ACCOUNTS_COUNT, -1 );
QString accGrp, dev, acc;
for (int i = 0; i < count; i++){
accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i);
config.setGroup(accGrp);
dev = config.readEntry( ACOUNTS_DEV, "error" );
acc = config.readEntry( ACOUNTS_ACC, "error" );
ifaces.insert( dev, acc );
}
return ifaces;
}
void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces )
{
QMap<QString,QString>::Iterator it;
int i = 0;
Config cfg = config();
for( it = ifaces.begin(); it != ifaces.end(); ++it ){
cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i++));
cfg.writeEntry( ACOUNTS_DEV, it.key() );
cfg.writeEntry( ACOUNTS_ACC, it.data() );
qDebug("I %i",i);
}
cfg.setGroup( ACCLIST_GRP );
qDebug("saved %i account settings", i);
cfg.writeEntry( ACCOUNTS_COUNT, i );
}
/**
* pppd's getword() function knows about escape characters.
* If we write the username and password to the secrets file
* we'll therefore have to escape back slashes.
*/
QString PPPData::encodeWord(const QString &s) {
QString r = s;
r.replace(QRegExp("\\"), "\\\\");
return r;
}
+
+QStringList PPPData::getDevicesList()
+{
+ Config cfg("NetworkSetupPPP");
+ cfg.setGroup("Devices_General");
+ return cfg.readListEntry(DEVICES_LIST,DEVICES_LIST_SEP);
+}
+
+QStringList PPPData::getAccountList()
+{
+ QStringList list;
+ QString save_cgroup;
+ save_cgroup = cgroup;
+ for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) {
+ cgroup = *it;
+ list << accname();
+ }
+ cgroup = save_cgroup;
+ return list;
+};
+
+
+const QString PPPData::devname()
+{
+ QString tmp = readConfig(modemGroup(), MODEMNAME_KEY );
+ qDebug("PPPData::devname() of %s is %s", modemGroup().latin1(), tmp.latin1());
+ return tmp;
+}
+
+void PPPData::setDevname(const QString &n) {
+ // if(!cgroup.isNull()) {
+// // are we manipulating the default account's name ? then change it, too.
+// bool def = accname() == defaultAccount();
+// writeConfig(cgroup, NAME_KEY, n);
+// if (def)
+// setDefaultAccount(n);
+// }
+ writeConfig(modemGroup(), MODEMNAME_KEY, n );
+}
+
+
+bool PPPData::setDevice(const QString &dev )
+{
+ qDebug("setting device to >%s<", dev.latin1());
+ QString save_mName = _modemName;
+ for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) {
+ _modemName = *it;
+ qDebug("PPPData::setDevice %s is named %s", _modemName.latin1(), devname().latin1() );
+ qDebug( "iterator %s", (*it).latin1() );
+ if(devname() == dev) {
+ qDebug("SUCCESS");
+ return true;
+ }
+
+ }
+ _modemName = save_mName;
+ qDebug("FAILURE");
+ return false;
+}
+
+bool PPPData::deleteDevice()
+{
+ // FIXME: check if this account exists in a config...
+ Config cfg = PPPData::config();
+ cfg.setGroup(modemGroup());
+ cfg.clearGroup();
+ deviceList.remove(modemGroup());
+
+ QString key;
+ QStringList keys;
+ for( QMap<QString,QString>::Iterator it = stringEntries.begin();
+ it != stringEntries.end(); ++it ){
+ QString val = it.data();
+ key = it.key();
+ keys = QStringList::split( "SEPARATOR", key );
+ if(keys[0]==modemGroup()){
+ stringEntries.remove( it );
+ qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() );
+ }
+ }
+ for( QMap<QString,int>::Iterator it = intEntries.begin();
+ it != intEntries.end(); ++it ){
+ int val = it.data();
+ key = it.key();
+ keys = QStringList::split( "SEPARATOR", key );
+ if(keys[0]==modemGroup()){
+ intEntries.remove( it );
+ qDebug("deleting >%s< key >%s< value >%i<", keys[0].latin1(), keys[1].latin1(), val );
+ }
+ }
+ for( QMap<QString,QStringList>::Iterator it = listEntries.begin();
+ it != listEntries.end(); ++it ){
+ QStringList val = it.data();
+ key = it.key();
+ if(keys[0]==modemGroup()){
+ listEntries.remove( it );
+ sepEntries.remove( key );
+ qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.join("").latin1() );
+ }
+ }
+
+ return true;
+
+}
+
+bool PPPData::deleteDevice(const QString &dev)
+{
+ if(!setDevice(dev))
+ return false;
+
+ return deleteDevice();
+}
+
+int PPPData::newdevice()
+{
+
+ qDebug("PPPData::newdevice highcount %i",highcountdev);
+
+
+ QString tmp;
+ tmp.sprintf("%s%i", MODEM_GRP, ++highcountdev);
+ _modemName = QString(tmp);
+ deviceList << tmp;
+ qDebug("PPPData::newdevice() Group: >%s<",cgroup.latin1());
+ return highcountdev;
+}
+
+int PPPData::copydevice(const QString&)
+{
+ return false;
+}
+
+
+QStringList PPPData::getDevicesNamesList()
+{
+ QStringList list;
+ QString save_mName = _modemName;
+ qDebug("PPPData::getDevicesNamesList has %s", deviceList.join("---").latin1());
+ for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) {
+ _modemName = *it;
+ qDebug("PPPData::getDevicesNamesList adding %s as %s",_modemName.latin1(), devname().latin1());
+ list << devname();
+ }
+ _modemName = save_mName;
+ return list;
+};
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h
index 6e1379d..d1cbeb5 100644
--- a/noncore/settings/networksettings/ppp/pppdata.h
+++ b/noncore/settings/networksettings/ppp/pppdata.h
@@ -19,420 +19,449 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _PPPDATA_H_
#define _PPPDATA_H_
#include <unistd.h>
#include <sys/types.h>
#include <qcolor.h>
#include <qmap.h>
#include <qstring.h>
#include <qstringlist.h>
#include "kpppconfig.h"
class Config;
// string lengths
#define PATH_SIZE 120
#define MODEMSTR_SIZE 80
#define ACCNAME_SIZE 50
#define PHONENUMBER_SIZE 60
#define COMMAND_SIZE 255
#define IPADDR_SIZE 15
#define DOMAIN_SIZE 50
#define TIMEOUT_SIZE 60
//
// keys for config file
//
// groups
#define GENERAL_GRP "PPP_General"
#define MODEM_GRP "PPP_Modem"
#define ACCOUNT_GRP "PPP_Account"
#define ACCLIST_GRP "PPP_Accounts_List"
//#define GRAPH_GRP "Graph"
//#define WINPOS_GRP "WindowPosition"
// general
+#define ACCOUNT_LIST "AccountList"
+#define DEVICE_LIST "DeviceList"
#define DEFAULTACCOUNT_KEY "DefaultAccount"
#define PPPDVERSION_KEY "pppdVersion"
#define PPPDTIMEOUT_KEY "pppdTimeout"
#define SHOWCLOCK_KEY "ShowClock"
#define SHOWLOGWIN_KEY "ShowLogWindow"
#define AUTOREDIAL_KEY "AutomaticRedial"
#define DISCONNECT_KEY "DisconnectOnXServerExit"
#define QUITONDISCONNECT_KEY "QuitOnDisconnect"
-#define NUMACCOUNTS_KEY "NumberOfAccounts"
+#define NUMACCOUNTS_KEY "HighcountAccounts"
+#define NUMDEVICES_KEY "HighcountDevices"
#define ID_KEY "ID"
// modem
+#define MODEMNAME_KEY "Modem_Name"
#define MODEMDEV_KEY "Device"
#define LOCKFILE_KEY "UseLockFile"
#define FLOWCONTROL_KEY "FlowControl"
#define SPEED_KEY "Speed"
#define TIMEOUT_KEY "Timeout"
#define TONEDURATION_KEY "ToneDuration"
#define BUSYWAIT_KEY "BusyWait"
#define INITSTR_KEY "InitString"
#define INITRESP_KEY "InitResponse"
#define PREINITDELAY_KEY "PreInitDelay"
#define INITDELAY_KEY "InitDelay"
#define NODTDETECT_KEY "NoDialToneDetection"
#define DIALTONEWAIT_KEY "WaitForDialTone"
#define DIALSTR_KEY "DialString"
#define CONNECTRESP_KEY "ConnectResponse"
#define BUSYRESP_KEY "BusyResponse"
#define NOCARRIERRESP_KEY "NoCarrierResponse"
#define NODIALTONERESP_KEY "NoDialToneResp"
#define HANGUPSTR_KEY "HangupString"
#define HANGUPRESP_KEY "HangUpResponse"
#define ANSWERSTR_KEY "AnswerString"
#define RINGRESP_KEY "RingResponse"
#define ANSWERRESP_KEY "AnswerResponse"
#define ENTER_KEY "Enter"
#define ESCAPESTR_KEY "EscapeString"
#define ESCAPERESP_KEY "EscapeResponse"
#define ESCAPEGUARDTIME_KEY "EscapeGuardTime"
#define USECDLINE_KEY "UseCDLine"
#define VOLUME_HIGH "VolumeHigh"
#define VOLUME_MEDIUM "VolumeMedium"
#define VOLUME_OFF "VolumeOff"
#define VOLUME_KEY "Volume"
// account
#define NAME_KEY "Name"
#define PHONENUMBER_KEY "Phonenumber"
#define DIAL_PREFIX_KEY "DialPrefix"
#define AUTH_KEY "Authentication"
#define STORED_PASSWORD_KEY "Password"
#define STORED_USERNAME_KEY "Username"
#define STORE_PASSWORD_KEY "StorePassword"
#define BEFORE_CONNECT_KEY "BeforeConnect"
#define COMMAND_KEY "Command"
#define DISCONNECT_COMMAND_KEY "DisconnectCommand"
#define BEFORE_DISCONNECT_KEY "BeforeDisconnect"
#define IPADDR_KEY "IPAddr"
#define SUBNETMASK_KEY "SubnetMask"
#define ACCTENABLED_KEY "AccountingEnabled"
#define VOLACCTENABLED_KEY "VolumeAccountingEnabled"
#define ACCTFILE_KEY "AccountingFile"
#define AUTONAME_KEY "AutoName"
#define GATEWAY_KEY "Gateway"
#define DEFAULTROUTE_KEY "DefaultRoute"
#define DOMAIN_KEY "Domain"
#define DNS_KEY "DNS"
#define AUTODNS_KEY "AutoDNS"
#define EXDNSDISABLED_KEY "ExDNSDisabled"
#define SCRIPTCOM_KEY "ScriptCommands"
#define SCRIPTARG_KEY "ScriptArguments"
#define PPPDARG_KEY "pppdArguments"
#define PPP_DEBUG_OPTION "PPPDebug"
#define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect"
#define DOCKING_KEY "DockIntoPanel"
#define TOTALCOSTS_KEY "TotalCosts"
#define TOTALBYTES_KEY "TotalBytes"
// pppd errors
#define E_IF_TIMEOUT 1
#define E_PPPD_DIED 2
// account list
#define ACCOUNTS_COUNT "Accounts_Count"
#define ACOUNTS_DEV "Accounts_Modem"
#define ACOUNTS_ACC "Accounts_Account"
+#define DEVICESNAMES_LIST "DevicesNames_List"
+#define DEVICES_LIST "Devices_List"
+#define DEVICES_LIST_SEP ','
+
class PPPData {
public:
PPPData();
~PPPData() {};
enum { NumInitStrings = 2 };
// general functions
void save();
void cancel();
+ QStringList getAccountList();
+
static QMap<QString,QString> getConfiguredInterfaces();
static void setConfiguredInterfaces( QMap<QString,QString> );
// function to read/write date to configuration file
static Config config();
QString readConfig(const QString &, const QString &, const QString &);
int readNumConfig(const QString &, const QString &, int);
bool readListConfig(const QString &, const QString &,
QStringList &, char sep = ',');
void writeConfig(const QString &, const QString &, const QString &);
void writeConfig(const QString &, const QString &, int);
void writeListConfig(const QString &, const QString &,
QStringList &, char sep = ',');
// return the current account group
QString currentGroup() { return cgroup; }
QString modemGroup();
// functions to set/get general kppp info
QString password();
void setPassword(const QString &);
- int currentAccountID() { return caccount; };
+// int currentAccountID() { return caccount; };
const QString defaultAccount();
void setDefaultAccount(const QString &);
void set_xserver_exit_disconnect(bool set);
bool get_xserver_exit_disconnect();
void setPPPDebug(bool set);
bool getPPPDebug();
void set_quit_on_disconnect(bool);
bool quit_on_disconnect();
void set_show_clock_on_caption(bool set);
bool get_show_clock_on_caption();
void set_show_log_window(bool set);
bool get_show_log_window();
void set_automatic_redial(bool set);
bool automatic_redial();
// void set_iconify_on_connect(bool set);
// bool get_iconify_on_connect();
// void set_dock_into_panel(bool set);
// bool get_dock_into_panel();
const QString enter();
void setEnter(const QString &);
QString pppdVersion();
bool pppdVersionMin(int ver, int mod, int patch);
int pppdTimeout();
void setpppdTimeout(int);
int busyWait();
void setbusyWait(int);
bool modemLockFile();
void setModemLockFile(bool set);
int modemEscapeGuardTime();
void setModemEscapeGuardTime(int i);
void setModemEscapeStr(const QString &);
const QString modemEscapeStr();
void setModemEscapeResp(const QString &);
const QString modemEscapeResp();
- const QString modemDevice();
- bool setModemDevice(const QString &);
+// const QString modemName();
+// bool setModemName(const QString &);
+// bool changeModemName(const QString &);
+
+ const QString modemDevice();
+ bool setModemDevice(const QString &);
const QString flowcontrol();
void setFlowcontrol(const QString &);
int modemTimeout();
void setModemTimeout(int);
int modemToneDuration();
void setModemToneDuration(int);
QString volumeInitString();
int volume();
void setVolume(int);
int waitForDialTone();
void setWaitForDialTone(int i);
// modem command strings/responses
const QString modemInitStr(int i);
void setModemInitStr(int i, const QString &);
const QString modemInitResp();
void setModemInitResp(const QString &);
int modemPreInitDelay();
void setModemPreInitDelay(int);
int modemInitDelay();
void setModemInitDelay(int);
QString modemNoDialToneDetectionStr();
void setModemNoDialToneDetectionStr(const QString &);
const QString modemDialStr();
void setModemDialStr(const QString &);
const QString modemConnectResp();
void setModemConnectResp(const QString &);
const QString modemBusyResp();
void setModemBusyResp(const QString &);
const QString modemNoCarrierResp();
void setModemNoCarrierResp(const QString &);
const QString modemNoDialtoneResp();
void setModemNoDialtoneResp(const QString &);
const QString modemHangupStr();
void setModemHangupStr(const QString &);
const QString modemHangupResp();
void setModemHangupResp(const QString &);
const QString modemAnswerStr();
void setModemAnswerStr(const QString &);
const QString modemRingResp();
void setModemRingResp(const QString &);
const QString modemAnswerResp();
void setModemAnswerResp(const QString &);
QString volumeOff();
void setVolumeOff(const QString &);
QString volumeMedium();
void setVolumeMedium(const QString &);
QString volumeHigh();
void setVolumeHigh(const QString &);
// functions to set/get account information
int count() const;
bool setAccount(const QString &);
- bool setAccountbyIndex(int);
+// bool setAccountbyIndex(int);
bool isUniqueAccname(const QString &);
+ bool isUniqueDevname(const QString &);
bool deleteAccount();
bool deleteAccount(const QString &);
int newaccount();
- int copyaccount(int i);
+ int copyaccount(const QString&);
const QString accname();
void setAccname(const QString &);
QStringList &phonenumbers();
const QString phonenumber();
void setPhonenumber(const QString &);
const QString dialPrefix();
void setDialPrefix(const QString &);
int authMethod();
void setAuthMethod(int);
const QString storedUsername();
void setStoredUsername(const QString &);
const QString storedPassword();
void setStoredPassword(const QString &);
bool storePassword();
void setStorePassword(bool);
const QString speed();
void setSpeed(const QString &);
const QString command_before_connect();
void setCommand_before_connect(const QString &);
const QString command_on_connect();
void setCommand_on_connect(const QString &);
const QString command_on_disconnect();
void setCommand_on_disconnect(const QString &);
const QString command_before_disconnect();
void setCommand_before_disconnect(const QString &);
const QString ipaddr();
void setIpaddr(const QString &);
const QString subnetmask();
void setSubnetmask(const QString &);
bool AcctEnabled();
void setAcctEnabled(bool set);
// int VolAcctEnabled();
// void setVolAcctEnabled(int set);
bool autoDNS();
void setAutoDNS(bool set);
bool exDNSDisabled();
void setExDNSDisabled(bool set);
bool autoname();
void setAutoname(bool set);
const QString gateway();
void setGateway(const QString &);
bool defaultroute();
void setDefaultroute(bool set);
QStringList &dns();
void setDns(QStringList &);
const QString domain();
void setDomain(const QString &);
QStringList &scriptType();
void setScriptType(QStringList &);
QStringList &script();
void setScript(QStringList &);
QStringList &pppdArgument();
void setpppdArgumentDefaults();
void setpppdArgument(QStringList &);
//functions to change/set the child pppd process info
bool pppdRunning() const;
void setpppdRunning(bool set);
int pppdError() const;
void setpppdError(int err);
+ QStringList getDevicesList();
static QString encodeWord(const QString &s);
+ const QString devname();
+ void setDevname(const QString &);
+ bool setDevice(const QString& );
+ bool deleteDevice();
+ bool deleteDevice(const QString &);
+ int newdevice();
+ int copydevice(const QString&);
+ QStringList getDevicesNamesList();
+
private:
//static PPPData *_data;
- int modemDeviceGroup;
+// int modemDeviceGroup;
QString passwd;
- // static Config* config; // configuration object
+ QString _modemName;
int highcount; // index of highest account
- int caccount; // index of the current account
+ int highcountdev; // index of highest device
+// int caccount; // index of the current account
QString cgroup; // name of current config group
pid_t suidprocessid; // process ID of setuid child
bool pppdisrunning; // pppd process
// daemon
int pppderror; // error encounterd running pppd
int pppdVer, pppdMod, pppdPatch; // pppd version
+
QStringList phonelist;
+ QStringList accountList;
+ QStringList deviceList;
QMap<QString,QString> stringEntries;
QMap<QString,int> intEntries;
QMap<QString,QStringList> listEntries;
QMap<QString,QChar> sepEntries;
};
#endif
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index d4c137b..af05eb7 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -1,137 +1,250 @@
+#include <errno.h>
+#include <signal.h>
+
+#include <qpe/config.h>
+
+#include "modem.h"
#include "pppconfig.h"
#include "pppmodule.h"
#include "pppdata.h"
#include "interfaceinformationppp.h"
#include "interfaceppp.h"
+// don't polute global namespace
+namespace {
+ /*
+ * If network settings is qutting and we've ppp
+ * devices open we need to save the pid_t the PPData
+ * and the interface number
+ */
+ struct Connection {
+ pid_t pid;
+ QString device;
+ QString name;
+ };
+ class InterfaceKeeper {
+ public:
+ InterfaceKeeper();
+ ~InterfaceKeeper();
+
+ void addInterface( pid_t, const QString& pppDev, const QString& name );
+ QMap<QString, Connection> interfaces()const; // will check if still available
+ private:
+ bool isAvailable( pid_t )const;
+ QMap<QString, Connection> m_interfaces;
+ };
+}
+
/**
* Constructor, find all of the possible interfaces
+ * We also need to restore the state.. it could be that
+ * an interface was up while closing the application
+ * we need to be able to shut it down...
*/
PPPModule::PPPModule() : Module()
{
+ InterfaceKeeper inFace;
+ QMap<QString,Connection> running = inFace.interfaces();
+ QStringList handledInterfaceNames;
+
QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces();
QMap<QString,QString>::Iterator it;
InterfacePPP *iface;
qDebug("getting interfaces");
for( it = ifaces.begin(); it != ifaces.end(); ++it ){
- qDebug("ifaces %s", it.key().latin1());
+ qDebug("ifaces %s %s", it.key().latin1(), it.data().latin1() );
iface = new InterfacePPP( 0, it.key() );
iface->setHardwareName( it.data() );
list.append( (Interface*)iface );
+
+ // check if (*it) is one of the running ifaces
+ if ( running.contains( it.data() ) ) {
+ qDebug("iface is running %s", it.key().latin1() );
+ handledInterfaceNames << running[it.data()].device;
+ iface->setStatus( true );
+ iface->setPPPDpid( running[it.data()].pid );
+ iface->modem()->setPPPDevice( running[it.data()].device );
+ iface->refresh();
+ }
}
+
+ setHandledInterfaceNames( handledInterfaceNames );
}
/**
* Delete any interfaces that we own.
*/
PPPModule::~PPPModule(){
+ qDebug("PPPModule::~PPPModule() " );
QMap<QString,QString> ifaces;
+ InterfaceKeeper keeper;
Interface *i;
for ( i=list.first(); i != 0; i=list.next() ){
+ /* if online save the state */
+ if ( i->getStatus() ) {
+ qDebug("Iface %s is still up", i->getHardwareName().latin1() );
+ InterfacePPP* ppp = static_cast<InterfacePPP*>(i);
+ keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() );
+ }
ifaces.insert( i->getInterfaceName(), i->getHardwareName() );
delete i;
}
PPPData::setConfiguredInterfaces( ifaces );
}
/**
* Change the current profile
*/
void PPPModule::setProfile(const QString &newProfile){
profile = newProfile;
}
/**
* get the icon name for this device.
* @param Interface* can be used in determining the icon.
* @return QString the icon name (minus .png, .gif etc)
*/
QString PPPModule::getPixmapName(Interface* ){
return "ppp";
}
/**
* Check to see if the interface i is owned by this module.
* @param Interface* interface to check against
* @return bool true if i is owned by this module, false otherwise.
*/
bool PPPModule::isOwner(Interface *i){
return list.find( i ) != -1;
}
/**
* Create, and return the WLANConfigure Module
* @return QWidget* pointer to this modules configure.
*/
QWidget *PPPModule::configure(Interface *i){
qDebug("return ModemWidget");
PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i,
0, "PPPConfig", false,
- Qt::WDestructiveClose );
+ Qt::WDestructiveClose | Qt::WStyle_ContextHelp);
return pppconfig;
}
/**
* Create, and return the Information Module
* @return QWidget* pointer to this modules info.
*/
QWidget *PPPModule::information(Interface *i){
// We don't have any advanced pppd information widget yet :-D
// TODO ^
return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i );
}
/**
* Get all active (up or down) interfaces
* @return QList<Interface> A list of interfaces that exsist that havn't
* been called by isOwner()
*/
QList<Interface> PPPModule::getInterfaces(){
// List all of the files in the peer directory
qDebug("PPPModule::getInterfaces");
return list;
}
/**
* Attempt to add a new interface as defined by name
* @param name the name of the type of interface that should be created given
* by possibleNewInterfaces();
* @return Interface* NULL if it was unable to be created.
*/
Interface *PPPModule::addNewInterface(const QString &newInterface){
InterfacePPP *ifaceppp;
Interface *iface;
ifaceppp = new InterfacePPP();
PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true);
imp.showMaximized();
if(imp.exec() == QDialog::Accepted ){
iface = (InterfacePPP*) ifaceppp;
iface->setModuleOwner( this );
list.append( iface );
return iface;
}else {
delete ifaceppp;
iface = NULL;
}
return iface;
}
/**
* Attempts to remove the interface, doesn't delete i
* @return bool true if successfull, false otherwise.
*/
bool PPPModule::remove(Interface *i){
return list.remove(i);
}
void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces)
{
newIfaces.insert(QObject::tr("PPP") ,
QObject::tr("generic ppp device"));
}
+
+namespace {
+ InterfaceKeeper::InterfaceKeeper( ) {
+ }
+ InterfaceKeeper::~InterfaceKeeper() {
+ Config cfg("ppp_plugin_keeper");
+ QStringList lst = cfg.groupList();
+ for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
+ Connection con;
+ cfg.setGroup( (*it) );
+ cfg.clearGroup();
+ }
+
+ for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it ) {
+ Connection con = it.data();
+ cfg.setGroup( con.name );
+ cfg.writeEntry( "pid", con.pid );
+ cfg.writeEntry( "device", con.device );
+ }
+ }
+ void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name ) {
+ Connection con;
+ con.pid = pid;
+ con.device = dev;
+ con.name = name;
+ m_interfaces.insert( name, con );
+ }
+ QMap<QString, Connection> InterfaceKeeper::interfaces()const {
+ Config cfg("ppp_plugin_keeper");
+ QMap<QString, Connection> ifaces;
+ QStringList lst = cfg.groupList();
+ for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
+ Connection con;
+ cfg.setGroup( (*it) );
+ con.name = (*it);
+ con.pid = cfg.readNumEntry("pid");
+ con.device = cfg.readEntry("device");
+ qDebug(" %s %s %d", con.name.latin1(), con.device.latin1(), con.pid );
+
+ if ( con.pid != -1 && isAvailable( con.pid ) )
+ ifaces.insert( con.name, con );
+ }
+ return ifaces;
+ }
+ bool InterfaceKeeper::isAvailable( pid_t p)const {
+ if (::kill(p, 0 ) == 0 || errno != ESRCH ) {
+ qDebug("isAvailable %d", p);
+ return true;
+ }
+
+ qDebug("notAvailable %d", p);
+ return false;
+ }
+
+}
diff --git a/noncore/settings/networksettings/ppp/runtests.cpp b/noncore/settings/networksettings/ppp/runtests.cpp
index 83ef2ea..5548601 100644
--- a/noncore/settings/networksettings/ppp/runtests.cpp
+++ b/noncore/settings/networksettings/ppp/runtests.cpp
@@ -1,96 +1,94 @@
/*
* kPPP: A pppd front end for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* This file was contributed by Mario Weilguni <mweilguni@sime.com>
* Thanks Mario !
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <qdir.h>
#include "runtests.h"
#include <ctype.h>
#include <unistd.h>
#include <qmessagebox.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <sys/types.h>
#include <pwd.h>
#include <netinet/in.h>
#ifdef HAVE_RESOLV_H
#include <arpa/nameser.h>
#include <resolv.h>
#endif
#ifndef _PATH_RESCONF
#define _PATH_RESCONF "/etc/resolv.conf"
#endif
-//#include <klocale.h>
-#define i18n QObject::tr
#include "pppdata.h"
// initial effective uid (main.cpp)
extern uid_t euid;
// secure pppd location (opener.cpp)
extern const char* pppdPath();
// shamelessly stolen from pppd-2.3.5
/********************************************************************
*
* Internal routine to decode the version.modification.patch level
*/
static void decode_version (const char *_buf, int *version,
int *modification, int *patch)
{
char *buffer = qstrdup(_buf);
char *buf = buffer;
*version = (int) strtoul (buf, &buf, 10);
*modification = 0;
*patch = 0;
if (*buf == '.')
{
++buf;
*modification = (int) strtoul (buf, &buf, 10);
if (*buf == '.')
{
++buf;
*patch = (int) strtoul (buf, &buf, 10);
}
}
if (*buf != '\0')
{
*version =
*modification =
*patch = 0;
}
delete [] buffer;
}
void pppdVersion(int *version, int *modification, int *patch) {
char buffer[30];
const char *pppd;
@@ -172,108 +170,108 @@ const char *homedirFromUid(uid_t uid) {
endpwent();
return d;
}
const char* getHomeDir() {
static const char *hd = 0;
static bool ranTest = false;
if(!ranTest) {
hd = homedirFromUid(getuid());
ranTest = true;
}
return hd;
}
int runTests() {
int warning = 0;
// Test pre-1: check if the user is allowed to dial-out
if(access("/etc/kppp.allow", R_OK) == 0 && getuid() != 0) {
bool access = FALSE;
FILE *f;
if((f = fopen("/etc/kppp.allow", "r")) != NULL) {
char buf[2048]; // safe
while(f != NULL && !feof(f)) {
if(fgets(buf, sizeof(buf), f) != NULL) {
QString s(buf);
s = s.stripWhiteSpace();
if(s[0] == '#' || s.length() == 0)
continue;
if((uid_t)uidFromName(QFile::encodeName(s)) == getuid()) {
access = TRUE;
fclose(f);
f = NULL;
}
}
}
if(f)
fclose(f);
}
if(!access) {
QMessageBox::warning(0,"error",
- i18n("You're not allowed to dial out with "
+ QObject::tr("You're not allowed to dial out with "
"kppp.\nContact your system administrator."));
return TEST_CRITICAL;
}
}
// Test 1: search the pppd binary
const char *f = pppdPath();
if(!f) {
QMessageBox::warning(0,"error",
- i18n("Cannot find the PPP daemon!\n"
+ QObject::tr("Cannot find the PPP daemon!\n"
"Make sure that pppd is installed."));
warning++;
}
// Test 2: check access to the pppd binary
if(f) {
#if 0
if(access(f, X_OK) != 0 /* && geteuid() != 0 */) {
KMessageBox::warning(0,
- i18n("You do not have the permission "
+ QObject::tr("You do not have the permission "
"to start pppd!\n"
"Contact your system administrator "
"and ask to get access to pppd."));
return TEST_CRITICAL;
}
#endif
if(geteuid() != 0) {
struct stat st;
stat(f, &st);
if(st.st_uid != 0 || (st.st_mode & S_ISUID) == 0) {
QMessageBox::warning(0,"error",
- i18n("You don't have sufficient permission to run\n"
+ QObject::tr("You don't have sufficient permission to run\n"
"%1\n"
"Please make sure that kppp is owned by root "
"and has the SUID bit set.").arg(f));
warning++;
}
}
}
// Test 5: check for existence of /etc/resolv.conf
if (access(_PATH_RESCONF, R_OK) != 0) {
QString file = _PATH_RESCONF" ";
- QString msgstr = i18n("%1 is missing or can't be read!\n"
+ QString msgstr = QObject::tr("%1 is missing or can't be read!\n"
"Ask your system administrator to create "
"this file (can be empty) with appropriate "
"read and write permissions.").arg(file);
QMessageBox::warning(0, "errror", msgstr);
warning ++;
}
if(warning == 0)
return TEST_OK;
else
return TEST_WARNING;
}
diff --git a/noncore/settings/networksettings/wlan/keyedit.cpp b/noncore/settings/networksettings/wlan/keyedit.cpp
index ad9ecae..13a1c3b 100644
--- a/noncore/settings/networksettings/wlan/keyedit.cpp
+++ b/noncore/settings/networksettings/wlan/keyedit.cpp
@@ -1,21 +1,22 @@
#include "keyedit.h"
#include <qlineedit.h>
KeyEdit::KeyEdit(QWidget* parent, const char* name) :
QLineEdit(parent, name)
{
+ setEchoMode(Password);
}
KeyEdit::~KeyEdit()
{
}
void KeyEdit::focusInEvent(QFocusEvent *event)
{
setEchoMode(Normal);
}
void KeyEdit::focusOutEvent(QFocusEvent *event)
{
setEchoMode(Password);
}
diff --git a/noncore/settings/networksettings/wlan/wlan.ui b/noncore/settings/networksettings/wlan/wlan.ui
index 7932445..7e39e23 100644
--- a/noncore/settings/networksettings/wlan/wlan.ui
+++ b/noncore/settings/networksettings/wlan/wlan.ui
@@ -1,62 +1,62 @@
<!DOCTYPE UI><UI>
<class>WLAN</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>WLAN</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>251</width>
+ <width>247</width>
<height>299</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Wireless Configuration</string>
</property>
<property stdset="1">
<name>sizeGripEnabled</name>
<bool>true</bool>
</property>
<property>
<name>layoutMargin</name>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QTabWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tabWidget</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>true</bool>
</property>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>ConfigPage</cstring>
</property>
<attribute>
<name>title</name>
<string>General</string>
</attribute>
<spacer>
<property>
<name>name</name>
<cstring>Spacer31</cstring>
</property>
@@ -242,184 +242,190 @@
</property>
</widget>
<widget>
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>specifyChan</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>11</x>
<y>141</y>
<width>129</width>
<height>21</height>
</rect>
</property>
<property stdset="1">
<name>text</name>
<string>Specify &amp;Channel</string>
</property>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer10</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget>
<class>QComboBox</class>
<item>
<property>
<name>text</name>
- <string>Auto</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>Managed</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>Ad-Hoc</string>
+ <string>any</string>
</property>
</item>
<property stdset="1">
<name>name</name>
- <cstring>mode</cstring>
- </property>
- <property stdset="1">
- <name>enabled</name>
- <bool>true</bool>
+ <cstring>essid</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>101</x>
- <y>11</y>
+ <y>46</y>
<width>103</width>
<height>29</height>
</rect>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
- <hsizetype>1</hsizetype>
+ <hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
</sizepolicy>
</property>
+ <property stdset="1">
+ <name>editable</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>currentItem</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>sizeLimit</name>
+ <number>5</number>
+ </property>
+ <property stdset="1">
+ <name>autoCompletion</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>duplicatesEnabled</name>
+ <bool>false</bool>
+ </property>
</widget>
<widget>
<class>QComboBox</class>
<item>
<property>
<name>text</name>
- <string>any</string>
+ <string>Infrastructure</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>Auto</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>Managed</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>Ad-Hoc</string>
</property>
</item>
<property stdset="1">
<name>name</name>
- <cstring>essid</cstring>
+ <cstring>mode</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>true</bool>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>101</x>
- <y>46</y>
+ <y>11</y>
<width>103</width>
<height>29</height>
</rect>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
- <hsizetype>7</hsizetype>
+ <hsizetype>1</hsizetype>
<vsizetype>0</vsizetype>
</sizepolicy>
</property>
- <property stdset="1">
- <name>editable</name>
- <bool>true</bool>
- </property>
- <property stdset="1">
- <name>currentItem</name>
- <number>0</number>
- </property>
- <property stdset="1">
- <name>sizeLimit</name>
- <number>5</number>
- </property>
- <property stdset="1">
- <name>autoCompletion</name>
- <bool>true</bool>
- </property>
- <property stdset="1">
- <name>duplicatesEnabled</name>
- <bool>false</bool>
- </property>
</widget>
</widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>WepPage</cstring>
</property>
<attribute>
<name>title</name>
<string>Encryption</string>
</attribute>
<grid>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget row="0" column="0" >
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>wepEnabled</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Enable Encryption</string>
</property>
</widget>
<widget row="1" column="0" >
<class>QButtonGroup</class>
<property stdset="1">
<name>name</name>
<cstring>KeyButtonGroup</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>false</bool>
</property>
<property stdset="1">
<name>title</name>
<string>&amp;Key Setting</string>
</property>
<grid>
<property stdset="1">
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp
index cdafb4d..26e3aa9 100644
--- a/noncore/settings/networksettings/wlan/wlanimp2.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp
@@ -1,125 +1,120 @@
#include "wlanimp2.h"
#include "keyedit.h"
#include "interfacesetupimp.h"
#include <qfile.h>
#include <qdir.h>
#include <qtextstream.h>
#include <qmessagebox.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qspinbox.h>
#include <qradiobutton.h>
#include <qcheckbox.h>
#include <qtabwidget.h>
#include <qcombobox.h>
#ifdef QWS
#include <opie/oprocess.h>
#else
#define OProcess KProcess
#include <kprocess.h>
#endif
#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
#define PREUP "/etc/netwrok/if-pre-up.d/wireless-tools"
/**
* Constructor, read in the wireless.opts file for parsing later.
*/
-WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), currentProfile("*"), interface(i) {
+WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") {
interfaces = new Interfaces();
interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces);
tabWidget->insertTab(interfaceSetup, "TCP/IP");
// Check sanity - the existance of the wireless-tools if-pre-up script
QFile file(QString(PREUP));
if (file.exists()) {
qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools"));
}
}
WLANImp::~WLANImp() {
//FIXME: delete interfaces;
}
/**
* Change the profile for both wireless settings and network settings.
*/
void WLANImp::setProfile(const QString &profile){
interfaceSetup->setProfile(profile);
parseOpts();
}
void WLANImp::parseOpts() {
bool error;
QString opt;
if (! interfaces->isInterfaceSet())
return;
opt = interfaces->getInterfaceOption("wireless_essid", error);
if(opt == "any" || opt == "off" || opt.isNull()){
essid->setEditText("any");
} else {
essid->setEditText(opt);
}
opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace();
- if (opt == "Auto") {
- mode->setCurrentItem(0);
- } else if (opt == "Ad-Hoc") {
- mode->setCurrentItem(2);
- } else {
- // Managed/Infrastructure mode
- mode->setCurrentItem(1);
- }
+
+ for ( int i = 0; i < mode->count(); i++)
+ if ( mode->text( i ) == opt ) mode->setCurrentItem( i );
opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace();
if (! opt.isNull()) {
specifyAp->setChecked(true);
macEdit->setText(opt);
}
opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace();
if (! opt.isNull()) {
specifyChan->setChecked(true);
networkChannel->setValue(opt.toInt());
}
opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace();
if (opt.isNull())
opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace();
parseKeyStr(opt);
}
void WLANImp::parseKeyStr(QString keystr) {
int loc = 0;
int index = 1;
QString key;
QStringList keys = QStringList::split(QRegExp("\\s+"), keystr);
int enc = -1; // encryption state
for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) {
if ((*it).left(3) == "off") {
// encryption disabled
enc = 0;
} else if ((*it).left(2) == "on") {
// encryption enabled
enc = 1;
} else if ((*it).left(4) == "open") {
// open mode, accept non encrypted packets
acceptNonEnc->setChecked(true);
} else if ((*it).left(10) == "restricted") {
// restricted mode, only accept encrypted packets
rejectNonEnc->setChecked(true);
} else if ((*it).left(3) == "key") {
// new set of options
} else if ((*it).left(1) == "[") {
index = (*it).mid(1, 1).toInt();
// switch current key to index
switch (index) {
case 1:
keyRadio0->setChecked(true);
break;
@@ -158,112 +153,124 @@ void WLANImp::parseKeyStr(QString keystr) {
keyLineEdit1->setText(key);
break;
case 3:
keyLineEdit2->setText(key);
break;
case 4:
keyLineEdit3->setText(key);
break;
}
key = QString::null;
}
}
if (enc == 1) {
wepEnabled->setChecked(true);
} else {
wepEnabled->setChecked(false);
}
}
/**
* Check to see if the current config is valid
* Save interfaces
*/
void WLANImp::accept() {
if (wepEnabled->isChecked()) {
if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) ||
(keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) ||
(keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) ||
(keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) {
QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok);
return;
}
}
if (essid->currentText().isEmpty()) {
QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok);
return;
}
if (specifyAp->isChecked() && macEdit->text().isEmpty()) {
QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok);
return;
}
// Try to save the interfaces settings.
writeOpts();
// Close out the dialog
- QDialog::accept();
+// FIXME: QDialog::accept();
}
void WLANImp::writeOpts() {
- bool error = false;
+ // eh can't really do anything about it other then return. :-D
+ if(!interfaces->isInterfaceSet()){
+ QMessageBox::warning(0,"Inface not set","should not happen!!!");
+ return;
+ }
+ bool error = false;
+
+ qDebug("setting wlan interface %s", interfaces->getInterfaceName( error ).latin1() );
+
+ if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!");
interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText());
interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText());
if (specifyAp->isChecked()) {
interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text());
} else {
interfaces->removeInterfaceOption(QString("wireless_ap"));
}
if (specifyChan->isChecked()) {
interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text());
} else {
interfaces->removeInterfaceOption(QString("wireless_channel"));
}
if (wepEnabled->isChecked()) {
QStringList keyList;
if (! keyLineEdit0->text().isNull()) {
keyList += keyLineEdit0->text();
keyList += "[1]";
- } else if (! keyLineEdit1->text().isNull()) {
+ } //else
+ if (! keyLineEdit1->text().isNull()) {
keyList += keyLineEdit1->text();
keyList += "[2]";
- } else if (! keyLineEdit2->text().isNull()) {
+ } //else
+ if (! keyLineEdit2->text().isNull()) {
keyList += keyLineEdit2->text();
keyList += "[3]";
- } else if (! keyLineEdit3->text().isNull()) {
+ } //else
+ if (! keyLineEdit3->text().isNull()) {
keyList += keyLineEdit3->text();
keyList += "[4]";
}
if (acceptNonEnc->isChecked()) {
keyList += "open";
} else {
keyList += "restricted";
}
keyList += "key";
if (keyRadio0->isChecked()) {
keyList += "[1]";
} else if (keyRadio1->isChecked()) {
keyList += "[2]";
} else if (keyRadio2->isChecked()) {
keyList += "[3]";
} else if (keyRadio3->isChecked()) {
keyList += "[4]";
}
interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" ")));
} else {
interfaces->removeInterfaceOption(QString("wireless_key"));
}
interfaces->removeInterfaceOption(QString("wireless_enc"));
if(!interfaceSetup->saveChanges())
return;
QDialog::accept();
}
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index a4488f9..b4c3509 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -1,50 +1,50 @@
#include "wlanmodule.h"
-#include "wlanimp.h"
+#include "wlanimp2.h"
#include "infoimp.h"
#include "wextensions.h"
#include "interfaceinformationimp.h"
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qprogressbar.h>
#include <qspinbox.h>
#include <qtabwidget.h>
/**
* Constructor, find all of the possible interfaces
*/
WLANModule::WLANModule()
: Module(),
wlanconfigWiget(0)
{
}
/**
* Delete any interfaces that we own.
*/
WLANModule::~WLANModule(){
Interface *i;
for ( i=list.first(); i != 0; i=list.next() )
delete i;
}
/**
* Change the current profile
*/
void WLANModule::setProfile(const QString &newProfile){
profile = newProfile;
}
/**
* get the icon name for this device.
* @param Interface* can be used in determining the icon.
* @return QString the icon name (minus .png, .gif etc)
*/
QString WLANModule::getPixmapName(Interface* ){
return "wlan";
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp
index c06f639..19b0e84 100644
--- a/noncore/settings/usermanager/userdialog.cpp
+++ b/noncore/settings/usermanager/userdialog.cpp
@@ -380,62 +380,62 @@ bool UserDialog::editUser(const char *username) {
accounts->pw_shell=edituserDialog->shellComboBox->currentText();
// Update userinfo, using the information stored in the user variables stored in the accounts object.
accounts->updateUser(username);
// Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.)
for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {
accounts->delGroupMember((*it).left((*it).find(":")),username);
}
// Add User to additional groups that he/she is a member of.
QListViewItemIterator it( edituserDialog->groupsListView );
for ( ; it.current(); ++it ) {
temp=(QCheckListItem*)it.current();
if ( temp->isOn() )
accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text());
}
// Copy image to pics/users/
if(!(edituserDialog->userImage.isNull())) {
QDir d;
if(!(d.exists("/opt/QtPalmtop/pics/users"))) {
d.mkdir("/opt/QtPalmtop/pics/users");
}
QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png";
// edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48);
edituserDialog->userImage.save(filename,"PNG");
}
return true;
}
/**
* "OK" has been clicked. Verify some information before closing the dialog.
*
*/
void UserDialog::accept() {
// Add checking... valid username? username taken?
if(loginLineEdit->text().isEmpty()) {
QMessageBox::information(0,"Empty Login","Please enter a login.");
return;
}
QDialog::accept();
}
/**
* This slot is called when the usericon is clicked, this loads (should) the iconselector.
*
*/
void UserDialog::clickedPicture() {
- QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED,"/opt/QtPalmtop/pics");
+ QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED, QString::null);
if(!(filename.isEmpty())) {
userImage.reset();
if(!(userImage.load(filename))) {
QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename);
} else {
// userImage=userImage.smoothScale(48,48);
QPixmap *picture;
picture=(QPixmap *)picturePushButton->pixmap();
picture->convertFromImage(userImage,0);
picturePushButton->update();
}
}
}
diff --git a/noncore/settings/usermanager/userdialog.h b/noncore/settings/usermanager/userdialog.h
index b7b925d..3272afc 100644
--- a/noncore/settings/usermanager/userdialog.h
+++ b/noncore/settings/usermanager/userdialog.h
@@ -1,66 +1,67 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef USERDIALOG_H
#define USERDIALOG_H
#include <qdialog.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qlistview.h>
#include <qtabwidget.h>
#include <qpushbutton.h>
#include <qcheckbox.h>
+#include <qlabel.h>
#include <qpe/resource.h>
#include <opie/ofiledialog.h>
class UserDialog : public QDialog
{
Q_OBJECT
private:
QTabWidget *myTabWidget;
QPushButton *picturePushButton;
QLineEdit *loginLineEdit;
QLineEdit *uidLineEdit;
QLineEdit *gecosLineEdit;
QLineEdit *passwordLineEdit;
QComboBox *shellComboBox;
QComboBox *groupComboBox;
QLabel *skelLabel;
QCheckBox *skelCheckBox;
QListView *groupsListView;
QStringList groupMembers;
QString pictureLocation;
QImage userImage;
int groupID;
int userID;
int vm;
enum VIEWMODE {
VIEWMODE_NEW,
VIEWMODE_EDIT
};
void setupTab1(void);
void setupTab2(void);
void accept(void);
private slots:
void clickedPicture(void);
public:
UserDialog( int viewmode=VIEWMODE_NEW, QWidget* parent = 0, const char* name = 0, bool modal=true, WFlags fl = 0 );
~UserDialog();
static bool addUser(int uid, int gid);
static bool editUser(const char *username);
static bool delUser(const char *username);
};
#endif
diff --git a/noncore/settings/usermanager/usermanager.cpp b/noncore/settings/usermanager/usermanager.cpp
index 1946013..65bbd8b 100644
--- a/noncore/settings/usermanager/usermanager.cpp
+++ b/noncore/settings/usermanager/usermanager.cpp
@@ -1,78 +1,78 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "usermanager.h"
#include <qlayout.h>
#include <stdio.h>
#include <qmessagebox.h>
#include <qfile.h>
#include <qpe/resource.h>
#include <qregexp.h>
/**
* The mainwindow constructor.
*
* @param QWidget *parent
* @param const char *name
* @ param WFlags fl
*
*/
UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) {
- setCaption(tr("OPIE User Manager"));
+ setCaption(tr("Opie User Manager"));
// Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them.
accounts=new Passwd();
accounts->open(); // This actually loads the files /etc/passwd & /etc/group into memory.
// Create the toolbar.
QPEToolBar *toolbar = new QPEToolBar(this,"Toolbar");
toolbar->setHorizontalStretchable(1); // Is there any other way to get the toolbar to stretch of the full screen!?
adduserToolButton = new QToolButton(Resource::loadPixmap("usermanager/adduser"),"Add User",0,this,SLOT(addUser()),toolbar,"Add User");
edituserToolButton = new QToolButton(Resource::loadPixmap("usermanager/edituser"),"Edit User",0,this,SLOT(editUser()),toolbar,"Edit User");
deleteuserToolButton = new QToolButton(Resource::loadPixmap("usermanager/deleteuser"),"Delete User",0,this,SLOT(delUser()),toolbar,"Delete User");
QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User");
userstext->setUsesTextLabel(true);
toolbar->addSeparator();
addgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/addgroup"),"Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group");
editgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/editgroup"),"Edit Group",0,this,SLOT(editGroup()),toolbar,"Edit Group");
deletegroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/deletegroup"),"Delete Group",0,this,SLOT(delGroup()),toolbar,"Delete Group");
QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group");
groupstext->setUsesTextLabel(true);
addToolBar(toolbar,"myToolBar");
// Add a tabwidget and all the tabs.
myTabWidget = new QTabWidget(this,"My Tab Widget");
setupTabAccounts();
setupTabAllUsers();
setupTabAllGroups();
userPopupMenu.insertItem("Copy",0);
getUsers(); // Fill out the iconview & listview with all users.
getGroups(); // Fill out the group listview with all groups.
setCentralWidget(myTabWidget);
}
UserConfig::~UserConfig() {
accounts->close();
delete accounts;
}
void UserConfig::setupTabAccounts() {
QWidget *tabpage = new QWidget(this);
QVBoxLayout *layout = new QVBoxLayout(tabpage);
layout->setMargin(5);
usersIconView=new QListView(tabpage,"users");
usersIconView->addColumn("Icon");
usersIconView->addColumn("Username");
usersIconView->setAllColumnsShowFocus(true);
diff --git a/noncore/settings/usermanager/usermanager.pro b/noncore/settings/usermanager/usermanager.pro
index 576a233..1baccb6 100644
--- a/noncore/settings/usermanager/usermanager.pro
+++ b/noncore/settings/usermanager/usermanager.pro
@@ -1,34 +1,34 @@
TEMPLATE = app
#CONFIG = qt warn_on debug
CONFIG = qt warn_on release
HEADERS = usermanager.h userdialog.h groupdialog.h passwd.h
-SOURCES = usermanager.cpp userdialog.cpp groupdialog.cpp passwd.cpp main.cpp
+SOURCES = usermanager.cpp userdialog.cpp groupdialog.cpp passwd.h main.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopie -lcrypt
TARGET = usermanager
DESTDIR = $(OPIEDIR)/bin
TRANSLATIONS = ../../../i18n/de/usermanager.ts \
../../../i18n/nl/usermanager.ts \
../../../i18n/xx/usermanager.ts \
../../../i18n/en/usermanager.ts \
../../../i18n/es/usermanager.ts \
../../../i18n/fr/usermanager.ts \
../../../i18n/hu/usermanager.ts \
../../../i18n/ja/usermanager.ts \
../../../i18n/ko/usermanager.ts \
../../../i18n/no/usermanager.ts \
../../../i18n/pl/usermanager.ts \
../../../i18n/pt/usermanager.ts \
../../../i18n/pt_BR/usermanager.ts \
../../../i18n/sl/usermanager.ts \
../../../i18n/zh_CN/usermanager.ts \
../../../i18n/zh_TW/usermanager.ts \
../../../i18n/it/usermanager.ts \
../../../i18n/da/usermanager.ts
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/styles/flat/flat.cpp b/noncore/styles/flat/flat.cpp
index b6635c5..24366f6 100644
--- a/noncore/styles/flat/flat.cpp
+++ b/noncore/styles/flat/flat.cpp
@@ -1,333 +1,395 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
-#include "flat.h"
-#include <qpe/qpeapplication.h>
+#include <qtopia/qpeapplication.h>
#include <qpushbutton.h>
#include <qtoolbutton.h>
#include <qpainter.h>
#include <qfontmetrics.h>
#include <qpalette.h>
#include <qdrawutil.h>
#include <qscrollbar.h>
#include <qbutton.h>
#include <qframe.h>
#include <qtabbar.h>
#include <qspinbox.h>
#include <qlineedit.h>
+#include <qmap.h>
#define INCLUDE_MENUITEM_DEF
#include <qmenudata.h>
+#include <qpopupmenu.h>
+
+#include "flat.h"
#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
class SpinBoxHack : public QSpinBox
{
public:
void setFlatButtons( bool f ) {
upButton()->setFlat( f );
downButton()->setFlat( f );
}
};
class FlatStylePrivate : public QObject
{
Q_OBJECT
public:
FlatStylePrivate() : QObject() {}
bool eventFilter( QObject *o, QEvent *e ) {
- if ( e->type() == QEvent::ParentPaletteChange && o->inherits( "QMenuBar" ) ) {
- QWidget *w = (QWidget *)o;
- if ( w->parentWidget() ) {
- QPalette p = w->parentWidget()->palette();
- QColorGroup a = p.active();
- a.setColor( QColorGroup::Light, a.foreground() );
- a.setColor( QColorGroup::Dark, a.foreground() );
- p.setActive( a );
- p.setInactive( a );
- w->setPalette( p );
+ if ( e->type() == QEvent::ParentPaletteChange ) {
+ if ( o->inherits( "QMenuBar" ) ) {
+ QWidget *w = (QWidget *)o;
+ if ( w->parentWidget() ) {
+ QPalette p = w->parentWidget()->palette();
+ QColorGroup a = p.active();
+ a.setColor( QColorGroup::Light, a.foreground() );
+ a.setColor( QColorGroup::Dark, a.foreground() );
+ p.setActive( a );
+ p.setInactive( a );
+ w->setPalette( p );
+ }
+ } else if ( o->inherits( "QHeader" ) ) {
+ QWidget *w = (QWidget *)o;
+ if ( w->parentWidget() ) {
+ QPalette p = w->parentWidget()->palette();
+ QColorGroup a = p.active();
+ a.setColor( QColorGroup::Light, a.button() );
+ p.setActive( a );
+ p.setInactive( a );
+ w->setPalette( p );
+ }
}
}
return FALSE;
}
+
+ QMap<QFrame *,int> frameStyles;
};
-FlatStyle::FlatStyle() : revItem(FALSE)
+FlatStyle::FlatStyle() : revItem(FALSE), fillBtnBorder(FALSE)
{
setButtonMargin(3);
setScrollBarExtent(13,13);
setButtonDefaultIndicatorWidth(0);
d = new FlatStylePrivate;
}
FlatStyle::~FlatStyle()
{
delete d;
}
int FlatStyle::buttonMargin() const
{
return 3;
}
QSize FlatStyle::scrollBarExtent() const
{
return QSize(13,13);
}
void FlatStyle::polish ( QPalette & )
{
}
void FlatStyle::polish( QWidget *w )
{
if ( w->inherits( "QFrame" ) ) {
QFrame *f = (QFrame *)w;
- if ( f->frameShape() != QFrame::NoFrame )
+ if ( f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine )
+ f->setFrameShadow( QFrame::Plain );
+ else if ( f->frameShape() != QFrame::NoFrame )
f->setFrameShape( QFrame::StyledPanel );
f->setLineWidth( 1 );
}
if ( w->inherits( "QSpinBox" ) )
((SpinBoxHack*)w)->setFlatButtons( TRUE );
if ( w->inherits( "QMenuBar" ) ) {
// make selected item look flat
QPalette p = w->palette();
QColorGroup a = p.active();
a.setColor( QColorGroup::Light, a.foreground() );
a.setColor( QColorGroup::Dark, a.foreground() );
p.setActive( a );
p.setInactive( a );
w->setPalette( p );
w->installEventFilter( d );
+ } else if ( w->inherits( "QHeader" ) ) {
+ // make headers look flat
+ QPalette p = w->palette();
+ QColorGroup a = p.active();
+ a.setColor( QColorGroup::Light, a.button() );
+ p.setActive( a );
+ p.setInactive( a );
+ w->setPalette( p );
+ w->installEventFilter( d );
}
}
void FlatStyle::unPolish( QWidget *w )
{
- if ( w->inherits( "QFrame" ) ) {
+ if ( w->inherits("QFrame") ) {
QFrame *f = (QFrame *)w;
- if ( f->frameShape() != QFrame::NoFrame )
+ if ( f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine ) {
+ f->setFrameShadow( QFrame::Sunken );
+ } else if ( f->frameShape() != QFrame::NoFrame ) {
f->setFrameShape( QFrame::StyledPanel );
- f->setLineWidth( 2 );
+ f->setLineWidth( 2 );
+ }
}
- if ( w->inherits( "QSpinBox" ) )
+ if ( w->inherits("QSpinBox") )
((SpinBoxHack*)w)->setFlatButtons( FALSE );
- if ( w->inherits( "QMenuBar" ) ) {
+ if ( w->inherits("QMenuBar") || w->inherits("QHeader") ) {
w->unsetPalette();
w->removeEventFilter( d );
}
}
int FlatStyle::defaultFrameWidth() const
{
- return 1;
+ return 2;
}
void FlatStyle::drawItem( QPainter *p, int x, int y, int w, int h,
int flags, const QColorGroup &g, bool enabled,
const QPixmap *pixmap, const QString& text, int len,
const QColor* penColor )
{
QColor pc( penColor ? *penColor : g.foreground() );
QColorGroup cg( g );
if ( !enabled )
cg.setColor( QColorGroup::Light, cg.background() );
if ( revItem ) {
pc = cg.button();
revItem = FALSE;
}
QWindowsStyle::drawItem( p, x, y, w, h, flags, cg, enabled, pixmap, text, len, &pc );
}
void FlatStyle::drawPanel ( QPainter * p, int x, int y, int w, int h,
const QColorGroup &g, bool /*sunken*/, int lineWidth, const QBrush * fill )
{
if ( fill )
p->setBrush( *fill );
p->setPen( QPen(g.foreground(), lineWidth) );
p->drawRect( x, y, w, h );
}
void FlatStyle::drawButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &cg, bool /*sunken*/, const QBrush* fill )
{
QPen oldPen = p->pen();
+ int x2 = x+w-1;
+ int y2 = y+h-1;
+
+ if ( fillBtnBorder && btnBg != cg.color(QColorGroup::Button) ) {
+ p->setPen( btnBg );
+ p->drawLine( x, y, x2, y );
+ p->drawLine( x, y2, x2, y2 );
+ p->drawLine( x, y+1, x, y2-1 );
+ p->drawLine( x2, y+1, x2, y2-1 );
+ p->fillRect( x+1, y+1, 3, 3, btnBg );
+ p->fillRect( x+1, y2-3, 3, 3, btnBg );
+ p->fillRect( x2-3, y2-3, 3, 3, btnBg );
+ p->fillRect( x2-3, y+1, 3, 3, btnBg );
+ p->fillRect( x+2, y+2, w-4, h-4, fill?(*fill):cg.brush(QColorGroup::Button) );
+ } else {
+ p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):cg.brush(QColorGroup::Button) );
+ }
+
if ( h >= 10 ) {
x++; y++;
+ x2--; y2--;
w -= 2; h -= 2;
}
- p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):cg.brush(QColorGroup::Button) );
-
- int x2 = x+w-1;
- int y2 = y+h-1;
-
p->setPen( cg.foreground() );
if ( h < 10 ) {
p->setBrush( NoBrush );
p->drawRect( x, y, w, h );
} else {
p->drawLine( x+3, y, x2-3, y );
p->drawLine( x+3, y2, x2-3, y2 );
p->drawLine( x, y+3, x, y2-3 );
p->drawLine( x2, y+3, x2, y2-3 );
p->drawLine( x+1, y+1, x+2, y+1 );
p->drawPoint( x+1, y+2 );
p->drawLine( x2-2, y+1, x2-1, y+1 );
p->drawPoint( x2-1, y+2 );
p->drawLine( x+1, y2-1, x+2, y2-1 );
p->drawPoint( x+1, y2-2 );
p->drawLine( x2-2, y2-1, x2-1, y2-1 );
p->drawPoint( x2-1, y2-2 );
}
p->setPen( oldPen );
}
void FlatStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h )
{
x++; y++;
x-=2; y-=2;
p->fillRect( x, y, w, h, color1 );
}
void FlatStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool /*sunken*/, const QBrush* fill )
{
p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):g.brush(QColorGroup::Button) );
p->setPen( g.foreground() );
p->setBrush( NoBrush );
p->drawRect( x, y, w, h );
}
void FlatStyle::drawToolButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken, const QBrush* fill )
{
+ if ( p->device()->devType() == QInternal::Widget ) {
+ QWidget *w = (QWidget *)p->device();
+ if ( w->isA("QToolButton") ) {
+ QToolButton *btn = (QToolButton *)w;
+ if ( btn->parentWidget() ) {
+ btnBg = btn->parentWidget()->backgroundColor();
+ fillBtnBorder = TRUE;
+ }
+ }
+ }
QBrush fb( fill ? *fill : g.button() );
if ( sunken && fb == g.brush( QColorGroup::Button ) ) {
fb = g.buttonText();
revItem = TRUE; // ugh
}
drawButton( p, x, y, w, h, g, sunken, &fb );
+ fillBtnBorder = FALSE;
}
void FlatStyle::drawPushButton( QPushButton *btn, QPainter *p )
{
QColorGroup g = btn->colorGroup();
int x1, y1, x2, y2;
btn->rect().coords( &x1, &y1, &x2, &y2 ); // get coordinates
p->setPen( g.foreground() );
p->setBrush( QBrush(g.button(),NoBrush) );
// int diw = buttonDefaultIndicatorWidth();
/*
if ( btn->isDefault() || btn->autoDefault() ) {
if ( btn->isDefault() ) {
p->setPen( g.shadow() );
p->drawRect( x1, y1, x2-x1+1, y2-y1+1 );
}
x1 += diw;
y1 += diw;
x2 -= diw;
y2 -= diw;
}
*/
+ if ( btn->parentWidget() ) {
+ btnBg = btn->parentWidget()->backgroundColor();
+ fillBtnBorder = TRUE;
+ }
+
bool clearButton = TRUE;
if ( btn->isDown() ) {
drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE,
&g.brush( QColorGroup::Text ) );
} else {
if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() ) {
QBrush fill(g.light(), Dense4Pattern );
drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE, &fill );
clearButton = FALSE;
} else {
if ( !btn->isFlat() )
drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, btn->isOn(),
&g.brush( QColorGroup::Button ) );
}
}
/*
if ( clearButton ) {
if (btn->isDown())
p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
p->fillRect( x1+2, y1+2, x2-x1-3, y2-y1-3,
g.brush( QColorGroup::Button ) );
if (btn->isDown())
p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
}
*/
+ fillBtnBorder = FALSE;
if ( p->brush().style() != NoBrush )
p->setBrush( NoBrush );
}
void FlatStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p )
{
QRect r = pushButtonContentsRect( btn );
int x, y, w, h;
r.rect( &x, &y, &w, &h );
QColorGroup cg = btn->colorGroup();
if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() && !btn->isDown() )
cg.setColor( QColorGroup::ButtonText, btn->colorGroup().text() );
else if ( btn->isDown() || btn->isOn() )
cg.setColor( QColorGroup::ButtonText, btn->colorGroup().button() );
if ( btn->isMenuButton() ) {
int dx = menuButtonIndicatorWidth( btn->height() );
drawArrow( p, DownArrow, FALSE,
x+w-dx, y+2, dx-4, h-4,
cg,
btn->isEnabled() );
w -= dx;
}
if ( btn->iconSet() && !btn->iconSet()->isNull() ) {
QIconSet::Mode mode = btn->isEnabled()
? QIconSet::Normal : QIconSet::Disabled;
if ( mode == QIconSet::Normal && btn->hasFocus() )
mode = QIconSet::Active;
QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode );
int pixw = pixmap.width();
int pixh = pixmap.height();
p->drawPixmap( x+2, y+h/2-pixh/2, pixmap );
x += pixw + 4;
w -= pixw + 4;
}
drawItem( p, x, y, w, h,
AlignCenter | ShowPrefix,
cg, btn->isEnabled(),
btn->pixmap(), btn->text(), -1, &cg.buttonText() );
}
QRect FlatStyle::comboButtonRect( int x, int y, int w, int h)
{
return QRect(x+2, y+2, w-4-13, h-4);
}
@@ -544,97 +606,98 @@ void FlatStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sl
subPageR.setRect( 0, 0, sliderStart+1, sliderW );
addPageR.setRect( sliderEnd-1, 0, subX - sliderEnd+2, sliderW );
sliderR .setRect( sliderStart, 0, sliderLength, sliderW );
} else {
subB.setRect( subX,subY,dimB,dimB );
addB.setRect( addX,addY,dimB,dimB );
subPageR.setRect( 0, 0, sliderW, sliderStart+1 );
addPageR.setRect( 0, sliderEnd-1, sliderW, subY - sliderEnd+2 );
sliderR .setRect( 0, sliderStart, sliderW, sliderLength );
}
bool maxedOut = (sb->maxValue() == sb->minValue());
p->setPen( g.foreground() );
if ( controls & AddLine ) {
p->setBrush( ADD_LINE_ACTIVE ? g.foreground() : g.button() );
p->drawRect( addB.x(), addB.y(), addB.width(), addB.height() );
p->setPen( ADD_LINE_ACTIVE ? g.button() : g.foreground() );
QColorGroup cg( g );
if ( maxedOut )
cg.setColor( QColorGroup::ButtonText, g.mid() );
else if ( ADD_LINE_ACTIVE )
cg.setColor( QColorGroup::ButtonText, g.button() );
int xo = VERTICAL ? 1 : 0;
drawArrow( p, VERTICAL ? DownArrow : RightArrow, FALSE,
addB.x()+2+xo, addB.y()+2, addB.width()-4-xo, addB.height()-4,
cg, TRUE, &p->brush() );
}
if ( controls & SubLine ) {
p->setBrush( SUB_LINE_ACTIVE ? g.foreground() : g.button() );
p->drawRect( subB.x(), subB.y(), subB.width(), subB.height() );
p->setPen( SUB_LINE_ACTIVE ? g.button() : g.foreground() );
QColorGroup cg( g );
if ( maxedOut )
cg.setColor( QColorGroup::ButtonText, g.mid() );
else if ( SUB_LINE_ACTIVE )
cg.setColor( QColorGroup::ButtonText, g.button() );
int xo = VERTICAL ? 1 : 0;
drawArrow( p, VERTICAL ? UpArrow : LeftArrow, FALSE,
subB.x()+2+xo, subB.y()+2, subB.width()-4-xo, subB.height()-4,
cg, TRUE, &p->brush() );
}
p->setPen( g.foreground() );
p->setBrush( g.brush( QColorGroup::Mid ) );
if ( controls & SubPage )
p->drawRect( subPageR.x(), subPageR.y(), subPageR.width(), subPageR.height() );
- if ( controls & AddPage && addPageR.y() < addPageR.bottom() )
+ if ( controls & AddPage && addPageR.y() < addPageR.bottom() &&
+ addPageR.x() < addPageR.right() )
p->drawRect( addPageR.x(), addPageR.y(), addPageR.width(), addPageR.height() );
if ( controls & Slider ) {
QPoint bo = p->brushOrigin();
p->setBrushOrigin(sliderR.topLeft());
p->setPen( g.foreground() );
p->setBrush( g.button() );
p->drawRect( sliderR.x(), sliderR.y(), sliderR.width(), sliderR.height() );
p->setBrushOrigin(bo);
QColorGroup cg( g );
if ( maxedOut )
cg.setColor( QColorGroup::ButtonText, g.mid() );
drawRiffles( p, sliderR.x(), sliderR.y(),
sliderR.width(), sliderR.height(), cg, HORIZONTAL );
}
// ### perhaps this should not be able to accept focus if maxedOut?
if ( sb->hasFocus() && (controls & Slider) )
p->drawWinFocusRect( sliderR.x()+2, sliderR.y()+2,
sliderR.width()-5, sliderR.height()-5,
sb->backgroundColor() );
}
void FlatStyle::drawRiffles( QPainter* p, int x, int y, int w, int h,
const QColorGroup &g, bool horizontal )
{
if (!horizontal) {
if (h > 20) {
y += (h-20)/2 ;
h = 20;
}
if (h > 12) {
int n = 3;
int my = y+h/2-2;
int i ;
p->setPen(g.buttonText());
for (i=0; i<n; i++) {
p->drawLine(x+4, my+3*i, x+w-5, my+3*i);
}
}
} else {
if (w > 20) {
x += (w-20)/2 ;
w = 20;
}
if (w > 12) {
int n = 3;
int mx = x+w/2-4;
@@ -739,96 +802,102 @@ void FlatStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected
p->drawPoint( r.right() - 1, r.top() + 1 );
p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1);
} else if ( tb->shape() == QTabBar::RoundedBelow ) {
if ( selected ) {
p->setPen( tb->colorGroup().background() );
p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2),
tb->palette().normal().brush( QColorGroup::Background ));
} else {
p->setPen( tb->colorGroup().foreground() );
p->drawLine( r.left(), r.top(),
r.right(), r.top() );
r.setRect( r.left() + 2, r.top(),
r.width() - 4, r.height() - 2 );
p->setPen( tb->colorGroup().button() );
p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3),
tb->palette().normal().brush( QColorGroup::Button ));
}
p->setPen( tb->colorGroup().foreground() );
p->drawLine( r.right(), r.top(),
r.right(), r.bottom() - 2 );
p->drawPoint( r.right() - 1, r.bottom() - 1 );
p->drawLine( r.right() - 2, r.bottom(),
r.left() + 2, r.bottom() );
p->drawLine( r.left(), r.top()+1,
r.left(), r.bottom() - 2 );
p->drawPoint( r.left() + 1, r.bottom() - 1 );
if ( r.left() == 0 )
p->drawPoint( tb->rect().topLeft() );
} else {
QCommonStyle::drawTab( p, tb, t, selected );
}
}
static const int motifItemFrame = 0; // menu item frame width
static const int motifSepHeight = 2; // separator item height
static const int motifItemHMargin = 1; // menu item hor text margin
static const int motifItemVMargin = 2; // menu item ver text margin
static const int motifArrowHMargin = 0; // arrow horizontal margin
static const int motifTabSpacing = 12; // space between text and tab
static const int motifCheckMarkHMargin = 1; // horiz. margins of check mark
static const int windowsRightBorder = 8; // right border on windows
static const int windowsCheckMarkWidth = 2; // checkmarks width on windows
+void FlatStyle::polishPopupMenu ( QPopupMenu *m )
+{
+ QWindowsStyle::polishPopupMenu( m );
+ m->setLineWidth( 1 );
+}
+
/*! \reimp
*/
int FlatStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ )
{
#ifndef QT_NO_MENUDATA
int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm
if ( mi->isSeparator() )
return 10; // arbitrary
else if ( mi->pixmap() )
w += mi->pixmap()->width(); // pixmap only
if ( !mi->text().isNull() ) {
if ( mi->text().find('\t') >= 0 ) // string contains tab
w += motifTabSpacing;
}
if ( maxpmw ) { // we have iconsets
w += maxpmw;
w += 6; // add a little extra border around the iconset
}
if ( checkable && maxpmw < windowsCheckMarkWidth ) {
w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks
}
if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks)
w += motifCheckMarkHMargin; // add space to separate the columns
w += windowsRightBorder; // windows has a strange wide border on the right side
return w;
#endif
}
/*! \reimp
*/
int FlatStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm )
{
#ifndef QT_NO_MENUDATA
int h = 0;
if ( mi->isSeparator() ) // separator height
h = motifSepHeight;
else if ( mi->pixmap() ) // pixmap height
h = mi->pixmap()->height() + 2*motifItemFrame;
else // text height
h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1;
@@ -963,70 +1032,71 @@ void FlatStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int
int dim = (h-2*motifItemFrame) / 2;
if ( act ) {
if ( !dis )
discol = white;
QColorGroup g2( discol, g.highlight(),
white, white,
dis ? discol : white,
discol, white );
drawArrow( p, RightArrow, FALSE,
x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
dim, dim, g2, TRUE );
} else {
drawArrow( p, RightArrow,
FALSE,
x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
dim, dim, g, mi->isEnabled() );
}
}
#endif
}
void FlatStyle::getButtonShift( int &x, int &y )
{
x = 0; y = 0;
}
//===========================================================================
FlatStyleImpl::FlatStyleImpl()
: flat(0), ref(0)
{
}
FlatStyleImpl::~FlatStyleImpl()
{
// We do not delete the style because Qt does that when a new style
// is set.
}
QStyle *FlatStyleImpl::style()
{
if ( !flat )
flat = new FlatStyle();
return flat;
}
QString FlatStyleImpl::name() const
{
- return QString("Flat");
+ return qApp->translate("FlatStyle", "Flat", "Name of the style Flat");
}
QRESULT FlatStyleImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
{
*iface = 0;
if ( uuid == IID_QUnknown )
*iface = this;
else if ( uuid == IID_Style )
*iface = this;
+ else
+ return QS_FALSE;
- if ( *iface )
- (*iface)->addRef();
+ (*iface)->addRef();
return QS_OK;
}
Q_EXPORT_INTERFACE()
{
Q_CREATE_INSTANCE( FlatStyleImpl )
}
#include "flat.moc"
diff --git a/noncore/styles/flat/flat.h b/noncore/styles/flat/flat.h
index e446800..ebea95b 100644
--- a/noncore/styles/flat/flat.h
+++ b/noncore/styles/flat/flat.h
@@ -1,114 +1,118 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef FLATSTYLE_H
#define FLATSTYLE_H
+#include <qcolor.h>
#include <qwindowsstyle.h>
#include <qpe/styleinterface.h>
class FlatStylePrivate;
-class Q_EXPORT FlatStyle : public QWindowsStyle
+class FlatStyle : public QWindowsStyle
{
public:
FlatStyle();
virtual ~FlatStyle();
virtual void polish( QPalette &p );
virtual void polish( QWidget *w );
virtual void unPolish( QWidget *w );
int defaultFrameWidth () const;
void drawItem( QPainter *p, int x, int y, int w, int h,
int flags, const QColorGroup &g, bool enabled,
const QPixmap *pixmap, const QString& text, int len, const QColor* penColor );
void drawPanel ( QPainter * p, int x, int y, int w, int h,
const QColorGroup &, bool sunken=FALSE, int lineWidth = 1, const QBrush * fill = 0 );
void drawButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken, const QBrush* fill );
void drawButtonMask ( QPainter * p, int x, int y, int w, int h );
void drawBevelButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken=FALSE, const QBrush* fill=0 );
void drawToolButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken=FALSE, const QBrush* fill=0 );
void drawPushButton( QPushButton *btn, QPainter *p );
void drawPushButtonLabel( QPushButton *btn, QPainter *p );
QRect comboButtonRect( int x, int y, int w, int h);
QRect comboButtonFocusRect( int x, int y, int w, int h);
void drawComboButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken, bool, bool enabled,
const QBrush *fill );
void drawExclusiveIndicator ( QPainter * p, int x, int y, int w, int h,
const QColorGroup & g, bool on, bool down = FALSE, bool enabled = TRUE );
void drawIndicator ( QPainter * p, int x, int y, int w, int h,
const QColorGroup & g, int state, bool down = FALSE, bool enabled = TRUE );
void scrollBarMetrics( const QScrollBar*, int&, int&, int&, int&);
void drawScrollBarControls( QPainter*, const QScrollBar*, int sliderStart, uint controls, uint activeControl );
ScrollControl scrollBarPointOver( const QScrollBar* sb, int sliderStart, const QPoint& p );
void drawRiffles( QPainter* p, int x, int y, int w, int h,
const QColorGroup &g, bool horizontal );
int sliderLength() const;
void drawSlider( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, Orientation, bool tickAbove, bool tickBelow );
void drawSliderMask( QPainter *p, int x, int y, int w, int h,
Orientation, bool tickAbove, bool tickBelow );
void drawSliderGrooveMask( QPainter *p, int x, int y, int w, int h,
const QColorGroup& , QCOORD c, Orientation orient );
void drawSliderGroove ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, QCOORD c, Orientation );
void drawTab( QPainter *, const QTabBar *, QTab *, bool selected );
+ void polishPopupMenu ( QPopupMenu * );
int extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem*, const QFontMetrics& );
int popupMenuItemHeight( bool checkable, QMenuItem*, const QFontMetrics& );
void drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi,
const QPalette& pal,
bool act, bool enabled, int x, int y, int w, int h);
int buttonMargin() const;
QSize scrollBarExtent() const;
void getButtonShift( int &x, int &y );
private:
FlatStylePrivate *d;
bool revItem;
+ bool fillBtnBorder;
+ QColor btnBg;
// Disabled copy constructor and operator=
#if defined(Q_DISABLE_COPY)
FlatStyle( const FlatStyle & );
FlatStyle& operator=( const FlatStyle & );
#endif
};
class FlatStyleImpl : public StyleInterface
{
public:
FlatStyleImpl();
virtual ~FlatStyleImpl();
QRESULT queryInterface( const QUuid&, QUnknownInterface** );
Q_REFCOUNT
virtual QStyle *style();
virtual QString name() const;
private:
FlatStyle *flat;
ulong ref;
};
#endif // FLATSTYLE_H
diff --git a/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp b/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp
index 71dd7eb..73f8bb3 100644
--- a/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp
+++ b/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp
@@ -1,59 +1,60 @@
#include "inputDialog.h"
#include <qapplication.h>
#include <qlayout.h>
#include <qcheckbox.h>
#include <qlineedit.h>
#include <qvariant.h>
#include <qpushbutton.h>
#include <qwhatsthis.h>
#include <qlabel.h>
+#include <qlayout.h>
#include <qpe/config.h>
#include <qstringlist.h>
#include <qmainwindow.h>
#include "helpwindow.h"
#include <opie/oprocess.h>
#include <stdlib.h>
// #include <sys/stat.h>
// #include <unistd.h>
InputDialog::InputDialog( )
: QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) {
setCaption( tr("Symbol Lookup"));
QGridLayout *layout = new QGridLayout( this );
layout->setSpacing(6);
layout->setMargin( 2);
LineEdit1 = new QLineEdit( this, "LineEdit1" );
LineEdit1->setFocus();
layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 3);
QLabel *label;
label = new QLabel(this);
label->setText( tr("Enter something to lookup / search."));
label->setMaximumHeight(60);
layout->addMultiCellWidget( label, 1, 1, 0, 3);
connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(doLookup()));
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding );
layout->addItem( spacer, 8, 0 );
}
InputDialog::~InputDialog() {
}
void InputDialog::doLookup() {
// http://finance.yahoo.com/l?m=&s=siemens&t=
QString url = "\"http://finance.yahoo.com/l?m=&s="+LineEdit1->text()+"\"";
QString tempHtml = "/tmp/stockticker.html";
QString cmd = "wget -O "+tempHtml+" "+url;
qDebug(cmd);
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp
index d740b6f..915233a 100644
--- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp
@@ -76,97 +76,97 @@ StocktickerPluginConfig::StocktickerPluginConfig( QWidget *parent, const char*
layout->addMultiCellWidget( symbolCheck, 2, 2, 2, 2 );
QWhatsThis::add(symbolCheck, tr("Toggles Symbol field"));
nameCheck= new QCheckBox ( "Name", this );
nameCheck->setChecked( cfg.readBoolEntry("nameCheck",1));
layout->addMultiCellWidget( nameCheck, 3, 3, 0, 0 );
QWhatsThis::add(nameCheck, tr("Toggles Name of symbols owner field"));
currentPriceCheck= new QCheckBox ( "Price", this );
currentPriceCheck->setChecked( cfg.readBoolEntry("currentPriceCheck",1));
layout->addMultiCellWidget( currentPriceCheck, 3, 3, 1, 1 );
QWhatsThis::add(currentPriceCheck, tr("Toggles current Price field"));
lastPriceCheck= new QCheckBox ( "Last Price", this );
lastPriceCheck->setChecked( cfg.readBoolEntry("lastPriceCheck",1));
layout->addMultiCellWidget(lastPriceCheck, 3, 3, 2, 2);
QWhatsThis::add(lastPriceCheck, tr("Toggles last price field"));
openPriceCheck= new QCheckBox ( "Open Price", this);
openPriceCheck->setChecked( cfg.readBoolEntry("openPriceCheck",1));
layout->addMultiCellWidget( openPriceCheck, 4, 4, 0, 0 );
QWhatsThis::add(openPriceCheck, tr("Toggles opening price field"));
minPriceCheck= new QCheckBox ( "Min Price", this );
minPriceCheck->setChecked( cfg.readBoolEntry("minPriceCheck",1));
layout->addMultiCellWidget( minPriceCheck, 4, 4, 1, 1);
QWhatsThis::add(minPriceCheck, tr("Toggles minimum daily price field"));
maxPriceCheck= new QCheckBox ( "Max Price", this);
maxPriceCheck->setChecked( cfg.readBoolEntry("maxPriceCheck",1));
layout->addMultiCellWidget( maxPriceCheck, 4, 4, 2, 2 );
QWhatsThis::add(maxPriceCheck, tr("Toggles maximum daily price field"));
variationCheck= new QCheckBox ( "Variation", this );
variationCheck->setChecked( cfg.readBoolEntry("variationCheck",1));
layout->addMultiCellWidget( variationCheck, 5, 5, 0, 0 );
QWhatsThis::add(variationCheck, tr("Toggles daily variation of price field"));
volumeCheck= new QCheckBox ( "Volume", this );
volumeCheck->setChecked( cfg.readBoolEntry("volumeCheck",1));
layout->addMultiCellWidget( volumeCheck , 5, 5, 1, 1);
QWhatsThis::add(volumeCheck, tr("Toggles volume of trading field"));
timerDelaySpin = new QSpinBox( this, "timer spin" );
QWhatsThis::add( timerDelaySpin , tr( "How often stocks prices should be looked up. In minutes" ) );
timerDelaySpin->setMaxValue( 60);
cfg.setGroup("Timer");
- timerDelaySpin->setValue( cfg.readNumEntry("Delay",0));
+ timerDelaySpin->setValue( cfg.readNumEntry("Delay",15));
layout->addMultiCellWidget( timerDelaySpin , 6, 6, 0, 0);
QLabel *label2;
label2 = new QLabel(this);
label2->setText( tr("Minutes between lookups."));
label2->setMaximumHeight(60);
layout->addMultiCellWidget( label2, 6, 6, 1, 2);
scrollSpeed = new QSpinBox( this, "Scrollspin" );
QWhatsThis::add( timerDelaySpin , tr( "Speed of scrolling action, in milliseconds" ) );
scrollSpeed->setMaxValue( 1000);
scrollSpeed->setSteps(50,50);
cfg.setGroup("Timer");
scrollSpeed->setValue( cfg.readNumEntry("ScrollSpeed",50));
layout->addMultiCellWidget( scrollSpeed , 7, 7, 0, 0);
QLabel *label3;
label3 = new QLabel(this);
label3->setText( tr("Scroll Speed, in milliseconds"));
label3->setMaximumHeight(60);
layout->addMultiCellWidget( label3, 7, 7, 1, 2);
scrollLength = new QSpinBox( this, "ScrollLength" );
QWhatsThis::add( timerDelaySpin , tr( "Length of scrolling" ) );
scrollLength->setMaxValue( 10);
// scrollLength->setSteps(5,5);
cfg.setGroup("Timer");
scrollLength->setValue( cfg.readNumEntry("ScrollLength",1));
layout->addMultiCellWidget( scrollLength , 8, 8, 0, 0);
QLabel *label4;
label4 = new QLabel(this);
label4->setText( tr("Scroll Length"));
label4->setMaximumHeight(60);
layout->addMultiCellWidget( label4, 8, 8, 1, 2);
// lookupButton = new QPushButton(this, "LookupButton");
// lookupButton->setText(tr("Symbol Lookup"));
// connect(lookupButton,SIGNAL(clicked()),SLOT( doLookup()));
// layout->addMultiCellWidget( lookupButton , 9, 9, 0, 0);
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding );
layout->addItem( spacer, 9, 0 );
}
void StocktickerPluginConfig::writeConfig() {
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h
index 2b67a8b..10f9678 100644
--- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h
@@ -1,46 +1,46 @@
/*
* stocktickerconfig.h
*
* copyright : (c) 2002 by LJP
* email : llornkcor@handhelds.org
*
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef STOCKTICKER_PLUGIN_CONFIG_H
#define STOCKTICKER_PLUGIN_CONFIG_H
#include <qwidget.h>
#include <opie/todayconfigwidget.h>
#include <qstring.h>
class QLineEdit;
class QCheckBox;
class QPushButton;
class QCheckBox;
class QSpinBox;
class StocktickerPluginConfig : public TodayConfigWidget {
-//Q_OBJECT
+ Q_OBJECT
public:
StocktickerPluginConfig( QWidget *parent, const char *name );
~StocktickerPluginConfig();
QString text() const;
void writeConfig();
private:
QLineEdit* LineEdit1;
QCheckBox *timeCheck, *dateCheck, *symbolCheck, *nameCheck, *currentPriceCheck, *lastPriceCheck, *openPriceCheck, *minPriceCheck, *maxPriceCheck, *variationCheck, *volumeCheck;
QPushButton *lookupButton;
QSpinBox *timerDelaySpin, *scrollSpeed, *scrollLength;
private slots:
void doLookup();
};
#endif
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
index c3ca52d..fedc79c 100644
--- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
@@ -1,301 +1,327 @@
-/*
- * stocktickerpluginwidget.cpp
- *
- * copyright : (c) 2002 by L.J. Potter
- * email : llornkcor@handhelds.org
- *
- */
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include <qlayout.h>
-
-#include <qpe/config.h>
-
-#include <opie/oticker.h>
-
-extern "C" {
-#include "libstocks/stocks.h"
-}
-
-#include <pthread.h>
-
-#include "stocktickerpluginwidget.h"
-
-QString output;
-OTicker *stocktickerTicker;
+ /*
+ * stocktickerpluginwidget.cpp
+ *
+ * copyright : (c) 2002 by L.J. Potter
+ * email : llornkcor@handhelds.org
+ *
+ */
+ /***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+ #include <qlayout.h>
+
+ #include <qpe/config.h>
+
+ #include <opie/oticker.h>
+
+ extern "C" {
+ #include "libstocks/stocks.h"
+ }
+
+ #include <pthread.h>
+
+ #include "stocktickerpluginwidget.h"
+
+ QString output;
+ OTicker *stocktickerTicker;
+ QCString stock_liste;
+ bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck;
+ bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck;
+ bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck;
void getStocks(char *blah) {
-// stocktickerTicker->setText( "Downloading stock data.");
- stock *stocks_quotes=NULL;
- stock *stocks_tmp;
- QCString stock_liste = blah;
- ::free ( blah );
- // char *stock_liste = (char *)blah->latin1();
- qDebug("%s", stock_liste.data() );
- QString tempString;
- output = "";
-
- libstocks_return_code error;
-
- Config cfg( "stockticker");
- cfg.setGroup( "Fields" );
- bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck;
- bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck;
- bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck;
-
- dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false;
-
- dotimeCheck=cfg.readBoolEntry("timeCheck",1);
- dodateCheck=cfg.readBoolEntry("dateCheck",1);
- dosymbolCheck=cfg.readBoolEntry("symbolCheck",1);
- donameCheck=cfg.readBoolEntry("nameCheck",1);
- docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1);
- dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1);
- doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1);
- dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1);
- domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1);
- dovariationCheck=cfg.readBoolEntry("variationCheck",1);
- dovolumeCheck=cfg.readBoolEntry("volumeCheck",1);
-
-// DefProxy();
- {
- char *proxy;
- libstocks_return_code error;
-
- /* Proxy support */
- /* Checks for "http_proxy" environment variable */
- proxy = getenv("http_proxy");
- if(proxy) {
- /* printf("proxy set\n"); */
- error = set_proxy(proxy);
- if (error) {
- printf("Proxy error (%d)\n", error);
- QString tempString;
- tempString.sprintf("Proxy error (%d)\n", error);
- output = tempString;
- return;
-// exit(1);
- }
- }
- }
-// char *stock_liste = (char *)blah;
- /* Get the stocks and process errors */
- error = get_stocks( stock_liste.data(), &stocks_quotes);
-
- if (error) {
- printf("Error in getting stocks (%d)\n", error);
- tempString.sprintf("Error in getting stocks (%d)\n", error);
- output =tempString;
- return;
-// exit(1);
- }
-
- stocks_tmp = stocks_quotes;
-
- /* Displays the stocks */
- while(stocks_tmp!=0){
-
- if (stocks_tmp->Time) {
-// printf("%s ", stocks_tmp->Time);
- tempString.sprintf("| %s ", stocks_tmp->Time);
- tempString.replace(QRegExp("\""),"");
- if( dotimeCheck)
- output +=tempString;
- }
- if (stocks_tmp->Date) {
-// printf("%s ", stocks_tmp->Date);
- tempString.sprintf("| %s ", stocks_tmp->Date);
- tempString.replace(QRegExp("\""),"");
- if(dodateCheck)
- output +=tempString;
- }
-// printf("\n");
-
-// printf("----------------------------------------\n");
-
- if ( strlen(stocks_tmp->Symbol) > 20 ) {
-// printf("| Symbol | %.20s |\n",stocks_tmp->Symbol);
- tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol);
- if(dosymbolCheck)
- output +=tempString;
- }
- else {
-// printf("| Symbol | %-20s |\n",stocks_tmp->Symbol);
- tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol);
- if(dosymbolCheck)
- output +=tempString;
- }
-
- if (stocks_tmp->Name) {
- if ( strlen(stocks_tmp->Name) > 20 ) {
-// printf("| Name %.20s |\n",stocks_tmp->Name);
- tempString.sprintf("| Name %s ",stocks_tmp->Name);
- tempString.stripWhiteSpace();
- if(donameCheck)
- output +=tempString;
- } else {
-// printf("| Name | %-20s |\n",stocks_tmp->Name);
- tempString.sprintf("| Name %s ",stocks_tmp->Name);
- tempString.stripWhiteSpace();
- if(donameCheck)
- output +=tempString;
- }
- }
- else {
-// printf("| Name | |\n");
- tempString.sprintf("| Name | |");
- if(donameCheck)
- output +=tempString;
- }
-
-// printf("| Price | %-7.2f |\n", stocks_tmp->CurrentPrice);
- tempString.sprintf("| Price %-7.2f ", stocks_tmp->CurrentPrice);
- if(docurrentPriceCheck)
- output +=tempString;
-
-// printf("| Yesterday | %-7.2f |\n",stocks_tmp->LastPrice);
- tempString.sprintf("| Yesterday %-7.2f ",stocks_tmp->LastPrice);
- if(dolastPriceCheck)
- output +=tempString;
-
-// printf("| Open | %-7.2f |\n",stocks_tmp->OpenPrice);
- tempString.sprintf("| Open %-7.2f ",stocks_tmp->OpenPrice);
- if(doopenPriceCheck)
- output +=tempString;
-
-// printf("| Min | %-7.2f |\n", stocks_tmp->MinPrice);
- tempString.sprintf("| Min %-7.2f ", stocks_tmp->MinPrice);
- if(dominPriceCheck)
- output +=tempString;
-
-// printf("| Max | %-7.2f |\n",stocks_tmp->MaxPrice);
- tempString.sprintf("| Max %-7.2f ",stocks_tmp->MaxPrice);
- if(domaxPriceCheck)
- output +=tempString;
-
-// printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage);
- tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage);
- if(dovariationCheck)
- output +=tempString;
-
-// printf("| Volume | %-9d |\n", stocks_tmp->Volume);
- tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume);
- if(dovolumeCheck)
- output +=tempString;
-
-// printf("----------------------------------------\n\n");
- tempString.sprintf("||==++==|");
- output +=tempString;
-
- /* Simple function which help to browse in the stocks list */
- stocks_tmp = next_stock(stocks_tmp);
- }
-
- /* frees stocks */
- free_stocks(stocks_quotes);
- stocktickerTicker->setText( output.latin1() );
-
-}
-
-StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name)
- : QWidget(parent, name ) {
- init();
- startTimer(1000);
-
- stocktickerTicker->setTextFormat(Qt::RichText);
-// checkConnection();
-}
-
-StockTickerPluginWidget::~StockTickerPluginWidget() {
-}
-
-void StockTickerPluginWidget::init() {
-
- QHBoxLayout* layout = new QHBoxLayout( this );
- stocktickerTicker = new OTicker(this);
-// stocktickerTicker->setMinimumHeight(15);
- connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( checkConnection() ));
- layout->addWidget( stocktickerTicker);
- wasError = true;
-}
-
-void StockTickerPluginWidget::doStocks() {
- Config cfg( "stockticker");
- cfg.setGroup( "Symbols" );
- symbollist="";
- symbollist = cfg.readEntry("Symbols", "");
- symbollist.replace(QRegExp(" "),"+");//seperated by +
-
- cfg.setGroup("Timer");
- stocktickerTicker->setUpdateTime( cfg.readNumEntry("ScrollSpeed",50));
- stocktickerTicker->setScrollLength( cfg.readNumEntry("ScrollLength",10));
-
- if (!symbollist.isEmpty()) {
- pthread_t thread1;
- char *blah = ::strdup(symbollist.latin1());
- pthread_create(&thread1,NULL, (void * (*)(void *))getStocks, (void *) blah);
- }
-}
-
-void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) {
- killTimer(e->timerId());
- checkConnection();
-}
-
-void StockTickerPluginWidget::checkConnection() {
-// qDebug("checking connection");
-// Sock = new QSocket( this );
-
-// if( wasError)
-// stocktickerTicker->setText("Checking connection");
-
-// if(Sock->state() == QSocket::Idle) {
-// Sock->connectToHost("finance.yahoo.com", 80);
-// connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) );
-// connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) );
-// } else {
-// qDebug("State is not Idle");
- isConnected();
-// }
-}
-
-void StockTickerPluginWidget::isConnected() {
-// qDebug("We connect, so ok to grab stocks");
- doStocks();
-
- Config cfg( "stockticker");
- cfg.setGroup("Timer");
- timerDelay= cfg.readNumEntry("Delay",0);
- if(timerDelay > 0)
- startTimer(timerDelay*60000);
- qDebug("timer set for %d",(timerDelay*60000)/60000);
- wasError = false;
-
-// Sock->close();
-}
-
-void StockTickerPluginWidget::socketError(int errcode) {
- switch(errcode) {
- case QSocket::ErrConnectionRefused:
- output = tr("Connection refused.");
- break;
- case QSocket::ErrHostNotFound:
- output = tr("Could not find server.");
- break;
- case QSocket::ErrSocketRead :
- output = tr("Socket read error.");
- break;
- };
- stocktickerTicker->setText( output );
- wasError = true;
-// Sock->close();
-
-}
+ // stocktickerTicker->setText( "Downloading stock data.");
+ stock *stocks_quotes=NULL;
+ stock *stocks_tmp;
+ stock_liste = blah;
+ ::free ( blah );
+ // char *stock_liste = (char *)blah->latin1();
+ // qDebug("%s", stock_liste.data() );
+ output = "";
+ QString tempString;
+ libstocks_return_code error;
+
+// Config cfg( "stockticker");
+// cfg.setGroup( "Fields" );
+// bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck;
+// bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck;
+// bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck;
+
+ dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false;
+
+ dotimeCheck=1;
+ dodateCheck=1;
+ dosymbolCheck=1;
+ donameCheck=1;
+ docurrentPriceCheck=1;
+ dolastPriceCheck=1;
+ doopenPriceCheck=1;
+ dominPriceCheck=1;
+ domaxPriceCheck=1;
+ dovariationCheck=1;
+ dovolumeCheck=1;
+
+// dotimeCheck=cfg.readBoolEntry("timeCheck",1);
+// dodateCheck=cfg.readBoolEntry("dateCheck",1);
+// dosymbolCheck=cfg.readBoolEntry("symbolCheck",1);
+// donameCheck=cfg.readBoolEntry("nameCheck",1);
+// docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1);
+// dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1);
+// doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1);
+// dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1);
+// domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1);
+// dovariationCheck=cfg.readBoolEntry("variationCheck",1);
+// dovolumeCheck=cfg.readBoolEntry("volumeCheck",1);
+
+ // DefProxy();
+ // {
+ char *proxy;
+ // libstocks_return_code error;
+
+ /* Proxy support */
+ /* Checks for "http_proxy" environment variable */
+ proxy = getenv("http_proxy");
+ if(proxy) {
+ /* printf("proxy set\n"); */
+ error = set_proxy(proxy);
+ if (error) {
+// printf("Proxy error (%d)\n", error);
+// QString tempString2;
+// tempString2.sprintf("Proxy error (%d)\n", error);
+// output = tempString2;
+ // delete tempString2;
+ return;
+ // exit(1);
+ }
+ }
+ ::free(proxy);
+ // }
+ /* Get the stocks and process errors */
+ error = get_stocks( stock_liste.data(), &stocks_quotes);
+
+ if (error) {
+ printf("Error in getting stocks (%d)\n", error);
+ tempString.sprintf("Error in getting stocks (%d)\n", error);
+ output =tempString;
+ return;
+ }
+
+ stocks_tmp = stocks_quotes;
+
+ /* Displays the stocks */
+ while(stocks_tmp!=0){
+
+ if (stocks_tmp->Time) {
+ // printf("%s ", stocks_tmp->Time);
+ tempString.sprintf("| %s ", stocks_tmp->Time);
+ tempString.replace(QRegExp("\""),"");
+ if( dotimeCheck)
+ output +=tempString;
+ }
+ if (stocks_tmp->Date) {
+ // printf("%s ", stocks_tmp->Date);
+ tempString.sprintf("| %s ", stocks_tmp->Date);
+ tempString.replace(QRegExp("\""),"");
+ if(dodateCheck)
+ output +=tempString;
+ }
+ // printf("\n");
+
+ // printf("----------------------------------------\n");
+
+ if ( strlen(stocks_tmp->Symbol) > 20 ) {
+ // printf("| Symbol | %.20s |\n",stocks_tmp->Symbol);
+ tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol);
+ if(dosymbolCheck)
+ output +=tempString;
+ }
+ else {
+ // printf("| Symbol | %-20s |\n",stocks_tmp->Symbol);
+ tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol);
+ if(dosymbolCheck)
+ output +=tempString;
+ }
+
+ if (stocks_tmp->Name) {
+ if ( strlen(stocks_tmp->Name) > 20 ) {
+ // printf("| Name %.20s |\n",stocks_tmp->Name);
+ tempString.sprintf("| Name %s ",stocks_tmp->Name);
+ tempString.stripWhiteSpace();
+ if(donameCheck)
+ output +=tempString;
+ } else {
+ // printf("| Name | %-20s |\n",stocks_tmp->Name);
+ tempString.sprintf("| Name %s ",stocks_tmp->Name);
+ tempString.stripWhiteSpace();
+ if(donameCheck)
+ output +=tempString;
+ }
+ }
+ else {
+ // printf("| Name | |\n");
+ tempString.sprintf("| Name | |");
+ if(donameCheck)
+ output +=tempString;
+ }
+
+ // printf("| Price | %-7.2f |\n", stocks_tmp->CurrentPrice);
+ tempString.sprintf("| Price %-7.2f ", stocks_tmp->CurrentPrice);
+ if(docurrentPriceCheck)
+ output +=tempString;
+
+ // printf("| Yesterday | %-7.2f |\n",stocks_tmp->LastPrice);
+ tempString.sprintf("| Yesterday %-7.2f ",stocks_tmp->LastPrice);
+ if(dolastPriceCheck)
+ output +=tempString;
+
+ // printf("| Open | %-7.2f |\n",stocks_tmp->OpenPrice);
+ tempString.sprintf("| Open %-7.2f ",stocks_tmp->OpenPrice);
+ if(doopenPriceCheck)
+ output +=tempString;
+
+ // printf("| Min | %-7.2f |\n", stocks_tmp->MinPrice);
+ tempString.sprintf("| Min %-7.2f ", stocks_tmp->MinPrice);
+ if(dominPriceCheck)
+ output +=tempString;
+
+ // printf("| Max | %-7.2f |\n",stocks_tmp->MaxPrice);
+ tempString.sprintf("| Max %-7.2f ",stocks_tmp->MaxPrice);
+ if(domaxPriceCheck)
+ output +=tempString;
+
+ // printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage);
+ tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage);
+ if(dovariationCheck)
+ output +=tempString;
+
+ // printf("| Volume | %-9d |\n", stocks_tmp->Volume);
+ tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume);
+ if(dovolumeCheck)
+ output +=tempString;
+
+ // printf("----------------------------------------\n\n");
+ tempString.sprintf("||==++==|");
+ output +=tempString;
+
+ /* Simple function which help to browse in the stocks list */
+ stocks_tmp = next_stock(stocks_tmp);
+ }
+
+ stocktickerTicker->setText( output.latin1() );
+
+ /* frees stocks */
+ free_stocks(stocks_quotes);
+ free_stocks(stocks_tmp);
+
+ stock_liste="";
+ //delete stock_liste;
+ tempString="";
+ output="";
+ }
+
+ StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name)
+ : QWidget(parent, name ) {
+ init();
+ startTimer(1000);
+
+ stocktickerTicker->setTextFormat(Qt::RichText);
+ // checkConnection();
+ }
+
+ StockTickerPluginWidget::~StockTickerPluginWidget() {
+ }
+
+ void StockTickerPluginWidget::init() {
+
+ QHBoxLayout* layout = new QHBoxLayout( this );
+ stocktickerTicker = new OTicker(this);
+ // stocktickerTicker->setMinimumHeight(15);
+ connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( checkConnection() ));
+ layout->addWidget( stocktickerTicker);
+ wasError = true;
+ }
+
+ void StockTickerPluginWidget::doStocks() {
+ Config cfg( "stockticker");
+ cfg.setGroup( "Symbols" );
+ symbollist="";
+ symbollist = cfg.readEntry("Symbols", "");
+ symbollist.replace(QRegExp(" "),"+");//seperated by +
+
+ cfg.setGroup("Timer");
+ stocktickerTicker->setUpdateTime( cfg.readNumEntry("ScrollSpeed",50));
+ stocktickerTicker->setScrollLength( cfg.readNumEntry("ScrollLength",10));
+
+ if (!symbollist.isEmpty()) {
+ pthread_t thread1;
+ char *blah = ::strdup(symbollist.latin1());
+ pthread_create( &thread1, NULL, (void * (*)(void *))getStocks, (void *) blah);
+ pthread_detach( thread1);
+
+ //::free((void*)thread1);
+ //getStocks(blah);
+ }
+ }
+
+ void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) {
+ killTimer(e->timerId());
+ checkConnection();
+ }
+
+ void StockTickerPluginWidget::checkConnection() {
+ // qDebug("checking connection");
+ // Sock = new QSocket( this );
+
+ // if( wasError)
+ // stocktickerTicker->setText("Checking connection");
+
+ // if(Sock->state() == QSocket::Idle) {
+ // Sock->connectToHost("finance.yahoo.com", 80);
+ // connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) );
+ // connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) );
+ // } else {
+ // qDebug("State is not Idle");
+ isConnected();
+ // }
+ }
+
+ void StockTickerPluginWidget::isConnected() {
+ // qDebug("We connect, so ok to grab stocks");
+ if(this->isVisible())
+ doStocks();
+
+ Config cfg( "stockticker");
+ cfg.setGroup("Timer");
+ timerDelay= cfg.readNumEntry("Delay",0);
+ if(timerDelay > 0)
+ startTimer(timerDelay*60000);
+ // qDebug("timer set for %d",(timerDelay*60000)/60000);
+ wasError = false;
+
+ // Sock->close();
+ }
+
+ void StockTickerPluginWidget::socketError(int errcode) {
+ switch(errcode) {
+ case QSocket::ErrConnectionRefused:
+ output = tr("Connection refused.");
+ break;
+ case QSocket::ErrHostNotFound:
+ output = tr("Could not find server.");
+ break;
+ case QSocket::ErrSocketRead :
+ output = tr("Socket read error.");
+ break;
+ };
+ stocktickerTicker->setText( output );
+ wasError = true;
+ // Sock->close();
+
+ }
diff --git a/noncore/todayplugins/weather/weatherconfig.h b/noncore/todayplugins/weather/weatherconfig.h
index 3877818..d9ffec2 100644
--- a/noncore/todayplugins/weather/weatherconfig.h
+++ b/noncore/todayplugins/weather/weatherconfig.h
@@ -1,59 +1,60 @@
/*
                This file is part of the OPIE Project
=.
             .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
           .>+-=
 _;:,     .>    :=|. This file is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This file is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
..}^=.=       =       ; Public License for more details.
++=   -.     .`     .:
 :     =  ...= . :.=- You should have received a copy of the GNU
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef WEATHER_PLUGIN_CONFIG_H
#define WEATHER_PLUGIN_CONFIG_H
#include <qstring.h>
#include <qwidget.h>
#include <opie/todayconfigwidget.h>
class QCheckBox;
class QLineEdit;
class QPushButton;
class QSpinBox;
class WeatherPluginConfig : public TodayConfigWidget
{
+ Q_OBJECT
public:
WeatherPluginConfig( QWidget *parent, const char *name );
~WeatherPluginConfig();
void writeConfig();
private:
QLineEdit *locationEdit;
QCheckBox *metricCB;
QSpinBox *timerDelaySB;
private slots:
void doLookup();
//void slotCopyLink();
};
#endif
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp
index 41c99a8..ecbf12f 100644
--- a/noncore/tools/clock/clock.cpp
+++ b/noncore/tools/clock/clock.cpp
@@ -388,116 +388,117 @@ void Clock::slotSnooze()
int warn = 0;
QTime t = QTime::currentTime();
QDateTime whenl( when.date(), t.addSecs( snoozeTime * 60 ) );
when = whenl;
AlarmServer::addAlarm( when,
"QPE/Application/clock",
"alarm(QDateTime,int)", warn );
}
//toggles alarm on/off
void Clock::slotToggleAlarm()
{
Config config( "qpe" );
config.setGroup( "Time" );
if ( alarmBool )
{
config.writeEntry( "clockAlarmSet", "FALSE" );
alarmOffBtn->setText( tr( "Alarm Is Off" ) );
snoozeBtn->hide();
alarmBool = FALSE;
alarmOff();
}
else
{
config.writeEntry( "clockAlarmSet", "TRUE" );
alarmOffBtn->setText( tr( "Alarm Is On" ) );
snoozeBtn->show();
alarmBool = TRUE;
alarmOn();
}
config.write();
}
void Clock::alarmOn()
{
QDate d = QDate::currentDate();
QTime tm( ( int ) hour, ( int ) minute, 0 );
qDebug( "Time set " + tm.toString() );
QTime t = QTime::currentTime();
if ( t > tm )
d = d.addDays( 1 );
int warn = 0;
QDateTime whenl( d, tm );
when = whenl;
AlarmServer::addAlarm( when,
"QPE/Application/clock",
"alarm(QDateTime,int)", warn );
- setCaption( "Alarm set: " + whenl.toString() );
+// setCaption( "Alarm set: " + whenl.toString() );
+ setCaption( tr("Alarm set: %1" ).arg(whenl.toString()) );
}
void Clock::alarmOff()
{
int warn = 0;
bSound = FALSE;
AlarmServer::deleteAlarm( when,
"QPE/Application/clock",
"alarm(QDateTime,int)", warn );
qDebug( "Alarm Off " + when.toString() );
- setCaption( "Clock" );
+ setCaption( tr("Clock") );
}
void Clock::clearTimer()
{
alarmOffBtn->setText( tr( "Alarm Is Off" ) );
alarmBool = FALSE;
snoozeBtn->hide();
- setCaption( "Clock" );
+ setCaption( tr("Clock") );
}
void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ )
{
int stopTimer = 0;
int timerStay = 5000;
bSound = TRUE;
qDebug( "Message received in clock" );
if ( msg == "alarm(QDateTime,int)" )
{
Config config( "qpe" );
config.setGroup( "Time" );
if ( config.readBoolEntry( "mp3Alarm", 0 ) )
{
clearTimer();
pthread_t thread;
pthread_create(&thread, NULL, (void * (*) (void *))startPlayer, NULL/* &*/);
}
else
{
Sound::soundAlarm();
stopTimer = startTimer( timerStay );
}
}
if ( msg == "timerStart()" )
{
slotStartTimer();
}
if ( msg == "timerStop()" )
{
slotStopTimer();
}
if ( msg == "timerReset()" )
{
slotResetTimer();
}
show();
raise();
QPEApplication::setKeepRunning();
setActiveWindow();
}
void Clock::timerEvent( QTimerEvent *e )
{
diff --git a/noncore/tools/euroconv/main.cpp b/noncore/tools/euroconv/main.cpp
index 2d97f4e..7d69535 100644
--- a/noncore/tools/euroconv/main.cpp
+++ b/noncore/tools/euroconv/main.cpp
@@ -1,39 +1,39 @@
/****************************************************************************
*
* File: main.cpp
*
* Description: main file for OPIE Euroconv aapp
*
*
* Authors: Eric Santonacci <Eric.Santonacci@talc.fr>
*
* Requirements: Qt
*
* $Id$
*
***************************************************************************/
#include <qpe/qpeapplication.h>
#include <qvbox.h>
//#include <qapplication.h>
#include "calcdisplay.h"
#include "calckeypad.h"
int main( int argc, char **argv ) {
QPEApplication app( argc, argv );
QVBox *layout = new QVBox(0, "fond");
LCDDisplay lcd (layout, "lcd");
KeyPad num(&lcd, layout, "keypad");
app.setMainWidget(layout);
- layout->setCaption("Euroconv");
+ layout->setCaption( QObject::tr("Euroconv") );
layout->showMaximized ();
layout->show();
return app.exec();
}
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp
index 21de4d2..49f6355 100644
--- a/noncore/tools/formatter/formatter.cpp
+++ b/noncore/tools/formatter/formatter.cpp
@@ -355,97 +355,98 @@ void FormatterApp::storageComboSelected(int index ) {
TextLabel4->setText( tr( "Storage Type: %1").arg( nameS) );
currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4);
QString fsType = getFileSystemType((const QString &) currentText);
// qDebug(fsType);
for(int i = 0; i < fileSystemsCombo->count(); i++) {
if( fsType == fileSystemsCombo->text(i))
fileSystemsCombo->setCurrentItem(i);
}
// deviceComboSelected(index);
}
void FormatterApp::deviceComboSelected(int index) {
StorageInfo storageInfo;
QString totalS, usedS, avS, diskS, nameS, fsType, selectedText;
selectedText = deviceComboBox->text(index);
const QList<FileSystem> &fs = storageInfo.fileSystems();
QListIterator<FileSystem> it ( fs );
QString storage;
for( ; it.current(); ++it ){
const QString name = (*it)->name();
const QString path = (*it)->path();
const QString disk = (*it)->disk();
// const QString options = (*it)->options();
if( selectedText == disk) {
diskS = disk; nameS= name;
mountPointLineEdit->setText(path);
long mult = (*it)->blockSize() / 1024;
long div = 1024 / (*it)->blockSize();
if ( !mult ) mult = 1;
if ( !div ) div = 1;
long total = (*it)->totalBlocks() * mult / div;
long totalMb = total/1024;
long avail = (*it)->availBlocks() * mult / div;
long availMb = avail/1024;
long used = total - avail;
long usedMb = used/1024;
totalS.sprintf(tr("Total: %1 kB ( %d mB)\n").arg( total ), totalMb );
usedS.sprintf(tr("Used: %1 kB ( %d mB)\n").arg(used) ,usedMb);
avS.sprintf( tr("Available: %1 kB ( %d mB)").arg(avail), availMb );
}
}
fsType = getFileSystemType((const QString &)selectedText);
- TextLabel5->setText(tr("Type: %1\nFormatted with %1\n%1, %1, %1").arg( nameS).arg( fsType).arg(totalS).arg( usedS).arg( avS ));
+ TextLabel5->setText(tr("Type: %1\nFormatted with %2\n%3, %4, %5").arg( nameS).arg( fsType).arg(totalS).arg( usedS).arg( avS ));
+ TextLabel5->setTextFormat( Qt::RichText );
// storageComboSelected(0);
}
void FormatterApp::cleanUp() {
}
void FormatterApp::editFstab() {
QCopEnvelope e("QPE/Application/textedit","setDocument(QString)");
e << (const QString &)"/etc/fstab";
}
void FormatterApp::parsetab(const QString &fileName) {
fileSystemTypeList.clear();
fsList.clear();
struct mntent *me;
// if(fileName == "/etc/mtab") {
FILE *mntfp = setmntent( fileName.latin1(), "r" );
if ( mntfp ) {
while ( (me = getmntent( mntfp )) != 0 ) {
QString deviceName = me->mnt_fsname;
QString filesystemType = me->mnt_type;
if(deviceName != "none") {
if( fsList.contains(filesystemType) == 0
& filesystemType.find("proc",0,TRUE) == -1
& filesystemType.find("cramfs",0,TRUE) == -1
& filesystemType.find("auto",0,TRUE) == -1)
fsList << filesystemType;
deviceList << deviceName;
qDebug(deviceName+"::"+filesystemType);
fileSystemTypeList << deviceName+"::"+filesystemType;
}
}
}
endmntent( mntfp );
// } else if(fileName == "/etc/fstab") {
// QFile f("/etc/fstab");
// if ( f.open(IO_ReadOnly) ) {
// QTextStream t (&f);
// QString s;
// while (! t.eof()) {
// s=t.readLine();
// s=s.simplifyWhiteSpace();
// if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) {
// // = me->mnt_fsname;
// QString filesystemType = me->mnt_type;