summaryrefslogtreecommitdiff
path: root/noncore/settings
Side-by-side diff
Diffstat (limited to 'noncore/settings') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/appearance2/appearance.cpp24
-rw-r--r--noncore/settings/appearance2/sample.cpp4
-rw-r--r--noncore/settings/aqpkg/inputdlg.cpp4
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp8
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp10
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp26
-rw-r--r--noncore/settings/aqpkg/settingsimpl.cpp4
-rw-r--r--noncore/settings/backup/backuprestore.cpp4
-rw-r--r--noncore/settings/netsystemtime/mainwindow.cpp14
-rw-r--r--noncore/settings/netsystemtime/settingstabwidget.cpp4
-rw-r--r--noncore/settings/netsystemtime/timetabwidget.cpp2
-rw-r--r--noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp4
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp14
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp8
-rw-r--r--noncore/settings/networksettings/ppp/general.cpp4
-rw-r--r--noncore/settings/networksettings/ppp/kpppwidget.cpp12
-rw-r--r--noncore/settings/networksettings/ppp/pppdargs.cpp4
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.cpp2
-rw-r--r--noncore/settings/packagemanager/filterdlg.cpp2
-rw-r--r--noncore/settings/packagemanager/mainwindow.cpp8
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp16
-rw-r--r--noncore/settings/sound/soundsettings.cpp20
-rw-r--r--noncore/settings/sysinfo/benchmarkinfo.cpp2
-rw-r--r--noncore/settings/sysinfo/modulesinfo.cpp4
-rw-r--r--noncore/settings/sysinfo/processinfo.cpp4
-rw-r--r--noncore/settings/tabmanager/tabmanager.cpp4
-rw-r--r--noncore/settings/usermanager/usermanager.cpp2
27 files changed, 107 insertions, 107 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp
index b39203b..8ae87fe 100644
--- a/noncore/settings/appearance2/appearance.cpp
+++ b/noncore/settings/appearance2/appearance.cpp
@@ -1,682 +1,682 @@
/*
                This file is part of the OPIE Project
Copyright (c) 2002 Trolltech AS <info@trolltech.com>
=. Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.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.
*/
#include "appearance.h"
#include "editScheme.h"
#include "stylelistitem.h"
#include "decolistitem.h"
#include "colorlistitem.h"
#include "exceptlistitem.h"
#include "sample.h"
/* OPIE */
#include <opie2/odevice.h>
#include <opie2/ofiledialog.h>
#include <opie2/otabwidget.h>
#include <qpe/config.h>
#include <qpe/global.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpemessagebox.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpestyle.h>
#include <qpe/lightstyle.h>
#include <qpe/styleinterface.h>
/* QT */
#include <qbuttongroup.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qdialog.h>
#include <qdir.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qlistbox.h>
#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>
using namespace Opie;
class DefaultWindowDecoration : public WindowDecorationInterface
{
public:
DefaultWindowDecoration() : ref(0) {}
QString name() const
{
return "Default";
}
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 ( )));
+ 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 ) ) );
+ 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", "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 ) ) );
+ 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 & )),
- this, SLOT( fontClicked ( const QFont & )));
+ connect( m_fontselect, SIGNAL( fontSelected(const QFont&)),
+ this, SLOT( fontClicked(const QFont&)));
return m_fontselect;
}
QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg )
{
QWidget *tab = new QWidget( parent, "ColorTab" );
QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 );
gridLayout->setRowStretch ( 3, 10 );
m_color_list = new QListBox ( tab );
gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 );
- connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) );
+ connect( m_color_list, SIGNAL( highlighted(int) ), this, SLOT( colorClicked(int) ) );
QWhatsThis::add( m_color_list, tr( "Color schemes are a collection of colors which are used for various parts of the display.\n\nClick here to select an available scheme." ) );
m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg ));
QString path = QPEApplication::qpeDir ( );
path.append( "/etc/colors/" );
QStringList sl = QDir ( path ). entryList ( "*.scheme" );
for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
{
QString name = (*it). left ((*it). find ( ".scheme" ));
QString pathstr = path;
pathstr.append( *it );
Config config ( pathstr, Config::File );
config. setGroup ( "Colors" );
m_color_list-> insertItem ( new ColorListItem ( name, config ));
}
m_color_list-> setCurrentItem ( 0 );
QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" );
tempButton->setText( tr( "Edit..." ) );
connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) );
gridLayout->addWidget( tempButton, 0, 1 );
QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) );
tempButton = new QPushButton( tab, "deleteSchemeButton" );
tempButton->setText( tr( "Delete" ) );
connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) );
gridLayout->addWidget( tempButton, 1, 1 );
QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) );
tempButton = new QPushButton( tab, "saveSchemeButton" );
tempButton->setText( tr( "Save" ) );
connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) );
gridLayout->addWidget( tempButton, 2, 1 );
QWhatsThis::add( tempButton, tr( "Click here to name and save the current color scheme." ) );
return tab;
}
QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg )
{
QWidget *tab = new QWidget ( parent );
QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 );
QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 );
m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab );
m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" ));
lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 );
QWhatsThis::add( m_force, tr( "Click here to allow all applications to use global appearance settings." ) );
QLabel *l = new QLabel ( tab );
l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" )));
lay-> addMultiCellWidget ( l, 1, 1, 0, 1 );
QWhatsThis::add( l, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) );
m_except = new QListView ( tab );
m_except-> addColumn ( Resource::loadIconSet ( "appearance" ), "", 24 );
m_except-> addColumn ( Resource::loadIconSet ( "font" ), "", 24 );
m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco" ), "", 24 );
m_except-> addColumn ( tr( "Binary file(s)" ));
m_except-> setColumnAlignment ( 0, AlignCenter );
m_except-> setColumnAlignment ( 1, AlignCenter );
m_except-> setColumnAlignment ( 2, AlignCenter );
m_except-> setAllColumnsShowFocus ( true );
m_except-> setMinimumHeight ( 30 );
m_except-> header ( )-> setClickEnabled ( false );
m_except-> header ( )-> setResizeEnabled ( false );
m_except-> header ( )-> setMovingEnabled ( false );
m_except-> setSorting ( -1 );
lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 );
QWhatsThis::add( m_except, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) );
- connect ( m_except, SIGNAL( clicked ( QListViewItem *, const QPoint &, int )), this, SLOT( clickedExcept ( QListViewItem *, const QPoint &, int )));
+ connect ( m_except, SIGNAL( clicked(QListViewItem*,const QPoint&,int)), this, SLOT( clickedExcept(QListViewItem*,const QPoint&,int)));
QToolButton *tb = new QToolButton ( tab );
tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" ));
tb-> setFocusPolicy ( QWidget::StrongFocus );
lay-> addWidget ( tb, 2, 1 );
- connect ( tb, SIGNAL( clicked ( )), this, SLOT( addExcept ( )));
+ connect ( tb, SIGNAL( clicked()), this, SLOT( addExcept()));
QWhatsThis::add( tb, tr( "Click here to add an application to the list above." ) );
tb = new QToolButton ( tab );
tb-> setIconSet ( Resource::loadIconSet ( "editdelete" ));
tb-> setFocusPolicy ( QWidget::StrongFocus );
lay-> addWidget ( tb, 3, 1 );
- connect ( tb, SIGNAL( clicked ( )), this, SLOT( delExcept ( )));
+ connect ( tb, SIGNAL( clicked()), this, SLOT( delExcept()));
QWhatsThis::add( tb, tr( "Click here to delete the currently selected application." ) );
tb = new QToolButton ( tab );
tb-> setIconSet ( Resource::loadIconSet ( "up" ));
tb-> setFocusPolicy ( QWidget::StrongFocus );
lay-> addWidget ( tb, 4, 1 );
- connect ( tb, SIGNAL( clicked ( )), this, SLOT( upExcept ( )));
+ connect ( tb, SIGNAL( clicked()), this, SLOT( upExcept()));
QWhatsThis::add( tb, tr( "Click here to move the currently selected application up in the list." ) );
tb = new QToolButton ( tab );
tb-> setIconSet ( Resource::loadIconSet ( "down" ));
tb-> setFocusPolicy ( QWidget::StrongFocus );
lay-> addWidget ( tb, 5, 1 );
- connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( )));
+ connect ( tb, SIGNAL( clicked()), this, SLOT( downExcept()));
QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) );
lay-> setRowStretch ( 6, 10 );
lay-> setColStretch ( 0, 10 );
QStringList sl = cfg. readListEntry ( "NoStyle", ';' );
QListViewItem *lvit = 0;
for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
{
int fl = ( *it ). left ( 1 ). toInt ( 0, 32 );
lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 );
}
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 );
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 ( ) );
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 * )));
+ 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 ( ));
}
if ( m_deco_changed )
{
DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( ));
if ( item )
config.writeEntry( "Decoration", item-> key ( ));
}
if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos ))
{
config. writeEntry ( "TabStyle", newtabstyle + 1 );
config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" );
}
if ( m_font_changed )
{
config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( ));
config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( ));
config. writeEntry ( "FontSize", m_fontselect-> fontSize ( ));
}
if ( m_color_changed )
{
ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
if ( item )
item-> save ( config );
}
ODirection rot;
if (m_rotdir_ccw-> isChecked ( ))
{
rot = CCW;
}
else if (m_rotdir_cw-> isChecked ( ))
{
rot = CW;
}
else
{
rot = Flip;
}
config. writeEntry ( "rotatedir", (int)rot );
m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated
QStringList sl;
QString exceptstr;
for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( ))
{
int fl = 0;
fl |= ( it-> noStyle ( ) ? 0x01 : 0 );
fl |= ( it-> noFont ( ) ? 0x02 : 0 );
fl |= ( it-> noDeco ( ) ? 0x04 : 0 );
exceptstr = QString::number ( fl, 32 );
exceptstr.append( it-> pattern ( ));
sl << exceptstr;
}
config. writeEntry ( "NoStyle", sl, ';' );
config. writeEntry ( "ForceStyle", m_force-> isChecked ( ));
config. write ( ); // need to flush the config info first
Global::applyStyle ( );
QDialog::accept ( );
}
void Appearance::done ( int r )
{
QDialog::done ( r );
close ( );
}
void Appearance::styleClicked ( int index )
{
StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index );
m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false );
if ( m_sample && sli && sli-> style ( ))
{
int ci = m_color_list ? m_color_list-> currentItem ( ) : -1;
m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( ));
}
m_style_changed |= ( index != m_original_style );
}
void Appearance::styleSettingsClicked ( )
{
StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( ));
if ( item && item-> hasSettings ( ))
{
QDialog *d = new QDialog ( this, "SETTINGS-DLG", true );
QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 );
QWidget *w = item-> settings ( d );
if ( w )
{
vbox-> addWidget ( w );
d-> setCaption ( w-> caption ( ));
bool accepted = ( QPEApplication::execDialog ( d ) == QDialog::Accepted );
if ( item-> setSettings ( accepted ))
m_style_changed = true;
}
delete d;
}
}
void Appearance::decoClicked ( int index )
{
DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index );
if ( m_sample )
{
if ( dli && dli-> interface ( ))
m_sample-> setDecoration ( dli-> interface ( ));
else
m_sample-> setDecoration ( new DefaultWindowDecoration ( ));
m_sample-> repaint ( );
}
m_deco_changed |= ( index != m_original_deco );
}
void Appearance::fontClicked ( const QFont &f )
{
m_font_changed |= ( f != m_sample-> font ( ));
m_sample-> setFont ( f );
}
void Appearance::colorClicked ( int index )
{
ColorListItem *item = (ColorListItem *) m_color_list-> item ( index );
if ( item )
m_sample-> setPalette ( item-> palette ( ));
m_color_changed |= ( item-> palette ( ) != qApp-> palette ( ));
}
void Appearance::editSchemeClicked ( )
{
ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
int cnt = 0;
QString labels [QColorGroup::NColorRoles];
QColor colors [QColorGroup::NColorRoles];
for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ )
{
QColor col = item-> color ( role );
diff --git a/noncore/settings/appearance2/sample.cpp b/noncore/settings/appearance2/sample.cpp
index b3a9d48..f6c4dca 100644
--- a/noncore/settings/appearance2/sample.cpp
+++ b/noncore/settings/appearance2/sample.cpp
@@ -1,271 +1,271 @@
/*
                This file is part of the OPIE Project
=. Copyright (c) 2002 Trolltech AS <info@trolltech.com>
             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.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.
*/
#include <qvbox.h>
#include <qpopupmenu.h>
#include <qpainter.h>
#include <qmenubar.h>
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qscrollbar.h>
#include <qlayout.h>
#include <qwhatsthis.h>
#include <qpixmapcache.h>
#include <qtimer.h>
#include <qobjectlist.h>
#include <qcommonstyle.h>
#include "sample.h"
class SampleText : public QWidget
{
public:
SampleText( const QString &t, bool h, QWidget *parent )
: QWidget( parent ), hl(h), text(t)
{
if ( hl )
setBackgroundMode( PaletteHighlight );
else
setBackgroundMode( PaletteBase );
}
QSize sizeHint() const
{
QFontMetrics fm(font());
return QSize( fm.width(text)+10, fm.height()+4 );
}
void paintEvent( QPaintEvent * )
{
QPainter p(this);
if ( hl )
p.setPen( colorGroup().highlightedText() );
else
p.setPen( colorGroup().text() );
p.drawText( rect(), AlignCenter, text );
}
private:
bool hl;
QString text;
};
SampleWindow::SampleWindow( QWidget *parent ) : QWidget(parent), iface(0)
{
init();
}
QSize SampleWindow::sizeHint() const
{
return container->sizeHint() + QSize( 10, 35 );
}
void SampleWindow::setFont( const QFont &f )
{
QWidget::setFont( f );
popup->setFont( f );
- QTimer::singleShot ( 0, this, SLOT( fixGeometry ( )));
+ QTimer::singleShot ( 0, this, SLOT( fixGeometry()));
}
static void setStyleRecursive ( QWidget *w, QStyle *s )
{
w->setStyle( s );
QObjectList *childObjects=(QObjectList*)w->children();
if ( childObjects ) {
QObject * o;
for(o=childObjects->first();o!=0;o=childObjects->next()) {
if( o->isWidgetType() ) {
setStyleRecursive((QWidget *)o,s);
}
}
}
}
void SampleWindow::setStyle2 ( QStyle *sty, const QPalette &pal )
{
typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, QColorGroup &, bool, bool);
extern QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl);
QPixmapCache::clear ( );
QPalette p = pal; // ette ( );
sty-> polish ( p );
qt_set_draw_menu_bar_impl ( 0 );
setStyleRecursive ( this, sty );
setPalette ( p );
- QTimer::singleShot ( 0, this, SLOT( fixGeometry ( )));
+ QTimer::singleShot ( 0, this, SLOT( fixGeometry()));
}
void SampleWindow::setDecoration( WindowDecorationInterface *i )
{
iface = i;
wd.rect = QRect( 0, 0, 150, 75 );
wd.caption = tr("Sample");
wd.palette = palette();
wd.flags = WindowDecorationInterface::WindowData::Dialog |
WindowDecorationInterface::WindowData::Active;
wd.reserved = 1;
th = iface->metric(WindowDecorationInterface::TitleHeight, &wd);
tb = iface->metric(WindowDecorationInterface::TopBorder, &wd);
lb = iface->metric(WindowDecorationInterface::LeftBorder, &wd);
rb = iface->metric(WindowDecorationInterface::RightBorder, &wd);
bb = iface->metric(WindowDecorationInterface::BottomBorder, &wd);
int yoff = th + tb;
int xoff = lb;
wd.rect.setX( 0 );
wd.rect.setWidth( width() - lb - rb );
wd.rect.setY( 0 );
wd.rect.setHeight( height() - yoff - bb );
container->setGeometry( xoff, yoff, wd.rect.width(), wd.rect.height() );
setMinimumSize( container->sizeHint().width()+lb+rb,
container->sizeHint().height()+tb+th+bb );
}
void SampleWindow::paintEvent( QPaintEvent * )
{
if ( !iface )
return;
QPainter p( this );
p.translate( lb, th+tb );
iface->drawArea(WindowDecorationInterface::Border, &p, &wd);
iface->drawArea(WindowDecorationInterface::Title, &p, &wd);
p.setPen(palette().active().color(QColorGroup::HighlightedText));
QFont f( font() );
f.setWeight( QFont::Bold );
p.setFont(f);
iface->drawArea(WindowDecorationInterface::TitleText, &p, &wd);
QRect brect( 0, -th, iface->metric(WindowDecorationInterface::HelpWidth,&wd), th );
iface->drawButton( WindowDecorationInterface::Help, &p, &wd,
brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 );
brect.moveBy( wd.rect.width() -
iface->metric(WindowDecorationInterface::OKWidth,&wd) -
iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 );
iface->drawButton( WindowDecorationInterface::Close, &p, &wd,
brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 );
brect.moveBy( iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 );
iface->drawButton( WindowDecorationInterface::OK, &p, &wd,
brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 );
}
void SampleWindow::init()
{
container = new QVBox( this );
popup = new QPopupMenu( this );
popup->insertItem( tr("Normal Item"), 1 );
popup->insertItem( tr("Disabled Item"), 2 );
popup->setItemEnabled(2, FALSE);
QMenuBar *mb = new QMenuBar( container );
mb->insertItem( tr("Menu"), popup );
QHBox *hb = new QHBox( container );
QWidget *w = new QWidget( hb );
(void)new QScrollBar( 0, 0, 0, 0, 0, Vertical, hb );
QGridLayout *gl = new QGridLayout( w, 2, 2, 4 );
SampleText *l = new SampleText( tr("Normal Text"), FALSE, w );
gl->addWidget( l, 0, 0 );
l = new SampleText( tr("Highlighted Text"), TRUE, w );
gl->addWidget( l, 1, 0 );
QPushButton *pb = new QPushButton( tr("Button"), w );
gl->addWidget( pb, 0, 1 );
pb->setFocusPolicy( NoFocus );
QCheckBox *cb = new QCheckBox( tr("Check Box"), w );
gl->addWidget( cb, 1, 1 );
cb->setFocusPolicy( NoFocus );
cb->setChecked( TRUE );
QWhatsThis::add( this, tr("Sample window using the selected settings.") );
}
bool SampleWindow::eventFilter( QObject *, QEvent *e )
{
switch ( e->type() ) {
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseButtonDblClick:
case QEvent::MouseMove:
case QEvent::KeyPress:
case QEvent::KeyRelease:
return TRUE;
default:
break;
}
return FALSE;
}
void SampleWindow::paletteChange( const QPalette &old )
{
QWidget::paletteChange ( old );
wd. palette = palette ( );
popup-> setPalette ( palette ( ));
}
void SampleWindow::setPalette ( const QPalette &pal )
{
QPixmapCache::clear ( );
QPalette p = pal;
style ( ). polish ( p );
QWidget::setPalette ( p );
}
void SampleWindow::resizeEvent( QResizeEvent *re )
{
wd.rect = QRect( 0, 0, 150, 75 );
wd.rect.setX( 0 );
wd.rect.setWidth( width() - lb - rb );
wd.rect.setY( 0 );
wd.rect.setHeight( height() - th - tb - bb );
container->setGeometry( lb, th+tb, wd.rect.width(), wd.rect.height() );
QWidget::resizeEvent( re );
}
void SampleWindow::fixGeometry()
{
setMinimumSize( container->sizeHint().width()+lb+rb,
container->sizeHint().height()+tb+th+bb );
}
diff --git a/noncore/settings/aqpkg/inputdlg.cpp b/noncore/settings/aqpkg/inputdlg.cpp
index 06e934c..30f0527 100644
--- a/noncore/settings/aqpkg/inputdlg.cpp
+++ b/noncore/settings/aqpkg/inputdlg.cpp
@@ -1,134 +1,134 @@
/*
                This file is part of the OPIE Project
=. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
             .=l. Dan Williams <drw@handhelds.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.
*/
#include <qlayout.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qspinbox.h>
#include <qcombobox.h>
#include <qwidgetstack.h>
#include <qvalidator.h>
#include <qapplication.h>
#include "inputdlg.h"
#include "global.h"
InputDialog :: InputDialog( const QString &label, QWidget* parent, const char* name,
bool modal )
: QDialog( parent, name, modal )
{
lineEdit = 0;
QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 );
QLabel* l = new QLabel( label, this );
vbox->addWidget( l );
lineEdit = new QLineEdit( this );
vbox->addWidget( lineEdit );
QHBoxLayout *hbox = new QHBoxLayout( 6 );
vbox->addLayout( hbox, AlignRight );
ok = new QPushButton( tr( "&OK" ), this );
ok->setDefault( TRUE );
QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this );
QSize bs( ok->sizeHint() );
if ( cancel->sizeHint().width() > bs.width() )
bs.setWidth( cancel->sizeHint().width() );
ok->setFixedSize( bs );
cancel->setFixedSize( bs );
hbox->addWidget( new QWidget( this ) );
hbox->addWidget( ok );
hbox->addWidget( cancel );
connect( lineEdit, SIGNAL( returnPressed() ),
this, SLOT( tryAccept() ) );
- connect( lineEdit, SIGNAL( textChanged( const QString & ) ),
- this, SLOT( textChanged( const QString & ) ) );
+ connect( lineEdit, SIGNAL( textChanged(const QString&) ),
+ this, SLOT( textChanged(const QString&) ) );
connect( ok, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
resize( QMAX( sizeHint().width(), 240 ), sizeHint().height() );
}
/*!
Destructor.
*/
InputDialog::~InputDialog()
{
}
void InputDialog :: setText( const QString &text )
{
lineEdit->setText( text );
lineEdit->selectAll();
}
QString InputDialog :: getText()
{
return lineEdit->text();
}
QString InputDialog::getText( const QString &caption, const QString &label,
const QString &text, bool *ok, QWidget *parent,
const char *name )
{
InputDialog *dlg = new InputDialog( label, parent, name, true );
dlg->setCaption( caption );
dlg->setText( text );
QString result;
*ok = dlg->exec() == QDialog::Accepted;
if ( *ok )
result = dlg->getText();
delete dlg;
return result;
}
void InputDialog :: textChanged( const QString &s )
{
ok->setEnabled( !s.isEmpty() );
}
void InputDialog :: tryAccept()
{
if ( !lineEdit->text().isEmpty() )
accept();
}
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index d927a36..d2babb4 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -1,476 +1,476 @@
/*
                This file is part of the OPIE Project
=. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
             .=l. Dan Williams <drw@handhelds.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.
*/
#include <stdio.h>
#include <opie2/ofiledialog.h>
#ifdef QWS
#include <qpe/config.h>
#include <qpe/fileselector.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/storage.h>
#endif
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qdialog.h>
#include <qfileinfo.h>
#include <qgroupbox.h>
#include <qmultilineedit.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include "datamgr.h"
#include "destination.h"
#include "instoptionsimpl.h"
#include "installdlgimpl.h"
#include "ipkg.h"
#include "utils.h"
#include "global.h"
enum {
MAXLINES = 100,
};
InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title )
: QWidget( 0, 0, 0 )
{
setCaption( title );
init( TRUE );
pIpkg = 0;
upgradePackages = false;
dataMgr = dataManager;
QString defaultDest = "root";
#ifdef QWS
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
defaultDest = cfg.readEntry( "dest", "root" );
// Grab flags - Turn MAKE_LINKS on by default (if no flags found)
flags = cfg.readNumEntry( "installFlags", 0 );
infoLevel = cfg.readNumEntry( "infoLevel", 1 );
#else
flags = 0;
#endif
// Output text is read only
output->setReadOnly( true );
// QFont f( "helvetica" );
// f.setPointSize( 10 );
// output->setFont( f );
// setup destination data
int defIndex = 0;
int i;
QListIterator<Destination> dit( dataMgr->getDestinationList() );
for ( i = 0; dit.current(); ++dit, ++i )
{
destination->insertItem( dit.current()->getDestinationName() );
if ( dit.current()->getDestinationName() == defaultDest )
defIndex = i;
}
destination->setCurrentItem( defIndex );
QListIterator<InstallData> it( packageList );
// setup package data
QString remove = tr( "Remove\n" );
QString install = tr( "Install\n" );
QString upgrade = tr( "Upgrade\n" );
for ( ; it.current(); ++it )
{
InstallData *item = it.current();
InstallData *newitem = new InstallData();
newitem->option = item->option;
newitem->packageName = item->packageName;
newitem->destination = item->destination;
newitem->recreateLinks = item->recreateLinks;
packages.append( newitem );
if ( item->option == "I" )
{
install.append( QString( " %1\n" ).arg( item->packageName ) );
}
else if ( item->option == "D" )
{
remove.append( QString( " %1\n" ).arg( item->packageName ) );
}
else if ( item->option == "U" || item->option == "R" )
{
QString type;
if ( item->option == "R" )
type = tr( "(ReInstall)" );
else
type = tr( "(Upgrade)" );
upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) );
}
}
output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) );
displayAvailableSpace( destination->currentText() );
}
InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title )
: QWidget( 0, 0, 0 )
{
setCaption( title );
init( FALSE );
pIpkg = ipkg;
output->setText( initialText );
}
InstallDlgImpl::~InstallDlgImpl()
{
if ( pIpkg )
delete pIpkg;
}
void InstallDlgImpl :: init( bool displayextrainfo )
{
QGridLayout *layout = new QGridLayout( this );
layout->setSpacing( 4 );
layout->setMargin( 4 );
if ( displayextrainfo )
{
QLabel *label = new QLabel( tr( "Destination" ), this );
layout->addWidget( label, 0, 0 );
destination = new QComboBox( FALSE, this );
layout->addWidget( destination, 0, 1 );
- connect( destination, SIGNAL( highlighted( const QString & ) ),
- this, SLOT( displayAvailableSpace( const QString & ) ) );
+ connect( destination, SIGNAL( highlighted(const QString&) ),
+ this, SLOT( displayAvailableSpace(const QString&) ) );
QLabel *label2 = new QLabel( tr( "Space Avail" ), this );
layout->addWidget( label2, 1, 0 );
txtAvailableSpace = new QLabel( "", this );
layout->addWidget( txtAvailableSpace, 1, 1 );
}
else
{
destination = 0x0;
txtAvailableSpace = 0x0;
}
QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this );
GroupBox2->layout()->setSpacing( 0 );
GroupBox2->layout()->setMargin( 4 );
QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() );
output = new QMultiLineEdit( GroupBox2 );
GroupBox2Layout->addWidget( output );
layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 );
btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this );
layout->addWidget( btnInstall, 3, 0 );
connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) );
btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this );
layout->addWidget( btnOptions, 3, 1 );
connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) );
}
void InstallDlgImpl :: optionsSelected()
{
if ( btnOptions->text() == tr( "Options" ) )
{
InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true );
if ( opt.exec() == QDialog::Accepted )
{
// set options selected from dialog
flags = opt.getFlags();
infoLevel = opt.getInfoLevel();
#ifdef QWS
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
cfg.writeEntry( "installFlags", flags );
cfg.writeEntry( "infoLevel", infoLevel );
#endif
}
}
else // Save output
{
QMap<QString, QStringList> map;
map.insert( tr( "All" ), QStringList() );
QStringList text;
text << "text/*";
map.insert(tr( "Text" ), text );
text << "*";
map.insert( tr( "All" ), text );
QString filename = Opie::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map );
if( !filename.isEmpty() )
{
QString currentFileName = QFileInfo( filename ).fileName();
DocLnk doc;
doc.setType( "text/plain" );
doc.setFile( filename );
doc.setName( currentFileName );
FileManager fm;
fm.saveFile( doc, output->text() );
}
}
}
void InstallDlgImpl :: installSelected()
{
if ( btnInstall->text() == tr( "Abort" ) )
{
if ( pIpkg )
{
displayText( tr( "\n**** User Clicked ABORT ***" ) );
pIpkg->abort();
displayText( tr( "**** Process Aborted ****" ) );
}
btnInstall->setText( tr( "Close" ) );
btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
return;
}
else if ( btnInstall->text() == tr( "Close" ) )
{
emit reloadData( this );
return;
}
// Disable buttons
btnOptions->setEnabled( false );
// btnInstall->setEnabled( false );
btnInstall->setText( tr( "Abort" ) );
btnInstall->setIconSet( Resource::loadPixmap( "close" ) );
if ( pIpkg )
{
output->setText( "" );
- connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
+ connect( pIpkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&)));
connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished()));
pIpkg->runIpkg();
}
else
{
output->setText( "" );
Destination *d = dataMgr->getDestination( destination->currentText() );
QString dest = d->getDestinationName();
QString destDir = d->getDestinationPath();
int instFlags = flags;
if ( d->linkToRoot() )
instFlags |= MAKE_LINKS;
#ifdef QWS
// Save settings
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
cfg.writeEntry( "dest", dest );
#endif
pIpkg = new Ipkg;
- connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
+ connect( pIpkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&)));
connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished()));
firstPackage = TRUE;
ipkgFinished();
// First run through the remove list, then the install list then the upgrade list
/*
pIpkg->setOption( "remove" );
QListIterator<InstallData> it( removeList );
InstallData *idata;
for ( ; it.current(); ++it )
{
idata = it.current();
pIpkg->setDestination( idata->destination->getDestinationName() );
pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
pIpkg->setPackage( idata->packageName );
int tmpFlags = flags;
if ( idata->destination->linkToRoot() )
tmpFlags |= MAKE_LINKS;
pIpkg->setFlags( tmpFlags, infoLevel );
pIpkg->runIpkg();
}
pIpkg->setOption( "install" );
pIpkg->setDestination( dest );
pIpkg->setDestinationDir( destDir );
pIpkg->setFlags( instFlags, infoLevel );
QListIterator<InstallData> it2( installList );
for ( ; it2.current(); ++it2 )
{
pIpkg->setPackage( it2.current()->packageName );
pIpkg->runIpkg();
}
flags |= FORCE_REINSTALL;
QListIterator<InstallData> it3( updateList );
for ( ; it3.current() ; ++it3 )
{
idata = it3.current();
if ( idata->option == "R" )
pIpkg->setOption( "reinstall" );
else
pIpkg->setOption( "upgrade" );
pIpkg->setDestination( idata->destination->getDestinationName() );
pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
pIpkg->setPackage( idata->packageName );
int tmpFlags = flags;
if ( idata->destination->linkToRoot() && idata->recreateLinks )
tmpFlags |= MAKE_LINKS;
pIpkg->setFlags( tmpFlags, infoLevel );
pIpkg->runIpkg();
}
delete pIpkg;
pIpkg = 0;
*/
}
}
void InstallDlgImpl :: displayText(const QString &text )
{
QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text );
/* Set a max line count for the QMultiLineEdit, as users have reported
* performance issues when line count gets extreme.
*/
if(output->numLines() >= MAXLINES)
output->removeLine(0);
output->setText( newtext );
output->setCursorPosition( output->numLines(), 0 );
}
void InstallDlgImpl :: displayAvailableSpace( const QString &text )
{
Destination *d = dataMgr->getDestination( text );
QString destDir = d->getDestinationPath();
long blockSize = 0;
long totalBlocks = 0;
long availBlocks = 0;
QString space;
if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) )
{
long mult = blockSize / 1024;
long div = 1024 / blockSize;
if ( !mult ) mult = 1;
if ( !div ) div = 1;
long avail = availBlocks * mult / div;
space = tr( "%1 Kb" ).arg( avail );
}
else
space = tr( "Unknown" );
if ( txtAvailableSpace )
txtAvailableSpace->setText( space );
}
void InstallDlgImpl :: ipkgFinished()
{
InstallData *item;
if ( firstPackage )
item = packages.first();
else
{
// Create symlinks if necessary before moving on to next package
pIpkg->createSymLinks();
item = packages.next();
}
firstPackage = FALSE;
if ( item )
{
pIpkg->setPackage( item->packageName );
int tmpFlags = flags;
if ( item->option == "I" )
{
pIpkg->setOption( "install" );
Destination *d = dataMgr->getDestination( destination->currentText() );
pIpkg->setDestination( d->getDestinationName() );
pIpkg->setDestinationDir( d->getDestinationPath() );
if ( d->linkToRoot() )
tmpFlags |= MAKE_LINKS;
}
else if ( item->option == "D" )
{
pIpkg->setOption( "remove" );
pIpkg->setDestination( item->destination->getDestinationName() );
pIpkg->setDestinationDir( item->destination->getDestinationPath() );
if ( item->destination->linkToRoot() )
tmpFlags |= MAKE_LINKS;
}
else
{
if ( item->option == "R" )
pIpkg->setOption( "reinstall" );
else
pIpkg->setOption( "upgrade" );
pIpkg->setDestination( item->destination->getDestinationName() );
pIpkg->setDestinationDir( item->destination->getDestinationPath() );
pIpkg->setPackage( item->packageName );
tmpFlags |= FORCE_REINSTALL;
if ( item->destination->linkToRoot() && item->recreateLinks )
tmpFlags |= MAKE_LINKS;
}
pIpkg->setFlags( tmpFlags, infoLevel );
pIpkg->runIpkg();
}
else
{
btnOptions->setEnabled( true );
btnInstall->setText( tr( "Close" ) );
btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
btnOptions->setText( tr( "Save output" ) );
btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
displayAvailableSpace( destination->currentText() );
}
}
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp
index 3761b67..866afed 100644
--- a/noncore/settings/aqpkg/ipkg.cpp
+++ b/noncore/settings/aqpkg/ipkg.cpp
@@ -99,392 +99,392 @@ void Ipkg :: runIpkg()
if ( flags & MAKE_LINKS )
{
// If destDir == / turn off make links as package is being insalled
// to root already.
if ( destDir == "/" )
flags ^= MAKE_LINKS;
}
}
#ifdef X86
commands << "-f";
commands << IPKG_CONF;
#endif
if ( option == "reinstall" )
commands << "install";
else
commands << option;
if ( package != "" )
commands << package;
if ( package != "" )
emit outputText( tr( "Dealing with package %1" ).arg( package) );
qApp->processEvents();
// If we are removing, reinstalling or upgrading packages and make links option is selected
// create the links
if ( option == "remove" || option == "reinstall" || option == "upgrade" )
{
createLinks = false;
if ( flags & MAKE_LINKS )
{
emit outputText( tr( "Removing symbolic links...\n" ) );
linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
emit outputText( QString( " " ) );
}
}
// Execute command
dependantPackages = new QList<QString>;
dependantPackages->setAutoDelete( true );
executeIpkgCommand( commands, option );
}
void Ipkg :: createSymLinks()
{
if ( option == "install" || option == "reinstall" || option == "upgrade" )
{
// If we are not removing packages and make links option is selected
// create the links
createLinks = true;
if ( flags & MAKE_LINKS )
{
emit outputText( " " );
emit outputText( tr( "Creating symbolic links for %1." ).arg( package) );
linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
// link dependant packages that were installed with this release
QString *pkg;
for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() )
{
if ( *pkg == package )
continue;
emit outputText( " " );
emit outputText( tr( "Creating symbolic links for %1" ).arg( *pkg ) );
linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir );
}
}
}
delete dependantPackages;
emit outputText( tr("Finished") );
emit outputText( "" );
}
void Ipkg :: removeStatusEntry()
{
QString statusFile = destDir;
if ( statusFile.right( 1 ) != "/" )
statusFile.append( "/" );
statusFile.append( "usr/lib/ipkg/status" );
QString outStatusFile = statusFile;
outStatusFile.append( ".tmp" );
emit outputText( "" );
emit outputText( tr("Removing status entry...") );
QString tempstr = tr("status file - ");
tempstr.append( statusFile );
emit outputText( tempstr );
tempstr = tr("package - ");
tempstr.append( package );
emit outputText( tempstr );
QFile readFile( statusFile );
QFile writeFile( outStatusFile );
if ( !readFile.open( IO_ReadOnly ) )
{
tempstr = tr("Couldn't open status file - ");
tempstr.append( statusFile );
emit outputText( tempstr );
return;
}
if ( !writeFile.open( IO_WriteOnly ) )
{
tempstr = tr("Couldn't create tempory status file - ");
tempstr.append( outStatusFile );
emit outputText( tempstr );
return;
}
int i = 0;
QTextStream readStream( &readFile );
QTextStream writeStream( &writeFile );
QString line;
char k[21];
char v[1001];
QString key;
QString value;
while ( !readStream.atEnd() )
{
//read new line
line = readStream.readLine();
if ( line.contains( ":", TRUE ) )
{
//grep key and value from line
k[0] = '\0';
v[0] = '\0';
sscanf( line, "%[^:]: %[^\n]", k, v );
key = k;
value = v;
key = key.stripWhiteSpace();
value = value.stripWhiteSpace();
} else {
key = "";
value = "";
}
if ( key == "Package" && value == package )
{
//skip lines from the deleted package
while ( ( !readStream.atEnd() ) && ( line.stripWhiteSpace() != "" ) )
{
line = readStream.readLine();
}
} else {
//write other lines into the tempfile
writeStream << line << "\n";
// Improve UI responsiveness
i++;
if ( ( i % 50 ) == 0 )
qApp->processEvents();
}
}
readFile.close();
writeFile.close();
// Remove old status file and put tmp stats file in its place
remove( statusFile );
rename( outStatusFile, statusFile );
}
int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ )
{
// If one is already running - should never be but just to be safe
if ( proc )
{
delete proc;
proc = 0;
}
// OK we're gonna use OProcess to run this thing
proc = new OProcess();
aborted = false;
// Connect up our slots
- connect(proc, SIGNAL(processExited(OProcess *)),
+ connect(proc, SIGNAL(processExited(OProcess*)),
this, SLOT( processFinished()));
- connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
- this, SLOT(commandStdout(OProcess *, char *, int)));
+ connect(proc, SIGNAL(receivedStdout(OProcess*,char*,int)),
+ this, SLOT(commandStdout(OProcess*,char*,int)));
- connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
- this, SLOT(commandStderr(OProcess *, char *, int)));
+ connect(proc, SIGNAL(receivedStderr(OProcess*,char*,int)),
+ this, SLOT(commandStderr(OProcess*,char*,int)));
for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it )
{
*proc << (*it).latin1();
}
// Start the process going
finished = false;
if(!proc->start(OProcess::NotifyOnExit, OProcess::All))
{
emit outputText( tr("Couldn't start ipkg process" ) );
}
}
void Ipkg::commandStdout(OProcess*, char *buffer, int buflen)
{
QString lineStr = buffer;
if ( lineStr[buflen-1] == '\n' )
buflen --;
lineStr = lineStr.left( buflen );
emit outputText( lineStr );
// check if we are installing dependant packages
if ( option == "install" || option == "reinstall" )
{
// Need to keep track of any dependant packages that get installed
// so that we can create links to them as necessary
if ( lineStr.startsWith( "Installing " ) )
{
int start = lineStr.find( " " ) + 1;
int end = lineStr.find( " ", start );
QString *package = new QString( lineStr.mid( start, end-start ) );
dependantPackages->append( package );
}
}
else if ( option == "remove" && !( flags & FORCE_DEPENDS ) &&
lineStr.find( "is depended upon by packages:" ) != -1 )
{
// Ipkg should send this to STDERR, but doesn't - so trap here
error = true;
}
buffer[0] = '\0';
}
void Ipkg::commandStderr(OProcess*, char *buffer, int buflen)
{
QString lineStr = buffer;
if ( lineStr[buflen-1] == '\n' )
buflen --;
lineStr=lineStr.left( buflen );
emit outputText( lineStr );
buffer[0] = '\0';
error = true;
}
void Ipkg::processFinished()
{
// Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file
// to workaround an ipkg bug which stops reinstall to a different location
if ( !error && option == "remove" )
removeStatusEntry();
delete proc;
proc = 0;
finished = true;
emit ipkgFinished();
}
void Ipkg :: abort()
{
if ( proc )
{
proc->kill();
aborted = true;
}
}
void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir )
{
if ( dest == "root" || dest == "/" )
return;
qApp->processEvents();
QStringList *fileList = getList( packFileName, destDir );
qApp->processEvents();
processFileList( fileList, destDir );
delete fileList;
}
QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir )
{
QString packageFileDir = destDir;
packageFileDir.append( "/usr/lib/ipkg/info/" );
packageFileDir.append( packageFilename );
packageFileDir.append( ".list" );
QFile f( packageFileDir );
if ( !f.open(IO_ReadOnly) )
{
// Couldn't open from dest, try from /
f.close();
packageFileDir = "/usr/lib/ipkg/info/";
packageFileDir.append( packageFilename );
packageFileDir.append( ".list" );
f.setName( packageFileDir );
if ( ! f.open(IO_ReadOnly) )
{
QString tempstr = tr("Could not open :");
tempstr.append( packageFileDir );
emit outputText( tempstr );
return (QStringList*)0;
}
}
QStringList *fileList = new QStringList();
QTextStream t( &f );
while ( !t.eof() )
*fileList += t.readLine();
f.close();
return fileList;
}
void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir )
{
if ( !fileList || fileList->isEmpty() )
return;
QString baseDir = ROOT;
if ( createLinks == true )
{
for ( uint i=0; i < fileList->count(); i++ )
{
processLinkDir( (*fileList)[i], baseDir, destDir );
qApp->processEvents();
}
}
else
{
for ( int i = fileList->count()-1; i >= 0 ; i-- )
{
processLinkDir( (*fileList)[i], baseDir, destDir );
qApp->processEvents();
}
}
}
void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir )
{
QString sourceFile = baseDir;
sourceFile.append( file );
QString linkFile = destDir;
if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" )
{
linkFile.append( file.mid( 1 ) );
}
else
{
linkFile.append( file );
}
QString text;
if ( createLinks )
{
// If this file is a directory (ends with a /) and it doesn't exist,
// we need to create it
if ( file.right(1) == "/" )
{
QFileInfo f( linkFile );
if ( !f.exists() )
{
QString tempstr = tr("Creating directory ");
tempstr.append( linkFile );
emit outputText( tempstr );
QDir d;
d.mkdir( linkFile, true );
}
// else
// emit outputText( QString( "Directory " ) + linkFile + " already exists" );
}
else
{
int rc = symlink( sourceFile, linkFile );
text = ( rc == 0 ? tr( "Linked %1 to %2" ) : tr( "Failed to link %1 to %2" ) ).
arg( sourceFile ).
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index 6f5c712..6b31cd1 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -1,504 +1,504 @@
/*
                This file is part of the OPIE Project
=. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
             .=l. Dan Williams <drw@handhelds.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.
*/
#include "categoryfilterimpl.h"
#include "datamgr.h"
#include "global.h"
#include "inputdlg.h"
#include "ipkg.h"
#include "installdlgimpl.h"
#include "letterpushbutton.h"
#include "mainwin.h"
#include "packagewin.h"
#include "settingsimpl.h"
#include "utils.h"
/* OPIE */
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <qpe/resource.h>
/* QT */
#include <qmenubar.h>
#include <qtoolbar.h>
#include <qaction.h>
#include <qcombobox.h>
#include <qfile.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qprogressbar.h>
#include <qtimer.h>
#include <qwhatsthis.h>
#include <qwidgetstack.h>
/* STD */
#include <linux/limits.h>
#include <unistd.h>
extern int compareVersions( const char *v1, const char *v2 );
MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl )
: QMainWindow( parent, name, fl || WStyle_ContextHelp )
{
// Disable suspend mode
QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend;
LOCAL_SERVER = QObject::tr( "Installed packages" );
LOCAL_IPKGS = QObject::tr( "Local packages" );
setCaption( tr( "AQPkg - Package Manager" ) );
// Create UI widgets
initMainWidget();
initProgressWidget();
// Build menu and tool bars
setToolBarsMovable( FALSE );
QToolBar *bar = new QToolBar( this );
bar->setHorizontalStretchable( TRUE );
QMenuBar *mb = new QMenuBar( bar );
mb->setMargin( 0 );
bar = new QToolBar( this );
// Find toolbar
findBar = new QToolBar( this );
addToolBar( findBar, QMainWindow::Top, true );
findBar->setHorizontalStretchable( true );
findEdit = new QLineEdit( findBar );
QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) );
findBar->setStretchableWidget( findEdit );
- connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) );
+ connect( findEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( findPackage(const QString&) ) );
// Quick jump toolbar
jumpBar = new QToolBar( this );
addToolBar( jumpBar, QMainWindow::Top, true );
jumpBar->setHorizontalStretchable( true );
QWidget *w = new QWidget( jumpBar );
jumpBar->setStretchableWidget( w );
QGridLayout *layout = new QGridLayout( w );
char text[2];
text[1] = '\0';
for ( int i = 0 ; i < 26 ; ++i )
{
text[0] = 'A' + i;
LetterPushButton *b = new LetterPushButton( text, w );
- connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
+ connect( b, SIGNAL( released(QString) ), this, SLOT( letterPushed(QString) ) );
layout->addWidget( b, i / 13, i % 13);
}
QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 );
a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) );
connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) );
a->addTo( jumpBar );
jumpBar->hide();
// Packages menu
QPopupMenu *popup = new QPopupMenu( this );
a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) );
a->addTo( popup );
a->addTo( bar );
actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 );
actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) );
actionUpgrade->addTo( popup );
actionUpgrade->addTo( bar );
iconDownload = Resource::loadPixmap( "aqpkg/download" );
iconRemove = Resource::loadPixmap( "aqpkg/remove" );
actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) );
actionDownload->addTo( popup );
actionDownload->addTo( bar );
a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) );
a->addTo( popup );
a->addTo( bar );
popup->insertSeparator();
a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to configure this application." ) );
connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) );
a->addTo( popup );
mb->insertItem( tr( "Actions" ), popup );
// View menu
popup = new QPopupMenu( this );
actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
actionUninstalled->setToggleAction( TRUE );
actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) );
actionUninstalled->addTo( popup );
actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
actionInstalled->setToggleAction( TRUE );
actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) );
actionInstalled->addTo( popup );
actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
actionUpdated->setToggleAction( TRUE );
actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) );
actionUpdated->addTo( popup );
popup->insertSeparator();
actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 );
actionFilter->setToggleAction( TRUE );
actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) );
connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) );
actionFilter->addTo( popup );
a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to change package category to used filter." ) );
connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) );
a->addTo( popup );
popup->insertSeparator();
a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to search for text in package names." ) );
connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) );
a->addTo( popup );
actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
actionFindNext->setEnabled( FALSE );
actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) );
connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) );
actionFindNext->addTo( popup );
actionFindNext->addTo( findBar );
popup->insertSeparator();
a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) );
connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) );
a->addTo( popup );
mb->insertItem( tr( "View" ), popup );
// Finish find toolbar creation
a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to hide the find toolbar." ) );
connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) );
a->addTo( findBar );
findBar->hide();
// Create widget stack and add UI widgets
stack = new QWidgetStack( this );
stack->addWidget( progressWindow, 2 );
stack->addWidget( networkPkgWindow, 1 );
setCentralWidget( stack );
stack->raiseWidget( progressWindow );
// Delayed call to finish initialization
QTimer::singleShot( 100, this, SLOT( init() ) );
}
MainWindow :: ~MainWindow()
{
delete mgr;
// Reenable suspend mode
QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
}
void MainWindow :: initMainWidget()
{
networkPkgWindow = new QWidget( this );
QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow );
serversList = new QComboBox( networkPkgWindow );
connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) );
QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) );
installedIcon = Resource::loadPixmap( "installed" );
updatedIcon = Resource::loadPixmap( "aqpkg/updated" );
packagesList = new QListView( networkPkgWindow );
packagesList->addColumn( tr( "Packages" ), 225 );
QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) );
QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold );
- connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)),
- this, SLOT(slotDisplayPackage(QListViewItem *)) );
+ connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)),
+ this, SLOT(slotDisplayPackage(QListViewItem*)) );
QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 );
QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 );
hbox1->addWidget( l );
hbox1->addWidget( serversList );
vbox->addWidget( packagesList );
downloadEnabled = TRUE;
}
void MainWindow :: initProgressWidget()
{
progressWindow = new QWidget( this );
QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 );
m_status = new QLabel( progressWindow );
m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
layout->addWidget( m_status );
m_progress = new QProgressBar( progressWindow );
layout->addWidget( m_progress );
}
void MainWindow :: init()
{
#ifdef QWS
// read download directory from config file
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
// showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
#endif
stack->raiseWidget( progressWindow );
mgr = new DataManager();
- connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) );
- connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
- this, SLOT( setProgressMessage( const QString & ) ) );
- connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) );
+ connect( mgr, SIGNAL( progressSetSteps(int) ), this, SLOT( setProgressSteps(int) ) );
+ connect( mgr, SIGNAL( progressSetMessage(const QString&) ),
+ this, SLOT( setProgressMessage(const QString&) ) );
+ connect( mgr, SIGNAL( progressUpdate(int) ), this, SLOT( updateProgress(int) ) );
mgr->loadServers();
showUninstalledPkgs = false;
showInstalledPkgs = false;
showUpgradedPkgs = false;
categoryFilterEnabled = false;
updateData();
stack->raiseWidget( networkPkgWindow );
}
void MainWindow :: setDocument( const QString &doc )
{
// Remove path from package
QString package = Utils::getPackageNameFromIpkFilename( doc );
// First select local server
for ( int i = 0 ; i < serversList->count() ; ++i )
{
if ( serversList->text( i ) == LOCAL_IPKGS )
{
serversList->setCurrentItem( i );
break;
}
}
serverSelected( 0 );
// Now set the check box of the selected package
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->text().startsWith( package ) )
{
item->setOn( true );
break;
}
}
}
void MainWindow :: displaySettings()
{
SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
if ( dlg->showDlg() )
{
stack->raiseWidget( progressWindow );
updateData();
stack->raiseWidget( networkPkgWindow );
}
delete dlg;
}
void MainWindow :: closeEvent( QCloseEvent *e )
{
// If install dialog is visible, return to main view, otherwise close app
QWidget *widget = stack->visibleWidget();
if ( widget != networkPkgWindow && widget != progressWindow )
{
if ( widget ) delete widget;
stack->raiseWidget( networkPkgWindow );
e->ignore();
}
else
{
e->accept();
}
}
void MainWindow :: displayFindBar()
{
findBar->show();
findEdit->setFocus();
}
void MainWindow :: displayJumpBar()
{
jumpBar->show();
}
void MainWindow :: repeatFind()
{
searchForPackage( findEdit->text() );
}
void MainWindow :: findPackage( const QString &text )
{
actionFindNext->setEnabled( !text.isEmpty() );
searchForPackage( text );
}
void MainWindow :: hideFindBar()
{
findBar->hide();
}
void MainWindow :: hideJumpBar()
{
jumpBar->hide();
}
void MainWindow :: filterUninstalledPackages()
{
showUninstalledPkgs = actionUninstalled->isOn();
if ( showUninstalledPkgs )
{
showInstalledPkgs = FALSE;
showUpgradedPkgs = FALSE;
}
serverSelected( -1 );
actionInstalled->setOn( FALSE );
actionUpdated->setOn( FALSE );
}
void MainWindow :: filterInstalledPackages()
{
showInstalledPkgs = actionInstalled->isOn();
if ( showInstalledPkgs )
{
showUninstalledPkgs = FALSE;
showUpgradedPkgs = FALSE;
}
serverSelected( -1 );
actionUninstalled->setOn( FALSE );
actionUpdated->setOn( FALSE );
}
void MainWindow :: filterUpgradedPackages()
{
showUpgradedPkgs = actionUpdated->isOn();
if ( showUpgradedPkgs )
{
showUninstalledPkgs = FALSE;
showInstalledPkgs = FALSE;
}
serverSelected( -1 );
actionUninstalled->setOn( FALSE );
actionInstalled->setOn( FALSE );
}
bool MainWindow :: setFilterCategory()
{
// Get categories;
CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this );
if ( dlg.exec() == QDialog::Accepted )
{
categoryFilter = dlg.getSelectedFilter();
if ( categoryFilter == "" )
return false;
categoryFilterEnabled = true;
serverSelected( -1 );
actionFilter->setOn( TRUE );
return true;
}
return false;
}
void MainWindow :: filterCategory()
{
if ( !actionFilter->isOn() )
{
filterByCategory( FALSE );
}
else
{
actionFilter->setOn( filterByCategory( TRUE ) );
}
}
bool MainWindow :: filterByCategory( bool val )
{
if ( val )
{
if ( categoryFilter == "" )
{
if ( !setFilterCategory() )
return false;
}
categoryFilterEnabled = true;
serverSelected( -1 );
return true;
}
else
{
@@ -581,603 +581,603 @@ void MainWindow :: updateData()
{
i--;
continue;
}
serversList->insertItem( serverName );
if ( serverName == currentlySelectedServer )
activeItem = i;
}
// set selected server to be active server
if ( activeItem != -1 )
serversList->setCurrentItem( activeItem );
serverSelected( 0, FALSE );
}
void MainWindow :: serverSelected( int index )
{
serverSelected( index, TRUE );
}
void MainWindow :: serverSelected( int, bool raiseProgress )
{
QPixmap nullIcon( installedIcon.size() );
nullIcon.fill( colorGroup().base() );
// display packages
QString serverName = serversList->currentText();
currentlySelectedServer = serverName;
Server *s = mgr->getServer( serverName );
QList<Package> &list = s->getPackageList();
QListIterator<Package> it( list );
// Display progress widget while loading list
bool doProgress = ( list.count() > 200 );
if ( doProgress )
{
if ( raiseProgress )
{
stack->raiseWidget( progressWindow );
}
m_progress->setTotalSteps( list.count() );
m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
}
packagesList->clear();
#ifdef QWS
// read download directory from config file
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
cfg.writeEntry( "selectedServer", currentlySelectedServer );
#endif
int i = 0;
Package *package;
for ( ; it.current(); ++it )
{
// Update progress after every 100th package (arbitrary value, seems to give good balance)
i++;
if ( ( i % 100 ) == 0 )
{
if ( doProgress )
{
m_progress->setProgress( i );
}
qApp->processEvents();
}
QString text = "";
package = it.current();
// Apply show only uninstalled packages filter
if ( showUninstalledPkgs && package->isInstalled() )
continue;
// Apply show only installed packages filter
if ( showInstalledPkgs && !package->isInstalled() )
continue;
// Apply show only new installed packages filter
if ( showUpgradedPkgs )
{
if ( !package->isInstalled() || !package->getNewVersionAvailable() )
continue;
}
// Apply the section filter
if ( categoryFilterEnabled && categoryFilter != "" )
{
if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 )
continue;
}
// If the local server, only display installed packages
if ( serverName == LOCAL_SERVER && !package->isInstalled() )
continue;
QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(),
QCheckListItem::CheckBox );
if ( package->isInstalled() )
{
// If a different version of package is available, show update available icon
// Otherwise, show installed icon
if ( package->getNewVersionAvailable())
{
item->setPixmap( 0, updatedIcon );
}
else
{
item->setPixmap( 0, installedIcon );
}
}
else
{
item->setPixmap( 0, nullIcon );
}
packagesList->insertItem( item );
}
// If the local server or the local ipkgs server disable the download button
if ( serverName == LOCAL_SERVER )
{
downloadEnabled = TRUE;
actionUpgrade->setEnabled( FALSE );
}
else if ( serverName == LOCAL_IPKGS )
{
downloadEnabled = FALSE;
actionUpgrade->setEnabled( FALSE );
}
else
{
downloadEnabled = TRUE;
actionUpgrade->setEnabled( TRUE );
}
enableDownload( downloadEnabled );
// Display this widget once everything is done
if ( doProgress && raiseProgress )
{
stack->raiseWidget( networkPkgWindow );
}
}
void MainWindow :: searchForPackage( const QString &text )
{
if ( !text.isEmpty() )
{
// look through package list for text startng at current position
QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
if ( start == 0 )
start = (QCheckListItem *)packagesList->firstChild();
for ( QCheckListItem *item = start; item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->text().lower().find( text ) != -1 )
{
packagesList->ensureItemVisible( item );
packagesList->setCurrentItem( item );
break;
}
}
}
}
void MainWindow :: updateServer()
{
QString serverName = serversList->currentText();
// Update the current server
// Display dialog
// Disable buttons to stop silly people clicking lots on them :)
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
Ipkg *ipkg = new Ipkg;
ipkg->setOption( "update" );
InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ),
tr( "Update lists" ) );
- connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
+ connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) );
reloadDocuments = FALSE;
stack->addWidget( dlg, 3 );
stack->raiseWidget( dlg );
// delete progDlg;
}
void MainWindow :: upgradePackages()
{
// We're gonna do an upgrade of all packages
// First warn user that this isn't recommended
// TODO - ODevice????
QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
QMessageBox::Yes,
QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
0, this );
warn.adjustSize();
if ( warn.exec() == QMessageBox::Yes )
{
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
// Now run upgrade
Ipkg *ipkg = new Ipkg;
ipkg->setOption( "upgrade" );
InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ),
tr ( "Upgrade" ) );
- connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
+ connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) );
reloadDocuments = TRUE;
stack->addWidget( dlg, 3 );
stack->raiseWidget( dlg );
}
}
void MainWindow :: downloadPackage()
{
bool doUpdate = true;
if ( downloadEnabled )
{
// See if any packages are selected
bool found = false;
if ( serversList->currentText() != LOCAL_SERVER )
{
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 && !found;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
found = true;
}
}
// If user selected some packages then download the and store the locally
// otherwise, display dialog asking user what package to download from an http server
// and whether to install it
if ( found )
downloadSelectedPackages();
else
downloadRemotePackage();
}
else
{
doUpdate = false;
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
QString name = item->text();
int pos = name.find( "*" );
name.truncate( pos );
// if (there is a (installed), remove it
pos = name.find( "(installed)" );
if ( pos > 0 )
name.truncate( pos - 1 );
Package *p = mgr->getServer( serversList->currentText() )->getPackage( name );
QString msgtext;
msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() );
if ( QMessageBox::information( this, tr( "Are you sure?" ),
msgtext, tr( "No" ), tr( "Yes" ) ) == 1 )
{
doUpdate = true;
QFile f( p->getFilename() );
f.remove();
}
}
}
}
if ( doUpdate )
{
reloadData( 0x0 );
}
}
void MainWindow :: downloadSelectedPackages()
{
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
// Display dialog to user asking where to download the files to
bool ok = FALSE;
QString dir = "";
#ifdef QWS
// read download directory from config file
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
#endif
QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
if ( ok && !text.isEmpty() )
dir = text; // user entered something and pressed ok
else
return; // user entered nothing or pressed cancel
#ifdef QWS
// Store download directory in config file
cfg.writeEntry( "downloadDir", dir );
#endif
// Get starting directory
char initDir[PATH_MAX];
getcwd( initDir, PATH_MAX );
// Download each package
Ipkg ipkg;
- connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
+ connect( &ipkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&)));
ipkg.setOption( "download" );
ipkg.setRuntimeDirectory( dir );
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
ipkg.setPackage( item->text() );
ipkg.runIpkg( );
}
}
}
void MainWindow :: downloadRemotePackage()
{
// Display dialog
bool ok;
QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
if ( !ok || package.isEmpty() )
return;
// DownloadRemoteDlgImpl dlg( this, "Install", true );
// if ( dlg.exec() == QDialog::Rejected )
// return;
// grab details from dialog
// QString package = dlg.getPackageLocation();
InstallData *item = new InstallData();
item->option = "I";
item->packageName = package;
QList<InstallData> workingPackages;
workingPackages.setAutoDelete( TRUE );
workingPackages.append( item );
InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) );
- connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
+ connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) );
reloadDocuments = TRUE;
stack->addWidget( dlg, 3 );
stack->raiseWidget( dlg );
}
void MainWindow :: applyChanges()
{
stickyOption = "";
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
// Now for each selected item
// deal with it
QList<InstallData> workingPackages;
workingPackages.setAutoDelete( TRUE );
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
InstallData *instdata = dealWithItem( item );
if ( instdata )
workingPackages.append( instdata );
else
return;
}
}
if ( workingPackages.count() == 0 )
{
// Nothing to do
QMessageBox::information( this, tr( "Nothing to do" ),
tr( "No packages selected" ), tr( "OK" ) );
return;
}
// do the stuff
InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) );
- connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
+ connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) );
reloadDocuments = TRUE;
stack->addWidget( dlg, 3 );
stack->raiseWidget( dlg );
}
// decide what to do - either remove, upgrade or install
// Current rules:
// If not installed - install
// If installed and different version available - upgrade
// If installed and version up to date - remove
InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
{
QString name = item->text();
// Get package
Server *s = mgr->getServer( serversList->currentText() );
Package *p = s->getPackage( name );
// If the package has a filename then it is a local file
if ( p->isPackageStoredLocally() )
name = p->getFilename();
QString option;
QString dest = "root";
if ( !p->isInstalled() )
{
InstallData *newitem = new InstallData();
newitem->option = "I";
newitem->packageName = name;
return newitem;
}
else
{
InstallData *newitem = new InstallData();
newitem->option = "D";
// If local file, remove using package name, not filename
if ( p->isPackageStoredLocally() )
name = item->text();
if ( !p->isPackageStoredLocally() )
newitem->packageName = p->getInstalledPackageName();
else
newitem->packageName = name;
if ( p->getInstalledTo() )
{
newitem->destination = p->getInstalledTo();
}
else
{
newitem->destination = p->getLocalPackage()->getInstalledTo();
}
// Now see if version is newer or not
int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
// If the version requested is older and user selected a local ipk file, then reinstall the file
if ( p->isPackageStoredLocally() && val == -1 )
val = 0;
if ( val == -2 )
{
// Error - should handle
}
else if ( val == -1 )
{
// Version available is older - remove only
newitem->option = "D";
// If local file, remove using package name, not filename
if ( p->isPackageStoredLocally() )
name = item->text();
}
else
{
QString caption;
QString text;
QString secondButton;
QString secondOption;
if ( val == 0 )
{
// Version available is the same - option to remove or reinstall
caption = tr( "Do you wish to remove or reinstall\n%1?" );
text = tr( "Remove or ReInstall" );
secondButton = tr( "ReInstall" );
secondOption = "R"; // Internal action code, do not translate
}
else if ( val == 1 )
{
// Version available is newer - option to remove or upgrade
caption = tr( "Do you wish to remove or upgrade\n%1?" );
text = tr( "Remove or Upgrade" );
secondButton = tr( "Upgrade" );
secondOption = "U"; // Internal action code, do not translate
}
// Sticky option not implemented yet, but will eventually allow
// the user to say something like 'remove all'
if ( stickyOption == "" )
{
QString msgtext;
msgtext = caption.arg( ( const char * )name );
QuestionDlg dlg( text, msgtext, secondButton );
switch( dlg.exec() )
{
case 0: // Cancel
delete newitem;
return 0x0;
break;
case 1: // Remove
newitem->option = "D";
// If local file, remove using package name, not filename
if ( p->isPackageStoredLocally() )
name = item->text();
break;
case 2: // Reinstall or Upgrade
newitem->option = secondOption;
break;
}
}
else
{
// newitem->option = stickyOption;
}
}
// Check if we are reinstalling the same version
if ( newitem->option != "R" )
newitem->recreateLinks = true;
else
newitem->recreateLinks = false;
// User hit cancel (on dlg - assume remove)
return newitem;
}
}
void MainWindow :: reloadData( InstallDlgImpl *dlg )
{
stack->raiseWidget( progressWindow );
if ( dlg )
{
dlg->close();
delete dlg;
}
mgr->reloadServerData();
serverSelected( -1, FALSE );
#ifdef QWS
if ( reloadDocuments )
{
m_status->setText( tr( "Updating Launcher..." ) );
// Finally let the main system update itself
QCopEnvelope e("QPE/System", "linkChanged(QString)");
QString lf = QString::null;
e << lf;
}
#endif
stack->raiseWidget( networkPkgWindow );
}
void MainWindow :: letterPushed( QString t )
{
QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
if ( packagesList->firstChild() == 0 )
return;
QCheckListItem *item;
if ( start == 0 )
{
item = (QCheckListItem *)packagesList->firstChild();
start = top;
}
else
item = (QCheckListItem *)start->nextSibling();
if ( item == 0 )
item = (QCheckListItem *)packagesList->firstChild();
do
{
if ( item->text().lower().startsWith( t.lower() ) )
{
packagesList->setSelected( item, true );
packagesList->ensureItemVisible( item );
break;
}
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp
index 6e9dd99..b9dbb6e 100644
--- a/noncore/settings/aqpkg/settingsimpl.cpp
+++ b/noncore/settings/aqpkg/settingsimpl.cpp
@@ -1,364 +1,364 @@
/*
                This file is part of the OPIE Project
=. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk>
             .=l. Dan Williams <drw@handhelds.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.
*/
#include "settingsimpl.h"
#include "global.h"
/* OPIE */
#include <opie2/otabwidget.h>
#ifdef QWS
#include <qpe/config.h>
#include <qpe/resource.h>
#endif
#include <qpe/qpeapplication.h>
/* QT */
#include <qcheckbox.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qlistbox.h>
#include <qpushbutton.h>
/* STD */
#include <fstream>
#include <algorithm>
using namespace std;
SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
setCaption( tr( "Configuration" ) );
// Setup layout to make everything pretty
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setMargin( 2 );
layout->setSpacing( 4 );
// Setup tabs for all info
Opie::OTabWidget *tabwidget = new Opie::OTabWidget( this );
layout->addWidget( tabwidget );
tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) );
tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) );
tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) );
tabwidget->setCurrentTab( tr( "Servers" ) );
dataMgr = dataManager;
setupData();
changed = false;
newserver = false;
newdestination = false;
}
SettingsImpl :: ~SettingsImpl()
{
}
bool SettingsImpl :: showDlg()
{
QPEApplication::execDialog( this );
if ( changed )
dataMgr->writeOutIpkgConf();
return changed;
}
QWidget *SettingsImpl :: initServerTab()
{
QWidget *control = new QWidget( this );
QVBoxLayout *vb = new QVBoxLayout( control );
QScrollView *sv = new QScrollView( control );
vb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
QGridLayout *layout = new QGridLayout( container );
layout->setSpacing( 2 );
layout->setMargin( 4 );
servers = new QListBox( container );
servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
- connect( servers, SIGNAL( highlighted( int ) ), this, SLOT( editServer( int ) ) );
+ connect( servers, SIGNAL( highlighted(int) ), this, SLOT( editServer(int) ) );
layout->addMultiCellWidget( servers, 0, 0, 0, 1 );
QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) );
layout->addWidget( btn, 1, 0 );
btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) );
layout->addWidget( btn, 1, 1 );
QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container );
grpbox->layout()->setSpacing( 2 );
grpbox->layout()->setMargin( 4 );
layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
QLabel *label = new QLabel( tr( "Name:" ), grpbox );
grplayout->addWidget( label, 0, 0 );
servername = new QLineEdit( grpbox );
grplayout->addWidget( servername, 0, 1 );
label = new QLabel( tr( "Address:" ), grpbox );
grplayout->addWidget( label, 1, 0 );
serverurl = new QLineEdit( grpbox );
grplayout->addWidget( serverurl, 1, 1 );
active = new QCheckBox( tr( "Active Server" ), grpbox );
grplayout->addMultiCellWidget( active, 2, 2, 0, 1 );
btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) );
grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
return control;
}
QWidget *SettingsImpl :: initDestinationTab()
{
QWidget *control = new QWidget( this );
QVBoxLayout *vb = new QVBoxLayout( control );
QScrollView *sv = new QScrollView( control );
vb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
QGridLayout *layout = new QGridLayout( container );
layout->setSpacing( 2 );
layout->setMargin( 4 );
destinations = new QListBox( container );
destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
- connect( destinations, SIGNAL( highlighted( int ) ), this, SLOT( editDestination( int ) ) );
+ connect( destinations, SIGNAL( highlighted(int) ), this, SLOT( editDestination(int) ) );
layout->addMultiCellWidget( destinations, 0, 0, 0, 1 );
QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) );
layout->addWidget( btn, 1, 0 );
btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) );
layout->addWidget( btn, 1, 1 );
QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container );
grpbox->layout()->setSpacing( 2 );
grpbox->layout()->setMargin( 4 );
layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
QLabel *label = new QLabel( tr( "Name:" ), grpbox );
grplayout->addWidget( label, 0, 0 );
destinationname = new QLineEdit( grpbox );
grplayout->addWidget( destinationname, 0, 1 );
label = new QLabel( tr( "Location:" ), grpbox );
grplayout->addWidget( label, 1, 0 );
destinationurl = new QLineEdit( grpbox );
grplayout->addWidget( destinationurl, 1, 1 );
linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox );
grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 );
btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) );
grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
return control;
}
QWidget *SettingsImpl :: initProxyTab()
{
QWidget *control = new QWidget( this );
QVBoxLayout *vb = new QVBoxLayout( control );
QScrollView *sv = new QScrollView( control );
vb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
QGridLayout *layout = new QGridLayout( container );
layout->setSpacing( 2 );
layout->setMargin( 4 );
QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container );
grpbox->layout()->setSpacing( 2 );
grpbox->layout()->setMargin( 4 );
layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 );
QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
txtHttpProxy = new QLineEdit( grpbox );
grplayout->addWidget( txtHttpProxy );
chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox );
grplayout->addWidget( chkHttpProxyEnabled );
grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container );
grpbox->layout()->setSpacing( 2 );
grpbox->layout()->setMargin( 4 );
layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 );
grplayout = new QVBoxLayout( grpbox->layout() );
txtFtpProxy = new QLineEdit( grpbox );
grplayout->addWidget( txtFtpProxy );
chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox );
grplayout->addWidget( chkFtpProxyEnabled );
QLabel *label = new QLabel( tr( "Username:" ), container );
layout->addWidget( label, 2, 0 );
txtUsername = new QLineEdit( container );
layout->addWidget( txtUsername, 2, 1 );
label = new QLabel( tr( "Password:" ), container );
layout->addWidget( label, 3, 0 );
txtPassword = new QLineEdit( container );
layout->addWidget( txtPassword, 3, 1 );
QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container );
connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) );
layout->addMultiCellWidget( btn, 4, 4, 0, 1 );
return control;
}
void SettingsImpl :: setupData()
{
// add servers
QString serverName;
QListIterator<Server> it( dataMgr->getServerList() );
for ( ; it.current(); ++it )
{
serverName = it.current()->getServerName();
if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS )
continue;
servers->insertItem( serverName );
}
// add destinations
QListIterator<Destination> it2( dataMgr->getDestinationList() );
for ( ; it2.current(); ++it2 )
destinations->insertItem( it2.current()->getDestinationName() );
// setup proxy tab
txtHttpProxy->setText( dataMgr->getHttpProxy() );
txtFtpProxy->setText( dataMgr->getFtpProxy() );
txtUsername->setText( dataMgr->getProxyUsername() );
txtPassword->setText( dataMgr->getProxyPassword() );
chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() );
chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() );
}
//------------------ Servers tab ----------------------
void SettingsImpl :: editServer( int sel )
{
currentSelectedServer = sel;
Server *s = dataMgr->getServer( servers->currentText() );
if ( s )
{
serverName = s->getServerName();
servername->setText( s->getServerName() );
serverurl->setText( s->getServerUrl() );
active->setChecked( s->isServerActive() );
}
else
{
serverName = "";
servername->setText( "" );
serverurl->setText( "" );
active->setChecked( false );
}
}
void SettingsImpl :: newServer()
{
newserver = true;
servername->setText( "" );
serverurl->setText( "" );
servername->setFocus();
active->setChecked( true );
}
void SettingsImpl :: removeServer()
{
changed = true;
Server *s = dataMgr->getServer( servers->currentText() );
if ( s )
{
dataMgr->getServerList().removeRef( s );
servers->removeItem( currentSelectedServer );
}
}
void SettingsImpl :: changeServerDetails()
{
changed = true;
QString newName = servername->text();
// Convert any spaces to underscores
char *tmpStr = new char[newName.length() + 1];
for ( unsigned int i = 0 ; i < newName.length() ; ++i )
{
if ( newName[i] == ' ' )
tmpStr[i] = '_';
else
tmpStr[i] = newName[i].latin1();
}
tmpStr[newName.length()] = '\0';
newName = tmpStr;
delete tmpStr;
if ( !newserver )
{
Server *s = dataMgr->getServer( servers->currentText() );
if ( s )
{
// Update url
s->setServerUrl( serverurl->text() );
s->setActive( active->isChecked() );
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp
index 977c283..6b83bc9 100644
--- a/noncore/settings/backup/backuprestore.cpp
+++ b/noncore/settings/backup/backuprestore.cpp
@@ -1,247 +1,247 @@
#include "backuprestore.h"
#include "errordialog.h"
/* OPIE */
#include <opie2/ostorageinfo.h>
#include <qpe/qpeapplication.h>
/* QT */
#include <qapplication.h>
#include <qmultilineedit.h>
#include <qdir.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qlistview.h>
#include <qpushbutton.h>
#include <qheader.h>
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qmessagebox.h>
#include <qcombobox.h>
#include <qlist.h>
#include <stdlib.h>
#include <qregexp.h>
#include <qtextstream.h>
#include <qtextview.h>
/* STD */
#include <errno.h>
#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, WFlags fl)
: BackupAndRestoreBase(parent, name, fl)
{
backupList->header()->hide();
restoreList->header()->hide();
connect(backupButton, SIGNAL(clicked()),
this, SLOT(backup()));
connect(restoreButton, SIGNAL(clicked()),
this, SLOT(restore()));
- connect(backupList, SIGNAL(clicked( QListViewItem * )),
+ connect(backupList, SIGNAL(clicked(QListViewItem*)),
this, SLOT(selectItem(QListViewItem*)));
- connect(restoreSource, SIGNAL(activated( int )),
+ connect(restoreSource, SIGNAL(activated(int)),
this, SLOT(sourceDirChanged(int)));
connect(updateList, SIGNAL(clicked()),
this, SLOT( fileListUpdate()));
//add directorys for backing up
applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/");
selectItem(applicationSettings);
applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/");
selectItem(applicationSettings);
documents= new QListViewItem(backupList, "Documents", "", "Documents/");
selectItem(documents);
scanForApplicationSettings();
OStorageInfo storage;
backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" );
if ( storage.hasCf() )
{
backupLocations.insert( "CF", storage.cfPath() );
qDebug( "Cf Path: " + storage.cfPath() );
}
if ( storage.hasSd() )
{
backupLocations.insert( "SD", storage.sdPath() );
qDebug( " Sd Path: " + storage.sdPath() );
}
if ( storage.hasMmc() )
{
backupLocations.insert( "MMC", storage.mmcPath() );
qDebug( "Mmc Path: " + storage.mmcPath() );
}
Config config("BackupAndRestore");
//read last locations
config.setGroup("LastLocation");
QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" );
QString lastRestoreLocation = config.readEntry( "LastRestoreLocation", "" );
int locationIndex = 0;
QMap<QString, QString>::Iterator it;
for( it = backupLocations.begin(); it != backupLocations.end(); ++it )
{
storeToLocation->insertItem(it.key());
restoreSource->insertItem(it.key());
//check for last locations
if ( it.key() == lastStoreLocation )
storeToLocation->setCurrentItem( locationIndex );
if ( it.key() == lastRestoreLocation )
restoreSource->setCurrentItem( locationIndex );
locationIndex++;
}
// 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;
}
}
}
QPEApplication::showWidget( this );
}
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));
count++;
}
}
config.writeEntry("Total", count);
// Remove Temp File
if ( QFile::exists( tempFileName ) )
QFile::remove( tempFileName );
}
QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list)
{
while(item)
{
if(item->childCount() > 0)
getAllItems(item->firstChild(), list);
list.append(item);
item = item->nextSibling();
}
return list;
}
/**
* Selects and unselects the item by setting the HEADER_BACKUP to B or !.
* and changing the icon to match
* @param currentItem the item to swich the selection choice.
*/
void BackupAndRestore::selectItem(QListViewItem *currentItem)
{
if(!currentItem)
return;
if(currentItem->text(HEADER_BACKUP) == "B")
{
currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null"));
currentItem->setText(HEADER_BACKUP, "");
}
else
{
currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check"));
currentItem->setText(HEADER_BACKUP, "B");
}
}
void BackupAndRestore::scanForApplicationSettings()
{
QDir d( QDir::homeDirPath() + "/" + QString( applicationSettings->text(BACKUP_LOCATION) ) );
d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) )
{
//qDebug((d.path()+"/"+fi->fileName()).latin1());
if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) )
{
QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName());
selectItem(newItem);
}
++it;
}
}
/**
* The "Backup" button has been pressed. Get a list of all of the files that
* should be backed up. If there are no files, emit and error and exit.
* Determine the file name to store the backup in. Backup the file(s) using
* tar and gzip --best. Report failure or success
*/
void BackupAndRestore::backup()
{
QString backupFiles;
if(getBackupFiles(backupFiles, NULL) == 0)
{
QMessageBox::critical(this, "Message",
"No items selected.",QString("Ok") );
return;
}
setCaption(tr("Backup and Restore... working..."));
QString outputFile = backupLocations[storeToLocation->currentText()];
QDateTime datetime = QDateTime::currentDateTime();
QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') +
QString::number( datetime.date().day() ).rightJustify(2, '0');
outputFile += "/" + dateString;
QString t = outputFile;
int c = 1;
while(QFile::exists(outputFile + EXTENSION))
{
outputFile = t + QString("%1").arg(c);
c++;
}
diff --git a/noncore/settings/netsystemtime/mainwindow.cpp b/noncore/settings/netsystemtime/mainwindow.cpp
index 7df41d4..c995d6e 100644
--- a/noncore/settings/netsystemtime/mainwindow.cpp
+++ b/noncore/settings/netsystemtime/mainwindow.cpp
@@ -1,295 +1,295 @@
/*
                This file is part of the OPIE Project
=.
             .=l. Copyright (c) 2002 OPIE team <opie@handhelds.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.
*/
#include "mainwindow.h"
#include "timetabwidget.h"
#include "formattabwidget.h"
#include "settingstabwidget.h"
#include "ntptabwidget.h"
#include "predicttabwidget.h"
#include <qpe/config.h>
#include <qpe/datebookdb.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpedialog.h>
#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
#include <qpe/qcopenvelope_qws.h>
#endif
#include <qlayout.h>
#include <qmessagebox.h>
#include <qsocket.h>
#include <qstring.h>
#include <qtimer.h>
MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f )
: QDialog( 0x0, 0x0, TRUE, 0 )
{
setCaption( tr( "SystemTime" ) );
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setMargin( 2 );
layout->setSpacing( 4 );
// Create main tabbed control
mainWidget = new OTabWidget( this );
// Default object pointers to null
ntpProcess = 0x0;
ntpTab = 0x0;
// Add tab widgets
mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) );
mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) );
mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) );
mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) );
Config config( "ntp" );
config.setGroup( "settings" );
slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) );
slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) );
mainWidget->setCurrentTab( tr( "Time" ) );
layout->addWidget( mainWidget );
- connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
- this, SLOT(slotQCopReceive(const QCString&, const QByteArray&)) );
+ connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
+ this, SLOT(slotQCopReceive(const QCString&,const QByteArray&)) );
// Create NTP socket
ntpSock = new QSocket( this );
connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) );
slotProbeNTPServer();
// Create timer for automatic time lookups
ntpTimer = new QTimer( this );
// Connect everything together
connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) );
- connect( timeTab, SIGNAL(tzChanged(const QString &)), predictTab, SLOT(slotTZChanged(const QString &)) );
+ connect( timeTab, SIGNAL(tzChanged(const QString&)), predictTab, SLOT(slotTZChanged(const QString&)) );
connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) );
- connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime( int )) );
- connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat &)),
- timeTab, SLOT(slotDateFormatChanged(const DateFormat &)) );
+ connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime(int)) );
+ connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat&)),
+ timeTab, SLOT(slotDateFormatChanged(const DateFormat&)) );
connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) );
connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) );
connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) );
connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) );
- connect( predictTab, SIGNAL(setTime(const QDateTime &)), this, SLOT(slotSetTime(const QDateTime &)) );
+ connect( predictTab, SIGNAL(setTime(const QDateTime&)), this, SLOT(slotSetTime(const QDateTime&)) );
// Do initial time server check
slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) );
slotCheckNtp( -1 );
// Display app
//showMaximized();
(void)new QPEDialogListener(this);
}
MainWindow::~MainWindow()
{
if ( ntpProcess )
delete ntpProcess;
}
void MainWindow::accept()
{
// Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends)
{
QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
disableScreenSaver << 0 << 0 << 0;
}
// Update the systemtime
timeTab->saveSettings( TRUE );
// Save format options
formatTab->saveSettings( TRUE );
// Save settings options
settingsTab->saveSettings();
// Since time has changed quickly load in the DateBookDB to allow the alarm server to get a better
// grip on itself (example re-trigger alarms for when we travel back in time).
DateBookDB db;
// Turn back on the screensaver
QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
enableScreenSaver << -1 << -1 << -1;
// Exit app
qApp->quit();
}
void MainWindow::reject()
{
// Reset time settings
timeTab->saveSettings( FALSE );
// Send notifications but do not save settings
formatTab->saveSettings( FALSE );
// Exit app
qApp->quit();
}
void MainWindow::runNTP()
{
if ( !ntpDelayElapsed() && ntpInteractive )
{
QString msg = tr( "You asked for a delay of %1 minutes, but only %2 minutes elapsed since last lookup.<br>Continue?" ).arg( QString::number( ntpDelay ) ).arg( QString::number( _lookupDiff / 60 ) );
switch (
QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No )
)
{
case QMessageBox::Yes: break;
case QMessageBox::No: return;
default: return;
}
}
QString srv = settingsTab->ntpServer();
// Send information to time server tab if enabled
if ( ntpTabEnabled )
{
ntpTab->setStartTime( QDateTime::currentDateTime().toString() );
QString output = tr( "Running:\nntpdate " );
output.append( srv );
ntpTab->addNtpOutput( output );
}
if ( !ntpProcess )
{
ntpProcess = new OProcess();
connect( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)),
this, SLOT(slotNtpOutput(OProcess*,char*,int)) );
connect( ntpProcess, SIGNAL(processExited(OProcess*)),
this, SLOT(slotNtpFinished(OProcess*)) );
}
else
ntpProcess->clearArguments();
*ntpProcess << "ntpdate" << srv;
bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput );
if ( !ret )
{
QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) );
if ( ntpTabEnabled )
ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) );
}
}
bool MainWindow::ntpDelayElapsed()
{
// Determine if time elapsed is greater than time delay
Config config( "ntp" );
config.setGroup( "lookups" );
_lookupDiff = TimeConversion::toUTC( QDateTime::currentDateTime() ) - config.readNumEntry( "time", 0 );
if ( _lookupDiff < 0 )
return true;
return ( _lookupDiff - ( ntpDelay * 60) ) > 0;
}
void MainWindow::slotSetTime( const QDateTime &dt )
{
timeTab->setDateTime( dt );
}
void MainWindow::slotQCopReceive( const QCString &msg, const QByteArray & )
{
if ( msg == "ntpLookup(QString)" )
{
ntpInteractive = false;
runNTP();
}
if ( msg == "setPredictedTime(QString)" )
{
//setPredictTime();
}
}
void MainWindow::slotDisplayNTPTab( bool display )
{
ntpTabEnabled = display;
// Create widget if it hasn't needed
if ( display && !ntpTab )
{
ntpTab = new NTPTabWidget( mainWidget );
connect( ntpTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) );
}
// Display/hide tab
display ? mainWidget->addTab( ntpTab, "netsystemtime/ntptab", tr( "Time Server" ) )
: mainWidget->removePage( ntpTab );
}
void MainWindow::slotDisplayPredictTab( bool display )
{
predictTabEnabled = display;
// Create widget if it hasn't needed
if ( display && !predictTab )
{
}
// Display/hide tab
display ? mainWidget->addTab( predictTab, "netsystemtime/predicttab", tr( "Predict" ) )
: mainWidget->removePage( predictTab );
}
void MainWindow::slotGetNTPTime()
{
ntpInteractive = TRUE;
runNTP();
}
void MainWindow::slotTimerGetNTPTime()
{
ntpInteractive = FALSE;
runNTP();
}
void MainWindow::slotProbeNTPServer()
{
ntpSock->connectToHost( settingsTab->ntpServer(), 123 );
}
void MainWindow::slotNtpOutput( OProcess *, char *buffer, int buflen )
{
QString output = QString( buffer ).left( buflen );
ntpOutput.append( output );
if ( ntpTabEnabled )
ntpTab->addNtpOutput( output );
}
void MainWindow::slotNtpFinished( OProcess *p )
{
diff --git a/noncore/settings/netsystemtime/settingstabwidget.cpp b/noncore/settings/netsystemtime/settingstabwidget.cpp
index 2a7e28d..ad80e05 100644
--- a/noncore/settings/netsystemtime/settingstabwidget.cpp
+++ b/noncore/settings/netsystemtime/settingstabwidget.cpp
@@ -1,159 +1,159 @@
/*
                This file is part of the OPIE Project
=.
             .=l. Copyright (c) 2002 OPIE team <opie@handhelds.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.
*/
#include "settingstabwidget.h"
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qscrollview.h>
#include <qspinbox.h>
SettingsTabWidget::SettingsTabWidget( QWidget *parent )
: QWidget( parent, 0x0, 0 )
{
QVBoxLayout *tmpvb = new QVBoxLayout( this );
QScrollView *sv = new QScrollView( this );
tmpvb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
QGridLayout *layout = new QGridLayout( container );
layout->setMargin( 2 );
layout->setSpacing( 4 );
// Time server selector
layout->addWidget( new QLabel( tr( "Time server" ), container ), 0, 0 );
cbTimeServer = new QComboBox( TRUE, container );
layout->addMultiCellWidget( cbTimeServer, 1, 1, 0, 1 );
// Lookup delay selector
layout->addWidget( new QLabel( tr( "minutes between time updates" ), container ), 2, 1 );
sbNtpDelay = new QSpinBox( 1, 9999999, 1, container );
sbNtpDelay->setWrapping( TRUE );
sbNtpDelay->setMaximumWidth( 50 );
connect( sbNtpDelay, SIGNAL(valueChanged(int)), this, SIGNAL(ntpDelayChanged(int)) );
layout->addWidget( sbNtpDelay, 2, 0 );
// Prediction delay selector
layout->addWidget( new QLabel( tr( "minutes between prediction updates" ), container ), 3, 1 );
sbPredictDelay = new QSpinBox( 42, 9999999, 1, container );
sbPredictDelay->setWrapping( TRUE );
sbPredictDelay->setMaximumWidth( 50 );
layout->addWidget( sbPredictDelay, 3, 0 );
// Space filler
layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 4, 0 );
// Display time server information selector
chNtpTab = new QCheckBox( tr( "Display time server information" ), container );
- connect( chNtpTab, SIGNAL( toggled( bool ) ), this, SIGNAL( displayNTPTab( bool ) ) );
+ connect( chNtpTab, SIGNAL( toggled(bool) ), this, SIGNAL( displayNTPTab(bool) ) );
layout->addMultiCellWidget( chNtpTab, 5, 5, 0, 1 );
// Display time prediction information selector
chPredictTab = new QCheckBox( tr( "Display time prediction information" ), container );
- connect( chPredictTab, SIGNAL( toggled( bool ) ), this, SIGNAL( displayPredictTab( bool ) ) );
+ connect( chPredictTab, SIGNAL( toggled(bool) ), this, SIGNAL( displayPredictTab(bool) ) );
layout->addMultiCellWidget( chPredictTab, 6, 6, 0, 1 );
// Space filler
layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 );
// Initialize values
QString ntpSrvsFile = QPEApplication::qpeDir();
ntpSrvsFile.append( "etc/ntpservers" );
Config ntpSrvs( ntpSrvsFile, Config::File );
ntpSrvs.setGroup( "servers" );
int srvCount = ntpSrvs.readNumEntry( "count", 0 );
for ( int i = 0; i < srvCount; i++ )
{
ntpSrvs.setGroup( QString::number( i ) );
cbTimeServer->insertItem( ntpSrvs.readEntry( "name" ) );
}
if ( srvCount==0 )
cbTimeServer->insertItem( "time.fu-berlin.de" );
Config config( "ntp" );
config.setGroup( "settings" );
sbPredictDelay->setValue( config.readNumEntry( "minLookupDiff", 720 ) );
sbNtpDelay->setValue( config.readNumEntry( "ntpRefreshFreq", 1440 ) );
cbTimeServer->setCurrentItem( config.readNumEntry( "ntpServer", 0 ) );
chNtpTab->setChecked( config.readBoolEntry( "displayNtpTab", FALSE ) );
chPredictTab->setChecked( config.readBoolEntry( "displayPredictTab", FALSE ) );
}
SettingsTabWidget::~SettingsTabWidget()
{
}
void SettingsTabWidget::saveSettings()
{
int srvCount = cbTimeServer->count();
bool serversChanged = TRUE;
int curSrv = cbTimeServer->currentItem();
QString edit = cbTimeServer->currentText();
for ( int i = 0; i < srvCount; i++ )
{
if ( edit == cbTimeServer->text( i ) )
serversChanged = FALSE;
}
if ( serversChanged )
{
QString ntpSrvsFile = QPEApplication::qpeDir();
ntpSrvsFile.append( "etc/ntpservers" );
Config ntpSrvs( ntpSrvsFile, Config::File );
ntpSrvs.setGroup( "servers" );
ntpSrvs.writeEntry( "count", ++srvCount );
ntpSrvs.setGroup( "0" );
ntpSrvs.writeEntry( "name", edit );
curSrv = 0;
for ( int i = 1; i < srvCount; i++ )
{
// qDebug( "ntpSrvs[%i/%i]=%s", i, srvCount, cbTimeServer->text( i ).latin1() );
ntpSrvs.setGroup( QString::number( i ) );
ntpSrvs.writeEntry( "name", cbTimeServer->text( i-1 ) );
}
}
Config config( "ntp", Config::User );
config.setGroup( "settings" );
config.writeEntry( "ntpServer", curSrv );
config.writeEntry( "minLookupDiff", sbPredictDelay->value() );
config.writeEntry( "ntpRefreshFreq", sbNtpDelay->value() );
config.writeEntry( "displayNtpTab", chNtpTab->isChecked() );
config.writeEntry( "displayPredictTab", chPredictTab->isChecked() );
}
QString SettingsTabWidget::ntpServer()
{
return cbTimeServer->currentText();
}
diff --git a/noncore/settings/netsystemtime/timetabwidget.cpp b/noncore/settings/netsystemtime/timetabwidget.cpp
index 6f24462..1ea460e 100644
--- a/noncore/settings/netsystemtime/timetabwidget.cpp
+++ b/noncore/settings/netsystemtime/timetabwidget.cpp
@@ -1,292 +1,292 @@
/*
                This file is part of the OPIE Project
=.
             .=l. Copyright (c) 2002 OPIE team <opie@handhelds.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.
*/
#include "timetabwidget.h"
#include <qpe/config.h>
#include <qpe/datebookmonth.h>
#include <qpe/global.h>
#include <qpe/resource.h>
#include <qpe/tzselect.h>
#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
#include <qpe/qcopenvelope_qws.h>
#endif
#include <qcombobox.h>
#include <qdatetime.h>
#include <qframe.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qscrollview.h>
#include <qspinbox.h>
#include <stdlib.h>
#include <sys/time.h>
static const int ValueAM = 0;
static const int ValuePM = 1;
TimeTabWidget::TimeTabWidget( QWidget *parent )
: QWidget( parent, 0x0, 0 )
{
// Synchronize HW clock to systemtime
// This app will update systemtime
// - if Cancel is clicked, will reset systemtime to HW clock's time
// - if Ok is clicked, will leave systemtime as is
system("/sbin/hwclock --systohc --utc");
QVBoxLayout *tmpvb = new QVBoxLayout( this );
QScrollView *sv = new QScrollView( this );
tmpvb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
QGridLayout *layout = new QGridLayout( container );
layout->setMargin( 2 );
layout->setSpacing( 4 );
// Hours
layout->addMultiCellWidget( new QLabel( tr( "Hour" ), container ), 1, 1, 0, 1 );
sbHour = new QSpinBox( container );
sbHour->setWrapping( TRUE );
layout->addMultiCellWidget( sbHour, 2, 2, 0, 1 );
// Minutes
layout->addMultiCellWidget( new QLabel( tr( "Minute" ), container ), 1, 1, 2, 3 );
sbMin = new QSpinBox( container );
sbMin->setWrapping( TRUE );
sbMin->setMinValue( 0 );
sbMin->setMaxValue( 59 );
layout->addMultiCellWidget( sbMin, 2, 2, 2, 3 );
// AM/PM
cbAmpm = new QComboBox( container );
cbAmpm->insertItem( tr( "AM" ), ValueAM );
cbAmpm->insertItem( tr( "PM" ), ValuePM );
layout->addMultiCellWidget( cbAmpm, 2, 2, 4, 5 );
// Date
layout->addWidget( new QLabel( tr( "Date" ), container ), 4, 0 );
btnDate = new DateButton( TRUE, container );
layout->addMultiCellWidget( btnDate, 4, 4, 1, 5 );
// Timezone
layout->addMultiCellWidget( new QLabel( tr( "Time zone" ), container ), 6, 6, 0, 1 );
selTimeZone = new TimeZoneSelector( container );
- connect( selTimeZone, SIGNAL(signalNewTz(const QString &)), this, SLOT(slotTZChanged(const QString &)) );
+ connect( selTimeZone, SIGNAL(signalNewTz(const QString&)), this, SLOT(slotTZChanged(const QString&)) );
layout->addMultiCellWidget( selTimeZone, 6, 6, 2, 5 );
// Space filler
layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 );
// Set NTP time button
QPushButton *pb = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ),
tr( "Get time from the network" ), container );
connect( pb, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) );
layout->addMultiCellWidget( pb, 8, 8, 0, 5 );
// Set predicted time button
pb = new QPushButton( Resource::loadPixmap( "netsystemtime/predicttab" ), tr( "Set predicted time" ),
container );
connect( pb, SIGNAL(clicked()), this, SIGNAL(getPredictedTime()) );
layout->addMultiCellWidget( pb, 9, 9, 0, 5 );
// Space filler at bottom of widget
layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 10, 0 );
// Initialize values
Config config( "locale" );
config.setGroup( "Location" );
selTimeZone->setCurrentZone( config.readEntry( "Timezone", "America/New_York" ) );
use12HourTime = FALSE;
setDateTime( QDateTime::currentDateTime() );
}
TimeTabWidget::~TimeTabWidget()
{
}
void TimeTabWidget::saveSettings( bool commit )
{
if ( commit )
{
// Set timezone and announce to world
QString tz = selTimeZone->currentZone();
Config config("locale");
config.setGroup( "Location" );
config.writeEntry( "Timezone", tz );
setenv( "TZ", tz, 1 );
QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" );
setTimeZone << tz;
// If controls have a valid date & time, update systemtime
int hour = sbHour->value();
if ( use12HourTime && cbAmpm->currentItem() == ValuePM )
hour += 12;
QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) );
setSystemTime( dt );
}
else
{
// Reset systemtime to hardware clock (i.e. undo any changes made by this app)
system("/sbin/hwclock --hctosys --utc");
}
}
void TimeTabWidget::setDateTime( const QDateTime &dt )
{
// Set time
QTime t = dt.time();
if( use12HourTime )
{
int show_hour = t.hour();
if ( t.hour() >= 12 )
{
show_hour -= 12;
cbAmpm->setCurrentItem( ValuePM );
}
else
{
cbAmpm->setCurrentItem( ValueAM );
}
if ( show_hour == 0 )
show_hour = 12;
sbHour->setValue( show_hour );
}
else
{
sbHour->setValue( t.hour() );
}
sbMin->setValue( t.minute() );
// Set date
btnDate->setDate( dt.date() );
}
void TimeTabWidget::setSystemTime( const QDateTime &dt )
{
// Set system clock
if ( dt.isValid() )
{
struct timeval myTv;
int t = TimeConversion::toUTC( dt );
myTv.tv_sec = t;
myTv.tv_usec = 0;
if ( myTv.tv_sec != -1 )
::settimeofday( &myTv, 0 );
}
}
void TimeTabWidget::slotUse12HourTime( int i )
{
use12HourTime = (i == 1);
cbAmpm->setEnabled( use12HourTime );
int show_hour = sbHour->value();
if ( use12HourTime )
{
sbHour->setMinValue( 1 );
sbHour->setMaxValue( 12 );
if ( show_hour >= 12 )
{
show_hour -= 12;
cbAmpm->setCurrentItem( ValuePM );
}
else
{
cbAmpm->setCurrentItem( ValueAM );
}
if ( show_hour == 0 )
show_hour = 12;
}
else
{
sbHour->setMinValue( 0 );
sbHour->setMaxValue( 23 );
if ( cbAmpm->currentItem() == ValuePM )
{
show_hour += 12;
if ( show_hour == 24 )
show_hour = 0;
}
}
sbHour->setValue( show_hour );
}
void TimeTabWidget::slotDateFormatChanged( const DateFormat &df )
{
btnDate->setDateFormat( df );
}
void TimeTabWidget::slotWeekStartChanged( int monday )
{
btnDate->setWeekStartsMonday( monday );
}
void TimeTabWidget::slotTZChanged( const QString &newtz )
{
// If controls have a valid date & time, update systemtime
int hour = sbHour->value();
if ( use12HourTime && cbAmpm->currentItem() == ValuePM )
hour += 12;
QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) );
setSystemTime( dt );
QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" );
setTimeZone << newtz;
// Set system timezone
QString currtz = getenv( "TZ" );
setenv( "TZ", newtz, 1 );
// Get new date/time
hour = sbHour->value();
if ( use12HourTime && cbAmpm->currentItem() == ValuePM )
hour += 12;
dt = QDateTime::currentDateTime();
// Reset system timezone
if ( !currtz.isNull() )
{
setenv( "TZ", currtz, 1 );
}
// Set controls to new time
setDateTime( dt );
emit tzChanged( newtz );
}
diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
index 698dfd3..ff65424 100644
--- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
@@ -1,104 +1,104 @@
#include "interfaceinformationimp.h"
#include "interfaceadvanced.h"
/* OPIE */
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
/* QT */
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qgroupbox.h>
#include <qmessagebox.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 &)));
+ 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());
QPEApplication::showWidget( a );
}
/**
* 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/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index b0a1dd9..1e16b97 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,464 +1,464 @@
#include "mainwindowimp.h"
#include "addconnectionimp.h"
#include "interfaceinformationimp.h"
#include "interfacesetupimp.h"
#include "interfaces.h"
#include "module.h"
/* OPIE */
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
/* QT */
#include <qpushbutton.h>
#include <qlistbox.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qheader.h>
#include <qlabel.h>
#include <qtabwidget.h> // in order to disable the profiles tab
#include <qmessagebox.h>
#if QT_VERSION < 300
#include <qlist.h>
#else
#include <qptrlist.h>
#endif
#include <qdir.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qregexp.h>
/* STD */
#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, WFlags) : 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 );
// 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 *)));
+ 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.
*/
MainWindowImp::~MainWindowImp()
{
// Save profiles.
Config cfg("NetworkSetup");
cfg.setGroup("General");
cfg.writeEntry("Profiles", profiles.join(" "));
// Delete all interfaces that don't have owners.
QMap<Interface*, QListViewItem*>::Iterator iIt;
for( iIt = items.begin(); iIt != items.end(); ++iIt )
{
if(iIt.key()->getModuleOwner() == NULL)
delete iIt.key();
}
#ifdef QWS
// Delete Modules and Libraries
QMap<Module*, QLibrary*>::Iterator it;
for( it = libraries.begin(); it != libraries.end(); ++it )
{
delete it.key();
// I wonder why I can't delete the libraries
// What fucking shit this is.
//delete it.data();
}
#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 *)));
+ 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 *)));
+ connect(i, SIGNAL(updateInterface(Interface*)),
+ this, SLOT(updateInterface(Interface*)));
}
}
}
}
/**
* Load all modules that are found in the path
* @param path a directory that is scaned for any plugins that can be loaded
* and attempts to load them
*/
void MainWindowImp::loadModules(const QString &path)
{
#ifdef DEBUG
qDebug("MainWindowImp::loadModules: %s", path.latin1());
#endif
QDir d(path);
if(!d.exists())
return;
// 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);
if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) )
{
QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
if(!item)
return;
for( it = libraries.begin(); it != libraries.end(); ++it )
{
if(it.key())
{
Interface *i = (it.key())->addNewInterface(item->text(0));
if(i)
{
qDebug("iface name %s",i->getInterfaceName().latin1());
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
}
}
}
}
}
/**
* Prompt the user to see if they really want to do this.
* If they do then remove from the list and unload.
*/
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;
@@ -523,226 +523,226 @@ void MainWindowImp::informationClicked()
}
/**
* 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())
typeName = "connect_no";
// Actually try to use the Module
if(i->getModuleOwner() != NULL)
typeName = i->getModuleOwner()->getPixmapName(i);
#ifdef QWS
item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName)));
#else
item->setPixmap(1, (SmallIcon(typeName)));
#endif
item->setText(2, i->getHardwareName());
item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
}
void MainWindowImp::newProfileChanged(const QString& newText)
{
if(newText.length() > 0)
newProfileButton->setEnabled(true);
else
newProfileButton->setEnabled(false);
}
/**
* Adds a new profile to the list of profiles.
* Don't add profiles that already exists.
* Appends to the list and QStringList
*/
void MainWindowImp::addProfile()
{
QString newProfileName = newProfile->text();
if(profiles.grep(newProfileName).count() > 0)
{
QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok);
return;
}
profiles.append(newProfileName);
profilesList->insertItem(newProfileName);
}
/**
* Removes the currently selected profile in the combo.
* Doesn't delete if there are less then 2 profiles.
*/
void MainWindowImp::removeProfile()
{
if(profilesList->count() <= 1)
{
QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok);
return;
}
QString profileToRemove = profilesList->currentText();
if(profileToRemove == "All")
{
QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok);
return;
}
// Can't remove the curent profile
if(profileToRemove == currentProfileLabel->text())
{
QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok);
return;
}
if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
{
profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
profilesList->clear();
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
profilesList->insertItem((*it));
// Remove any interface settings and mappings.
Interfaces interfaces;
// Go through them one by one
QMap<Interface*, QListViewItem*>::Iterator it;
for( it = items.begin(); it != items.end(); ++it )
{
QString interfaceName = it.key()->getInterfaceName();
qDebug(interfaceName.latin1());
if(interfaces.setInterface(interfaceName + "_" + profileToRemove))
{
interfaces.removeInterface();
if(interfaces.setMapping(interfaceName))
{
if(profilesList->count() == 1)
interfaces.removeMapping();
else
{
interfaces.removeMap("map", interfaceName + "_" + profileToRemove);
}
}
interfaces.write();
break;
}
}
}
}
/**
* 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&)) );
+ 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/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp
index 7d21605..3b2393c 100644
--- a/noncore/settings/networksettings/ppp/edit.cpp
+++ b/noncore/settings/networksettings/ppp/edit.cpp
@@ -383,386 +383,386 @@ IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char
staticadd_rb = new QRadioButton(box);
staticadd_rb->setText(tr("Static IP address"));
rb->insert(dynamicadd_rb, 0);
rb->insert(staticadd_rb, 1);
QWhatsThis::add(staticadd_rb,
tr("Select this option when your computer has a\n"
"fixed internet address (IP). Most computers\n"
"don't have this, so you should probably select\n"
"dynamic IP addressing unless you know what you\n"
"are doing."));
QWidget *ipWidget = new QWidget(box);
QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2);
ipLayout->setSpacing( 2 );//KDialog::spacingHint());
ipaddress_label = new QLabel(tr("IP address:"), ipWidget);
QString tmp = tr("If your computer has a permanent internet\n"
"address, you must supply your IP address here.");
ipLayout->addWidget(ipaddress_label, 0, 0);
ipaddress_l = new IPLineEdit(ipWidget);
ipLayout->addWidget(ipaddress_l, 0, 1);
QWhatsThis::add(ipaddress_label,tmp);
QWhatsThis::add(ipaddress_l,tmp);
sub_label = new QLabel(tr("Subnet mask:"), ipWidget);
tmp = tr("<p>If your computer has a static Internet address,\n"
"you must supply a network mask here. In almost\n"
"all cases this netmask will be <b>255.255.255.0</b>,\n"
"but your mileage may vary.\n"
"\n"
"If unsure, contact your Internet Service Provider");
ipLayout->addWidget(sub_label, 1, 0);
subnetmask_l = new IPLineEdit(ipWidget);
ipLayout->addWidget(subnetmask_l, 1, 1);
QWhatsThis::add(sub_label,tmp);
QWhatsThis::add(subnetmask_l,tmp);
autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this);
autoname->setChecked(_pppdata->autoname());
connect(autoname,SIGNAL(toggled(bool)),
this,SLOT(autoname_t(bool)));
QWhatsThis::add(autoname,
tr("<p>Whenever you connect, this reconfigures\n"
"your hostname to match the IP address you\n"
"got from the PPP server. This may be useful\n"
"if you need to use a protocol which depends\n"
"on this information, but it can also cause several\n"
"<a href=\"kppp-7.html#autohostname\">problems</a>.\n"
"\n"
"Don't enable this unless you really need it."));
topLayout->addWidget(box);
topLayout->addWidget(autoname);
topLayout->addStretch();
//load info from gpppdata
if(!isnewaccount)
{
if(_pppdata->ipaddr() == "0.0.0.0" &&
_pppdata->subnetmask() == "0.0.0.0")
{
dynamicadd_rb->setChecked(true);
hitIPSelect(0);
autoname->setChecked(_pppdata->autoname());
}
else
{
ipaddress_l->setText(_pppdata->ipaddr());
subnetmask_l->setText(_pppdata->subnetmask());
staticadd_rb->setChecked(true);
autoname->setChecked(false);
}
}
else
{
dynamicadd_rb->setChecked(true);
hitIPSelect(0);
}
}
void IPWidget::autoname_t(bool on)
{
static bool was_warned = false;
// big-fat warning when selecting the auto configure hostname option
if(on && !was_warned)
{
QMessageBox::information(this,
tr("Selecting this option might cause some weird "
"problems with the X-server and applications "
"while kppp is connected. Don't use it until "
"you know what you are doing!\n"
"For more information take a look at the "
"handbook (or help) in the section \"Frequently "
"asked questions\"."),
tr("Warning"));
was_warned = true;
}
}
void IPWidget::save()
{
if(dynamicadd_rb->isChecked())
{
_pppdata->setIpaddr("0.0.0.0");
_pppdata->setSubnetmask("0.0.0.0");
}
else
{
_pppdata->setIpaddr(ipaddress_l->text());
_pppdata->setSubnetmask(subnetmask_l->text());
}
_pppdata->setAutoname(autoname->isChecked());
}
void IPWidget::hitIPSelect( int i )
{
if(i == 0)
{
ipaddress_label->setEnabled(false);
sub_label->setEnabled(false);
ipaddress_l->setEnabled(false);
subnetmask_l->setEnabled(false);
}
else
{
ipaddress_label->setEnabled(true);
sub_label->setEnabled(true);
ipaddress_l->setEnabled(true);
subnetmask_l->setEnabled(true);
}
}
DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
: QWidget(parent, name), _pppdata(pd)
{
QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );
dnsdomain_label = new QLabel(tr("Domain name:"), this);
tl->addWidget(dnsdomain_label, 0, 0);
dnsdomain = new QLineEdit(this);
tl->addWidget(dnsdomain, 0, 1);
QString tmp = tr("If you enter a domain name here, this domain\n"
"name is used for your computer while you are\n"
"connected. When the connection is closed, the\n"
"original domain name of your computer is\n"
"restored.\n"
"\n"
"If you leave this field blank, no changes are\n"
"made to the domain name.");
QWhatsThis::add(dnsdomain_label,tmp);
QWhatsThis::add(dnsdomain,tmp);
conf_label = new QLabel(tr("Configuration:"), this);
tl->addWidget(conf_label, 1, 0);
bg = new QButtonGroup("Group", this);
connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int)));
bg->hide();
autodns = new QRadioButton(tr("Automatic"), this);
bg->insert(autodns, 0);
tl->addWidget(autodns, 1, 1);
if(!_pppdata->pppdVersionMin(2, 3, 7))
autodns->setEnabled(false);
mandns = new QRadioButton(tr("Manual"), this);
bg->insert(mandns, 1);
tl->addWidget(mandns, 2, 1);
dns_label = new QLabel(tr("DNS IP address:"), this);
tl->addWidget(dns_label, 3, 0);
QHBoxLayout *l2 = new QHBoxLayout;
tl->addLayout(l2, 3, 1);
dnsipaddr = new IPLineEdit(this);
connect(dnsipaddr, SIGNAL(returnPressed()),
SLOT(adddns()));
- connect(dnsipaddr, SIGNAL(textChanged(const QString &)),
- SLOT(DNS_Edit_Changed(const QString &)));
+ connect(dnsipaddr, SIGNAL(textChanged(const QString&)),
+ SLOT(DNS_Edit_Changed(const QString&)));
l2->addWidget(dnsipaddr, 1);
l2->addStretch(1);
tmp = tr("<p>Allows you to specify a new DNS server to be\n"
"used while you are connected. When the\n"
"connection is closed, this DNS entry will be\n"
"removed again.\n"
"\n"
"To add a DNS server, type in the IP address of\n"
"the DNS server here and click on <b>Add</b>");
QWhatsThis::add(dns_label, tmp);
QWhatsThis::add(dnsipaddr, tmp);
QHBoxLayout *l1 = new QHBoxLayout;
tl->addLayout(l1, 4, 1);
add = new QPushButton(tr("Add"), this);
connect(add, SIGNAL(clicked()), SLOT(adddns()));
l1->addWidget(add);
// l1->addStretch(1);
QWhatsThis::add(add,
tr("Click this button to add the DNS server\n"
"specified in the field above. The entry\n"
"will then be added to the list below"));
remove = new QPushButton(tr("Remove"), this);
connect(remove, SIGNAL(clicked()), SLOT(removedns()));
l1->addWidget(remove);
QWhatsThis::add(remove,
tr("Click this button to remove the selected DNS\n"
"server entry from the list below"));
servers_label = new QLabel(tr("DNS address list:"), this);
servers_label->setAlignment(AlignTop|AlignLeft);
tl->addWidget(servers_label, 5, 0);
dnsservers = new QListBox(this);
dnsservers->setMinimumSize(150, 80);
connect(dnsservers, SIGNAL(highlighted(int)),
SLOT(DNS_Entry_Selected(int)));
tl->addWidget(dnsservers, 5, 1);
tmp = tr("<p>This shows all defined DNS servers to use\n"
"while you are connected. Use the <b>Add</b> and\n"
"<b>Remove</b> buttons to modify the list");
QWhatsThis::add(servers_label,tmp);
QWhatsThis::add(dnsservers,tmp);
exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this);
// exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this);
exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled());
tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter);
QWhatsThis::add(exdnsdisabled_toggle,
tr("<p>When this option is selected, all DNS\n"
"servers specified in <tt>/etc/resolv.conf</tt> are\n"
"temporary disabled while the dialup connection\n"
"is established. After the connection is\n"
"closed, the servers will be re-enabled\n"
"\n"
"Typically, there is no reason to use this\n"
"option, but it may become useful under \n"
"some circumstances."));
// restore data if editing
if(!isnewaccount)
{
dnsservers->insertStringList(_pppdata->dns());
dnsdomain->setText(_pppdata->domain());
}
int mode = _pppdata->autoDNS() ? 0 : 1;
bg->setButton(mode);
DNS_Mode_Selected(mode);
tl->activate();
}
void DNSWidget::DNS_Edit_Changed(const QString &text)
{
QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+");
add->setEnabled(text.find(r) != -1);
}
void DNSWidget::DNS_Entry_Selected(int)
{
remove->setEnabled(true);
}
void DNSWidget::DNS_Mode_Selected(int mode)
{
bool on = (mode == 1);
dns_label->setEnabled(on);
servers_label->setEnabled(on);
dnsipaddr->setText("");
dnsipaddr->setEnabled(on);
add->setEnabled(false);
remove->setEnabled(dnsservers->count()>0 && on);
dnsservers->clearSelection();
dnsservers->setEnabled(on);
dnsservers->triggerUpdate(false);
}
void DNSWidget::save()
{
_pppdata->setAutoDNS(bg->id(bg->selected()) == 0);
QStringList serverlist;
for(uint i=0; i < dnsservers->count(); i++)
serverlist.append(dnsservers->text(i));
_pppdata->setDns(serverlist);
// strip leading dot
QString s(dnsdomain->text());
if(s.left(1) == ".")
_pppdata->setDomain(s.mid(1));
else
_pppdata->setDomain(dnsdomain->text());
_pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked());
}
void DNSWidget::adddns()
{
if(dnsservers->count() < MAX_DNS_ENTRIES)
{
dnsservers->insertItem(dnsipaddr->text());
dnsipaddr->setText("");
}
}
void DNSWidget::removedns()
{
int i;
i = dnsservers->currentItem();
if(i != -1)
dnsservers->removeItem(i);
remove->setEnabled(dnsservers->count()>0);
}
//
// GatewayWidget
//
GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
: QWidget(parent, name), _pppdata(pd)
{
QVBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->setSpacing( 2 );
topLayout->setMargin( 0 );
box = new QVGroupBox(tr("Configuration"), this);
rb = new QButtonGroup(this);
rb->hide();
connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int)));
defaultgateway = new QRadioButton(box);
defaultgateway->setText(tr("Default gateway"));
rb->insert(defaultgateway, 0);
QWhatsThis::add(defaultgateway,
tr("This makes the PPP peer computer (the computer\n"
"you are connected to with your modem) to act as\n"
"a gateway. Your computer will send all packets not\n"
"going to a computer inside your local net to this\n"
"computer, which will route these packets.\n"
"\n"
"This is the default for most ISPs, so you should\n"
"probably leave this option on."));
staticgateway = new QRadioButton(box);
staticgateway->setText(tr("Static gateway"));
rb->insert(staticgateway, 1);
QWhatsThis::add(staticgateway,
tr("<p>Allows you to specify which computer you want\n"
"to use as gateway (see <i>Default Gateway</i> above)"));
QHBox *gateBox = new QHBox(box);
gate_label = new QLabel(tr("Gateway IP address:"), gateBox);
gatewayaddr = new IPLineEdit(gateBox);
defaultroute = new QCheckBox(tr("Assign the default route to this gateway"),
this);
QWhatsThis::add(defaultroute,
tr("If this option is enabled, all packets not\n"
"going to the local net are routed through\n"
"the PPP connection.\n"
"\n"
"Normally, you should turn this on"));
topLayout->addWidget(box);
@@ -995,217 +995,217 @@ void ScriptWidget::addButton()
case ScriptEdit::Timeout:
stl->insertItem("Timeout");
sl->insertItem(se->text());
break;
case ScriptEdit::Password:
stl->insertItem("Password");
sl->insertItem(se->text());
break;
case ScriptEdit::ID:
stl->insertItem("ID");
sl->insertItem(se->text());
break;
case ScriptEdit::Prompt:
stl->insertItem("Prompt");
sl->insertItem(se->text());
break;
case ScriptEdit::PWPrompt:
stl->insertItem("PWPrompt");
sl->insertItem(se->text());
break;
case ScriptEdit::LoopStart:
stl->insertItem("LoopStart");
sl->insertItem(se->text());
break;
case ScriptEdit::LoopEnd:
stl->insertItem("LoopEnd");
sl->insertItem(se->text());
break;
case ScriptEdit::Scan:
stl->insertItem("Scan");
sl->insertItem(se->text());
break;
case ScriptEdit::Save:
stl->insertItem("Save");
sl->insertItem(se->text());
break;
default:
break;
}
//get the scrollbar adjusted, and scroll the list so we can see what
//we're adding to
adjustScrollBar();
slb->setValue(slb->maxValue());
//clear the text in the entry box
se->setText("");
}
void ScriptWidget::insertButton()
{
//exit if there is no highlighted item, or we've reached the
//maximum entries in the script list
if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1))
return;
switch(se->type())
{
case ScriptEdit::Expect:
stl->insertItem("Expect", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Send:
stl->insertItem("Send", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::SendNoEcho:
stl->insertItem("SendNoEcho", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Pause:
stl->insertItem("Pause", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Hangup:
stl->insertItem("Hangup", stl->currentItem());
sl->insertItem("", sl->currentItem());
break;
case ScriptEdit::Answer:
stl->insertItem("Answer", stl->currentItem());
sl->insertItem("", sl->currentItem());
break;
case ScriptEdit::Timeout:
stl->insertItem("Timeout", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Password:
stl->insertItem("Password", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::ID:
stl->insertItem("ID", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Prompt:
stl->insertItem("Prompt", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::PWPrompt:
stl->insertItem("PWPrompt", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::LoopStart:
stl->insertItem("LoopStart", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::LoopEnd:
stl->insertItem("LoopEnd", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Scan:
stl->insertItem("Scan", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Save:
stl->insertItem("Save", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
default:
break;
}
adjustScrollBar();
se->setText("");
}
void ScriptWidget::removeButton()
{
if(sl->currentItem() >= 0)
{
int stlc = stl->currentItem();
sl->removeItem(sl->currentItem());
stl->removeItem(stlc);
adjustScrollBar();
insert->setEnabled(sl->currentItem() != -1);
remove->setEnabled(sl->currentItem() != -1);
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Used to specify a new phone number
//
/////////////////////////////////////////////////////////////////////////////
PhoneNumberDialog::PhoneNumberDialog(QWidget *parent)
: QDialog(parent,"PhoneNumberDialog",true)
{
setCaption( tr("Add Phone Number") );
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setSpacing( 3 );
layout->setMargin( 3 );
// QHBox *hbox = new QHBox(this);
// setMainWidget(hbox);
// hbox->setSpacing( 2 );//KDialog::spacingHint());
QLabel *label = new QLabel(this, tr("Enter a phone number:"));
layout->addWidget( label );
le = new QLineEdit(this, "lineEdit");
layout->addWidget( le );
- connect(le, SIGNAL(textChanged(const QString &)),
- this, SLOT(textChanged(const QString &)));
+ connect(le, SIGNAL(textChanged(const QString&)),
+ this, SLOT(textChanged(const QString&)));
le->setFocus();
textChanged("");
}
QString PhoneNumberDialog::phoneNumber()
{
QString s = le->text();
return s;
}
void PhoneNumberDialog::textChanged(const QString &s)
{
// enableButtonOK(s.length() > 0);
}
//#include "edit.moc"
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp
index ff1b11b..81dab38 100644
--- a/noncore/settings/networksettings/ppp/general.cpp
+++ b/noncore/settings/networksettings/ppp/general.cpp
@@ -1,280 +1,280 @@
/*
* 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 "general.h"
#include "interfaceppp.h"
#include "modeminfo.h"
#include "modemcmds.h"
#include "pppdata.h"
/* OPIE */
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
/* QT */
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qslider.h>
#include <qspinbox.h>
#include <qwhatsthis.h>
/* STD */
#include <termios.h>
#include <string.h>
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(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);
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 &) ) );
+ // connect(modemdevice, SIGNAL(textChanged(const QString&) ),
+ // SLOT( setmodemdc(const QString&) ) );
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(tr("&Flow control:"), this);
tl->addWidget(label1, 2, 0);
flowcontrol = new QComboBox(false, this);
label1->setBuddy(flowcontrol);
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(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, 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(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, 4, 1);
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(_pppdata->enter() == enter->text(i))
enter->setCurrentItem(i);
}
tl->addRowSpacing(5, 10);
//Modem Lock File
modemlockfile = new QCheckBox(tr("&Use lock file"), this);
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,
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(tr("Modem &timeout:"));
// modemtimeout->setRange(1, 120, 1);
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, 7, 7, 0, 1);
QWhatsThis::add(modemtimeout,
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(_pppdata->enter() == enter->text(i))
enter->setCurrentItem(i);
}
for(int i=0; i <= modemdevice->count()-1; i++)
{
if(_pppdata->modemDevice() == modemdevice->text(i))
modemdevice->setCurrentItem(i);
}
for(int i=0; i <= flowcontrol->count()-1; 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) == _pppdata->speed())
baud_c->setCurrentItem(i);
tl->setRowStretch(1, 1);
}
ModemWidget::~ModemWidget()
{
QStringList devs;
for (int i=0;i<modemdevice->count();i++)
{
QString s = modemdevice->text(i);
s.simplifyWhiteSpace();
if (! s.isEmpty() ) devs << s;
}
QString edited = modemdevice->currentText();
if ( !( edited ).isEmpty() )
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp
index e466358..e21bbc7 100644
--- a/noncore/settings/networksettings/ppp/kpppwidget.cpp
+++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp
@@ -207,671 +207,671 @@ KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *na
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 = 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;
// }
// }
// }
// return false;
// }
void KPPPWidget::enterPressedInID() {
PW_Edit->setFocus();
}
void KPPPWidget::enterPressedInPW() {
connect_b->setFocus();
}
// triggered by the session manager
void KPPPWidget::saveMyself() {
_pppdata->save();
}
void KPPPWidget::shutDown() {
interruptConnection();
saveMyself();
}
void KPPPWidget::log_window_toggled(bool on) {
_pppdata->set_show_log_window(on);
}
// void KPPPWidget::resetaccounts() {
// connectto_c->clear();
// int count = _pppdata->count();
// // enable/disable controls
// connectto_c->setEnabled(count > 0);
// connect_b->setEnabled(count > 0);
// log->setEnabled(count > 0);
// ID_Edit->setEnabled(count > 0);
// PW_Edit->setEnabled(count > 0);
// //load the accounts
// for(int i=0; i < count; i++) {
// _pppdata->setAccountbyIndex(i);
// connectto_c->insertItem(_pppdata->accname());
// }
// //set the default account
// if(!_pppdata->defaultAccount().isEmpty()) {
// for(int i=0; i < count; i++)
// if(_pppdata->defaultAccount() == connectto_c->text(i)) {
// connectto_c->setCurrentItem(i);
// _pppdata->setAccountbyIndex(i);
// ID_Edit->setText(_pppdata->storedUsername());
// PW_Edit->setText(_pppdata->storedPassword());
// }
// }
// else
// if(count > 0) {
// _pppdata->setDefaultAccount(connectto_c->text(0));
// _pppdata->save();
// ID_Edit->setText(_pppdata->storedUsername());
// PW_Edit->setText(_pppdata->storedPassword());
// }
-// connect(ID_Edit, SIGNAL(textChanged(const QString &)),
-// this, SLOT(usernameChanged(const QString &)));
+// connect(ID_Edit, SIGNAL(textChanged(const QString&)),
+// this, SLOT(usernameChanged(const QString&)));
-// connect(PW_Edit, SIGNAL(textChanged(const QString &)),
-// this, SLOT(passwordChanged(const QString &)));
+// connect(PW_Edit, SIGNAL(textChanged(const QString&)),
+// this, SLOT(passwordChanged(const QString&)));
// if (ID_Edit->text().isEmpty())
// ID_Edit->setFocus();
// else if (PW_Edit->text().isEmpty())
// PW_Edit->setFocus();
// }
void KPPPWidget::interruptConnection() {
// interrupt dial up
//
if (con->isVisible())
emit con->cancelbutton();
// disconnect if online
if (_pppdata->pppdRunning())
emit disconnect();
}
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 = QObject::tr("Timeout expired while waiting for the PPP interface "
"to come up!");
else {
msg = QObject::tr("<p>The pppd daemon died unexpectedly!</p>");
Modem::modem->pppdExitStatus();
if (Modem::modem->lastStatus != 99) { // more recent pppds only
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, 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 = 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", 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 = 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 = 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",
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 = 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 = QObject::tr("You must specify a telephone number!");
QMessageBox::warning(this, "error", s);
return;
}
this->hide();
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(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,
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)));
+// connect(acct, SIGNAL(changed(QString,QString)),
+// con_win, SLOT(slotAccounting(QString,QString)));
// // if(!acct->loadRuleSet(_pppdata->accountingFile())) {
// // 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(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(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(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(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 = 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/pppdargs.cpp b/noncore/settings/networksettings/ppp/pppdargs.cpp
index 66a4d82..d6d8d88 100644
--- a/noncore/settings/networksettings/ppp/pppdargs.cpp
+++ b/noncore/settings/networksettings/ppp/pppdargs.cpp
@@ -1,151 +1,151 @@
/*
* 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 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 <qlayout.h>
#include <qbuttongroup.h>
#include <qapplication.h>
#include "pppdargs.h"
#include "pppdata.h"
PPPdArguments::PPPdArguments( PPPData *pd, QWidget *parent, const char *name)
: QDialog(parent, name, TRUE), _pppdata(pd)
{
setCaption(tr("Customize pppd Arguments"));
// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
QVBoxLayout *l = new QVBoxLayout(this, 10, 10);
QHBoxLayout *tl = new QHBoxLayout(10);
l->addLayout(tl);
QVBoxLayout *l1 = new QVBoxLayout();
QVBoxLayout *l2 = new QVBoxLayout();
tl->addLayout(l1, 1);
tl->addLayout(l2, 0);
QHBoxLayout *l11 = new QHBoxLayout(10);
l1->addLayout(l11);
argument_label = new QLabel(tr("Argument:"), this);
l11->addWidget(argument_label);
argument = new QLineEdit(this);
connect(argument, SIGNAL(returnPressed()),
SLOT(addbutton()));
l11->addWidget(argument);
- connect(argument, SIGNAL(textChanged(const QString &)),
- this, SLOT(textChanged(const QString &)));
+ connect(argument, SIGNAL(textChanged(const QString&)),
+ this, SLOT(textChanged(const QString&)));
arguments = new QListBox(this);
arguments->setMinimumSize(1, fontMetrics().lineSpacing()*10);
connect(arguments, SIGNAL(highlighted(int)),
this, SLOT(itemSelected(int)));
l1->addWidget(arguments, 1);
add = new QPushButton(tr("Add"), this);
connect(add, SIGNAL(clicked()), SLOT(addbutton()));
l2->addWidget(add);
l2->addStretch(1);
remove = new QPushButton(tr("Remove"), this);
connect(remove, SIGNAL(clicked()), SLOT(removebutton()));
l2->addWidget(remove);
defaults = new QPushButton(tr("Defaults"), this);
connect(defaults, SIGNAL(clicked()), SLOT(defaultsbutton()));
l2->addWidget(defaults);
l->addSpacing(5);
//load info from gpppdata
init();
add->setEnabled(false);
remove->setEnabled(false);
argument->setFocus();
}
void PPPdArguments::addbutton() {
if(!argument->text().isEmpty() && arguments->count() < MAX_PPPD_ARGUMENTS) {
arguments->insertItem(argument->text());
argument->setText("");
}
}
void PPPdArguments::removebutton() {
if(arguments->currentItem() >= 0)
arguments->removeItem(arguments->currentItem());
}
void PPPdArguments::defaultsbutton() {
// all of this is a hack
// save current list
QStringList arglist(_pppdata->pppdArgument());
// get defaults
_pppdata->setpppdArgumentDefaults();
init();
// restore old list
_pppdata->setpppdArgument(arglist);
}
void PPPdArguments::accept() {
QStringList arglist;
for(uint i=0; i < arguments->count(); i++)
arglist.append(arguments->text(i));
_pppdata->setpppdArgument(arglist);
QDialog::accept();
}
void PPPdArguments::init() {
while(arguments->count())
arguments->removeItem(0);
QStringList &arglist = _pppdata->pppdArgument();
for ( QStringList::Iterator it = arglist.begin();
it != arglist.end();
++it )
arguments->insertItem(*it);
}
void PPPdArguments::textChanged(const QString &s) {
add->setEnabled(s.length() > 0);
}
void PPPdArguments::itemSelected(int idx) {
remove->setEnabled(idx != -1);
}
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp
index 92339d6..dd1db28 100644
--- a/noncore/settings/networksettings/wlan/wlanimp2.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp
@@ -1,249 +1,249 @@
#include "wlanimp2.h"
#include "keyedit.h"
#include "interfacesetupimp.h"
#include "../interfaces/interface.h"
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <qapplication.h>
#include <qfile.h>
#include <qdir.h>
#include <qdialog.h>
#include <qtextstream.h>
#include <qmessagebox.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qspinbox.h>
#include <qradiobutton.h>
#include <qpushbutton.h>
#include <qcheckbox.h>
#include <qtabwidget.h>
#include <qcombobox.h>
#include <qlistview.h>
#include <qvbox.h>
#include <qprogressbar.h>
#ifdef QWS
#include <qpe/resource.h>
#include <opie2/oprocess.h>
#include <opie2/onetwork.h>
#include <opie2/opcap.h>
#else
#define OProcess KProcess
#include <kprocess.h>
#endif
#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
#define PREUP "/etc/network/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), 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"));
}
connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) );
- connect( netView, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectNetwork( QListViewItem* ) ) );
+ connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) );
netView->setColumnAlignment( col_chn, AlignCenter );
netView->setItemMargin( 3 );
netView->setAllColumnsShowFocus( true );
}
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();
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;
case 2:
keyRadio1->setChecked(true);
break;
case 3:
keyRadio2->setChecked(true);
break;
case 4:
keyRadio3->setChecked(true);
break;
}
} else {
// key
key = (*it);
}
if (! key.isNull()) {
if (enc == -1)
enc = 1;
QStringList::Iterator next = ++it;
if (it == keys.end()) {
break;
}
if ((*(next)).left(1) == "[") {
// set key at index
index = (*(next)).mid(1, 1).toInt();
} else {
index = 1;
}
switch (index) {
case 1:
keyLineEdit0->setText(key);
break;
case 2:
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
// FIXME: QDialog::accept();
}
void WLANImp::writeOpts() {
// 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 {
diff --git a/noncore/settings/packagemanager/filterdlg.cpp b/noncore/settings/packagemanager/filterdlg.cpp
index 0da9d19..eeed398 100644
--- a/noncore/settings/packagemanager/filterdlg.cpp
+++ b/noncore/settings/packagemanager/filterdlg.cpp
@@ -1,179 +1,179 @@
/*
                This file is part of the OPIE Project
=. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
             .=l.
           .>+-=
 _;:,     .>    :=|. 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.
*/
#include "filterdlg.h"
FilterDlg::FilterDlg( QWidget *parent, OPackageManager *pm, const QString &name,
const QString &server, const QString &destination,
OPackageManager::Status status, const QString &category )
: QDialog( parent, QString::null, true )
{
setCaption( tr( "Filter packages" ) );
QVBoxLayout *layout = new QVBoxLayout( this );
QScrollView *sv = new QScrollView( this );
layout->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
layout = new QVBoxLayout( container, 4, 4 );
// Category
m_categoryCB = new QCheckBox( tr( "Category:" ), container );
connect( m_categoryCB, SIGNAL(toggled(bool)), this, SLOT(slotCategorySelected(bool)) );
m_category = new QComboBox( container );
m_category->insertStringList( pm->categories() );
initItem( m_category, m_categoryCB, category );
layout->addWidget( m_categoryCB );
layout->addWidget( m_category );
// Package name
m_nameCB = new QCheckBox( tr( "Names containing:" ), container );
connect( m_nameCB, SIGNAL(toggled(bool)), this, SLOT(slotNameSelected(bool)) );
m_name = new QLineEdit( name, container );
if ( !name.isNull() )
m_nameCB->setChecked( true );
m_name->setEnabled( !name.isNull() );
layout->addWidget( m_nameCB );
layout->addWidget( m_name );
// Status
m_statusCB = new QCheckBox( tr( "With the status:" ), container );
connect( m_statusCB, SIGNAL(toggled(bool)), this, SLOT(slotStatusSelected(bool)) );
m_status = new QComboBox( container );
- connect( m_status, SIGNAL(activated(const QString &)), this, SLOT(slotStatusChanged(const QString &)) );
+ connect( m_status, SIGNAL(activated(const QString&)), this, SLOT(slotStatusChanged(const QString&)) );
QString currStatus;
switch ( status )
{
case OPackageManager::All : currStatus = tr( "All" );
break;
case OPackageManager::Installed : currStatus = tr( "Installed" );
break;
case OPackageManager::NotInstalled : currStatus = tr( "Not installed" );
break;
case OPackageManager::Updated : currStatus = tr( "Updated" );
break;
default : currStatus = QString::null;
};
m_status->insertItem( tr( "All" ) );
m_status->insertItem( tr( "Installed" ) );
m_status->insertItem( tr( "Not installed" ) );
m_status->insertItem( tr( "Updated" ) );
initItem( m_status, m_statusCB, currStatus );
layout->addWidget( m_statusCB );
layout->addWidget( m_status );
// Server
m_serverCB = new QCheckBox( tr( "Available from the following server:" ), container );
connect( m_serverCB, SIGNAL(toggled(bool)), this, SLOT(slotServerSelected(bool)) );
m_server = new QComboBox( container );
m_server->insertStringList( *(pm->servers()) );
initItem( m_server, m_serverCB, server );
layout->addWidget( m_serverCB );
layout->addWidget( m_server );
// Destination
m_destCB = new QCheckBox( tr( "Installed on device at:" ), container );
connect( m_destCB, SIGNAL(toggled(bool)), this, SLOT(slotDestSelected(bool)) );
m_destination = new QComboBox( container );
m_destination->insertStringList( *(pm->destinations()) );
initItem( m_destination, m_destCB, destination );
layout->addWidget( m_destCB );
layout->addWidget( m_destination );
//showMaximized();
}
void FilterDlg::initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection )
{
if ( !selection.isNull() )
{
checkBox->setChecked( true );
for ( int i = 0; i < comboBox->count(); i++ )
{
if ( comboBox->text( i ) == selection )
{
comboBox->setCurrentItem( i );
return;
}
}
}
comboBox->setEnabled( !selection.isNull() );
}
void FilterDlg::slotNameSelected( bool selected )
{
m_name->setEnabled( selected );
}
void FilterDlg::slotServerSelected( bool selected )
{
m_server->setEnabled( selected );
}
void FilterDlg::slotDestSelected( bool selected )
{
m_destination->setEnabled( selected );
}
void FilterDlg::slotStatusSelected( bool selected )
{
m_status->setEnabled( selected );
if ( !selected && !m_destCB->isEnabled() )
{
// If status check box has been deselected and destination option was previously deselected
// (because status == "Not installed"), re-enable destination option
m_destCB->setEnabled( true );
m_destination->setEnabled( true );
}
else if ( selected && m_destCB->isEnabled() && m_status->currentText() == tr( "Not installed" ) )
{
// If status check box has been selected and status == "Not installed", disable destination option
m_destCB->setEnabled( false );
m_destCB->setChecked( false );
m_destination->setEnabled( false );
}
}
void FilterDlg::slotStatusChanged( const QString &category )
{
bool notInstalled = ( category == tr( "Not installed" ) );
m_destCB->setEnabled( !notInstalled );
m_destination->setEnabled( !notInstalled );
if ( notInstalled )
m_destCB->setChecked( false );
}
void FilterDlg::slotCategorySelected( bool selected )
{
m_category->setEnabled( selected );
}
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp
index 8fd960f..b334bca 100644
--- a/noncore/settings/packagemanager/mainwindow.cpp
+++ b/noncore/settings/packagemanager/mainwindow.cpp
@@ -1,346 +1,346 @@
/*
                This file is part of the OPIE Project
=. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
             .=l.
           .>+-=
 _;:,     .>    :=|. 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.
*/
#include <qaction.h>
#include <qdir.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qtimer.h>
#include <qtoolbar.h>
#include <qwhatsthis.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include "mainwindow.h"
#include "installdlg.h"
#include "filterdlg.h"
#include "promptdlg.h"
#include "entrydlg.h"
#include "packageinfodlg.h"
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ )
: QMainWindow( parent, name, WStyle_ContextHelp )
, m_config( "packman" )
, m_packman( &m_config, this )
, m_menuBar( this )
, m_toolBar( this )
, m_findBar( this )
, m_widgetStack( this )
, m_packageList( this )
, m_statusWidget( this )
, m_statusText( &m_statusWidget )
, m_statusBar( &m_statusWidget )
, m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) )
, m_iconInstalled( Resource::loadPixmap( "installed" ) )
, m_iconNull( m_iconUpdated.size() )
, m_filterName( QString::null )
, m_filterServer( QString::null )
, m_filterDest( QString::null )
, m_filterStatus( OPackageManager::NotDefined )
, m_filterCategory( QString::null )
{
// setCaption( tr( "Package Manager" ) );
m_iconNull.fill( colorGroup().base() );
connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) );
// Initialize widget stack, package list and status widget
initStatusWidget();
initPackageList();
m_widgetStack.addWidget( &m_statusWidget, 2 );
m_widgetStack.addWidget( &m_packageList, 1 );
setCentralWidget( &m_widgetStack );
// Initialize remaining user interface items
initUI();
// Initialize package information
QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) );
}
void MainWindow::closeEvent( QCloseEvent *event )
{
// Close app only if either the package or status widgets are currently active
bool close = m_widgetStack.visibleWidget() == &m_packageList ||
m_widgetStack.visibleWidget() == &m_statusWidget;
if ( close )
{
// TODO - write out application configuration settings
// Write out package manager configuration settings
m_packman.saveSettings();
event->accept();
}
else
{
delete m_widgetStack.visibleWidget();
m_widgetStack.raiseWidget( &m_packageList );
event->ignore();
}
}
void MainWindow::initPackageList()
{
m_packageList.addColumn( tr( "Packages" ) );
QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) );
QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold );
- connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)),
- this, SLOT(slotDisplayPackageInfo(QListViewItem *)) );
+ connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)),
+ this, SLOT(slotDisplayPackageInfo(QListViewItem*)) );
}
void MainWindow::initStatusWidget()
{
QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 );
m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
layout->addWidget( &m_statusText );
connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) );
- connect( &m_packman, SIGNAL(statusText(const QString &)), this, SLOT(slotStatusText(const QString &)) );
+ connect( &m_packman, SIGNAL(statusText(const QString&)), this, SLOT(slotStatusText(const QString&)) );
connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) );
layout->addWidget( &m_statusBar );
}
void MainWindow::initUI()
{
// Build menu and tool bars
setToolBarsMovable( false );
m_menuBar.setHorizontalStretchable( true );
QMenuBar *mb = new QMenuBar( &m_menuBar );
mb->setMargin( 0 );
// Find toolbar
addToolBar( &m_findBar, QMainWindow::Top, true );
m_findBar.setHorizontalStretchable( true );
m_findEdit = new QLineEdit( &m_findBar );
QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) );
m_findBar.setStretchableWidget( m_findEdit );
- connect( m_findEdit, SIGNAL(textChanged(const QString &)), this, SLOT(slotFindChanged(const QString &)) );
+ connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) );
// Packages menu
QPopupMenu *popup = new QPopupMenu( this );
QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) );
a->addTo( popup );
a->addTo( &m_toolBar );
QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 );
actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) );
actionUpgrade->addTo( popup );
actionUpgrade->addTo( &m_toolBar );
QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" );
QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" );
QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) );
actionDownload->addTo( popup );
actionDownload->addTo( &m_toolBar );
a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
connect( a, SIGNAL(activated()), this, SLOT(slotApply()) );
a->addTo( popup );
a->addTo( &m_toolBar );
popup->insertSeparator();
a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to configure this application." ) );
connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) );
a->addTo( popup );
mb->insertItem( tr( "Actions" ), popup );
// View menu
popup = new QPopupMenu( this );
m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
m_actionShowNotInstalled->setToggleAction( true );
m_actionShowNotInstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) );
m_actionShowNotInstalled->addTo( popup );
m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
m_actionShowInstalled->setToggleAction( true );
m_actionShowInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) );
m_actionShowInstalled->addTo( popup );
m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
m_actionShowUpdated->setToggleAction( true );
m_actionShowUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) );
m_actionShowUpdated->addTo( popup );
popup->insertSeparator();
m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ),
QString::null, 0, this, 0 );
m_actionFilter->setToggleAction( true );
m_actionFilter->setWhatsThis( tr( "Click here to apply current filter." ) );
connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) );
m_actionFilter->addTo( popup );
a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to change the package filter criteria." ) );
connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) );
a->addTo( popup );
popup->insertSeparator();
a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to search for text in package names." ) );
connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) );
a->addTo( popup );
m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
m_actionFindNext->setEnabled( false );
m_actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) );
connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) );
m_actionFindNext->addTo( popup );
m_actionFindNext->addTo( &m_findBar );
mb->insertItem( tr( "View" ), popup );
// Finish find toolbar creation
a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to hide the find toolbar." ) );
connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) );
a->addTo( &m_findBar );
m_findBar.hide();
}
void MainWindow::loadPackageList( OPackageList *packages, bool clearList )
{
if ( clearList )
m_packageList.clear();
if ( packages )
{
for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt )
{
OPackage *package = packageIt.current();
QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(),
QCheckListItem::CheckBox );
m_packageList.insertItem( item );
// If a different version of package is available, show update available icon
// Otherwise, show installed icon
if ( !package->versionInstalled().isNull() )
{
if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 )
item->setPixmap( 0, m_iconUpdated );
else
item->setPixmap( 0, m_iconInstalled );
}
else
item->setPixmap( 0, m_iconNull );
}
}
}
void MainWindow::searchForPackage( const QString &text )
{
if ( !text.isEmpty() )
{
// look through package list for text startng at current position
QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem());
if ( start == 0 )
start = static_cast<QCheckListItem *>(m_packageList.firstChild());
// for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ;
for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ;
item = static_cast<QCheckListItem *>(item->nextSibling()) )
{
if ( item->text().lower().find( text ) != -1 )
{
m_packageList.ensureItemVisible( item );
m_packageList.setCurrentItem( item );
break;
}
}
}
}
void MainWindow::initPackageInfo()
{
m_widgetStack.raiseWidget( &m_statusWidget );
// Load package list
m_packman.loadAvailablePackages();
m_packman.loadInstalledPackages();
OPackageList *packageList = m_packman.packages();
if ( packageList )
{
loadPackageList( packageList, true );
delete packageList;
}
m_widgetStack.raiseWidget( &m_packageList );
}
void MainWindow::slotWidgetStackShow( QWidget *widget )
{
if ( widget == &m_packageList )
{
setCaption( tr( "Package Manager" ) );
m_menuBar.show();
m_toolBar.show();
}
else
{
m_menuBar.hide();
m_toolBar.hide();
}
}
void MainWindow::slotInitStatusBar( int numSteps )
{
m_statusBar.setTotalSteps( numSteps );
}
void MainWindow::slotStatusText( const QString &status )
{
m_statusText.setText( status );
}
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index 086e91b..1dc23a4 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -127,383 +127,383 @@ OConfItemList *OIpkg::options()
void OIpkg::setConfigItems( OConfItemList *configList )
{
if ( m_confInfo )
delete m_confInfo;
m_confInfo = configList;
}
void OIpkg::saveSettings()
{
// Save Ipkg execution options to application configuration file
if ( m_config )
{
m_config->setGroup( "Ipkg" );
m_config->writeEntry( "ExecOptions", m_ipkgExecOptions );
m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity );
}
}
OPackageList *OIpkg::availablePackages( const QString &server )
{
// Load Ipkg configuration info if not already cached
if ( !m_confInfo )
loadConfiguration();
// Build new server list (caller is responsible for deleting)
OPackageList *pl = new OPackageList;
// Open package list file
QFile f( IPKG_PKG_PATH + "/" + server );
if ( !f.open( IO_ReadOnly ) )
return NULL;
QTextStream t( &f );
// Process all information in package list file
OPackage *package = NULL;
QString line = t.readLine();
while ( !t.eof() )
{
// Determine key/value pair
int pos = line.find( ':', 0 );
QString key;
if ( pos > -1 )
key = line.mid( 0, pos );
else
key = QString::null;
QString value = line.mid( pos+2, line.length()-pos );
// Allocate new package and insert into list
if ( package == NULL && !key.isEmpty() )
{
package = new OPackage( value );
package->setSource( server );
pl->append( package );
}
// Update package data
if ( key == "Package" )
package->setName( value );
else if ( key == "Version" )
package->setVersion( value );
else if ( key == "Section" )
package->setCategory( value );
//DataManager::setAvailableCategories( value );
else if ( key.isEmpty() && value.isEmpty() )
package = NULL;
// Skip past all description lines
if ( key == "Description" )
{
line = t.readLine();
while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
line = t.readLine();
}
else
line = t.readLine();
}
f.close();
return pl;
}
OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath )
{
// Load Ipkg configuration info if not already cached
if ( !m_confInfo )
loadConfiguration();
// Build new server list (caller is responsible for deleting)
OPackageList *pl = new OPackageList;
// Open status file
QString path = destPath;
if ( path.right( 1 ) != "/" )
path.append( "/" );
path.append( IPKG_STATUS_PATH );
QFile f( path );
if ( !f.open( IO_ReadOnly ) )
return NULL;
QTextStream t( &f );
// Process all information in status file
bool newPackage = false;
QString line = t.readLine();
QString name;
QString version;
QString status;
while ( !t.eof() )
{
// Determine key/value pair
int pos = line.find( ':', 0 );
QString key;
if ( pos > -1 )
key = line.mid( 0, pos );
else
key = QString::null;
QString value = line.mid( pos+2, line.length()-pos );
// Allocate new package and insert into list
if ( newPackage && !key.isEmpty() )
{
// Add to list only if it has a valid name and is installed
if ( !name.isNull() && status.contains( " installed" ) )
{
pl->append( new OPackage( name, QString::null, version, QString::null, destName ) );
name = QString::null;
version = QString::null;
status = QString::null;
newPackage = false;
}
}
// Update package data
if ( key == "Package" )
name = value;
else if ( key == "Version" )
version = value;
else if ( key == "Status" )
status = value;
else if ( key.isEmpty() && value.isEmpty() )
newPackage = true;
// Skip past all description lines
if ( key == "Description" )
{
line = t.readLine();
while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
line = t.readLine();
}
else
line = t.readLine();
}
f.close();
return pl;
}
bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination,
const QObject *receiver, const char *slotOutput, bool rawOutput )
{
if ( command == OPackage::NotDefined )
return false;
// Set ipkg run-time options/arguments
m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS );
m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL );
// TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE );
m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE );
m_ipkgArgs.verbosity = m_ipkgExecVerbosity;
if ( m_ipkgArgs.dest )
free( m_ipkgArgs.dest );
if ( !destination.isNull() )
{
int len = destination.length() + 1;
m_ipkgArgs.dest = (char *)malloc( len );
strncpy( m_ipkgArgs.dest, destination, destination.length() );
m_ipkgArgs.dest[ len - 1 ] = '\0';
}
else
m_ipkgArgs.dest = 0x0;
// Connect output signal to widget
if ( rawOutput )
{
// if ( slotOutput )
-// connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput );
+// connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
}
else
{
// TODO - connect to local slot and parse output before emitting signalIpkgMessage
}
switch( command )
{
case OPackage::Update : {
- connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput );
+ connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
ipkg_lists_update( &m_ipkgArgs );
};
break;
case OPackage::Upgrade : {
- connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput );
+ connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
ipkg_packages_upgrade( &m_ipkgArgs );
};
break;
case OPackage::Install : {
- connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput );
+ connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
{
ipkg_packages_install( &m_ipkgArgs, (*it) );
}
};
break;
case OPackage::Remove : {
- connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput );
+ connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
{
ipkg_packages_remove( &m_ipkgArgs, (*it), true );
}
};
break;
case OPackage::Download : {
- connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput );
+ connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
{
ipkg_packages_download( &m_ipkgArgs, (*it) );
}
};
break;
case OPackage::Info : {
- connect( this, SIGNAL(signalIpkgStatus(char *)), receiver, slotOutput );
+ connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput );
ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 );
};
break;
case OPackage::Files : {
- connect( this, SIGNAL(signalIpkgList(char *)), receiver, slotOutput );
+ connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput );
ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 );
};
break;
default : break;
};
return true;
}
void OIpkg::ipkgMessage( char *msg )
{
emit signalIpkgMessage( msg );
}
void OIpkg::ipkgStatus( char *status )
{
emit signalIpkgStatus( status );
}
void OIpkg::ipkgList( char *filelist )
{
emit signalIpkgList( filelist );
}
void OIpkg::loadConfiguration()
{
if ( m_confInfo )
delete m_confInfo;
// Load configuration item list
m_confInfo = new OConfItemList();
QStringList confFiles;
QDir confDir( IPKG_CONF_DIR );
if ( confDir.exists() )
{
confDir.setNameFilter( "*.conf" );
confDir.setFilter( QDir::Files );
confFiles = confDir.entryList( "*.conf", QDir::Files );
confFiles << IPKG_CONF;
for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++it )
{
// Create absolute file path if necessary
QString absFile = (*it);
if ( !absFile.startsWith( "/" ) )
absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
// Read in file
QFile f( absFile );
if ( f.open( IO_ReadOnly ) )
{
QTextStream s( &f );
while ( !s.eof() )
{
QString line = s.readLine().simplifyWhiteSpace();
// Parse line and save info to the conf options list
if ( !line.isEmpty() )
{
if ( !line.startsWith( "#" ) ||
line.startsWith( "#src" ) ||
line.startsWith( "#dest" ) ||
line.startsWith( "#arch" ) ||
line.startsWith( "#option" ) )
{
int pos = line.find( ' ', 1 );
// Type
QString typeStr = line.left( pos );
OConfItem::Type type;
if ( typeStr == "src" || typeStr == "#src" )
type = OConfItem::Source;
else if ( typeStr == "dest" || typeStr == "#dest" )
type = OConfItem::Destination;
else if ( typeStr == "option" || typeStr == "#option" )
type = OConfItem::Option;
else if ( typeStr == "arch" || typeStr == "#arch" )
type = OConfItem::Arch;
else
type = OConfItem::NotDefined;
++pos;
int endpos = line.find( ' ', pos );
// Name
QString name = line.mid( pos, endpos - pos );
// Value
QString value = "";
if ( endpos > -1 )
value = line.right( line.length() - endpos - 1 );
// Active
bool active = !line.startsWith( "#" );
// Add to list
m_confInfo->append( new OConfItem( absFile, type, name, value, active ) );
}
}
}
f.close();
}
}
}
// Load Ipkg execution options from application configuration file
if ( m_config )
{
m_config->setGroup( "Ipkg" );
m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions );
m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity );
}
}
OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter )
{
// Load Ipkg configuration info if not already cached
if ( !m_confInfo )
loadConfiguration();
// Build new server list (caller is responsible for deleting)
OConfItemList *sl = new OConfItemList;
// If typefilter is empty, retrieve all items
bool retrieveAll = ( typefilter == OConfItem::NotDefined );
// Parse configuration info for servers
OConfItemListIterator it( *m_confInfo );
for ( ; it.current(); ++it )
{
OConfItem *item = it.current();
if ( retrieveAll || item->type() == typefilter )
{
sl->append( item );
}
}
return sl;
}
diff --git a/noncore/settings/sound/soundsettings.cpp b/noncore/settings/sound/soundsettings.cpp
index 4bc86fa..8ad0a3f 100644
--- a/noncore/settings/sound/soundsettings.cpp
+++ b/noncore/settings/sound/soundsettings.cpp
@@ -1,220 +1,220 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of 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.
**
**********************************************************************/
// parts copyright 2002 L.J. Potter
#include "soundsettings.h"
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/storage.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <sys/utsname.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
SoundSettings::SoundSettings( QWidget* parent, const char* objname, WFlags fl )
: SoundSettingsBase( parent, objname, TRUE, fl )
{
keyReset=FALSE;
noWarning=false;
Config config( "qpe");
config.setGroup( "Volume" );
Config cfg("Vmemo");
connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
AlertCheckBox->setChecked(cfg.readBoolEntry("Alert"));
cfg.setGroup("Record");
int rate=config.readNumEntry("SampleRate", 22050);
if(rate == 8000)
sampleRate->setCurrentItem(0);
else if(rate == 11025)
sampleRate->setCurrentItem(1);
else if(rate == 22050)
sampleRate->setCurrentItem(2);
else if(rate == 33075)
sampleRate->setCurrentItem(3);
else if(rate==44100)
sampleRate->setCurrentItem(4);
stereoCheckBox->setChecked(cfg.readNumEntry("Stereo", 0));
//TODO hide if zaurus- mono only
#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
//since ipaq and zaurus have particular
//devices
bool systemZaurus=FALSE;
struct utsname name; /* check for embedix kernel running on the zaurus*/
if (uname(&name) != -1) {// TODO change this here,...
QString release=name.release;
if( release.find("embedix",0,TRUE) != -1) {
qDebug("IS System Zaurus");
systemZaurus=TRUE;
}
}
if(!systemZaurus) {
stereoCheckBox->setChecked(TRUE);
}
stereoCheckBox->setEnabled(FALSE);
sixteenBitCheckBox->setEnabled(FALSE);
#else
#endif
int sRate=cfg.readNumEntry("SizeLimit", 30);
qDebug("%d",sRate);
if(sRate ==30)
timeLimitComboBox->setCurrentItem(0);
else if(sRate==20)
timeLimitComboBox->setCurrentItem(1);
else if(sRate == 15)
timeLimitComboBox->setCurrentItem(2);
else if(sRate == 10)
timeLimitComboBox->setCurrentItem(3);
else if(sRate == 5)
timeLimitComboBox->setCurrentItem(4);
else
timeLimitComboBox->setCurrentItem(5);
sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1));
cfg.setGroup("Defaults");
keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") );
updateStorageCombo();
Config vmCfg("Vmemo");
vmCfg.setGroup("Defaults");
adpcmCheckBox->setChecked( vmCfg.readBoolEntry("use_ADPCM", 0));
- connect( LocationComboBox,SIGNAL(activated(const QString &)), this,
- SLOT( setLocation(const QString &)));
- connect( keyComboBox,SIGNAL(activated( int)), this,
- SLOT( setKeyButton( int)));
- connect( timeLimitComboBox,SIGNAL(activated( const QString &)), this,
- SLOT( setSizeLimitButton(const QString &)));
- connect( restartCheckBox,SIGNAL( toggled( bool)), this,
- SLOT( restartOpie( bool)));
- connect( adpcmCheckBox,SIGNAL( toggled( bool)), this,
- SLOT( slotAdpcm( bool)));
+ connect( LocationComboBox,SIGNAL(activated(const QString&)), this,
+ SLOT( setLocation(const QString&)));
+ connect( keyComboBox,SIGNAL(activated(int)), this,
+ SLOT( setKeyButton(int)));
+ connect( timeLimitComboBox,SIGNAL(activated(const QString&)), this,
+ SLOT( setSizeLimitButton(const QString&)));
+ connect( restartCheckBox,SIGNAL( toggled(bool)), this,
+ SLOT( restartOpie(bool)));
+ connect( adpcmCheckBox,SIGNAL( toggled(bool)), this,
+ SLOT( slotAdpcm(bool)));
// connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
}
void SoundSettings::updateStorageCombo() {
Config config( "Vmemo" );
config.setGroup( "System" );
QString loc = config.readEntry("RecLocation","/");
int i=0;
int set=0;
StorageInfo storageInfo;
QString sName, sPath;
QStringList list;
list << "Documents : "+QPEApplication::documentDir();
list << "tmp : /tmp";
const QList<FileSystem> &fs = storageInfo.fileSystems();
QListIterator<FileSystem> it ( fs );
for( ; it.current(); ++it ){
const QString name = (*it)->name();
const QString path = (*it)->path();
qDebug("storage name "+name +" storage path is "+path);
list << name + ": " +path;
if( loc.find( path,0,TRUE) != -1)
set = i;
// if(dit.current()->file().find(path) != -1 ) storage=name;
i++;
}
LocationComboBox->insertStringList(list);
qDebug("set item %d", set);
LocationComboBox->setCurrentItem(set);
}
void SoundSettings::setLocation(const QString & string) {
Config config( "Vmemo" );
config.setGroup( "System" );
config.writeEntry("RecLocation",string);
qDebug("set location "+string);
config.write();
}
void SoundSettings::cleanUp() {
Config cfg("Vmemo");
cfg.writeEntry("Alert",AlertCheckBox->isChecked());
cfg.setGroup("Record");
cfg.writeEntry("SampleRate",sampleRate->currentText());
cfg.writeEntry("Stereo",stereoCheckBox->isChecked());
cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked());
if(keyReset && noWarning) {
QCopEnvelope ("QPE/System", "restart()");
}
}
void SoundSettings::setKeyButton( int index) {
Config cfg("Vmemo");
cfg.setGroup("Defaults");
cfg.writeEntry( "toggleKey", index );
keyReset = TRUE;
if( index == 1) {
cfg.writeEntry( "hideIcon", 0 );
keyLabel->setText(tr("Shows icon"));
}
else {
cfg.writeEntry( "hideIcon", 1);
keyLabel->setText(tr("Hides icon"));
}
cfg.write();
}
void SoundSettings::updateLocationCombo() {
}
void SoundSettings::setSizeLimitButton(const QString &index) {
Config cfg("Vmemo");
cfg.setGroup("Record");
if(index.find("Unlimited",0,TRUE) != -1)
cfg.writeEntry("SizeLimit", -1);
else
cfg.writeEntry("SizeLimit", index);
cfg.write();
}
void SoundSettings::restartOpie(bool b) {
noWarning=b;
}
void SoundSettings::slotAdpcm(bool b) {
Config vmCfg("Vmemo");
vmCfg.setGroup("Defaults");
vmCfg.writeEntry("use_ADPCM", b);
vmCfg.write();
}
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp
index 0aeb251..d6ecec5 100644
--- a/noncore/settings/sysinfo/benchmarkinfo.cpp
+++ b/noncore/settings/sysinfo/benchmarkinfo.cpp
@@ -1,340 +1,340 @@
/**********************************************************************
** BenchmarkInfo
**
** A benchmark for Qt/Embedded
**
** Copyright (C) 2004 Michael Lauer <mickey@vanille.de>
** Inspired by ZBench (C) 2002 Satoshi <af230533@im07.alpha-net.ne.jp>
**
** 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.
**
**********************************************************************/
/* OPIE */
#include <opie2/ostorageinfo.h>
#include <qpe/qpeapplication.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpedecoration_qws.h>
#include <qpe/resource.h>
#include <qpe/config.h>
/* QT */
#include <qclipboard.h>
#include <qcolor.h>
#include <qcombobox.h>
#include <qdirectpainter_qws.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qfiledialog.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpainter.h>
#include <qpushbutton.h>
#include <qtimer.h>
/* STD */
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "benchmarkinfo.h"
extern "C"
{
void BenchFFT( void );
double dhry_main( int );
}
#define DHRYSTONE_RUNS 20000000
#define TEST_DURATION 3
#define BUFF_SIZE 8192
#define FILE_SIZE 1024 * 1024 // 1Mb
//===========================================================================
class BenchmarkPaintWidget : public QWidget
{
public:
BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever )
{
resize( QApplication::desktop()->size() );
show();
p.begin( this );
};
~BenchmarkPaintWidget()
{
p.end();
hide();
};
QPainter p;
};
//===========================================================================
BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags )
: QWidget( parent, name, wFlags )
{
setMinimumSize( 200, 150 );
QVBoxLayout* vb = new QVBoxLayout( this );
vb->setSpacing( 4 );
vb->setMargin( 4 );
tests = new QListView( this );
tests->setMargin( 0 );
tests->addColumn( tr( "Tests" ) );
tests->addColumn( tr( "Results" ) );
tests->addColumn( tr( "Comparison" ) );
tests->setShowSortIndicator( true );
test_alu = new QCheckListItem( tests, tr( "1. Integer Arithmetic " ), QCheckListItem::CheckBox );
test_fpu = new QCheckListItem( tests, tr( "2. Floating Point Unit " ), QCheckListItem::CheckBox );
test_txt = new QCheckListItem( tests, tr( "3. Text Rendering " ), QCheckListItem::CheckBox );
test_gfx = new QCheckListItem( tests, tr( "4. Gfx Rendering " ), QCheckListItem::CheckBox );
test_ram = new QCheckListItem( tests, tr( "5. RAM Performance " ), QCheckListItem::CheckBox );
test_sd = new QCheckListItem( tests, tr( "6. SD Card Performance " ), QCheckListItem::CheckBox );
test_cf = new QCheckListItem( tests, tr( "7. CF Card Performance " ), QCheckListItem::CheckBox );
test_alu->setText( 1, "n/a" );
test_fpu->setText( 1, "n/a" );
test_txt->setText( 1, "n/a" );
test_gfx->setText( 1, "n/a" );
test_ram->setText( 1, "n/a" );
test_sd->setText( 1, "n/a" );
test_cf->setText( 1, "n/a" );
test_alu->setText( 2, "n/a" );
test_fpu->setText( 2, "n/a" );
test_txt->setText( 2, "n/a" );
test_gfx->setText( 2, "n/a" );
test_ram->setText( 2, "n/a" );
test_sd->setText( 2, "n/a" );
test_cf->setText( 2, "n/a" );
startButton = new QPushButton( tr( "&Start Tests!" ), this );
connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) );
vb->addWidget( tests, 2 );
QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" );
if ( f.open( IO_ReadOnly ) )
{
machineCombo = new QComboBox( this );
QTextStream ts( &f );
while( !ts.eof() )
{
QString machline = ts.readLine();
qDebug( "sysinfo: parsing benchmark results for '%s'", (const char*) machline );
QString resline = ts.readLine();
machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) );
machineCombo->insertItem( machline );
}
QHBoxLayout* hb = new QHBoxLayout( vb );
hb->addWidget( new QLabel( tr( "Compare To:" ), this ) );
hb->addWidget( machineCombo, 2 );
- connect( machineCombo, SIGNAL( activated( int ) ), this, SLOT( machineActivated( int ) ) );
+ connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) );
}
vb->addWidget( startButton, 2 );
}
BenchmarkInfo::~BenchmarkInfo()
{}
void BenchmarkInfo::machineActivated( int index )
{
QStringList* results = machines[ machineCombo->text( index ) ];
if ( !results )
{
qDebug( "sysinfo: no results available." );
return;
}
QStringList::Iterator it = results->begin();
test_alu->setText( 2, *(it++) );
test_fpu->setText( 2, *(it++) );
test_txt->setText( 2, *(it++) );
test_gfx->setText( 2, *(it++) );
test_ram->setText( 2, *(it++) );
test_sd->setText( 2, *(it++) );
test_cf->setText( 2, *(it++) );
}
void BenchmarkInfo::run()
{
startButton->setText( "> Don't touch! Running Tests! Don't touch! <" );
qApp->processEvents();
QTime t;
if ( test_alu->isOn() )
{
int d = round( dhry_main( DHRYSTONE_RUNS ) );
test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) );
test_alu->setOn( false );
}
if ( test_fpu->isOn() )
{
t.start();
BenchFFT();
test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) );
test_fpu->setOn( false );
}
if ( test_txt->isOn() )
{
int value = textRendering( TEST_DURATION );
test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) );
test_txt->setOn( false );
}
if ( test_gfx->isOn() )
{
int value = gfxRendering( TEST_DURATION );
test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests
test_gfx->setOn( false );
}
if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA
{
performFileTest( "/tmp/benchmarkFile.dat", test_ram );
}
if ( test_cf->isOn() )
{
OStorageInfo storage;
performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf );
}
if ( test_sd->isOn() )
{
OStorageInfo storage;
performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd );
}
startButton->setText( tr( "&Start Tests!" ) );
}
int BenchmarkInfo::textRendering( int seconds )
{
QTime t;
t.start();
int stop = t.elapsed() + seconds * 1000;
int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 };
int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 };
int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 };
const QString text( "Opie Benchmark Test" );
int w = QApplication::desktop()->width();
int h = QApplication::desktop()->height();
srand( time( NULL ) );
BenchmarkPaintWidget bpw;
int loops = 0;
while ( t.elapsed() < stop )
{
int k = rand() % 9;
int s = rand() % 100;
bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) );
bpw.p.setFont( QFont( "Vera", s ) );
bpw.p.drawText( rand() % w, rand() % h, text, text.length() );
++loops;
}
return loops * text.length();
}
int BenchmarkInfo::gfxRendering( int seconds )
{
int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 };
int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 };
int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 };
int w = QApplication::desktop()->width();
int h = QApplication::desktop()->height();
srand( time( NULL ) );
BenchmarkPaintWidget bpw;
QTime t;
t.start();
int stop = t.elapsed() + seconds*1000;
int loops = 0;
while ( t.elapsed() < stop )
{
int k = rand() % 9;
bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) );
bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h );
++loops;
}
t.restart();
stop = t.elapsed() + seconds*1000;
while ( t.elapsed() < stop )
{
int k = rand() % 9;
bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) );
bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 );
++loops;
}
QBrush br1;
br1.setStyle( SolidPattern );
t.restart();
stop = t.elapsed() + seconds*1000;
while ( t.elapsed() < stop )
{
int k = rand() % 9;
br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) );
bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 );
++loops;
}
QPixmap p = Resource::loadPixmap( "sysinfo/pattern" );
t.restart();
stop = t.elapsed() + seconds*1000;
while ( t.elapsed() < stop )
{
bpw.p.drawPixmap( rand()%w, rand()%h, p );
++loops;
}
return loops;
}
void BenchmarkInfo::performFileTest( const QString& fname, QCheckListItem* item )
{
QTime time;
time.start();
if ( writeFile( fname ) &&
readFile( fname ) )
{
QFile::remove( fname );
item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) );
item->setOn( false );
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp
index 9cb8ad2..e688a29 100644
--- a/noncore/settings/sysinfo/modulesinfo.cpp
+++ b/noncore/settings/sysinfo/modulesinfo.cpp
@@ -1,190 +1,190 @@
/**********************************************************************
** ModulesInfo
**
** Display Modules information
**
** Copyright (C) 2002, Michael Lauer
** mickey@tm.informatik.uni-frankfurt.de
** http://www.Vanille.de
**
** Based on ProcessInfo by Dan Williams <williamsdr@acm.org>
**
** 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.
**
**********************************************************************/
#include "modulesinfo.h"
#include "detail.h"
/* OPIE */
#include <qpe/qpeapplication.h>
/* QT */
#include <qfile.h>
#include <qlayout.h>
#include <qmessagebox.h>
#include <qtimer.h>
#include <qwhatsthis.h>
ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl )
: QWidget( parent, name, fl )
{
QGridLayout *layout = new QGridLayout( this );
layout->setSpacing( 4 );
layout->setMargin( 4 );
ModulesView = new QListView( this );
int colnum = ModulesView->addColumn( tr( "Module" ) );
colnum = ModulesView->addColumn( tr( "Size" ) );
ModulesView->setColumnAlignment( colnum, Qt::AlignRight );
colnum = ModulesView->addColumn( tr( "Use#" ) );
ModulesView->setColumnAlignment( colnum, Qt::AlignRight );
colnum = ModulesView->addColumn( tr( "Used by" ) );
ModulesView->setAllColumnsShowFocus( TRUE );
layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 );
QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) );
// Test if we have /sbin/modinfo, and if so, allow module detail window
if ( QFile::exists( "/sbin/modinfo" ) )
{
QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold );
- connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
- this, SLOT( viewModules( QListViewItem * ) ) );
+ connect( ModulesView, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ),
+ this, SLOT( viewModules(QListViewItem*) ) );
}
CommandCB = new QComboBox( FALSE, this );
CommandCB->insertItem( "modprobe -r" );
CommandCB->insertItem( "rmmod" );
// I can't think of other useful commands yet. Anyone?
layout->addWidget( CommandCB, 1, 0 );
QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) );
QPushButton *btn = new QPushButton( this );
btn->setMinimumSize( QSize( 50, 24 ) );
btn->setMaximumSize( QSize( 50, 24 ) );
btn->setText( tr( "Send" ) );
connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) );
layout->addWidget( btn, 1, 1 );
QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) );
QTimer *t = new QTimer( this );
connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
t->start( 5000 );
updateData();
ModulesDtl = new Detail();
QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) );
}
ModulesInfo::~ModulesInfo()
{}
void ModulesInfo::updateData()
{
char modname[64];
char usage[200];
int modsize, usecount;
QString selectedmod;
QListViewItem *curritem = ModulesView->currentItem();
if ( curritem )
{
selectedmod = curritem->text( 0 );
}
ModulesView->clear();
FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r");
if ( procfile )
{
QListViewItem *newitem;
QListViewItem *selecteditem = 0x0;
while ( true )
{
modname[0] = '\0';
usage[0] = '\0';
int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage );
if ( success == EOF )
break;
QString qmodname = QString( modname );
QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' );
QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' );
QString qusage = QString( usage );
newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage );
if ( qmodname == selectedmod )
{
selecteditem = newitem;
}
}
ModulesView->setCurrentItem( selecteditem );
fclose( procfile );
}
}
void ModulesInfo::slotSendClicked()
{
if ( !ModulesView->currentItem() )
{
return;
}
QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() );
QString modname = ModulesView->currentItem()->text( 0 );
if ( QMessageBox::warning( this, modname, capstr,
QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes )
{
QString command = "/sbin/";
command.append( CommandCB->currentText() );
command.append( " " );
command.append( modname );
FILE* stream = popen( command, "r" );
if ( stream )
pclose( stream );
}
}
void ModulesInfo::viewModules( QListViewItem *modules )
{
QString modname = modules->text( 0 );
QString capstr = "Module: ";
capstr.append( modname );
ModulesDtl->setCaption( capstr );
QString command = "/sbin/modinfo ";
command.append( modname );
FILE* modinfo = popen( command, "r" );
if ( modinfo )
{
char line[200];
ModulesDtl->detailView->setText( " Details:\n------------\n" );
while( true )
{
int success = fscanf( modinfo, "%[^\n]\n", line );
if ( success == EOF )
break;
ModulesDtl->detailView->append( line );
}
pclose( modinfo );
}
QPEApplication::showWidget( ModulesDtl );
}
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp
index 2a90b0f..69b4ab5 100644
--- a/noncore/settings/sysinfo/processinfo.cpp
+++ b/noncore/settings/sysinfo/processinfo.cpp
@@ -1,202 +1,202 @@
/**********************************************************************
** ProcessInfo
**
** Display process information
**
** Copyright (C) 2002, Dan Williams
** williamsdr@acm.org
** http://draknor.net
**
** 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.
**
**********************************************************************/
#include "processinfo.h"
#include "detail.h"
/* OPIE */
#include <qpe/qpeapplication.h>
/* QT */
#include <qdir.h>
#include <qlayout.h>
#include <qmessagebox.h>
#include <qtimer.h>
#include <qwhatsthis.h>
/* STD */
#include <sys/types.h>
#include <signal.h>
ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl )
: QWidget( parent, name, fl )
{
QGridLayout *layout = new QGridLayout( this );
layout->setSpacing( 4 );
layout->setMargin( 4 );
ProcessView = new QListView( this, "ProcessView" );
int colnum = ProcessView->addColumn( tr( "PID" ) );
ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
colnum = ProcessView->addColumn( tr( "Command" ),96 );
colnum = ProcessView->addColumn( tr( "Status" ) );
colnum = ProcessView->addColumn( tr( "Time" ) );
ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
ProcessView->setAllColumnsShowFocus( TRUE );
QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold );
- connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
- this, SLOT( viewProcess( QListViewItem * ) ) );
+ connect( ProcessView, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ),
+ this, SLOT( viewProcess(QListViewItem*) ) );
layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 );
QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) );
SignalCB = new QComboBox( FALSE, this, "SignalCB" );
SignalCB->insertItem( " 1: SIGHUP" );
SignalCB->insertItem( " 2: SIGINT" );
SignalCB->insertItem( " 3: SIGQUIT" );
SignalCB->insertItem( " 5: SIGTRAP" );
SignalCB->insertItem( " 6: SIGABRT" );
SignalCB->insertItem( " 9: SIGKILL" );
SignalCB->insertItem( "14: SIGALRM" );
SignalCB->insertItem( "15: SIGTERM" );
SignalCB->insertItem( "18: SIGCONT" );
SignalCB->insertItem( "19: SIGSTOP" );
layout->addWidget( SignalCB, 1, 0 );
QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) );
SendButton = new QPushButton( this, "SendButton" );
SendButton->setMinimumSize( QSize( 50, 24 ) );
SendButton->setMaximumSize( QSize( 50, 24 ) );
SendButton->setText( tr( "Send" ) );
connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) );
layout->addWidget( SendButton, 1, 1 );
QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) );
QTimer *t = new QTimer( this );
connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
t->start( 5000 );
updateData();
ProcessDtl = new Detail();
QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) );
}
ProcessInfo::~ProcessInfo()
{}
void ProcessInfo::updateData()
{
int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime,
signal, blocked, sigignore, sigcatch;
uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode,
endcode, startstack, kstkesp, kstkeip, wchan;
char state;
char comm[64];
QString selectedpid;
QListViewItem *curritem = ProcessView->currentItem();
if ( curritem )
{
selectedpid = curritem->text( 0 );
}
ProcessView->clear();
QListViewItem *newitem;
QListViewItem *selecteditem = 0x0;
QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs);
QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList()));
if ( proclist )
{
QFileInfoListIterator it(*proclist);
QFileInfo *f;
while ( ( f = it.current() ) != 0 )
{
++it;
QString processnum = f->fileName();
if ( processnum >= "1" && processnum <= "99999" )
{
FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r");
if ( procfile )
{
fscanf( procfile,
"%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u",
&pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt,
&majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout,
&itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack,
&kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan );
processnum = processnum.rightJustify( 5, ' ' );
QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" );
QString processstatus = QChar(state);
QString processtime = QString::number( ( utime + stime ) / 100 );
processtime = processtime.rightJustify( 9, ' ' );
fclose( procfile );
newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime );
if ( processnum == selectedpid )
{
selecteditem = newitem;
}
}
}
}
ProcessView->setCurrentItem( selecteditem );
}
delete proclist;
delete procdir;
}
void ProcessInfo::slotSendClicked()
{
QListViewItem *currprocess = ProcessView->currentItem();
if ( !currprocess )
{
return;
}
QString capstr = tr( "Really want to send %1\nto this process?" ).arg( SignalCB->currentText() );
if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr,
QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes )
{
currprocess = ProcessView->currentItem();
if ( currprocess )
{
QString sigstr = SignalCB->currentText();
sigstr.truncate(2);
int sigid = sigstr.toUInt();
kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid );
}
}
}
void ProcessInfo::viewProcess( QListViewItem *process )
{
QString pid= process->text( 0 ).stripWhiteSpace();
QString command = process->text( 1 );
ProcessDtl->setCaption( pid + " - " + command );
FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r");
if ( statfile )
{
char line[81];
fgets( line, 81, statfile );
ProcessDtl->detailView->setText( line );
while ( fgets( line, 81, statfile ) )
{
ProcessDtl->detailView->append( line );
}
fclose( statfile );
}
QPEApplication::showWidget( ProcessDtl );
}
diff --git a/noncore/settings/tabmanager/tabmanager.cpp b/noncore/settings/tabmanager/tabmanager.cpp
index ff5957c..15aeaf5 100644
--- a/noncore/settings/tabmanager/tabmanager.cpp
+++ b/noncore/settings/tabmanager/tabmanager.cpp
@@ -1,231 +1,231 @@
#include "tabmanager.h"
#include "app.h"
#include "wait.h"
#include "tabapplnk.h"
#include <qpe/applnk.h>
#include <qdir.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qlistview.h>
#include <qheader.h>
#include <qcombobox.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qmessagebox.h>
#include <stdlib.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#define HOME_APP_DIR QPEApplication::qpeDir()+"/apps"
#define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info"
#define NEW_FOLDER "EmptyTab"
#define NEW_APPLICATION "NewApp"
#define APPLICATION_EXTENSION ".desktop"
#define APPLICATION_EXTENSION_LENGTH 8
/**
* Constructor. Sets up signals. Performs initial scan of applications
* and tabs
*/
TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false), application(NULL){
rescanFolder(HOME_APP_DIR);
// Connect the signals and slots
- connect(tabList, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(editItem(QListViewItem*)));
+ connect(tabList, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(editItem(QListViewItem*)));
(tabList->header())->hide();
- connect(tabList, SIGNAL(moveItem(QListViewItem *, QListViewItem *)), this, SLOT(moveApplication(QListViewItem *, QListViewItem *)));
+ connect(tabList, SIGNAL(moveItem(QListViewItem*,QListViewItem*)), this, SLOT(moveApplication(QListViewItem*,QListViewItem*)));
}
/**
* If anything in the tab's have been changed then update the system or alert
* the user.
*/
TabManager::~TabManager(){
if(changed){
// Prompt.
//int answer = QMessageBox::warning(this, "Message", "Should your desktop be","Yes", "Cancel", 0, 1 );
//if (answer)
// return;
QCopEnvelope e("QPE/System", "linkChanged(QString)");
QString link; //we'll just send an empty string
e << link;
}
}
/**
* Scans root directory for any tabs or applications. Will recursivly go down,
* but will not follow symlinks.
* @param directory - the directory to look in.
* @param parent - the parent to place any new tabs or apps into. If parent is
* NULL then the item is a tab and should be placed as a child of the window.
*/
void TabManager::rescanFolder(QString directory, QListViewItem* parent){
//qDebug(QString("rescanFolder: ") + directory.latin1());
QDir d;
d.setPath(directory);
// Show hidden files for .directories
d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs);
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list ); // create list iterator
QFileInfo *fi; // pointer for traversing
while ( (fi=it.current()) ) { // for each file...
// If it is a dir and not .. or . then add it as a tab and go down.
if(fi->isDir()){
if(fi->fileName() != ".." && fi->fileName() != ".") {
QListViewItem* newItem;
if(!parent)
newItem = new QListViewItem(tabList, fi->fileName());
else
newItem = new QListViewItem(parent, fi->fileName());
itemList.insert(newItem, directory + "/" + fi->fileName() + "/.directory" );
rescanFolder(directory + "/" + fi->fileName(), newItem);
}
}
else{
// it is a file, if not a .directory add to parent.
// Change parents name and icon to reflect icon.
if(fi->fileName() == ".directory"){
AppLnk app(directory + "/" + fi->fileName());
if(parent){
parent->setPixmap(0,app.pixmap());
parent->setText(0, app.name());
}
}
else{
// Add any desktop files found.
QListViewItem* newItem;
if(directory != HOME_APP_DIR){
if(!parent)
newItem = new QListViewItem(tabList, fi->fileName());
else
newItem = new QListViewItem(parent, fi->fileName());
if(fi->fileName().right(APPLICATION_EXTENSION_LENGTH) == APPLICATION_EXTENSION){
AppLnk app(directory + "/" + fi->fileName());
newItem->setPixmap(0,app.pixmap());
newItem->setText(0, app.name());
itemList.insert(newItem, directory + "/" + fi->fileName());
}
}
}
}
++it; // goto next list element
}
}
/**
* Create a new blank Tab.
* Create a physical folder with .directory file
* Create a item on the list
*/
void TabManager::newFolder(){
QDir r;
r.mkdir(QString(HOME_APP_DIR) + "/" + NEW_FOLDER);
system((QString("echo [Desktop Entry] | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1());
system((QString("echo Name=" NEW_FOLDER " | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1());
QString homeLocation = QString(HOME_APP_DIR) + "/" + NEW_FOLDER + "/.directory";
QListViewItem *newItem = new QListViewItem(tabList, NEW_FOLDER);
itemList.insert(newItem, homeLocation );
// We have changed something.
changed = true;
}
/**
* Create a new blank application
* Make sure a tab is selected
* create physical file
* fill file with default information (entry, name, type).
*/
void TabManager::newApplication(){
QListViewItem *item = tabList->currentItem();
if(!item || item->parent())
return;
QString parentDir = itemList[item].mid(0,itemList[item].length()-11);
QString homeLocation = parentDir + "/" NEW_APPLICATION APPLICATION_EXTENSION;
system((QString("echo [Desktop Entry] | cat >> ") + homeLocation).latin1());
system((QString("echo Name=" NEW_APPLICATION " | cat >> ") + homeLocation).latin1());
int slash = parentDir.findRev('/', -1);
QString folderName = parentDir.mid(slash+1, parentDir.length());
system((QString("echo Type=") + folderName + " | cat >> " + homeLocation).latin1());
// Insert into the tree
QListViewItem *newItem = new QListViewItem(item, NEW_APPLICATION);
itemList.insert(newItem, homeLocation );
// We have changed something.
changed = true;
}
/**
* Remove the item.
* Check if we can
* Prompt user
* Delete physical file (Dir, remove .dir, then dir. File, remove file)
* Remove from installer if need too.
*/
void TabManager::removeItem(){
// Make sure we can delete
QListViewItem *item = tabList->currentItem();
if(!item)
return;
if(item->childCount() > 0){
QMessageBox::critical(this, tr("Message"), tr("Can't remove with applications\nstill in the group."), tr("Ok") );
return;
}
// Prompt.
int answer = QMessageBox::warning(this, tr("Message"), tr("Are you sure you want to delete?"), tr("Yes"), tr("Cancel"), 0, 1 );
if (answer)
return;
bool removeSuccessful = true;
QString location = itemList[item];
// Remove file (.directory in a Directory case)
if(!QFile::remove(location))
removeSuccessful = false;
// Remove directory
if(item->parent() == NULL){
// Remove .directory file string
location = location.mid(0,location.length()-10);
QDir dir;
if(!dir.rmdir(location))
removeSuccessful = false;
else
removeSuccessful = true;
}
// If removing failed.
if(!removeSuccessful){
qDebug((QString("removeItem: ") + location).latin1());
QMessageBox::critical(this, tr("Message"), tr("Can't remove."), tr("Ok") );
return;
}
// Remove from the installer so it wont fail.
// Don't need to do this sense the current install uses rm -f so no error
// Remove from the gui list.
itemList.remove(item);
if(item->parent())
item->parent()->takeItem(item);
delete item;
// We have changed something.
changed = true;
}
/**
* Helper function. Edits the current item.
* calls editItem with the currently selected item.
*/
diff --git a/noncore/settings/usermanager/usermanager.cpp b/noncore/settings/usermanager/usermanager.cpp
index 5411995..a1130d4 100644
--- a/noncore/settings/usermanager/usermanager.cpp
+++ b/noncore/settings/usermanager/usermanager.cpp
@@ -1,257 +1,257 @@
/***************************************************************************
* *
* 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 <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"));
// 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.
QToolBar *toolbar = new QToolBar(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);
layout->addWidget(usersIconView);
- connect(usersIconView,SIGNAL(returnPressed(QListViewItem *)),this,SLOT(showUserMenu(QListViewItem *)));
+ connect(usersIconView,SIGNAL(returnPressed(QListViewItem*)),this,SLOT(showUserMenu(QListViewItem*)));
myTabWidget->addTab(tabpage,"Users");
}
void UserConfig::setupTabAllUsers() {
QWidget *tabpage = new QWidget(this);
QVBoxLayout *layout = new QVBoxLayout(tabpage);
layout->setMargin(5);
usersListView=new QListView(tabpage,"allusers");
usersListView->addColumn("UID");
usersListView->addColumn("Login");
usersListView->addColumn("Username");
layout->addWidget(usersListView);
usersListView->setSorting(1,1);
usersListView->setAllColumnsShowFocus(true);
myTabWidget->addTab(tabpage,"All Users");
}
void UserConfig::setupTabAllGroups() {
QWidget *tabpage = new QWidget(this);
QVBoxLayout *layout = new QVBoxLayout(tabpage);
layout->setMargin(5);
groupsListView=new QListView(tabpage,"groups");
groupsListView->addColumn("GID");
groupsListView->addColumn("Groupname");
layout->addWidget(groupsListView);
groupsListView->setSorting(1,1);
groupsListView->setAllColumnsShowFocus(true);
myTabWidget->addTab(tabpage,"All Groups");
}
void UserConfig::getUsers() {
QString mytext;
QPixmap mypixmap;
QListViewItem *listviewitem;
// Empty the iconview & the listview.
usersIconView->clear();
usersListView->clear();
// availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500.
availableUID=500;
for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) {
accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.)
if(accounts->pw_name.find(QRegExp("^#"),0)) { // Skip commented lines.
new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos);
if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) { // Is this user a "normal" user ?
mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon.
if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) { // Is there an icon for this user? Resource::loadPixmap is caching, doesn't work.
mypixmap=Resource::loadPixmap(QString("usermanager/usericon")); // If this user has no icon, load the default icon.
}
listviewitem=new QListViewItem(usersIconView,"",mytext); // Add the icon+text to the qiconview.
listviewitem->setPixmap(0,mypixmap);
}
if((accounts->pw_uid>=availableUID) && (accounts->pw_uid<65000)) availableUID=accounts->pw_uid+1; // Increase 1 to the latest know UID to get a free uid.
}
}
usersIconView->sort();
}
void UserConfig::addUser() {
if(UserDialog::addUser(availableUID,availableGID)) { // Add the user to the system, also send next available UID and GID.
getUsers(); // Update users views.
getGroups(); // Update groups view.
}
}
void UserConfig::editUser() {
QString username;
if(myTabWidget->currentPageIndex()==0) { // Users
if(usersIconView->currentItem()) { // Any icon selected?
username=usersIconView->currentItem()->text(1); // Get the text associated with the icon.
username=username.left(username.find(" - (",0,true)); // Strip out the username.
if(UserDialog::editUser(username)) { // Bring up the userinfo dialog.
// If there were any changed also update the views.
getUsers();
getGroups();
}
} else {
QMessageBox::information(this,"No selection.","No user has been selected.");
}
}
if(myTabWidget->currentPageIndex()==1) { // All users
if(usersListView->currentItem()) { // Anything changed!?
username=usersListView->currentItem()->text(1); // Get the username.
if(UserDialog::editUser(username)) { // Bring up the userinfo dialog.
// And again update the views if there were any changes.
getUsers();
getGroups();
}
} else {
QMessageBox::information(this,"No selection.","No user has been selected.");
}
}
}
void UserConfig::delUser() {
QString username;
if(myTabWidget->currentPageIndex()==0) { // Users, Iconview.
if(usersIconView->currentItem()) { // Anything selected?
username=usersIconView->currentItem()->text(1); // Get string associated with icon.
username=username.left(username.find(" - (",0,true)); // Strip out the username.
if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) {
if(UserDialog::delUser(username)) { // Delete the user if possible.
// Update views.
getUsers();
getGroups();
}
}
} else {
QMessageBox::information(this,"No selection","No user has been selected.");
}
}
if(myTabWidget->currentPageIndex()==1) { // All users
if(usersListView->currentItem()) { // Anything changed!?
username=usersListView->currentItem()->text(1); // Get the username.
if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) {
if(UserDialog::delUser(username)) { // Try to delete the user.
// Update views.
getUsers();
getGroups();
}
}
} else {
QMessageBox::information(this,"No selection","No user has been selected.");
}
}
}
void UserConfig::getGroups() {
groupsListView->clear(); // Empty the listview.
availableGID=500; // We need to find the next free GID, and are only interested in values between 500 & 65000.
for(QStringList::Iterator it=accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) { // Split the list into lines.
accounts->splitGroupEntry(*it); // Split the line into its components and fill the variables of 'accounts'. (gr_name, gr_uid & gr_mem).
if(accounts->gr_name.find(QRegExp("^#"),0)) { // Skip commented lines.
new QListViewItem(groupsListView,QString::number(accounts->gr_gid),accounts->gr_name);
if((accounts->gr_gid>=availableGID) && (accounts->gr_gid<65000)) availableGID=accounts->gr_gid+1; // Maybe a new free GID.
}
}
}
void UserConfig::addGroup() {
if(GroupDialog::addGroup(availableGID)) getGroups(); // Bring up the add group dialog.
}
void UserConfig::editGroup() {
int gid;
if(groupsListView->currentItem()) { // Any group selected?
gid=groupsListView->currentItem()->text(0).toInt(); // Get the GID from the listview.
if(GroupDialog::editGroup(gid)) getGroups(); // Bring up the edit group dialog.
} else {
QMessageBox::information(this,"No selection","No group has been selected.");
}
}
void UserConfig::delGroup() {
const char *groupname;
if(groupsListView->currentItem()) { // Any group selected?
groupname=groupsListView->currentItem()->text(1); // Get the groupname from the listview.
if(QMessageBox::warning(this,"Delete group","Are you sure you want to\ndelete the group \""+QString(groupname)+"\" ?","&No","&Yes",0,0,1)) {
// If confirmed, try to delete the group.
if(GroupDialog::delGroup(groupname)) getGroups(); // And also update the view afterwards if the user was deleted.
}
} else {
QMessageBox::information(this,"No selection","No group has been selected.");
}
}
void UserConfig::showUserMenu(QListViewItem *item) {
// userPopupMenu.exec(item->mapToGlobal(QPoint(0,0)));
qWarning("Pressed!");
}