summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/zkbapplet/zkbapplet.control2
-rw-r--r--noncore/apps/confedit/opie-confeditor.control2
-rw-r--r--noncore/apps/dagger/opie-dagger.control2
-rw-r--r--noncore/apps/opie-bartender/opie-bartender.control2
-rw-r--r--noncore/apps/opie-console/opie-console-embedix.control2
-rw-r--r--noncore/apps/opie-console/opie-console.control2
-rw-r--r--noncore/apps/opie-gutenbrowser/opie-gutenbrowser.control2
-rw-r--r--noncore/games/bounce/opie-bounce.control2
-rw-r--r--noncore/games/buzzword/opie-buzzword.control2
-rw-r--r--noncore/games/kbill/opie-kbill.control2
-rw-r--r--noncore/games/kcheckers/opie-kcheckers.control2
-rw-r--r--noncore/games/kpacman/opie-kpacman.control2
-rw-r--r--noncore/games/tetrix/ohighscoredlg.cpp81
-rw-r--r--noncore/games/tetrix/ohighscoredlg.h13
-rw-r--r--noncore/games/tetrix/tetrix.pro2
-rw-r--r--noncore/multimedia/camera/opie-camera.control2
-rw-r--r--noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.control2
-rw-r--r--noncore/multimedia/opieplayer2/opie-mediaplayer2.control2
-rw-r--r--noncore/multimedia/powerchord/opie-powerchord.control2
-rw-r--r--noncore/net/mail/libetpanstuff/libetpan.control2
-rw-r--r--noncore/net/mail/libmailwrapper/libmailwrapper.control2
-rw-r--r--noncore/net/mail/opie-mail.control2
-rw-r--r--noncore/net/mail/taskbarapplet/opie-mailapplet.control2
-rw-r--r--noncore/net/opieirc/opie-irc.control2
-rw-r--r--noncore/net/opierdesktop/opie-rdesktop.control2
-rw-r--r--noncore/net/opietooth/blue-pin/main.cc1
-rw-r--r--noncore/net/opietooth/blue-pin/opie-bluepin.control2
-rw-r--r--noncore/net/opietooth/blue-pin/pindlgbase.ui32
-rw-r--r--noncore/net/opietooth/lib/libopietooth1.control2
-rw-r--r--noncore/net/opietooth/manager/opie-bluetoothmanager.control2
-rw-r--r--noncore/net/wellenreiter/opie-wellenreiter.control4
-rw-r--r--noncore/securityplugins/blueping/bluepingplugin.control2
-rw-r--r--noncore/securityplugins/dummy/dummyplugin.control2
-rw-r--r--noncore/securityplugins/notice/notice.control2
-rw-r--r--noncore/securityplugins/pin/pin.control2
-rw-r--r--noncore/settings/networksettings2/activatevpn.cpp6
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetooth.pro14
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp2
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h7
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp354
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h35
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui256
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp31
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h24
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp144
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h14
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h33
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp9
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetooth_NN.h2
-rw-r--r--noncore/settings/networksettings2/bluetooth/config.in2
-rw-r--r--noncore/settings/networksettings2/bluetooth/opie-networksettings2plugin-bluetooth.control4
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.cpp9
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.h2
-rw-r--r--noncore/settings/networksettings2/cable/cable_NNI.cpp14
-rw-r--r--noncore/settings/networksettings2/cable/cable_NNI.h6
-rw-r--r--noncore/settings/networksettings2/cable/cabledata.h7
-rw-r--r--noncore/settings/networksettings2/cable/cableedit.cpp4
-rw-r--r--noncore/settings/networksettings2/cable/cableedit.h4
-rw-r--r--noncore/settings/networksettings2/cable/cablerun.cpp18
-rw-r--r--noncore/settings/networksettings2/cable/cablerun.h18
-rw-r--r--noncore/settings/networksettings2/cable/opie-networksettings2plugin-cable.control2
-rw-r--r--noncore/settings/networksettings2/config.in5
-rw-r--r--noncore/settings/networksettings2/editconnection.cpp188
-rw-r--r--noncore/settings/networksettings2/irda/irda_NN.cpp9
-rw-r--r--noncore/settings/networksettings2/irda/irda_NN.h2
-rw-r--r--noncore/settings/networksettings2/irda/irdadata.h5
-rw-r--r--noncore/settings/networksettings2/irda/irdarun.h23
-rw-r--r--noncore/settings/networksettings2/irda/opie-networksettings2plugin-irda.control2
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NN.cpp12
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NN.h2
-rw-r--r--noncore/settings/networksettings2/lancard/lancarddata.h5
-rw-r--r--noncore/settings/networksettings2/lancard/lancardrun.cpp110
-rw-r--r--noncore/settings/networksettings2/lancard/lancardrun.h28
-rw-r--r--noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control2
-rw-r--r--noncore/settings/networksettings2/main.cpp46
-rw-r--r--noncore/settings/networksettings2/modem/modem_NN.cpp11
-rw-r--r--noncore/settings/networksettings2/modem/modem_NN.h2
-rw-r--r--noncore/settings/networksettings2/modem/modemdata.h5
-rw-r--r--noncore/settings/networksettings2/modem/modemedit.cpp4
-rw-r--r--noncore/settings/networksettings2/modem/modemedit.h4
-rw-r--r--noncore/settings/networksettings2/modem/modemrun.h23
-rw-r--r--noncore/settings/networksettings2/modem/opie-networksettings2plugin-modem.control2
-rw-r--r--noncore/settings/networksettings2/network/network_NN.cpp40
-rw-r--r--noncore/settings/networksettings2/network/network_NN.h8
-rw-r--r--noncore/settings/networksettings2/network/network_NNI.cpp50
-rw-r--r--noncore/settings/networksettings2/network/network_NNI.h10
-rw-r--r--noncore/settings/networksettings2/network/networkdata.h5
-rw-r--r--noncore/settings/networksettings2/network/networkedit.cpp4
-rw-r--r--noncore/settings/networksettings2/network/networkedit.h4
-rw-r--r--noncore/settings/networksettings2/network/networkrun.cpp91
-rw-r--r--noncore/settings/networksettings2/network/networkrun.h19
-rw-r--r--noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control2
-rw-r--r--noncore/settings/networksettings2/networksettings.cpp277
-rw-r--r--noncore/settings/networksettings2/networksettings.h26
-rw-r--r--noncore/settings/networksettings2/networksettings.pro6
-rw-r--r--noncore/settings/networksettings2/networksettings2/GUIUtils.h9
-rw-r--r--noncore/settings/networksettings2/networksettings2/Utils.h2
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.cpp224
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.h266
-rw-r--r--noncore/settings/networksettings2/networksettings2/networksettings2.pro6
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.cpp70
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.h6
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.cpp298
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.h63
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.cpp70
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.h11
-rw-r--r--noncore/settings/networksettings2/networksettingsGUI.ui118
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp252
-rw-r--r--noncore/settings/networksettings2/nsdata.h13
-rw-r--r--noncore/settings/networksettings2/ppp/PPPAuthedit.cpp4
-rw-r--r--noncore/settings/networksettings2/ppp/PPPAuthedit.h4
-rw-r--r--noncore/settings/networksettings2/ppp/PPPDNSedit.cpp4
-rw-r--r--noncore/settings/networksettings2/ppp/PPPDNSedit.h4
-rw-r--r--noncore/settings/networksettings2/ppp/PPPGUI.ui20
-rw-r--r--noncore/settings/networksettings2/ppp/PPPIPGUI.ui255
-rw-r--r--noncore/settings/networksettings2/ppp/PPPIPedit.cpp37
-rw-r--r--noncore/settings/networksettings2/ppp/PPPIPedit.h4
-rw-r--r--noncore/settings/networksettings2/ppp/PPPedit.cpp11
-rw-r--r--noncore/settings/networksettings2/ppp/PPPedit.h14
-rw-r--r--noncore/settings/networksettings2/ppp/opie-networksettings2plugin-ppp.control2
-rw-r--r--noncore/settings/networksettings2/ppp/ppp.pro11
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NN.cpp36
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NN.h6
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NNI.cpp154
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NNI.h12
-rw-r--r--noncore/settings/networksettings2/ppp/pppdata.h22
-rw-r--r--noncore/settings/networksettings2/ppp/ppprun.cpp56
-rw-r--r--noncore/settings/networksettings2/ppp/ppprun.h34
-rw-r--r--noncore/settings/networksettings2/profile/opie-networksettings2plugin-bluetooth.control4
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.cpp13
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.h2
-rw-r--r--noncore/settings/networksettings2/profile/profile_NNI.cpp13
-rw-r--r--noncore/settings/networksettings2/profile/profile_NNI.h4
-rw-r--r--noncore/settings/networksettings2/profile/profiledata.h5
-rw-r--r--noncore/settings/networksettings2/profile/profileedit.cpp10
-rw-r--r--noncore/settings/networksettings2/profile/profileedit.h8
-rw-r--r--noncore/settings/networksettings2/profile/profilerun.cpp72
-rw-r--r--noncore/settings/networksettings2/profile/profilerun.h24
-rw-r--r--noncore/settings/networksettings2/usb/opie-networksettings2plugin-usb.control2
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.cpp12
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.h2
-rw-r--r--noncore/settings/networksettings2/usb/usb_NNI.cpp12
-rw-r--r--noncore/settings/networksettings2/usb/usb_NNI.h4
-rw-r--r--noncore/settings/networksettings2/usb/usbdata.h5
-rw-r--r--noncore/settings/networksettings2/usb/usbedit.cpp4
-rw-r--r--noncore/settings/networksettings2/usb/usbedit.h4
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.cpp102
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.h27
-rw-r--r--noncore/settings/networksettings2/vpn/opie-networksettings2plugin-vpn.control2
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NN.cpp8
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NN.h2
-rw-r--r--noncore/settings/networksettings2/vpn/vpndata.h5
-rw-r--r--noncore/settings/networksettings2/vpn/vpnedit.cpp4
-rw-r--r--noncore/settings/networksettings2/vpn/vpnedit.h4
-rw-r--r--noncore/settings/networksettings2/vpn/vpnrun.cpp5
-rw-r--r--noncore/settings/networksettings2/vpn/vpnrun.h25
-rw-r--r--noncore/settings/networksettings2/wlan/opie-networksettings2plugin-wlan.control2
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NN.cpp12
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NN.h2
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NNI.cpp22
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NNI.h4
-rw-r--r--noncore/settings/networksettings2/wlan/wlandata.h5
-rw-r--r--noncore/settings/networksettings2/wlan/wlanedit.cpp6
-rw-r--r--noncore/settings/networksettings2/wlan/wlanedit.h8
-rw-r--r--noncore/settings/networksettings2/wlan/wlanrun.cpp91
-rw-r--r--noncore/settings/networksettings2/wlan/wlanrun.h27
-rw-r--r--noncore/settings/packagemanager/oconfitem.h7
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp7
-rw-r--r--noncore/settings/packagemanager/opie-packagemanager.control4
-rw-r--r--noncore/tools/opie-sh/opie-sh.control2
-rw-r--r--noncore/tools/opie-sh/scripts/opie-sh-wavelanchooser.control2
-rw-r--r--noncore/unsupported/filebrowser/opie-filebrowser.control2
-rw-r--r--noncore/unsupported/gsmtool/opie-gsmtool.control2
-rw-r--r--noncore/unsupported/oipkg/opie-oipkg.control2
-rw-r--r--noncore/unsupported/ubrowser/opie-ubrowser.control2
175 files changed, 2876 insertions, 2059 deletions
diff --git a/noncore/applets/zkbapplet/zkbapplet.control b/noncore/applets/zkbapplet/zkbapplet.control
index 4e03c26..08b540f 100644
--- a/noncore/applets/zkbapplet/zkbapplet.control
+++ b/noncore/applets/zkbapplet/zkbapplet.control
@@ -6,5 +6,5 @@ Maintainer: Rajko Albrecht <alwin@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal 7Depends: task-opie-minimal
8Description: ZKB Applet and configuration program 8Description: ZKB Applet and configuration program
9Obsoletes: keyz-cfg 9Obsoletes: keyz-cfg
10Version: 0.6.0$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/apps/confedit/opie-confeditor.control b/noncore/apps/confedit/opie-confeditor.control
index 00a05da..b49aad3 100644
--- a/noncore/apps/confedit/opie-confeditor.control
+++ b/noncore/apps/confedit/opie-confeditor.control
@@ -3,7 +3,7 @@ Files: bin/confedit apps/Settings/confedit.desktop pics/confedit/confedit.png pl
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Patrick S. Vogt <tille@handhelds.org> 5Maintainer: Patrick S. Vogt <tille@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal, libopiecore2 8Depends: task-opie-minimal, libopiecore2
9Description: An enditor for the ~/Settings/*.conf files 9Description: An enditor for the ~/Settings/*.conf files
diff --git a/noncore/apps/dagger/opie-dagger.control b/noncore/apps/dagger/opie-dagger.control
index 4ded1f2..cfb45be 100644
--- a/noncore/apps/dagger/opie-dagger.control
+++ b/noncore/apps/dagger/opie-dagger.control
@@ -5,5 +5,5 @@ Section: opie/applications
5Depends: task-opie-minimal, libopiecore2, libopieui2 5Depends: task-opie-minimal, libopiecore2, libopieui2
6Architecture: arm 6Architecture: arm
7Maintainer: Dan Williams (drw@handhelds.org) 7Maintainer: Dan Williams (drw@handhelds.org)
8Description: A Bible study program utilizing the Sword library. 8Description: A Bible study program utilizing the Sword library.
9Version: 0.9.1$EXTRAVERSION 9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/apps/opie-bartender/opie-bartender.control b/noncore/apps/opie-bartender/opie-bartender.control
index 045c68e..29ad0ba 100644
--- a/noncore/apps/opie-bartender/opie-bartender.control
+++ b/noncore/apps/opie-bartender/opie-bartender.control
@@ -3,8 +3,8 @@ Priority: optional
3Package: opie-bartender 3Package: opie-bartender
4Section: opie/applications 4Section: opie/applications
5Maintainer: L.J. Potter <lpotter@trolltech.com> 5Maintainer: L.J. Potter <lpotter@trolltech.com>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal 8Depends: task-opie-minimal
9Description: Bartender drink receipe database lookup, and 9Description: Bartender drink receipe database lookup, and
10 blood alcohol estimator. 10 blood alcohol estimator.
diff --git a/noncore/apps/opie-console/opie-console-embedix.control b/noncore/apps/opie-console/opie-console-embedix.control
index cf27554..e902d0e 100644
--- a/noncore/apps/opie-console/opie-console-embedix.control
+++ b/noncore/apps/opie-console/opie-console-embedix.control
@@ -3,8 +3,8 @@ Files: bin/opie-console apps/Applications/opie-console.desktop pics/console/* sh
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Opie Team <opie@handhelds.org> 5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 0.6-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: qpe-base, libopiecore2, libopieui2, opie-console-help-en, lrzsz, opie-keytabs 8Depends: qpe-base, libopiecore2, libopieui2, opie-console-help-en, lrzsz, opie-keytabs
9License: GPL 9License: GPL
10Description: Opie terminal app 10Description: Opie terminal app
diff --git a/noncore/apps/opie-console/opie-console.control b/noncore/apps/opie-console/opie-console.control
index e924b79..b64898b 100644
--- a/noncore/apps/opie-console/opie-console.control
+++ b/noncore/apps/opie-console/opie-console.control
@@ -3,8 +3,8 @@ Files: bin/opie-console apps/Applications/opie-console.desktop pics/console/*
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Opie Team <opie@handhelds.org> 5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 0.6-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: qpe-base, libopiecore2, libopieui2, opie-console-help-en, lrzsz, opie-keytabs 8Depends: qpe-base, libopiecore2, libopieui2, opie-console-help-en, lrzsz, opie-keytabs
9License: GPL 9License: GPL
10Description: Opie terminal app 10Description: Opie terminal app
diff --git a/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.control b/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.control
index 47fbcdf..bc0283e 100644
--- a/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.control
+++ b/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.control
@@ -4,8 +4,8 @@ Priority: optional
4Section: opie 4Section: opie
5Maintainer: ljp <lpotter@trolltech.com> 5Maintainer: ljp <lpotter@trolltech.com>
6Source: opie.handhelds.org 6Source: opie.handhelds.org
7Architecture: arm 7Architecture: arm
8Version: $QPE_VERSION-$SUB_VERSION 8Version: $QPE_VERSION$EXTRAVERSION
9Depends: ftplib, libopiecore2, libopieui2 9Depends: ftplib, libopiecore2, libopieui2
10Description: Etext read for the Project Gutenberg. 10Description: Etext read for the Project Gutenberg.
11 11
diff --git a/noncore/games/bounce/opie-bounce.control b/noncore/games/bounce/opie-bounce.control
index dfd1bf0..0513958 100644
--- a/noncore/games/bounce/opie-bounce.control
+++ b/noncore/games/bounce/opie-bounce.control
@@ -1,7 +1,7 @@
1Package: opie-bounce 1Package: opie-bounce
2Files: plugins/application/libbounce.so* bin/bounce apps/Games/bounce.desktop pics/bounce/*.png 2Files: plugins/application/libbounce.so* bin/bounce apps/Games/bounce.desktop pics/bounce/*.png
3Version: 0.6-$SUB_VERSION 3Version: $QPE_VERSION$EXTRAVERSION
4Depends: task-opie-minimal, libopiecore2 4Depends: task-opie-minimal, libopiecore2
5Priority: optional 5Priority: optional
6Section: opie/games 6Section: opie/games
7Maintainer: Martin Imobersteg <imm@gmx.ch> 7Maintainer: Martin Imobersteg <imm@gmx.ch>
diff --git a/noncore/games/buzzword/opie-buzzword.control b/noncore/games/buzzword/opie-buzzword.control
index 3316445..f76a2c2 100644
--- a/noncore/games/buzzword/opie-buzzword.control
+++ b/noncore/games/buzzword/opie-buzzword.control
@@ -1,7 +1,7 @@
1Package: opie-buzzword 1Package: opie-buzzword
2Files: plugins/application/libbuzzword.so* bin/buzzword apps/Games/buzzword.desktop pics/buzzword/buzzword.png share/buzzword/buzzwords 2Files: plugins/application/libbuzzword.so* bin/buzzword apps/Games/buzzword.desktop pics/buzzword/buzzword.png share/buzzword/buzzwords
3Version: 1.1-$SUB_VERSION 3Version: $QPE_VERSION$EXTRAVERSION
4Depends: task-opie-minimal,libopiecore2 4Depends: task-opie-minimal,libopiecore2
5Priority: optional 5Priority: optional
6Section: opie/games 6Section: opie/games
7Maintainer: Martin Imobersteg <imm@gmx.ch> 7Maintainer: Martin Imobersteg <imm@gmx.ch>
diff --git a/noncore/games/kbill/opie-kbill.control b/noncore/games/kbill/opie-kbill.control
index 3299b93..cf12bca 100644
--- a/noncore/games/kbill/opie-kbill.control
+++ b/noncore/games/kbill/opie-kbill.control
@@ -3,9 +3,9 @@ Files: bin/kbill apps/Games/kbill.desktop pics/kbill/*
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Mark Westcott <mark@houseoffish.org> 5Maintainer: Mark Westcott <mark@houseoffish.org>
6Architecture: arm 6Architecture: arm
7Version: 0.8-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal 8Depends: task-opie-minimal
9License: GPL 9License: GPL
10Description: The famous hit Bill game 10Description: The famous hit Bill game
11 Hit Bill as hard as you can before he 11 Hit Bill as hard as you can before he
diff --git a/noncore/games/kcheckers/opie-kcheckers.control b/noncore/games/kcheckers/opie-kcheckers.control
index 5bd03ae..e7c20d3 100644
--- a/noncore/games/kcheckers/opie-kcheckers.control
+++ b/noncore/games/kcheckers/opie-kcheckers.control
@@ -3,8 +3,8 @@ Files: plugins/application/libkcheckers.so* bin/kcheckers apps/Games/kcheckers.d
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: leseb <prudhomme@laposte.net> 5Maintainer: leseb <prudhomme@laposte.net>
6Architecture: arm 6Architecture: arm
7Version: 0.3-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal, libopiecore2 8Depends: task-opie-minimal, libopiecore2
9Description: The game of Checkers 9Description: The game of Checkers
10 A game for the Opie environment. 10 A game for the Opie environment.
diff --git a/noncore/games/kpacman/opie-kpacman.control b/noncore/games/kpacman/opie-kpacman.control
index 68487ec..97120aa 100644
--- a/noncore/games/kpacman/opie-kpacman.control
+++ b/noncore/games/kpacman/opie-kpacman.control
@@ -1,7 +1,7 @@
1Package: opie-kpacman 1Package: opie-kpacman
2Files: plugins/applications/libkpacman.so* bin/kpacman apps/Games/kpacman.desktop pics/kpacman/kpacman.png share/kpacman 2Files: plugins/applications/libkpacman.so* bin/kpacman apps/Games/kpacman.desktop pics/kpacman/kpacman.png share/kpacman
3Version: 0.3.1-$SUB_VERSION 3Version: $QPE_VERSION$EXTRAVERSION
4Depends: task-opie-minimal 4Depends: task-opie-minimal
5Priority: optional 5Priority: optional
6Section: opie/games 6Section: opie/games
7Maintainer: Catalin Climov <catalin@climov.com> 7Maintainer: Catalin Climov <catalin@climov.com>
diff --git a/noncore/games/tetrix/ohighscoredlg.cpp b/noncore/games/tetrix/ohighscoredlg.cpp
index 8d8079e..66f4917 100644
--- a/noncore/games/tetrix/ohighscoredlg.cpp
+++ b/noncore/games/tetrix/ohighscoredlg.cpp
@@ -18,30 +18,27 @@
18#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
19#include <qpe/config.h> 19#include <qpe/config.h>
20 20
21#include <qstring.h> 21#include <qstring.h>
22#include <qlist.h>
22#include <qhbox.h> 23#include <qhbox.h>
23#include <qvbox.h> 24#include <qvbox.h>
24#include <qlabel.h> 25#include <qlabel.h>
25#include <qlistview.h> 26#include <qlistview.h>
26#include <qlineedit.h> 27#include <qlineedit.h>
27 28
28#include "ohighscoredlg.h" 29#include "ohighscoredlg.h"
29 30
30OHighscore::OHighscore( int score , int playerLevel ) 31OHighscore::OHighscore( int score , int playerLevel ) : playerData()
31{ 32{
32 pLevel = playerLevel; 33 pLevel = playerLevel;
33 getList(); 34 getList();
34 checkIfItIsANewhighscore( score ); 35 checkIfItIsANewhighscore( score );
36 playerData.setAutoDelete( TRUE );
35} 37}
36 38
37OHighscore::~OHighscore() 39OHighscore::~OHighscore()
38{ 40{
39 std::list<t_playerData*>::iterator deleteIterator = playerData.begin();
40 for ( ; deleteIterator != playerData.end() ; deleteIterator++ )
41 {
42 delete ( *deleteIterator );
43 }
44} 41}
45 42
46void OHighscore::getList() 43void OHighscore::getList()
47{ 44{
@@ -63,9 +60,9 @@ void OHighscore::getList()
63 pPlayerData->sName = cfg.readEntry( "Name" ); 60 pPlayerData->sName = cfg.readEntry( "Name" );
64 pPlayerData->points = temp; 61 pPlayerData->points = temp;
65 pPlayerData->level = cfg.readNumEntry( "Level" ); 62 pPlayerData->level = cfg.readNumEntry( "Level" );
66 63
67 playerData.push_back( pPlayerData ); 64 playerData.append( pPlayerData );
68 65
69 if ( (temp < lowest) ) lowest = temp; 66 if ( (temp < lowest) ) lowest = temp;
70 rest++; 67 rest++;
71 } 68 }
@@ -82,9 +79,9 @@ void OHighscore::getList()
82 pPlayerData->sName = tr( "empty"); 79 pPlayerData->sName = tr( "empty");
83 pPlayerData->points = 0; 80 pPlayerData->points = 0;
84 pPlayerData->level = 0; 81 pPlayerData->level = 0;
85 82
86 playerData.push_back( pPlayerData ); 83 playerData.append( pPlayerData );
87 } 84 }
88 } 85 }
89 86
90} 87}
@@ -99,43 +96,43 @@ void OHighscore::checkIfItIsANewhighscore( int points)
99 96
100void OHighscore::insertData( QString name , int punkte , int playerLevel ) 97void OHighscore::insertData( QString name , int punkte , int playerLevel )
101{ 98{
102 Config cfg ( "tetrix" ); 99 Config cfg ( "tetrix" );
100 t_playerData * Run;
101 int index = 0;
103 int entryNumber = 1; 102 int entryNumber = 1;
104 std::list<t_playerData*>::iterator insertIterator = playerData.begin(); 103
105 while ( insertIterator != playerData.end() ) 104 for ( Run=playerData.first();
106 { 105 Run != 0;
107 if ( punkte > ( *insertIterator )->points ) 106 index ++, Run=playerData.next() ) {
107
108 if ( punkte > Run->points )
108 { 109 {
109 t_playerData* temp = new t_playerData; 110 t_playerData* temp = new t_playerData;
110 temp->sName = name; 111 temp->sName = name;
111 temp->points = punkte; 112 temp->points = punkte;
112 temp->level = playerLevel; 113 temp->level = playerLevel;
113 playerData.insert( insertIterator , temp ); 114
115 playerData.insert( index, temp );
114 116
115 //now we have to delete the last entry 117 //now we have to delete the last entry
116 insertIterator = playerData.end(); 118 playerData.remove( playerData.count() );
117 insertIterator--;
118 //X delete *insertIterator; //memleak?
119 playerData.erase( insertIterator );
120 119
121 ///////////////////////////////////////// 120 /////////////////////////////////////////
122 //this block just rewrites the highscore 121 //this block just rewrites the highscore
123 insertIterator = playerData.begin(); 122 for ( t_playerData * Run2=playerData.first();
124 while ( insertIterator != playerData.end() ) 123 Run2 != 0;
125 { 124 Run2=playerData.next() ) {
126 cfg.setGroup( QString::number( entryNumber ) ); 125 cfg.setGroup( QString::number( entryNumber ) );
127 cfg.writeEntry( "Name" , ( *insertIterator )->sName ); 126 cfg.writeEntry( "Name" , Run2->sName );
128 cfg.writeEntry( "Points" , ( *insertIterator )->points ); 127 cfg.writeEntry( "Points" , Run2->points );
129 cfg.writeEntry( "Level" , ( *insertIterator )->level ); 128 cfg.writeEntry( "Level" , Run2->level );
130 entryNumber++; 129 entryNumber++;
131 insertIterator++;
132 } 130 }
133 //////////////////////////////////////// 131 ////////////////////////////////////////
134 132
135 return; 133 return;
136 } 134 }
137 insertIterator++;
138 } 135 }
139} 136}
140 137
141QString OHighscore::getName() 138QString OHighscore::getName()
@@ -176,22 +173,32 @@ void OHighscoreDialog::createHighscoreListView()
176{ 173{
177 int pos = 10; 174 int pos = 10;
178 int points_ = 0; 175 int points_ = 0;
179 int level_ = 0; 176 int level_ = 0;
180 177 QListViewItem * Prev = 0;
181 std::list<t_playerData*>::reverse_iterator iListe = hs_->playerData.rbegin(); 178
182 179 for ( t_playerData * Run = hs_->playerData.first();
183 for ( ; iListe != hs_->playerData.rend() ; ++iListe ) 180 Run != 0;
184 { 181 Run=hs_->playerData.next() )
185 QListViewItem *item = new QListViewItem( list ); 182 {
183 QListViewItem *item;
184
185 if( Prev ) {
186 // after previous
187 item = new QListViewItem( list, Prev );
188 Prev = item;
189 } else {
190 item = new QListViewItem( list );
191
192 }
186 item->setText( 0 , QString::number( pos ) ); //number 193 item->setText( 0 , QString::number( pos ) ); //number
187 item->setText( 1 , ( *iListe )->sName ); //name 194 item->setText( 1 , Run->sName ); //name
188 if ( ( *iListe )->points == -1 ) 195 if ( Run->points == -1 )
189 points_ = 0; 196 points_ = 0;
190 else points_ = ( *iListe )->points; 197 else points_ = Run->points;
191 if ( ( *iListe )->level == -1 ) 198 if ( Run->level == -1 )
192 level_ = 0; 199 level_ = 0;
193 else level_ = ( *iListe )->level; 200 else level_ = Run->level;
194 item->setText( 2 , QString::number( points_ ) ); //points 201 item->setText( 2 , QString::number( points_ ) ); //points
195 item->setText( 3 , QString::number( level_ ) ); //level 202 item->setText( 3 , QString::number( level_ ) ); //level
196 pos--; 203 pos--;
197 } 204 }
diff --git a/noncore/games/tetrix/ohighscoredlg.h b/noncore/games/tetrix/ohighscoredlg.h
index fdbe623..845e639 100644
--- a/noncore/games/tetrix/ohighscoredlg.h
+++ b/noncore/games/tetrix/ohighscoredlg.h
@@ -11,14 +11,15 @@ class QWidget;
11class QVBoxLayout; 11class QVBoxLayout;
12class QListView; 12class QListView;
13 13
14#include <qdialog.h> 14#include <qdialog.h>
15#include <list> 15#include <qlist.h>
16 16
17using namespace std; 17class t_playerData
18
19struct t_playerData
20{ 18{
19
20public :
21
21 QString sName; 22 QString sName;
22 int points; 23 int points;
23 int level; 24 int level;
24}; 25};
@@ -44,18 +45,16 @@ class OHighscore : public QWidget
44 * this inserts the new entry at the correct position 45 * this inserts the new entry at the correct position
45 */ 46 */
46 void insertData( QString , int , int ); 47 void insertData( QString , int , int );
47 48
48 list<t_playerData*> playerData; 49 QList<t_playerData> playerData;
49 50
50 /* 51 /*
51 * As Qt/e does not support QInputDialog I did that code myself 52 * As Qt/e does not support QInputDialog I did that code myself
52 */ 53 */
53 QString getName(); 54 QString getName();
54 private: 55 private:
55 56
56 list<t_playerData*>::iterator iPlayerData;
57
58 /* 57 /*
59 * the lowest score in the highscorelist 58 * the lowest score in the highscorelist
60 */ 59 */
61 int lowest; 60 int lowest;
diff --git a/noncore/games/tetrix/tetrix.pro b/noncore/games/tetrix/tetrix.pro
index 580a542..96f452f 100644
--- a/noncore/games/tetrix/tetrix.pro
+++ b/noncore/games/tetrix/tetrix.pro
@@ -11,9 +11,9 @@ SOURCES = main.cpp \
11 tpiece.cpp \ 11 tpiece.cpp \
12 ohighscoredlg.cpp 12 ohighscoredlg.cpp
13INCLUDEPATH += $(OPIEDIR)/include 13INCLUDEPATH += $(OPIEDIR)/include
14 DEPENDPATH+= $(OPIEDIR)/include 14 DEPENDPATH+= $(OPIEDIR)/include
15LIBS += -lqpe -lopiecore2 -lstdc++ 15LIBS += -lqpe -lopiecore2
16 INTERFACES= 16 INTERFACES=
17 TARGET = tetrix 17 TARGET = tetrix
18 18
19 19
diff --git a/noncore/multimedia/camera/opie-camera.control b/noncore/multimedia/camera/opie-camera.control
index d9eaab8..5171050 100644
--- a/noncore/multimedia/camera/opie-camera.control
+++ b/noncore/multimedia/camera/opie-camera.control
@@ -3,8 +3,8 @@ Files: lib/libcamera.* bin/camera bin/capture pics/camera apps/Applications/came
3Priority: optional 3Priority: optional
4Section: opie/multimedia 4Section: opie/multimedia
5Maintainer: Michael 'Mickey' Lauer <mickeyl@Vanille.de> 5Maintainer: Michael 'Mickey' Lauer <mickeyl@Vanille.de>
6Architecture: arm 6Architecture: arm
7Version: 1.0.1 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: libqpe1, libopiecore2, libopieui2 8Depends: libqpe1, libopiecore2, libopieui2
9Description: A Camera Application 9Description: A Camera Application
10 A Camera Application to use with the Sharp CE-AG06. 10 A Camera Application to use with the Sharp CE-AG06.
diff --git a/noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.control b/noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.control
index 1d0fbfb..f4cbc41 100644
--- a/noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.control
+++ b/noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.control
@@ -2,9 +2,9 @@ Package: opie-mediaplayer2-codecs
2Files: root/usr/lib/libao.so* root/usr/lib/libogg* root/usr/lib/libvorbisidec.so* root/usr/lib/libxine.so* root/usr/lib/xine/* 2Files: root/usr/lib/libao.so* root/usr/lib/libogg* root/usr/lib/libvorbisidec.so* root/usr/lib/libxine.so* root/usr/lib/xine/*
3Section: ;ibs 3Section: ;ibs
4Essential: no 4Essential: no
5Priority: optional 5Priority: optional
6Version: 0.7-$SUB_VERSION.3 6Version: $QPE_VERSION$EXTRAVERSION
7Architecture: arm 7Architecture: arm
8Maintainer: Maximilian Reiss <harlekin@handhelds.org> 8Maintainer: Maximilian Reiss <harlekin@handhelds.org>
9Depends: libc6 (>= 2.1), opie-mediaplayer2 9Depends: libc6 (>= 2.1), opie-mediaplayer2
10Description: Codecs for opieplayer 2 10Description: Codecs for opieplayer 2
diff --git a/noncore/multimedia/opieplayer2/opie-mediaplayer2.control b/noncore/multimedia/opieplayer2/opie-mediaplayer2.control
index af6bb01..78cfa8b 100644
--- a/noncore/multimedia/opieplayer2/opie-mediaplayer2.control
+++ b/noncore/multimedia/opieplayer2/opie-mediaplayer2.control
@@ -3,9 +3,9 @@ Files: plugins/application/libopieplayer2.so* bin/opieplayer2 apps/Applications
3Priority: optional 3Priority: optional
4Section: opie/multimedia 4Section: opie/multimedia
5Maintainer: L.J.Potter <ljp@llornkcor.com>, Maximilian Reiss <harlekin@handhelds.org> 5Maintainer: L.J.Potter <ljp@llornkcor.com>, Maximilian Reiss <harlekin@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal, libopie1, zlib1g, opie-mediaplayer2-skin-default | opie-mediaplayer2-skin-default-landscape , libxine1 | opie-mediaplayer2-codecs 7Depends: task-opie-minimal, libopiecore2, libopieui2, libqtaux2, libz1, opie-mediaplayer2-skin-default | opie-mediaplayer2-skin-default-landscape , libxine1 | opie-mediaplayer2-codecs
8Description: The Opie media player 8Description: The Opie media player
9 The mediaplayer for Opie. It plays mp3, mpeg, wav, ogg, quicktime, divx and 9 The mediaplayer for Opie. It plays mp3, mpeg, wav, ogg, quicktime, divx and
10 more. Also it is streaming capable. 10 more. Also it is streaming capable.
11Version: $QPE_VERSION$EXTRAVERSION 11Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/multimedia/powerchord/opie-powerchord.control b/noncore/multimedia/powerchord/opie-powerchord.control
index 39d926b..4b5bc88 100644
--- a/noncore/multimedia/powerchord/opie-powerchord.control
+++ b/noncore/multimedia/powerchord/opie-powerchord.control
@@ -2,9 +2,9 @@ Files: plugins/applications/libpowerchord.so* bin/powerchord apps/Applications/p
2Priority: optional 2Priority: optional
3Section: opie/multimedia 3Section: opie/multimedia
4Maintainer: Camilo Mesias <camilo@mesias.co.uk>, ljp <lpotter@trolltech.com> 4Maintainer: Camilo Mesias <camilo@mesias.co.uk>, ljp <lpotter@trolltech.com>
5Architecture: arm 5Architecture: arm
6Version: 0.0.8 6Version: $QPE_VERSION$EXTRAVERSION
7Depends: task-opie-minimal 7Depends: task-opie-minimal
8Description: Guitar Chord generator application 8Description: Guitar Chord generator application
9 Allows naming of chords using base note and key. Fretboard diagrams are 9 Allows naming of chords using base note and key. Fretboard diagrams are
10 produced illustrating ways to play the chord. 10 produced illustrating ways to play the chord.
diff --git a/noncore/net/mail/libetpanstuff/libetpan.control b/noncore/net/mail/libetpanstuff/libetpan.control
index 2b5b354..b664157 100644
--- a/noncore/net/mail/libetpanstuff/libetpan.control
+++ b/noncore/net/mail/libetpanstuff/libetpan.control
@@ -3,8 +3,8 @@ Files: usr/lib/libetpan*
3Priority: optional 3Priority: optional
4Section: system 4Section: system
5Maintainer: Rajko Albrecht <alwin@handhelds.org> 5Maintainer: Rajko Albrecht <alwin@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 0.33pre-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: libssl0.9.7 8Depends: libssl0.9.7
9Description: libetpan mail/news library - A version of libetpan patched for Opies mailing app 9Description: libetpan mail/news library - A version of libetpan patched for Opies mailing app
10License: LGPL 10License: LGPL
diff --git a/noncore/net/mail/libmailwrapper/libmailwrapper.control b/noncore/net/mail/libmailwrapper/libmailwrapper.control
index ec55bb3..3491d67 100644
--- a/noncore/net/mail/libmailwrapper/libmailwrapper.control
+++ b/noncore/net/mail/libmailwrapper/libmailwrapper.control
@@ -3,8 +3,8 @@ Files: lib/libmailwrapper.so*
3Priority: optional 3Priority: optional
4Section: libs 4Section: libs
5Maintainer: Rajko Albrecht <alwin@handhelds.org>, Juergen Graf <jgf@handhelds.org>, Maximilian Reiß <harlekin@handhelds.org> 5Maintainer: Rajko Albrecht <alwin@handhelds.org>, Juergen Graf <jgf@handhelds.org>, Maximilian Reiß <harlekin@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 0.6-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal, libopiecore2, libopieui2, libetpan (>= 0.33pre) 8Depends: task-opie-minimal, libopiecore2, libopieui2, libetpan (>= 0.33pre)
9Description: wrapper lib needed by Opie's mailer 9Description: wrapper lib needed by Opie's mailer
10License: LGPL 10License: LGPL
diff --git a/noncore/net/mail/opie-mail.control b/noncore/net/mail/opie-mail.control
index 698aaa7..e3b18b3 100644
--- a/noncore/net/mail/opie-mail.control
+++ b/noncore/net/mail/opie-mail.control
@@ -3,8 +3,8 @@ Files: plugins/application/libopiemail.so* bin/opiemail apps/1Pim/opiemail.deskt
3Priority: optional 3Priority: optional
4Section: opie/pim 4Section: opie/pim
5Maintainer: Rajko Albrecht <alwin@handhelds.org>, Juergen Graf <jgf@handhelds.org>, Maximilian Reiß <harlekin@handhelds.org> 5Maintainer: Rajko Albrecht <alwin@handhelds.org>, Juergen Graf <jgf@handhelds.org>, Maximilian Reiß <harlekin@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 0.6-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal, libopiecore2, libopieui2, libopiemm2, libopiedb2, libmailwrapper (>= 0.6), libssl 8Depends: task-opie-minimal, libopiecore2, libopieui2, libopiemm2, libopiedb2, libmailwrapper (>= 0.6), libssl
9Description: Opie's mail and news client (POP3, IMAP and NNTP) 9Description: Opie's mail and news client (POP3, IMAP and NNTP)
10License: LGPL 10License: LGPL
diff --git a/noncore/net/mail/taskbarapplet/opie-mailapplet.control b/noncore/net/mail/taskbarapplet/opie-mailapplet.control
index f9822a5..c838e0b 100644
--- a/noncore/net/mail/taskbarapplet/opie-mailapplet.control
+++ b/noncore/net/mail/taskbarapplet/opie-mailapplet.control
@@ -3,8 +3,8 @@ Files: plugins/applets/libmailapplet.so*
3Priority: optional 3Priority: optional
4Section: opie/applets 4Section: opie/applets
5Maintainer: Rajko Albrecht <alwin@handhelds.org>, Juergen Graf <jgf@handhelds.org>, Maximilian Reiß <harlekin@handhelds.org> 5Maintainer: Rajko Albrecht <alwin@handhelds.org>, Juergen Graf <jgf@handhelds.org>, Maximilian Reiß <harlekin@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 0.5-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal, libopiecore2, opie-mail 8Depends: task-opie-minimal, libopiecore2, opie-mail
9Description: A Biff-like mailchecker 9Description: A Biff-like mailchecker
10License: LGPL 10License: LGPL
diff --git a/noncore/net/opieirc/opie-irc.control b/noncore/net/opieirc/opie-irc.control
index b9f20f0..195b5ff 100644
--- a/noncore/net/opieirc/opie-irc.control
+++ b/noncore/net/opieirc/opie-irc.control
@@ -3,7 +3,7 @@ Files: plugins/application/libopieirc.so* bin/opieirc pics/opieirc apps/Applicat
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Wenzel Jakob <root@wazlaf.de> 5Maintainer: Wenzel Jakob <root@wazlaf.de>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal, libopie1 7Depends: task-opie-minimal, libopiecore2, libopieui2, libqtaux2
8Description: The Opie IRC client lets you chat on your favorite IRC server using your handheld computer 8Description: The Opie IRC client lets you chat on your favorite IRC server using your handheld computer
9Version: $QPE_VERSION$EXTRAVERSION 9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/net/opierdesktop/opie-rdesktop.control b/noncore/net/opierdesktop/opie-rdesktop.control
index a8726e0..2a9d415 100644
--- a/noncore/net/opierdesktop/opie-rdesktop.control
+++ b/noncore/net/opierdesktop/opie-rdesktop.control
@@ -3,7 +3,7 @@ Files: bin/ordesktop pics/opierdesktop apps/Applications/ordesktop.desktop
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Michael 'Mickey' Lauer <mickeyl@handhelds.org> 5Maintainer: Michael 'Mickey' Lauer <mickeyl@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 1.2.0-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal 8Depends: task-opie-minimal
9Description: Remote Desktop Protocol (RDP) Client 9Description: Remote Desktop Protocol (RDP) Client
diff --git a/noncore/net/opietooth/blue-pin/main.cc b/noncore/net/opietooth/blue-pin/main.cc
index 1ab1f2e..dbe5b41 100644
--- a/noncore/net/opietooth/blue-pin/main.cc
+++ b/noncore/net/opietooth/blue-pin/main.cc
@@ -8,5 +8,4 @@
8#include "pindlg.h" 8#include "pindlg.h"
9 9
10using namespace Opie::Core; 10using namespace Opie::Core;
11OPIE_EXPORT_APP( OApplicationFactory<OpieTooth::PinDlg> ) 11OPIE_EXPORT_APP( OApplicationFactory<OpieTooth::PinDlg> )
12
diff --git a/noncore/net/opietooth/blue-pin/opie-bluepin.control b/noncore/net/opietooth/blue-pin/opie-bluepin.control
index 7147975..e9aa683 100644
--- a/noncore/net/opietooth/blue-pin/opie-bluepin.control
+++ b/noncore/net/opietooth/blue-pin/opie-bluepin.control
@@ -3,8 +3,8 @@ Files: plugins/application/libbluepin.so* bin/bluepin
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Holger Freyther <zecke@handhelds.org> 5Maintainer: Holger Freyther <zecke@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 0.3.4-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal 8Depends: task-opie-minimal
9License: GPL 9License: GPL
10Description: Bluetooth pin application 10Description: Bluetooth pin application
diff --git a/noncore/net/opietooth/blue-pin/pindlgbase.ui b/noncore/net/opietooth/blue-pin/pindlgbase.ui
index 889a25e..6784de7 100644
--- a/noncore/net/opietooth/blue-pin/pindlgbase.ui
+++ b/noncore/net/opietooth/blue-pin/pindlgbase.ui
@@ -11,9 +11,9 @@
11 <name>geometry</name> 11 <name>geometry</name>
12 <rect> 12 <rect>
13 <x>0</x> 13 <x>0</x>
14 <y>0</y> 14 <y>0</y>
15 <width>258</width> 15 <width>254</width>
16 <height>245</height> 16 <height>245</height>
17 </rect> 17 </rect>
18 </property> 18 </property>
19 <property stdset="1"> 19 <property stdset="1">
@@ -28,23 +28,8 @@
28 <property stdset="1"> 28 <property stdset="1">
29 <name>spacing</name> 29 <name>spacing</name>
30 <number>6</number> 30 <number>6</number>
31 </property> 31 </property>
32 <widget>
33 <class>QLabel</class>
34 <property stdset="1">
35 <name>name</name>
36 <cstring>txtStatus</cstring>
37 </property>
38 <property stdset="1">
39 <name>text</name>
40 <string></string>
41 </property>
42 <property stdset="1">
43 <name>textFormat</name>
44 <enum>RichText</enum>
45 </property>
46 </widget>
47 <spacer> 32 <spacer>
48 <property> 33 <property>
49 <name>name</name> 34 <name>name</name>
50 <cstring>Spacer4_2</cstring> 35 <cstring>Spacer4_2</cstring>
@@ -65,8 +50,23 @@
65 </size> 50 </size>
66 </property> 51 </property>
67 </spacer> 52 </spacer>
68 <widget> 53 <widget>
54 <class>QLabel</class>
55 <property stdset="1">
56 <name>name</name>
57 <cstring>txtStatus</cstring>
58 </property>
59 <property stdset="1">
60 <name>text</name>
61 <string></string>
62 </property>
63 <property stdset="1">
64 <name>textFormat</name>
65 <enum>RichText</enum>
66 </property>
67 </widget>
68 <widget>
69 <class>QLayoutWidget</class> 69 <class>QLayoutWidget</class>
70 <property stdset="1"> 70 <property stdset="1">
71 <name>name</name> 71 <name>name</name>
72 <cstring>Layout6</cstring> 72 <cstring>Layout6</cstring>
diff --git a/noncore/net/opietooth/lib/libopietooth1.control b/noncore/net/opietooth/lib/libopietooth1.control
index 20e4b76..9bc9572 100644
--- a/noncore/net/opietooth/lib/libopietooth1.control
+++ b/noncore/net/opietooth/lib/libopietooth1.control
@@ -4,7 +4,7 @@ Priority: optional
4Section: libs 4Section: libs
5Maintainer: Maximilian Reiß <max.reiss@gmx.de> 5Maintainer: Maximilian Reiß <max.reiss@gmx.de>
6Architecture: arm 6Architecture: arm
7Replaces: libopietooth 7Replaces: libopietooth
8Depends: libqte2 (>=2.3.4), libopie1, task-bluez 8Depends: libqte2 (>=2.3.4), libopiecore2, task-bluez
9Description: Opie bluetooth library 9Description: Opie bluetooth library
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/net/opietooth/manager/opie-bluetoothmanager.control b/noncore/net/opietooth/manager/opie-bluetoothmanager.control
index 4fe1e06..89ab698 100644
--- a/noncore/net/opietooth/manager/opie-bluetoothmanager.control
+++ b/noncore/net/opietooth/manager/opie-bluetoothmanager.control
@@ -3,8 +3,8 @@ Files: plugins/application/libbluetooth-manager.so* bin/bluetooth-manager apps/S
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Maximilian Reiß <max.reiss@gmx.de> 5Maintainer: Maximilian Reiß <max.reiss@gmx.de>
6Architecture: arm 6Architecture: arm
7Version: 0.5.4-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal, libopietooth1, opie-bluepin 8Depends: task-opie-minimal, libopietooth1, opie-bluepin
9License: GPL 9License: GPL
10Description: Bluetooth Manager application 10Description: Bluetooth Manager application
diff --git a/noncore/net/wellenreiter/opie-wellenreiter.control b/noncore/net/wellenreiter/opie-wellenreiter.control
index e7bc25d..7dc9c22 100644
--- a/noncore/net/wellenreiter/opie-wellenreiter.control
+++ b/noncore/net/wellenreiter/opie-wellenreiter.control
@@ -3,8 +3,8 @@ Files: bin/wellenreiter pics/wellenreiter apps/Applications/wellenreiter.desktop
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Michael 'Mickey' Lauer <mickeyl@handhelds.org> 5Maintainer: Michael 'Mickey' Lauer <mickeyl@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 1.0.3-cvs 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: libqpe1, libpcap0 (>=0.7.2), libopiecore2, libopienet2, libopieui2 8Depends: libqpe1, libpcap0.8 (>=0.7.2), libopiecore2, libopienet2, libopieui2
9Description: A WaveLAN Network Monitor 9Description: A WaveLAN Network Monitor
10 A WaveLAN Network Monitor/Sniffer for the Opie Environment. 10 A WaveLAN Network Monitor/Sniffer for the Opie Environment.
diff --git a/noncore/securityplugins/blueping/bluepingplugin.control b/noncore/securityplugins/blueping/bluepingplugin.control
index 0339996..62562f7 100644
--- a/noncore/securityplugins/blueping/bluepingplugin.control
+++ b/noncore/securityplugins/blueping/bluepingplugin.control
@@ -3,9 +3,9 @@ Files: plugins/security/libmultiauthbluepingplugin.so* pics/security/bluepingplu
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Clement Seveillac <clement@nist.gov> 5Maintainer: Clement Seveillac <clement@nist.gov>
6Architecture: arm 6Architecture: arm
7Version: 0.0.2.7 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: libopiecore2, opie-security, bluez-utils (<= 2.3rel-hh5) 8Depends: libopiecore2, opie-security, bluez-utils (<= 2.3rel-hh5)
9Description: Blueping plugin for opie-security authentication. 9Description: Blueping plugin for opie-security authentication.
10 This is a bluetooth-based authentication plugin (you need 10 This is a bluetooth-based authentication plugin (you need
11 to have another Bluetooth device around to use it). 11 to have another Bluetooth device around to use it).
diff --git a/noncore/securityplugins/dummy/dummyplugin.control b/noncore/securityplugins/dummy/dummyplugin.control
index 0ab2491..b4cc5e2 100644
--- a/noncore/securityplugins/dummy/dummyplugin.control
+++ b/noncore/securityplugins/dummy/dummyplugin.control
@@ -3,9 +3,9 @@ Files: plugins/security/libmultiauthdummyplugin.so* pics/security/dummyplugin.pn
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Clement Seveillac <clement@nist.gov> 5Maintainer: Clement Seveillac <clement@nist.gov>
6Architecture: arm 6Architecture: arm
7Version: 0.0.2.3 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: libopiecore2, opie-security 8Depends: libopiecore2, opie-security
9Description: Dummy plugin for opie-security authentication. 9Description: Dummy plugin for opie-security authentication.
10 This is a very simple authentication plugin (you just have 10 This is a very simple authentication plugin (you just have
11 to press a button basically), for demonstration purpose. 11 to press a button basically), for demonstration purpose.
diff --git a/noncore/securityplugins/notice/notice.control b/noncore/securityplugins/notice/notice.control
index 8b8c7cd..091ce74 100644
--- a/noncore/securityplugins/notice/notice.control
+++ b/noncore/securityplugins/notice/notice.control
@@ -3,9 +3,9 @@ Files: plugins/security/libmultiauthnoticeplugin.so* pics/security/noticeplugin.
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Clement Seveillac <clement@nist.gov> 5Maintainer: Clement Seveillac <clement@nist.gov>
6Architecture: arm 6Architecture: arm
7Version: 0.0.1.6 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: libopiecore2, opie-security 8Depends: libopiecore2, opie-security
9Description: Notice plugin for opie-security authentication. 9Description: Notice plugin for opie-security authentication.
10 It allows you to display e.g. a notice from your legal departement. 10 It allows you to display e.g. a notice from your legal departement.
11 11
diff --git a/noncore/securityplugins/pin/pin.control b/noncore/securityplugins/pin/pin.control
index 3709d08..51c3f08 100644
--- a/noncore/securityplugins/pin/pin.control
+++ b/noncore/securityplugins/pin/pin.control
@@ -3,9 +3,9 @@ Files: plugins/security/libmultiauthpinplugin.so* pics/security/pinplugin.png
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Clement Seveillac <clement@nist.gov> 5Maintainer: Clement Seveillac <clement@nist.gov>
6Architecture: arm 6Architecture: arm
7Version: 0.0.2.6 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: libopiecore2, opie-security 8Depends: libopiecore2, opie-security
9Description: PIN plugin for opie-security authentication. 9Description: PIN plugin for opie-security authentication.
10 Simple PIN-based authentication plugin (replicate the functionality 10 Simple PIN-based authentication plugin (replicate the functionality
11 Qtopia has, or Opie used to have, without plugins). 11 Qtopia has, or Opie used to have, without plugins).
diff --git a/noncore/settings/networksettings2/activatevpn.cpp b/noncore/settings/networksettings2/activatevpn.cpp
index 2bdef0a..b75e623 100644
--- a/noncore/settings/networksettings2/activatevpn.cpp
+++ b/noncore/settings/networksettings2/activatevpn.cpp
@@ -21,23 +21,17 @@ MyCheckListItem::MyCheckListItem( NodeCollection * N, QListView * V ):
21ActivateVPN::ActivateVPN( void ) : 21ActivateVPN::ActivateVPN( void ) :
22 ActivateVPNGUI( 0, 0, TRUE ), NSD() { 22 ActivateVPNGUI( 0, 0, TRUE ), NSD() {
23 23
24 QCheckListItem * CI; 24 QCheckListItem * CI;
25 printf( "%d\n", __LINE__ );
26 VPN_LV->clear(); 25 VPN_LV->clear();
27 VPN_LV->header()->hide(); 26 VPN_LV->header()->hide();
28 printf( "%d\n", __LINE__ );
29 27
30 for( QDictIterator<NodeCollection> it(NSResources->connections()); 28 for( QDictIterator<NodeCollection> it(NSResources->connections());
31 it.current(); 29 it.current();
32 ++it ) { 30 ++it ) {
33 printf( "%d\n", __LINE__ );
34 if( it.current()->triggeredBy( "vpn" ) ) { 31 if( it.current()->triggeredBy( "vpn" ) ) {
35 printf( "%d\n", __LINE__ );
36 CI = new MyCheckListItem( it.current(), VPN_LV ); 32 CI = new MyCheckListItem( it.current(), VPN_LV );
37 printf( "%d\n", __LINE__ );
38 } 33 }
39 printf( "%d\n", __LINE__ );
40 } 34 }
41} 35}
42 36
43ActivateVPN::~ActivateVPN( void ) { 37ActivateVPN::~ActivateVPN( void ) {
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth.pro b/noncore/settings/networksettings2/bluetooth/bluetooth.pro
index 8170d46..2e3b5bb 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetooth.pro
+++ b/noncore/settings/networksettings2/bluetooth/bluetooth.pro
@@ -1,21 +1,25 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3DESTDIR = $(OPIEDIR)/plugins/networksettings2 3DESTDIR = $(OPIEDIR)/plugins/networksettings2
4 HEADERS = bluetooth_NN.h \ 4 HEADERS = bluetoothBNEP_NN.h \
5 bluetoothBNEP_NNI.h \ 5 bluetoothBNEP_NNI.h \
6 bluetoothRFCOMM_NN.h \
6 bluetoothRFCOMM_NNI.h \ 7 bluetoothRFCOMM_NNI.h \
7 bluetoothBNEPedit.h \ 8 bluetoothBNEPedit.h \
9 bluetoothRFCOMMrun.h \
8 bluetoothRFCOMMedit.h 10 bluetoothRFCOMMedit.h
9 SOURCES = bluetooth_NN.cpp \ 11 SOURCES = bluetoothBNEP_NN.cpp \
10 bluetoothBNEP_NNI.cpp \ 12 bluetoothBNEP_NNI.cpp \
13 bluetoothRFCOMM_NN.cpp \
11 bluetoothRFCOMM_NNI.cpp \ 14 bluetoothRFCOMM_NNI.cpp \
12 bluetoothBNEPedit.cpp \ 15 bluetoothBNEPedit.cpp \
13 bluetoothBNEPrun.cpp \ 16 bluetoothBNEPrun.cpp \
17 bluetoothRFCOMMrun.cpp \
14 bluetoothRFCOMMedit.cpp 18 bluetoothRFCOMMedit.cpp
15 INCLUDEPATH+= $(OPIEDIR)/include ../ ../networksettings2 19 INCLUDEPATH+= $(OPIEDIR)/include ../ ../networksettings2 ../opietooth2
16 DEPENDPATH+= $(OPIEDIR)/include ../ ../networksettings2 20 DEPENDPATH+= $(OPIEDIR)/include ../ ../networksettings2 ../opietooth2
17LIBS += -lqpe 21LIBS += -lqpe -lopietooth2
18 INTERFACES= bluetoothBNEPGUI.ui bluetoothRFCOMMGUI.ui 22 INTERFACES= bluetoothBNEPGUI.ui bluetoothRFCOMMGUI.ui
19 TARGET = bluetooth 23 TARGET = bluetooth
20 VERSION = 1.0.0 24 VERSION = 1.0.0
21 25
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp
index 398dcdc..42b2515 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp
@@ -1,7 +1,7 @@
1#include "bluetoothBNEPedit.h" 1#include "bluetoothBNEPedit.h"
2#include "bluetoothBNEP_NNI.h" 2#include "bluetoothBNEP_NNI.h"
3#include "bluetooth_NN.h" 3#include "bluetoothBNEP_NN.h"
4 4
5ABluetoothBNEP::ABluetoothBNEP( BluetoothBNEPNetNode * PNN ) : 5ABluetoothBNEP::ABluetoothBNEP( BluetoothBNEPNetNode * PNN ) :
6 ANetNodeInstance( PNN ), Data() { 6 ANetNodeInstance( PNN ), Data() {
7 GUI = 0; 7 GUI = 0;
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h
index 03c6903..f52a2c5 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h
@@ -2,10 +2,13 @@
2#define BLUETOOTHBNEP_DATA_H 2#define BLUETOOTHBNEP_DATA_H
3 3
4#include <qstringlist.h> 4#include <qstringlist.h>
5 5
6typedef struct BluetoothBNEPData { 6class BluetoothBNEPData {
7
8public :
9
7 bool AllowAll; 10 bool AllowAll;
8 QStringList BDAddress; 11 QStringList BDAddress;
9} BluetoothBNEPData_t; 12};
10 13
11#endif 14#endif
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp
index 24e4b7b..9d4ae97 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp
@@ -3,247 +3,159 @@
3#include <qtextstream.h> 3#include <qtextstream.h>
4#include <resources.h> 4#include <resources.h>
5#include "bluetoothBNEPrun.h" 5#include "bluetoothBNEPrun.h"
6 6
7QDict<QString> * BluetoothBNEPRun::PANConnections = 0; 7BluetoothBNEPRun::BluetoothBNEPRun( ANetNodeInstance * NNI,
8 BluetoothBNEPData & D ) :
9 RuntimeInfo( NNI ),
10 Data( D),
11 Pat( "bnep[0-6]" ) {
12 OT = 0;
13}
8 14
9void BluetoothBNEPRun::detectState( NodeCollection * NC ) { 15BluetoothBNEPRun::~BluetoothBNEPRun( void ) {
10 // unavailable : no card found 16 if( OT ) {
11 // available : card found and assigned to us or free 17 OTGateway::releaseOTGateway();
12 // up : card found and assigned to us and up 18 }
13 QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); 19}
14 System & Sys = NSResources->system();
15 InterfaceInfo * Run;
16 QFile F( S );
17
18 Log(("Detecting for %s\n", NC->name().latin1() ));
19
20 if( F.open( IO_ReadOnly ) ) {
21 // could open file -> read interface and assign
22 QString X;
23 bool accepted = 0;
24 QTextStream TS(&F);
25 X = TS.readLine();
26 Log(("%s exists : %s\n", S.latin1(), X.latin1() ));
27 // find interface
28 if( handlesInterface( X ) ) {
29
30 Log(("Handles interface %s, PANC %p\n", X.latin1(), PANConnections ));
31 if( PANConnections == 0 ) {
32 // load connections that are active
33 // format : bnep0 00:60:57:02:71:A2 PANU
34 FILE * OutputOfCmd = popen( "pand --show", "r" ) ;
35
36 PANConnections = new QDict<QString>;
37
38 if( OutputOfCmd ) {
39 char ch;
40 // could fork
41 // read all data
42 QString Line = "";
43 while( 1 ) {
44 if( fread( &ch, 1, 1, OutputOfCmd ) < 1 ) {
45 // eof
46 break;
47 }
48 if( ch == '\n' || ch == '\r' ) {
49 if( ! Line.isEmpty() ) {
50 if( Line.startsWith( "bnep" ) ) {
51 QStringList SL = QStringList::split( " ", Line );
52 Log(("Detected PAN %s %s\n",
53 SL[0].latin1(), SL[1].latin1() ));
54 PANConnections->insert( SL[0], new QString(SL[1]));
55 }
56 Line="";
57 }
58 } else {
59 Line += ch;
60 }
61 }
62 }
63 20
64 pclose( OutputOfCmd ); 21State_t BluetoothBNEPRun::detectState( void ) {
65 }
66 22
67 // check if this runtime allows connection to node 23 /*
68 if( ! Data.AllowAll ) {
69 // has addresses
70 for ( QStringList::Iterator it = Data.BDAddress.begin();
71 ! accepted && it != Data.BDAddress.end();
72 ++ it ) {
73 for( QDictIterator<QString> it2( *(PANConnections) );
74 it2.current();
75 ++ it2 ) {
76 if( X == it2.currentKey() &&
77 (*it) == *(it2.current())
78 ) {
79 // found
80 Log(("%s accepts connections to %s\n",
81 NC->name().latin1(),
82 it2.current()->latin1() ));
83 accepted = 1;
84 break;
85 }
86 }
87 }
88 } else {
89 Log(("%s accepts any connection\n", NC->name().latin1() ));
90 // accept any
91 accepted = 1;
92 }
93 24
94 if( accepted ) { 25 need to detect
95 // matches and is allowed for this node 26
96 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 27 1. for any PAN connection that is found if that
97 It.current(); 28 PAN is connected.
98 ++It ) { 29
99 Run = It.current(); 30 if it is connected it is not available (since we do
100 if( X == Run->Name ) { 31 not manage IP settings and we are called to detect
101 Log(("%s Assigned %p\n", NC->name().latin1(), Run )); 32 the state we knwo that we do not have an UP connection)
102 Run->assignNode( netNode() ); 33
103 assignInterface( Run ); 34 2. if it not connected and we allow any connection we
104 NC->setCurrentState( IsUp ); 35 are available or if that PAN connection is to a device
105 return; 36 with a correct address
106 } 37
107 } 38 3. if it is not connected and the address do not match or
108 } 39 we do not accept any address, we are Unavailable but
109 } 40 not DOWN. I.e a new connection could perhaps be created
110 } 41
111 42 */
112 Log(("Assigned %p\n", assignedInterface() )); 43
113 if( ( Run = assignedInterface() ) ) { 44 if( ! OT ) {
114 // we already have an interface assigned -> still present ? 45 OT = OTGateway::getOTGateway();
115 if( ! Run->IsUp ) {
116 // usb is still free -> keep assignment
117 NC->setCurrentState( Available );
118 return;
119 } // else interface is up but NOT us -> some other profile
120 } 46 }
121 47
122 // nothing (valid) assigned to us 48 if( ! OT->isEnabled() ) {
123 assignInterface( 0 ); 49 return Unavailable;
124
125 // find possible interface
126 for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
127 It.current();
128 ++It ) {
129 Run = It.current();
130
131 Log(("%s %d %d=%d %d\n",
132 Run->Name.latin1(),
133 handlesInterface( Run->Name ),
134 Run->CardType, ARPHRD_ETHER,
135 ! Run->IsUp ));
136
137 if( handlesInterface( Run->Name ) &&
138 Run->CardType == ARPHRD_ETHER &&
139 ! Run->IsUp
140 ) {
141 Log(("Released(OFF)\n" ));
142 // proper type, and Not UP -> free
143 NC->setCurrentState( Off );
144 return;
145 }
146 } 50 }
147 // no free found
148 Log(("None available\n" ));
149 51
150 NC->setCurrentState( Unavailable ); 52 // if there is a PAN connection that is UP but not
53 // yet configured (no ifup) the we are available
54 return ( hasFreePANConnection() ) ? Available : Unknown;
151} 55}
152 56
153bool BluetoothBNEPRun::setState( NodeCollection * NC, Action_t A, bool ) { 57QString BluetoothBNEPRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
154 58
155 // we only handle activate and deactivate 59 if( A == Activate ) {
156 switch( A ) { 60 if( hasFreePANConnection( 1 ) ) {
157 case Activate : 61 // we have now an assignedinterface
158 { 62 } else {
159 if( NC->currentState() != Off ) { 63 return QString("TODO : Start PAND");
160 return 0; 64 }
161 } 65
162 InterfaceInfo * N = getInterface(); 66 Log(( "Assigned interface" ));
163 if( ! N ) { 67 NC->setCurrentState( Available );
164 // no interface available 68
165 NC->setCurrentState( Unavailable ); 69 return QString();
166 return 0;
167 }
168 // because we were OFF the interface
169 // we get back is NOT assigned
170 N->assignNode( netNode() );
171 assignInterface( N );
172 Log(("Assing %p\n", N ));
173 NC->setCurrentState( Available );
174 return 1;
175 }
176 case Deactivate :
177 if( NC->currentState() == IsUp ) {
178 // bring down first
179 if( ! connection()->setState( Down ) )
180 // could not ...
181 return 0;
182 } else if( NC->currentState() != Available ) {
183 return 1;
184 }
185 assignedInterface()->assignNode( 0 ); // release
186 assignInterface( 0 );
187 NC->setCurrentState( Off );
188 return 1;
189 default :
190 // FT
191 break;
192 } 70 }
193 return 0; 71
72 if( A == Deactivate ) {
73 // nothing to do
74 NC->setCurrentState( Off );
75 return QString();
76 }
77 return QString();
194} 78}
195 79
196bool BluetoothBNEPRun::canSetState( State_t Curr , Action_t A ) { 80bool BluetoothBNEPRun::handlesInterface( const QString & S ) {
197 // we only handle up down activate and deactivate 81 return Pat.match( S ) >= 0;
198 switch( A ) { 82}
199 case Activate : 83
200 { // at least available 84bool BluetoothBNEPRun::handlesInterface( InterfaceInfo * I ) {
201 if( Curr == Available ) { 85 return handlesInterface( I->Name );
202 return 1; 86}
203 } 87
204 // or we can make one available 88bool BluetoothBNEPRun::hasFreePANConnection( bool Grab ) {
205 InterfaceInfo * N = getInterface(); 89
206 if( ! N || N->assignedNode() != 0 ) { 90 if( ! OT ) {
207 // non available or assigned 91 OT = OTGateway::getOTGateway();
208 return 0; 92 }
93
94 // load PAN connections
95 OTPANConnection * C;
96 InterfaceInfo * Run;
97 InterfaceInfo * Candidate = 0; // reuse this interface
98 PANConnectionVector Conns = OT->getPANConnections();
99 System & Sys = NSResources->system();
100 bool IsValid;
101
102 for( unsigned int i = 0;
103 i < Conns.count();
104 i ++ ) {
105 C = Conns[i];
106
107 if( Data.AllowAll ) {
108 // we allow all
109 IsValid = 1;
110 } else {
111 // is this PAN connection connecting to a Peer
112 // we allow ?
113 IsValid = 0;
114 for ( QStringList::Iterator it = Data.BDAddress.begin();
115 it != Data.BDAddress.end();
116 ++ it ) {
117 if( C->ConnectedTo == (*it) ) {
118 // this is a connection we could accept
119 IsValid = 1;
120 break;
209 } 121 }
210 return 1;
211 } 122 }
212 case Deactivate : 123 }
213 return ( Curr >= Available ); 124
214 default : 125 if( ! IsValid ) {
215 // FT 126 Log(("%s to %s not acceptable\n",
216 break; 127 C->Device.latin1(),
128 C->ConnectedTo.latin1() ));
129 // don't bother checking this address
130 // it is not acceptable
131 continue;
132 }
133
134 // is this PAN connection available to us ?
135 Run = Sys.findInterface( C->Device );
136
137 if( Run && Run->IsUp ) {
138 // this PAN connection is up
139 Log(("%s acceptable but unavailable\n",
140 C->Device.latin1() ));
141 // find others
142 continue;
143 }
144
145 // we at least have a possible interface
146 if( ! Candidate ) {
147 Candidate = Run;
148 }
217 } 149 }
218 return 0;
219}
220 150
221// get interface that is free or assigned to us 151 if( Candidate ) {
222InterfaceInfo * BluetoothBNEPRun::getInterface( void ) { 152 if ( Grab ) {
223 153 netNode()->connection()->assignInterface( Candidate );
224 System & S = NSResources->system();
225 InterfaceInfo * best = 0, * Run;
226
227 for( QDictIterator<InterfaceInfo> It(S.interfaces());
228 It.current();
229 ++It ) {
230 Run = It.current();
231 if( handlesInterface( Run->Name ) &&
232 Run->CardType == ARPHRD_ETHER
233 ) {
234 // this is a bluetooth card
235 if( Run->assignedNode() == netNode() ) {
236 // assigned to us
237 return Run;
238 } else if( Run->assignedNode() == 0 ) {
239 // free
240 best = Run;
241 }
242 } 154 }
155 return 1;
243 } 156 }
244 return best; // can be 0
245}
246 157
247bool BluetoothBNEPRun::handlesInterface( const QString & S ) { 158 // no free PAN
248 return Pat.match( S ) >= 0; 159 return 0;
249} 160}
161
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h
index ce03cbb..a05a7a2 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h
@@ -1,34 +1,35 @@
1#include <asdevice.h> 1#include <netnode.h>
2#include "bluetoothBNEPdata.h" 2#include "bluetoothBNEPdata.h"
3 3
4class BluetoothBNEPRun : public AsDevice { 4#include <OTGateway.h>
5using namespace Opietooth2;
6
7class BluetoothBNEPRun : public RuntimeInfo {
5 8
6public : 9public :
7 10
8 BluetoothBNEPRun( ANetNodeInstance * NNI, 11 BluetoothBNEPRun( ANetNodeInstance * NNI,
9 BluetoothBNEPData & D ) : 12 BluetoothBNEPData & D );
10 AsDevice( NNI ), 13 virtual ~BluetoothBNEPRun( void );
11 Data( D), 14
12 Pat( "bnep[0-6]" ) 15 // i am a device
13 { } 16 virtual RuntimeInfo * device( void )
17 { return this; }
14 18
15 virtual AsDevice * asDevice( void ) 19 bool handlesInterface( const QString & );
16 { return (AsDevice *)this; } 20 bool handlesInterface( InterfaceInfo * );
17 21
18 virtual AsDevice * device( void ) 22 State_t detectState( void );
19 { return asDevice(); }
20 23
21protected : 24protected :
22 25
23 void detectState( NodeCollection * ); 26 QString setMyState( NodeCollection * , Action_t, bool );
24 bool setState( NodeCollection * , Action_t, bool );
25 bool canSetState( State_t , Action_t );
26 bool handlesInterface( const QString & );
27 27
28private : 28private :
29 29
30 InterfaceInfo * getInterface( void ); 30 bool hasFreePANConnection( bool Grab = 0 );
31
31 BluetoothBNEPData & Data; 32 BluetoothBNEPData & Data;
32 static QDict<QString> * PANConnections; 33 OTGateway * OT;
33 QRegExp Pat; 34 QRegExp Pat;
34}; 35};
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui
index 2754a70..7f6565a 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui
@@ -10,10 +10,10 @@
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>283</width> 14 <width>488</width>
15 <height>199</height> 15 <height>604</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
@@ -27,105 +27,305 @@
27 </property> 27 </property>
28 <vbox> 28 <vbox>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
31 <number>2</number> 31 <number>0</number>
32 </property> 32 </property>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>2</number> 35 <number>3</number>
36 </property> 36 </property>
37 <widget> 37 <widget>
38 <class>QLabel</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>TextLabel5_2</cstring>
42 </property>
43 <property stdset="1">
44 <name>text</name>
45 <string>Selected devices with gprs capability</string>
46 </property>
47 <property stdset="1">
48 <name>alignment</name>
49 <set>WordBreak|AlignVCenter|AlignLeft</set>
50 </property>
51 <property>
52 <name>wordwrap</name>
53 </property>
54 </widget>
55 <widget>
38 <class>QLayoutWidget</class> 56 <class>QLayoutWidget</class>
39 <property stdset="1"> 57 <property stdset="1">
40 <name>name</name> 58 <name>name</name>
41 <cstring>Layout4</cstring> 59 <cstring>Layout8</cstring>
60 </property>
61 <property>
62 <name>layoutSpacing</name>
42 </property> 63 </property>
43 <hbox> 64 <hbox>
44 <property stdset="1"> 65 <property stdset="1">
45 <name>margin</name> 66 <name>margin</name>
46 <number>0</number> 67 <number>0</number>
47 </property> 68 </property>
48 <property stdset="1"> 69 <property stdset="1">
49 <name>spacing</name> 70 <name>spacing</name>
50 <number>6</number> 71 <number>3</number>
51 </property> 72 </property>
52 <widget> 73 <widget>
53 <class>QLabel</class> 74 <class>QLabel</class>
54 <property stdset="1"> 75 <property stdset="1">
55 <name>name</name> 76 <name>name</name>
56 <cstring>TextLabel4</cstring> 77 <cstring>TextLabel5</cstring>
57 </property> 78 </property>
58 <property stdset="1"> 79 <property stdset="1">
59 <name>text</name> 80 <name>text</name>
60 <string>Name</string> 81 <string>Address</string>
61 </property> 82 </property>
62 </widget> 83 </widget>
63 <widget> 84 <widget>
64 <class>QLineEdit</class> 85 <class>QLineEdit</class>
65 <property stdset="1"> 86 <property stdset="1">
66 <name>name</name> 87 <name>name</name>
67 <cstring>Name_LE</cstring> 88 <cstring>Address_LE</cstring>
89 </property>
90 </widget>
91 <widget>
92 <class>QToolButton</class>
93 <property stdset="1">
94 <name>name</name>
95 <cstring>FindDevice_TB</cstring>
96 </property>
97 <property stdset="1">
98 <name>text</name>
99 <string>...</string>
68 </property> 100 </property>
69 </widget> 101 </widget>
70 </hbox> 102 </hbox>
71 </widget> 103 </widget>
72 <widget> 104 <widget>
73 <class>QLabel</class> 105 <class>QLayoutWidget</class>
74 <property stdset="1"> 106 <property stdset="1">
75 <name>name</name> 107 <name>name</name>
76 <cstring>TextLabel3</cstring> 108 <cstring>Layout7</cstring>
77 </property> 109 </property>
78 <property stdset="1"> 110 <property>
79 <name>text</name> 111 <name>layoutSpacing</name>
80 <string>Description</string>
81 </property>
82 </widget>
83 <widget>
84 <class>QMultiLineEdit</class>
85 <property stdset="1">
86 <name>name</name>
87 <cstring>Description_LE</cstring>
88 </property> 112 </property>
113 <hbox>
114 <property stdset="1">
115 <name>margin</name>
116 <number>0</number>
117 </property>
118 <property stdset="1">
119 <name>spacing</name>
120 <number>3</number>
121 </property>
122 <widget>
123 <class>QLabel</class>
124 <property stdset="1">
125 <name>name</name>
126 <cstring>TextLabel2</cstring>
127 </property>
128 <property stdset="1">
129 <name>text</name>
130 <string>Channel</string>
131 </property>
132 </widget>
133 <widget>
134 <class>QSpinBox</class>
135 <property stdset="1">
136 <name>name</name>
137 <cstring>Channel_SB</cstring>
138 </property>
139 <property stdset="1">
140 <name>sizePolicy</name>
141 <sizepolicy>
142 <hsizetype>0</hsizetype>
143 <vsizetype>0</vsizetype>
144 </sizepolicy>
145 </property>
146 <property stdset="1">
147 <name>minValue</name>
148 <number>1</number>
149 </property>
150 </widget>
151 <widget>
152 <class>QLabel</class>
153 <property stdset="1">
154 <name>name</name>
155 <cstring>TextLabel2_2</cstring>
156 </property>
157 <property stdset="1">
158 <name>text</name>
159 <string>Name</string>
160 </property>
161 </widget>
162 <widget>
163 <class>QLabel</class>
164 <property stdset="1">
165 <name>name</name>
166 <cstring>Name_LBL</cstring>
167 </property>
168 <property stdset="1">
169 <name>sizePolicy</name>
170 <sizepolicy>
171 <hsizetype>7</hsizetype>
172 <vsizetype>1</vsizetype>
173 </sizepolicy>
174 </property>
175 <property stdset="1">
176 <name>frameShape</name>
177 <enum>Box</enum>
178 </property>
179 <property stdset="1">
180 <name>indent</name>
181 <number>0</number>
182 </property>
183 </widget>
184 </hbox>
89 </widget> 185 </widget>
90 <widget> 186 <widget>
91 <class>QLayoutWidget</class> 187 <class>QLayoutWidget</class>
92 <property stdset="1"> 188 <property stdset="1">
93 <name>name</name> 189 <name>name</name>
94 <cstring>Layout5</cstring> 190 <cstring>Layout5</cstring>
95 </property> 191 </property>
192 <property>
193 <name>layoutSpacing</name>
194 </property>
96 <hbox> 195 <hbox>
97 <property stdset="1"> 196 <property stdset="1">
98 <name>margin</name> 197 <name>margin</name>
99 <number>0</number> 198 <number>0</number>
100 </property> 199 </property>
101 <property stdset="1"> 200 <property stdset="1">
102 <name>spacing</name> 201 <name>spacing</name>
103 <number>6</number> 202 <number>3</number>
104 </property> 203 </property>
105 <widget> 204 <widget>
106 <class>QCheckBox</class> 205 <class>QLabel</class>
107 <property stdset="1"> 206 <property stdset="1">
108 <name>name</name> 207 <name>name</name>
109 <cstring>Automatic_CB</cstring> 208 <cstring>TextLabel7</cstring>
209 </property>
210 <property stdset="1">
211 <name>sizePolicy</name>
212 <sizepolicy>
213 <hsizetype>7</hsizetype>
214 <vsizetype>1</vsizetype>
215 </sizepolicy>
110 </property> 216 </property>
111 <property stdset="1"> 217 <property stdset="1">
112 <name>text</name> 218 <name>text</name>
113 <string>Start automatically</string> 219 <string>Addresses</string>
220 </property>
221 <property stdset="1">
222 <name>alignment</name>
223 <set>AlignVCenter|AlignLeft</set>
224 </property>
225 <property>
226 <name>vAlign</name>
227 </property>
228 </widget>
229 <widget>
230 <class>QToolButton</class>
231 <property stdset="1">
232 <name>name</name>
233 <cstring>Add_TB</cstring>
234 </property>
235 <property stdset="1">
236 <name>text</name>
237 <string>...</string>
114 </property> 238 </property>
115 </widget> 239 </widget>
116 <widget> 240 <widget>
117 <class>QCheckBox</class> 241 <class>QToolButton</class>
118 <property stdset="1"> 242 <property stdset="1">
119 <name>name</name> 243 <name>name</name>
120 <cstring>Confirm_CB</cstring> 244 <cstring>Remove_TB</cstring>
121 </property> 245 </property>
122 <property stdset="1"> 246 <property stdset="1">
123 <name>text</name> 247 <name>text</name>
124 <string>Confirm before start</string> 248 <string>...</string>
125 </property> 249 </property>
126 </widget> 250 </widget>
127 </hbox> 251 </hbox>
128 </widget> 252 </widget>
253 <widget>
254 <class>QListView</class>
255 <column>
256 <property>
257 <name>text</name>
258 <string>Name</string>
259 </property>
260 <property>
261 <name>clickable</name>
262 <bool>true</bool>
263 </property>
264 <property>
265 <name>resizeable</name>
266 <bool>true</bool>
267 </property>
268 </column>
269 <column>
270 <property>
271 <name>text</name>
272 <string>Channel</string>
273 </property>
274 <property>
275 <name>clickable</name>
276 <bool>true</bool>
277 </property>
278 <property>
279 <name>resizeable</name>
280 <bool>true</bool>
281 </property>
282 </column>
283 <column>
284 <property>
285 <name>text</name>
286 <string>Address</string>
287 </property>
288 <property>
289 <name>clickable</name>
290 <bool>true</bool>
291 </property>
292 <property>
293 <name>resizeable</name>
294 <bool>true</bool>
295 </property>
296 </column>
297 <property stdset="1">
298 <name>name</name>
299 <cstring>Addresses_LV</cstring>
300 </property>
301 <property stdset="1">
302 <name>allColumnsShowFocus</name>
303 <bool>true</bool>
304 </property>
305 </widget>
129 </vbox> 306 </vbox>
130</widget> 307</widget>
308<connections>
309 <connection>
310 <sender>Add_TB</sender>
311 <signal>clicked()</signal>
312 <receiver>BluetoothRFCOMM_FRM</receiver>
313 <slot>SLOT_AddServer()</slot>
314 </connection>
315 <connection>
316 <sender>Remove_TB</sender>
317 <signal>clicked()</signal>
318 <receiver>BluetoothRFCOMM_FRM</receiver>
319 <slot>SLOT_RemoveServer()</slot>
320 </connection>
321 <connection>
322 <sender>FindDevice_TB</sender>
323 <signal>clicked()</signal>
324 <receiver>BluetoothRFCOMM_FRM</receiver>
325 <slot>SLOT_FindDevice()</slot>
326 </connection>
327 <slot access="public">SLOT_AddServer()</slot>
328 <slot access="public">SLOT_RemoveServer()</slot>
329 <slot access="public">SLOT_FindDevice()</slot>
330</connections>
131</UI> 331</UI>
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp
index 7ec8288..d19386e 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp
@@ -1,17 +1,36 @@
1#include "bluetoothRFCOMMedit.h" 1#include "bluetoothRFCOMMedit.h"
2#include "bluetoothRFCOMM_NNI.h" 2#include "bluetoothRFCOMM_NNI.h"
3#include "bluetooth_NN.h" 3#include "bluetoothRFCOMM_NN.h"
4 4
5ABluetoothRFCOMM::ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN ) : ANetNodeInstance( PNN ) { 5ABluetoothRFCOMM::ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN ) :
6 GUI = 0; 6 ANetNodeInstance( PNN ), Data() {
7 RT = 0; 7 Data.Devices.setAutoDelete( TRUE );
8 GUI = 0;
9 RT = 0;
8} 10}
9 11
10void ABluetoothRFCOMM::setSpecificAttribute( QString & , QString & ) { 12void ABluetoothRFCOMM::setSpecificAttribute( QString & A, QString & V) {
13
14 if( A == "bdaddress" ) {
15 Data.Devices.resize( Data.Devices.size() + 1 );
16 Data.Devices.insert( Data.Devices.size() - 1, new RFCOMMChannel);
17 Data.Devices[ Data.Devices.size() - 1 ]->BDAddress = V;
18 } else if ( A == "channel" ) {
19 Data.Devices[ Data.Devices.size() - 1 ]->Channel = V.toLong();
20 } else if ( A == "name" ) {
21 Data.Devices[ Data.Devices.size() - 1 ]->Name = V;
22 }
11} 23}
12 24
13void ABluetoothRFCOMM::saveSpecificAttribute( QTextStream & ) { 25void ABluetoothRFCOMM::saveSpecificAttribute( QTextStream & TS ) {
26 for( unsigned int i = 0 ;
27 i < Data.Devices.count();
28 i ++ ) {
29 TS << "bdaddress=" << Data.Devices[i]->BDAddress << endl;
30 TS << "name=" << quote( Data.Devices[i]->Name ) << endl;
31 TS << "channel=" << Data.Devices[i]->Channel << endl;
32 }
14} 33}
15 34
16 35
17QWidget * ABluetoothRFCOMM::edit( QWidget * parent ) { 36QWidget * ABluetoothRFCOMM::edit( QWidget * parent ) {
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h
index 18f0d38..14cfeb0 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h
@@ -1,18 +1,22 @@
1#ifndef BLUETOOTHRFCOMM_DATA_H 1#ifndef BLUETOOTHRFCOMM_DATA_H
2#define BLUETOOTHRFCOMM_DATA_H 2#define BLUETOOTHRFCOMM_DATA_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qvector.h>
5 6
6typedef struct BluetoothRFCOMMData { 7class RFCOMMChannel {
7 QString Device;
8 QString LockFile;
9 long Speed;
10 short Parity;
11 short DataBits;
12 short StopBits;
13 bool HardwareControl;
14 bool SoftwareControl;
15 8
16} BluetoothRFCOMMData_t; 9public :
10 QString BDAddress;
11 QString Name;
12 int Channel;
13};
14
15class BluetoothRFCOMMData {
16
17public :
18
19 QVector<RFCOMMChannel> Devices;
20};
17 21
18#endif 22#endif
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp
index d3ddab4..7cac13f 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp
@@ -1,18 +1,156 @@
1#include <qlistview.h>
2#include <qdialog.h>
3#include <qlabel.h>
4#include <qlineedit.h>
5#include <qtoolbutton.h>
6#include <qcheckbox.h>
7#include <qspinbox.h>
8#include <OTPeer.h>
9#include <OTGateway.h>
10#include <Opietooth.h>
11#include <resources.h>
1#include <GUIUtils.h> 12#include <GUIUtils.h>
2#include "bluetoothRFCOMMedit.h" 13#include "bluetoothRFCOMMedit.h"
3 14
15using namespace Opietooth2;
16
17class PeerLBI : public QListViewItem {
18
19public :
20
21 PeerLBI( OTPeer * P, int Ch, QListView * LV ) : QListViewItem( LV ) {
22 Peer = P;
23 Channel = Ch;
24
25 setText( 0, (P->name().isEmpty()) ?
26 P->address().toString() :
27 P->name() );
28 QString S;
29 S.setNum( Ch );
30 setText( 1, S );
31 setText( 2, P->address().toString() );
32 }
33 ~PeerLBI( ) {
34 }
35
36 inline int channel( void ) const
37 { return Channel; }
38 inline OTPeer * peer( void ) const
39 { return Peer; }
40
41 int Channel;
42 OTPeer * Peer;
43};
44
4BluetoothRFCOMMEdit::BluetoothRFCOMMEdit( QWidget * Parent ) : 45BluetoothRFCOMMEdit::BluetoothRFCOMMEdit( QWidget * Parent ) :
5 BluetoothRFCOMMGUI( Parent ){ 46 BluetoothRFCOMMGUI( Parent ){
47 Modified = 0;
48 OT = OTGateway::getOTGateway();
49
50 Add_TB->setPixmap( NSResources->getPixmap( "add" ) );
51 Remove_TB->setPixmap( NSResources->getPixmap( "remove" ) );
52 FindDevice_TB->setPixmap( NSResources->getPixmap( "Devices/bluetooth" ) );
53 Addresses_LV->setColumnAlignment( 1, Qt::AlignRight );
54}
6 55
56BluetoothRFCOMMEdit::~BluetoothRFCOMMEdit( void ) {
57 OTGateway::releaseOTGateway();
7} 58}
8 59
9QString BluetoothRFCOMMEdit::acceptable( void ) { 60QString BluetoothRFCOMMEdit::acceptable( void ) {
10 return QString(); 61 return QString();
62}
63
64bool BluetoothRFCOMMEdit::commit( BluetoothRFCOMMData & Data ) {
65 int ct = 0;
66 PeerLBI * I;
67
68 if( Modified ) {
69 QListViewItem * it = Addresses_LV->firstChild();
70
71 Data.Devices.resize( 0 );
72 while( it ) {
73
74 ct ++;
75 Data.Devices.resize( ct );
76 I = (PeerLBI * )it;
77
78 Data.Devices.insert( ct-1, new RFCOMMChannel );
79
80 Data.Devices[ct-1]->BDAddress = I->peer()->address().toString();
81 Data.Devices[ct-1]->Name = I->peer()->name();
82 Data.Devices[ct-1]->Channel = I->channel();
83
84 it = it->nextSibling();
85 }
86 }
87
88 return Modified;
11} 89}
12 90
13void BluetoothRFCOMMEdit::showData( BluetoothRFCOMMData & Data ) { 91void BluetoothRFCOMMEdit::showData( BluetoothRFCOMMData & Data ) {
92
93 OTPeer * P;
94
95 for( unsigned int i = 0;
96 i < Data.Devices.count();
97 i ++ ) {
98 P = new OTPeer( OT );
99 P->setAddress( OTDeviceAddress( Data.Devices[i]->BDAddress ) );
100 P->setName( Data.Devices[i]->Name );
101
102 new PeerLBI( P, Data.Devices[i]->Channel, Addresses_LV );
103 }
104 Modified = 0;
14} 105}
15 106
16bool BluetoothRFCOMMEdit::commit( BluetoothRFCOMMData & Data ) { 107void BluetoothRFCOMMEdit::SLOT_AddServer( void ) {
17 return 0; 108 QListViewItem * it = Addresses_LV->firstChild();
109
110 while( it ) {
111 // check address
112 if( it->text(2) == Address_LE->text() ) {
113 // already in table
114 return;
115 }
116 it = it->nextSibling();
117 }
118
119 // new server
120 Modified = 1;
121 OTPeer * P = new OTPeer( OT );
122 P->setAddress( OTDeviceAddress( Address_LE->text() ) );
123 P->setName( Name_LBL->text() );
124 new PeerLBI( P, Channel_SB->value(), Addresses_LV );
125
126 Address_LE->setText("");
127 Name_LBL->setText("");
128 Channel_SB->setValue(1);
129}
130
131void BluetoothRFCOMMEdit::SLOT_RemoveServer( void ) {
132
133 QListViewItem * it = Addresses_LV->firstChild();
134
135 while( it ) {
136 // check address
137 if( it->isSelected() ) {
138 delete it;
139 Modified = 1;
140 return;
141 }
142 it = it->nextSibling();
143 }
144}
145
146void BluetoothRFCOMMEdit::SLOT_FindDevice( void ) {
147 OTPeer * Peer;
148 int Channel;
149
150 // find device in Opietooth
151 if( OTScan::getDevice( Peer, Channel, OT ) == QDialog::Accepted ) {
152 Address_LE->setText( Peer->address().toString() );
153 Name_LBL->setText( Peer->name() );
154 Channel_SB->setValue( Channel );
155 }
18} 156}
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h
index 14a6d64..9ad8f2a 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h
@@ -1,13 +1,27 @@
1#include "bluetoothRFCOMMdata.h" 1#include "bluetoothRFCOMMdata.h"
2#include "bluetoothRFCOMMGUI.h" 2#include "bluetoothRFCOMMGUI.h"
3 3
4#include <Opietooth.h>
5using namespace Opietooth2;
6
4class BluetoothRFCOMMEdit : public BluetoothRFCOMMGUI { 7class BluetoothRFCOMMEdit : public BluetoothRFCOMMGUI {
5 8
6public : 9public :
7 10
8 BluetoothRFCOMMEdit( QWidget * parent ); 11 BluetoothRFCOMMEdit( QWidget * parent );
12 virtual ~BluetoothRFCOMMEdit( void );
9 13
10 QString acceptable( void ); 14 QString acceptable( void );
11 void showData( BluetoothRFCOMMData & Data ); 15 void showData( BluetoothRFCOMMData & Data );
12 bool commit( BluetoothRFCOMMData & Data ); 16 bool commit( BluetoothRFCOMMData & Data );
17
18 bool Modified;
19 OTGateway * OT;
20
21public slots :
22
23 void SLOT_AddServer( void );
24 void SLOT_RemoveServer( void );
25 void SLOT_FindDevice( void );
26
13}; 27};
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
index 65fd686..24e3dae 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
@@ -1,28 +1,33 @@
1#include <asline.h> 1#include <netnode.h>
2#include "bluetoothRFCOMMdata.h" 2#include "bluetoothRFCOMMdata.h"
3 3
4class BluetoothRFCOMMRun : public AsLine { 4#include <OTGateway.h>
5using namespace Opietooth2;
6
7class BluetoothRFCOMMRun : public RuntimeInfo {
5 8
6public : 9public :
7 10
8 BluetoothRFCOMMRun( ANetNodeInstance * NNI, 11 BluetoothRFCOMMRun( ANetNodeInstance * NNI,
9 BluetoothRFCOMMData & Data ) : AsLine( NNI ) 12 BluetoothRFCOMMData & D ) : RuntimeInfo( NNI )
10 { } 13 { DeviceNr = -1; Data = &D; OT = 0; }
14 virtual ~BluetoothRFCOMMRun( void );
11 15
12 virtual AsLine * asLine( void ) 16 virtual RuntimeInfo * line( void )
13 { return (AsLine *)this; } 17 { return this; }
18 virtual QString deviceFile( void );
14 19
15 virtual QString deviceFile( void ) 20 State_t detectState( void );
16 { return QString( "/dev/rfcomm..." ); }
17 21
18protected : 22protected :
19 23
20 void detectState( NodeCollection * ) 24 QString setMyState( NodeCollection * , Action_t, bool );
21 { }
22 25
23 bool setState( NodeCollection * , Action_t, bool ) 26private :
24 { return 0; }
25 27
26 bool canSetState( State_t , Action_t ) 28 int deviceNrOfConnection( void );
27 { return 0; } 29 RFCOMMChannel * getChannel( void );
30 BluetoothRFCOMMData * Data;
31 Opietooth2::OTGateway * OT;
32 int DeviceNr; // cached from detection
28}; 33};
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
index 443a627..9be6b16 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
@@ -11,8 +11,13 @@
11static const char * BluetoothBNEPNeeds[] = 11static const char * BluetoothBNEPNeeds[] =
12 { 0 12 { 0
13 }; 13 };
14 14
15static const char * BluetoothBNEPProvides[] =
16 { "device",
17 0
18 };
19
15/** 20/**
16 * Constructor, find all of the possible interfaces 21 * Constructor, find all of the possible interfaces
17 */ 22 */
18BluetoothBNEPNetNode::BluetoothBNEPNetNode() : 23BluetoothBNEPNetNode::BluetoothBNEPNetNode() :
@@ -41,10 +46,10 @@ ANetNodeInstance * BluetoothBNEPNetNode::createInstance( void ) {
41const char ** BluetoothBNEPNetNode::needs( void ) { 46const char ** BluetoothBNEPNetNode::needs( void ) {
42 return BluetoothBNEPNeeds; 47 return BluetoothBNEPNeeds;
43} 48}
44 49
45const char * BluetoothBNEPNetNode::provides( void ) { 50const char ** BluetoothBNEPNetNode::provides( void ) {
46 return "device"; 51 return BluetoothBNEPProvides;
47} 52}
48 53
49QString BluetoothBNEPNetNode::genNic( long nr ) { 54QString BluetoothBNEPNetNode::genNic( long nr ) {
50 QString S; 55 QString S;
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h
index 4d6a3c1..b93342e 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h
@@ -21,9 +21,9 @@ public:
21 { return "Devices/bluetooth"; } 21 { return "Devices/bluetooth"; }
22 22
23 virtual const QString nodeDescription() ; 23 virtual const QString nodeDescription() ;
24 virtual ANetNodeInstance * createInstance( void ); 24 virtual ANetNodeInstance * createInstance( void );
25 virtual const char * provides( void ); 25 virtual const char ** provides( void );
26 virtual const char ** needs( void ); 26 virtual const char ** needs( void );
27 27
28private: 28private:
29 29
diff --git a/noncore/settings/networksettings2/bluetooth/config.in b/noncore/settings/networksettings2/bluetooth/config.in
index 6968ac8..398cff1 100644
--- a/noncore/settings/networksettings2/bluetooth/config.in
+++ b/noncore/settings/networksettings2/bluetooth/config.in
@@ -1,4 +1,4 @@
1 config NS2BT 1 config NS2BT
2 boolean "opie-networksettings2plugin-bluetooth (set up BLUETOOTH)" 2 boolean "opie-networksettings2plugin-bluetooth (set up BLUETOOTH)"
3 default "n" if NS2 3 default "n" if NS2
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2CORE 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2CORE && NS2OPIETOOTH
diff --git a/noncore/settings/networksettings2/bluetooth/opie-networksettings2plugin-bluetooth.control b/noncore/settings/networksettings2/bluetooth/opie-networksettings2plugin-bluetooth.control
index ea77bd7..c4d29f2 100644
--- a/noncore/settings/networksettings2/bluetooth/opie-networksettings2plugin-bluetooth.control
+++ b/noncore/settings/networksettings2/bluetooth/opie-networksettings2plugin-bluetooth.control
@@ -1,9 +1,9 @@
1Package: opie-networksettingsplugin2-bluetooth 1Package: opie-networksettings2plugin-bluetooth
2Files: plugins/networksettings2/libbluetooth.so* 2Files: plugins/networksettings2/libbluetooth.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Wim Delvaux <wimpie@handhelds.org> 5Maintainer: Wim Delvaux <wimpie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: opie-networksettings2, libopiecore2, libopienet2 7Depends: opie-networksettings2, libopietooth2, libopiecore2, libopienet2
8Description: Network settings bluetooth plugin. 8Description: Network settings bluetooth plugin.
9Version: $QPE_VERSION$EXTRAVERSION 9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp
index 38568df..dc4205c 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.cpp
+++ b/noncore/settings/networksettings2/cable/cable_NN.cpp
@@ -4,8 +4,13 @@
4static const char * CableNeeds[] = 4static const char * CableNeeds[] =
5 { 0 5 { 0
6 }; 6 };
7 7
8static const char * CableProvides[] =
9 { "line",
10 0
11 };
12
8/** 13/**
9 * Constructor, find all of the possible interfaces 14 * Constructor, find all of the possible interfaces
10 */ 15 */
11CableNetNode::CableNetNode() : ANetNode(tr("Cable Connection")) { 16CableNetNode::CableNetNode() : ANetNode(tr("Cable Connection")) {
@@ -31,10 +36,10 @@ ANetNodeInstance * CableNetNode::createInstance( void ) {
31const char ** CableNetNode::needs( void ) { 36const char ** CableNetNode::needs( void ) {
32 return CableNeeds; 37 return CableNeeds;
33} 38}
34 39
35const char * CableNetNode::provides( void ) { 40const char ** CableNetNode::provides( void ) {
36 return "line"; 41 return CableProvides;
37} 42}
38 43
39void CableNetNode::setSpecificAttribute( QString & , QString & ) { 44void CableNetNode::setSpecificAttribute( QString & , QString & ) {
40} 45}
diff --git a/noncore/settings/networksettings2/cable/cable_NN.h b/noncore/settings/networksettings2/cable/cable_NN.h
index 5cc2b2d..8d649cc 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.h
+++ b/noncore/settings/networksettings2/cable/cable_NN.h
@@ -19,9 +19,9 @@ public:
19 19
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21 virtual ANetNodeInstance * createInstance( void ); 21 virtual ANetNodeInstance * createInstance( void );
22 virtual const char ** needs( void ); 22 virtual const char ** needs( void );
23 virtual const char * provides( void ); 23 virtual const char ** provides( void );
24 24
25private: 25private:
26 26
27 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
diff --git a/noncore/settings/networksettings2/cable/cable_NNI.cpp b/noncore/settings/networksettings2/cable/cable_NNI.cpp
index 4bd9421..12a00a2 100644
--- a/noncore/settings/networksettings2/cable/cable_NNI.cpp
+++ b/noncore/settings/networksettings2/cable/cable_NNI.cpp
@@ -48,27 +48,25 @@ void ACable::saveSpecificAttribute( QTextStream & TS ) {
48 TS << "softwarecontrol=" << 48 TS << "softwarecontrol=" <<
49 ((Data.SoftwareControl) ? "yes" : "no") << endl; 49 ((Data.SoftwareControl) ? "yes" : "no") << endl;
50} 50}
51 51
52short ACable::generateFileEmbedded( const QString & ID, 52short ACable::generateFileEmbedded( SystemFile & SF,
53 const QString & Path,
54 QTextStream & TS,
55 long DevNr ) { 53 long DevNr ) {
56 short rvl, rvd; 54 short rvl, rvd;
57 55
58 rvl = 1; 56 rvl = 1;
59 if( ID == "peers" ) { 57 if( SF.name() == "peers" ) {
60 TS << Data.Device 58 SF << Data.Device
61 << endl; 59 << endl;
62 TS << Data.Speed 60 SF << Data.Speed
63 << endl; 61 << endl;
64 TS << "lock " 62 SF << "lock "
65 << Data.LockFile 63 << Data.LockFile
66 << endl; 64 << endl;
67 rvl = 0; 65 rvl = 0;
68 } 66 }
69 67
70 rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr ); 68 rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr );
71 return (rvd == 2 || rvl == 2 ) ? 2 : 69 return (rvd == 2 || rvl == 2 ) ? 2 :
72 (rvd == 0 || rvl == 0 ) ? 0 : 1; 70 (rvd == 0 || rvl == 0 ) ? 0 : 1;
73} 71}
74 72
diff --git a/noncore/settings/networksettings2/cable/cable_NNI.h b/noncore/settings/networksettings2/cable/cable_NNI.h
index d06cbbe..18a52de 100644
--- a/noncore/settings/networksettings2/cable/cable_NNI.h
+++ b/noncore/settings/networksettings2/cable/cable_NNI.h
@@ -25,11 +25,9 @@ public :
25 25
26 virtual void * data( void ) 26 virtual void * data( void )
27 { return (void *)&Data; } 27 { return (void *)&Data; }
28 28
29 short generateFileEmbedded( const QString & ID, 29 short generateFileEmbedded( SystemFile & Sf,
30 const QString & Path,
31 QTextStream & TS,
32 long DevNr ); 30 long DevNr );
33protected : 31protected :
34 32
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 33 virtual void setSpecificAttribute( QString & Attr, QString & Value );
@@ -37,9 +35,9 @@ protected :
37 35
38private : 36private :
39 37
40 CableEdit * GUI; 38 CableEdit * GUI;
41 CableData_t Data; 39 CableData Data;
42 CableRun * RT; 40 CableRun * RT;
43 41
44}; 42};
45 43
diff --git a/noncore/settings/networksettings2/cable/cabledata.h b/noncore/settings/networksettings2/cable/cabledata.h
index c449d96..ea81f8d 100644
--- a/noncore/settings/networksettings2/cable/cabledata.h
+++ b/noncore/settings/networksettings2/cable/cabledata.h
@@ -2,9 +2,12 @@
2#define CABLE_DATA_H 2#define CABLE_DATA_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5 5
6typedef struct CableData { 6class CableData {
7
8public :
9
7 QString Device; 10 QString Device;
8 QString LockFile; 11 QString LockFile;
9 long Speed; 12 long Speed;
10 short Parity; 13 short Parity;
@@ -12,7 +15,7 @@ typedef struct CableData {
12 short StopBits; 15 short StopBits;
13 bool HardwareControl; 16 bool HardwareControl;
14 bool SoftwareControl; 17 bool SoftwareControl;
15 18
16} CableData_t; 19};
17 20
18#endif 21#endif
diff --git a/noncore/settings/networksettings2/cable/cableedit.cpp b/noncore/settings/networksettings2/cable/cableedit.cpp
index 6e1a13b..4e57845 100644
--- a/noncore/settings/networksettings2/cable/cableedit.cpp
+++ b/noncore/settings/networksettings2/cable/cableedit.cpp
@@ -16,9 +16,9 @@ static long SpeedTable[] = {
16 16
17CableEdit::CableEdit( QWidget * Parent ) : CableGUI( Parent ) { 17CableEdit::CableEdit( QWidget * Parent ) : CableGUI( Parent ) {
18} 18}
19 19
20void CableEdit::showData( CableData_t & D ) { 20void CableEdit::showData( CableData & D ) {
21 DeviceFile_LE->setText( D.Device ); 21 DeviceFile_LE->setText( D.Device );
22 LockFile_LE->setText( D.LockFile ); 22 LockFile_LE->setText( D.LockFile );
23 for( long * Run = SpeedTable; *Run != -1; *Run ++ ) { 23 for( long * Run = SpeedTable; *Run != -1; *Run ++ ) {
24 if( *Run == D.Speed ) { 24 if( *Run == D.Speed ) {
@@ -39,9 +39,9 @@ QString CableEdit::acceptable( void ) {
39 return tr("Device filename needed"); 39 return tr("Device filename needed");
40 return QString(); 40 return QString();
41} 41}
42 42
43bool CableEdit::commit( CableData_t & D ) { 43bool CableEdit::commit( CableData & D ) {
44 bool SM = 0; 44 bool SM = 0;
45 45
46 TXTM( D.Device, DeviceFile_LE, SM ); 46 TXTM( D.Device, DeviceFile_LE, SM );
47 TXTM( D.LockFile, LockFile_LE, SM ); 47 TXTM( D.LockFile, LockFile_LE, SM );
diff --git a/noncore/settings/networksettings2/cable/cableedit.h b/noncore/settings/networksettings2/cable/cableedit.h
index ffacc61..ad1e832 100644
--- a/noncore/settings/networksettings2/cable/cableedit.h
+++ b/noncore/settings/networksettings2/cable/cableedit.h
@@ -6,7 +6,7 @@ class CableEdit : public CableGUI {
6public : 6public :
7 7
8 CableEdit( QWidget * parent ); 8 CableEdit( QWidget * parent );
9 QString acceptable( void ); 9 QString acceptable( void );
10 bool commit( CableData_t & D ); 10 bool commit( CableData & D );
11 void showData( CableData_t & D ); 11 void showData( CableData & D );
12}; 12};
diff --git a/noncore/settings/networksettings2/cable/cablerun.cpp b/noncore/settings/networksettings2/cable/cablerun.cpp
index 85660f6..7a8deb9 100644
--- a/noncore/settings/networksettings2/cable/cablerun.cpp
+++ b/noncore/settings/networksettings2/cable/cablerun.cpp
@@ -1,29 +1,21 @@
1#include <fcntl.h> 1#include <fcntl.h>
2#include <unistd.h> 2#include <unistd.h>
3#include "cablerun.h" 3#include "cablerun.h"
4 4
5void CableRun::detectState( NodeCollection * NC ) { 5State_t CableRun::detectState( void ) {
6 6
7 int fd = open( Data->Device.latin1(), O_RDWR ); 7 int fd = open( Data->Device.latin1(), O_RDWR );
8 8
9 if( fd < 0 ) { 9 if( fd < 0 ) {
10 NC->setCurrentState( Unavailable ); 10 return Unavailable;
11 } 11 }
12 close( fd ); 12 close( fd );
13 NC->setCurrentState( Available ); 13 return Available;
14} 14}
15 15
16bool CableRun::setState( NodeCollection * NC, Action_t A, bool ) { 16QString CableRun::setMyState( NodeCollection *, Action_t , bool ) {
17 if( A == Activate ) { 17 return QString();
18 detectState(NC);
19 return (NC->currentState() == Available);
20 }
21 return 1;
22}
23
24bool CableRun::canSetState( State_t , Action_t ) {
25 return 1;
26} 18}
27 19
28QString CableRun::deviceFile( void ) { 20QString CableRun::deviceFile( void ) {
29 return Data->Device; 21 return Data->Device;
diff --git a/noncore/settings/networksettings2/cable/cablerun.h b/noncore/settings/networksettings2/cable/cablerun.h
index 20608f6..41aea01 100644
--- a/noncore/settings/networksettings2/cable/cablerun.h
+++ b/noncore/settings/networksettings2/cable/cablerun.h
@@ -1,26 +1,26 @@
1#include <asline.h> 1#include <netnode.h>
2#include "cabledata.h" 2#include "cabledata.h"
3 3
4class CableRun : public AsLine { 4class CableRun : public RuntimeInfo {
5 5
6public : 6public :
7 7
8 CableRun( ANetNodeInstance * NNI, 8 CableRun( ANetNodeInstance * NNI,
9 CableData_t & D ) : AsLine( NNI ) 9 CableData & D ) : RuntimeInfo( NNI )
10 { Data = &D; } 10 { Data = &D; }
11 11
12 virtual AsLine * asLine( void ) 12 virtual RuntimeInfo * line( void )
13 { return (AsLine *)this; } 13 { return this; }
14 14
15 virtual QString deviceFile( void ); 15 virtual QString deviceFile( void );
16 16
17 State_t detectState( void );
18
17protected : 19protected :
18 20
19 void detectState( NodeCollection * NC ); 21 QString setMyState( NodeCollection * , Action_t, bool );
20 bool setState( NodeCollection * NC, Action_t A, bool Force );
21 bool canSetState( State_t Curr, Action_t A );
22 22
23private : 23private :
24 24
25 CableData_t * Data; 25 CableData * Data;
26}; 26};
diff --git a/noncore/settings/networksettings2/cable/opie-networksettings2plugin-cable.control b/noncore/settings/networksettings2/cable/opie-networksettings2plugin-cable.control
index 79520e2..dd08279 100644
--- a/noncore/settings/networksettings2/cable/opie-networksettings2plugin-cable.control
+++ b/noncore/settings/networksettings2/cable/opie-networksettings2plugin-cable.control
@@ -1,5 +1,5 @@
1Package: opie-networksettingsplugin2-bluetooth 1Package: opie-networksettings2plugin-cable
2Files: plugins/networksettings2/libcable.so* 2Files: plugins/networksettings2/libcable.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Wim Delvaux <wimpie@handhelds.org> 5Maintainer: Wim Delvaux <wimpie@handhelds.org>
diff --git a/noncore/settings/networksettings2/config.in b/noncore/settings/networksettings2/config.in
index d0e5a32..d2b5f26 100644
--- a/noncore/settings/networksettings2/config.in
+++ b/noncore/settings/networksettings2/config.in
@@ -1,10 +1,12 @@
1 source noncore/settings/networksettings2/networksettings2/config.in 1 source noncore/settings/networksettings2/networksettings2/config.in
2 source noncore/settings/networksettings2/opietooth2/config.in
3 source noncore/settings/networksettings2/opietooth2_applet/config.in
2 4
3config NS2 5config NS2
4 boolean 6 boolean
5 default "y" 7 default "y"
6 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2CORE 8 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2CORE && NS2OPIETOOTH
7 9
8 source noncore/settings/networksettings2/profile/config.in 10 source noncore/settings/networksettings2/profile/config.in
9 source noncore/settings/networksettings2/network/config.in 11 source noncore/settings/networksettings2/network/config.in
10 source noncore/settings/networksettings2/lancard/config.in 12 source noncore/settings/networksettings2/lancard/config.in
@@ -15,4 +17,5 @@ config NS2
15 source noncore/settings/networksettings2/vpn/config.in 17 source noncore/settings/networksettings2/vpn/config.in
16 source noncore/settings/networksettings2/bluetooth/config.in 18 source noncore/settings/networksettings2/bluetooth/config.in
17 source noncore/settings/networksettings2/cable/config.in 19 source noncore/settings/networksettings2/cable/config.in
18 source noncore/settings/networksettings2/modem/config.in 20 source noncore/settings/networksettings2/modem/config.in
21 source noncore/settings/networksettings2/gprs/config.in
diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp
index 77826d1..3f8a53f 100644
--- a/noncore/settings/networksettings2/editconnection.cpp
+++ b/noncore/settings/networksettings2/editconnection.cpp
@@ -1,4 +1,5 @@
1#include <opie2/odebug.h>
1#include <qlistview.h> 2#include <qlistview.h>
2#include <qwidgetstack.h> 3#include <qwidgetstack.h>
3#include <qframe.h> 4#include <qframe.h>
4#include <qcombobox.h> 5#include <qcombobox.h>
@@ -30,8 +31,15 @@ public:
30 QCheckListItem( parent, S, T ) { } 31 QCheckListItem( parent, S, T ) { }
31 MyQCheckListItem( QListViewItem *parent, const QString & S, Type T ) : 32 MyQCheckListItem( QListViewItem *parent, const QString & S, Type T ) :
32 QCheckListItem( parent, S, T ) { } 33 QCheckListItem( parent, S, T ) { }
33 34
35 MyQCheckListItem( QListView *parent, const QString & S ) :
36 QCheckListItem( parent, S, QCheckListItem::Controller ) { }
37 MyQCheckListItem( QCheckListItem *parent, const QString & S ) :
38 QCheckListItem( parent, S, QCheckListItem::Controller ) { }
39 MyQCheckListItem( QListViewItem *parent, const QString & S ) :
40 QCheckListItem( parent, S, QCheckListItem::Controller ) { }
41
34 virtual void paintCell( QPainter *p, const QColorGroup &cg, 42 virtual void paintCell( QPainter *p, const QColorGroup &cg,
35 int column, int width, int alignment ); 43 int column, int width, int alignment );
36 44
37}; 45};
@@ -115,50 +123,72 @@ NodeCollection * EditConnection::getTmpCollection( void ) {
115 123
116 // update content 124 // update content
117 QListViewItem * it = Nodes_LV->firstChild(); 125 QListViewItem * it = Nodes_LV->firstChild();
118 ANetNode * NN; 126 ANetNode * NN;
119 // start iter 127
128 // start iter (if there is a collection)
129 /*
130
131 a node collection is sorted from the toplevel
132 node to the deepest node
133
134 */
120 ANetNodeInstance * NNI = 135 ANetNodeInstance * NNI =
121 (SelectedNodes) ? SelectedNodes->first() : 0 ; 136 (SelectedNodes) ? SelectedNodes->first() : 0 ;
122 137
123 TmpCollection.setModified( 0 ); 138 TmpCollection.setModified( 0 );
124 139
140 // the listview always starts with the toplevel
141 // hierarchy. This is always a controller item
125 while ( it ) { 142 while ( it ) {
126 NN = (*Mapping)[it]; 143 NN = (*Mapping)[it];
127 if( NN == 0 ) { 144 if( NN == 0 ) {
128 // child is controller -> has sub radio 145 // this item is a controller ->
129 // check if one radio is selected 146 // has radio items as children ->
147 // find selected one
130 it = it->firstChild(); 148 it = it->firstChild();
131 while( it ) { 149 while( it ) {
132 if( ((QCheckListItem *)it)->isOn() ) { 150 if( ((QCheckListItem *)it)->isOn() ) {
133 // this radio is selected -> go deeper 151 // this radio is selected -> go deeper
134 if( SelectedNodes == 0 ||
135 NNI == 0 ||
136 it->text(0) != NNI->nodeClass()->name() ) {
137 // new item not in previous collection
138 ANetNodeInstance * NNI = (*Mapping)[it]->createInstance();
139 NNI->initialize();
140 // this node type not in collection
141 TmpCollection.append( NNI );
142 // master collection changed because new item in it
143 TmpCollection.setModified( 1 );
144 // no more valid items in old list
145 NNI = 0;
146 } else {
147 // already in list -> copy pointer
148 TmpCollection.append( NNI );
149 NNI = SelectedNodes->next();
150 }
151 it = it->firstChild();
152 // do not bother to check other items
153 break; 152 break;
154 } 153 }
155 it = it->nextSibling(); 154 it = it->nextSibling();
156 } 155 }
156
157 if( ! it ) {
158 owarn << "Radio not selected" << oendl;
159 TmpIsValid = 0;
160 return 0;
161 }
162
163 // it now contains selected radio
164 NN = (*Mapping)[it];
165 }
166
167 // NN here contains the netnode of the
168 // current item -> this node needs to
169 // be stored in the collection
170 if( NNI == 0 ||
171 it->text(0) != NNI->nodeClass()->name() ) {
172 // new item not in previous collection
173 ANetNodeInstance * NNI = NN->createInstance();
174 NNI->initialize();
175 // this node type not in collection
176 TmpCollection.append( NNI );
177 // master collection changed because new item in it
178 TmpCollection.setModified( 1 );
179 // no more valid items in old list
180 NNI = 0;
157 } else { 181 } else {
158 // check children 182 // already in list -> copy pointer
159 it = it->firstChild(); 183 TmpCollection.append( NNI );
184 NNI = SelectedNodes->next();
160 } 185 }
186
187 // go deeper to next level
188 // this level is can be a new controller
189 // or an item
190 it = it->firstChild();
161 } 191 }
162 192
163 TmpIsValid = 1; 193 TmpIsValid = 1;
164 return &(TmpCollection); 194 return &(TmpCollection);
@@ -186,14 +216,13 @@ void EditConnection::setConnection( NodeCollection * NC ) {
186 216
187 TmpIsValid = 0; 217 TmpIsValid = 0;
188 218
189 while ( it ) { 219 while ( it ) {
190 // listitem corresponds to netnode
191 NN = (*Mapping)[it]; 220 NN = (*Mapping)[it];
192 if( NN == 0 ) { 221 if( NN == 0 ) {
193 // child is controller -> has sub radio 222 // this item is a controller ->
194 QString Ctr = it->text(0); 223 // has radio items as children ->
195 // check if one radio is selected 224 // find selected one
196 it = it->firstChild(); 225 it = it->firstChild();
197 Found = 0; 226 Found = 0;
198 while( it ) { 227 while( it ) {
199 if( NNI && it->text(0) == NNI->nodeClass()->name() ) { 228 if( NNI && it->text(0) == NNI->nodeClass()->name() ) {
@@ -208,20 +237,41 @@ void EditConnection::setConnection( NodeCollection * NC ) {
208 break; 237 break;
209 } 238 }
210 it = it->nextSibling(); 239 it = it->nextSibling();
211 } 240 }
241
212 if( ! Found ) { 242 if( ! Found ) {
213 // this means that this level is NOT present in collection 243 // this means that this level is NOT present in collection
214 // probably INCOMPATIBEL collection OR Missing plugin 244 // probably INCOMPATIBEL collection OR Missing plugin
215 QMessageBox::warning( 245 QMessageBox::warning(
216 0, 246 0,
217 tr( "Error presentig Connection" ), 247 tr( "Error presentig Connection" ),
218 tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). 248 tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ).
219 arg(Ctr) ); 249 arg(NNI->nodeClass()->name()) );
220 return; 250 return;
221 } 251 }
252
253 // it now contains selected radio
254 NN = (*Mapping)[it];
222 } else { 255 } else {
223 // automatic item -> check children 256 // automatic selection
257 if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) {
258 // should exist and be the same
259 if( NNI ) {
260 QMessageBox::warning(
261 0,
262 tr( "Error presentig Connection" ),
263 tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ).
264 arg(NNI->nodeClass()->name()) );
265 } else {
266 QMessageBox::warning(
267 0,
268 tr( "Error presentig Connection" ),
269 tr( "<p>Missing connection\"<i>%1</i>\"</p>" ).
270 arg(it->text(0)) );
271 }
272 return;
273 }
224 it = it->firstChild(); 274 it = it->firstChild();
225 } 275 }
226 } 276 }
227} 277}
@@ -268,9 +318,9 @@ void EditConnection::buildFullTree( void ) {
268 Description_LBL->setText( 318 Description_LBL->setText(
269 NSResources->netNode2Description( "fullsetup" ) ); 319 NSResources->netNode2Description( "fullsetup" ) );
270 Nodes_LV->setSelected( TheTop, TRUE ); 320 Nodes_LV->setSelected( TheTop, TRUE );
271 321
272 // find all Nodes that care toplevel nodes -> ie provide 322 // find all Nodes that are toplevel nodes -> ie provide
273 // TCP/IP Connection 323 // TCP/IP Connection
274 for( QDictIterator<NetNode_t> Iter(NSResources->netNodes()); 324 for( QDictIterator<NetNode_t> Iter(NSResources->netNodes());
275 Iter.current(); 325 Iter.current();
276 ++Iter ) { 326 ++Iter ) {
@@ -283,9 +333,11 @@ void EditConnection::buildFullTree( void ) {
283 333
284 MyQCheckListItem * it = new MyQCheckListItem( TheTop, 334 MyQCheckListItem * it = new MyQCheckListItem( TheTop,
285 NN->name(), 335 NN->name(),
286 QCheckListItem::RadioButton ); 336 QCheckListItem::RadioButton );
287 it->setPixmap( 0, NSResources->getPixmap( "Devices/commprofile" ) ); 337 it->setPixmap( 0,
338 NSResources->getPixmap( NN->pixmapName() )
339 );
288 // remember that this node maps to this listitem 340 // remember that this node maps to this listitem
289 Mapping->insert( it, NN ); 341 Mapping->insert( it, NN );
290 buildSubTree( it, NN ); 342 buildSubTree( it, NN );
291 } 343 }
@@ -298,9 +350,9 @@ void EditConnection::buildSubTree( QListViewItem * it, ANetNode *NN ) {
298 if( NNL.size() > 1 ) { 350 if( NNL.size() > 1 ) {
299 // this node has alternatives -> needs radio buttons 351 // this node has alternatives -> needs radio buttons
300 it = new MyQCheckListItem( 352 it = new MyQCheckListItem(
301 it, 353 it,
302 NSResources->netNode2Name(NNL[0]->provides()), 354 NSResources->netNode2Name(NN->needs()[0]),
303 QCheckListItem::Controller ); 355 QCheckListItem::Controller );
304 it->setSelectable( FALSE ); 356 it->setSelectable( FALSE );
305 } 357 }
306 358
@@ -386,12 +438,13 @@ void EditConnection::SLOT_SelectNode( QListViewItem * it ) {
386 NN = (*Mapping)[ it ]; 438 NN = (*Mapping)[ it ];
387 439
388 if( ! NN ) { 440 if( ! NN ) {
389 // intermediate node 441 // intermediate node
390 NN = (*Mapping)[ it->firstChild() ]; 442 NN = (*Mapping)[ it->parent() ];
391 if( NN ) { 443 if( NN ) {
392 // figure out type of this node -> produce mesage 444 // figure out type of this node -> produce mesage
393 Description_LBL->setText( NSResources->netNode2Description(NN->provides()) ); 445 Description_LBL->setText( NSResources->netNode2Description(
446 NN->needs()[0]) );
394 } else { 447 } else {
395 Description_LBL->setText( "" ); 448 Description_LBL->setText( "" );
396 } 449 }
397 return; 450 return;
@@ -538,40 +591,41 @@ void EditConnection::enablePath( QListViewItem * it, bool pha ) {
538} 591}
539 592
540// do we have a complete configuration (all needs are provided for ?) 593// do we have a complete configuration (all needs are provided for ?)
541bool EditConnection::haveCompleteConfig( QListViewItem * it ) { 594bool EditConnection::haveCompleteConfig( QListViewItem * it ) {
542 if( it == 0 || ((QCheckListItem *)it)->isOn() ) { 595
543 // check children 596 // check if all below this level is selected
544 it = (it) ? it->firstChild() : Nodes_LV->firstChild() ; 597 it = ( it ) ?it : Nodes_LV->firstChild();
545 while ( it ) { 598 ANetNode *NN;
546 if( ((QCheckListItem *)it)->type() == 599 bool Found;
547 QCheckListItem::Controller ) { 600
548 // child is controller -> has sub radio 601 while ( it ) {
549 // check if one radio is selected 602 NN = (*Mapping)[it];
550 it = it->firstChild(); 603 if( NN == 0 ) {
551 while( it ) { 604 // this item is a controller ->
552 if( ((QCheckListItem *)it)->isOn() ) { 605 // has radio items as children ->
553 // this radio is selected -> go deeper 606 // find selected one
554 it = it->firstChild(); 607 it = it->firstChild();
555 if( ! it ) { 608 Found = 0;
556 // was deepest level 609 while( it ) {
557 return 1; 610 if( ((QCheckListItem *)it)->isOn() ) {
558 } 611 Found = 1;
559 // do not bother to check other items 612 // go deeper
560 break; 613 it = it->firstChild();
561 } 614 break;
562 it = it->nextSibling();
563 }
564 if( ! it ) {
565 // no radio selected
566 return 0;
567 } 615 }
568 } else { 616 it = it->nextSibling();
569 // check children
570 it = it->firstChild();
571 } 617 }
618
619 if( ! Found ) {
620 return 0; // no not complete -> a radio should have been chkd
621 }
622
623 // it now contains selected radio
624 NN = (*Mapping)[it];
625 } else {
626 // automatic selection
627 it = it->firstChild();
572 } 628 }
573 // deepest level -> all is still OK 629 }
574 return 1; 630 return 1;
575 } // was not ON
576 return 0;
577} 631}
diff --git a/noncore/settings/networksettings2/irda/irda_NN.cpp b/noncore/settings/networksettings2/irda/irda_NN.cpp
index 9483e22..485cad3 100644
--- a/noncore/settings/networksettings2/irda/irda_NN.cpp
+++ b/noncore/settings/networksettings2/irda/irda_NN.cpp
@@ -4,8 +4,13 @@
4static const char * IRDANeeds[] = 4static const char * IRDANeeds[] =
5 { 0 5 { 0
6 }; 6 };
7 7
8static const char * IRDAProvides[] =
9 { "line",
10 0
11 };
12
8/** 13/**
9 * Constructor, find all of the possible interfaces 14 * Constructor, find all of the possible interfaces
10 */ 15 */
11IRDANetNode::IRDANetNode() : ANetNode(tr("Infrared link")) { 16IRDANetNode::IRDANetNode() : ANetNode(tr("Infrared link")) {
@@ -31,10 +36,10 @@ ANetNodeInstance * IRDANetNode::createInstance( void ) {
31const char ** IRDANetNode::needs( void ) { 36const char ** IRDANetNode::needs( void ) {
32 return IRDANeeds; 37 return IRDANeeds;
33} 38}
34 39
35const char * IRDANetNode::provides( void ) { 40const char ** IRDANetNode::provides( void ) {
36 return "line"; 41 return IRDAProvides;
37} 42}
38 43
39void IRDANetNode::setSpecificAttribute( QString & , QString & ) { 44void IRDANetNode::setSpecificAttribute( QString & , QString & ) {
40} 45}
diff --git a/noncore/settings/networksettings2/irda/irda_NN.h b/noncore/settings/networksettings2/irda/irda_NN.h
index 900bbc6..9e5c5e6 100644
--- a/noncore/settings/networksettings2/irda/irda_NN.h
+++ b/noncore/settings/networksettings2/irda/irda_NN.h
@@ -19,9 +19,9 @@ public:
19 19
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21 virtual ANetNodeInstance * createInstance( void ); 21 virtual ANetNodeInstance * createInstance( void );
22 virtual const char ** needs( void ); 22 virtual const char ** needs( void );
23 virtual const char * provides( void ); 23 virtual const char ** provides( void );
24 24
25private: 25private:
26 26
27 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
diff --git a/noncore/settings/networksettings2/irda/irdadata.h b/noncore/settings/networksettings2/irda/irdadata.h
index c3c683e..568f796 100644
--- a/noncore/settings/networksettings2/irda/irdadata.h
+++ b/noncore/settings/networksettings2/irda/irdadata.h
@@ -2,9 +2,10 @@
2#define IRDA_DATA_H 2#define IRDA_DATA_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5 5
6typedef struct IRDAData { 6class IRDAData {
7public :
7 QString Device; 8 QString Device;
8 QString LockFile; 9 QString LockFile;
9 long Speed; 10 long Speed;
10 short Parity; 11 short Parity;
@@ -12,7 +13,7 @@ typedef struct IRDAData {
12 short StopBits; 13 short StopBits;
13 bool HardwareControl; 14 bool HardwareControl;
14 bool SoftwareControl; 15 bool SoftwareControl;
15 16
16} IRDAData_t; 17} ;
17 18
18#endif 19#endif
diff --git a/noncore/settings/networksettings2/irda/irdarun.h b/noncore/settings/networksettings2/irda/irdarun.h
index 4258aff..d3b714b 100644
--- a/noncore/settings/networksettings2/irda/irdarun.h
+++ b/noncore/settings/networksettings2/irda/irdarun.h
@@ -1,28 +1,25 @@
1#include <asline.h> 1#include <netnode.h>
2#include "irdadata.h" 2#include "irdadata.h"
3 3
4class IRDARun : public AsLine { 4class IRDARun : public RuntimeInfo {
5 5
6public : 6public :
7 7
8 IRDARun( ANetNodeInstance * NNI, 8 IRDARun( ANetNodeInstance * NNI,
9 IRDAData & Data ) : AsLine( NNI ) 9 IRDAData & Data ) : RuntimeInfo( NNI )
10 { } 10 { }
11 11
12 virtual AsLine * asLine( void ) 12 virtual RuntimeInfo * line( void )
13 { return (AsLine *)this; } 13 { return this; }
14 14
15 virtual QString deviceFile( void ) 15 virtual QString deviceFile( void )
16 { return QString( "/dev/irda" ); } 16 { return QString( "/dev/irda" ); }
17 17
18protected : 18 State_t detectState( void )
19 19 { return Unknown; }
20 void detectState( NodeCollection * )
21 { }
22 20
23 bool setState( NodeCollection * , Action_t, bool ) 21protected :
24 { return 0; }
25 22
26 bool canSetState( State_t , Action_t ) 23 QString setMyState( NodeCollection * , Action_t, bool )
27 { return 0; } 24 { return QString(); }
28}; 25};
diff --git a/noncore/settings/networksettings2/irda/opie-networksettings2plugin-irda.control b/noncore/settings/networksettings2/irda/opie-networksettings2plugin-irda.control
index 938bee5..4afbbcf 100644
--- a/noncore/settings/networksettings2/irda/opie-networksettings2plugin-irda.control
+++ b/noncore/settings/networksettings2/irda/opie-networksettings2plugin-irda.control
@@ -1,5 +1,5 @@
1Package: opie-networksettingsplugin2-irda 1Package: opie-networksettings2plugin-irda
2Files: plugins/networksettings2/libirda.so* 2Files: plugins/networksettings2/libirda.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Wim Delvaux <wimpie@handhelds.org> 5Maintainer: Wim Delvaux <wimpie@handhelds.org>
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
index 20ae7f6..e36f757 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp
+++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
@@ -1,9 +1,15 @@
1#include "lancard_NN.h" 1#include "lancard_NN.h"
2#include "lancard_NNI.h" 2#include "lancard_NNI.h"
3 3
4static const char * LanCardNeeds[] = 4static const char * LanCardNeeds[] =
5 { 0 }; 5 { 0
6 };
7
8static const char * LanCardProvides[] =
9 { "device",
10 0
11 };
6 12
7/** 13/**
8 * Constructor, find all of the possible interfaces 14 * Constructor, find all of the possible interfaces
9 */ 15 */
@@ -33,10 +39,10 @@ ANetNodeInstance * LanCardNetNode::createInstance( void ) {
33const char ** LanCardNetNode::needs( void ) { 39const char ** LanCardNetNode::needs( void ) {
34 return LanCardNeeds; 40 return LanCardNeeds;
35} 41}
36 42
37const char * LanCardNetNode::provides( void ) { 43const char ** LanCardNetNode::provides( void ) {
38 return "device"; 44 return LanCardProvides;
39} 45}
40 46
41QString LanCardNetNode::genNic( long nr ) { 47QString LanCardNetNode::genNic( long nr ) {
42 QString S; 48 QString S;
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.h b/noncore/settings/networksettings2/lancard/lancard_NN.h
index 6882af7..dc7566a 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NN.h
+++ b/noncore/settings/networksettings2/lancard/lancard_NN.h
@@ -24,9 +24,9 @@ public:
24 24
25 virtual const QString nodeDescription() ; 25 virtual const QString nodeDescription() ;
26 virtual ANetNodeInstance * createInstance( void ); 26 virtual ANetNodeInstance * createInstance( void );
27 virtual const char ** needs( void ); 27 virtual const char ** needs( void );
28 virtual const char * provides( void ); 28 virtual const char ** provides( void );
29 29
30 QStringList & addressesOfNIC( void ) 30 QStringList & addressesOfNIC( void )
31 { return NICMACAddresses; } 31 { return NICMACAddresses; }
32 32
diff --git a/noncore/settings/networksettings2/lancard/lancarddata.h b/noncore/settings/networksettings2/lancard/lancarddata.h
index c76767f..8f5e2b5 100644
--- a/noncore/settings/networksettings2/lancard/lancarddata.h
+++ b/noncore/settings/networksettings2/lancard/lancarddata.h
@@ -3,11 +3,12 @@
3 3
4#include <qstringlist.h> 4#include <qstringlist.h>
5#include <qstring.h> 5#include <qstring.h>
6 6
7typedef struct LanCardData { 7class LanCardData {
8public :
8 bool AnyLanCard; 9 bool AnyLanCard;
9 QStringList HWAddresses; 10 QStringList HWAddresses;
10 11
11} LanCardData_t; 12} ;
12 13
13#endif 14#endif
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.cpp b/noncore/settings/networksettings2/lancard/lancardrun.cpp
index 1544ddc..470b797 100644
--- a/noncore/settings/networksettings2/lancard/lancardrun.cpp
+++ b/noncore/settings/networksettings2/lancard/lancardrun.cpp
@@ -3,15 +3,17 @@
3#include <qstringlist.h> 3#include <qstringlist.h>
4#include <resources.h> 4#include <resources.h>
5#include "lancardrun.h" 5#include "lancardrun.h"
6 6
7void LanCardRun::detectState( NodeCollection * NC ) { 7State_t LanCardRun::detectState( void ) {
8 8
9 // unavailable : no card found 9 // unavailable : no card found
10 // available : card found and assigned to us or free 10 // available : card found and assigned to us or free
11 // up : card found and assigned to us and up 11 // up : card found and assigned to us and up
12 12
13 QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); 13 NodeCollection * NC = nodeCollection();
14 QString S = QString( "/tmp/profile-%1.up" ).
15 arg( NC->number());
14 System & Sys = NSResources->system(); 16 System & Sys = NSResources->system();
15 InterfaceInfo * Run; 17 InterfaceInfo * Run;
16 18
17 QFile F( S ); 19 QFile F( S );
@@ -27,28 +29,25 @@ void LanCardRun::detectState( NodeCollection * NC ) {
27 It.current(); 29 It.current();
28 ++It ) { 30 ++It ) {
29 Run = It.current(); 31 Run = It.current();
30 if( X == Run->Name ) { 32 if( X == Run->Name ) {
31 Run->assignNode( netNode() ); 33 NC->assignInterface( Run );
32 assignInterface( Run ); 34 return IsUp;
33 NC->setCurrentState( IsUp );
34 return;
35 } 35 }
36 } 36 }
37 } 37 }
38 } 38 }
39 39
40 if( ( Run = assignedInterface() ) ) { 40 if( ( Run = NC->assignedInterface() ) ) {
41 // we already have an interface assigned -> still present ? 41 // we already have an interface assigned -> still present ?
42 if( ! Run->IsUp ) { 42 if( ! Run->IsUp ) {
43 // usb is still free -> keep assignment 43 // usb is still free -> keep assignment
44 NC->setCurrentState( Available ); 44 return Available;
45 return;
46 } // else interface is up but NOT us -> some other profile 45 } // else interface is up but NOT us -> some other profile
47 } 46 }
48 47
49 // nothing (valid) assigned to us 48 // nothing (valid) assigned to us
50 assignInterface( 0 ); 49 NC->assignInterface( 0 );
51 50
52 // find possible interface 51 // find possible interface
53 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 52 for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
54 It.current(); 53 It.current();
@@ -62,83 +61,40 @@ void LanCardRun::detectState( NodeCollection * NC ) {
62 ) && 61 ) &&
63 ! Run->IsUp 62 ! Run->IsUp
64 ) { 63 ) {
65 // proper type, and Not UP -> free 64 // proper type, and Not UP -> free
66 NC->setCurrentState( Off ); 65 return Off;
67 return;
68 } 66 }
69 } 67 }
70 // no free found 68 // no free found
71 69
72 NC->setCurrentState( Unavailable ); 70 return Unavailable;
73
74} 71}
75 72
76bool LanCardRun::setState( NodeCollection * NC, Action_t A, bool ) { 73QString LanCardRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
77 74
78 // we only handle activate and deactivate 75 if( A == Activate ) {
79 switch( A ) { 76 InterfaceInfo * N = getInterface();
80 case Activate : 77
81 { 78 if( ! N ) {
82 if( NC->currentState() != Off ) { 79 // no interface available
83 return 0; 80 NC->setCurrentState( Unavailable );
84 } 81 return tr("No interface found");
85 InterfaceInfo * N = getInterface(); 82 }
86 if( ! N ) { 83
87 // no interface available 84 // because we were OFF the interface
88 NC->setCurrentState( Unavailable ); 85 // we get back is NOT assigned
89 return 0; 86 NC->assignInterface( N );
90 } 87 NC->setCurrentState( Available );
91 // because we were OFF the interface 88 return QString();
92 // we get back is NOT assigned
93 N->assignNode( netNode() );
94 assignInterface( N );
95 NC->setCurrentState( Available );
96 return 1;
97 }
98 case Deactivate :
99 if( NC->currentState() == IsUp ) {
100 // bring down first
101 if( ! connection()->setState( Down ) )
102 // could not ...
103 return 0;
104 } else if( NC->currentState() != Available ) {
105 return 1;
106 }
107 assignedInterface()->assignNode( 0 ); // release
108 assignInterface( 0 );
109 NC->setCurrentState( Off );
110 return 1;
111 default :
112 // FT
113 break;
114 } 89 }
115 return 0;
116}
117 90
118bool LanCardRun::canSetState( State_t Curr, Action_t A ) { 91 if( A == Deactivate ) {
119 // we only handle up down activate and deactivate 92 NC->assignInterface( 0 );
120 switch( A ) { 93 NC->setCurrentState( Off );
121 case Activate :
122 { // at least available
123 if( Curr == Available ) {
124 return 1;
125 }
126 // or we can make one available
127 InterfaceInfo * N = getInterface();
128 if( ! N || N->assignedNode() != 0 ) {
129 // non available or assigned
130 return 0;
131 }
132 return 1;
133 }
134 case Deactivate :
135 return ( Curr >= Available );
136 default :
137 // FT
138 break;
139 } 94 }
140 return 0; 95
96 return QString();
141} 97}
142 98
143// get interface that is free or assigned to us 99// get interface that is free or assigned to us
144InterfaceInfo * LanCardRun::getInterface( void ) { 100InterfaceInfo * LanCardRun::getInterface( void ) {
@@ -157,12 +113,12 @@ InterfaceInfo * LanCardRun::getInterface( void ) {
157#endif 113#endif
158 ) 114 )
159 ) { 115 ) {
160 // this is a LAN card 116 // this is a LAN card
161 if( Run->assignedNode() == netNode() ) { 117 if( Run->assignedConnection() == netNode()->connection() ) {
162 // assigned to us 118 // assigned to us
163 return Run; 119 return Run;
164 } else if( Run->assignedNode() == 0 ) { 120 } else if( Run->assignedConnection() == 0 ) {
165 // free 121 // free
166 best = Run; 122 best = Run;
167 } 123 }
168 } 124 }
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.h b/noncore/settings/networksettings2/lancard/lancardrun.h
index b28dda7..57ef3fb 100644
--- a/noncore/settings/networksettings2/lancard/lancardrun.h
+++ b/noncore/settings/networksettings2/lancard/lancardrun.h
@@ -1,34 +1,32 @@
1#ifndef LANCARDRUN_H 1#ifndef LANCARDRUN_H
2#define LANCARDRUN_H 2#define LANCARDRUN_H
3 3
4#include <asdevice.h> 4#include <netnode.h>
5#include <qregexp.h> 5#include <qregexp.h>
6#include "lancarddata.h" 6#include "lancarddata.h"
7 7
8class LanCardRun : public AsDevice { 8class LanCardRun : public RuntimeInfo {
9 9
10public : 10public :
11 11
12 LanCardRun( ANetNodeInstance * NNI, 12 LanCardRun( ANetNodeInstance * NNI,
13 LanCardData & D ) : AsDevice( NNI ), 13 LanCardData & D ) : RuntimeInfo( NNI ),
14 Pat( "eth[0-9]" ) 14 Pat( "eth[0-9]" ) {
15 { Data = &D; } 15 Data = &D;
16 }
16 17
17 virtual AsDevice * device( void ) 18 virtual RuntimeInfo * device( void )
18 { return (AsDevice *)this; } 19 { return this; }
19 20
20 virtual AsDevice * asDevice( void ) 21 bool handlesInterface( const QString & I );
21 { return (AsDevice *)this; } 22 bool handlesInterface( const InterfaceInfo & II );
22 23
23protected : 24 State_t detectState( void );
24 25
25 void detectState( NodeCollection * NC ); 26protected :
26 bool setState( NodeCollection * NC, Action_t A, bool Force );
27 bool canSetState( State_t Curr, Action_t A );
28 27
29 bool handlesInterface( const QString & I ); 28 QString setMyState( NodeCollection * , Action_t, bool );
30 bool handlesInterface( const InterfaceInfo & II );
31 29
32private : 30private :
33 31
34 InterfaceInfo * getInterface( void ); 32 InterfaceInfo * getInterface( void );
diff --git a/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control b/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control
index d5aca66..4f87d04 100644
--- a/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control
+++ b/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control
@@ -1,5 +1,5 @@
1Package: opie-networksettingsplugin2-lancard 1Package: opie-networksettings2plugin-lancard
2Files: plugins/networksettings2/liblancard.so* 2Files: plugins/networksettings2/liblancard.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Wim Delvaux <wimpie@handhelds.org> 5Maintainer: Wim Delvaux <wimpie@handhelds.org>
diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp
index 18bf652..8487e3e 100644
--- a/noncore/settings/networksettings2/main.cpp
+++ b/noncore/settings/networksettings2/main.cpp
@@ -2,8 +2,9 @@
2#include "activateprofile.h" 2#include "activateprofile.h"
3#include "activatevpn.h" 3#include "activatevpn.h"
4#include "networksettings.h" 4#include "networksettings.h"
5 5
6#include <opie2/odebug.h>
6#include <qpe/qpeapplication.h> 7#include <qpe/qpeapplication.h>
7 8
8#include <opie2/oapplicationfactory.h> 9#include <opie2/oapplicationfactory.h>
9using namespace Opie::Core; 10using namespace Opie::Core;
@@ -23,8 +24,19 @@ OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> )
23// used by interfaces to request user prompt 24// used by interfaces to request user prompt
24#define ACT_PROMPT 3 25#define ACT_PROMPT 3
25// used by interfaces to trigger VPN 26// used by interfaces to trigger VPN
26#define ACT_VPN 4 27#define ACT_VPN 4
28// activate opietooth
29#define ACT_OT 5
30
31// include Opietooth GUI
32#include <opietooth2/Opietooth.h>
33using namespace Opietooth2;
34
35#include <qpushbutton.h>
36#include <qlayout.h>
37#include <qframe.h>
38#include <qlabel.h>
27 39
28int main( int argc, char * argv[] ) { 40int main( int argc, char * argv[] ) {
29 int rv = 0; 41 int rv = 0;
30 int Action = ACT_GUI; 42 int Action = ACT_GUI;
@@ -49,8 +61,11 @@ int main( int argc, char * argv[] ) {
49 rmv = 1; 61 rmv = 1;
50 } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) { 62 } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) {
51 Action = ACT_VPN; 63 Action = ACT_VPN;
52 rmv = 1; 64 rmv = 1;
65 } else if( strcmp( argv[i], "--opietooth" ) == 0 ) {
66 Action = ACT_OT;
67 rmv = 1;
53 } 68 }
54 if( rmv ) { 69 if( rmv ) {
55 memmove( argv+i, argv+i+rmv, 70 memmove( argv+i, argv+i+rmv,
56 sizeof( char * ) * (argc-i-rmv) ); 71 sizeof( char * ) * (argc-i-rmv) );
@@ -63,8 +78,10 @@ int main( int argc, char * argv[] ) {
63 // called from system to request something 78 // called from system to request something
64 GuiType = QApplication::Tty; 79 GuiType = QApplication::Tty;
65 Action = ACT_REQUEST; 80 Action = ACT_REQUEST;
66 Log(("Request : %s\n", argv[1] )); 81 Log(("Request : %s\n", argv[1] ));
82 } else if( strstr( argv[0], "-opietooth" ) ) {
83 Action = ACT_OT;
67 } 84 }
68 85
69 // Start Qt 86 // Start Qt
70#ifdef _WS_QWS_ 87#ifdef _WS_QWS_
@@ -85,27 +102,25 @@ int main( int argc, char * argv[] ) {
85 switch( Action ) { 102 switch( Action ) {
86 case ACT_REQUEST : 103 case ACT_REQUEST :
87 { NetworkSettingsData NS; 104 { NetworkSettingsData NS;
88 if( NS.canStart( argv[1] ) ) { 105 if( NS.canStart( argv[1] ) ) {
89 QString S; 106 QStringList S;
90 S.sprintf( QPEApplication::qpeDir()+ 107 S << QPEApplication::qpeDir() + "/bin/networksettings2";
91 "bin/networksettings2" ); 108 S << "networksettings2";
92 char * MyArgv[4]; 109 S << "--prompt";
93 MyArgv[0] = "networksettings2"; 110 S << argv[1];
94 MyArgv[1] = "--prompt"; 111 NSResources->system().execAsUser( S );
95 MyArgv[2] = argv[1];
96 MyArgv[3] = NULL;
97 NSResources->system().execAsUser( S, MyArgv );
98 Log(("FAILED %s-cNN-allowed\n", argv[1] )); 112 Log(("FAILED %s-cNN-allowed\n", argv[1] ));
99 // if we come here , failed 113 // if we come here , failed
100 printf( "%s-cNN-disallowed", argv[1] ); 114 printf( "%s-cNN-disallowed", argv[1] );
101 } 115 }
102 } 116 }
103 break; 117 break;
104 case ACT_REGEN : 118 case ACT_REGEN :
105 { NetworkSettingsData NS; 119 { NetworkSettingsData NS;
120 QString S= NS.generateSettings();
106 // regen returns 0 if OK 121 // regen returns 0 if OK
107 rv = (NS.regenerate()) ? 1 : 0; 122 rv = ( S.isEmpty() ) ? 0 : 1;
108 } 123 }
109 break; 124 break;
110 case ACT_PROMPT : 125 case ACT_PROMPT :
111 { ActivateProfile AP(argv[1]); 126 { ActivateProfile AP(argv[1]);
@@ -124,17 +139,26 @@ int main( int argc, char * argv[] ) {
124 AVPN.exec(); 139 AVPN.exec();
125 } 140 }
126 break; 141 break;
127 case ACT_GUI : 142 case ACT_GUI :
128 { QWidget * W = new NetworkSettings(0); 143 case ACT_OT :
144 { QWidget * W;
145
146 if( Action == ACT_OT ) {
147 W = new OTMain( 0 );
148 } else {
149 W = new NetworkSettings(0);
150 }
129 TheApp->setMainWidget( W ); 151 TheApp->setMainWidget( W );
152
130 W->show(); 153 W->show();
131#ifdef _WS_QWS_ 154#ifdef _WS_QWS_
132 W->showMaximized(); 155 W->showMaximized();
133#else 156#else
134 W->resize( W->sizeHint() ); 157 W->resize( W->sizeHint() );
135#endif 158#endif
136 rv = TheApp->exec(); 159 rv = TheApp->exec();
160
137 delete W; 161 delete W;
138 } 162 }
139 break; 163 break;
140 } 164 }
diff --git a/noncore/settings/networksettings2/modem/modem_NN.cpp b/noncore/settings/networksettings2/modem/modem_NN.cpp
index ee61b10..06f417c 100644
--- a/noncore/settings/networksettings2/modem/modem_NN.cpp
+++ b/noncore/settings/networksettings2/modem/modem_NN.cpp
@@ -1,9 +1,14 @@
1#include "modem_NN.h" 1#include "modem_NN.h"
2#include "modem_NNI.h" 2#include "modem_NNI.h"
3 3
4static const char * ModemNeeds[] = 4static const char * ModemNeeds[] =
5 { "line" 5 { "line",
6 0
7 };
8static const char * ModemProvides[] =
9 { "modem",
10 0
6 }; 11 };
7 12
8/** 13/**
9 * Constructor, find all of the possible interfaces 14 * Constructor, find all of the possible interfaces
@@ -32,10 +37,10 @@ ANetNodeInstance * ModemNetNode::createInstance( void ) {
32const char ** ModemNetNode::needs( void ) { 37const char ** ModemNetNode::needs( void ) {
33 return ModemNeeds; 38 return ModemNeeds;
34} 39}
35 40
36const char * ModemNetNode::provides( void ) { 41const char ** ModemNetNode::provides( void ) {
37 return "line"; 42 return ModemProvides;
38} 43}
39 44
40void ModemNetNode::setSpecificAttribute( QString & , QString & ) { 45void ModemNetNode::setSpecificAttribute( QString & , QString & ) {
41} 46}
diff --git a/noncore/settings/networksettings2/modem/modem_NN.h b/noncore/settings/networksettings2/modem/modem_NN.h
index a76525f..5b3b573 100644
--- a/noncore/settings/networksettings2/modem/modem_NN.h
+++ b/noncore/settings/networksettings2/modem/modem_NN.h
@@ -19,9 +19,9 @@ public:
19 19
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21 virtual ANetNodeInstance * createInstance( void ); 21 virtual ANetNodeInstance * createInstance( void );
22 virtual const char ** needs( void ); 22 virtual const char ** needs( void );
23 virtual const char * provides( void ); 23 virtual const char ** provides( void );
24 24
25private: 25private:
26 26
27 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
diff --git a/noncore/settings/networksettings2/modem/modemdata.h b/noncore/settings/networksettings2/modem/modemdata.h
index 773cb77..89656ed 100644
--- a/noncore/settings/networksettings2/modem/modemdata.h
+++ b/noncore/settings/networksettings2/modem/modemdata.h
@@ -1,9 +1,10 @@
1#ifndef MODEM_DATA_H 1#ifndef MODEM_DATA_H
2#define MODEM_DATA_H 2#define MODEM_DATA_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5typedef struct ModemData { 5class ModemData {
6public :
6 QString Device; 7 QString Device;
7 QString LockFile; 8 QString LockFile;
8 long Speed; 9 long Speed;
9 short Parity; 10 short Parity;
@@ -11,7 +12,7 @@ typedef struct ModemData {
11 short StopBits; 12 short StopBits;
12 bool HardwareControl; 13 bool HardwareControl;
13 bool SoftwareControl; 14 bool SoftwareControl;
14 15
15} ModemData_t; 16} ;
16 17
17#endif 18#endif
diff --git a/noncore/settings/networksettings2/modem/modemedit.cpp b/noncore/settings/networksettings2/modem/modemedit.cpp
index fd3d694..d97d895 100644
--- a/noncore/settings/networksettings2/modem/modemedit.cpp
+++ b/noncore/settings/networksettings2/modem/modemedit.cpp
@@ -8,11 +8,11 @@ ModemEdit::ModemEdit( QWidget * Parent ) : ModemGUI( Parent ){
8QString ModemEdit::acceptable( void ) { 8QString ModemEdit::acceptable( void ) {
9 return QString(); 9 return QString();
10} 10}
11 11
12bool ModemEdit::commit( ModemData_t & Data ) { 12bool ModemEdit::commit( ModemData & Data ) {
13 return 0; 13 return 0;
14} 14}
15 15
16void ModemEdit::showData( ModemData_t & Data ) { 16void ModemEdit::showData( ModemData & Data ) {
17} 17}
18 18
diff --git a/noncore/settings/networksettings2/modem/modemedit.h b/noncore/settings/networksettings2/modem/modemedit.h
index 56e2a82..ed9cfc0 100644
--- a/noncore/settings/networksettings2/modem/modemedit.h
+++ b/noncore/settings/networksettings2/modem/modemedit.h
@@ -6,7 +6,7 @@ class ModemEdit : public ModemGUI {
6public : 6public :
7 7
8 ModemEdit( QWidget * parent ); 8 ModemEdit( QWidget * parent );
9 QString acceptable( void ); 9 QString acceptable( void );
10 bool commit( ModemData_t & Data ); 10 bool commit( ModemData & Data );
11 void showData( ModemData_t & Data ); 11 void showData( ModemData & Data );
12}; 12};
diff --git a/noncore/settings/networksettings2/modem/modemrun.h b/noncore/settings/networksettings2/modem/modemrun.h
index 491a677..eb3a193 100644
--- a/noncore/settings/networksettings2/modem/modemrun.h
+++ b/noncore/settings/networksettings2/modem/modemrun.h
@@ -1,28 +1,25 @@
1#include <asline.h> 1#include <netnode.h>
2#include "modemdata.h" 2#include "modemdata.h"
3 3
4class ModemRun : public AsLine { 4class ModemRun : public RuntimeInfo {
5 5
6public : 6public :
7 7
8 ModemRun( ANetNodeInstance * NNI, 8 ModemRun( ANetNodeInstance * NNI,
9 ModemData & Data ) : AsLine ( NNI ) 9 ModemData & Data ) : RuntimeInfo ( NNI )
10 { } 10 { }
11 11
12 virtual AsLine * asLine( void ) 12 virtual RuntimeInfo * line( void )
13 { return (AsLine *)this; } 13 { return this; }
14 14
15 virtual QString deviceFile( void ) 15 virtual QString deviceFile( void )
16 { return QString("/dev/modem"); } 16 { return QString("/dev/modem"); }
17 17
18protected : 18 State_t detectState( void )
19 19 { return Unknown;}
20 void detectState( NodeCollection * )
21 { }
22 20
23 bool setState( NodeCollection *, Action_t, bool ) 21protected :
24 { return 0; }
25 22
26 bool canSetState( State_t, Action_t ) 23 QString setMyState( NodeCollection * , Action_t, bool )
27 { return 0; } 24 { return QString(); }
28}; 25};
diff --git a/noncore/settings/networksettings2/modem/opie-networksettings2plugin-modem.control b/noncore/settings/networksettings2/modem/opie-networksettings2plugin-modem.control
index eaa6ab0..a73249a 100644
--- a/noncore/settings/networksettings2/modem/opie-networksettings2plugin-modem.control
+++ b/noncore/settings/networksettings2/modem/opie-networksettings2plugin-modem.control
@@ -1,5 +1,5 @@
1Package: opie-networksettingsplugin2-modem 1Package: opie-networksettings2plugin-modem
2Files: plugins/networksettings2/libmodem.so* 2Files: plugins/networksettings2/libmodem.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Wim Delvaux <wimpie@handhelds.org> 5Maintainer: Wim Delvaux <wimpie@handhelds.org>
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp
index b5c41bf..23b3d44 100644
--- a/noncore/settings/networksettings2/network/network_NN.cpp
+++ b/noncore/settings/networksettings2/network/network_NN.cpp
@@ -1,18 +1,27 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <asdevice.h> 2#include <resources.h>
3#include <netnode.h>
3#include "network_NN.h" 4#include "network_NN.h"
4#include "network_NNI.h" 5#include "network_NNI.h"
5 6
6static const char * NetworkNeeds[] = 7static const char * NetworkNeeds[] =
7 { "device", 8 { "device",
8 0 9 0
9 }; 10 };
10 11
12static const char * NetworkProvides[] =
13 { "connection",
14 0
15 };
16
11/** 17/**
12 * Constructor, find all of the possible interfaces 18 * Constructor, find all of the possible interfaces
13 */ 19 */
14NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) { 20NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) {
21
22 NSResources->addSystemFile(
23 "interfaces", "/etc/network/interfaces", 1 );
15} 24}
16 25
17/** 26/**
18 * Delete any interfaces that we own. 27 * Delete any interfaces that we own.
@@ -31,33 +40,36 @@ const QString NetworkNetNode::nodeDescription(){
31ANetNodeInstance * NetworkNetNode::createInstance( void ) { 40ANetNodeInstance * NetworkNetNode::createInstance( void ) {
32 return new ANetwork( this ); 41 return new ANetwork( this );
33} 42}
34 43
35bool NetworkNetNode::hasDataForFile( const QString & S ) { 44bool NetworkNetNode::hasDataForFile( SystemFile & S ) {
36 return S == "interfaces"; 45 return S.name() == "interfaces";
37} 46}
38 47
39short NetworkNetNode::generateFile( const QString & ID, 48short NetworkNetNode::generateFile( SystemFile & SF,
40 const QString & ,
41 QTextStream & TS,
42 ANetNodeInstance * NNI, 49 ANetNodeInstance * NNI,
43 long DevNr ) { 50 long DevNr ) {
44 51
52 if( DevNr < 0 ) {
53 // generate device specific but common part
54 return 1;
55 }
56
45 QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); 57 QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
46 58
47 if( ID == "interfaces" ) { 59 if( SF.name() == "interfaces" ) {
48 Log(("Generate entry for %s in %s\n", NIC.latin1(), ID.latin1() )); 60 Log(("Generate entry for %s in %s\n", NIC.latin1(), SF.name().latin1() ));
49 // generate mapping stanza for this interface 61 // generate mapping stanza for this interface
50 TS << "# check if " 62 SF << "# check if "
51 << NIC 63 << NIC
52 << " can be brought UP" 64 << " can be brought UP"
53 << endl; 65 << endl;
54 TS << "mapping " 66 SF << "mapping "
55 << NIC 67 << NIC
56 << endl; 68 << endl;
57 TS << " script " 69 SF << " script "
58 << QPEApplication::qpeDir() 70 << QPEApplication::qpeDir()
59 << "/bin/networksettings2-request" 71 << "bin/networksettings2-request"
60 << endl 72 << endl
61 << endl; 73 << endl;
62 return 0; 74 return 0;
63 } 75 }
@@ -67,10 +79,10 @@ short NetworkNetNode::generateFile( const QString & ID,
67const char ** NetworkNetNode::needs( void ) { 79const char ** NetworkNetNode::needs( void ) {
68 return NetworkNeeds; 80 return NetworkNeeds;
69} 81}
70 82
71const char * NetworkNetNode::provides( void ) { 83const char ** NetworkNetNode::provides( void ) {
72 return "connection"; 84 return NetworkProvides;
73} 85}
74 86
75void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { 87void NetworkNetNode::setSpecificAttribute( QString & , QString & ) {
76} 88}
diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h
index 745d1a7..b063d4c 100644
--- a/noncore/settings/networksettings2/network/network_NN.h
+++ b/noncore/settings/networksettings2/network/network_NN.h
@@ -13,22 +13,20 @@ public:
13 13
14 NetworkNetNode(); 14 NetworkNetNode();
15 virtual ~NetworkNetNode(); 15 virtual ~NetworkNetNode();
16 16
17 virtual bool hasDataForFile( const QString & S ); 17 virtual bool hasDataForFile( SystemFile & S );
18 18
19 virtual short generateFile( const QString & ID, 19 virtual short generateFile( SystemFile & TS,
20 const QString & Path,
21 QTextStream & TS,
22 ANetNodeInstance * NNI, 20 ANetNodeInstance * NNI,
23 long DevNr ); 21 long DevNr );
24 virtual const QString pixmapName() 22 virtual const QString pixmapName()
25 { return "Devices/tcpip"; } 23 { return "Devices/tcpip"; }
26 24
27 virtual const QString nodeDescription() ; 25 virtual const QString nodeDescription() ;
28 virtual ANetNodeInstance * createInstance( void ); 26 virtual ANetNodeInstance * createInstance( void );
29 virtual const char ** needs( void ); 27 virtual const char ** needs( void );
30 virtual const char * provides( void ); 28 virtual const char ** provides( void );
31 29
32private: 30private:
33 31
34 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 32 virtual void setSpecificAttribute( QString & Attr, QString & Value );
diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp
index 324c6e2..78e6545 100644
--- a/noncore/settings/networksettings2/network/network_NNI.cpp
+++ b/noncore/settings/networksettings2/network/network_NNI.cpp
@@ -1,6 +1,6 @@
1#include <system.h> 1#include <system.h>
2#include <asdevice.h> 2#include <netnode.h>
3#include "networkedit.h" 3#include "networkedit.h"
4#include "network_NNI.h" 4#include "network_NNI.h"
5#include "network_NN.h" 5#include "network_NN.h"
6 6
@@ -98,71 +98,69 @@ void ANetwork::commit( void ) {
98 if( GUI && GUI->commit( Data ) ) 98 if( GUI && GUI->commit( Data ) )
99 setModified( 1 ); 99 setModified( 1 );
100} 100}
101 101
102bool ANetwork::hasDataForFile( const QString & S ) { 102bool ANetwork::hasDataForFile( SystemFile & S ) {
103 return S == "interfaces"; 103 return S.name() == "interfaces";
104} 104}
105 105
106short ANetwork::generateFile( const QString & ID, 106short ANetwork::generateFile( SystemFile &SF,
107 const QString & Path, 107 long DevNr
108 QTextStream &TS, 108 ) {
109 long DevNr
110 ) {
111 109
112 short rvl, rvd ; 110 short rvl, rvd ;
113 QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); 111 QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
114 112
115 rvl = 1; 113 rvl = 1;
116 if( ID == "interfaces" ) { 114 if( SF.name() == "interfaces" ) {
117 Log(("Generate Network for %s\n", ID.latin1() )); 115 Log(("Generate Network for %s\n", SF.name().latin1() ));
118 // we can safely call from here since device item is deeper 116 // we can safely call from here since device item is deeper
119 if( Data.UseDHCP ) { 117 if( Data.UseDHCP ) {
120 TS << "iface " 118 SF << "iface "
121 << NIC 119 << NIC
122 << "-c" 120 << "-c"
123 << connection()->number() 121 << connection()->number()
124 << "-allowed inet dhcp" 122 << "-allowed inet dhcp"
125 << endl; 123 << endl;
126 TS << " up echo \"" 124 SF << " up echo \""
127 << NIC 125 << NIC
128 << "\" > /tmp/profile-" 126 << "\" > /tmp/profile-"
129 << connection()->number() 127 << connection()->number()
130 << ".up" 128 << ".up"
131 << endl; 129 << endl;
132 if( Data.SendHostname ) { 130 if( Data.SendHostname ) {
133 TS << " hostname " 131 SF << " hostname "
134 << Data.Hostname 132 << Data.Hostname
135 << endl; 133 << endl;
136 } 134 }
137 135
138 TS << " down rm -f /tmp/profile-" 136 SF << " down rm -f /tmp/profile-"
139 << connection()->number() 137 << connection()->number()
140 << ".up" 138 << ".up"
141 << endl; 139 << endl;
142 } else { 140 } else {
143 TS << "iface " 141 SF << "iface "
144 << NIC << "-c" 142 << NIC << "-c"
145 << connection()->number() 143 << connection()->number()
146 << "-allowed inet static" 144 << "-allowed inet static"
147 << endl; 145 << endl;
148 TS << " up echo \"" 146 SF << " up echo \""
149 << NIC 147 << NIC
150 << "\" > /tmp/profile-" 148 << "\" > /tmp/profile-"
151 << connection()->number() 149 << connection()->number()
152 << ".up" 150 << ".up"
153 << endl; 151 << endl;
154 TS << " down rm -f /tmp/profile-" 152 SF << " down rm -f /tmp/profile-"
155 << connection()->number() 153 << connection()->number()
156 << ".up" 154 << ".up"
157 << endl; 155 << endl;
158 TS << " address " 156 SF << " address "
159 << Data.IPAddress 157 << Data.IPAddress
160 << endl; 158 << endl;
161 TS << " broadcast " 159 SF << " broadcast "
162 << Data.Broadcast 160 << Data.Broadcast
163 << endl; 161 << endl;
164 TS << " netmask " 162 SF << " netmask "
165 << Data.NetMask 163 << Data.NetMask
166 << endl; 164 << endl;
167 165
168 // derive network address = IPAddress & netmask 166 // derive network address = IPAddress & netmask
@@ -174,46 +172,46 @@ short ANetwork::generateFile( const QString & ID,
174 arg( ipal[0].toShort() & nmal[0].toShort() ). 172 arg( ipal[0].toShort() & nmal[0].toShort() ).
175 arg( ipal[1].toShort() & nmal[1].toShort() ). 173 arg( ipal[1].toShort() & nmal[1].toShort() ).
176 arg( ipal[2].toShort() & nmal[2].toShort() ). 174 arg( ipal[2].toShort() & nmal[2].toShort() ).
177 arg( ipal[3].toShort() & nmal[3].toShort() ); 175 arg( ipal[3].toShort() & nmal[3].toShort() );
178 TS << " network " 176 SF << " network "
179 << NW 177 << NW
180 << endl; 178 << endl;
181 } 179 }
182 } 180 }
183 for ( QStringList::Iterator it = Data.PreUp_SL.begin(); 181 for ( QStringList::Iterator it = Data.PreUp_SL.begin();
184 it != Data.PreUp_SL.end(); 182 it != Data.PreUp_SL.end();
185 ++it ) { 183 ++it ) {
186 TS << " pre-up " 184 SF << " pre-up "
187 << (*it) 185 << (*it)
188 << endl; 186 << endl;
189 } 187 }
190 for ( QStringList::Iterator it = Data.PostUp_SL.begin(); 188 for ( QStringList::Iterator it = Data.PostUp_SL.begin();
191 it != Data.PostUp_SL.end(); 189 it != Data.PostUp_SL.end();
192 ++it ) { 190 ++it ) {
193 TS << " up " 191 SF << " up "
194 << (*it) 192 << (*it)
195 << endl; 193 << endl;
196 } 194 }
197 for ( QStringList::Iterator it = Data.PreDown_SL.begin(); 195 for ( QStringList::Iterator it = Data.PreDown_SL.begin();
198 it != Data.PreDown_SL.end(); 196 it != Data.PreDown_SL.end();
199 ++it ) { 197 ++it ) {
200 TS << " down " 198 SF << " down "
201 << (*it) 199 << (*it)
202 << endl; 200 << endl;
203 } 201 }
204 for ( QStringList::Iterator it = Data.PostDown_SL.begin(); 202 for ( QStringList::Iterator it = Data.PostDown_SL.begin();
205 it != Data.PostDown_SL.end(); 203 it != Data.PostDown_SL.end();
206 ++it ) { 204 ++it ) {
207 TS << " post-down " 205 SF << " post-down "
208 << (*it) 206 << (*it)
209 << endl; 207 << endl;
210 } 208 }
211 rvl = 0; 209 rvl = 0;
212 } 210 }
213 211
214 // embed other info in it 212 // embed other info in it
215 rvd = connection()->getToplevel()->generateFileEmbedded( ID, Path, TS, DevNr ); 213 rvd = connection()->getToplevel()->generateFileEmbedded( SF, DevNr );
216 214
217 return (rvd == 2 || rvl == 2 ) ? 2 : 215 return (rvd == 2 || rvl == 2 ) ? 2 :
218 (rvd == 0 || rvl == 0 ) ? 0 : 1; 216 (rvd == 0 || rvl == 0 ) ? 0 : 1;
219} 217}
diff --git a/noncore/settings/networksettings2/network/network_NNI.h b/noncore/settings/networksettings2/network/network_NNI.h
index 5e42503..71c276a 100644
--- a/noncore/settings/networksettings2/network/network_NNI.h
+++ b/noncore/settings/networksettings2/network/network_NNI.h
@@ -26,13 +26,11 @@ public :
26 26
27 virtual void * data( void ) 27 virtual void * data( void )
28 { return (void *)&Data; } 28 { return (void *)&Data; }
29 29
30 virtual bool hasDataForFile( const QString & S ); 30 virtual bool hasDataForFile( SystemFile & SF );
31 virtual short generateFile( const QString & ID, 31 virtual short generateFile( SystemFile &TS,
32 const QString & Path, 32 long DevNr );
33 QTextStream &TS,
34 long DevNr );
35 33
36protected : 34protected :
37 35
38 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 36 virtual void setSpecificAttribute( QString & Attr, QString & Value );
@@ -40,9 +38,9 @@ protected :
40 38
41private : 39private :
42 40
43 NetworkEdit * GUI; 41 NetworkEdit * GUI;
44 NetworkData_t Data; 42 NetworkData Data;
45 NetworkRun * RT; 43 NetworkRun * RT;
46}; 44};
47 45
48#endif 46#endif
diff --git a/noncore/settings/networksettings2/network/networkdata.h b/noncore/settings/networksettings2/network/networkdata.h
index 2c5da37..1df9dc4 100644
--- a/noncore/settings/networksettings2/network/networkdata.h
+++ b/noncore/settings/networksettings2/network/networkdata.h
@@ -2,9 +2,10 @@
2#define NETWORK_DATA_H 2#define NETWORK_DATA_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qstringlist.h> 5#include <qstringlist.h>
6typedef struct NetworkData { 6class NetworkData {
7public :
7 bool UseDHCP; 8 bool UseDHCP;
8 QString Hostname; 9 QString Hostname;
9 bool SendHostname; 10 bool SendHostname;
10 QString IPAddress; 11 QString IPAddress;
@@ -16,7 +17,7 @@ typedef struct NetworkData {
16 QStringList PreUp_SL; 17 QStringList PreUp_SL;
17 QStringList PostUp_SL; 18 QStringList PostUp_SL;
18 QStringList PreDown_SL; 19 QStringList PreDown_SL;
19 QStringList PostDown_SL; 20 QStringList PostDown_SL;
20} NetworkData_t; 21} ;
21 22
22#endif 23#endif
diff --git a/noncore/settings/networksettings2/network/networkedit.cpp b/noncore/settings/networksettings2/network/networkedit.cpp
index 05110d9..d13cb66 100644
--- a/noncore/settings/networksettings2/network/networkedit.cpp
+++ b/noncore/settings/networksettings2/network/networkedit.cpp
@@ -64,9 +64,9 @@ QString NetworkEdit::acceptable( void ) {
64 return tr("DNS2 address not valid"); 64 return tr("DNS2 address not valid");
65 return QString(); 65 return QString();
66} 66}
67 67
68bool NetworkEdit::commit( NetworkData_t & Data ) { 68bool NetworkEdit::commit( NetworkData & Data ) {
69 bool SM = 0; 69 bool SM = 0;
70 CBM( Data.UseDHCP, DHCP_CB, SM ); 70 CBM( Data.UseDHCP, DHCP_CB, SM );
71 TXTM( Data.IPAddress, IPAddress_LE, SM ); 71 TXTM( Data.IPAddress, IPAddress_LE, SM );
72 CBM( Data.SendHostname, SendHostname_CB, SM ); 72 CBM( Data.SendHostname, SendHostname_CB, SM );
@@ -84,9 +84,9 @@ bool NetworkEdit::commit( NetworkData_t & Data ) {
84 84
85 return SM; 85 return SM;
86} 86}
87 87
88void NetworkEdit::showData( NetworkData_t & Data ) { 88void NetworkEdit::showData( NetworkData & Data ) {
89 DHCP_CB->setChecked( Data.UseDHCP ); 89 DHCP_CB->setChecked( Data.UseDHCP );
90 SendHostname_CB->setChecked( Data.SendHostname ); 90 SendHostname_CB->setChecked( Data.SendHostname );
91 Hostname_LE->setText( Data.Hostname ); 91 Hostname_LE->setText( Data.Hostname );
92 IPAddress_LE->setText( Data.IPAddress ); 92 IPAddress_LE->setText( Data.IPAddress );
diff --git a/noncore/settings/networksettings2/network/networkedit.h b/noncore/settings/networksettings2/network/networkedit.h
index adc20e0..45635c8 100644
--- a/noncore/settings/networksettings2/network/networkedit.h
+++ b/noncore/settings/networksettings2/network/networkedit.h
@@ -8,10 +8,10 @@ class NetworkEdit : public NetworkGUI {
8public : 8public :
9 9
10 NetworkEdit( QWidget * parent ); 10 NetworkEdit( QWidget * parent );
11 QString acceptable( void ); 11 QString acceptable( void );
12 bool commit( NetworkData_t & Data ); 12 bool commit( NetworkData & Data );
13 void showData( NetworkData_t & Data ); 13 void showData( NetworkData & Data );
14 14
15public slots : 15public slots :
16 16
17 void SLOT_NetmaskModified( const QString & S ); 17 void SLOT_NetmaskModified( const QString & S );
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp
index 3e24c5f..c17aa7f 100644
--- a/noncore/settings/networksettings2/network/networkrun.cpp
+++ b/noncore/settings/networksettings2/network/networkrun.cpp
@@ -1,78 +1,51 @@
1#include <system.h> 1#include <system.h>
2#include <asdevice.h> 2#include <netnode.h>
3#include <resources.h>
3#include "networkrun.h" 4#include "networkrun.h"
4 5
5void NetworkRun::detectState( NodeCollection * NC ) { 6State_t NetworkRun::detectState( void ) {
6 RuntimeInfo * RI = netNode()->nextNode()->runtime(); 7 InterfaceInfo * II = nodeCollection()->assignedInterface();
7 AsDevice * Next = RI->asDevice();
8 InterfaceInfo * II = Next->assignedInterface();
9 8
10 if( II ) { 9 Log(( "Interface %p : %d\n", II, (II) ? II->IsUp : 0 ));
10 if( II && II->IsUp ) {
11 // device has assigned interface 11 // device has assigned interface
12 NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); 12 return IsUp;
13 return;
14 } 13 }
15 14
16 Log(( "%s not ! UP or ava\n", NC->name().latin1() )); 15 // had no interface or interface is no longer up -> release
17 // has no interface -> delegate 16 nodeCollection()->assignInterface( 0 );
18 RI->detectState( NC ); 17
18 return Unknown;
19} 19}
20 20
21bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) { 21QString NetworkRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
22 // we handle UP and DOWN 22 // we handle UP and DOWN
23 RuntimeInfo * RI = netNode()->nextNode()->runtime(); 23 InterfaceInfo * II = NC->assignedInterface();
24 AsDevice * Next = RI->asDevice();
25 InterfaceInfo * II = Next->assignedInterface();
26 24
27 if( A == Up ) { 25 if( A == Up ) {
28 // we can bring UP if lower level is available 26 // we can bring UP if lower level is available
29 if( NC->currentState() == Available || Force ) { 27 QStringList SL;
30 QString S; 28 SL << "ifup"
31 S.sprintf( "ifup %s=%s-c%d-allowed", 29 << QString().sprintf( "%s=%s-c%d-allowed",
32 II->Name.latin1(), II->Name.latin1(), 30 II->Name.latin1(), II->Name.latin1(),
33 connection()->number() ); 31 nodeCollection()->number() );
34 NSResources->system().runAsRoot( S ); 32 if( ! NSResources->system().runAsRoot( SL ) ) {
33 return QString("Cannot call %1").arg(SL.join(" "));
35 } 34 }
36 return 1; 35 return QString();
37 } else if( A == Down ) { 36 }
38 QString S; 37
39 if( Force ) { 38 if( A == Down ) {
40 Log(("Force mode %d\n", Force )); 39 QStringList SL;
41 for( int i = 0; 40 if( II ) {
42 i < RI->netNode()->nodeClass()->instanceCount(); 41 SL << "ifdown"
43 i ++ ) { 42 << II->Name.latin1();
44 S.sprintf( "ifdown %s", 43 if( ! NSResources->system().runAsRoot( SL ) ) {
45 RI->netNode()->nodeClass()->genNic( i ).latin1() ); 44 return QString( "Cannot call %1" ).arg( SL.join( " " ));
46 NSResources->system().runAsRoot( S );
47 } 45 }
48 } else { 46 } else {
49 if( NC->currentState() == IsUp ) { 47 Log(( "no interface assigned." ));
50 S.sprintf( "ifdown %s=%s-c%d-allowed",
51 II->Name.latin1(), II->Name.latin1(),
52 connection()->number() );
53 NSResources->system().runAsRoot( S );
54 }
55 } 48 }
56 return 1;
57 }
58 // delegate
59 return RI->setState( NC, A, Force );
60}
61
62bool NetworkRun::canSetState( State_t Curr, Action_t A ) {
63 // we handle UP and DOWN
64 RuntimeInfo * RI = netNode()->nextNode()->runtime();
65
66 if( A == Up ) {
67 return ( Curr == Available );
68 } else if( A == Down ) {
69 return ( Curr == IsUp );
70 } 49 }
71 // delegate 50 return QString();
72 return RI->canSetState( Curr, A );
73}
74
75bool NetworkRun::handlesInterface( const QString & S ) {
76 // donno -> pass deeper
77 return netNode()->nextNode()->runtime()->handlesInterface(S);
78} 51}
diff --git a/noncore/settings/networksettings2/network/networkrun.h b/noncore/settings/networksettings2/network/networkrun.h
index 522a912..78a1694 100644
--- a/noncore/settings/networksettings2/network/networkrun.h
+++ b/noncore/settings/networksettings2/network/networkrun.h
@@ -1,23 +1,20 @@
1#include <asconnection.h> 1#include <netnode.h>
2#include "networkdata.h" 2#include "networkdata.h"
3 3
4class NetworkRun : public AsConnection { 4class NetworkRun : public RuntimeInfo {
5 5
6public : 6public :
7 7
8 NetworkRun( ANetNodeInstance * NNI, 8 NetworkRun( ANetNodeInstance * NNI,
9 NetworkData & Data ) : AsConnection( NNI ) 9 NetworkData & Data ) : RuntimeInfo( NNI )
10 { } 10 { }
11 11
12 virtual AsConnection * asConnection( void ) 12 virtual RuntimeInfo * connection( void )
13 { return (AsConnection *)this; } 13 { return this; }
14 14
15protected : 15 State_t detectState( void );
16
17 void detectState( NodeCollection * );
18 bool setState( NodeCollection * ,Action_t A, bool );
19 bool canSetState( State_t , Action_t A );
20 16
21 bool handlesInterface( const QString & I ); 17protected :
22 18
19 QString setMyState( NodeCollection * , Action_t, bool );
23}; 20};
diff --git a/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control b/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control
index 3dbb808..7b1056b 100644
--- a/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control
+++ b/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control
@@ -1,5 +1,5 @@
1Package: opie-networksettingsplugin2-network 1Package: opie-networksettings2plugin-network
2Files: plugins/networksettings2/libnetwork.so* 2Files: plugins/networksettings2/libnetwork.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Wim Delvaux <wimpie@handhelds.org> 5Maintainer: Wim Delvaux <wimpie@handhelds.org>
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp
index ce0eabc..a0d4c7c 100644
--- a/noncore/settings/networksettings2/networksettings.cpp
+++ b/noncore/settings/networksettings2/networksettings.cpp
@@ -1,10 +1,14 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <unistd.h> 2#include <unistd.h>
3#include <errno.h> 3#include <errno.h>
4 4
5#include <opie2/odebug.h>
6#include <opie2/oledbox.h>
7
5#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
6#include <qlistbox.h> 9#include <qlistbox.h>
10#include <qlayout.h>
7#include <qgroupbox.h> 11#include <qgroupbox.h>
8#include <qtimer.h> 12#include <qtimer.h>
9#include <qlistbox.h> 13#include <qlistbox.h>
10#include <qmessagebox.h> 14#include <qmessagebox.h>
@@ -14,9 +18,8 @@
14#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
15#include <qtoolbutton.h> 19#include <qtoolbutton.h>
16#include <qevent.h> 20#include <qevent.h>
17 21
18#include <asdevice.h>
19#include "networksettings.h" 22#include "networksettings.h"
20#include "netnode.h" 23#include "netnode.h"
21#include "editconnection.h" 24#include "editconnection.h"
22 25
@@ -30,15 +33,26 @@ NetworkSettings::NetworkSettings( QWidget *parent,
30 // set pixmaps 33 // set pixmaps
31 Add_TB->setPixmap( NSResources->getPixmap( "add" ) ); 34 Add_TB->setPixmap( NSResources->getPixmap( "add" ) );
32 Delete_TB->setPixmap( NSResources->getPixmap( "remove" ) ); 35 Delete_TB->setPixmap( NSResources->getPixmap( "remove" ) );
33 CheckState_TB->setPixmap( NSResources->getPixmap( "check" ) ); 36 CheckState_TB->setPixmap( NSResources->getPixmap( "check" ) );
34 Enable_TB->setPixmap( NSResources->getPixmap( "disabled" ) );
35 GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) ); 37 GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) );
36 38
37 Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) ); 39 Disable_TB->setPixmap( NSResources->getPixmap( "disabled" ) );
38 Disconnect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) ); 40 Up_TB->setPixmap( NSResources->getPixmap( "more" ) );
41 Down_TB->setPixmap( NSResources->getPixmap( "less" ) );
42
43 QVBoxLayout* V = new QVBoxLayout( LED_Frm );
44 QHBoxLayout * H = new QHBoxLayout( 0 );
45 V->addStretch(1);
46 V->addLayout( H );
47 Leds[0] = new OLedBox( red, LED_Frm );
48 H->addWidget( Leds[0], 0, Qt::AlignVCenter );
49 Leds[1] = new OLedBox( red, LED_Frm );
50 H->addWidget( Leds[1], 0, Qt::AlignVCenter );
51 Leds[2] = new OLedBox( red, LED_Frm );
52 H->addWidget( Leds[2], 0, Qt::AlignVCenter );
53 V->addStretch(1);
39 54
40 On_TB->setPixmap( NSResources->getPixmap( "off" ) );
41 55
42 SLOT_ToProfile(); 56 SLOT_ToProfile();
43 57
44 // populate main Listbox 58 // populate main Listbox
@@ -71,9 +85,17 @@ NetworkSettings::NetworkSettings( QWidget *parent,
71 QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) ); 85 QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) );
72 } 86 }
73 87
74 connect( &(NSResources->system()), 88 connect( &(NSResources->system()),
75 SIGNAL( lineFromCommand(const QString &) ), 89 SIGNAL( stdoutLine(const QString &) ),
90 this, SLOT( SLOT_CmdMessage(const QString &) ) );
91
92 connect( &(NSResources->system()),
93 SIGNAL( stderrLine(const QString &) ),
94 this, SLOT( SLOT_CmdMessage(const QString &) ) );
95
96 connect( &(NSResources->system()),
97 SIGNAL( processEvent(const QString &) ),
76 this, SLOT( SLOT_CmdMessage(const QString &) ) ); 98 this, SLOT( SLOT_CmdMessage(const QString &) ) );
77 99
78 UpdateTimer->start( 5000 ); 100 UpdateTimer->start( 5000 );
79 connect( UpdateTimer, SIGNAL( timeout() ), 101 connect( UpdateTimer, SIGNAL( timeout() ),
@@ -86,18 +108,23 @@ NetworkSettings::NetworkSettings( QWidget *parent,
86 108
87NetworkSettings::~NetworkSettings() { 109NetworkSettings::~NetworkSettings() {
88 QString S; 110 QString S;
89 111
90 if( isModified() ) { 112 owarn << "Dispose NS" << oendl;
113 if( NSD.isModified() ) {
114 owarn << "Modified" << oendl;
91 S = NSD.saveSettings(); 115 S = NSD.saveSettings();
92 if( ! S.isEmpty() ) { 116 if( ! S.isEmpty() ) {
117 S.insert( 0, "<p>" );
118 S.append( "</p>" );
93 // problem saving 119 // problem saving
94 QMessageBox::warning( 120 QMessageBox::warning(
95 0, 121 0,
96 tr( "Saving setup" ), S ); 122 tr( "Saving setup" ), S );
97 } 123 }
98 124
99 SLOT_GenerateConfig(); 125 SLOT_GenerateConfig();
126 NSD.setModified( 0 );
100 } 127 }
101 128
102} 129}
103 130
@@ -166,16 +193,15 @@ void NetworkSettings::SLOT_DeleteNode( void ) {
166 tr( "Remove selected profile ?" ), 193 tr( "Remove selected profile ?" ),
167 1, 0 ) == 1 ) { 194 1, 0 ) == 1 ) {
168 NSResources->removeConnection( LBI->text() ); 195 NSResources->removeConnection( LBI->text() );
169 delete LBI; 196 delete LBI;
170 setModified( 1 ); 197 NSD.setModified( 1 );
171 } 198 }
172} 199}
173 200
174void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { 201void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
175 QString OldName = ""; 202 QString OldName = "";
176 203
177 printf( "------------------ Edit NOde\n" );
178 EditConnection EC( this ); 204 EditConnection EC( this );
179 205
180 if( LBI ) { 206 if( LBI ) {
181 NodeCollection * NC = NSResources->findConnection( LBI->text() ); 207 NodeCollection * NC = NSResources->findConnection( LBI->text() );
@@ -195,9 +221,8 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
195 if( EC.exec() == QDialog::Accepted ) { 221 if( EC.exec() == QDialog::Accepted ) {
196 // toplevel item -> store 222 // toplevel item -> store
197 NodeCollection * NC = EC.connection(); 223 NodeCollection * NC = EC.connection();
198 if( NC->isModified() ) { 224 if( NC->isModified() ) {
199 setModified( 1 );
200 if( LBI ) { 225 if( LBI ) {
201 if( NC->name() != OldName ) { 226 if( NC->name() != OldName ) {
202 // find if new name is free 227 // find if new name is free
203 NodeCollection * LCN = NSResources->findConnection( 228 NodeCollection * LCN = NSResources->findConnection(
@@ -248,64 +273,57 @@ void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) {
248 return; 273 return;
249 274
250 NodeCollection * NC = NSResources->findConnection( LBI->text() ); 275 NodeCollection * NC = NSResources->findConnection( LBI->text() );
251 276
252 // is button possible 277 if( NC->description().isEmpty() ) {
253 bool EnabledPossible, OnPossible, ConnectPossible; 278 Description_LBL->setText( tr( "<<No description>>" ) );
254 // is button On or Off 279 } else {
255 bool DisabledOn, OnOn, ConnectOn; 280 Description_LBL->setText( NC->description() );
281 }
282
283 Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() );
256 284
257 EnabledPossible = OnPossible = ConnectPossible = 1; 285 bool FrmActive = 1;
258 DisabledOn = 1; 286 bool IsEnabled = 1;
259 OnOn = ConnectOn = 0; 287 int leds = 0;
260 288
289 owarn << "State " << NC->state() << oendl;
261 switch( NC->state() ) { 290 switch( NC->state() ) {
262 case Unknown : 291 case Disabled : // no further work
263 // cannot occur here 292 IsEnabled = 0;
293 FrmActive = 0;
294 owarn << "LEds " << leds << oendl;
264 break; 295 break;
296 case Unknown :
265 case Unchecked : 297 case Unchecked :
266 case Unavailable : 298 case Unavailable :
267 // cannot do anything but recheck 299 FrmActive = 0;
268 EnabledPossible = OnPossible = ConnectPossible = 0;
269 break;
270 case Disabled :
271 OnPossible = ConnectPossible = 0;
272 break; 300 break;
273 case Off : 301 case Off :
274 DisabledOn = 0; 302 leds = 1;
275 break; 303 break;
276 case Available : 304 case Available :
277 OnOn = 1; 305 leds = 2;
278 Connect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) );
279 DisabledOn = 0;
280 break; 306 break;
281 case IsUp : 307 case IsUp :
282 OnOn = ConnectOn = 1; 308 leds = 3;
283 Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) );
284 DisabledOn = 0;
285 break; 309 break;
286 } 310 }
287 311
288 if( ! OnOn ) { 312 Disable_TB->setOn( ! IsEnabled );
289 Connect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) ); 313 LED_Frm->setEnabled( FrmActive );
290 }
291
292 // set button state
293 Enable_TB->setEnabled( EnabledPossible );
294 On_TB->setEnabled( OnPossible );
295 Connect_TB->setEnabled( ConnectPossible );
296
297 Enable_TB->setOn( DisabledOn );
298 On_TB->setOn( OnOn );
299 Connect_TB->setOn( ConnectOn );
300 314
301 if( NC->description().isEmpty() ) { 315 for( int i = 0 ; i < leds; i ++ ) {
302 Description_LBL->setText( tr( "<<No description>>" ) ); 316 Leds[i]->setColor( red );
303 } else { 317 Leds[i]->setOn( true );
304 Description_LBL->setText( NC->description() ); 318 }
319 for( int i = leds ; i < 3; i ++ ) {
320 Leds[i]->setColor( red );
321 Leds[i]->setOn( false );
305 } 322 }
306 323
307 Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() ); 324 Up_TB->setEnabled( leds < 3 && leds != 0 );
325 Down_TB->setEnabled( leds > 0 );
308} 326}
309 327
310void NetworkSettings::SLOT_CheckState( void ) { 328void NetworkSettings::SLOT_CheckState( void ) {
311 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 329 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
@@ -320,138 +338,165 @@ void NetworkSettings::updateProfileState( QListBoxItem * LBI ) {
320 } 338 }
321} 339}
322 340
323void NetworkSettings::SLOT_GenerateConfig( void ) { 341void NetworkSettings::SLOT_GenerateConfig( void ) {
324 NSD.regenerate(); 342 QString S = NSD.generateSettings();
343 if( ! S.isEmpty() ) {
344 S.insert( 0, "<p>" );
345 S.append( "</p>" );
346 QMessageBox::warning(
347 0,
348 tr( "Generate config" ),
349 S);
350 }
325} 351}
326 352
327void NetworkSettings::SLOT_Enable( void ) { 353void NetworkSettings::SLOT_Disable( bool T ) {
328 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 354 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
329 QString Msg; 355 QString Msg;
356
330 if ( ! LBI ) 357 if ( ! LBI )
331 return; 358 return;
332 359
333 NodeCollection * NC = 360 NodeCollection * NC = NSResources->findConnection( LBI->text() );
334 NSResources->findConnection( LBI->text() );
335
336 bool rv;
337 switch( NC->state() ) {
338 case Disabled :
339 Msg = tr( "Cannot enable profile" );
340 rv = NC->setState( Enable );
341 break;
342 default :
343 Msg = tr( "Cannot disable profile" );
344 rv = NC->setState( Disable );
345 break;
346 }
347 361
348 if( ! rv ) { 362 owarn << "Prepare to disable" << oendl;
363 Msg = NC->setState( (T) ? Disable : Enable );
364 if( ! Msg.isEmpty() ) {
365 Msg.insert( 0, "<p>" );
366 Msg.append( "</p>" );
349 QMessageBox::warning( 367 QMessageBox::warning(
350 0, 368 0,
351 tr( "Activating profile" ), 369 tr( "Activating profile" ),
352 Msg ); 370 Msg );
353 return; 371 return;
354 } 372 }
373
374 // reload new state
375 NC->state( true );
355 updateProfileState( LBI ); 376 updateProfileState( LBI );
356} 377}
357 378
358void NetworkSettings::SLOT_On( void ) { 379void NetworkSettings::SLOT_Up( void ) {
380 // bring more up
381
359 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 382 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
383 QString Msg;
384 int led = -1;
360 385
361 if ( ! LBI ) 386 if ( ! LBI )
362 return; 387 return;
363 388
364 NodeCollection * NC = 389 NodeCollection * NC =
365 NSResources->findConnection( LBI->text() ); 390 NSResources->findConnection( LBI->text() );
366 391
367 bool rv;
368 switch( NC->state() ) { 392 switch( NC->state() ) {
369 case Off : 393 case Disabled : // cannot modify this state
370 // activate interface 394 case Unknown : // cannot modify this state
371 rv = NC->setState( Activate ); 395 case Unchecked : // cannot modify this state
396 case Unavailable : // cannot modify this state
397 case IsUp : // highest UP state
398 return;
399 case Off : // -> activate
400 led = 1;
401 Down_TB->setEnabled( true );
402 Log(( "Activate interface %s\n", NC->name().latin1() ));
403 Msg = NC->setState( Activate );
372 break; 404 break;
373 case Available : // deactivate 405 case Available : // -> up
374 case IsUp : // deactivate (will also bring down if needed) 406 led = 2;
375 rv = NC->setState( Deactivate ); 407 Log(( "Bring up interface %s\n", NC->name().latin1() ));
408 Msg = NC->setState( Up );
409 if( Msg.isEmpty() ) {
410 Up_TB->setEnabled( false );
411 }
376 break; 412 break;
377 default : 413 }
378 // others no change
379 return;
380 }
381 414
382 if( ! rv ) { 415 if( ! Msg.isEmpty() ) {
416 Msg.insert( 0, "<p>" );
417 Msg.append( "</p>" );
383 QMessageBox::warning( 418 QMessageBox::warning(
384 0, 419 0,
385 tr( "Activating profile" ), 420 tr( "Increase availability" ),
386 tr( "Cannot enable profile" ) ); 421 Msg );
387 return; 422 return;
388 } 423 }
424
389 updateProfileState( LBI ); 425 updateProfileState( LBI );
426
427 // set color of led we should change
428 if( led > 0 ) {
429 Leds[led]->setColor( blue );
430 Leds[led]->setOn( true );
431 }
432
390} 433}
391 434
392void NetworkSettings::SLOT_Connect( void ) { 435void NetworkSettings::SLOT_Down( void ) {
436 // bring more down
437
393 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 438 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
439 int led = -1;
440 QString Msg;
394 441
395 if ( ! LBI ) 442 if ( ! LBI )
396 return; 443 return;
397 444
398 NodeCollection * NC = 445 NodeCollection * NC =
399 NSResources->findConnection( LBI->text() ); 446 NSResources->findConnection( LBI->text() );
400 447
401 bool rv = 1 ;
402 switch( NC->state() ) { 448 switch( NC->state() ) {
403 case IsUp : 449 case Disabled : // cannot modify this state
404 // down interface 450 case Unknown : // cannot modify this state
405 rv = NC->setState( Down ); 451 case Unchecked : // cannot modify this state
406 break; 452 case Unavailable : // cannot modify this state
407 case Available : 453 case Off : // highest DOWN state
408 // up interface
409 rv = NC->setState( Up );
410 break; 454 break;
411 case Off : 455 case Available : // -> down
412 // activate and bring up 456 led = 0;
413 rv = ( NC->setState( Activate ) && 457 Log(( "Deactivate interface %s\n", NC->name().latin1() ));
414 NC->setState( Up ) ); 458 Msg = NC->setState( Deactivate );
459 Down_TB->setEnabled( false );
415 break; 460 break;
416 default : 461 case IsUp : // highest UP state
417 // others no change 462 led = 1;
463 Up_TB->setEnabled( true );
464 Log(( "Bring down interface %s\n", NC->name().latin1() ));
465 Msg = NC->setState( Down, 1 );
466 if( Msg.isEmpty() ) {
467 // remove 'up' file to make sure
468 unlink ( QString().sprintf( "/tmp/Profile-%d.up", NC->number() ).latin1() );;
469 }
418 break; 470 break;
419 } 471 }
420 472
421 if( ! rv ) { 473 if( ! Msg.isEmpty() ) {
474 Msg.insert( 0, "<p>" );
475 Msg.append( "</p>" );
422 QMessageBox::warning( 476 QMessageBox::warning(
423 0, 477 0,
424 tr( "Activating profile" ), 478 tr( "Decrease availability" ),
425 tr( "Cannot enable profile" ) ); 479 Msg );
426 }
427
428 // we do not update the GUI but wait for the REAL upping of the device
429}
430
431void NetworkSettings::SLOT_Disconnect( void ) {
432 QString S;
433 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
434
435 if ( ! LBI )
436 return; 480 return;
481 }
437 482
438 NodeCollection * NC = 483 updateProfileState( LBI );
439 NSResources->findConnection( LBI->text() );
440 484
441 Log(( "Force interface %s down\n", NC->name().latin1() )); 485 // set color of led we should change
442 NC->setState( Down, 1 ); 486 if( led >= 0 ) {
443 // remove 'up' file to make sure 487 Leds[led]->setColor( blue );
444 S.sprintf( "/tmp/Profile-%d.up", NC->number() ); 488 }
445 unlink( S.latin1() );
446} 489}
447 490
448void NetworkSettings::SLOT_ToMessages( void ) { 491void NetworkSettings::SLOT_ToMessages( void ) {
492 Profiles_LB->hide();
449 Profile_GB->hide(); 493 Profile_GB->hide();
450 Messages_GB->show(); 494 Messages_GB->show();
451} 495}
452 496
453void NetworkSettings::SLOT_ToProfile( void ) { 497void NetworkSettings::SLOT_ToProfile( void ) {
498 Profiles_LB->show();
454 Profile_GB->show(); 499 Profile_GB->show();
455 Messages_GB->hide(); 500 Messages_GB->hide();
456} 501}
457 502
diff --git a/noncore/settings/networksettings2/networksettings.h b/noncore/settings/networksettings2/networksettings.h
index 8ec5d08..987e311 100644
--- a/noncore/settings/networksettings2/networksettings.h
+++ b/noncore/settings/networksettings2/networksettings.h
@@ -6,8 +6,9 @@ class ANetNode;
6class ANetNodeInstance; 6class ANetNodeInstance;
7class QTimer; 7class QTimer;
8class QListBoxItem; 8class QListBoxItem;
9class QEvent; 9class QEvent;
10class OLedBox;
10 11
11class NetworkSettings : public NetworkSettingsGUI { 12class NetworkSettings : public NetworkSettingsGUI {
12 13
13 Q_OBJECT 14 Q_OBJECT
@@ -16,29 +17,25 @@ public :
16 17
17 NetworkSettings( QWidget *parent=0, 18 NetworkSettings( QWidget *parent=0,
18 const char *name=0, 19 const char *name=0,
19 WFlags fl = 0 ); 20 WFlags fl = 0 );
20 ~NetworkSettings( void ); 21 virtual ~NetworkSettings( void );
21 22
22 static QString appName( void ) 23 static QString appName( void )
23 { return QString::fromLatin1("networksettings"); } 24 { return QString::fromLatin1("networksettings"); }
24 25
25 bool isModified( void )
26 { return NSD.isModified(); }
27 void setModified( bool m )
28 { NSD.setModified( m ); }
29
30public slots : 26public slots :
31 27
32 void SLOT_AddNode( void ); 28 void SLOT_AddNode( void );
33 void SLOT_DeleteNode( void ); 29 void SLOT_DeleteNode( void );
34 void SLOT_ShowNode( QListBoxItem * ); 30 void SLOT_ShowNode( QListBoxItem * );
35 void SLOT_EditNode( QListBoxItem * ); 31 void SLOT_EditNode( QListBoxItem * );
36 void SLOT_CheckState( void ); 32 void SLOT_CheckState( void );
37 void SLOT_Enable( void ); 33
38 void SLOT_On( void ); 34 void SLOT_Up( void );
39 void SLOT_Connect( void ); 35 void SLOT_Down( void );
40 void SLOT_Disconnect( void ); 36 void SLOT_Disable( bool );
37
41 void SLOT_GenerateConfig( void ); 38 void SLOT_GenerateConfig( void );
42 void SLOT_RefreshStates( void ); 39 void SLOT_RefreshStates( void );
43 void SLOT_QCopMessage( const QCString&,const QByteArray& ); 40 void SLOT_QCopMessage( const QCString&,const QByteArray& );
44 void SLOT_ToProfile( void ); 41 void SLOT_ToProfile( void );
@@ -49,5 +46,14 @@ private :
49 46
50 void updateProfileState( QListBoxItem * it ); 47 void updateProfileState( QListBoxItem * it );
51 QTimer * UpdateTimer; 48 QTimer * UpdateTimer;
52 NetworkSettingsData NSD; 49 NetworkSettingsData NSD;
50 /*
51
52 no leds : not present, unknown, unchecked or disabled
53 (1) down : hardware present but inactive
54 (2) available : hardware present and active
55 (3) up : present active and connected
56
57 */
58 OLedBox * Leds[3];
53}; 59};
diff --git a/noncore/settings/networksettings2/networksettings.pro b/noncore/settings/networksettings2/networksettings.pro
index 5d9efbb..d201db1 100644
--- a/noncore/settings/networksettings2/networksettings.pro
+++ b/noncore/settings/networksettings2/networksettings.pro
@@ -10,11 +10,11 @@ SOURCES = main.cpp \
10 nsdata.cpp \ 10 nsdata.cpp \
11 activateprofile.cpp \ 11 activateprofile.cpp \
12 activatevpn.cpp \ 12 activatevpn.cpp \
13 editconnection.cpp 13 editconnection.cpp
14INCLUDEPATH += $(OPIEDIR)/include networksettings2/ 14INCLUDEPATH += $(OPIEDIR)/include networksettings2/ opietooth2/
15DEPENDPATH += $(OPIEDIR)/include networksettings2/ 15DEPENDPATH += $(OPIEDIR)/include networksettings2/ opietooth2/
16LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings2 -lnetworksettings2 -lopiecore2 16LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings2 -lnetworksettings2 -lopietooth2 -lopiecore2
17INTERFACES = networksettingsGUI.ui \ 17INTERFACES = networksettingsGUI.ui \
18 editconnectionGUI.ui \ 18 editconnectionGUI.ui \
19 activatevpnGUI.ui \ 19 activatevpnGUI.ui \
20 activateprofileGUI.ui 20 activateprofileGUI.ui
diff --git a/noncore/settings/networksettings2/networksettings2/GUIUtils.h b/noncore/settings/networksettings2/networksettings2/GUIUtils.h
index 23290a9..baf6f0c 100644
--- a/noncore/settings/networksettings2/networksettings2/GUIUtils.h
+++ b/noncore/settings/networksettings2/networksettings2/GUIUtils.h
@@ -30,7 +30,16 @@
30 FL = 1; \ 30 FL = 1; \
31 Data = Wdg->currentItem(); \ 31 Data = Wdg->currentItem(); \
32 } 32 }
33 33
34#define STXT(a, b) \
35 b->setText( a );
36
37#define SCB(a, b) \
38 b->setChecked( a );
39
40#define SSB( Data,Wdg) \
41 Wdg->setValue( Data )
42
34extern bool validIP( const QString & S ); 43extern bool validIP( const QString & S );
35 44
36#endif 45#endif
diff --git a/noncore/settings/networksettings2/networksettings2/Utils.h b/noncore/settings/networksettings2/networksettings2/Utils.h
index 739476e..301aac1 100644
--- a/noncore/settings/networksettings2/networksettings2/Utils.h
+++ b/noncore/settings/networksettings2/networksettings2/Utils.h
@@ -1,7 +1,9 @@
1#ifndef __UTILS_H 1#ifndef __UTILS_H
2#define __UTILS_H 2#define __UTILS_H
3 3
4#include <opie2/odebug.h>
5
4#define Log(x) VLog x 6#define Log(x) VLog x
5extern void VLog( char * Format, ... ); 7extern void VLog( char * Format, ... );
6extern void LogClose( void ); 8extern void LogClose( void );
7extern QString removeSpaces( const QString & X ); 9extern QString removeSpaces( const QString & X );
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp
index 110786a..17653bd 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.cpp
+++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp
@@ -1,21 +1,34 @@
1#include <time.h> 1#include <time.h>
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4 4
5
6#include <qpainter.h> 5#include <qpainter.h>
7#include <qbitmap.h> 6#include <qbitmap.h>
8#include <qtextstream.h> 7#include <qtextstream.h>
9#include <qpixmap.h> 8#include <qpixmap.h>
10 9
11#include "resources.h" 10#include "resources.h"
12#include "netnode.h" 11#include "netnode.h"
13 12
14#include "asdevice.h" 13static char * ActionName[] = {
15#include "asline.h" 14 "Disable",
16#include "asconnection.h" 15 "Enable",
17#include "asfullsetup.h" 16 "Activate",
17 "Deactivate",
18 "Up",
19 "Down"
20};
21
22static char * StateName[] = {
23 "Unchecked",
24 "Unknown",
25 "Unavailable",
26 "Disabled",
27 "Off",
28 "Available",
29 "IsUp"
30};
18 31
19QString & deQuote( QString & X ) { 32QString & deQuote( QString & X ) {
20 if( X[0] == '"' ) { 33 if( X[0] == '"' ) {
21 // remove end and trailing "" and \x -> x 34 // remove end and trailing "" and \x -> x
@@ -64,8 +77,23 @@ void ANetNode::saveAttributes( QTextStream & TS ) {
64void ANetNode::setAttribute( QString & Attr, QString & Value ){ 77void ANetNode::setAttribute( QString & Attr, QString & Value ){
65 setSpecificAttribute( Attr, Value ); 78 setSpecificAttribute( Attr, Value );
66} 79}
67 80
81bool ANetNode::isToplevel( void ) {
82 const char ** P = provides();
83 while( *P ) {
84 if( strcmp( *P, "fullsetup") == 0 )
85 return 1;
86 P ++;
87 }
88 return 0;
89}
90
91bool ANetNode::openFile( SystemFile & SF,
92 ANetNodeInstance * NNI ) {
93 return (NNI ) ? NNI->openFile( SF ) : 0 ;
94}
95
68// 96//
69// 97//
70// ANETNODEINSTANCE 98// ANETNODEINSTANCE
71// 99//
@@ -83,17 +111,17 @@ void ANetNodeInstance::initialize( void ) {
83 setName( N.latin1() ); 111 setName( N.latin1() );
84} 112}
85 113
86void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ 114void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){
87 if( Attr == "name" ) { 115 if( Attr == "__name" ) {
88 setName( Value.latin1() ); 116 setName( Value.latin1() );
89 } else { 117 } else {
90 setSpecificAttribute( Attr, Value ); 118 setSpecificAttribute( Attr, Value );
91 } 119 }
92} 120}
93 121
94void ANetNodeInstance::saveAttributes( QTextStream & TS ) { 122void ANetNodeInstance::saveAttributes( QTextStream & TS ) {
95 TS << "name=" << name() << endl; 123 TS << "__name=" << name() << endl;
96 saveSpecificAttribute( TS ); 124 saveSpecificAttribute( TS );
97} 125}
98 126
99ANetNodeInstance * ANetNodeInstance::nextNode( void ) { 127ANetNodeInstance * ANetNodeInstance::nextNode( void ) {
@@ -111,8 +139,9 @@ NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() {
111 Index = -1; 139 Index = -1;
112 Name=""; 140 Name="";
113 IsNew = 1; 141 IsNew = 1;
114 CurrentState = Unchecked; 142 CurrentState = Unchecked;
143 AssignedInterface = 0;
115} 144}
116 145
117NodeCollection::NodeCollection( QTextStream & TS ) : 146NodeCollection::NodeCollection( QTextStream & TS ) :
118 QList<ANetNodeInstance>() { 147 QList<ANetNodeInstance>() {
@@ -122,8 +151,9 @@ NodeCollection::NodeCollection( QTextStream & TS ) :
122 IsModified = 0; 151 IsModified = 0;
123 Index = -1; 152 Index = -1;
124 Name=""; 153 Name="";
125 IsNew = 0; 154 IsNew = 0;
155 AssignedInterface = 0;
126 CurrentState = Unchecked; 156 CurrentState = Unchecked;
127 157
128 do { 158 do {
129 S = TS.readLine(); 159 S = TS.readLine();
@@ -146,9 +176,8 @@ NodeCollection::NodeCollection( QTextStream & TS ) :
146 176
147 if( A == "name" ) { 177 if( A == "name" ) {
148 Name = N; 178 Name = N;
149 } else if( A == "number" ) { 179 } else if( A == "number" ) {
150 Log(( "Profile number %s\n", N.latin1() ));
151 setNumber( N.toLong() ); 180 setNumber( N.toLong() );
152 } else if( A == "node" ) { 181 } else if( A == "node" ) {
153 ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); 182 ANetNodeInstance * NNI = NSResources->findNodeInstance( N );
154 if( NNI && ! InError ) { 183 if( NNI && ! InError ) {
@@ -158,17 +187,20 @@ NodeCollection::NodeCollection( QTextStream & TS ) :
158 InError = 1; 187 InError = 1;
159 } 188 }
160 } 189 }
161 } while( 1 ); 190 } while( 1 );
191
192 Log(( "Profile number %s : %d nodes\n",
193 N.latin1(), count() ));
162} 194}
163 195
164 196
165NodeCollection::~NodeCollection( void ) { 197NodeCollection::~NodeCollection( void ) {
166} 198}
167 199
168const QString & NodeCollection::description( void ) { 200const QString & NodeCollection::description( void ) {
169 ANetNodeInstance * NNI = getToplevel(); 201 ANetNodeInstance * NNI = getToplevel();
170 return (NNI) ? NNI->runtime()->asFullSetup()->description() : Name; 202 return (NNI) ? NNI->runtime()->description() : Name;
171} 203}
172 204
173void NodeCollection::append( ANetNodeInstance * NNI ) { 205void NodeCollection::append( ANetNodeInstance * NNI ) {
174 NNI->setConnection( this ); 206 NNI->setConnection( this );
@@ -253,9 +285,10 @@ static char * State2PixmapTbl[] = {
253QPixmap NodeCollection::devicePixmap( void ) { 285QPixmap NodeCollection::devicePixmap( void ) {
254 QPixmap pm = NSResources->getPixmap( 286 QPixmap pm = NSResources->getPixmap(
255 getToplevel()->nextNode()->pixmapName()+"-large"); 287 getToplevel()->nextNode()->pixmapName()+"-large");
256 288
257 QPixmap Mini = NSResources->getPixmap( device()->netNode()->pixmapName() ); 289 QPixmap Mini = NSResources->getPixmap(
290 device()->netNode()->pixmapName() );
258 291
259 if( pm.isNull() || Mini.isNull() ) 292 if( pm.isNull() || Mini.isNull() )
260 return Resource::loadPixmap("Unknown"); 293 return Resource::loadPixmap("Unknown");
261 294
@@ -279,13 +312,13 @@ QString NodeCollection::stateName( State_t S) {
279 return qApp->translate( "networksettings2", "Unavailable"); 312 return qApp->translate( "networksettings2", "Unavailable");
280 case Disabled : 313 case Disabled :
281 return qApp->translate( "networksettings2", "Disabled"); 314 return qApp->translate( "networksettings2", "Disabled");
282 case Off : 315 case Off :
283 return qApp->translate( "networksettings2", "Off"); 316 return qApp->translate( "networksettings2", "Inactive");
284 case Available : 317 case Available :
285 return qApp->translate( "networksettings2", "Available"); 318 return qApp->translate( "networksettings2", "Available");
286 case IsUp : 319 case IsUp :
287 return qApp->translate( "networksettings2", "IsUp"); 320 return qApp->translate( "networksettings2", "Up");
288 case Unchecked : /* FT */ 321 case Unchecked : /* FT */
289 default : 322 default :
290 break; 323 break;
291 } 324 }
@@ -299,39 +332,180 @@ void NodeCollection::reassign( void ) {
299 it.current()->setConnection( this ); 332 it.current()->setConnection( this );
300 } 333 }
301} 334}
302 335
303bool NodeCollection::triggersVPN() { 336const QStringList & NodeCollection::triggers() {
304 return getToplevel()->runtime()->asFullSetup()->triggersVPN(); 337 return getToplevel()->runtime()->triggers();
305} 338}
306 339
307bool NodeCollection::hasDataForFile( const QString & S ) { 340bool NodeCollection::hasDataForFile( SystemFile & S ) {
308 return ( firstWithDataForFile( S ) != 0 ); 341 return ( firstWithDataForFile( S ) != 0 );
309} 342}
310 343
311ANetNodeInstance * NodeCollection::firstWithDataForFile( const QString & S ) { 344ANetNodeInstance * NodeCollection::firstWithDataForFile( SystemFile & S ) {
312 for( QListIterator<ANetNodeInstance> it(*this); 345 for( QListIterator<ANetNodeInstance> it(*this);
313 it.current(); 346 it.current();
314 ++it ) { 347 ++it ) {
315 if( it.current()->hasDataForFile( S ) ) { 348 if( it.current()->hasDataForFile( S ) ) {
316 Log(( "Node %s has data for %s\n",
317 it.current()->nodeClass()->name(),
318 S.latin1() ));
319 return it.current(); 349 return it.current();
320 } 350 }
321 } 351 }
322 return 0; 352 return 0;
323} 353}
324 354
355State_t NodeCollection::state( bool Update ) {
356 State_t NodeState;
357
358 if( CurrentState == Unchecked || Update ) {
359 // collect states of all nodes until with get the 'higest'
360 // state possible
361
362 Log(( "Connection %s state %s\n",
363 Name.latin1(), StateName[CurrentState] ));
364
365 CurrentState = Unknown;
366 for( QListIterator<ANetNodeInstance> it(*this);
367 it.current();
368 ++it ) {
369 Log(( "-> Detect %s\n", it.current()->name() ));
370 NodeState = it.current()->runtime()->detectState();
371 Log(( " state %s\n", StateName[NodeState] ));
372
373 if( NodeState == Disabled ||
374 NodeState == IsUp ) {
375 // max
376 CurrentState = NodeState;
377 break;
378 }
379
380 if( NodeState > CurrentState ) {
381 // higher
382 CurrentState = NodeState;
383 }
384 }
385 }
386
387 return CurrentState;
388}
389
390QString NodeCollection::setState( Action_t A, bool Force ) {
391
392 QString msg;
393 Action_t Actions[10];
394 int NoOfActions = 0;
395
396 // get current state
397 state( Force );
398
399 switch( A ) {
400 case Disable :
401 if( CurrentState < Disabled ) {
402 // disabled
403 CurrentState = Disabled;
404 return QString();
405 }
406
407 if( CurrentState == IsUp ) {
408 Actions[NoOfActions++] = Down;
409 Actions[NoOfActions++] = Deactivate;
410 } else if( CurrentState == Available ) {
411 Actions[NoOfActions++] = Deactivate;
412 }
413 Actions[NoOfActions++] = Disable;
414 break;
415 case Enable :
416 // always possible -> detected state is new state
417 Actions[NoOfActions++] = Enable;
418 break;
419 case Activate :
420 if( ! Force ) {
421 if( CurrentState >= Available ) {
422 // already available
423 return QString();
424 }
425
426 if( CurrentState != Off ) {
427 return qApp->translate( "System",
428 "State should be off" );
429 }
430 }
431
432 Actions[NoOfActions++] = Activate;
433 break;
434 case Deactivate :
435 if( ! Force ) {
436 if( CurrentState < Off ) {
437 // already inactive
438 return QString();
439 }
440 }
441
442 if( CurrentState == IsUp ) {
443 Actions[NoOfActions++] = Down;
444 }
445 Actions[NoOfActions++] = Deactivate;
446 break;
447 case Up :
448 if( ! Force ) {
449 if( CurrentState == IsUp ) {
450 return QString();
451 }
452 if( CurrentState < Off ) {
453 return qApp->translate( "System",
454 "State should at least be off" );
455 }
456 }
457 if( CurrentState == Off ) {
458 Actions[NoOfActions++] = Activate;
459 }
460 Actions[NoOfActions++] = Up;
461 break;
462 case Down :
463 if( ! Force ) {
464 if( CurrentState < Available ) {
465 // OK
466 return QString();
467 }
468 }
469 Actions[NoOfActions++] = Down;
470 break;
471 }
472
473 // send actions to all nodes
474 Log(( "Action %s requires %d steps\n",
475 ActionName[A], NoOfActions ));
476
477 for( int i = 0 ; i < NoOfActions; i ++ ) {
478 // setState recurses through the tree depth first
479 msg = getToplevel()->runtime()->setState( this, Actions[i], Force );
480 if( ! msg.isEmpty() ) {
481 return msg;
482 }
483 }
484 return QString();
485}
486
325// 487//
326// 488//
327// RUNTIMEINFO 489// RuntimeInfo
328// 490//
329// 491//
330 492
331InterfaceInfo * RuntimeInfo::assignedInterface( void ) { 493QString RuntimeInfo::setState( NodeCollection * NC,
332 return netNode()->nextNode()->runtime()->assignedInterface(); 494 Action_t A,
333} 495 bool Force ) {
496 QString M;
497 RuntimeInfo * Deeper = nextNode();
498
499 if( Deeper ) {
500 // first go deeper
501 M = Deeper->setState( NC, A, Force );
502 if( ! M.isEmpty() )
503 return M;
504 }
334 505
335AsDevice * RuntimeInfo::device( void ) { 506 // set my own state
336 return netNode()->nextNode()->runtime()->device(); 507 Log (( "-> Act upon %s\n", netNode()->name() ));
508 M = setMyState( NC, A, Force );
509 Log (( " result %s\n", M.latin1() ));
510 return M;
337} 511}
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h
index d3d7b34..4626381 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.h
+++ b/noncore/settings/networksettings2/networksettings2/netnode.h
@@ -9,8 +9,9 @@
9#include <qobject.h> 9#include <qobject.h>
10#include <time.h> 10#include <time.h>
11 11
12#include <Utils.h> 12#include <Utils.h>
13#include <system.h>
13 14
14// difference feature interfaces 15// difference feature interfaces
15class AsDevice; 16class AsDevice;
16class AsLine; 17class AsLine;
@@ -25,8 +26,9 @@ class ANetNodeInstance;
25class NodeCollection; 26class NodeCollection;
26class QTextStream; 27class QTextStream;
27class RuntimeInfo; 28class RuntimeInfo;
28class InterfaceInfo; 29class InterfaceInfo;
30class NSResources;
29 31
30extern QString & deQuote( QString & X ); 32extern QString & deQuote( QString & X );
31extern QString quote( QString X ); 33extern QString quote( QString X );
32 34
@@ -54,23 +56,23 @@ typedef enum State {
54 IsUp = 6 56 IsUp = 6
55} State_t; 57} State_t;
56 58
57typedef enum Action { 59typedef enum Action {
58 // to make the device unavailable functionally 60 // to make the device unavailable functionally -> to disabled
59 Disable = 0, 61 Disable = 0,
60 // to make the device available functionally 62 // to make the device available functionally -> to off
61 Enable = 1, 63 Enable = 1,
62 // bring the hardware up 64 // bring the hardware up -> to Available
63 Activate = 2, 65 Activate = 2,
64 // bring the hardware down 66 // bring the hardware down -> to off
65 Deactivate = 3, 67 Deactivate = 3,
66 // bring the connection up 68 // bring the connection up -> to IsUp
67 Up = 4, 69 Up = 4,
68 // bring the connection down 70 // bring the connection down -> to Available
69 Down = 5 71 Down = 5
70} Action_t; 72} Action_t;
71 73
72class ANetNode : public QObject{ 74class ANetNode : public QObject {
73 75
74public: 76public:
75 77
76 typedef QArray<ANetNode *> NetNodeList; 78 typedef QArray<ANetNode *> NetNodeList;
@@ -89,10 +91,9 @@ public:
89 inline void setDone( int D ) 91 inline void setDone( int D )
90 { Done = D; } 92 { Done = D; }
91 93
92 // does this Node provide a Connection 94 // does this Node provide a Connection
93 inline bool isToplevel( void ) 95 bool isToplevel( void );
94 { return strcmp( provides(), "fullsetup") == 0 ; }
95 96
96 // set the value of an attribute 97 // set the value of an attribute
97 void setAttribute( QString & Attr, QString & Value ) ; 98 void setAttribute( QString & Attr, QString & Value ) ;
98 void saveAttributes( QTextStream & TS ) ; 99 void saveAttributes( QTextStream & TS ) ;
@@ -109,29 +110,40 @@ public:
109 // 110 //
110 // 111 //
111 112
112 // do instances of this noce class have data for this file 113 // do instances of this noce class have data for this file
113 virtual bool hasDataForFile( const QString & ) 114 virtual bool hasDataForFile( SystemFile & )
114 { return 0; } 115 { return 0; }
115 116
117 // open proper file SF identified by S
118 // this method is called by NS2.
119 //
120 // overrule this ONLY if this proper file is a common file
121 // for all NNI of this node class and the data generated
122 // by each of the NNI needs to be put in one file
123 //
124 // if this is the case the file should be (re)opened in append
125 // return 0 if file cannot be opened
126 virtual bool openFile( SystemFile &SF,
127 ANetNodeInstance * NNI );
128
116 // generate instance independent stuff 129 // generate instance independent stuff
117 // 0 : data output, 1 no data, 2 error 130 // 0 : data output, 1 no data, 2 error
118 virtual short generateFile( const QString & , 131 virtual short generatePreamble( SystemFile & )
119 const QString & , 132 { return 1; }
120 QTextStream & , 133
121 long ) 134 // generate instance independent stuff
135 // 0 : data output, 1 no data, 2 error
136 virtual short generatePostamble( SystemFile & )
122 { return 1; } 137 { return 1; }
123 138
124 // generate instance dependent but profile common stuff 139 // generate instance dependent but instance common stuff
125 // 0 : data output, 1 no data, 2 error 140 // 0 : data output, 1 no data, 2 error
126 virtual short generateFile( const QString & , 141 virtual short generateFile( SystemFile &,
127 const QString & ,
128 QTextStream & ,
129 ANetNodeInstance * , 142 ANetNodeInstance * ,
130 long ) 143 long )
131 { return 1; } 144 { return 1; }
132 145
133
134 // generate NIC name based on instance nr 146 // generate NIC name based on instance nr
135 // only relevant if node instances are devices 147 // only relevant if node instances are devices
136 virtual QString genNic( long ) 148 virtual QString genNic( long )
137 { return QString(""); } 149 { return QString(""); }
@@ -140,11 +152,12 @@ public:
140 // only relevant if node instances are devices 152 // only relevant if node instances are devices
141 virtual long instanceCount( void ) 153 virtual long instanceCount( void )
142 { return 1; } 154 { return 1; }
143 155
144 // return list of files that are specific for this node class 156 // return ID list for each file generated specially for
145 virtual QStringList * properFiles( void ) 157 // this node type
146 { return 0; } 158 virtual QStringList properFiles( void )
159 { return QStringList(); }
147 160
148 // 161 //
149 // 162 //
150 // pure virtual methods with sensible default 163 // pure virtual methods with sensible default
@@ -159,10 +172,12 @@ public:
159 172
160 // create a blank instance of a net node 173 // create a blank instance of a net node
161 virtual ANetNodeInstance * createInstance( void ) = 0; 174 virtual ANetNodeInstance * createInstance( void ) = 0;
162 175
163 // return feature this NetNode provides 176 // return features this NetNode provides
164 virtual const char * provides( void ) = 0; 177 virtual const char ** provides( void ) = 0;
178
179 // return features this NetNode needs
165 virtual const char ** needs( void ) = 0; 180 virtual const char ** needs( void ) = 0;
166 181
167protected : 182protected :
168 183
@@ -223,9 +238,9 @@ public:
223 // pixmap for this instance -> from NetNode 238 // pixmap for this instance -> from NetNode
224 inline const QString pixmapName( void ) 239 inline const QString pixmapName( void )
225 { return NodeType->pixmapName(); } 240 { return NodeType->pixmapName(); }
226 241
227 inline const char * provides( void ) 242 inline const char ** provides( void )
228 { return NodeType->provides(); } 243 { return NodeType->provides(); }
229 244
230 inline const char ** needs( void ) 245 inline const char ** needs( void )
231 { return NodeType->needs(); } 246 { return NodeType->needs(); }
@@ -243,34 +258,30 @@ public:
243 258
244 259
245 260
246 // open proper file identified by S 261 // open proper file identified by S
247 virtual QFile * openFile( const QString & ) 262 virtual bool openFile( SystemFile & )
248 { return 0; } 263 { return 0; }
249 264
250 // check if this node (or sub nodes) have data for this file 265 // check if this node (or sub nodes) have data for this file
251 virtual bool hasDataForFile( const QString & S ) 266 virtual bool hasDataForFile( SystemFile & S )
252 { return nodeClass()->hasDataForFile( S ); } 267 { return nodeClass()->hasDataForFile( S ); }
253 268
254 // generate code specific for this node but embedded 269 // generate code specific for this node but embedded
255 // in the section of the parent 270 // in the section of the parent
256 // this is called within the code of the parent 271 // this is called within the code of the parent
257 virtual short generateFileEmbedded( const QString & ID, 272 virtual short generateFileEmbedded( SystemFile & SF,
258 const QString & Path,
259 QTextStream & TS,
260 long DevNr ) 273 long DevNr )
261 { ANetNodeInstance * NNI = nextNode(); 274 { ANetNodeInstance * NNI = nextNode();
262 return (NNI) ? NNI->generateFileEmbedded( ID, Path, TS, DevNr ) : 1; 275 return (NNI) ? NNI->generateFileEmbedded( SF, DevNr ) : 1;
263 } 276 }
264 277
265 // generate code specific for this node 278 // generate code specific for this node
266 // (or find the first node that does) 279 // (or find the first node that does)
267 virtual short generateFile( const QString & ID, 280 virtual short generateFile( SystemFile & SF,
268 const QString & Path,
269 QTextStream & TS,
270 long DevNr ) 281 long DevNr )
271 { ANetNodeInstance * NNI = nextNode(); 282 { ANetNodeInstance * NNI = nextNode();
272 return (NNI) ? NNI->generateFile( ID, Path, TS, DevNr ) : 1; 283 return (NNI) ? NNI->generateFile( SF, DevNr ) : 1;
273 } 284 }
274 285
275 // return true if this node instance is triggered by this trigger 286 // return true if this node instance is triggered by this trigger
276 // could be delegated to deeper instances 287 // could be delegated to deeper instances
@@ -322,43 +333,133 @@ public :
322 333
323 RuntimeInfo( ANetNodeInstance * TheNNI ) 334 RuntimeInfo( ANetNodeInstance * TheNNI )
324 { NNI = TheNNI; } 335 { NNI = TheNNI; }
325 336
326 // downcast implemented by specify runtime classes 337 //
327 virtual AsDevice * asDevice( void ) 338 //
328 { return 0; } 339 // methods to be overloaded by connection capable
329 virtual AsConnection * asConnection( void ) 340 // runtimes
330 { return 0; } 341 //
331 virtual AsLine * asLine( void ) 342 //
332 { return 0; } 343
333 virtual AsFullSetup * asFullSetup( void ) 344
334 { return 0; } 345 //
346 //
347 // methods to be overloaded by device capable
348 // runtimes
349 //
350 //
335 351
336 // does this node handles this interface e.g.eth0 352 // does this node handles this interface e.g.eth0
337 // recurse deeper if this node cannot answer that question 353 // recurse deeper if this node cannot answer that question
338 virtual bool handlesInterface( const QString & ) 354 virtual bool handlesInterface( const QString & S ) {
339 { return 0; } 355 RuntimeInfo * RI = device();
340 virtual bool handlesInterface( const InterfaceInfo & ) 356 if( RI ) {
341 { return 0; } 357 return RI->handlesInterface( S );
342 virtual InterfaceInfo * assignedInterface( void ); 358 }
343 virtual AsDevice * device( void ); 359 return 0;
344 360 }
345 ANetNodeInstance * netNode() 361 bool handlesInterface( const InterfaceInfo & I ) {
362 RuntimeInfo * RI = device();
363 if( RI ) {
364 return RI->handlesInterface( I );
365 }
366 return 0;
367 }
368
369 //
370 //
371 // methods to be overloaded by full setup capable
372 // runtimes
373 //
374 //
375
376 // return description for this full setup
377 virtual const QString & description( void ) {
378 return fullSetup()->description( );
379 }
380 // return triggers that should fire when this
381 // setup is brought up
382 virtual const QStringList & triggers( void ) {
383 return fullSetup()->triggers( );
384 }
385
386 //
387 //
388 // methods to be overloaded by line capable
389 // runtimes
390 //
391 //
392
393 // return the device file ('/dev/xxx') created
394 // by this line capable runtime
395 virtual QString deviceFile( void ) {
396 RuntimeInfo * RI = line();
397 if( RI ) {
398 return RI->deviceFile();
399 }
400 return QString();
401 }
402
403 //
404 //
405 // runtime interface
406 //
407 //
408
409 // return the node that offers device capability
410 virtual RuntimeInfo * device( void )
411 { RuntimeInfo * RI = nextNode();
412 return (RI) ? RI->device() : 0;
413 }
414
415 // return the node that offers connection capability
416 virtual RuntimeInfo * connection( void )
417 { RuntimeInfo * RI = nextNode();
418 return (RI) ? RI->connection() : 0;
419 }
420
421 // return the node that offers line capability
422 virtual RuntimeInfo * line( void )
423 { RuntimeInfo * RI = nextNode();
424 return (RI) ? RI->line() : 0;
425 }
426
427 // return the node that offers full setup capability
428 virtual RuntimeInfo * fullSetup( void )
429 { RuntimeInfo * RI = nextNode();
430 return (RI) ? RI->fullSetup() : 0;
431 }
432
433 inline ANetNodeInstance * netNode()
346 { return NNI; } 434 { return NNI; }
347 NodeCollection * connection() 435
436 inline NodeCollection * nodeCollection()
348 { return NNI->connection(); } 437 { return NNI->connection(); }
349 438
350 virtual void detectState( NodeCollection * NC ) = 0; 439 virtual State_t detectState( void ) = 0;
351 virtual bool setState( NodeCollection * NC, Action_t A, bool Force = 0 ) = 0; 440 // public API to set the state
352 virtual bool canSetState( State_t Curr, Action_t A ) = 0; 441 virtual QString setState( NodeCollection * NC,
442 Action_t A,
443 bool Force = 0 );
444
445 inline RuntimeInfo * nextNode( void ) {
446 ANetNodeInstance * NNI = netNode()->nextNode();
447 return (NNI) ? NNI->runtime() : 0;
448 }
353 449
354signals : 450signals :
355 451
356 // sent by device if state changes 452 // sent by device if state changes
357 void stateChanged( State_t S, ANetNodeInstance * NNI ); 453 void stateChanged( State_t S, ANetNodeInstance * NNI );
358 454
359protected : 455protected :
360 456
457 // set state of this node (private API)
458 virtual QString setMyState( NodeCollection * NC,
459 Action_t A,
460 bool Force = 0 ) = 0;
461
361 // connection this runtime info belongs to 462 // connection this runtime info belongs to
362 ANetNodeInstance * NNI; 463 ANetNodeInstance * NNI;
363}; 464};
364 465
@@ -391,30 +492,34 @@ public :
391 inline bool handlesInterface( const QString & S ) { 492 inline bool handlesInterface( const QString & S ) {
392 return getToplevel()->runtime()->handlesInterface( S ); 493 return getToplevel()->runtime()->handlesInterface( S );
393 } 494 }
394 495
496 // return the interface in the OS that is assigned to
497 // this device
395 inline InterfaceInfo * assignedInterface( void ) { 498 inline InterfaceInfo * assignedInterface( void ) {
396 return getToplevel()->runtime()->assignedInterface(); 499 return AssignedInterface;
397 } 500 }
398 501
399 inline AsDevice * device() { 502 // assign the interface to this device
503 inline void assignInterface( InterfaceInfo * NI ) {
504 if( NI == 0 ) {
505 if( AssignedInterface ) {
506 AssignedInterface->assignConnection( 0 );
507 }
508 }
509 AssignedInterface = NI;
510 if( AssignedInterface ) {
511 AssignedInterface->assignConnection( this );
512 }
513 }
514
515 inline RuntimeInfo * device() {
400 return getToplevel()->runtime()->device(); 516 return getToplevel()->runtime()->device();
401 } 517 }
402 518
403 bool triggersVPN(); 519 const QStringList & triggers();
404 520
405 inline State_t state( bool Update = 0 ) 521 State_t state( bool Update = 0 );
406 { Log(( "%s state %d(=%d?)\n", Name.latin1(), CurrentState,
407 Unchecked ));
408 if( CurrentState == Unchecked || Update ) {
409 Log(( "TL %p TLR %p\n",
410 getToplevel(),
411 getToplevel()->runtime() ));
412 // need to get current state
413 getToplevel()->runtime()->detectState( this );
414 }
415 return CurrentState;
416 }
417 522
418 // get the ixmap for this device 523 // get the ixmap for this device
419 QPixmap devicePixmap( void ); 524 QPixmap devicePixmap( void );
420 QPixmap statePixmap( State_t S ); 525 QPixmap statePixmap( State_t S );
@@ -423,12 +528,9 @@ public :
423 QString stateName( State_t ); 528 QString stateName( State_t );
424 inline QString stateName( bool Update = 0 ) 529 inline QString stateName( bool Update = 0 )
425 { return stateName( state(Update) ); } 530 { return stateName( state(Update) ); }
426 531
427 inline bool setState( Action_t A, bool Force =0 ) 532 QString setState( Action_t A, bool Force = 0 );
428 { return getToplevel()->runtime()->setState( this, A, Force ); }
429 inline bool canSetState( Action_t A )
430 { return getToplevel()->runtime()->canSetState( CurrentState, A ); }
431 533
432 void save( QTextStream & TS ); 534 void save( QTextStream & TS );
433 535
434 void append( ANetNodeInstance * NNI ); 536 void append( ANetNodeInstance * NNI );
@@ -455,18 +557,16 @@ public :
455 { CurrentState = S; } 557 { CurrentState = S; }
456 558
457 // return TRUE if this node can have data to be inserted in 559 // return TRUE if this node can have data to be inserted in
458 // file identified by S 560 // file identified by S
459 bool hasDataForFile( const QString & S ); 561 bool hasDataForFile( SystemFile & S );
460 ANetNodeInstance * firstWithDataForFile( const QString & S ); 562 ANetNodeInstance * firstWithDataForFile( SystemFile & );
461 563
462 // generate items for this file -> toplevel call 564 // generate items for this file -> toplevel call
463 short generateFile( const QString & FID, // identification of file 565 short generateFile( SystemFile & SF,
464 const QString & FName, // effective filename of file
465 QTextStream & TS, // stream to file
466 long DN // device number 566 long DN // device number
467 ) 567 )
468 { return getToplevel()->generateFile( FID, FName, TS, DN ); } 568 { return getToplevel()->generateFile( SF, DN ); }
469 569
470 bool triggeredBy( const QString & Trigger ) 570 bool triggeredBy( const QString & Trigger )
471 { return getToplevel()->triggeredBy( Trigger ); } 571 { return getToplevel()->triggeredBy( Trigger ); }
472 572
@@ -488,7 +588,9 @@ private :
488 int Index; 588 int Index;
489 bool IsModified; 589 bool IsModified;
490 int Done; 590 int Done;
491 591
592 InterfaceInfo * AssignedInterface;
593
492}; 594};
493 595
494#endif 596#endif
diff --git a/noncore/settings/networksettings2/networksettings2/networksettings2.pro b/noncore/settings/networksettings2/networksettings2/networksettings2.pro
index d1e42b7..f2ba9df 100644
--- a/noncore/settings/networksettings2/networksettings2/networksettings2.pro
+++ b/noncore/settings/networksettings2/networksettings2/networksettings2.pro
@@ -4,15 +4,11 @@ CONFIG += qt warn_on release
4 DESTDIR = $(OPIEDIR)/lib$(PROJMAK) 4 DESTDIR = $(OPIEDIR)/lib$(PROJMAK)
5 HEADERS = netnode.h \ 5 HEADERS = netnode.h \
6 resources.h \ 6 resources.h \
7 system.h \ 7 system.h \
8 asline.h \
9 GUIUtils.h \ 8 GUIUtils.h \
10 asconnection.h \
11 asfullsetup.h \
12 systemfile.h \ 9 systemfile.h \
13 wextensions.h \ 10 wextensions.h
14 asdevice.h
15 SOURCES = netnode.cpp \ 11 SOURCES = netnode.cpp \
16 GUIUtils.cpp \ 12 GUIUtils.cpp \
17 system.cpp \ 13 system.cpp \
18 systemfile.cpp \ 14 systemfile.cpp \
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp
index 2f17693..8b3b4fe 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.cpp
+++ b/noncore/settings/networksettings2/networksettings2/resources.cpp
@@ -44,41 +44,40 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
44 if( InnerIt.current() == OuterIt.current() ) 44 if( InnerIt.current() == OuterIt.current() )
45 // avoid recursive 45 // avoid recursive
46 continue; 46 continue;
47 47
48 const char * Provides = InnerIt.current()->NetNode->provides(); 48 const char ** Provides = InnerIt.current()->NetNode->provides();
49 NeedsRun = OuterIt.current()->NetNode->needs(); 49 NeedsRun = OuterIt.current()->NetNode->needs();
50
50 for( ; *NeedsRun; NeedsRun ++ ) { 51 for( ; *NeedsRun; NeedsRun ++ ) {
51 if( strcmp( Provides, *NeedsRun ) == 0 ) { 52 const char ** PRun;
52 // inner provides what outer needs 53 PRun = Provides;
53 NNL.resize( NNL.size() + 1 ); 54 for( ; *PRun; PRun ++ ) {
54 NNL[NNL.size()-1] = InnerIt.current()->NetNode; 55 if( strcmp( *PRun, *NeedsRun ) == 0 ) {
55 Done = 1; // break from 2 loops 56 // inner provides what outer needs
56 break; 57 NNL.resize( NNL.size() + 1 );
58 NNL[NNL.size()-1] = InnerIt.current()->NetNode;
59 Done = 1; // break from 2 loops
60 break;
61 }
57 } 62 }
58 } 63 }
59 } 64 }
60 OuterIt.current()->NetNode->setAlternatives( NNLP ); 65 OuterIt.current()->NetNode->setAlternatives( NNLP );
61 } 66 }
62 } 67 }
63 68
64 // define Node types to Description map 69 // define built in Node types to Description map
65 NodeTypeNameMap.insert( "device", tr( "Network Device" ) ); 70 addNodeType( "device", tr( "Network Device" ),
66 NodeTypeNameMap.insert( "line", tr( "Character device" ) ); 71 tr( "<p>Devices that can handle IP packets</p>" ) );
67 NodeTypeNameMap.insert( "connection", tr( "IP Connection" ) ); 72 addNodeType( "line", tr( "Character device" ),
68 NodeTypeNameMap.insert( "fullsetup", tr( "Connection Profile" ) ); 73 tr( "<p>Devices that can handle single bytes</p>" ) );
69 74 addNodeType( "connection", tr( "IP Connection" ),
70 NodeTypeDescriptionMap.insert( "device", 75 tr( "<p>Nodes that provide working IP connections</p>" ) );
71 tr( "<p>Devices that can handle IP packets</p>" ) ); 76 addNodeType( "fullsetup", tr( "Connection Profile" ),
72 NodeTypeDescriptionMap.insert( "line", 77 tr( "<p>Fully configured connection profile</p>" ) );
73 tr( "<p>Devices that can handle single bytes</p>" ) ); 78 addNodeType( "GPRS", tr( "Connection to GPRS device" ),
74 NodeTypeDescriptionMap.insert( "connection", 79 tr( "<p>Connection to a GPRS capable device</p>" ) );
75 tr( "<p>Nodes that provide working IP connections</p>" ) );
76 NodeTypeDescriptionMap.insert( "fullsetup",
77 tr( "<p>Fully configured connection profile</p>" ) );
78
79 // define system files
80 addSystemFile( "interfaces", "/tmp/interfaces", 1 );
81 80
82 // get access to the system 81 // get access to the system
83 TheSystem = new System(); 82 TheSystem = new System();
84 83
@@ -87,8 +86,17 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
87TheNSResources::~TheNSResources( void ) { 86TheNSResources::~TheNSResources( void ) {
88 delete TheSystem; 87 delete TheSystem;
89} 88}
90 89
90void TheNSResources::addNodeType( const QString & ID,
91 const QString & Name,
92 const QString & Descr ) {
93 if( NodeTypeNameMap[ID].isEmpty() ) {
94 NodeTypeNameMap.insert( ID, Name );
95 NodeTypeDescriptionMap.insert( ID, Descr );
96 }
97}
98
91void TheNSResources::addSystemFile( const QString & ID, 99void TheNSResources::addSystemFile( const QString & ID,
92 const QString & P, 100 const QString & P,
93 bool KDI ) { 101 bool KDI ) {
94 if( ! SystemFiles.find( ID ) ) { 102 if( ! SystemFiles.find( ID ) ) {
@@ -219,10 +227,12 @@ bool TheNSResources::loadNetNode(
219QPixmap TheNSResources::getPixmap( const QString & QS ) { 227QPixmap TheNSResources::getPixmap( const QString & QS ) {
220 QPixmap P; 228 QPixmap P;
221 QString S("networksettings2/"); 229 QString S("networksettings2/");
222 S += QS; 230 S += QS;
223 Log(("%s\n", S.latin1() ));
224 P = Resource::loadPixmap( S ); 231 P = Resource::loadPixmap( S );
232 if( P.isNull() ) {
233 Log(( "Cannot load %s\n", S.latin1() ));
234 }
225 return ( P.isNull() ) ? QPixmap() : P; 235 return ( P.isNull() ) ? QPixmap() : P;
226} 236}
227 237
228QString TheNSResources::tr( const char * s ) { 238QString TheNSResources::tr( const char * s ) {
@@ -268,8 +278,18 @@ void TheNSResources::removeConnection( const QString & N ) {
268NodeCollection * TheNSResources::findConnection( const QString & S ) { 278NodeCollection * TheNSResources::findConnection( const QString & S ) {
269 return ConnectionsMap[ S ]; 279 return ConnectionsMap[ S ];
270} 280}
271 281
282NodeCollection * TheNSResources::getConnection( int nr ) {
283 for( QDictIterator<NodeCollection> it(ConnectionsMap);
284 it.current();
285 ++it ) {
286 if( it.current()->number() == nr ) {
287 return it.current();
288 }
289 }
290 return 0;
291}
272/* 292/*
273void TheNSResources::renumberConnections( void ) { 293void TheNSResources::renumberConnections( void ) {
274 Name2Connection_t & M = NSResources->connections(); 294 Name2Connection_t & M = NSResources->connections();
275 NodeCollection * NC; 295 NodeCollection * NC;
diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h
index 23b120e..634cd39 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.h
+++ b/noncore/settings/networksettings2/networksettings2/resources.h
@@ -66,8 +66,13 @@ public :
66 { NetNode_t * NNT = AllNodeTypes.find(N); 66 { NetNode_t * NNT = AllNodeTypes.find(N);
67 return (NNT) ? NNT->NetNode : 0; 67 return (NNT) ? NNT->NetNode : 0;
68 } 68 }
69 69
70 // define new plugin (=node)
71 void addNodeType( const QString & ID,
72 const QString & LongName,
73 const QString & Description );
74
70 Name2SystemFile_t & systemFiles( void ) 75 Name2SystemFile_t & systemFiles( void )
71 { return SystemFiles; } 76 { return SystemFiles; }
72 void addSystemFile( const QString & ID, 77 void addSystemFile( const QString & ID,
73 const QString & P, 78 const QString & P,
@@ -98,8 +103,9 @@ public :
98 103
99 void addConnection( NodeCollection * NC ); 104 void addConnection( NodeCollection * NC );
100 void removeConnection( const QString & N ); 105 void removeConnection( const QString & N );
101 NodeCollection * findConnection( const QString & N ); 106 NodeCollection * findConnection( const QString & N );
107 NodeCollection * getConnection( int nr );
102 Name2Connection_t & connections( void ) 108 Name2Connection_t & connections( void )
103 { return ConnectionsMap; } 109 { return ConnectionsMap; }
104 110
105 inline bool userKnown( void ) 111 inline bool userKnown( void )
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp
index 298bdc9..141484c 100644
--- a/noncore/settings/networksettings2/networksettings2/system.cpp
+++ b/noncore/settings/networksettings2/networksettings2/system.cpp
@@ -12,8 +12,10 @@
12#include <fcntl.h> 12#include <fcntl.h>
13#include <errno.h> 13#include <errno.h>
14#include <unistd.h> 14#include <unistd.h>
15 15
16#include <opie2/oprocess.h>
17
16#include <qdir.h> 18#include <qdir.h>
17#include <qregexp.h> 19#include <qregexp.h>
18#include <qstringlist.h> 20#include <qstringlist.h>
19#include <qfile.h> 21#include <qfile.h>
@@ -49,65 +51,120 @@ System::~System( void ) {
49 if( ProcDevNet ) 51 if( ProcDevNet )
50 delete ProcDevNet; 52 delete ProcDevNet;
51} 53}
52 54
53int System::runAsRoot( const QString & S ) { 55int System::runAsRoot( QStringList & S ) {
54 QString MyS = S;
55 char * usr = getenv("USER"); 56 char * usr = getenv("USER");
56 char ch;
57 57
58 if( S.isEmpty() ) { 58 if( S.count() == 0 ) {
59 // loophole to start shell 59 // loophole to start shell
60 return 8888; 60 return 8888;
61 } 61 }
62 if( usr == 0 || strcmp( usr, "root" ) ) { 62 if( usr == 0 || strcmp( usr, "root" ) ) {
63 // unknown or non-root user -> use SUDO 63 // unknown or non-root user -> use SUDO
64 MyS.prepend( "sudo " ); 64 S.prepend( "sudo" );
65 } 65 }
66 66
67 Log(("Executing %s\n", MyS.latin1() )); 67 if( getenv( "NS2TESTMODE" ) ) {
68 68 owarn << "TESTMODE !!! execute "
69 emit lineFromCommand( tr("Command : ") + MyS ); 69 << S.join( " ")
70 emit lineFromCommand( "---------------" ); 70 << oendl;
71 Log(( "Command : %s\n", MyS.latin1() ) ); 71 } else {
72 MyS += " 2>&1 "; 72 MyProcess * P = new MyProcess();
73 OutputOfCmd = popen( MyS.latin1(), "r" ) ; 73 emit processEvent( tr("Command : ") + S.join( " " ) );
74 if( ! OutputOfCmd ) { 74
75 // cannot fork 75 P->process() << S;
76 return 1; 76
77 connect( P,
78 SIGNAL( stdoutLine( const QString & ) ),
79 this,
80 SIGNAL( stdoutLine( const QString & ) ) );
81
82 connect( P,
83 SIGNAL( stderrLine( const QString & ) ),
84 this,
85 SIGNAL( stderrLine( const QString & ) ) );
86
87 connect( P,
88 SIGNAL(processExited(MyProcess*) ),
89 this, SLOT
90 (SLOT_ProcessExited(MyProcess*) ) );
91
92 Log(("Executing %s\n", S.join( " " ).latin1() ));
93
94 if( ! P->process().start( OProcess::DontCare,
95 OProcess::AllOutput ) ) {
96 owarn << "Error starting " << S << oendl;
97 delete P;
98 // error starting app
99 return 1;
100 }
101 owarn << "Started " << S << oendl;
77 } 102 }
78 103
79 // read all data 104 // all is fine
80 QString Line = ""; 105 return 0;
81 while( 1 ) { 106}
82 if( fread( &ch, 1, 1, OutputOfCmd ) < 1 ) 107
83 // eof 108int System::execAsUser( QStringList & SL ) {
84 break; 109 MyProcess * P = new MyProcess();
85 if( ch == '\n' || ch == '\r' ) { 110 CurrentQPEUser CU = NSResources->currentUser();
86 if( ! Line.isEmpty() ) { 111 char * usr = getenv("USER");
87 Log(( "read cmd output : **%s**\n", Line.latin1() ) ); 112
88 emit lineFromCommand( Line ); 113 if( strcmp( usr, "root" ) == 0 ) {
89 Line = ""; 114 // find user running qpe
90 qApp->processEvents(); 115 if( CU.UserName.isEmpty() ) {
116 // if we come here, the exec was not successfull
117 Log(("User not known \n" ));
118 return 0;
91 } 119 }
92 } else {
93 Line += ch;
94 } 120 }
95 }
96 121
97 if( ! Line.isEmpty() ) { 122 // now we are ready to exec the requested command
98 emit lineFromCommand( Line ); 123 setuid( CU.Uid );
99 Log(( "read cmd output : **%s**\n", Line.latin1() ) ); 124 setgid( CU.Gid );
100 }
101 Log(( "End of command\n", Line.latin1() ) );
102 125
103 if( pclose( OutputOfCmd ) < 0 ) { 126 for( unsigned int i = 0 ; i < CU.EnvList.count() ; i ++ ) {
104 // error in command 127 QString X;
105 return 3; 128 QStringList SL;
106 } 129 X = CU.EnvList[i];
130 SL = QStringList::split( "=", X );
131 P->process().setEnvironment( SL[0], SL[1] );
132 }
107 133
108 // all is fine 134 P->process() << SL;
109 return 0; 135
136 emit processEvent( tr("Command : ") + SL.join( " " ) );
137
138 Log(("Executing as user %s : %s\n",
139 CU.UserName.latin1(),
140 SL.join( " " ).latin1() ));
141
142 int rv = ( P->process().start( OProcess::DontCare,
143 OProcess::NoCommunication ) );
144 delete P;
145
146 if( rv ) {
147 // if we come here, the exec was not successfull
148 Log(("Could not exec : %d\n", errno ));
149 }
150
151 return rv;
152}
153
154void System::SLOT_ProcessExited( MyProcess * P ) {
155 QString R;
156
157 for( QValueListConstIterator<QCString> it = P->process().args().begin();
158 it != P->process().args().end();
159 ++it ) {
160 R += (*it);
161 R += " ";
162 }
163
164 R += "Returned with " + QString().setNum( P->process().exitStatus() );
165 emit processEvent( R );
166 delete P;
110} 167}
111 168
112void System::refreshStatistics( InterfaceInfo & I ) { 169void System::refreshStatistics( InterfaceInfo & I ) {
113 if( ! ProcDevNet ) { 170 if( ! ProcDevNet ) {
@@ -197,17 +254,31 @@ void System::probeInterfaces( void ) {
197 it.current()->IsUp = 0; 254 it.current()->IsUp = 0;
198 } 255 }
199 256
200 sockfd = socket(PF_INET, SOCK_DGRAM, 0); 257 sockfd = socket(PF_INET, SOCK_DGRAM, 0);
201 if(sockfd == -1) 258 if(sockfd == -1) {
259 owarn << "Cannot open INET socket "
260 << errno
261 << " "
262 << strerror( errno )
263 << oendl;
202 return; 264 return;
265 }
203 266
204 // read interfaces from /proc/dev/net 267 // read interfaces from /proc/dev/net
205 // SIOCGIFCONF does not return ALL interfaces ???!? 268 // SIOCGIFCONF does not return ALL interfaces ???!?
206 ProcDevNet = new QFile(PROCNETDEV); 269 ProcDevNet = new QFile(PROCNETDEV);
207 if( ! ProcDevNet->open(IO_ReadOnly) ) { 270 if( ! ProcDevNet->open(IO_ReadOnly) ) {
271 owarn << "Cannot open "
272 << PROCNETDEV
273 << " "
274 << errno
275 << " "
276 << strerror( errno )
277 << oendl;
208 delete ProcDevNet; 278 delete ProcDevNet;
209 ProcDevNet =0; 279 ProcDevNet =0;
280 ::close( sockfd );
210 return; 281 return;
211 } 282 }
212 283
213 QString line; 284 QString line;
@@ -228,12 +299,12 @@ void System::probeInterfaces( void ) {
228 strcpy( ifrs.ifr_name, NicName.latin1() ); 299 strcpy( ifrs.ifr_name, NicName.latin1() );
229 300
230 if ( ! ( IFI = ProbedInterfaces.find( NicName ) ) ) { 301 if ( ! ( IFI = ProbedInterfaces.find( NicName ) ) ) {
231 // new nic 302 // new nic
232 Log(("NEWNIC %s\n", NicName.latin1())); 303 Log(("New NIC found : %s\n", NicName.latin1()));
233 IFI = new InterfaceInfo; 304 IFI = new InterfaceInfo;
234 IFI->Name = line.left(loc); 305 IFI->Name = line.left(loc);
235 IFI->NetNode = 0; 306 IFI->Collection = 0;
236 ProbedInterfaces.insert( IFI->Name, IFI ); 307 ProbedInterfaces.insert( IFI->Name, IFI );
237 308
238 // get dynamic info 309 // get dynamic info
239 if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) { 310 if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) {
@@ -255,9 +326,9 @@ void System::probeInterfaces( void ) {
255 IFI->CardType = 999999; 326 IFI->CardType = 999999;
256 IFI->MACAddress = ""; 327 IFI->MACAddress = "";
257 328
258 if( ioctl(sockfd, SIOCGIFHWADDR, &ifrs) >= 0 ) { 329 if( ioctl(sockfd, SIOCGIFHWADDR, &ifrs) >= 0 ) {
259 Log(("%s = %d\n", IFI->Name.latin1(), 330 Log(("Family for NIC %s : %d\n", IFI->Name.latin1(),
260 ifrs.ifr_hwaddr.sa_family )); 331 ifrs.ifr_hwaddr.sa_family ));
261 332
262 IFI->CardType = ifrs.ifr_hwaddr.sa_family; 333 IFI->CardType = ifrs.ifr_hwaddr.sa_family;
263 switch( ifrs.ifr_hwaddr.sa_family ) { 334 switch( ifrs.ifr_hwaddr.sa_family ) {
@@ -323,9 +394,9 @@ void System::probeInterfaces( void ) {
323 break; 394 break;
324 } 395 }
325 } 396 }
326 } else // else already probed before -> just update 397 } else // else already probed before -> just update
327 Log(("OLDNIC %s\n", NicName.latin1())); 398 Log(("Redetected NIC %s\n", NicName.latin1()));
328 399
329 // get dynamic info 400 // get dynamic info
330 if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) { 401 if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) {
331 IFI->IsUp = ((ifrs.ifr_flags & IFF_UP) == IFF_UP); 402 IFI->IsUp = ((ifrs.ifr_flags & IFF_UP) == IFF_UP);
@@ -353,37 +424,27 @@ void System::probeInterfaces( void ) {
353 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_netmask)->sin_addr); 424 inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_netmask)->sin_addr);
354 } else { 425 } else {
355 IFI->Netmask = ""; 426 IFI->Netmask = "";
356 } 427 }
357 Log(("NIC %s UP %d\n", NicName.latin1(), IFI->IsUp )); 428 Log(("NIC %s UP ? %d\n", NicName.latin1(), IFI->IsUp ));
358 } 429 }
359}
360
361void System::execAsUser( QString & Cmd, char * argv[] ) {
362 CurrentQPEUser CU = NSResources->currentUser();
363
364 if( CU.UserName.isEmpty() ) {
365 // if we come here, the exec was not successfull
366 Log(("User not known \n" ));
367 return;
368 }
369 430
370 // now we are ready to exec the requested command 431 ::close( sockfd );
371 setuid( CU.Uid ); 432}
372 setgid( CU.Gid );
373
374 char ** envp = (char **)alloca( sizeof( char *) *
375 (CU.EnvList.count()+1) );
376 433
377 for( unsigned int i = 0 ; i < CU.EnvList.count() ; i ++ ) { 434InterfaceInfo * System::findInterface( const QString & N ) {
378 *(envp+i) = CU.EnvList[i]; 435 InterfaceInfo * Run;
436 // has PAN connection UP interface ?
437 for( QDictIterator<InterfaceInfo> It(ProbedInterfaces);
438 It.current();
439 ++It ) {
440 Run = It.current();
441 if( N == Run->Name ) {
442 // this PAN connection is up
443 return Run;
444 }
379 } 445 }
380 envp[CU.EnvList.count()]=NULL; 446 return 0;
381
382 execve( Cmd.latin1(), argv, envp );
383
384 // if we come here, the exec was not successfull
385 Log(("Could not exec : %d\n", errno ));
386} 447}
387 448
388#include <stdarg.h> 449#include <stdarg.h>
389static FILE * logf = 0; 450static FILE * logf = 0;
@@ -393,26 +454,31 @@ void VLog( char * Format, ... ) {
393 454
394 va_start(l, Format ); 455 va_start(l, Format );
395 456
396 if( logf == (FILE *)0 ) { 457 if( logf == (FILE *)0 ) {
397 if( getenv("NS2STDERR") ) { 458 QString S = getenv("NS2LOG");
459 if( S == "stderr" ) {
398 logf = stderr; 460 logf = stderr;
399 } else { 461 } else if( S.isEmpty() ) {
400 logf = fopen( "/tmp/ns2log", "a" ); 462 logf = fopen( "/tmp/ns2log", "a" );
463 } else {
464 logf = fopen( S, "a" );
401 } 465 }
466
402 if( ! logf ) { 467 if( ! logf ) {
403 fprintf( stderr, "Cannot open logfile /tmp/ns2log %d\n", 468 fprintf( stderr, "Cannot open logfile %s : %d\n",
404 errno ); 469 S.latin1(), errno );
405 logf = (FILE *)1; 470 logf = (FILE *)1;
406 } else { 471 } else {
407 fprintf( logf, "____ OPEN LOGFILE ____\n"); 472 fprintf( logf, "____ OPEN LOGFILE ____\n");
408 } 473 }
409 } 474 }
410 475
411 if( (long)logf > 1 ) { 476 if( (unsigned long)logf > 1 ) {
412 vfprintf( logf, Format, l ); 477 vfprintf( logf, Format, l );
413 } 478 }
414 va_end( l ); 479 va_end( l );
480 fflush( logf );
415 481
416} 482}
417 483
418void LogClose( void ) { 484void LogClose( void ) {
@@ -425,9 +491,83 @@ void LogClose( void ) {
425 } 491 }
426} 492}
427 493
428QString removeSpaces( const QString & X ) { 494QString removeSpaces( const QString & X ) {
429 QStringList SL; 495 QString Y;
496 Y = X.simplifyWhiteSpace();
497 Y.replace( QRegExp(" "), "_" );
498 owarn << X << " **" << Y << "**" << oendl;
499 return Y;
500}
501
502//
503//
504//
505//
506//
507
508MyProcess::MyProcess() : QObject(), StdoutBuffer(), StderrBuffer() {
509 P = new OProcess();
510 connect( P,
511 SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int ) ),
512 this,
513 SLOT( SLOT_Stdout(Opie::Core::OProcess*,char*,int) ) );
514
515 connect( P,
516 SIGNAL( receivedStderr(Opie::Core::OProcess*, char*, int ) ),
517 this,
518 SLOT( SLOT_Stderr(Opie::Core::OProcess*,char*,int) ) );
519 connect( P,
520 SIGNAL( processExited(Opie::Core::OProcess*) ),
521 this,
522 SLOT( SLOT_ProcessExited(Opie::Core::OProcess*) ) );
523}
524
525MyProcess::~MyProcess() {
526 delete P;
527}
528
529void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) {
530 char * LB = (char *)alloca( len + 1 );
531 memcpy( LB, Buf, len );
532 LB[len] = '\0';
533
534 // now input is zero terminated
535 StdoutBuffer += LB;
536
537 owarn << "Received " << len << " bytes on stdout" << oendl;
538 // see if we have some lines (allow empty lines)
539 QStringList SL = QStringList::split( "\n", StdoutBuffer, TRUE );
540
541 for( unsigned int i = 0; i < SL.count()-1; i ++ ) {
542 Log(( "Stdout : \"%s\"\n", SL[i].latin1() ) );
543 emit stdoutLine( SL[i] );
544 }
545
546 // last line is rest
547 StdoutBuffer = SL[ SL.count()-1 ];
548}
549
550void MyProcess::SLOT_Stderr( Opie::Core::OProcess * , char * Buf, int len ) {
551 char * LB = (char *)alloca( len + 1 );
552 memcpy( LB, Buf, len );
553 LB[len] = '\0';
554
555 // now input is zero terminated
556 StderrBuffer += LB;
557
558 owarn << "Received " << len << " bytes on stderr" << oendl;
559 // see if we have some lines (allow empty lines)
560 QStringList SL = QStringList::split( "\n", StderrBuffer, TRUE );
561
562 for( unsigned int i = 0; i < SL.count()-1; i ++ ) {
563 Log(( "Stderr : \"%s\"\n", SL[i].latin1() ) );
564 emit stderrLine( SL[i] );
565 }
566
567 // last line is rest
568 StderrBuffer = SL[ SL.count()-1 ];
569}
430 570
431 SL = QStringList::split( " ", X ); 571void MyProcess::SLOT_ProcessExited( Opie::Core::OProcess * ) {
432 return SL.join( "_" ); 572 emit processExited( this );
433} 573}
diff --git a/noncore/settings/networksettings2/networksettings2/system.h b/noncore/settings/networksettings2/networksettings2/system.h
index 33af391..e67d695 100644
--- a/noncore/settings/networksettings2/networksettings2/system.h
+++ b/noncore/settings/networksettings2/networksettings2/system.h
@@ -1,16 +1,54 @@
1#ifndef __SYSTEM__H 1#ifndef __SYSTEM__H
2#define __SYSTEM__H 2#define __SYSTEM__H
3 3
4#include <qstring.h>
5
6#include <opie2/oprocess.h>
7
8using namespace Opie::Core;
9
4// for hardware types 10// for hardware types
5#include <net/if_arp.h> 11#include <net/if_arp.h>
6#include <qdict.h> 12#include <qdict.h>
7#include <qobject.h> 13#include <qobject.h>
8#include <stdio.h> 14#include <stdio.h>
9 15
16class NodeCollection;
10class ANetNodeInstance; 17class ANetNodeInstance;
11class QFile; 18class QFile;
12 19
20class MyProcess : public QObject {
21
22 Q_OBJECT
23
24public :
25
26 MyProcess();
27 ~MyProcess();
28
29 inline OProcess & process()
30 { return *P; }
31
32public slots :
33
34 void SLOT_Stdout( Opie::Core::OProcess * P, char *, int );
35 void SLOT_Stderr( Opie::Core::OProcess * P, char *, int );
36 void SLOT_ProcessExited( Opie::Core::OProcess * P);
37
38signals :
39
40 void stdoutLine( const QString & );
41 void stderrLine( const QString & );
42 void processExited( MyProcess * );
43
44private :
45
46 QString StdoutBuffer;
47 QString StderrBuffer;
48 OProcess * P;
49};
50
13class InterfaceInfo { 51class InterfaceInfo {
14 52
15public : 53public :
16 54
@@ -21,15 +59,15 @@ public :
21 Netmask(), 59 Netmask(),
22 DstAddress() { 60 DstAddress() {
23 } 61 }
24 62
25 ANetNodeInstance * assignedNode() 63 NodeCollection * assignedConnection()
26 { return NetNode; } 64 { return Collection; }
27 65
28 void assignNode( ANetNodeInstance * NNI ) 66 void assignConnection( NodeCollection * NNI )
29 { NetNode = NNI; } 67 { Collection = NNI; }
30 68
31 ANetNodeInstance * NetNode; // netnode taking care of me 69 NodeCollection * Collection; // connection taking care of me
32 QString Name; // name of interface 70 QString Name; // name of interface
33 int CardType; // type of card 71 int CardType; // type of card
34 QString MACAddress; // MAC address 72 QString MACAddress; // MAC address
35 QString Address; // IP Address 73 QString Address; // IP Address
@@ -63,28 +101,35 @@ public :
63 InterfaceInfo * interface( const QString& N ) 101 InterfaceInfo * interface( const QString& N )
64 { return ProbedInterfaces[N]; } 102 { return ProbedInterfaces[N]; }
65 103
66 // exec command as root 104 // exec command as root
67 int runAsRoot( const QString & S ); 105 int runAsRoot( QStringList & S );
68 106
69 // exec command as user 107 // exec command as user
70 void execAsUser( QString & Cmd, char * argv[] ); 108 int execAsUser( QStringList & Cmd );
71 109
72 // refresh stats for this interface 110 // refresh stats for this interface
73 void refreshStatistics( InterfaceInfo & ); 111 void refreshStatistics( InterfaceInfo & );
74 112
75 // reloads interfaces 113 // reloads interfaces
76 void probeInterfaces( void ); 114 void probeInterfaces( void );
77 115
116 InterfaceInfo * findInterface( const QString & DevName );
117
118private slots :
119
120 void SLOT_ProcessExited( MyProcess * );
121
78signals : 122signals :
79 123
80 void lineFromCommand( const QString & S ); 124 void stdoutLine( const QString & );
125 void stderrLine( const QString & );
126 void processEvent( const QString & );
81 127
82private : 128private :
83 129
84 QDict<InterfaceInfo> ProbedInterfaces; 130 QDict<InterfaceInfo> ProbedInterfaces;
85 FILE * OutputOfCmd; 131 FILE * OutputOfCmd;
86 QFile * ProcDevNet; 132 QFile * ProcDevNet;
87
88}; 133};
89 134
90#endif 135#endif
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.cpp b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
index 2b40834..82fd43a 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.cpp
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
@@ -15,8 +15,9 @@ SystemFile::SystemFile( const QString & N,
15 const QString & P, 15 const QString & P,
16 bool KDI ){ 16 bool KDI ){
17 Name = N; 17 Name = N;
18 Path = P; 18 Path = P;
19 InAppend = 0;
19 F = 0; 20 F = 0;
20 // get template info 21 // get template info
21 { QString S; 22 { QString S;
22 QFileInfo FI; 23 QFileInfo FI;
@@ -62,39 +63,84 @@ SystemFile::SystemFile( const QString & N,
62 63
63 KnowsDeviceInstances = KDI; 64 KnowsDeviceInstances = KDI;
64} 65}
65 66
67SystemFile::SystemFile( const QString & N, bool KDI ){
68 Name = N;
69 Path = "";
70 InAppend = 0;
71 F =0;
72 KnowsDeviceInstances = KDI;
73 hasPreSection =
74 hasPostSection =
75 hasPreNodeSection =
76 hasPostNodeSection =
77 hasPreDeviceSection =
78 hasPostDeviceSection = 0;
79}
80
66SystemFile::~SystemFile( void ) { 81SystemFile::~SystemFile( void ) {
67 if( F ) 82 close();
68 delete F;
69} 83}
70 84
71bool SystemFile::open( void ) { 85bool SystemFile::open( void ) {
72 if( F ) { 86 QString Prefix = getenv( "NS2OUTPUTTO" );
73 F->close(); 87
74 delete F; 88 if( Prefix != "stderr" /* && Name != "interfaces" */ ) {
75 } 89 // generate files where the need to be
90 if( F ) {
91 F->close();
92 delete F;
93 }
76 94
77 F = new QFile( Path + "bup" ); 95 F = new QFile( Prefix + Path + ((InAppend)?"":"bup") );
78 if( ! F->open( IO_WriteOnly ) ) { 96 Log(( "Open systemfile %s\n", F->name().latin1() ));
79 return 0; 97 if( ! F->open( ((InAppend)?IO_Append : 0 ) | IO_WriteOnly ) ) {
98 return 0;
99 }
100 } else {
101 if( ! F ) {
102 owarn << "!!!!!!!!!!!!!!!!!! " << oendl;
103 owarn << "!!!! TESTMODE !!!!" << oendl;
104 owarn << "!!!!!!!!!!!!!!!!!! " << oendl;
105 owarn << "!!!!" << oendl;
106 owarn << "!!!! GENERATE " << Path << oendl;
107 if( InAppend ) {
108 owarn << "!!!! In APPEND mode" << oendl;
109 }
110 owarn << "!!!!" << oendl;
111 owarn << "!!!!!!!!!!!!!!!!!!" << oendl;
112
113 F = new QFile();
114 F->open( IO_WriteOnly, stderr );
115 }
80 } 116 }
81 setDevice( F ); 117 setDevice( F );
82 return 1; 118 return 1;
83} 119}
84 120
85bool SystemFile::close( void ) { 121bool SystemFile::close( void ) {
86 if( ! F ) { 122 if( ! F || ! F->isOpen() ) {
87 return 1 ; 123 return 1 ;
88 } 124 }
89 125
90 QString OldP = Path + "bup"; 126 QString Prefix = getenv( "NS2OUTPUTTO" );
127
128 if( Prefix == "stderr" ) {
129 return 1;
130 }
131
132 QString OldP = Prefix + Path + "bup";
91 133
92 F->close(); 134 F->close();
93 delete F; 135 delete F;
94 F = 0; 136 F = 0;
95 137
96 return ( rename( OldP.latin1(), Path.latin1() ) >= 0 ); 138 if( ! InAppend ) {
139 owarn << "Rename " << OldP << " to " << Path << oendl;
140 return ( rename( OldP.latin1(), Path.latin1() ) >= 0 );
141 }
142 return 1;
97} 143}
98 144
99bool SystemFile::preSection( void ) { 145bool SystemFile::preSection( void ) {
100 if( hasPreSection ) { 146 if( hasPreSection ) {
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.h b/noncore/settings/networksettings2/networksettings2/systemfile.h
index ceed605..a950c4d 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.h
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.h
@@ -13,17 +13,27 @@ public :
13 13
14 SystemFile( const QString & Name, 14 SystemFile( const QString & Name,
15 const QString & Path, 15 const QString & Path,
16 bool KnowsDevicesInstances ); 16 bool KnowsDevicesInstances );
17 SystemFile( const QString & Name,
18 bool KnowsDevicesInstances = 0 );
17 ~SystemFile( void ); 19 ~SystemFile( void );
18 20
21 void setName( const QString & S )
22 { Name = S; }
19 const QString & name( void ) const 23 const QString & name( void ) const
20 { return Name; } 24 { return Name; }
25
26 void setPath( const QString & S )
27 { Path = S; }
21 const QString & path( void ) const 28 const QString & path( void ) const
22 { return Path; } 29 { return Path; }
30
23 bool knowsDeviceInstances( void ) const 31 bool knowsDeviceInstances( void ) const
24 { return KnowsDeviceInstances; } 32 { return KnowsDeviceInstances; }
25 33
34 void setAppendMode( bool A)
35 { InAppend = A; };
26 bool open( void ); 36 bool open( void );
27 bool close( void ); 37 bool close( void );
28 38
29 bool preSection( void ); 39 bool preSection( void );
@@ -44,7 +54,8 @@ private :
44 bool hasPostNodeSection; 54 bool hasPostNodeSection;
45 bool hasPreDeviceSection; 55 bool hasPreDeviceSection;
46 bool hasPostDeviceSection; 56 bool hasPostDeviceSection;
47 bool KnowsDeviceInstances; 57 bool KnowsDeviceInstances;
58 bool InAppend;
48 59
49}; 60};
50#endif 61#endif
diff --git a/noncore/settings/networksettings2/networksettingsGUI.ui b/noncore/settings/networksettings2/networksettingsGUI.ui
index 6ed29f3..1085e08 100644
--- a/noncore/settings/networksettings2/networksettingsGUI.ui
+++ b/noncore/settings/networksettings2/networksettingsGUI.ui
@@ -10,10 +10,10 @@
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>144</width> 14 <width>383</width>
15 <height>260</height> 15 <height>359</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
@@ -67,9 +67,9 @@
67 <number>0</number> 67 <number>0</number>
68 </property> 68 </property>
69 <property stdset="1"> 69 <property stdset="1">
70 <name>spacing</name> 70 <name>spacing</name>
71 <number>1</number> 71 <number>0</number>
72 </property> 72 </property>
73 <widget> 73 <widget>
74 <class>QToolButton</class> 74 <class>QToolButton</class>
75 <property stdset="1"> 75 <property stdset="1">
@@ -166,16 +166,9 @@
166 <widget> 166 <widget>
167 <class>QToolButton</class> 167 <class>QToolButton</class>
168 <property stdset="1"> 168 <property stdset="1">
169 <name>name</name> 169 <name>name</name>
170 <cstring>Enable_TB</cstring> 170 <cstring>Disable_TB</cstring>
171 </property>
172 <property stdset="1">
173 <name>sizePolicy</name>
174 <sizepolicy>
175 <hsizetype>0</hsizetype>
176 <vsizetype>0</vsizetype>
177 </sizepolicy>
178 </property> 171 </property>
179 <property stdset="1"> 172 <property stdset="1">
180 <name>text</name> 173 <name>text</name>
181 <string>...</string> 174 <string>...</string>
@@ -192,80 +185,55 @@
192 <widget> 185 <widget>
193 <class>QToolButton</class> 186 <class>QToolButton</class>
194 <property stdset="1"> 187 <property stdset="1">
195 <name>name</name> 188 <name>name</name>
196 <cstring>On_TB</cstring> 189 <cstring>Down_TB</cstring>
197 </property>
198 <property stdset="1">
199 <name>sizePolicy</name>
200 <sizepolicy>
201 <hsizetype>0</hsizetype>
202 <vsizetype>0</vsizetype>
203 </sizepolicy>
204 </property> 190 </property>
205 <property stdset="1"> 191 <property stdset="1">
206 <name>text</name> 192 <name>text</name>
207 <string>...</string> 193 <string>...</string>
208 </property> 194 </property>
209 <property stdset="1"> 195 <property stdset="1">
210 <name>toggleButton</name> 196 <name>toggleButton</name>
211 <bool>true</bool> 197 <bool>false</bool>
212 </property> 198 </property>
213 <property stdset="1"> 199 <property stdset="1">
214 <name>toggleButton</name> 200 <name>toggleButton</name>
215 <bool>true</bool> 201 <bool>false</bool>
216 </property> 202 </property>
217 </widget> 203 </widget>
218 <widget> 204 <widget>
219 <class>QToolButton</class> 205 <class>QFrame</class>
220 <property stdset="1"> 206 <property stdset="1">
221 <name>name</name> 207 <name>name</name>
222 <cstring>Connect_TB</cstring> 208 <cstring>LED_Frm</cstring>
223 </property> 209 </property>
224 <property stdset="1"> 210 <property stdset="1">
225 <name>sizePolicy</name> 211 <name>frameShape</name>
226 <sizepolicy> 212 <enum>NoFrame</enum>
227 <hsizetype>0</hsizetype>
228 <vsizetype>0</vsizetype>
229 </sizepolicy>
230 </property>
231 <property stdset="1">
232 <name>text</name>
233 <string>...</string>
234 </property>
235 <property stdset="1">
236 <name>toggleButton</name>
237 <bool>true</bool>
238 </property> 213 </property>
239 <property stdset="1"> 214 <property stdset="1">
240 <name>toggleButton</name> 215 <name>frameShadow</name>
241 <bool>true</bool> 216 <enum>Raised</enum>
242 </property> 217 </property>
243 </widget> 218 </widget>
244 <widget> 219 <widget>
245 <class>QToolButton</class> 220 <class>QToolButton</class>
246 <property stdset="1"> 221 <property stdset="1">
247 <name>name</name> 222 <name>name</name>
248 <cstring>Disconnect_TB</cstring> 223 <cstring>Up_TB</cstring>
249 </property>
250 <property stdset="1">
251 <name>sizePolicy</name>
252 <sizepolicy>
253 <hsizetype>0</hsizetype>
254 <vsizetype>0</vsizetype>
255 </sizepolicy>
256 </property> 224 </property>
257 <property stdset="1"> 225 <property stdset="1">
258 <name>text</name> 226 <name>text</name>
259 <string>...</string> 227 <string>...</string>
260 </property> 228 </property>
261 <property stdset="1"> 229 <property stdset="1">
262 <name>toggleButton</name> 230 <name>toggleButton</name>
263 <bool>true</bool> 231 <bool>false</bool>
264 </property> 232 </property>
265 <property stdset="1"> 233 <property stdset="1">
266 <name>toggleButton</name> 234 <name>toggleButton</name>
267 <bool>true</bool> 235 <bool>false</bool>
268 </property> 236 </property>
269 </widget> 237 </widget>
270 </hbox> 238 </hbox>
271 </widget> 239 </widget>
@@ -478,14 +446,8 @@
478 </vbox> 446 </vbox>
479</widget> 447</widget>
480<connections> 448<connections>
481 <connection> 449 <connection>
482 <sender>Add_TB</sender>
483 <signal>clicked()</signal>
484 <receiver>NetworkSettingsGUI</receiver>
485 <slot>SLOT_AddNode()</slot>
486 </connection>
487 <connection>
488 <sender>Delete_TB</sender> 450 <sender>Delete_TB</sender>
489 <signal>clicked()</signal> 451 <signal>clicked()</signal>
490 <receiver>NetworkSettingsGUI</receiver> 452 <receiver>NetworkSettingsGUI</receiver>
491 <slot>SLOT_DeleteNode()</slot> 453 <slot>SLOT_DeleteNode()</slot>
@@ -496,26 +458,8 @@
496 <receiver>NetworkSettingsGUI</receiver> 458 <receiver>NetworkSettingsGUI</receiver>
497 <slot>SLOT_CheckState()</slot> 459 <slot>SLOT_CheckState()</slot>
498 </connection> 460 </connection>
499 <connection> 461 <connection>
500 <sender>Enable_TB</sender>
501 <signal>clicked()</signal>
502 <receiver>NetworkSettingsGUI</receiver>
503 <slot>SLOT_Enable()</slot>
504 </connection>
505 <connection>
506 <sender>Connect_TB</sender>
507 <signal>clicked()</signal>
508 <receiver>NetworkSettingsGUI</receiver>
509 <slot>SLOT_Connect()</slot>
510 </connection>
511 <connection>
512 <sender>On_TB</sender>
513 <signal>clicked()</signal>
514 <receiver>NetworkSettingsGUI</receiver>
515 <slot>SLOT_On()</slot>
516 </connection>
517 <connection>
518 <sender>GenConfig_TB</sender> 462 <sender>GenConfig_TB</sender>
519 <signal>clicked()</signal> 463 <signal>clicked()</signal>
520 <receiver>NetworkSettingsGUI</receiver> 464 <receiver>NetworkSettingsGUI</receiver>
521 <slot>SLOT_GenerateConfig()</slot> 465 <slot>SLOT_GenerateConfig()</slot>
@@ -550,23 +494,41 @@
550 <receiver>NetworkSettingsGUI</receiver> 494 <receiver>NetworkSettingsGUI</receiver>
551 <slot>SLOT_ToMessages()</slot> 495 <slot>SLOT_ToMessages()</slot>
552 </connection> 496 </connection>
553 <connection> 497 <connection>
554 <sender>Disconnect_TB</sender> 498 <sender>Add_TB</sender>
499 <signal>clicked()</signal>
500 <receiver>NetworkSettingsGUI</receiver>
501 <slot>SLOT_AddNode()</slot>
502 </connection>
503 <connection>
504 <sender>Disable_TB</sender>
505 <signal>toggled(bool)</signal>
506 <receiver>NetworkSettingsGUI</receiver>
507 <slot>SLOT_Disable(bool)</slot>
508 </connection>
509 <connection>
510 <sender>Down_TB</sender>
511 <signal>clicked()</signal>
512 <receiver>NetworkSettingsGUI</receiver>
513 <slot>SLOT_Down()</slot>
514 </connection>
515 <connection>
516 <sender>Up_TB</sender>
555 <signal>clicked()</signal> 517 <signal>clicked()</signal>
556 <receiver>NetworkSettingsGUI</receiver> 518 <receiver>NetworkSettingsGUI</receiver>
557 <slot>SLOT_Disconnect()</slot> 519 <slot>SLOT_Up()</slot>
558 </connection> 520 </connection>
559 <slot access="public">SLOT_AddNode()</slot> 521 <slot access="public">SLOT_AddNode()</slot>
560 <slot access="public">SLOT_CheckState()</slot> 522 <slot access="public">SLOT_CheckState()</slot>
561 <slot access="public">SLOT_Connect()</slot>
562 <slot access="public">SLOT_DeleteNode()</slot> 523 <slot access="public">SLOT_DeleteNode()</slot>
524 <slot access="public">SLOT_Disable(bool)</slot>
563 <slot access="public">SLOT_EditNode( QListBoxItem *)</slot> 525 <slot access="public">SLOT_EditNode( QListBoxItem *)</slot>
564 <slot access="public">SLOT_Enable()</slot>
565 <slot access="public">SLOT_GenerateConfig()</slot> 526 <slot access="public">SLOT_GenerateConfig()</slot>
566 <slot access="public">SLOT_On()</slot> 527 <slot access="public">SLOT_SetState(int)</slot>
567 <slot access="public">SLOT_ShowNode( QListBoxItem*)</slot> 528 <slot access="public">SLOT_ShowNode( QListBoxItem*)</slot>
568 <slot access="public">SLOT_ToMessages()</slot> 529 <slot access="public">SLOT_ToMessages()</slot>
569 <slot access="public">SLOT_ToProfile()</slot> 530 <slot access="public">SLOT_ToProfile()</slot>
570 <slot access="public">SLOT_Disconnect()</slot> 531 <slot access="public">SLOT_Up()</slot>
532 <slot access="public">SLOT_Down()</slot>
571</connections> 533</connections>
572</UI> 534</UI>
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp
index e2dd5b5..698a941 100644
--- a/noncore/settings/networksettings2/nsdata.cpp
+++ b/noncore/settings/networksettings2/nsdata.cpp
@@ -1,13 +1,14 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <opie2/odebug.h>
2#include <qpe/qpeapplication.h> 3#include <qpe/qpeapplication.h>
3#include <qtextstream.h> 4#include <qtextstream.h>
4#include <qdir.h> 5#include <qdir.h>
5#include <qfile.h> 6#include <qfile.h>
6#include <qfileinfo.h> 7#include <qfileinfo.h>
7 8
8#include "nsdata.h" 9#include "nsdata.h"
9#include <asdevice.h> 10#include <netnode.h>
10#include <resources.h> 11#include <resources.h>
11 12
12static QString CfgFile; 13static QString CfgFile;
13 14
@@ -26,10 +27,48 @@ NetworkSettingsData::NetworkSettingsData( void ) {
26 NSResources->currentUser().HomeDir.latin1() ); 27 NSResources->currentUser().HomeDir.latin1() );
27 Log(( "Cfg from %s\n", CfgFile.latin1() )); 28 Log(( "Cfg from %s\n", CfgFile.latin1() ));
28 29
29 // load settings 30 // load settings
30 IsModified = 0;
31 loadSettings(); 31 loadSettings();
32
33 // assign interfaces by scanning /tmp/profile-%s.Up files
34 { QDir D( "/tmp" );
35 QFile * F = new QFile;
36 int profilenr;
37 QString interfacename;
38 QTextStream TS ( F );
39
40 QStringList SL = D.entryList( "profile-*.up");
41
42 Log(( "System reports %d interfaces. Found %d up\n",
43 NSResources->system().interfaces().count(),
44 SL.count() ));
45
46 for ( QStringList::Iterator it = SL.begin();
47 it != SL.end();
48 ++it ) {
49 profilenr = atol( (*it).mid( 8 ).latin1() );
50 // read the interface store int 'up'
51 F->setName( D.path() + "/" + (*it) );
52 if( F->open( IO_ReadOnly ) ) {
53 NodeCollection * NC;
54 interfacename = TS.readLine();
55 F->close();
56
57 Log(( "Assign interface %s to Profile nr %d\n",
58 interfacename.latin1(), profilenr ));
59
60 NC = NSResources->getConnection( profilenr );
61 if( NC ) {
62 NC->assignInterface(
63 NSResources->system().findInterface( interfacename ) );
64 } else {
65 Log(( "Profile nr %d no longer defined\n",
66 profilenr ));
67 }
68 }
69 }
70 }
32} 71}
33 72
34// saving is done by caller 73// saving is done by caller
35NetworkSettingsData::~NetworkSettingsData( void ) { 74NetworkSettingsData::~NetworkSettingsData( void ) {
@@ -43,8 +82,10 @@ void NetworkSettingsData::loadSettings( void ) {
43 82
44 QFile F( CfgFile ); 83 QFile F( CfgFile );
45 QTextStream TS( &F ); 84 QTextStream TS( &F );
46 85
86 ForceModified = 0;
87
47 do { 88 do {
48 89
49 if( ! F.open(IO_ReadOnly) ) 90 if( ! F.open(IO_ReadOnly) )
50 break; 91 break;
@@ -84,13 +125,11 @@ void NetworkSettingsData::loadSettings( void ) {
84 S = S.mid( 9, S.length()-9 ); 125 S = S.mid( 9, S.length()-9 );
85 S = deQuote(S); 126 S = deQuote(S);
86 // try to find netnode 127 // try to find netnode
87 NN = NSResources->findNetNode( S ); 128 NN = NSResources->findNetNode( S );
88 Log( ( "Node %s : %p\n", S.latin1(), NN ) );
89 } else { 129 } else {
90 // try to find instance 130 // try to find instance
91 NNI = NSResources->createNodeInstance( S ); 131 NNI = NSResources->createNodeInstance( S );
92 Log( ( "NodeInstance %s : %p\n", S.latin1(), NNI ));
93 } 132 }
94 133
95 if( NN == 0 && NNI == 0 ) { 134 if( NN == 0 && NNI == 0 ) {
96 LeftOvers.append( Line ); 135 LeftOvers.append( Line );
@@ -137,11 +176,15 @@ void NetworkSettingsData::loadSettings( void ) {
137 } while( 1 ); 176 } while( 1 );
138 177
139 if( NNI ) { 178 if( NNI ) {
140 // loading from file -> exists 179 // loading from file -> exists
180 Log( ( "NodeInstance %s : %p\n", NNI->name(), NNI ));
141 NNI->setNew( FALSE ); 181 NNI->setNew( FALSE );
142 NSResources->addNodeInstance( NNI ); 182 NSResources->addNodeInstance( NNI );
143 } 183 }
184 if( NN ) {
185 Log( ( "Node %s : %p\n", NN->name(), NN ) );
186 }
144 } 187 }
145 } 188 }
146 189
147 } while( 0 ); 190 } while( 0 );
@@ -219,9 +262,15 @@ QString NetworkSettingsData::saveSettings( void ) {
219 // 262 //
220 // proper files AND system files regenerated 263 // proper files AND system files regenerated
221 // 264 //
222 265
223 setModified( 0 ); 266
267 for( QDictIterator<NodeCollection> it(NSResources->connections());
268 it.current();
269 ++it ) {
270 it.current()->setModified( 0 );
271 }
272
224 return ErrS; 273 return ErrS;
225} 274}
226 275
227QString NetworkSettingsData::generateSettings( void ) { 276QString NetworkSettingsData::generateSettings( void ) {
@@ -230,61 +279,120 @@ QString NetworkSettingsData::generateSettings( void ) {
230 Name2Connection_t & M = NSResources->connections(); 279 Name2Connection_t & M = NSResources->connections();
231 NodeCollection * NC; 280 NodeCollection * NC;
232 ANetNodeInstance * NNI; 281 ANetNodeInstance * NNI;
233 ANetNodeInstance * FirstWithData; 282 ANetNodeInstance * FirstWithData;
234 SystemFile * SF; 283 RuntimeInfo * CurDev;
235 AsDevice * CurDev;
236 ANetNode * NN, * CurDevNN = 0; 284 ANetNode * NN, * CurDevNN = 0;
237 long NoOfDevs; 285 long NoOfDevs;
238 long DevCtStart; 286 long DevCtStart;
239 bool needToGenerate; 287 bool needToGenerate;
240 288
241 // regenerate system files 289 // regenerate system files
242 Log( ( "Generating settings from %s\n", CfgFile.latin1() )); 290 Log( ( "Generating settings from %s\n", CfgFile.latin1() ));
243 291
244 // 292 for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() );
245 // generate files proper to each netnodeinstance 293 nnit.current();
246 // 294 ++nnit ) {
247 { Name2Instance_t & NNIs = NSResources->netNodeInstances(); 295 { QStringList SL;
248 296 bool FirstItem = 1;
249 for( QDictIterator<ANetNodeInstance> NNIIt(NNIs); 297 bool Generated = 0;
250 NNIIt.current(); 298
251 ++NNIIt ) { 299 CurDevNN = nnit.current()->NetNode;
252 // for all nodes find those that are modified 300 SL = CurDevNN->properFiles();
253 NNI = NNIIt.current(); 301
254 302 for ( QStringList::Iterator it = SL.begin();
255 { // get list of proper files for this nodeclass (if any) 303 it != SL.end();
256 QStringList * PF = NNI->nodeClass()->properFiles(); 304 ++it ) {
257 305
258 if( PF ) { 306 Generated = 0;
259 for ( QStringList::Iterator it = PF->begin(); 307 FirstItem = 1;
260 it != PF->end(); 308 // iterate over NNI's of this class
261 ++it ) { 309 for( QDictIterator<ANetNodeInstance> nniit(
262 QFile * F = NNI->openFile( (*it) ); 310 NSResources->netNodeInstances() );
263 if( F ) { 311 nniit.current();
264 QTextStream TS( F ); 312 ++nniit ) {
265 if( NNI->generateFile( (*it), F->name(), TS, -1 ) == 2 ) { 313 if( nniit.current()->nodeClass() != CurDevNN )
266 // problem generating 314 // different class
315 continue;
316
317 // open proper file
318 { SystemFile SF( (*it) );
319
320 if( ! CurDevNN->openFile( SF, nniit.current()) ) {
321 // cannot open
322 S = qApp->translate( "NetworkSettings",
323 "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ).
324 arg( (*it) ).arg( CurDevNN->name() );
325 return S;
326 }
327
328 if( ! SF.open() ) {
329 S = qApp->translate( "NetworkSettings",
330 "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ).
331 arg( (*it) ).arg( CurDevNN->name() );
332 return S;
333 }
334
335 // preamble on first
336 if( FirstItem ) {
337 if( CurDevNN->generatePreamble( SF ) == 2 ) {
267 S = qApp->translate( "NetworkSettings", 338 S = qApp->translate( "NetworkSettings",
268 "<p>Cannot generate files proper to \"%1\"</p>" ). 339 "<p>Error in section \"preamble\" for proper file \"%1\" and node \"%2\"</p>" ).
269 arg(NNI->nodeClass()->name()) ; 340 arg( (*it) ).
270 delete F; 341 arg( CurDevNN->name() );
271 return S; 342 return S;
272 } 343 }
273 delete F; 344 }
345 FirstItem = 0;
346 Generated = 1;
347
348 // item specific
349 if( nniit.current()->generateFile( SF, -1 ) == 2 ) {
350 S = qApp->translate( "NetworkSettings",
351 "<p>Error in section for node \"%1\" for proper file \"%2\" and node class \"%3\"</p>" ).
352 arg( nniit.current()->name() ).
353 arg( (*it) ).
354 arg( CurDevNN->name() );
355 return S;
274 } 356 }
275 } 357 }
276 } 358 }
359
360 if( Generated ) {
361 SystemFile SF( (*it) );
362
363 if( CurDevNN->openFile( SF, 0 ) &&
364 ! SF.path().isEmpty()
365 ) {
366
367 if( ! SF.open() ) {
368 S = qApp->translate( "NetworkSettings",
369 "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ).
370 arg( (*it) ).arg( CurDevNN->name() );
371 return S;
372 }
373
374 if( CurDevNN->generatePostamble( SF ) == 2 ) {
375 S = qApp->translate( "NetworkSettings",
376 "<p>Error in section \"postamble\" for proper file \"%1\" and node \"%2\"</p>" ).
377 arg( (*it) ).
378 arg( CurDevNN->name() );
379 return S;
380 }
381 } // no postamble
382 }
277 } 383 }
278 } 384 }
279 } 385 }
280 386
281 // 387 //
282 // generate all system files 388 // generate all registered files
283 // 389 //
284 for( QDictIterator<SystemFile> sfit(SFM); 390 for( QDictIterator<SystemFile> sfit(SFM);
285 sfit.current(); 391 sfit.current();
286 ++sfit ) { 392 ++sfit ) {
393 SystemFile * SF;
394
287 SF = sfit.current(); 395 SF = sfit.current();
288 396
289 // reset all 397 // reset all
290 for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); 398 for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() );
@@ -305,9 +413,9 @@ QString NetworkSettingsData::generateSettings( void ) {
305 ++ncit ) { 413 ++ncit ) {
306 ncit.current()->setDone(0); 414 ncit.current()->setDone(0);
307 } 415 }
308 416
309 Log( ( "Generating %s\n", SF->name().latin1() )); 417 Log( ( "Generating system file %s\n", SF->name().latin1() ));
310 418
311 needToGenerate = 0; 419 needToGenerate = 0;
312 420
313 // are there netnodes that have instances and need 421 // are there netnodes that have instances and need
@@ -317,9 +425,9 @@ QString NetworkSettingsData::generateSettings( void ) {
317 ++nnit ) { 425 ++nnit ) {
318 426
319 NN = nnit.current()->NetNode; 427 NN = nnit.current()->NetNode;
320 428
321 if( NN->hasDataForFile( SF->name() ) ) { 429 if( NN->hasDataForFile( *SF ) ) {
322 // netnode can have data 430 // netnode can have data
323 431
324 // are there instances of this node ? 432 // are there instances of this node ?
325 for( QDictIterator<ANetNodeInstance> nniit( 433 for( QDictIterator<ANetNodeInstance> nniit(
@@ -344,9 +452,14 @@ QString NetworkSettingsData::generateSettings( void ) {
344 continue; 452 continue;
345 } 453 }
346 454
347 // ok generate this system file 455 // ok generate this system file
348 SF->open(); 456 if( ! SF->open() ) {
457 S = qApp->translate( "NetworkSettings",
458 "<p>Cannot open system file \"%1\"</p>" ).
459 arg( SF->name() );
460 return S;
461 }
349 462
350 // global presection for this system file 463 // global presection for this system file
351 if( ! SF->preSection() ) { 464 if( ! SF->preSection() ) {
352 S = qApp->translate( "NetworkSettings", 465 S = qApp->translate( "NetworkSettings",
@@ -366,27 +479,23 @@ QString NetworkSettingsData::generateSettings( void ) {
366 // already done 479 // already done
367 continue; 480 continue;
368 } 481 }
369 482
370 if( ! NC->hasDataForFile( SF->name() ) ) { 483 if( ! NC->hasDataForFile( *SF ) ) {
371 // no data 484 // no data
372 continue; 485 continue;
373 } 486 }
374 487
375 Log(("Generating %s for connection %s\n", 488 Log(("Generating %s for connection %s\n",
376 SF->name().latin1(), NC->name().latin1() )); 489 SF->name().latin1(), NC->name().latin1() ));
377 // find highest item that wants to write data to this file 490 // find highest item that wants to write data to this file
378 FirstWithData = NC->firstWithDataForFile( SF->name() ); 491 FirstWithData = NC->firstWithDataForFile( *SF );
379 492
380 // find device on which this connection works 493 // find device on which this connection works
381 CurDev = NC->device(); 494 CurDev = NC->device();
382 // class of that node 495 // class of that node
383 CurDevNN = CurDev->netNode()->nodeClass(); 496 CurDevNN = CurDev->netNode()->nodeClass();
384 497
385 Log(( "%s is done %d\n",
386 FirstWithData->nodeClass()->name(),
387 FirstWithData->nodeClass()->done() ));
388
389 if( ! FirstWithData->nodeClass()->done() ) { 498 if( ! FirstWithData->nodeClass()->done() ) {
390 // generate fixed part 499 // generate fixed part
391 if( ! SF->preDeviceSection( CurDevNN ) ) { 500 if( ! SF->preDeviceSection( CurDevNN ) ) {
392 S = qApp->translate( "NetworkSettings", 501 S = qApp->translate( "NetworkSettings",
@@ -395,16 +504,21 @@ QString NetworkSettingsData::generateSettings( void ) {
395 return S; 504 return S;
396 } 505 }
397 506
398 if( FirstWithData->nodeClass()->generateFile( 507 if( FirstWithData->nodeClass()->generateFile(
399 SF->name(), SF->path(), *SF, -1 ) == 2 ) { 508 *SF,
509 FirstWithData,
510 -2 ) == 2 ) {
400 S = qApp->translate( "NetworkSettings", 511 S = qApp->translate( "NetworkSettings",
401 "<p>Error in section \"Common\" for file \"%1\" and node \"%2\"</p>" ). 512 "<p>Error in section \"Common\" for file \"%1\" and node \"%2\"</p>" ).
402 arg( SF->name() ). 513 arg( SF->name() ).
403 arg( CurDevNN->name() ); 514 arg( CurDevNN->name() );
404 return S; 515 return S;
405 } 516 }
406 FirstWithData->nodeClass()->setDone( 1 ); 517 FirstWithData->nodeClass()->setDone( 1 );
518 Log(( "Systemfile %s for node instance %s is done\n",
519 SF->name().latin1(),
520 FirstWithData->name() ));
407 } 521 }
408 522
409 NoOfDevs = 0; 523 NoOfDevs = 0;
410 DevCtStart = -1; 524 DevCtStart = -1;
@@ -413,27 +527,28 @@ QString NetworkSettingsData::generateSettings( void ) {
413 DevCtStart = 0; 527 DevCtStart = 0;
414 NoOfDevs = CurDevNN->instanceCount(); 528 NoOfDevs = CurDevNN->instanceCount();
415 } 529 }
416 530
417 Log(( "Node %s is done %d\n",
418 CurDev->netNode()->nodeClass()->name(),
419 CurDev->netNode()->nodeClass()->done() ));
420
421 if( ! CurDev->netNode()->nodeClass()->done() ) { 531 if( ! CurDev->netNode()->nodeClass()->done() ) {
422 // first time this device is handled 532 // first time this device is handled
423 // generate common device specific part 533 // generate common device specific part
424 for( int i = DevCtStart; i < NoOfDevs ; i ++ ) { 534 for( int i = DevCtStart; i < NoOfDevs ; i ++ ) {
425 535
426 if( FirstWithData->nodeClass()->generateFile( 536 if( FirstWithData->nodeClass()->generateFile(
427 SF->name(), SF->path(), *SF, CurDev->netNode(), i ) == 2 ) { 537 *SF, CurDev->netNode(), i ) == 2 ) {
428 S = qApp->translate( "NetworkSettings", 538 S = qApp->translate( "NetworkSettings",
429 "<p>Error in section \"Device\" for file \"%1\" and node \"%2\"</p>" ). 539 "<p>Error in section \"Device\" for file \"%1\" and node \"%2\"</p>" ).
430 arg( SF->name() ). 540 arg( SF->name() ).
431 arg( CurDevNN->name() ); 541 arg( CurDevNN->name() );
432 return S; 542 return S;
433 } 543 }
434 } 544 }
435 CurDev->netNode()->nodeClass()->setDone( 1 ); 545 CurDev->netNode()->nodeClass()->setDone( 1 );
546
547 Log(( "Systemfile %s for Nodeclass %s is done\n",
548 SF->name().latin1(),
549 CurDev->netNode()->nodeClass()->name()
550 ));
436 } 551 }
437 552
438 // generate profile specific info 553 // generate profile specific info
439 // for all nodeconnections that work on the same device 554 // for all nodeconnections that work on the same device
@@ -445,11 +560,13 @@ QString NetworkSettingsData::generateSettings( void ) {
445 // different device 560 // different device
446 continue; 561 continue;
447 } 562 }
448 563
449 Log(("Connection %s of same family\n", ncit2.current()->name().latin1() )); 564 Log(("Connection %s of family %s\n",
565 ncit2.current()->name().latin1(),
566 CurDev->name() ));
450 // generate 567 // generate
451 NNI = ncit2.current()->firstWithDataForFile( SF->name() ); 568 NNI = ncit2.current()->firstWithDataForFile( *SF );
452 for( int i = DevCtStart; i < NoOfDevs ; i ++ ) { 569 for( int i = DevCtStart; i < NoOfDevs ; i ++ ) {
453 if( ! SF->preNodeSection( NNI, i ) ) { 570 if( ! SF->preNodeSection( NNI, i ) ) {
454 S = qApp->translate( "NetworkSettings", 571 S = qApp->translate( "NetworkSettings",
455 "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ). 572 "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
@@ -457,10 +574,9 @@ QString NetworkSettingsData::generateSettings( void ) {
457 arg( CurDevNN->name() ); 574 arg( CurDevNN->name() );
458 return S; 575 return S;
459 } 576 }
460 577
461 switch( NNI->generateFile( 578 switch( NNI->generateFile( *SF, i ) ) {
462 SF->name(), SF->path(), *SF, i ) ) {
463 case 0 : 579 case 0 :
464 (*SF) << endl; 580 (*SF) << endl;
465 break; 581 break;
466 case 1 : 582 case 1 :
@@ -568,11 +684,16 @@ bool NetworkSettingsData::canStart( const char * Interface ) {
568 // -> try others 684 // -> try others
569 break; 685 break;
570 case Off : 686 case Off :
571 // try to UP the device 687 // try to UP the device
572 if( ! NC->setState( Activate ) ) { 688 { QString S= NC->setState( Activate );
573 // cannot bring device Online -> try other alters 689 if( ! S.isEmpty() ) {
574 break; 690 // could not bring device Online -> try other alters
691 Log(( "%s-c%d-disallowed : %s\n",
692 Interface, NC->number(), S.latin1() ));
693 break;
694 }
695 // interface assigned
575 } 696 }
576 // FT 697 // FT
577 case Available : 698 case Available :
578 case IsUp : // also called for 'ifdown' 699 case IsUp : // also called for 'ifdown'
@@ -588,16 +709,17 @@ bool NetworkSettingsData::canStart( const char * Interface ) {
588 printf( "%s-cnn-disallowed\n", Interface ); 709 printf( "%s-cnn-disallowed\n", Interface );
589 return 0; 710 return 0;
590} 711}
591 712
592/* 713bool NetworkSettingsData::isModified( void ) {
593 Called by the system to regenerate config files 714 if( ForceModified )
594*/
595
596bool NetworkSettingsData::regenerate( void ) {
597 QString S = generateSettings();
598 if( ! S.isEmpty() ) {
599 fprintf( stdout, "%s\n", S.latin1() );
600 return 1; 715 return 1;
716
717 for( QDictIterator<NodeCollection> it(NSResources->connections());
718 it.current();
719 ++it ) {
720 if( it.current()->isModified() ) {
721 return 1;
722 }
601 } 723 }
602 return 0; 724 return 0;
603} 725}
diff --git a/noncore/settings/networksettings2/nsdata.h b/noncore/settings/networksettings2/nsdata.h
index 507185e..a0ae7d1 100644
--- a/noncore/settings/networksettings2/nsdata.h
+++ b/noncore/settings/networksettings2/nsdata.h
@@ -1,8 +1,8 @@
1#ifndef __NSDATA_H 1#ifndef __NSDATA_H
2#define __NSDATA_H 2#define __NSDATA_H
3 3
4#include "netnode.h" 4#include <netnode.h>
5 5
6class NetworkSettingsData { 6class NetworkSettingsData {
7 7
8public : 8public :
@@ -14,24 +14,21 @@ public :
14 QString saveSettings( void ); 14 QString saveSettings( void );
15 15
16 QString generateSettings( void ); 16 QString generateSettings( void );
17 17
18 bool isModified( void ) 18 bool isModified( void );
19 { return IsModified; } 19 inline void setModified( bool M )
20 void setModified( bool m ) 20 { ForceModified = M; }
21 { IsModified = m; }
22 21
23 QList<NodeCollection> collectPossible( const char * Interface ); 22 QList<NodeCollection> collectPossible( const char * Interface );
24 // return TRUE if we need gui to decide 23 // return TRUE if we need gui to decide
25 bool canStart( const char * Interface ); 24 bool canStart( const char * Interface );
26 bool regenerate( void );
27 25
28private : 26private :
29 27
30 bool IsModified; 28 bool ForceModified;
31 29
32 // collect strings in config file nobody wants 30 // collect strings in config file nobody wants
33 QStringList LeftOvers; 31 QStringList LeftOvers;
34
35}; 32};
36 33
37#endif 34#endif
diff --git a/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp b/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp
index 450d560..9403694 100644
--- a/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp
+++ b/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp
@@ -36,9 +36,9 @@ QString PPPAuthEdit::acceptable( void ) {
36 } 36 }
37 return QString(); 37 return QString();
38} 38}
39 39
40bool PPPAuthEdit::commit( PPPData_t & D ) { 40bool PPPAuthEdit::commit( PPPData & D ) {
41 bool SM = 0; 41 bool SM = 0;
42 42
43 if( ( D.Auth.Mode == 0 && ! Login_RB->isChecked() ) || 43 if( ( D.Auth.Mode == 0 && ! Login_RB->isChecked() ) ||
44 ( D.Auth.Mode == 1 && ! PAP_Checked() ) || 44 ( D.Auth.Mode == 1 && ! PAP_Checked() ) ||
@@ -69,9 +69,9 @@ bool PPPAuthEdit::commit( PPPData_t & D ) {
69 } 69 }
70 return SM; 70 return SM;
71} 71}
72 72
73void PPPAuthEdit::showData( PPPData_t & D ) { 73void PPPAuthEdit::showData( PPPData & D ) {
74 74
75 switch( D.Auth.Mode ) { 75 switch( D.Auth.Mode ) {
76 case 0 : 76 case 0 :
77 Login_RB->setChecked( TRUE ); 77 Login_RB->setChecked( TRUE );
diff --git a/noncore/settings/networksettings2/ppp/PPPAuthedit.h b/noncore/settings/networksettings2/ppp/PPPAuthedit.h
index 2392569..7a06657 100644
--- a/noncore/settings/networksettings2/ppp/PPPAuthedit.h
+++ b/noncore/settings/networksettings2/ppp/PPPAuthedit.h
@@ -6,10 +6,10 @@ class PPPAuthEdit : public PPPAuthGUI {
6public : 6public :
7 7
8 PPPAuthEdit( QWidget * parent ); 8 PPPAuthEdit( QWidget * parent );
9 QString acceptable( void ); 9 QString acceptable( void );
10 bool commit( PPPData_t & Data ); 10 bool commit( PPPData & Data );
11 void showData( PPPData_t & Data ); 11 void showData( PPPData & Data );
12 bool PAP_Checked( void ); 12 bool PAP_Checked( void );
13 13
14 14
15private : 15private :
diff --git a/noncore/settings/networksettings2/ppp/PPPDNSedit.cpp b/noncore/settings/networksettings2/ppp/PPPDNSedit.cpp
index 22f8e59..270f695 100644
--- a/noncore/settings/networksettings2/ppp/PPPDNSedit.cpp
+++ b/noncore/settings/networksettings2/ppp/PPPDNSedit.cpp
@@ -22,9 +22,9 @@ QString PPPDNSEdit::acceptable( void ) {
22 } 22 }
23 return QString(); 23 return QString();
24} 24}
25 25
26bool PPPDNSEdit::commit( PPPData_t & D ) { 26bool PPPDNSEdit::commit( PPPData & D ) {
27 bool SM = 0; 27 bool SM = 0;
28 28
29 CBM( D.DNS.ServerAssigned, DNSServerAssigned_RB, SM ); 29 CBM( D.DNS.ServerAssigned, DNSServerAssigned_RB, SM );
30 TXTM( D.DNS.DomainName, DomainName_LE, SM ); 30 TXTM( D.DNS.DomainName, DomainName_LE, SM );
@@ -74,9 +74,9 @@ bool PPPDNSEdit::commit( PPPData_t & D ) {
74 } 74 }
75 return SM; 75 return SM;
76} 76}
77 77
78void PPPDNSEdit::showData( PPPData_t & D) { 78void PPPDNSEdit::showData( PPPData & D) {
79 79
80 DNSServerAssigned_RB->setChecked( D.DNS.ServerAssigned ); 80 DNSServerAssigned_RB->setChecked( D.DNS.ServerAssigned );
81 81
82 DomainName_LE->setText( D.DNS.DomainName ); 82 DomainName_LE->setText( D.DNS.DomainName );
diff --git a/noncore/settings/networksettings2/ppp/PPPDNSedit.h b/noncore/settings/networksettings2/ppp/PPPDNSedit.h
index 43e0067..1ca8c21 100644
--- a/noncore/settings/networksettings2/ppp/PPPDNSedit.h
+++ b/noncore/settings/networksettings2/ppp/PPPDNSedit.h
@@ -6,10 +6,10 @@ class PPPDNSEdit : public PPPDNSGUI {
6public : 6public :
7 7
8 PPPDNSEdit( QWidget * parent ); 8 PPPDNSEdit( QWidget * parent );
9 QString acceptable( void ); 9 QString acceptable( void );
10 bool commit( PPPData_t & Data ); 10 bool commit( PPPData & Data );
11 void showData( PPPData_t & Data ); 11 void showData( PPPData & Data );
12 12
13public slots : 13public slots :
14 14
15 void SLOT_AddServer( void ); 15 void SLOT_AddServer( void );
diff --git a/noncore/settings/networksettings2/ppp/PPPGUI.ui b/noncore/settings/networksettings2/ppp/PPPGUI.ui
index 777e4a9..4c79fe3 100644
--- a/noncore/settings/networksettings2/ppp/PPPGUI.ui
+++ b/noncore/settings/networksettings2/ppp/PPPGUI.ui
@@ -10,10 +10,10 @@
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>124</width> 14 <width>528</width>
15 <height>29</height> 15 <height>345</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
@@ -27,9 +27,9 @@
27 </property> 27 </property>
28 <vbox> 28 <vbox>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
31 <number>2</number> 31 <number>0</number>
32 </property> 32 </property>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>2</number> 35 <number>2</number>
@@ -53,8 +53,20 @@
53 <name>text</name> 53 <name>text</name>
54 <string>DNS Settings</string> 54 <string>DNS Settings</string>
55 </property> 55 </property>
56 </item> 56 </item>
57 <item>
58 <property>
59 <name>text</name>
60 <string>Commands</string>
61 </property>
62 </item>
63 <item>
64 <property>
65 <name>text</name>
66 <string>Dialing</string>
67 </property>
68 </item>
57 <property stdset="1"> 69 <property stdset="1">
58 <name>name</name> 70 <name>name</name>
59 <cstring>PPPOptions_CB</cstring> 71 <cstring>PPPOptions_CB</cstring>
60 </property> 72 </property>
@@ -75,9 +87,9 @@
75 <sizehint> 87 <sizehint>
76 <width>-1</width> 88 <width>-1</width>
77 <height>-1</height> 89 <height>-1</height>
78 </sizehint> 90 </sizehint>
79 <container>0</container> 91 <container>1</container>
80 <sizepolicy> 92 <sizepolicy>
81 <hordata>7</hordata> 93 <hordata>7</hordata>
82 <verdata>7</verdata> 94 <verdata>7</verdata>
83 </sizepolicy> 95 </sizepolicy>
diff --git a/noncore/settings/networksettings2/ppp/PPPIPGUI.ui b/noncore/settings/networksettings2/ppp/PPPIPGUI.ui
index f3d5019..21bd29e 100644
--- a/noncore/settings/networksettings2/ppp/PPPIPGUI.ui
+++ b/noncore/settings/networksettings2/ppp/PPPIPGUI.ui
@@ -10,10 +10,10 @@
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>133</width> 14 <width>258</width>
15 <height>235</height> 15 <height>232</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
@@ -27,23 +27,19 @@
27 </property> 27 </property>
28 <vbox> 28 <vbox>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
31 <number>3</number> 31 <number>0</number>
32 </property> 32 </property>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>2</number> 35 <number>1</number>
36 </property> 36 </property>
37 <widget> 37 <widget>
38 <class>QButtonGroup</class> 38 <class>QGroupBox</class>
39 <property stdset="1"> 39 <property stdset="1">
40 <name>name</name> 40 <name>name</name>
41 <cstring>ButtonGroup4</cstring> 41 <cstring>GroupBox1</cstring>
42 </property>
43 <property stdset="1">
44 <name>frameShape</name>
45 <enum>Box</enum>
46 </property> 42 </property>
47 <property stdset="1"> 43 <property stdset="1">
48 <name>title</name> 44 <name>title</name>
49 <string>IP</string> 45 <string>IP</string>
@@ -53,174 +49,107 @@
53 </property> 49 </property>
54 <property> 50 <property>
55 <name>layoutSpacing</name> 51 <name>layoutSpacing</name>
56 </property> 52 </property>
57 <vbox> 53 <grid>
58 <property stdset="1"> 54 <property stdset="1">
59 <name>margin</name> 55 <name>margin</name>
60 <number>2</number> 56 <number>3</number>
61 </property> 57 </property>
62 <property stdset="1"> 58 <property stdset="1">
63 <name>spacing</name> 59 <name>spacing</name>
64 <number>2</number> 60 <number>2</number>
65 </property> 61 </property>
66 <widget> 62 <widget row="0" column="0" >
67 <class>QRadioButton</class> 63 <class>QLabel</class>
68 <property stdset="1"> 64 <property stdset="1">
69 <name>name</name> 65 <name>name</name>
70 <cstring>IPServerAssigned_RB</cstring> 66 <cstring>TextLabel1</cstring>
67 </property>
68 <property stdset="1">
69 <name>enabled</name>
70 <bool>true</bool>
71 </property> 71 </property>
72 <property stdset="1"> 72 <property stdset="1">
73 <name>text</name> 73 <name>text</name>
74 <string>Server assigned</string> 74 <string>Local</string>
75 </property> 75 </property>
76 </widget>
77 <widget row="0" column="1" >
78 <class>QLineEdit</class>
76 <property stdset="1"> 79 <property stdset="1">
77 <name>checked</name> 80 <name>name</name>
81 <cstring>LocalAddress_LE</cstring>
82 </property>
83 <property stdset="1">
84 <name>enabled</name>
78 <bool>true</bool> 85 <bool>true</bool>
79 </property> 86 </property>
80 </widget> 87 </widget>
81 <widget> 88 <widget row="0" column="2" >
82 <class>QRadioButton</class> 89 <class>QCheckBox</class>
83 <property stdset="1"> 90 <property stdset="1">
84 <name>name</name> 91 <name>name</name>
85 <cstring>IPFixed_RB</cstring> 92 <cstring>ServerOverrulesLocal_CB</cstring>
86 </property> 93 </property>
87 <property stdset="1"> 94 <property stdset="1">
88 <name>text</name> 95 <name>text</name>
89 <string>Fixed</string> 96 <string>Server Overrules</string>
90 </property> 97 </property>
91 </widget> 98 </widget>
92 <widget> 99 <widget row="1" column="1" >
93 <class>QLayoutWidget</class> 100 <class>QLineEdit</class>
94 <property stdset="1"> 101 <property stdset="1">
95 <name>name</name> 102 <name>name</name>
96 <cstring>Layout11</cstring> 103 <cstring>RemoteAddress_LE</cstring>
104 </property>
105 <property stdset="1">
106 <name>enabled</name>
107 <bool>true</bool>
97 </property> 108 </property>
98 <hbox>
99 <property stdset="1">
100 <name>margin</name>
101 <number>0</number>
102 </property>
103 <property stdset="1">
104 <name>spacing</name>
105 <number>6</number>
106 </property>
107 <spacer>
108 <property>
109 <name>name</name>
110 <cstring>Spacer8</cstring>
111 </property>
112 <property stdset="1">
113 <name>orientation</name>
114 <enum>Horizontal</enum>
115 </property>
116 <property stdset="1">
117 <name>sizeType</name>
118 <enum>Fixed</enum>
119 </property>
120 <property>
121 <name>sizeHint</name>
122 <size>
123 <width>20</width>
124 <height>20</height>
125 </size>
126 </property>
127 <property>
128 <name>layoutMargin</name>
129 </property>
130 <property>
131 <name>layoutSpacing</name>
132 </property>
133 </spacer>
134 <widget>
135 <class>QFrame</class>
136 <property stdset="1">
137 <name>name</name>
138 <cstring>Frame8</cstring>
139 </property>
140 <property stdset="1">
141 <name>enabled</name>
142 <bool>false</bool>
143 </property>
144 <property stdset="1">
145 <name>sizePolicy</name>
146 <sizepolicy>
147 <hsizetype>7</hsizetype>
148 <vsizetype>5</vsizetype>
149 </sizepolicy>
150 </property>
151 <property stdset="1">
152 <name>frameShape</name>
153 <enum>NoFrame</enum>
154 </property>
155 <property stdset="1">
156 <name>frameShadow</name>
157 <enum>Raised</enum>
158 </property>
159 <property>
160 <name>layoutMargin</name>
161 </property>
162 <property>
163 <name>layoutSpacing</name>
164 </property>
165 <grid>
166 <property stdset="1">
167 <name>margin</name>
168 <number>2</number>
169 </property>
170 <property stdset="1">
171 <name>spacing</name>
172 <number>2</number>
173 </property>
174 <widget row="0" column="1" >
175 <class>QLineEdit</class>
176 <property stdset="1">
177 <name>name</name>
178 <cstring>IPAddress_LE</cstring>
179 </property>
180 </widget>
181 <widget row="1" column="0" >
182 <class>QLabel</class>
183 <property stdset="1">
184 <name>name</name>
185 <cstring>TextLabel3</cstring>
186 </property>
187 <property stdset="1">
188 <name>text</name>
189 <string>Subnetmask</string>
190 </property>
191 </widget>
192 <widget row="0" column="0" >
193 <class>QLabel</class>
194 <property stdset="1">
195 <name>name</name>
196 <cstring>TextLabel2</cstring>
197 </property>
198 <property stdset="1">
199 <name>text</name>
200 <string>Address</string>
201 </property>
202 </widget>
203 <widget row="1" column="1" >
204 <class>QLineEdit</class>
205 <property stdset="1">
206 <name>name</name>
207 <cstring>IPSubMask_LE</cstring>
208 </property>
209 </widget>
210 </grid>
211 </widget>
212 </hbox>
213 </widget> 109 </widget>
214 </vbox> 110 <widget row="1" column="2" >
111 <class>QCheckBox</class>
112 <property stdset="1">
113 <name>name</name>
114 <cstring>ServerOverrulesRemote_CB</cstring>
115 </property>
116 <property stdset="1">
117 <name>text</name>
118 <string>Server Overrules</string>
119 </property>
120 </widget>
121 <widget row="1" column="0" >
122 <class>QLabel</class>
123 <property stdset="1">
124 <name>name</name>
125 <cstring>TextLabel1_2</cstring>
126 </property>
127 <property stdset="1">
128 <name>enabled</name>
129 <bool>true</bool>
130 </property>
131 <property stdset="1">
132 <name>text</name>
133 <string>Remote</string>
134 </property>
135 </widget>
136 </grid>
215 </widget> 137 </widget>
216 <widget> 138 <widget>
217 <class>QButtonGroup</class> 139 <class>QButtonGroup</class>
218 <property stdset="1"> 140 <property stdset="1">
219 <name>name</name> 141 <name>name</name>
220 <cstring>ButtonGroup5</cstring> 142 <cstring>ButtonGroup5</cstring>
221 </property> 143 </property>
222 <property stdset="1"> 144 <property stdset="1">
145 <name>sizePolicy</name>
146 <sizepolicy>
147 <hsizetype>5</hsizetype>
148 <vsizetype>1</vsizetype>
149 </sizepolicy>
150 </property>
151 <property stdset="1">
223 <name>title</name> 152 <name>title</name>
224 <string>Gateway</string> 153 <string>Gateway</string>
225 </property> 154 </property>
226 <property> 155 <property>
@@ -231,9 +160,9 @@
231 </property> 160 </property>
232 <vbox> 161 <vbox>
233 <property stdset="1"> 162 <property stdset="1">
234 <name>margin</name> 163 <name>margin</name>
235 <number>2</number> 164 <number>3</number>
236 </property> 165 </property>
237 <property stdset="1"> 166 <property stdset="1">
238 <name>spacing</name> 167 <name>spacing</name>
239 <number>2</number> 168 <number>2</number>
@@ -377,9 +306,9 @@
377 <widget> 306 <widget>
378 <class>QLayoutWidget</class> 307 <class>QLayoutWidget</class>
379 <property stdset="1"> 308 <property stdset="1">
380 <name>name</name> 309 <name>name</name>
381 <cstring>Layout3</cstring> 310 <cstring>Layout4</cstring>
382 </property> 311 </property>
383 <hbox> 312 <hbox>
384 <property stdset="1"> 313 <property stdset="1">
385 <name>margin</name> 314 <name>margin</name>
@@ -388,8 +317,19 @@
388 <property stdset="1"> 317 <property stdset="1">
389 <name>spacing</name> 318 <name>spacing</name>
390 <number>6</number> 319 <number>6</number>
391 </property> 320 </property>
321 <widget>
322 <class>QCheckBox</class>
323 <property stdset="1">
324 <name>name</name>
325 <cstring>GWIsDefault_CB</cstring>
326 </property>
327 <property stdset="1">
328 <name>text</name>
329 <string>Set as default</string>
330 </property>
331 </widget>
392 <spacer> 332 <spacer>
393 <property> 333 <property>
394 <name>name</name> 334 <name>name</name>
395 <cstring>Spacer3</cstring> 335 <cstring>Spacer3</cstring>
@@ -413,19 +353,40 @@
413 <widget> 353 <widget>
414 <class>QCheckBox</class> 354 <class>QCheckBox</class>
415 <property stdset="1"> 355 <property stdset="1">
416 <name>name</name> 356 <name>name</name>
417 <cstring>GWIsDefault_CB</cstring> 357 <cstring>GWIfNotSet_CB</cstring>
418 </property> 358 </property>
419 <property stdset="1"> 359 <property stdset="1">
420 <name>text</name> 360 <name>text</name>
421 <string>Set as default</string> 361 <string>Only if not yet set</string>
422 </property> 362 </property>
423 </widget> 363 </widget>
424 </hbox> 364 </hbox>
425 </widget> 365 </widget>
426 </vbox> 366 </vbox>
427 </widget> 367 </widget>
368 <spacer>
369 <property>
370 <name>name</name>
371 <cstring>Spacer4</cstring>
372 </property>
373 <property stdset="1">
374 <name>orientation</name>
375 <enum>Vertical</enum>
376 </property>
377 <property stdset="1">
378 <name>sizeType</name>
379 <enum>Expanding</enum>
380 </property>
381 <property>
382 <name>sizeHint</name>
383 <size>
384 <width>20</width>
385 <height>20</height>
386 </size>
387 </property>
388 </spacer>
428 </vbox> 389 </vbox>
429</widget> 390</widget>
430<connections> 391<connections>
431 <connection> 392 <connection>
@@ -433,12 +394,6 @@
433 <signal>toggled(bool)</signal> 394 <signal>toggled(bool)</signal>
434 <receiver>Frame9</receiver> 395 <receiver>Frame9</receiver>
435 <slot>setEnabled(bool)</slot> 396 <slot>setEnabled(bool)</slot>
436 </connection> 397 </connection>
437 <connection>
438 <sender>IPFixed_RB</sender>
439 <signal>toggled(bool)</signal>
440 <receiver>Frame8</receiver>
441 <slot>setEnabled(bool)</slot>
442 </connection>
443</connections> 398</connections>
444</UI> 399</UI>
diff --git a/noncore/settings/networksettings2/ppp/PPPIPedit.cpp b/noncore/settings/networksettings2/ppp/PPPIPedit.cpp
index 6965e5a..ef1b7c0 100644
--- a/noncore/settings/networksettings2/ppp/PPPIPedit.cpp
+++ b/noncore/settings/networksettings2/ppp/PPPIPedit.cpp
@@ -8,18 +8,9 @@
8PPPIPEdit::PPPIPEdit( QWidget * Parent ) : PPPIPGUI( Parent ){ 8PPPIPEdit::PPPIPEdit( QWidget * Parent ) : PPPIPGUI( Parent ){
9} 9}
10 10
11QString PPPIPEdit::acceptable( void ) { 11QString PPPIPEdit::acceptable( void ) {
12 if( IPFixed_RB->isChecked() ) { 12 if( GWFixed_RB->isChecked() ) {
13 if( IPAddress_LE->text().isEmpty() )
14 return tr("IPAddress needed" );
15 if( ! validIP( IPAddress_LE->text() ) )
16 return tr("IPAddress not valid" );
17 if( IPSubMask_LE->text().isEmpty() )
18 return tr("Subnet mask needed" );
19 if( ! validIP( IPSubMask_LE->text() ) )
20 return tr("Subnet mask not valid" );
21 } else if( GWFixed_RB->isChecked() ) {
22 if( GWAddress_LE->text().isEmpty() ) 13 if( GWAddress_LE->text().isEmpty() )
23 return tr("Gateway address needed" ); 14 return tr("Gateway address needed" );
24 if( ! validIP( GWAddress_LE->text() ) ) 15 if( ! validIP( GWAddress_LE->text() ) )
25 return tr("Gateway address not valid" ); 16 return tr("Gateway address not valid" );
@@ -27,31 +18,37 @@ QString PPPIPEdit::acceptable( void ) {
27 18
28 return QString(); 19 return QString();
29} 20}
30 21
31bool PPPIPEdit::commit( PPPData_t & D ) { 22bool PPPIPEdit::commit( PPPData & D ) {
32 23
33 bool SM = 0; 24 bool SM = 0;
34 25
35 CBM( D.IP.IPAutomatic, IPServerAssigned_RB, SM ); 26 CBM( D.IP.LocalOverrule, ServerOverrulesLocal_CB, SM );
36 if( ! D.IP.IPAutomatic ) { 27 CBM( D.IP.RemoteOverrule, ServerOverrulesRemote_CB, SM );
37 TXTM( D.IP.IPAddress, IPAddress_LE, SM ); 28
38 TXTM( D.IP.IPSubMask, IPSubMask_LE, SM ); 29 TXTM( D.IP.LocalAddress, LocalAddress_LE, SM );
39 } 30 TXTM( D.IP.RemoteAddress, RemoteAddress_LE, SM );
40 31
41 CBM( D.IP.GWAutomatic, GWServerAssigned_RB, SM ); 32 CBM( D.IP.GWAutomatic, GWServerAssigned_RB, SM );
33
42 if( ! D.IP.GWAutomatic ) { 34 if( ! D.IP.GWAutomatic ) {
43 TXTM( D.IP.GWAddress, GWAddress_LE, SM ); 35 TXTM( D.IP.GWAddress, GWAddress_LE, SM );
44 } 36 }
45 37
46 CBM( D.IP.GWIsDefault, GWIsDefault_CB, SM ); 38 CBM( D.IP.GWIsDefault, GWIsDefault_CB, SM );
39 CBM( D.IP.GWIfNotSet, GWIfNotSet_CB, SM );
40
47 return SM; 41 return SM;
48} 42}
49 43
50void PPPIPEdit::showData( PPPData_t & D ) { 44void PPPIPEdit::showData( PPPData & D ) {
51 IPServerAssigned_RB->setChecked( D.IP.IPAutomatic ); 45 ServerOverrulesLocal_CB->setChecked( D.IP.LocalOverrule );
52 IPAddress_LE->setText( D.IP.IPAddress ); 46 ServerOverrulesRemote_CB->setChecked( D.IP.RemoteOverrule );
53 IPSubMask_LE->setText( D.IP.IPSubMask ); 47 LocalAddress_LE->setText( D.IP.LocalAddress );
48 RemoteAddress_LE->setText( D.IP.RemoteAddress );
49
54 GWServerAssigned_RB->setChecked( D.IP.GWAutomatic ); 50 GWServerAssigned_RB->setChecked( D.IP.GWAutomatic );
55 GWAddress_LE->setText( D.IP.GWAddress ); 51 GWAddress_LE->setText( D.IP.GWAddress );
56 GWIsDefault_CB->setChecked( D.IP.GWIsDefault ); 52 GWIsDefault_CB->setChecked( D.IP.GWIsDefault );
53 GWIfNotSet_CB->setChecked( D.IP.GWIfNotSet );
57} 54}
diff --git a/noncore/settings/networksettings2/ppp/PPPIPedit.h b/noncore/settings/networksettings2/ppp/PPPIPedit.h
index 153ee68..5ca4326 100644
--- a/noncore/settings/networksettings2/ppp/PPPIPedit.h
+++ b/noncore/settings/networksettings2/ppp/PPPIPedit.h
@@ -6,10 +6,10 @@ class PPPIPEdit : public PPPIPGUI {
6public : 6public :
7 7
8 PPPIPEdit( QWidget * parent ); 8 PPPIPEdit( QWidget * parent );
9 QString acceptable( void ); 9 QString acceptable( void );
10 bool commit( PPPData_t & Data ); 10 bool commit( PPPData & Data );
11 void showData( PPPData_t & Data ); 11 void showData( PPPData & Data );
12 12
13private : 13private :
14 14
15}; 15};
diff --git a/noncore/settings/networksettings2/ppp/PPPedit.cpp b/noncore/settings/networksettings2/ppp/PPPedit.cpp
index eb4fdbf..17889aa 100644
--- a/noncore/settings/networksettings2/ppp/PPPedit.cpp
+++ b/noncore/settings/networksettings2/ppp/PPPedit.cpp
@@ -2,18 +2,25 @@
2 2
3#include "PPPIPedit.h" 3#include "PPPIPedit.h"
4#include "PPPDNSedit.h" 4#include "PPPDNSedit.h"
5#include "PPPAuthedit.h" 5#include "PPPAuthedit.h"
6#include "PPPRunedit.h"
7#include "PPPDialingedit.h"
6#include "PPPedit.h" 8#include "PPPedit.h"
7 9
8PPPEdit::PPPEdit( QWidget * Parent ) : PPPGUI( Parent ){ 10PPPEdit::PPPEdit( QWidget * Parent ) : PPPGUI( Parent ){
9 11
10 Auth = new PPPAuthEdit( Options_WS ); 12 Auth = new PPPAuthEdit( Options_WS );
11 IP = new PPPIPEdit( Options_WS ); 13 IP = new PPPIPEdit( Options_WS );
12 DNS = new PPPDNSEdit( Options_WS ); 14 DNS = new PPPDNSEdit( Options_WS );
15 Run = new PPPRunEdit( Options_WS );
16 Dialing = new PPPDialingEdit( Options_WS );
17
13 Options_WS->addWidget( Auth, 0 ); 18 Options_WS->addWidget( Auth, 0 );
14 Options_WS->addWidget( IP, 1 ); 19 Options_WS->addWidget( IP, 1 );
15 Options_WS->addWidget( DNS, 2 ); 20 Options_WS->addWidget( DNS, 2 );
21 Options_WS->addWidget( Run, 3 );
22 Options_WS->addWidget( Dialing, 4 );
16 23
17 Options_WS->raiseWidget( 0 ); 24 Options_WS->raiseWidget( 0 );
18} 25}
19 26
@@ -28,17 +35,17 @@ QString PPPEdit::acceptable( void ) {
28 } 35 }
29 return S; 36 return S;
30} 37}
31 38
32bool PPPEdit::commit( PPPData_t & Data ) { 39bool PPPEdit::commit( PPPData & Data ) {
33 bool SM ; 40 bool SM ;
34 SM = Auth->commit( Data ); 41 SM = Auth->commit( Data );
35 SM |= IP->commit( Data ); 42 SM |= IP->commit( Data );
36 SM |= DNS->commit( Data ); 43 SM |= DNS->commit( Data );
37 return SM; 44 return SM;
38} 45}
39 46
40void PPPEdit::showData( PPPData_t & Data ) { 47void PPPEdit::showData( PPPData & Data ) {
41 Auth->showData( Data ) ; 48 Auth->showData( Data ) ;
42 IP->showData( Data ); 49 IP->showData( Data );
43 DNS->showData( Data ); 50 DNS->showData( Data );
44} 51}
diff --git a/noncore/settings/networksettings2/ppp/PPPedit.h b/noncore/settings/networksettings2/ppp/PPPedit.h
index 57d38ee..f674b17 100644
--- a/noncore/settings/networksettings2/ppp/PPPedit.h
+++ b/noncore/settings/networksettings2/ppp/PPPedit.h
@@ -3,25 +3,29 @@
3 3
4class PPPAuthEdit; 4class PPPAuthEdit;
5class PPPIPEdit; 5class PPPIPEdit;
6class PPPDNSEdit; 6class PPPDNSEdit;
7class PPPRunEdit;
8class PPPDialingEdit;
7 9
8class PPPEdit : public PPPGUI { 10class PPPEdit : public PPPGUI {
9 11
10public : 12public :
11 13
12 PPPEdit( QWidget * parent ); 14 PPPEdit( QWidget * parent );
13 QString acceptable( void ); 15 QString acceptable( void );
14 bool commit( PPPData_t & Data ); 16 bool commit( PPPData & Data );
15 void showData( PPPData_t & Data ); 17 void showData( PPPData & Data );
16 18
17public slots : 19public slots :
18 20
19 void SLOT_SelectTopic( int ); 21 void SLOT_SelectTopic( int );
20 22
21private : 23private :
22 24
23 PPPAuthEdit * Auth; 25 PPPAuthEdit * Auth;
24 PPPDNSEdit * DNS; 26 PPPDNSEdit * DNS;
25 PPPIPEdit * IP; 27 PPPIPEdit * IP;
28 PPPRunEdit * Run;
29 PPPDialingEdit * Dialing;
26 30
27}; 31};
diff --git a/noncore/settings/networksettings2/ppp/opie-networksettings2plugin-ppp.control b/noncore/settings/networksettings2/ppp/opie-networksettings2plugin-ppp.control
index 7dfde38..19d1c89 100644
--- a/noncore/settings/networksettings2/ppp/opie-networksettings2plugin-ppp.control
+++ b/noncore/settings/networksettings2/ppp/opie-networksettings2plugin-ppp.control
@@ -1,5 +1,5 @@
1Package: opie-networksettingsplugin2-ppp 1Package: opie-networksettings2plugin-ppp
2Files: plugins/networksettings2/libppp.so* 2Files: plugins/networksettings2/libppp.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Wim Delvaux <wimpie@handhelds.org> 5Maintainer: Wim Delvaux <wimpie@handhelds.org>
diff --git a/noncore/settings/networksettings2/ppp/ppp.pro b/noncore/settings/networksettings2/ppp/ppp.pro
index f866bee..dd3408c 100644
--- a/noncore/settings/networksettings2/ppp/ppp.pro
+++ b/noncore/settings/networksettings2/ppp/ppp.pro
@@ -5,20 +5,29 @@ HEADERS = ppp_NN.h \
5 ppp_NNI.h \ 5 ppp_NNI.h \
6 PPPedit.h \ 6 PPPedit.h \
7 PPPAuthedit.h \ 7 PPPAuthedit.h \
8 PPPDNSedit.h \ 8 PPPDNSedit.h \
9 PPPRunedit.h \
10 PPPDialingedit.h \
9 PPPIPedit.h 11 PPPIPedit.h
10 SOURCES = ppp_NN.cpp \ 12 SOURCES = ppp_NN.cpp \
11 ppp_NNI.cpp \ 13 ppp_NNI.cpp \
12 PPPedit.cpp \ 14 PPPedit.cpp \
13 PPPDNSedit.cpp \ 15 PPPDNSedit.cpp \
16 PPPRunedit.cpp \
17 PPPDialingedit.cpp \
14 PPPAuthedit.cpp \ 18 PPPAuthedit.cpp \
15 ppprun.cpp \ 19 ppprun.cpp \
16 PPPIPedit.cpp 20 PPPIPedit.cpp
17 INCLUDEPATH+= $(OPIEDIR)/include ../ ../networksettings2 21 INCLUDEPATH+= $(OPIEDIR)/include ../ ../networksettings2
18 DEPENDPATH+= $(OPIEDIR)/include ../ ../networksettings2 22 DEPENDPATH+= $(OPIEDIR)/include ../ ../networksettings2
19LIBS += -lqpe 23LIBS += -lqpe
20 INTERFACES= PPPGUI.ui PPPAuthGUI.ui PPPIPGUI.ui PPPDNSGUI.ui 24 INTERFACES= PPPGUI.ui \
25 PPPAuthGUI.ui \
26 PPPIPGUI.ui \
27 PPPDNSGUI.ui \
28 PPPDialingGUI.ui \
29 PPPRunGUI.ui
21 TARGET = ppp 30 TARGET = ppp
22 VERSION = 1.0.0 31 VERSION = 1.0.0
23 32
24include( $(OPIEDIR)/include.pro ) 33include( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
index ff4465c..51ba27d 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
@@ -1,32 +1,31 @@
1#include <qfile.h> 1#include <qfile.h>
2#include <resources.h>
2#include <qtextstream.h> 3#include <qtextstream.h>
3#include "ppp_NN.h" 4#include "ppp_NN.h"
4#include "ppp_NNI.h" 5#include "ppp_NNI.h"
5 6
6QStringList * PPPNetNode::ProperFiles = 0; 7QStringList * PPPNetNode::ProperFiles = 0;
7 8
8static const char * PPPNeeds[] = 9static const char * PPPNeeds[] =
9 { "line", 10 { "modem",
10 "modem", 11 0
12 };
13
14static const char * PPPProvides[] =
15 { "connection",
11 0 16 0
12 }; 17 };
13 18
14/** 19/**
15 * Constructor, find all of the possible interfaces 20 * Constructor, find all of the possible interfaces
16 */ 21 */
17PPPNetNode::PPPNetNode() : ANetNode(tr("PPP Connection")) { 22PPPNetNode::PPPNetNode() : ANetNode(tr("PPP Connection")) {
18 23
19 // proper files : will leak
20 ProperFiles =new QStringList;
21 *ProperFiles << "peers";
22 *ProperFiles << "chatscript";
23
24 // system files
25 NSResources->addSystemFile( 24 NSResources->addSystemFile(
26 "pap-secrets", "/tmp/pap-secrets", 0 ); 25 "pap-secrets", "/etc/ppp/pap-secrets", 0 );
27 NSResources->addSystemFile( 26 NSResources->addSystemFile(
28 "chap-secrets", "/tmp/chap-secrets", 0 ); 27 "chap-secrets", "/etc/ppp/chap-secrets", 0 );
29} 28}
30 29
31/** 30/**
32 * Delete any interfaces that we own. 31 * Delete any interfaces that we own.
@@ -49,23 +48,24 @@ ANetNodeInstance * PPPNetNode::createInstance( void ) {
49const char ** PPPNetNode::needs( void ) { 48const char ** PPPNetNode::needs( void ) {
50 return PPPNeeds; 49 return PPPNeeds;
51} 50}
52 51
53const char * PPPNetNode::provides( void ) { 52const char ** PPPNetNode::provides( void ) {
54 return "connection"; 53 return PPPProvides;
55} 54}
56 55
57QStringList * PPPNetNode::properFiles( void ) { 56QStringList PPPNetNode::properFiles( void ) {
58 return ProperFiles; 57 QStringList SL;
59 58 SL << "peers" << "chatscripts";
59 return SL;
60} 60}
61 61
62// need to generate : 62// need to generate :
63// /etc/ppp/pap-secrets 63// /etc/ppp/pap-secrets
64// /etc/ppp/pap-secrets 64// /etc/ppp/pap-secrets
65bool PPPNetNode::hasDataForFile( const QString & S ) { 65bool PPPNetNode::hasDataForFile( SystemFile & S ) {
66 return S == "pap-secrets" || 66 return S.name() == "pap-secrets" ||
67 S == "chap-secrets" ; 67 S.name() == "chap-secrets" ;
68} 68}
69 69
70QString PPPNetNode::genNic( long NicNr ) { 70QString PPPNetNode::genNic( long NicNr ) {
71 QString S; 71 QString S;
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.h b/noncore/settings/networksettings2/ppp/ppp_NN.h
index 249be5a..3ead10e 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NN.h
+++ b/noncore/settings/networksettings2/ppp/ppp_NN.h
@@ -16,17 +16,17 @@ public:
16 16
17 virtual const QString pixmapName() 17 virtual const QString pixmapName()
18 { return "Devices/ppp"; } 18 { return "Devices/ppp"; }
19 19
20 virtual bool hasDataForFile( const QString & S ); 20 virtual bool hasDataForFile( SystemFile & S );
21 21
22 virtual const QString nodeDescription() ; 22 virtual const QString nodeDescription() ;
23 virtual ANetNodeInstance * createInstance( void ); 23 virtual ANetNodeInstance * createInstance( void );
24 virtual const char ** needs( void ); 24 virtual const char ** needs( void );
25 virtual const char * provides( void ); 25 virtual const char ** provides( void );
26 26
27 virtual QString genNic( long NicNr ); 27 virtual QString genNic( long NicNr );
28 virtual QStringList * properFiles( void ); 28 virtual QStringList properFiles( void );
29 29
30private: 30private:
31 31
32 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 32 virtual void setSpecificAttribute( QString & Attr, QString & Value );
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
index ba639de..9e3bb64 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
@@ -15,14 +15,23 @@ APPP::APPP( PPPNetNode * PNN ) : ANetNodeInstance( PNN ) {
15 Data.Auth.Client = "*"; 15 Data.Auth.Client = "*";
16 Data.Auth.Server = "*"; 16 Data.Auth.Server = "*";
17 Data.Auth.Secret = ""; 17 Data.Auth.Secret = "";
18 18
19 Data.IP.IPAutomatic = 1; 19 Data.IP.LocalAddress = "10.0.0.1";
20 Data.IP.IPAddress = ""; 20 Data.IP.RemoteAddress = "10.0.0.2";
21 Data.IP.IPSubMask = ""; 21 Data.IP.LocalOverrule = 1;
22 Data.IP.RemoteOverrule = 1;
23
22 Data.IP.GWAutomatic = 1; 24 Data.IP.GWAutomatic = 1;
23 Data.IP.GWAddress = ""; 25 Data.IP.GWAddress = "";
24 Data.IP.GWIsDefault = 1; 26 Data.IP.GWIsDefault = 1;
27 Data.IP.GWIfNotSet = 1;
28
29 Data.Run.PreConnect = "";
30 Data.Run.PostConnect = "";
31 Data.Run.PreDisconnect = "";
32 Data.Run.PostDisconnect = "";
33
25 GUI = 0; 34 GUI = 0;
26 RT = 0; 35 RT = 0;
27 36
28} 37}
@@ -58,21 +67,35 @@ void APPP::setSpecificAttribute( QString & A, QString & V ) {
58 } else if( A == "authsecret" ) { 67 } else if( A == "authsecret" ) {
59 Data.Auth.Secret = V; 68 Data.Auth.Secret = V;
60 } 69 }
61 } else if( A.startsWith( "ip" ) ) { 70 } else if( A.startsWith( "ip" ) ) {
62 if( A == "ipautomatic" ) { 71 if( A == "iplocaloverrule" ) {
63 Data.IP.IPAutomatic = (V == "yes"); 72 Data.IP.LocalOverrule = (V == "yes");
64 } else if( A == "gwautomatic" ) { 73 } else if( A == "ipremoteoverrule" ) {
74 Data.IP.RemoteOverrule = (V == "yes");
75 } else if( A == "ipgwautomatic" ) {
65 Data.IP.GWAutomatic = (V == "yes"); 76 Data.IP.GWAutomatic = (V == "yes");
66 } else if( A == "gwisdefault" ) { 77 } else if( A == "ipgwisdefault" ) {
67 Data.IP.GWIsDefault = (V == "yes"); 78 Data.IP.GWIsDefault = (V == "yes");
68 } else if( A == "ipaddress" ) { 79 } else if( A == "ipgwifnotset" ) {
69 Data.IP.IPAddress = V; 80 Data.IP.GWIfNotSet = (V == "yes");
70 } else if( A == "ipsubmask" ) { 81 } else if( A == "iplocaladdress" ) {
71 Data.IP.IPSubMask = V; 82 Data.IP.LocalAddress = V;
72 } else if( A == "gwaddress" ) { 83 } else if( A == "ipremoteaddress" ) {
84 Data.IP.RemoteAddress = V;
85 } else if( A == "ipgwaddress" ) {
73 Data.IP.GWAddress = V; 86 Data.IP.GWAddress = V;
74 } 87 }
88 } else if( A.startsWith( "run" ) ) {
89 if( A == "runpreconnect" ) {
90 Data.Run.PreConnect = V;
91 } else if( A == "runpostconnect" ) {
92 Data.Run.PostConnect = V;
93 } else if( A == "runpredisconnect" ) {
94 Data.Run.PreDisconnect = V;
95 } else if( A == "runpostdisconnect" ) {
96 Data.Run.PostDisconnect = V;
97 }
75 } 98 }
76} 99}
77 100
78void APPP::saveSpecificAttribute( QTextStream & TS ) { 101void APPP::saveSpecificAttribute( QTextStream & TS ) {
@@ -90,14 +113,22 @@ void APPP::saveSpecificAttribute( QTextStream & TS ) {
90 TS << "authpcemode=" << Data.Auth.PCEMode << endl; 113 TS << "authpcemode=" << Data.Auth.PCEMode << endl;
91 TS << "authclient=" << Data.Auth.Client << endl; 114 TS << "authclient=" << Data.Auth.Client << endl;
92 TS << "authserver=" << Data.Auth.Server << endl; 115 TS << "authserver=" << Data.Auth.Server << endl;
93 TS << "authsecret=" << quote( Data.Auth.Secret ) << endl; 116 TS << "authsecret=" << quote( Data.Auth.Secret ) << endl;
94 TS << "ipautomatic=" << ( ( Data.IP.IPAutomatic ) ? "yes" : "no" ) << endl; 117 TS << "ipgwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl;
95 TS << "gwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl; 118 TS << "ipgwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl;
96 TS << "gwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl; 119 TS << "ipgwifnotset=" << ( ( Data.IP.GWIfNotSet ) ? "yes" : "no" ) << endl;
97 TS << "ipaddress=" << Data.IP.IPAddress << endl; 120 TS << "iplocaloverrule=" << ( ( Data.IP.LocalOverrule ) ? "yes" : "no" ) << endl;
98 TS << "ipsubmask=" << Data.IP.IPSubMask << endl; 121 TS << "ipremoteoverrule=" << ( ( Data.IP.RemoteOverrule ) ? "yes" : "no" ) << endl;
99 TS << "gwaddress=" << Data.IP.GWAddress << endl; 122 TS << "iplocaladdress=" << Data.IP.LocalAddress << endl;
123 TS << "ipremoteaddress=" << Data.IP.RemoteAddress << endl;
124 TS << "ipgwaddress=" << Data.IP.GWAddress << endl;
125
126 TS << "runpreconnect=" << Data.Run.PreConnect << endl;
127 TS << "runpostconnect=" << Data.Run.PostConnect << endl;
128 TS << "runpredisconnect=" << Data.Run.PreDisconnect << endl;
129 TS << "runpostdisconnect=" << Data.Run.PostDisconnect << endl;
130
100} 131}
101 132
102QWidget * APPP::edit( QWidget * parent ) { 133QWidget * APPP::edit( QWidget * parent ) {
103 GUI = new PPPEdit( parent ); 134 GUI = new PPPEdit( parent );
@@ -114,107 +145,90 @@ void APPP::commit( void ) {
114 setModified( 1 ); 145 setModified( 1 );
115 } 146 }
116} 147}
117 148
118QFile * APPP::openFile( const QString & ID ) { 149bool APPP::openFile( SystemFile & SF ) {
119 QFile * F = 0; 150 if( SF.name() == "peers" ) {
120 QString S; 151 SF.setPath( removeSpaces(
121 152 QString( "/tmp/ppp/peers/" ) + connection()->name() ) );
122 if( ID == "peers" ) { 153 return 1;
123 S = removeSpaces( QString("/tmp/") + connection()->name() ); 154 } else if ( SF.name() == "chatscripts" ) {
124 155 SF.setPath( removeSpaces(
125 F = new QFile( S ); 156 QString( "/tmp/chatscripts/" ) + connection()->name() ) );
126 157 return 1;
127 if( ! F->open( IO_WriteOnly ) ) {
128 Log(("Cannot open file %s\n", S.latin1() ));
129 return 0;
130 }
131 } else if ( ID == "chatscripts" ) {
132 S = removeSpaces( QString("/tmp/") + connection()->name() + ".chat" );
133 F = new QFile( S );
134
135 if( ! F->open( IO_WriteOnly ) ) {
136 Log(("Cannot open file %s\n", S.latin1() ));
137 return 0;
138 }
139 } 158 }
140 if( F ) { 159 return 0;
141 Log(("Generate proper file %s = %s\n",
142 ID.latin1(), F->name().latin1()));
143 }
144 return F;
145} 160}
146 161
147short APPP::generateFile( const QString & ID, 162short APPP::generateFile( SystemFile & SF, long DevNr ) {
148 const QString & Path,
149 QTextStream & TS,
150 long DevNr ) {
151 short rvl, rvd; 163 short rvl, rvd;
152 164
153 rvl = 1; 165 rvl = 1;
154 rvd = 1; 166 rvd = 1;
155 167
156 if( ID == "pap-secrets" ) { 168 if( SF.name() == "pap-secrets" ) {
157 Log(("Generate PPP for %s\n", ID.latin1() )); 169 Log(("Generate PPP for %s\n", SF.name().latin1() ));
170
158 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) { 171 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) {
159 TS << "# secrets for " 172 SF << "# secrets for "
160 << connection()->name().latin1() 173 << connection()->name().latin1()
161 << endl; 174 << endl;
162 TS << Data.Auth.Client 175 SF << Data.Auth.Client
163 << " " 176 << " "
164 << Data.Auth.Server 177 << Data.Auth.Server
165 << " " 178 << " "
166 << Data.Auth.Secret 179 << Data.Auth.Secret
167 << endl; 180 << endl;
168 rvl = 0; 181 rvl = 0;
169 rvd = connection()->getToplevel()->generateFileEmbedded( 182 rvd = connection()->getToplevel()->generateFileEmbedded(
170 ID, Path, TS, DevNr ); 183 SF, DevNr );
171 } 184 }
172 } else if( ID == "chap-secrets" ) { 185 } else if( SF.name() == "chap-secrets" ) {
173 Log(("Generate PPP for %s\n", ID.latin1() )); 186 Log(("Generate PPP for %s\n", SF.name().latin1() ));
174 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) { 187 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) {
175 // used for both EAP and Chap 188 // used for both EAP and Chap
176 TS << "# secrets for " 189 SF << "# secrets for "
177 << connection()->name().latin1() 190 << connection()->name().latin1()
178 << endl; 191 << endl;
179 TS << Data.Auth.Client 192 SF << Data.Auth.Client
180 << " " 193 << " "
181 << Data.Auth.Server 194 << Data.Auth.Server
182 << " " 195 << " "
183 << Data.Auth.Secret 196 << Data.Auth.Secret
184 << endl; 197 << endl;
185 198
186 rvl = 0; 199 rvl = 0;
187 rvd = connection()->getToplevel()->generateFileEmbedded( 200 rvd = connection()->getToplevel()->generateFileEmbedded(
188 ID, Path, TS, DevNr ); 201 SF, DevNr );
189 } 202 }
190 } else if ( ID == "peers" ) { 203 } else if ( SF.name() == "peers" ) {
191 QFileInfo FI(Path); 204
192 Log(("Generate PPP for %s\n", ID.latin1() )); 205 QFileInfo FI(SF.path());
206 Log(("Generate PPP for %s\n", SF.name().latin1() ));
193 207
194 TS << "connect \"/usr/sbin/chat -v -f /etc/ppp/" 208 SF << "connect \"/usr/sbin/chat -v -f /etc/chatscripts/"
195 << FI.baseName() 209 << FI.baseName()
196 << ".chat\"" 210 << "\""
197 << endl; 211 << endl;
198 212
199 if( Data.IP.GWIsDefault ) { 213 if( Data.IP.GWIsDefault ) {
200 TS << "defaultroute" 214 SF << "defaultroute"
201 << endl; 215 << endl;
202 } 216 }
203 217
204 TS << "linkname " 218 SF << "linkname "
205 << removeSpaces( ID.latin1() ) 219 << removeSpaces( SF.name().latin1() )
206 << endl; 220 << endl;
207 221
208 // insert other data here 222 // insert other data here
209 rvl = 0; 223 rvl = 0;
210 rvd = connection()->getToplevel()->generateFileEmbedded( 224 rvd = connection()->getToplevel()->generateFileEmbedded(
211 ID, Path, TS, DevNr ); 225 SF, DevNr );
212 } else if ( ID == "chatscripts" ) { 226 } else if ( SF.name() == "chatscripts" ) {
213 Log(("Generate PPP for %s\n", ID.latin1() )); 227 Log(("Generate PPP for %s\n", SF.name().latin1() ));
214 rvl = 0; 228 rvl = 0;
215 rvd = connection()->getToplevel()->generateFileEmbedded( 229 rvd = connection()->getToplevel()->generateFileEmbedded(
216 ID, Path, TS, DevNr ); 230 SF, DevNr );
217 } 231 }
218 232
219 return (rvd == 2 || rvl == 2 ) ? 2 : 233 return (rvd == 2 || rvl == 2 ) ? 2 :
220 (rvd == 0 || rvl == 0 ) ? 0 : 1; 234 (rvd == 0 || rvl == 0 ) ? 0 : 1;
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.h b/noncore/settings/networksettings2/ppp/ppp_NNI.h
index 0bf8fa9..76afb21 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NNI.h
+++ b/noncore/settings/networksettings2/ppp/ppp_NNI.h
@@ -15,25 +15,19 @@ public :
15 15
16 APPP( PPPNetNode * PNN ); 16 APPP( PPPNetNode * PNN );
17 17
18 RuntimeInfo * runtime( void ) 18 RuntimeInfo * runtime( void )
19 { if( RT == 0 ) { 19 { return (RT) ? RT : (RT = new PPPRun( this, Data ) ); }
20 RT = new PPPRun( this, Data );
21 }
22 return RT->runtimeInfo();
23 }
24 20
25 QWidget * edit( QWidget * parent ); 21 QWidget * edit( QWidget * parent );
26 QString acceptable( void ); 22 QString acceptable( void );
27 void commit( void ); 23 void commit( void );
28 24
29 virtual void * data( void ) 25 virtual void * data( void )
30 { return (void *)&Data; } 26 { return (void *)&Data; }
31 27
32 virtual QFile * openFile( const QString & ID ); 28 virtual bool openFile( SystemFile & Sf );
33 short generateFile( const QString & ID, 29 short generateFile( SystemFile & TS,
34 const QString & Path,
35 QTextStream & TS,
36 long DevNr ); 30 long DevNr );
37 31
38protected : 32protected :
39 33
diff --git a/noncore/settings/networksettings2/ppp/pppdata.h b/noncore/settings/networksettings2/ppp/pppdata.h
index 9e8543c..68666f8 100644
--- a/noncore/settings/networksettings2/ppp/pppdata.h
+++ b/noncore/settings/networksettings2/ppp/pppdata.h
@@ -3,17 +3,23 @@
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qarray.h> 5#include <qarray.h>
6 6
7typedef struct PPPData { 7class PPPData {
8
9public :
10
8 struct { 11 struct {
9 bool IPAutomatic; 12 bool LocalOverrule;
10 QString IPAddress; 13 bool RemoteOverrule;
11 QString IPSubMask; 14 QString LocalAddress;
15 QString RemoteAddress;
12 bool GWAutomatic; 16 bool GWAutomatic;
13 QString GWAddress; 17 QString GWAddress;
14 bool GWIsDefault; 18 bool GWIsDefault;
19 bool GWIfNotSet;
15 } IP; 20 } IP;
21
16 struct { 22 struct {
17 short Mode; // 0 login, 1 chap/pap, 2 Terminal 23 short Mode; // 0 login, 1 chap/pap, 2 Terminal
18 struct { 24 struct {
19 QString Expect; 25 QString Expect;
@@ -32,7 +38,13 @@ typedef struct PPPData {
32 bool ServerAssigned; 38 bool ServerAssigned;
33 QString DomainName; 39 QString DomainName;
34 QArray<QString *> Servers; 40 QArray<QString *> Servers;
35 } DNS; 41 } DNS;
36} PPPData_t; 42 struct {
43 QString PreConnect;
44 QString PostConnect;
45 QString PreDisconnect;
46 QString PostDisconnect;
47 } Run;
48};
37 49
38#endif 50#endif
diff --git a/noncore/settings/networksettings2/ppp/ppprun.cpp b/noncore/settings/networksettings2/ppp/ppprun.cpp
index a8abc50..8403e6d 100644
--- a/noncore/settings/networksettings2/ppp/ppprun.cpp
+++ b/noncore/settings/networksettings2/ppp/ppprun.cpp
@@ -1,55 +1,21 @@
1#include <resources.h> 1#include <resources.h>
2#include "ppprun.h" 2#include "ppprun.h"
3 3
4PPPRun::PPPRun( ANetNodeInstance * NNI, PPPData & Data ) : 4PPPRun::PPPRun( ANetNodeInstance * NNI, PPPData & Data ) :
5 AsConnection( NNI ), AsDevice( NNI ), Pat( "eth[0-9]" ) { 5 RuntimeInfo( NNI ), Pat( "eth[0-9]" ) {
6 D = &Data; 6 D = &Data;
7} 7}
8 8
9void PPPRun::detectState( NodeCollection * NC ) { 9State_t PPPRun::detectState( void ) {
10 if( isMyPPPDRunning( ) ) { 10 if( isMyPPPDRunning( ) ) {
11 if( isMyPPPUp() ) { 11 return ( isMyPPPUp() ) ? IsUp : Available;
12 NC->setCurrentState( IsUp ); 12 }
13 } else { 13 return Off;
14 NC->setCurrentState( Available );
15 }
16 } else {
17 NC->setCurrentState( Off ); // at least this
18 // but could also be unavailable
19 AsDevice::netNode()->nextNode()->runtime()->detectState( NC );
20 }
21} 14}
22 15
23bool PPPRun::setState( NodeCollection * NC, Action_t A, bool ) { 16QString PPPRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
24 switch( A ) { 17 return QString();
25 case Activate :
26 NC->setCurrentState( Available );
27 // no
28 break;
29 case Deactivate :
30 if( NC->currentState() == IsUp ) {
31 NC->state( Down );
32 }
33 // cannot really disable
34 NC->setCurrentState( Available );
35 break;
36 case Up :
37 if( NC->currentState() != IsUp ) {
38 // start my PPPD
39 NC->setCurrentState( IsUp );
40 }
41 break;
42 case Down :
43 if( NC->currentState() == IsUp ) {
44 // stop my PPPD
45 NC->setCurrentState( Available );
46 }
47 break;
48 default : // FT
49 break;
50 }
51 return 1;
52} 18}
53 19
54bool PPPRun::isMyPPPDRunning( void ) { 20bool PPPRun::isMyPPPDRunning( void ) {
55 return 0; 21 return 0;
@@ -67,9 +33,9 @@ bool PPPRun::isMyPPPUp( void ) {
67 if( R.match( Run->Name ) >= 0 && 33 if( R.match( Run->Name ) >= 0 &&
68 Run->IsPointToPoint 34 Run->IsPointToPoint
69 ) { 35 ) {
70 // this is a LAN card 36 // this is a LAN card
71 if( Run->assignedNode() == AsDevice::netNode() ) { 37 if( Run->assignedConnection() == netNode()->connection() ) {
72 // assigned to us 38 // assigned to us
73 return 1; 39 return 1;
74 } 40 }
75 } 41 }
@@ -79,4 +45,8 @@ bool PPPRun::isMyPPPUp( void ) {
79 45
80bool PPPRun::handlesInterface( const QString & S ) { 46bool PPPRun::handlesInterface( const QString & S ) {
81 return Pat.match( S ) >= 0; 47 return Pat.match( S ) >= 0;
82} 48}
49
50bool PPPRun::handlesInterface( InterfaceInfo * I ) {
51 return handlesInterface( I->Name );
52}
diff --git a/noncore/settings/networksettings2/ppp/ppprun.h b/noncore/settings/networksettings2/ppp/ppprun.h
index 90a3f25..2990a96 100644
--- a/noncore/settings/networksettings2/ppp/ppprun.h
+++ b/noncore/settings/networksettings2/ppp/ppprun.h
@@ -1,47 +1,37 @@
1#ifndef PPPRUN_H 1#ifndef PPPRUN_H
2#define PPPRUN_H 2#define PPPRUN_H
3 3
4#include <qregexp.h> 4#include <qregexp.h>
5#include <asconnection.h> 5#include <netnode.h>
6#include <asdevice.h>
7#include "pppdata.h" 6#include "pppdata.h"
8 7
9class PPPRun : public AsConnection, public AsDevice { 8class PPPRun : public RuntimeInfo {
10 9
11public : 10public :
12 11
13 PPPRun( ANetNodeInstance * NNI, 12 PPPRun( ANetNodeInstance * NNI,
14 PPPData & Data ); 13 PPPData & Data );
15 14
16 virtual AsDevice * asDevice( void ) 15 bool handlesInterface( const QString & I );
17 { return (AsDevice *)this; } 16 bool handlesInterface( InterfaceInfo * );
18 virtual AsConnection * asConnection( void )
19 { return (AsConnection *)this; }
20
21 virtual AsDevice * device( void )
22 { return (AsDevice *)this; }
23 17
24 virtual RuntimeInfo * runtimeInfo( void ) 18 State_t detectState( void );
25 { return ( AsConnection *)this; } 19 virtual RuntimeInfo * device( void )
20 { return this; }
21 virtual RuntimeInfo * connection( void )
22 { return this; }
26 23
27 protected : 24protected :
28 25
29 void detectState( NodeCollection * NC ); 26 QString setMyState( NodeCollection * , Action_t, bool );
30 bool setState( NodeCollection * NC, Action_t A, bool );
31 bool canSetState( State_t S, Action_t A )
32 { return AsDevice::connection()->findNext(
33 AsDevice::netNode() )->runtime()->canSetState( S,A ); }
34
35 bool handlesInterface( const QString & I );
36 27
37private : 28private :
38 29
39 bool isMyPPPDRunning( void ); 30 bool isMyPPPDRunning( void );
40 bool isMyPPPUp( void ); 31 bool isMyPPPUp( void );
41 32
42 PPPData_t * D; 33 PPPData * D;
43 QRegExp Pat; 34 QRegExp Pat;
44
45}; 35};
46 36
47#endif 37#endif
diff --git a/noncore/settings/networksettings2/profile/opie-networksettings2plugin-bluetooth.control b/noncore/settings/networksettings2/profile/opie-networksettings2plugin-bluetooth.control
index c76f9b8..40c8b48 100644
--- a/noncore/settings/networksettings2/profile/opie-networksettings2plugin-bluetooth.control
+++ b/noncore/settings/networksettings2/profile/opie-networksettings2plugin-bluetooth.control
@@ -1,9 +1,9 @@
1Package: opie-networksettingsplugin2-profile 1Package: opie-networksettings2plugin-profile
2Files: plugins/networksettings2/libprofile.so* 2Files: plugins/networksettings2/libprofile.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Wim Delvaux <wimpie@handhelds.org> 5Maintainer: Wim Delvaux <wimpie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: opie-networksettings2, libopiecore2, libopienet2 7Depends: opie-networksettings2, libopiecore2, libopienet2
8Description: Network settings profile plugin. 8Description: Network settings usage profile plugin.
9Version: $QPE_VERSION$EXTRAVERSION 9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp
index 945b48d..b7d8aa0 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NN.cpp
@@ -1,16 +1,25 @@
1#include <resources.h>
1#include "profile_NN.h" 2#include "profile_NN.h"
2#include "profile_NNI.h" 3#include "profile_NNI.h"
3 4
4static const char * ProfileNeeds[] = 5static const char * ProfileNeeds[] =
5 { "connection", 6 { "connection",
6 0 7 0
7 }; 8 };
9static const char * ProfileProvides[] =
10 { "fullsetup",
11 0
12 };
8 13
9/** 14/**
10 * Constructor, find all of the possible interfaces 15 * Constructor, find all of the possible interfaces
11 */ 16 */
12ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular connection profile")) { 17ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular connection profile")) {
18
19 NSResources->addSystemFile(
20 "interfaces", "/etc/network/interfaces", 1 );
21
13} 22}
14 23
15/** 24/**
16 * Delete any interfaces that we own. 25 * Delete any interfaces that we own.
@@ -33,10 +42,10 @@ ANetNodeInstance * ProfileNetNode::createInstance( void ) {
33const char ** ProfileNetNode::needs( void ) { 42const char ** ProfileNetNode::needs( void ) {
34 return ProfileNeeds; 43 return ProfileNeeds;
35} 44}
36 45
37const char * ProfileNetNode::provides( void ) { 46const char ** ProfileNetNode::provides( void ) {
38 return "fullsetup"; 47 return ProfileProvides;
39} 48}
40 49
41void ProfileNetNode::setSpecificAttribute( QString & , QString & ) { 50void ProfileNetNode::setSpecificAttribute( QString & , QString & ) {
42} 51}
diff --git a/noncore/settings/networksettings2/profile/profile_NN.h b/noncore/settings/networksettings2/profile/profile_NN.h
index 1f1ee2c..f1648f9 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.h
+++ b/noncore/settings/networksettings2/profile/profile_NN.h
@@ -19,9 +19,9 @@ public:
19 19
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21 virtual ANetNodeInstance * createInstance( void ); 21 virtual ANetNodeInstance * createInstance( void );
22 virtual const char ** needs( void ); 22 virtual const char ** needs( void );
23 virtual const char * provides( void ); 23 virtual const char ** provides( void );
24 24
25private: 25private:
26 26
27 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.cpp b/noncore/settings/networksettings2/profile/profile_NNI.cpp
index f0f0b97..a1e1254 100644
--- a/noncore/settings/networksettings2/profile/profile_NNI.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NNI.cpp
@@ -1,4 +1,5 @@
1#include <opie2/odebug.h>
1#include "profileedit.h" 2#include "profileedit.h"
2#include "profile_NNI.h" 3#include "profile_NNI.h"
3#include "profile_NN.h" 4#include "profile_NN.h"
4 5
@@ -49,27 +50,25 @@ void AProfile::commit( void ) {
49 if( GUI && GUI->commit( Data ) ) 50 if( GUI && GUI->commit( Data ) )
50 setModified( 1 ); 51 setModified( 1 );
51} 52}
52 53
53short AProfile::generateFileEmbedded( const QString & ID, 54short AProfile::generateFileEmbedded( SystemFile & SF,
54 const QString & Path,
55 QTextStream & TS,
56 long DevNr ) { 55 long DevNr ) {
57 56
58 short rvl, rvd; 57 short rvl, rvd;
59 58
60 rvl = 1; 59 rvl = 1;
61 60
62 if( ID == "interfaces" ) { 61 if( SF.name() == "interfaces" ) {
63 Log(("Generate Profile for %s\n", ID.latin1() )); 62 Log(("Generate Profile for %s\n", SF.name().latin1() ));
64 if( Data.TriggerVPN ) { 63 if( Data.TriggerVPN ) {
65 // this profile triggers VPN -> insert trigger 64 // this profile triggers VPN -> insert trigger
66 TS << " up networksettings2 --triggervpn" 65 SF << " up networksettings2 --triggervpn"
67 << endl; 66 << endl;
68 rvl = 0; 67 rvl = 0;
69 } 68 }
70 } 69 }
71 rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr ); 70 rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr );
72 return (rvd == 2 || rvl == 2 ) ? 2 : 71 return (rvd == 2 || rvl == 2 ) ? 2 :
73 (rvd == 0 || rvl == 0 ) ? 0 : 1; 72 (rvd == 0 || rvl == 0 ) ? 0 : 1;
74} 73}
75 74
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.h b/noncore/settings/networksettings2/profile/profile_NNI.h
index 957f4af..ccd746c 100644
--- a/noncore/settings/networksettings2/profile/profile_NNI.h
+++ b/noncore/settings/networksettings2/profile/profile_NNI.h
@@ -25,11 +25,9 @@ public :
25 25
26 virtual void * data( void ) 26 virtual void * data( void )
27 { return (void *)&Data; } 27 { return (void *)&Data; }
28 28
29 virtual short generateFileEmbedded( const QString & ID, 29 virtual short generateFileEmbedded( SystemFile & TS,
30 const QString & Path,
31 QTextStream & TS,
32 long DevNr ); 30 long DevNr );
33 31
34 const QString & description( void ) 32 const QString & description( void )
35 { return Data.Description; } 33 { return Data.Description; }
diff --git a/noncore/settings/networksettings2/profile/profiledata.h b/noncore/settings/networksettings2/profile/profiledata.h
index 246d50c..c9577e5 100644
--- a/noncore/settings/networksettings2/profile/profiledata.h
+++ b/noncore/settings/networksettings2/profile/profiledata.h
@@ -1,16 +1,17 @@
1#ifndef PROFILE_DATA_H 1#ifndef PROFILE_DATA_H
2#define PROFILE_DATA_H 2#define PROFILE_DATA_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5typedef struct ProfileData { 5class ProfileData {
6public :
6 QString Description; 7 QString Description;
7 // start up automatically 8 // start up automatically
8 bool Automatic; 9 bool Automatic;
9 // if started up automatically, ask user for confirmation 10 // if started up automatically, ask user for confirmation
10 bool Confirm; 11 bool Confirm;
11 // Do not bring this connection up 12 // Do not bring this connection up
12 bool Disabled; 13 bool Disabled;
13 bool TriggerVPN; 14 bool TriggerVPN;
14} ProfileData_t; 15} ;
15 16
16#endif 17#endif
diff --git a/noncore/settings/networksettings2/profile/profileedit.cpp b/noncore/settings/networksettings2/profile/profileedit.cpp
index 87e503e..88aab15 100644
--- a/noncore/settings/networksettings2/profile/profileedit.cpp
+++ b/noncore/settings/networksettings2/profile/profileedit.cpp
@@ -4,9 +4,9 @@
4#include <qmultilineedit.h> 4#include <qmultilineedit.h>
5#include <qcheckbox.h> 5#include <qcheckbox.h>
6 6
7#include <GUIUtils.h> 7#include <GUIUtils.h>
8#include <asdevice.h> 8#include <netnode.h>
9#include <resources.h> 9#include <resources.h>
10 10
11#include "profileedit.h" 11#include "profileedit.h"
12 12
@@ -15,9 +15,9 @@ ProfileEdit::ProfileEdit( QWidget * Parent, ANetNodeInstance * TNNI ) :
15 InterfaceInfo * II; 15 InterfaceInfo * II;
16 16
17 NNI = TNNI; 17 NNI = TNNI;
18 Dev = NNI->runtime()->device(); 18 Dev = NNI->runtime()->device();
19 if( ( II = Dev->assignedInterface() ) ) { 19 if( ( II = NNI->connection()->assignedInterface() ) ) {
20 20
21 Refresh_CB->setEnabled( TRUE ); 21 Refresh_CB->setEnabled( TRUE );
22 Snd_GB->setEnabled( TRUE ); 22 Snd_GB->setEnabled( TRUE );
23 Rcv_GB->setEnabled( TRUE ); 23 Rcv_GB->setEnabled( TRUE );
@@ -54,18 +54,18 @@ ProfileEdit::ProfileEdit( QWidget * Parent, ANetNodeInstance * TNNI ) :
54QString ProfileEdit::acceptable( void ) { 54QString ProfileEdit::acceptable( void ) {
55 return QString(); 55 return QString();
56} 56}
57 57
58void ProfileEdit::showData( ProfileData_t & Data ) { 58void ProfileEdit::showData( ProfileData & Data ) {
59 Description_LE->setText( Data.Description ); 59 Description_LE->setText( Data.Description );
60 Automatic_CB->setChecked( Data.Automatic ); 60 Automatic_CB->setChecked( Data.Automatic );
61 TriggersVPN_CB->setChecked( Data.TriggerVPN ); 61 TriggersVPN_CB->setChecked( Data.TriggerVPN );
62 Confirm_CB->setChecked( Data.Confirm ); 62 Confirm_CB->setChecked( Data.Confirm );
63 Disabled_CB->setChecked( Data.Disabled ); 63 Disabled_CB->setChecked( Data.Disabled );
64} 64}
65 65
66 66
67bool ProfileEdit::commit( ProfileData_t & Data ) { 67bool ProfileEdit::commit( ProfileData & Data ) {
68 bool SM = 0; 68 bool SM = 0;
69 TXTM( Data.Description, Description_LE, SM ); 69 TXTM( Data.Description, Description_LE, SM );
70 70
71 CBM( Data.Automatic, Automatic_CB, SM ); 71 CBM( Data.Automatic, Automatic_CB, SM );
@@ -76,9 +76,9 @@ bool ProfileEdit::commit( ProfileData_t & Data ) {
76 return SM; 76 return SM;
77} 77}
78 78
79void ProfileEdit::SLOT_Refresh( void ) { 79void ProfileEdit::SLOT_Refresh( void ) {
80 InterfaceInfo * II = Dev->assignedInterface(); 80 InterfaceInfo * II = NNI->connection()->assignedInterface();
81 NSResources->system().refreshStatistics( *II ); 81 NSResources->system().refreshStatistics( *II );
82 RcvBytes_LBL->setText( II->RcvBytes ); 82 RcvBytes_LBL->setText( II->RcvBytes );
83 SndBytes_LBL->setText( II->SndBytes ); 83 SndBytes_LBL->setText( II->SndBytes );
84 RcvErrors_LBL->setText( II->RcvErrors ); 84 RcvErrors_LBL->setText( II->RcvErrors );
diff --git a/noncore/settings/networksettings2/profile/profileedit.h b/noncore/settings/networksettings2/profile/profileedit.h
index b186b58..9cde845 100644
--- a/noncore/settings/networksettings2/profile/profileedit.h
+++ b/noncore/settings/networksettings2/profile/profileedit.h
@@ -2,9 +2,9 @@
2#include "profileGUI.h" 2#include "profileGUI.h"
3 3
4#include <qtimer.h> 4#include <qtimer.h>
5class ANetNodeInstance; 5class ANetNodeInstance;
6class AsDevice; 6class RuntimeInfo;
7 7
8class ProfileEdit : public ProfileGUI { 8class ProfileEdit : public ProfileGUI {
9 9
10 Q_OBJECT 10 Q_OBJECT
@@ -12,10 +12,10 @@ class ProfileEdit : public ProfileGUI {
12public : 12public :
13 13
14 ProfileEdit( QWidget * parent, ANetNodeInstance * NNI ); 14 ProfileEdit( QWidget * parent, ANetNodeInstance * NNI );
15 QString acceptable( void ); 15 QString acceptable( void );
16 bool commit( ProfileData_t & Data ); 16 bool commit( ProfileData & Data );
17 void showData( ProfileData_t & Data ); 17 void showData( ProfileData & Data );
18 18
19public slots : 19public slots :
20 20
21 void SLOT_AutoRefresh( bool ); 21 void SLOT_AutoRefresh( bool );
@@ -24,6 +24,6 @@ public slots :
24private : 24private :
25 25
26 QTimer RefreshTimer; 26 QTimer RefreshTimer;
27 ANetNodeInstance * NNI; 27 ANetNodeInstance * NNI;
28 AsDevice * Dev; 28 RuntimeInfo * Dev;
29}; 29};
diff --git a/noncore/settings/networksettings2/profile/profilerun.cpp b/noncore/settings/networksettings2/profile/profilerun.cpp
index 1a5b15b..ab57a00 100644
--- a/noncore/settings/networksettings2/profile/profilerun.cpp
+++ b/noncore/settings/networksettings2/profile/profilerun.cpp
@@ -1,67 +1,27 @@
1#include <resources.h> 1#include <resources.h>
2 2
3#include "profilerun.h" 3#include "profilerun.h"
4 4
5void ProfileRun::detectState( NodeCollection * NC ) { 5State_t ProfileRun::detectState( void ) {
6 if( Data->Disabled ) { 6 if( Data->Disabled ) {
7 Log(( "%s disabled\n", NC->name().latin1() )); 7 return Disabled;
8 NC->setCurrentState( Disabled ); 8 }
9 } else { 9 return Unknown;
10 Log(( "%s not disabled\n", NC->name().latin1() ));
11 // find next item in connection
12 // convert to runtime and ask to detect the state
13 netNode()->nextNode()->runtime()->detectState( NC );
14 }
15} 10}
16 11
17bool ProfileRun::setState( NodeCollection * NC, Action_t A, bool F ) { 12QString ProfileRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
18 ANetNodeInstance * NNNI; 13 owarn << "Profile " << Data->Disabled << oendl;
19 14 if( A == Disable ) {
20 NNNI = netNode()->nextNode(); 15 if( ! Data->Disabled ) {
21 switch ( A ) {
22 case Enable :
23 if( NC->currentState() == Disabled ) {
24 Data->Disabled = 0;
25 NC->setCurrentState( Off ); // at least
26 // ... but request deeper
27 NNNI->runtime()->detectState(NC);
28 }
29 return 1;
30 case Disable :
31 switch( NC->currentState() ) {
32 case IsUp :
33 case Available :
34 // bring Deactivate (will bring down)
35 if( ! NNNI->runtime()->setState(NC, Deactivate) )
36 return 0;
37 default :
38 break;
39 }
40 Data->Disabled = 1; 16 Data->Disabled = 1;
41 NC->setCurrentState( Disabled ); 17 NC->setModified( 1 );
42 return 1; 18 }
43 default : 19 } else if( A == Enable ) {
44 break; 20 if( Data->Disabled ) {
45 } 21 Data->Disabled = 0;
46 return NNNI->runtime()->setState(NC, A, F ); 22 NC->setModified( 1 );
47} 23 }
48
49bool ProfileRun::canSetState( State_t Curr, Action_t A ) {
50 RuntimeInfo * RI;
51 switch ( A ) {
52 case Enable :
53 case Disable :
54 // always possible
55 return 1;
56 default :
57 break;
58 } 24 }
59 RI = netNode()->nextNode()->runtime();
60 return ( Curr != Disabled ) ?
61 RI->canSetState(Curr, A) : 0;
62}
63 25
64bool ProfileRun::handlesInterface( const QString & S ) { 26 return QString();
65 // donno -> pass deeper
66 return netNode()->nextNode()->runtime()->handlesInterface(S);
67} 27}
diff --git a/noncore/settings/networksettings2/profile/profilerun.h b/noncore/settings/networksettings2/profile/profilerun.h
index 400b56c..2d48b15 100644
--- a/noncore/settings/networksettings2/profile/profilerun.h
+++ b/noncore/settings/networksettings2/profile/profilerun.h
@@ -1,33 +1,31 @@
1#ifndef PROFILERUN_H 1#ifndef PROFILERUN_H
2#define PROFILERUN_H 2#define PROFILERUN_H
3 3
4#include <asfullsetup.h> 4#include <netnode.h>
5#include "profiledata.h" 5#include "profiledata.h"
6 6
7class ProfileRun : public AsFullSetup { 7class ProfileRun : public RuntimeInfo {
8 8
9public : 9public :
10 10
11 ProfileRun( ANetNodeInstance * NNI, ProfileData & D ) : 11 ProfileRun( ANetNodeInstance * NNI, ProfileData & D ) :
12 AsFullSetup( NNI ) 12 RuntimeInfo( NNI )
13 { Data = &D; } 13 { Data = &D; }
14 14
15 void detectState( NodeCollection * NC ); 15 virtual RuntimeInfo * fullSetup( void )
16 bool setState( NodeCollection * NC, Action_t A, bool ); 16 { return this; }
17 bool canSetState( State_t Curr, Action_t A );
18
19 bool handlesInterface( const QString & I );
20
21 virtual const QString & description( void ) 17 virtual const QString & description( void )
22 { return Data->Description; } 18 { return Data->Description; }
23
24 virtual AsFullSetup * asFullSetup( void )
25 { return (AsFullSetup *)this; }
26
27 virtual bool triggersVPN( void ) 19 virtual bool triggersVPN( void )
28 { return Data->TriggerVPN; } 20 { return Data->TriggerVPN; }
29 21
22 State_t detectState( void );
23
24protected :
25
26 QString setMyState( NodeCollection * , Action_t, bool );
27
30private : 28private :
31 29
32 ProfileData * Data; 30 ProfileData * Data;
33 31
diff --git a/noncore/settings/networksettings2/usb/opie-networksettings2plugin-usb.control b/noncore/settings/networksettings2/usb/opie-networksettings2plugin-usb.control
index 8b8508c..ffb3012 100644
--- a/noncore/settings/networksettings2/usb/opie-networksettings2plugin-usb.control
+++ b/noncore/settings/networksettings2/usb/opie-networksettings2plugin-usb.control
@@ -1,5 +1,5 @@
1Package: opie-networksettingsplugin2-usb 1Package: opie-networksettings2plugin-usb
2Files: plugins/networksettings2/libusb.so* 2Files: plugins/networksettings2/libusb.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Wim Delvaux <wimpie@handhelds.org> 5Maintainer: Wim Delvaux <wimpie@handhelds.org>
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp
index 14c479a..bd9ae2b 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.cpp
+++ b/noncore/settings/networksettings2/usb/usb_NN.cpp
@@ -1,15 +1,23 @@
1#include <resources.h>
1#include "usb_NN.h" 2#include "usb_NN.h"
2#include "usb_NNI.h" 3#include "usb_NNI.h"
3 4
4static const char * USBNeeds[] = 5static const char * USBNeeds[] =
5 { 0 6 { 0
6 }; 7 };
7 8
9static const char * USBProvides[] =
10 { "device",
11 0
12 };
13
8/** 14/**
9 * Constructor, find all of the possible interfaces 15 * Constructor, find all of the possible interfaces
10 */ 16 */
11USBNetNode::USBNetNode() : ANetNode(tr("USB Cable Connect")) { 17USBNetNode::USBNetNode() : ANetNode(tr("USB Cable Connect")) {
18 NSResources->addSystemFile(
19 "interfaces", "/etc/network/interfaces", 1 );
12} 20}
13 21
14/** 22/**
15 * Delete any interfaces that we own. 23 * Delete any interfaces that we own.
@@ -32,10 +40,10 @@ ANetNodeInstance * USBNetNode::createInstance( void ) {
32const char ** USBNetNode::needs( void ) { 40const char ** USBNetNode::needs( void ) {
33 return USBNeeds; 41 return USBNeeds;
34} 42}
35 43
36const char * USBNetNode::provides( void ) { 44const char ** USBNetNode::provides( void ) {
37 return "device"; 45 return USBProvides;
38} 46}
39 47
40QString USBNetNode::genNic( long ) { 48QString USBNetNode::genNic( long ) {
41 return QString( "usbf" ); 49 return QString( "usbf" );
diff --git a/noncore/settings/networksettings2/usb/usb_NN.h b/noncore/settings/networksettings2/usb/usb_NN.h
index 73da15a..b825cec 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.h
+++ b/noncore/settings/networksettings2/usb/usb_NN.h
@@ -19,9 +19,9 @@ public:
19 19
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21 virtual ANetNodeInstance * createInstance( void ); 21 virtual ANetNodeInstance * createInstance( void );
22 virtual const char ** needs( void ); 22 virtual const char ** needs( void );
23 virtual const char * provides( void ); 23 virtual const char ** provides( void );
24 24
25 virtual QString genNic( long nr ); 25 virtual QString genNic( long nr );
26 26
27private: 27private:
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.cpp b/noncore/settings/networksettings2/usb/usb_NNI.cpp
index 50c6e8d..600b771 100644
--- a/noncore/settings/networksettings2/usb/usb_NNI.cpp
+++ b/noncore/settings/networksettings2/usb/usb_NNI.cpp
@@ -31,30 +31,28 @@ void AUSB::commit( void ) {
31 setModified( 1 ); 31 setModified( 1 );
32 } 32 }
33} 33}
34 34
35short AUSB::generateFileEmbedded( const QString & ID, 35short AUSB::generateFileEmbedded( SystemFile & SF,
36 const QString & Path,
37 QTextStream & TS,
38 long DevNr ) { 36 long DevNr ) {
39 37
40 QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); 38 QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
41 short rvl, rvd; 39 short rvl, rvd;
42 40
43 rvl = 1; 41 rvl = 1;
44 42
45 if( ID == "interfaces" ) { 43 if( SF.name() == "interfaces" ) {
46 Log(("Generate USB for %s\n", ID.latin1() )); 44 Log(("Generate USB for %s\n", SF.name().latin1() ));
47 // generate mapping stanza for this interface 45 // generate mapping stanza for this interface
48 TS << " pre-up " 46 SF << " pre-up "
49 << QPEApplication::qpeDir() 47 << QPEApplication::qpeDir()
50 << "bin/setmacaddress.sh " 48 << "bin/setmacaddress.sh "
51 << NIC 49 << NIC
52 << " || true" 50 << " || true"
53 << endl; 51 << endl;
54 rvl = 0; 52 rvl = 0;
55 } 53 }
56 rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr ); 54 rvd = ANetNodeInstance::generateFileEmbedded(SF, DevNr );
57 55
58 return (rvd == 2 || rvl == 2 ) ? 2 : 56 return (rvd == 2 || rvl == 2 ) ? 2 :
59 (rvd == 0 || rvl == 0 ) ? 0 : 1; 57 (rvd == 0 || rvl == 0 ) ? 0 : 1;
60 58
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.h b/noncore/settings/networksettings2/usb/usb_NNI.h
index fcdfd91..27e71ee 100644
--- a/noncore/settings/networksettings2/usb/usb_NNI.h
+++ b/noncore/settings/networksettings2/usb/usb_NNI.h
@@ -25,11 +25,9 @@ public :
25 25
26 virtual void * data( void ) 26 virtual void * data( void )
27 { return (void *)&Data; } 27 { return (void *)&Data; }
28 28
29 virtual short generateFileEmbedded( const QString & ID, 29 virtual short generateFileEmbedded( SystemFile & TS,
30 const QString & Path,
31 QTextStream & TS,
32 long DevNr ); 30 long DevNr );
33 31
34protected : 32protected :
35 33
diff --git a/noncore/settings/networksettings2/usb/usbdata.h b/noncore/settings/networksettings2/usb/usbdata.h
index c59f508..fa357b5 100644
--- a/noncore/settings/networksettings2/usb/usbdata.h
+++ b/noncore/settings/networksettings2/usb/usbdata.h
@@ -1,8 +1,9 @@
1#ifndef USB_DATA_H 1#ifndef USB_DATA_H
2#define USB_DATA_H 2#define USB_DATA_H
3 3
4typedef struct USBData { 4class USBData {
5public :
5 bool Fake; 6 bool Fake;
6} USBData_t; 7} ;
7 8
8#endif 9#endif
diff --git a/noncore/settings/networksettings2/usb/usbedit.cpp b/noncore/settings/networksettings2/usb/usbedit.cpp
index 153c497..cc96b96 100644
--- a/noncore/settings/networksettings2/usb/usbedit.cpp
+++ b/noncore/settings/networksettings2/usb/usbedit.cpp
@@ -8,10 +8,10 @@ USBEdit::USBEdit( QWidget * Parent ) : USBGUI( Parent ){
8QString USBEdit::acceptable( void ) { 8QString USBEdit::acceptable( void ) {
9 return QString(); 9 return QString();
10} 10}
11 11
12void USBEdit::showData( USBData_t & Data ) { 12void USBEdit::showData( USBData & Data ) {
13} 13}
14 14
15bool USBEdit::commit( USBData_t & Data ) { 15bool USBEdit::commit( USBData & Data ) {
16 return 1; 16 return 1;
17} 17}
diff --git a/noncore/settings/networksettings2/usb/usbedit.h b/noncore/settings/networksettings2/usb/usbedit.h
index 441f2f0..4179898 100644
--- a/noncore/settings/networksettings2/usb/usbedit.h
+++ b/noncore/settings/networksettings2/usb/usbedit.h
@@ -6,7 +6,7 @@ class USBEdit : public USBGUI {
6public : 6public :
7 7
8 USBEdit( QWidget * parent ); 8 USBEdit( QWidget * parent );
9 QString acceptable( void ); 9 QString acceptable( void );
10 bool commit( USBData_t & Data ); 10 bool commit( USBData & Data );
11 void showData( USBData_t & Data ); 11 void showData( USBData & Data );
12}; 12};
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp
index b8ac8a8..f8824e0 100644
--- a/noncore/settings/networksettings2/usb/usbrun.cpp
+++ b/noncore/settings/networksettings2/usb/usbrun.cpp
@@ -3,12 +3,13 @@
3#include <qtextstream.h> 3#include <qtextstream.h>
4#include <resources.h> 4#include <resources.h>
5#include "usbrun.h" 5#include "usbrun.h"
6 6
7void USBRun::detectState( NodeCollection * NC ) { 7State_t USBRun::detectState( void ) {
8 // unavailable : no card found 8 // unavailable : no card found
9 // available : card found and assigned to us or free 9 // available : card found and assigned to us or free
10 // up : card found and assigned to us and up 10 // up : card found and assigned to us and up
11 NodeCollection * NC = nodeCollection();
11 QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); 12 QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number());
12 System & Sys = NSResources->system(); 13 System & Sys = NSResources->system();
13 InterfaceInfo * Run; 14 InterfaceInfo * Run;
14 QFile F( S ); 15 QFile F( S );
@@ -26,29 +27,26 @@ void USBRun::detectState( NodeCollection * NC ) {
26 It.current(); 27 It.current();
27 ++It ) { 28 ++It ) {
28 Run = It.current(); 29 Run = It.current();
29 if( X == Run->Name ) { 30 if( X == Run->Name ) {
30 Run->assignNode( netNode() ); 31 NC->assignInterface( Run );
31 assignInterface( Run ); 32 return IsUp;
32 NC->setCurrentState( IsUp );
33 return;
34 } 33 }
35 } 34 }
36 } 35 }
37 } 36 }
38 37
39 Log(("Assigned %p\n", assignedInterface() )); 38 Log(("Assigned %p\n", NC->assignedInterface() ));
40 if( ( Run = assignedInterface() ) ) { 39 if( ( Run = NC->assignedInterface() ) ) {
41 // we already have an interface assigned -> still present ? 40 // we already have an interface assigned -> still present ?
42 if( ! Run->IsUp ) { 41 if( ! Run->IsUp ) {
43 // usb is still free -> keep assignment 42 // usb is still free -> keep assignment
44 NC->setCurrentState( Available ); 43 return Available;
45 return;
46 } // else interface is up but NOT us -> some other profile 44 } // else interface is up but NOT us -> some other profile
47 } 45 }
48 46
49 // nothing (valid) assigned to us 47 // nothing (valid) assigned to us
50 assignInterface( 0 ); 48 NC->assignInterface( 0 );
51 49
52 // find possible interface 50 // find possible interface
53 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 51 for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
54 It.current(); 52 It.current();
@@ -64,86 +62,18 @@ void USBRun::detectState( NodeCollection * NC ) {
64 if( handlesInterface( Run->Name ) && 62 if( handlesInterface( Run->Name ) &&
65 Run->CardType == ARPHRD_ETHER && 63 Run->CardType == ARPHRD_ETHER &&
66 ! Run->IsUp 64 ! Run->IsUp
67 ) { 65 ) {
68 Log(("Released(OFF)\n" ));
69 // proper type, and Not UP -> free 66 // proper type, and Not UP -> free
70 NC->setCurrentState( Off ); 67 return Off;
71 return;
72 } 68 }
73 } 69 }
74 // no free found
75 Log(("UNA\n" ));
76 70
77 NC->setCurrentState( Unavailable ); 71 return Unavailable;
78} 72}
79 73
80bool USBRun::setState( NodeCollection * NC, Action_t A, bool ) { 74QString USBRun::setMyState( NodeCollection *, Action_t , bool ) {
81 75 return QString();
82 // we only handle activate and deactivate
83 switch( A ) {
84 case Activate :
85 {
86 if( NC->currentState() != Off ) {
87 return 0;
88 }
89 InterfaceInfo * N = getInterface();
90 if( ! N ) {
91 // no interface available
92 NC->setCurrentState( Unavailable );
93 return 0;
94 }
95 // because we were OFF the interface
96 // we get back is NOT assigned
97 N->assignNode( netNode() );
98 assignInterface( N );
99 Log(("Assing %p\n", N ));
100 NC->setCurrentState( Available );
101 return 1;
102 }
103 case Deactivate :
104 if( NC->currentState() == IsUp ) {
105 // bring down first
106 if( ! connection()->setState( Down ) )
107 // could not ...
108 return 0;
109 } else if( NC->currentState() != Available ) {
110 return 1;
111 }
112 assignedInterface()->assignNode( 0 ); // release
113 assignInterface( 0 );
114 NC->setCurrentState( Off );
115 return 1;
116 default :
117 // FT
118 break;
119 }
120 return 0;
121}
122
123bool USBRun::canSetState( State_t Curr, Action_t A ) {
124 // we only handle up down activate and deactivate
125 switch( A ) {
126 case Activate :
127 { // at least available
128 if( Curr == Available ) {
129 return 1;
130 }
131 // or we can make one available
132 InterfaceInfo * N = getInterface();
133 if( ! N || N->assignedNode() != 0 ) {
134 // non available or assigned
135 return 0;
136 }
137 return 1;
138 }
139 case Deactivate :
140 return ( Curr >= Available );
141 default :
142 // FT
143 break;
144 }
145 return 0;
146} 76}
147 77
148// get interface that is free or assigned to us 78// get interface that is free or assigned to us
149InterfaceInfo * USBRun::getInterface( void ) { 79InterfaceInfo * USBRun::getInterface( void ) {
@@ -159,12 +89,12 @@ InterfaceInfo * USBRun::getInterface( void ) {
159 if( handlesInterface( Run->Name ) && 89 if( handlesInterface( Run->Name ) &&
160 Run->CardType == ARPHRD_ETHER 90 Run->CardType == ARPHRD_ETHER
161 ) { 91 ) {
162 // this is a USB card 92 // this is a USB card
163 if( Run->assignedNode() == netNode() ) { 93 if( Run->assignedConnection() == netNode()->connection() ) {
164 // assigned to us 94 // assigned to us
165 return Run; 95 return Run;
166 } else if( Run->assignedNode() == 0 ) { 96 } else if( Run->assignedConnection() == 0 ) {
167 // free 97 // free
168 best = Run; 98 best = Run;
169 } 99 }
170 } 100 }
@@ -175,4 +105,8 @@ InterfaceInfo * USBRun::getInterface( void ) {
175bool USBRun::handlesInterface( const QString & S ) { 105bool USBRun::handlesInterface( const QString & S ) {
176 return Pat.match( S ) >= 0; 106 return Pat.match( S ) >= 0;
177} 107}
178 108
109bool USBRun::handlesInterface( InterfaceInfo * I ) {
110 return handlesInterface( I->Name );
111}
112
diff --git a/noncore/settings/networksettings2/usb/usbrun.h b/noncore/settings/networksettings2/usb/usbrun.h
index 03e21ab..6ce4fa2 100644
--- a/noncore/settings/networksettings2/usb/usbrun.h
+++ b/noncore/settings/networksettings2/usb/usbrun.h
@@ -1,33 +1,32 @@
1#ifndef USBRUN_H 1#ifndef USBRUN_H
2#define USBRUN_H 2#define USBRUN_H
3 3
4#include <asdevice.h> 4#include <netnode.h>
5#include <qregexp.h> 5#include <qregexp.h>
6#include "usbdata.h" 6#include "usbdata.h"
7 7
8class USBRun : public AsDevice { 8class USBRun : public RuntimeInfo {
9 9
10public : 10public :
11 11
12 USBRun( ANetNodeInstance * NNI, 12 USBRun( ANetNodeInstance * NNI,
13 USBData & Data ) : 13 USBData & Data ) :
14 AsDevice( NNI ), 14 RuntimeInfo( NNI ),
15 Pat( "usb[0-9abcdef]" ) 15 Pat( "usb[0-9abcdef]" ) {
16 { } 16 }
17 17
18 virtual AsDevice * device( void ) 18 virtual RuntimeInfo * device( void )
19 { return (AsDevice *)this; } 19 { return this; }
20 20
21 virtual AsDevice * asDevice( void ) 21 bool handlesInterface( const QString & I );
22 { return (AsDevice *)this; } 22 bool handlesInterface( InterfaceInfo * );
23protected :
24 23
25 void detectState( NodeCollection * ); 24 State_t detectState( void );
26 bool setState( NodeCollection * , Action_t A, bool );
27 bool canSetState( State_t , Action_t A );
28 25
29 bool handlesInterface( const QString & I ); 26protected :
27
28 QString setMyState( NodeCollection * , Action_t, bool );
30 29
31private : 30private :
32 31
33 InterfaceInfo * getInterface( void ); 32 InterfaceInfo * getInterface( void );
diff --git a/noncore/settings/networksettings2/vpn/opie-networksettings2plugin-vpn.control b/noncore/settings/networksettings2/vpn/opie-networksettings2plugin-vpn.control
index b346c5d..08f131f 100644
--- a/noncore/settings/networksettings2/vpn/opie-networksettings2plugin-vpn.control
+++ b/noncore/settings/networksettings2/vpn/opie-networksettings2plugin-vpn.control
@@ -1,5 +1,5 @@
1Package: opie-networksettingsplugin2-vpn 1Package: opie-networksettings2plugin-vpn
2Files: plugins/networksettings2/libvpn.so* 2Files: plugins/networksettings2/libvpn.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Wim Delvaux <wimpie@handhelds.org> 5Maintainer: Wim Delvaux <wimpie@handhelds.org>
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
index 9d3b6e7..23ec04a 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp
+++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
@@ -4,8 +4,12 @@
4static const char * VPNNeeds[] = 4static const char * VPNNeeds[] =
5 { 0 5 { 0
6 }; 6 };
7 7
8static const char * VPNProvides[] =
9 { "connection",
10 0
11 };
8/** 12/**
9 * Constructor, find all of the possible interfaces 13 * Constructor, find all of the possible interfaces
10 */ 14 */
11VPNNetNode::VPNNetNode() : ANetNode(tr("VPN Connection")) { 15VPNNetNode::VPNNetNode() : ANetNode(tr("VPN Connection")) {
@@ -32,10 +36,10 @@ ANetNodeInstance * VPNNetNode::createInstance( void ) {
32const char ** VPNNetNode::needs( void ) { 36const char ** VPNNetNode::needs( void ) {
33 return VPNNeeds; 37 return VPNNeeds;
34} 38}
35 39
36const char * VPNNetNode::provides( void ) { 40const char ** VPNNetNode::provides( void ) {
37 return "connection"; 41 return VPNProvides;
38} 42}
39 43
40void VPNNetNode::setSpecificAttribute( QString & , QString & ) { 44void VPNNetNode::setSpecificAttribute( QString & , QString & ) {
41} 45}
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.h b/noncore/settings/networksettings2/vpn/vpn_NN.h
index 3c7b5e0..c2e43d4 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NN.h
+++ b/noncore/settings/networksettings2/vpn/vpn_NN.h
@@ -19,9 +19,9 @@ public:
19 19
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21 virtual ANetNodeInstance * createInstance( void ); 21 virtual ANetNodeInstance * createInstance( void );
22 virtual const char ** needs( void ); 22 virtual const char ** needs( void );
23 virtual const char * provides( void ); 23 virtual const char ** provides( void );
24 24
25private: 25private:
26 26
27 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
diff --git a/noncore/settings/networksettings2/vpn/vpndata.h b/noncore/settings/networksettings2/vpn/vpndata.h
index 5c986aa..ee88bc4 100644
--- a/noncore/settings/networksettings2/vpn/vpndata.h
+++ b/noncore/settings/networksettings2/vpn/vpndata.h
@@ -1,16 +1,17 @@
1#ifndef VPN_DATA_H 1#ifndef VPN_DATA_H
2#define VPN_DATA_H 2#define VPN_DATA_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5typedef struct VPNData { 5class VPNData {
6public :
6 QString Device; 7 QString Device;
7 QString LockFile; 8 QString LockFile;
8 long Speed; 9 long Speed;
9 short Parity; 10 short Parity;
10 short DataBits; 11 short DataBits;
11 short StopBits; 12 short StopBits;
12 bool HardwareControl; 13 bool HardwareControl;
13 bool SoftwareControl; 14 bool SoftwareControl;
14} VPNData_t; 15} ;
15 16
16#endif 17#endif
diff --git a/noncore/settings/networksettings2/vpn/vpnedit.cpp b/noncore/settings/networksettings2/vpn/vpnedit.cpp
index f336394..8445757 100644
--- a/noncore/settings/networksettings2/vpn/vpnedit.cpp
+++ b/noncore/settings/networksettings2/vpn/vpnedit.cpp
@@ -9,10 +9,10 @@ VPNEdit::VPNEdit( QWidget * Parent ) : VPNGUI( Parent ){
9QString VPNEdit::acceptable( void ) { 9QString VPNEdit::acceptable( void ) {
10 return QString(); 10 return QString();
11} 11}
12 12
13void VPNEdit::showData( VPNData_t & Data ) { 13void VPNEdit::showData( VPNData & Data ) {
14} 14}
15 15
16bool VPNEdit::commit( VPNData_t & Data ) { 16bool VPNEdit::commit( VPNData & Data ) {
17 return 0; 17 return 0;
18} 18}
diff --git a/noncore/settings/networksettings2/vpn/vpnedit.h b/noncore/settings/networksettings2/vpn/vpnedit.h
index 76480cd..156bcc5 100644
--- a/noncore/settings/networksettings2/vpn/vpnedit.h
+++ b/noncore/settings/networksettings2/vpn/vpnedit.h
@@ -6,7 +6,7 @@ class VPNEdit : public VPNGUI {
6public : 6public :
7 7
8 VPNEdit( QWidget * parent ); 8 VPNEdit( QWidget * parent );
9 QString acceptable( void ); 9 QString acceptable( void );
10 bool commit( VPNData_t & Data ); 10 bool commit( VPNData & Data );
11 void showData( VPNData_t & Data ); 11 void showData( VPNData & Data );
12}; 12};
diff --git a/noncore/settings/networksettings2/vpn/vpnrun.cpp b/noncore/settings/networksettings2/vpn/vpnrun.cpp
index ab2966c..64728aa 100644
--- a/noncore/settings/networksettings2/vpn/vpnrun.cpp
+++ b/noncore/settings/networksettings2/vpn/vpnrun.cpp
@@ -1,6 +1 @@
1#include "vpnrun.h" #include "vpnrun.h"
2
3bool VPNRun::handlesInterface( const QString & ) {
4 // to be figured out
5 return 0;
6}
diff --git a/noncore/settings/networksettings2/vpn/vpnrun.h b/noncore/settings/networksettings2/vpn/vpnrun.h
index c19b609..9a55625 100644
--- a/noncore/settings/networksettings2/vpn/vpnrun.h
+++ b/noncore/settings/networksettings2/vpn/vpnrun.h
@@ -1,32 +1,27 @@
1#ifndef VPNRUN_H 1#ifndef VPNRUN_H
2#define VPNRUN_H 2#define VPNRUN_H
3 3
4#include <asconnection.h> 4#include <netnode.h>
5#include "vpndata.h" 5#include "vpndata.h"
6 6
7class VPNRun : public AsConnection { 7class VPNRun : public RuntimeInfo {
8 8
9public : 9public :
10 10
11 VPNRun( ANetNodeInstance * NNI, VPNData & Data ) : 11 VPNRun( ANetNodeInstance * NNI, VPNData & Data ) :
12 AsConnection( NNI ) 12 RuntimeInfo( NNI )
13 { } 13 { }
14 14
15 virtual AsConnection * asConnection( void ) 15 virtual RuntimeInfo * connection( void )
16 { return (AsConnection *)this; } 16 { return this; }
17protected :
18
19 void detectState( NodeCollection * )
20 { }
21 17
22 bool setState( NodeCollection *, Action_t, bool ) 18 State_t detectState( void )
23 { return 0; } 19 { return Unknown; }
24 20
25 bool canSetState( State_t, Action_t ) 21protected :
26 { return 0; }
27
28 bool handlesInterface( const QString & I );
29 22
23 QString setMyState( NodeCollection * , Action_t, bool )
24 { return QString(); }
30}; 25};
31 26
32#endif 27#endif
diff --git a/noncore/settings/networksettings2/wlan/opie-networksettings2plugin-wlan.control b/noncore/settings/networksettings2/wlan/opie-networksettings2plugin-wlan.control
index 14afd21..90f195a 100644
--- a/noncore/settings/networksettings2/wlan/opie-networksettings2plugin-wlan.control
+++ b/noncore/settings/networksettings2/wlan/opie-networksettings2plugin-wlan.control
@@ -1,5 +1,5 @@
1Package: opie-networksettingsplugin2-wlan 1Package: opie-networksettings2plugin-wlan
2Files: plugins/networksettings2/libwlan.so* 2Files: plugins/networksettings2/libwlan.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Wim Delvaux <wimpie@handhelds.org> 5Maintainer: Wim Delvaux <wimpie@handhelds.org>
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.cpp b/noncore/settings/networksettings2/wlan/wlan_NN.cpp
index e4c3f60..36a5c33 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NN.cpp
+++ b/noncore/settings/networksettings2/wlan/wlan_NN.cpp
@@ -1,15 +1,23 @@
1#include <resources.h>
1#include "wlan_NN.h" 2#include "wlan_NN.h"
2#include "wlan_NNI.h" 3#include "wlan_NNI.h"
3 4
4static const char * WLanNeeds[] = 5static const char * WLanNeeds[] =
5 { 0 6 { 0
6 }; 7 };
7 8
9static const char * WLanProvides[] =
10 { "device",
11 0
12 };
13
8/** 14/**
9 * Constructor, find all of the possible interfaces 15 * Constructor, find all of the possible interfaces
10 */ 16 */
11WLanNetNode::WLanNetNode() : ANetNode(tr("WLan Device")) { 17WLanNetNode::WLanNetNode() : ANetNode(tr("WLan Device")) {
18 NSResources->addSystemFile(
19 "interfaces", "/etc/network/interfaces", 1 );
12 InstanceCount = 2; 20 InstanceCount = 2;
13} 21}
14 22
15/** 23/**
@@ -33,10 +41,10 @@ ANetNodeInstance * WLanNetNode::createInstance( void ) {
33const char ** WLanNetNode::needs( void ) { 41const char ** WLanNetNode::needs( void ) {
34 return WLanNeeds; 42 return WLanNeeds;
35} 43}
36 44
37const char * WLanNetNode::provides( void ) { 45const char ** WLanNetNode::provides( void ) {
38 return "device"; 46 return WLanProvides;
39} 47}
40 48
41QString WLanNetNode::genNic( long nr ) { 49QString WLanNetNode::genNic( long nr ) {
42 QString S; 50 QString S;
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.h b/noncore/settings/networksettings2/wlan/wlan_NN.h
index c13c05c..4bffd3d 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NN.h
+++ b/noncore/settings/networksettings2/wlan/wlan_NN.h
@@ -19,9 +19,9 @@ public:
19 19
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21 virtual ANetNodeInstance * createInstance( void ); 21 virtual ANetNodeInstance * createInstance( void );
22 virtual const char ** needs( void ); 22 virtual const char ** needs( void );
23 virtual const char * provides( void ); 23 virtual const char ** provides( void );
24 24
25 virtual long instanceCount( void ) 25 virtual long instanceCount( void )
26 { return InstanceCount; } 26 { return InstanceCount; }
27 virtual QString genNic( long ); 27 virtual QString genNic( long );
diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp
index 0e4fc4c..d5b1014 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp
+++ b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp
@@ -78,20 +78,18 @@ void AWLan::commit( void ) {
78 if( GUI && GUI->commit( Data ) ) 78 if( GUI && GUI->commit( Data ) )
79 setModified( 1 ); 79 setModified( 1 );
80} 80}
81 81
82short AWLan::generateFileEmbedded( const QString & ID, 82short AWLan::generateFileEmbedded( SystemFile & SF,
83 const QString & Path,
84 QTextStream & TS,
85 long DevNr ) { 83 long DevNr ) {
86 84
87 short rvl, rvd; 85 short rvl, rvd;
88 86
89 rvl = 1; 87 rvl = 1;
90 88
91 if( ID == "interfaces" ) { 89 if( SF.name() == "interfaces" ) {
92 Log(("Generate WLanNNI for %s\n", ID.latin1() )); 90 Log(("Generate WLanNNI for %s\n", SF.name().latin1() ));
93 TS << " wireless_essid \"" 91 SF << " wireless_essid \""
94 << Data.ESSID 92 << Data.ESSID
95 << "\"" 93 << "\""
96 << endl; 94 << endl;
97 95
@@ -99,14 +97,14 @@ short AWLan::generateFileEmbedded( const QString & ID,
99 if( Data.NodeName == tr("<UseHostName>") ) { 97 if( Data.NodeName == tr("<UseHostName>") ) {
100 char Buf[100]; 98 char Buf[100];
101 if( gethostname(Buf, sizeof(Buf) ) == 0 ) { 99 if( gethostname(Buf, sizeof(Buf) ) == 0 ) {
102 Buf[99] = '\0'; // just to make sure 100 Buf[99] = '\0'; // just to make sure
103 TS << " wireless_nick " 101 SF << " wireless_nick "
104 << Buf 102 << Buf
105 << endl; 103 << endl;
106 } 104 }
107 } else { 105 } else {
108 TS << " wireless_nick \"" 106 SF << " wireless_nick \""
109 << Data.NodeName 107 << Data.NodeName
110 << "\"" 108 << "\""
111 << endl; 109 << endl;
112 } 110 }
@@ -123,28 +121,28 @@ short AWLan::generateFileEmbedded( const QString & ID,
123 M = "Ad-Hoc"; 121 M = "Ad-Hoc";
124 break; 122 break;
125 } 123 }
126 124
127 TS << " wireless_mode " 125 SF << " wireless_mode "
128 << M 126 << M
129 << endl; 127 << endl;
130 if( Data.Encrypted ) { 128 if( Data.Encrypted ) {
131 for( int i = 0; i < 4; i ++ ) { 129 for( int i = 0; i < 4; i ++ ) {
132 if( ! Data.Key[i].isEmpty() ) { 130 if( ! Data.Key[i].isEmpty() ) {
133 TS << " wireless_key" 131 SF << " wireless_key"
134 << i 132 << i
135 << " " 133 << " "
136 << Data.Key[i] 134 << Data.Key[i]
137 << endl; 135 << endl;
138 } 136 }
139 } 137 }
140 TS << " wireless_keymode " 138 SF << " wireless_keymode "
141 << ((Data.AcceptNonEncrypted) ? "open" : "restricted") 139 << ((Data.AcceptNonEncrypted) ? "open" : "restricted")
142 << endl; 140 << endl;
143 } 141 }
144 rvl = 0; 142 rvl = 0;
145 } 143 }
146 rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr); 144 rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr);
147 145
148 return (rvd == 2 || rvl == 2 ) ? 2 : 146 return (rvd == 2 || rvl == 2 ) ? 2 :
149 (rvd == 0 || rvl == 0 ) ? 0 : 1; 147 (rvd == 0 || rvl == 0 ) ? 0 : 1;
150} 148}
diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.h b/noncore/settings/networksettings2/wlan/wlan_NNI.h
index a9be65f..e3251c7 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NNI.h
+++ b/noncore/settings/networksettings2/wlan/wlan_NNI.h
@@ -25,11 +25,9 @@ public :
25 25
26 virtual void * data( void ) 26 virtual void * data( void )
27 { return (void *)&Data; } 27 { return (void *)&Data; }
28 28
29 virtual short generateFileEmbedded( const QString & ID, 29 virtual short generateFileEmbedded( SystemFile & Sf,
30 const QString & Path,
31 QTextStream & TS,
32 long DevNr ); 30 long DevNr );
33 31
34protected : 32protected :
35 33
diff --git a/noncore/settings/networksettings2/wlan/wlandata.h b/noncore/settings/networksettings2/wlan/wlandata.h
index 36990a9..f3cc1ab 100644
--- a/noncore/settings/networksettings2/wlan/wlandata.h
+++ b/noncore/settings/networksettings2/wlan/wlandata.h
@@ -1,16 +1,17 @@
1#ifndef WLAN_DATA_H 1#ifndef WLAN_DATA_H
2#define WLAN_DATA_H 2#define WLAN_DATA_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5typedef struct WLanData { 5class WLanData {
6public :
6 QString ESSID; 7 QString ESSID;
7 QString NodeName; 8 QString NodeName;
8 short Mode; 9 short Mode;
9 bool SpecificAP; 10 bool SpecificAP;
10 QString APMac; 11 QString APMac;
11 bool Encrypted; 12 bool Encrypted;
12 QString Key[4]; 13 QString Key[4];
13 bool AcceptNonEncrypted; 14 bool AcceptNonEncrypted;
14} WLanData_t; 15} ;
15 16
16#endif 17#endif
diff --git a/noncore/settings/networksettings2/wlan/wlanedit.cpp b/noncore/settings/networksettings2/wlan/wlanedit.cpp
index 8d3979e..74174bf 100644
--- a/noncore/settings/networksettings2/wlan/wlanedit.cpp
+++ b/noncore/settings/networksettings2/wlan/wlanedit.cpp
@@ -19,9 +19,9 @@ WLanEdit::WLanEdit( QWidget * Parent, ANetNodeInstance * TNNI ) :
19 19
20 NNI = TNNI; 20 NNI = TNNI;
21 Dev = NNI->runtime()->device(); 21 Dev = NNI->runtime()->device();
22 WE = 0; 22 WE = 0;
23 if( ( II = Dev->assignedInterface() ) ) { 23 if( ( II = NNI->connection()->assignedInterface() ) ) {
24 // show data 24 // show data
25 WE = new WExtensions( II->Name ); 25 WE = new WExtensions( II->Name );
26 26
27 if( WE->doesHaveWirelessExtensions() ) { 27 if( WE->doesHaveWirelessExtensions() ) {
@@ -60,9 +60,9 @@ QString WLanEdit::acceptable( void ) {
60 } 60 }
61 return QString(); 61 return QString();
62} 62}
63 63
64void WLanEdit::showData( WLanData_t & Data ) { 64void WLanEdit::showData( WLanData & Data ) {
65 Mode_CB->setCurrentItem( Data.Mode ); 65 Mode_CB->setCurrentItem( Data.Mode );
66 ESSID_LE->setText( Data.ESSID ); 66 ESSID_LE->setText( Data.ESSID );
67 NodeName_LE->setText( Data.NodeName ); 67 NodeName_LE->setText( Data.NodeName );
68 SpecifyAP_CB->setChecked( Data.SpecificAP ); 68 SpecifyAP_CB->setChecked( Data.SpecificAP );
@@ -75,9 +75,9 @@ void WLanEdit::showData( WLanData_t & Data ) {
75 Key3_LE->setText( Data.Key[2] ); 75 Key3_LE->setText( Data.Key[2] );
76 Key4_LE->setText( Data.Key[3] ); 76 Key4_LE->setText( Data.Key[3] );
77} 77}
78 78
79bool WLanEdit::commit( WLanData_t & Data ) { 79bool WLanEdit::commit( WLanData & Data ) {
80 bool SM = 0; 80 bool SM = 0;
81 81
82 TXTM( Data.ESSID, ESSID_LE, SM ); 82 TXTM( Data.ESSID, ESSID_LE, SM );
83 TXTM( Data.NodeName, NodeName_LE, SM ); 83 TXTM( Data.NodeName, NodeName_LE, SM );
diff --git a/noncore/settings/networksettings2/wlan/wlanedit.h b/noncore/settings/networksettings2/wlan/wlanedit.h
index e550c14..8f219d9 100644
--- a/noncore/settings/networksettings2/wlan/wlanedit.h
+++ b/noncore/settings/networksettings2/wlan/wlanedit.h
@@ -3,9 +3,9 @@
3#include "wlandata.h" 3#include "wlandata.h"
4#include "wlanGUI.h" 4#include "wlanGUI.h"
5 5
6class ANetNodeInstance; 6class ANetNodeInstance;
7class AsDevice; 7class RuntimeInfo;
8class WExtensions; 8class WExtensions;
9 9
10class WLanEdit : public WLanGUI { 10class WLanEdit : public WLanGUI {
11 11
@@ -13,10 +13,10 @@ public :
13 13
14 WLanEdit( QWidget * parent, ANetNodeInstance * NNI ); 14 WLanEdit( QWidget * parent, ANetNodeInstance * NNI );
15 ~WLanEdit( void ); 15 ~WLanEdit( void );
16 QString acceptable( void ); 16 QString acceptable( void );
17 void showData( WLanData_t & Data ); 17 void showData( WLanData & Data );
18 bool commit( WLanData_t & Data ); 18 bool commit( WLanData & Data );
19 19
20public slots : 20public slots :
21 21
22 void SLOT_AutoRefresh( bool ); 22 void SLOT_AutoRefresh( bool );
@@ -24,9 +24,9 @@ public slots :
24 24
25private : 25private :
26 26
27 ANetNodeInstance * NNI; 27 ANetNodeInstance * NNI;
28 AsDevice * Dev; 28 RuntimeInfo * Dev;
29 QTimer RefreshTimer; 29 QTimer RefreshTimer;
30 WExtensions * WE; 30 WExtensions * WE;
31 31
32}; 32};
diff --git a/noncore/settings/networksettings2/wlan/wlanrun.cpp b/noncore/settings/networksettings2/wlan/wlanrun.cpp
index 3f1d4a9..fe49c4e 100644
--- a/noncore/settings/networksettings2/wlan/wlanrun.cpp
+++ b/noncore/settings/networksettings2/wlan/wlanrun.cpp
@@ -4,14 +4,15 @@
4#include <qstringlist.h> 4#include <qstringlist.h>
5#include <resources.h> 5#include <resources.h>
6#include "wlanrun.h" 6#include "wlanrun.h"
7 7
8void WLanRun::detectState( NodeCollection * NC ) { 8State_t WLanRun::detectState( void ) {
9 9
10 // unavailable : no card found 10 // unavailable : no card found
11 // available : card found and assigned to us or free 11 // available : card found and assigned to us or free
12 // up : card found and assigned to us and up 12 // up : card found and assigned to us and up
13 13
14 NodeCollection * NC = nodeCollection();
14 QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); 15 QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number());
15 System & Sys = NSResources->system(); 16 System & Sys = NSResources->system();
16 InterfaceInfo * Run; 17 InterfaceInfo * Run;
17 18
@@ -28,28 +29,25 @@ void WLanRun::detectState( NodeCollection * NC ) {
28 It.current(); 29 It.current();
29 ++It ) { 30 ++It ) {
30 Run = It.current(); 31 Run = It.current();
31 if( X == Run->Name ) { 32 if( X == Run->Name ) {
32 Run->assignNode( netNode() ); 33 NC->assignInterface( Run );
33 assignInterface( Run ); 34 return IsUp;
34 NC->setCurrentState( IsUp );
35 return;
36 } 35 }
37 } 36 }
38 } 37 }
39 } 38 }
40 39
41 if( ( Run = assignedInterface() ) ) { 40 if( ( Run = NC->assignedInterface() ) ) {
42 // we already have an interface assigned -> still present ? 41 // we already have an interface assigned -> still present ?
43 if( ! Run->IsUp ) { 42 if( ! Run->IsUp ) {
44 // usb is still free -> keep assignment 43 // usb is still free -> keep assignment
45 NC->setCurrentState( Available ); 44 return Available;
46 return;
47 } // else interface is up but NOT us -> some other profile 45 } // else interface is up but NOT us -> some other profile
48 } 46 }
49 47
50 // nothing (valid) assigned to us 48 // nothing (valid) assigned to us
51 assignInterface( 0 ); 49 NC->assignInterface( 0 );
52 50
53 // find possible interface 51 // find possible interface
54 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 52 for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
55 It.current(); 53 It.current();
@@ -63,83 +61,20 @@ void WLanRun::detectState( NodeCollection * NC ) {
63 ) && 61 ) &&
64 ! Run->IsUp 62 ! Run->IsUp
65 ) { 63 ) {
66 // proper type, and Not UP -> free 64 // proper type, and Not UP -> free
67 NC->setCurrentState( Off ); 65 return Off;
68 return;
69 } 66 }
70 } 67 }
71 // no free found
72 68
73 NC->setCurrentState( Unavailable ); 69 return Unavailable;
74 70
75} 71}
76 72
77bool WLanRun::setState( NodeCollection * NC, Action_t A, bool ) { 73QString WLanRun::setMyState( NodeCollection * , Action_t , bool ) {
78 74
79 // we only handle activate and deactivate 75 // we only handle activate and deactivate
80 switch( A ) { 76 return QString();
81 case Activate :
82 {
83 if( NC->currentState() != Off ) {
84 return 0;
85 }
86 InterfaceInfo * N = getInterface();
87 if( ! N ) {
88 // no interface available
89 NC->setCurrentState( Unavailable );
90 return 0;
91 }
92 // because we were OFF the interface
93 // we get back is NOT assigned
94 N->assignNode( netNode() );
95 assignInterface( N );
96 NC->setCurrentState( Available );
97 return 1;
98 }
99 case Deactivate :
100 if( NC->currentState() == IsUp ) {
101 // bring down first
102 if( ! connection()->setState( Down ) )
103 // could not ...
104 return 0;
105 } else if( NC->currentState() != Available ) {
106 return 1;
107 }
108 assignedInterface()->assignNode( 0 ); // release
109 assignInterface( 0 );
110 NC->setCurrentState( Off );
111 return 1;
112 default :
113 // FT
114 break;
115 }
116 return 0;
117}
118
119bool WLanRun::canSetState( State_t Curr, Action_t A ) {
120 // we only handle up down activate and deactivate
121 switch( A ) {
122 case Activate :
123 { // at least available
124 if( Curr == Available ) {
125 return 1;
126 }
127 // or we can make one available
128 InterfaceInfo * N = getInterface();
129 if( ! N || N->assignedNode() != 0 ) {
130 // non available or assigned
131 return 0;
132 }
133 return 1;
134 }
135 case Deactivate :
136 return ( Curr >= Available );
137 default :
138 // FT
139 break;
140 }
141 return 0;
142} 77}
143 78
144// get interface that is free or assigned to us 79// get interface that is free or assigned to us
145InterfaceInfo * WLanRun::getInterface( void ) { 80InterfaceInfo * WLanRun::getInterface( void ) {
@@ -158,12 +93,12 @@ InterfaceInfo * WLanRun::getInterface( void ) {
158#endif 93#endif
159 ) 94 )
160 ) { 95 ) {
161 // this is a LAN card 96 // this is a LAN card
162 if( Run->assignedNode() == netNode() ) { 97 if( Run->assignedConnection() == netNode()->connection() ) {
163 // assigned to us 98 // assigned to us
164 return Run; 99 return Run;
165 } else if( Run->assignedNode() == 0 ) { 100 } else if( Run->assignedConnection() == 0 ) {
166 // free 101 // free
167 best = Run; 102 best = Run;
168 } 103 }
169 } 104 }
diff --git a/noncore/settings/networksettings2/wlan/wlanrun.h b/noncore/settings/networksettings2/wlan/wlanrun.h
index 25d5b96..fd325d4 100644
--- a/noncore/settings/networksettings2/wlan/wlanrun.h
+++ b/noncore/settings/networksettings2/wlan/wlanrun.h
@@ -1,33 +1,32 @@
1#ifndef WLANRUN_H 1#ifndef WLANRUN_H
2#define WLANRUN_H 2#define WLANRUN_H
3 3
4#include <qregexp.h> 4#include <qregexp.h>
5#include <asdevice.h> 5#include <netnode.h>
6#include "wlandata.h" 6#include "wlandata.h"
7 7
8class WLanRun : public AsDevice { 8class WLanRun : public RuntimeInfo {
9 9
10public : 10public :
11 11
12 WLanRun( ANetNodeInstance * NNI, WLanData & Data ) : 12 WLanRun( ANetNodeInstance * NNI, WLanData & Data ) :
13 AsDevice( NNI ), 13 RuntimeInfo( NNI ),
14 Pat( "wlan[0-9]" ) 14 Pat( "wlan[0-9]" ) {
15 { } 15 }
16 16
17 virtual AsDevice * device( void ) 17 virtual RuntimeInfo * device( void )
18 { return (AsDevice *)this; } 18 { return this; }
19 virtual AsDevice * asDevice( void )
20 { return (AsDevice *)this; }
21 19
22protected :
23
24 void detectState( NodeCollection * );
25 bool setState( NodeCollection *, Action_t, bool );
26 bool canSetState( State_t, Action_t );
27 bool handlesInterface( const QString & I ); 20 bool handlesInterface( const QString & I );
28 bool handlesInterface( const InterfaceInfo & II ); 21 bool handlesInterface( const InterfaceInfo & II );
29 22
23 State_t detectState( void );
24
25protected :
26
27 QString setMyState( NodeCollection * , Action_t, bool );
28
30private : 29private :
31 30
32 InterfaceInfo * getInterface( void ); 31 InterfaceInfo * getInterface( void );
33 QRegExp Pat; 32 QRegExp Pat;
diff --git a/noncore/settings/packagemanager/oconfitem.h b/noncore/settings/packagemanager/oconfitem.h
index 9972c00..7b52ce4 100644
--- a/noncore/settings/packagemanager/oconfitem.h
+++ b/noncore/settings/packagemanager/oconfitem.h
@@ -37,9 +37,14 @@ _;:, .> :=|. This program is free software; you can
37 37
38class OConfItem 38class OConfItem
39{ 39{
40public: 40public:
41 enum Type { Source, Destination, Option, Arch, NotDefined }; 41 enum Type { Source=0x01,
42 GzSource=0x02,
43 Destination=0x04,
44 Option=0x08,
45 Arch=0x10,
46 NotDefined=0x20 };
42 47
43 OConfItem( Type type = NotDefined, const QString &name = QString::null, 48 OConfItem( Type type = NotDefined, const QString &name = QString::null,
44 const QString &value = QString::null, const QString &features = QString::null, 49 const QString &value = QString::null, const QString &features = QString::null,
45 bool active = true ); 50 bool active = true );
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index f2d7e39..a885ef8 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -113,9 +113,10 @@ OConfItemList *OIpkg::configItems()
113 113
114OConfItemList *OIpkg::servers() 114OConfItemList *OIpkg::servers()
115{ 115{
116 // Retrieve only servers 116 // Retrieve only servers
117 return filterConfItems( OConfItem::Source ); 117 return filterConfItems( (OConfItem::Type)((int)OConfItem::Source |
118 (int)OConfItem::GzSource) );
118} 119}
119 120
120OConfItemList *OIpkg::destinations() 121OConfItemList *OIpkg::destinations()
121{ 122{
@@ -542,8 +543,9 @@ void OIpkg::loadConfiguration()
542 if ( !line.isEmpty() ) 543 if ( !line.isEmpty() )
543 { 544 {
544 if ( !line.startsWith( "#" ) || 545 if ( !line.startsWith( "#" ) ||
545 line.startsWith( "#src" ) || 546 line.startsWith( "#src" ) ||
547 line.startsWith( "#src/gz" ) ||
546 line.startsWith( "#dest" ) || 548 line.startsWith( "#dest" ) ||
547 line.startsWith( "#arch" ) || 549 line.startsWith( "#arch" ) ||
548 line.startsWith( "#option" ) ) 550 line.startsWith( "#option" ) )
549 { 551 {
@@ -617,9 +619,10 @@ OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter )
617 OConfItemListIterator it( *m_confInfo ); 619 OConfItemListIterator it( *m_confInfo );
618 for ( ; it.current(); ++it ) 620 for ( ; it.current(); ++it )
619 { 621 {
620 OConfItem *item = it.current(); 622 OConfItem *item = it.current();
621 if ( retrieveAll || item->type() == typefilter ) 623 if ( retrieveAll ||
624 ( item->type() & typefilter ) )
622 { 625 {
623 sl->append( item ); 626 sl->append( item );
624 } 627 }
625 } 628 }
diff --git a/noncore/settings/packagemanager/opie-packagemanager.control b/noncore/settings/packagemanager/opie-packagemanager.control
index da3ddfe..0153d40 100644
--- a/noncore/settings/packagemanager/opie-packagemanager.control
+++ b/noncore/settings/packagemanager/opie-packagemanager.control
@@ -1,10 +1,10 @@
1Package: opie-packagemanager 1Package: opie-packagemanager
2Files: plugins/application/libpackagemanager.so* bin/packagemanager pics/packagemanager apps/Settings/packagemanager.desktop 2Files: plugins/application/libpackagemanager.so* bin/packagemanager pics/packagemanager apps/Settings/packagemanager.desktop
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Depends: task-opie-minimal, libopiecore2, libopieui2, libipkg (>=0.99.120) 5Depends: task-opie-minimal, libopiecore2, libopieui2, libipkg0 (>=0.99.120), ipkg-link
6Replaces: packagemanager 6Replaces: packagemanager
7Architecture: arm 7Architecture: arm
8Maintainer: Dan Williams (drw@handhelds.org) 8Maintainer: Dan Williams (drw@handhelds.org)
9Description: Opie package management client 9Description: Opie package management client
10Version: 0.6.1$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/tools/opie-sh/opie-sh.control b/noncore/tools/opie-sh/opie-sh.control
index 106a183..496a036 100644
--- a/noncore/tools/opie-sh/opie-sh.control
+++ b/noncore/tools/opie-sh/opie-sh.control
@@ -3,9 +3,9 @@ Files: bin/opie-sh apps/Opie-SH/opie-sh.desktop pics/opie-sh/*.png help/opie-s
3Priority: optional 3Priority: optional
4Section: opie/sh 4Section: opie/sh
5Maintainer: Thomas Stephens <spiralman@softhome.net> 5Maintainer: Thomas Stephens <spiralman@softhome.net>
6Architecture: arm 6Architecture: arm
7Version: 0.5-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal 8Depends: task-opie-minimal
9License: GPL 9License: GPL
10Description: A QDialog shell frontend 10Description: A QDialog shell frontend
11 A program to let you use various dialogs from the console (or a shell script) 11 A program to let you use various dialogs from the console (or a shell script)
diff --git a/noncore/tools/opie-sh/scripts/opie-sh-wavelanchooser.control b/noncore/tools/opie-sh/scripts/opie-sh-wavelanchooser.control
index 3c3463f..0d6b235 100644
--- a/noncore/tools/opie-sh/scripts/opie-sh-wavelanchooser.control
+++ b/noncore/tools/opie-sh/scripts/opie-sh-wavelanchooser.control
@@ -1,8 +1,8 @@
1Package: opie-sh-wavelanchooser 1Package: opie-sh-wavelanchooser
2Files: bin/opie-sh-wavelanchooser.sh apps/Opie-SH/opie-sh-wavelanchooser.desktop pics/opie-sh-scripts/qtwavelan.png 2Files: bin/opie-sh-wavelanchooser.sh apps/Opie-SH/opie-sh-wavelanchooser.desktop pics/opie-sh-scripts/qtwavelan.png
3Installed-Size: 0 3Installed-Size: 0
4Version: 0.1-20020527-1 4Version: $QPE_VERSION$EXTRAVERSION
5Depends: task-opie-minimal (1.5.0+), opie-sh 5Depends: task-opie-minimal (1.5.0+), opie-sh
6Priority: optional 6Priority: optional
7Section: opie/sh 7Section: opie/sh
8Maintainer: gonz <gonz@directbox.com> 8Maintainer: gonz <gonz@directbox.com>
diff --git a/noncore/unsupported/filebrowser/opie-filebrowser.control b/noncore/unsupported/filebrowser/opie-filebrowser.control
index d40bd8a..50080a1 100644
--- a/noncore/unsupported/filebrowser/opie-filebrowser.control
+++ b/noncore/unsupported/filebrowser/opie-filebrowser.control
@@ -3,8 +3,8 @@ Files: bin/filebrowser apps/Applications/filebrowser.desktop pics/filebrowser/
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Opie Team <opie@handhelds.org> 5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal 8Depends: task-opie-minimal
9Description: Browse the file system 9Description: Browse the file system
10 The filebrowser for the Opie environment. 10 The filebrowser for the Opie environment.
diff --git a/noncore/unsupported/gsmtool/opie-gsmtool.control b/noncore/unsupported/gsmtool/opie-gsmtool.control
index 6bd3b46..d987b11 100644
--- a/noncore/unsupported/gsmtool/opie-gsmtool.control
+++ b/noncore/unsupported/gsmtool/opie-gsmtool.control
@@ -3,9 +3,9 @@ Files: plugins/application/libgsmtool.so* bin/gsmtool apps/Applications/gsmtool.
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: David Woodhouse <dwmw2@infradead.org> 5Maintainer: David Woodhouse <dwmw2@infradead.org>
6Architecture: arm 6Architecture: arm
7Version: 1.0.0-2 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal, gsmlib 8Depends: task-opie-minimal, gsmlib
9License: Public Domain 9License: Public Domain
10Description: GSMTool program 10Description: GSMTool program
11 An GSM phone utility program for the Opie environment. 11 An GSM phone utility program for the Opie environment.
diff --git a/noncore/unsupported/oipkg/opie-oipkg.control b/noncore/unsupported/oipkg/opie-oipkg.control
index 17e7049..da6c755 100644
--- a/noncore/unsupported/oipkg/opie-oipkg.control
+++ b/noncore/unsupported/oipkg/opie-oipkg.control
@@ -3,8 +3,8 @@ Files: bin/oipkg apps/Settings/oipkg.desktop pics/oipkg/*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Patrick S. Vogt <tille@almana.ch> 5Maintainer: Patrick S. Vogt <tille@almana.ch>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal, ipkg (>0.99.20), ar 8Depends: task-opie-minimal, ipkg (>0.99.20), ar
9Description: Opie Projects advanced gui ipkg installer 9Description: Opie Projects advanced gui ipkg installer
10 A GUI front-end to ipkg for the Opie environment. 10 A GUI front-end to ipkg for the Opie environment.
diff --git a/noncore/unsupported/ubrowser/opie-ubrowser.control b/noncore/unsupported/ubrowser/opie-ubrowser.control
index cf96888..bfa6c30 100644
--- a/noncore/unsupported/ubrowser/opie-ubrowser.control
+++ b/noncore/unsupported/ubrowser/opie-ubrowser.control
@@ -3,8 +3,8 @@ Files: bin/ubrowser apps/Applications/ubrowser.desktop pics/ubrowser/*.png plugi
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Thomas Stephens <spiralman@softhome.net> 5Maintainer: Thomas Stephens <spiralman@softhome.net>
6Architecture: arm 6Architecture: arm
7Version: 0.1-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal 8Depends: task-opie-minimal
9License: GPL 9License: GPL
10Description: A very small web browser 10Description: A very small web browser