Diffstat (limited to 'noncore/settings/networksettings2/wlan/wlan_NNI.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/wlan/wlan_NNI.cpp | 114 |
1 files changed, 109 insertions, 5 deletions
diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp index 78e756c..61969f2 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp +++ b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp | |||
@@ -1,23 +1,74 @@ | |||
1 | #include <unistd.h> | ||
1 | #include "wlanedit.h" | 2 | #include "wlanedit.h" |
2 | #include "wlan_NNI.h" | 3 | #include "wlan_NNI.h" |
3 | #include "wlan_NN.h" | 4 | #include "wlan_NN.h" |
4 | 5 | ||
5 | AWLan::AWLan( WLanNetNode * PNN ) : ANetNodeInstance( PNN ) { | 6 | AWLan::AWLan( WLanNetNode * PNN ) : ANetNodeInstance( PNN ) { |
6 | GUI = 0; | 7 | GUI = 0; |
7 | RT = 0; | 8 | RT = 0; |
9 | Data.ESSID = ""; | ||
10 | Data.NodeName = tr("<UseHostName>"); | ||
11 | Data.Mode = 0; | ||
12 | Data.SpecificAP = 0; | ||
13 | Data.APMac = ""; | ||
14 | Data.Encrypted = 0; | ||
15 | Data.AcceptNonEncrypted = 0; | ||
16 | Data.Key[0] = ""; | ||
17 | Data.Key[1] = ""; | ||
18 | Data.Key[2] = ""; | ||
19 | Data.Key[3] = ""; | ||
8 | } | 20 | } |
9 | 21 | ||
10 | void AWLan::setSpecificAttribute( QString & , QString & ) { | 22 | void AWLan::setSpecificAttribute( QString & A, QString & V ) { |
23 | if( A == "essid" ) { | ||
24 | Data.ESSID = V; | ||
25 | } else if( A == "nodename" ) { | ||
26 | Data.NodeName = V; | ||
27 | } else if( A == "mode" ) { | ||
28 | Data.Mode = V.toShort(); | ||
29 | } else if( A == "specificap" ) { | ||
30 | Data.SpecificAP = (V=="yes"); | ||
31 | } else if( A == "apmac" ) { | ||
32 | Data.APMac = V; | ||
33 | } else if( A == "encrypted" ) { | ||
34 | Data.Encrypted = (V=="yes"); | ||
35 | } else if( A == "acceptnonencrypted" ) { | ||
36 | Data.AcceptNonEncrypted = (V=="yes"); | ||
37 | } else if( A == "key0" ) { | ||
38 | Data.Key[0] = V; | ||
39 | } else if( A == "key1" ) { | ||
40 | Data.Key[1] = V; | ||
41 | } else if( A == "key2" ) { | ||
42 | Data.Key[2] = V; | ||
43 | } else if( A == "key3" ) { | ||
44 | Data.Key[3] = V; | ||
45 | } | ||
11 | } | 46 | } |
12 | 47 | ||
13 | void AWLan::saveSpecificAttribute( QTextStream & ) { | 48 | void AWLan::saveSpecificAttribute( QTextStream & S ) { |
49 | S << "essid=" << quote( Data.ESSID ) << endl; | ||
50 | S << "nodename=" << quote( Data.NodeName ) << endl; | ||
51 | S << "mode=" << Data.Mode << endl; | ||
52 | S << "specificap=" | ||
53 | << ((Data.SpecificAP) ? "yes" : "no") | ||
54 | << endl; | ||
55 | S << "apmac=" << Data.APMac << endl; | ||
56 | S << "encrypted=" | ||
57 | << ((Data.Encrypted) ? "yes" : "no") | ||
58 | << endl; | ||
59 | S << "acceptnonencrypted=" | ||
60 | << ((Data.AcceptNonEncrypted) ? "yes" : "no") | ||
61 | << endl; | ||
62 | for( int i = 0 ;i < 4 ; i ++ ) { | ||
63 | S << "key" << i << "=" << Data.Key[i] << endl; | ||
64 | } | ||
14 | } | 65 | } |
15 | 66 | ||
16 | QWidget * AWLan::edit( QWidget * parent ) { | 67 | QWidget * AWLan::edit( QWidget * parent ) { |
17 | GUI = new WLanEdit( parent ); | 68 | GUI = new WLanEdit( parent, this ); |
18 | GUI->showData( Data ); | 69 | GUI->showData( Data ); |
19 | return GUI; | 70 | return GUI; |
20 | } | 71 | } |
21 | 72 | ||
22 | QString AWLan::acceptable( void ) { | 73 | QString AWLan::acceptable( void ) { |
23 | return ( GUI ) ? GUI->acceptable( ) : QString(); | 74 | return ( GUI ) ? GUI->acceptable( ) : QString(); |
@@ -26,11 +77,64 @@ QString AWLan::acceptable( void ) { | |||
26 | void AWLan::commit( void ) { | 77 | void AWLan::commit( void ) { |
27 | if( GUI && GUI->commit( Data ) ) | 78 | if( GUI && GUI->commit( Data ) ) |
28 | setModified( 1 ); | 79 | setModified( 1 ); |
29 | } | 80 | } |
30 | 81 | ||
31 | bool AWLan::generateDataForCommonFile( | 82 | bool AWLan::generateDataForCommonFile( |
32 | SystemFile &, | 83 | SystemFile & S, |
33 | long ) { | 84 | long ) { |
34 | return 1; | 85 | |
86 | S << " wireless_essid \"" | ||
87 | << Data.ESSID | ||
88 | << "\"" | ||
89 | << endl; | ||
90 | |||
91 | if( ! Data.NodeName.isEmpty() ) { | ||
92 | if( Data.NodeName == tr("<UseHostName>") ) { | ||
93 | char Buf[100]; | ||
94 | if( gethostname(Buf, sizeof(Buf) ) == 0 ) { | ||
95 | Buf[99] = '\0'; // just to make sure | ||
96 | S << " wireless_nick " | ||
97 | << Buf | ||
98 | << endl; | ||
99 | } | ||
100 | } else { | ||
101 | S << " wireless_nick \"" | ||
102 | << Data.NodeName | ||
103 | << "\"" | ||
104 | << endl; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | char * M; | ||
109 | switch ( Data.Mode ) { | ||
110 | case 0 : | ||
111 | M = "Auto"; | ||
112 | break; | ||
113 | case 1 : | ||
114 | M = "Managed"; | ||
115 | break; | ||
116 | case 2 : | ||
117 | M = "Ad-Hoc"; | ||
118 | break; | ||
119 | } | ||
120 | |||
121 | S << " wireless_mode " | ||
122 | << M | ||
123 | << endl; | ||
124 | if( Data.Encrypted ) { | ||
125 | for( int i = 0; i < 4; i ++ ) { | ||
126 | if( ! Data.Key[i].isEmpty() ) { | ||
127 | S << " wireless_key" | ||
128 | << i | ||
129 | << " " | ||
130 | << Data.Key[i] | ||
131 | << endl; | ||
132 | } | ||
133 | } | ||
134 | S << " wireless_keymode " | ||
135 | << ((Data.AcceptNonEncrypted) ? "open" : "restricted") | ||
136 | << endl; | ||
137 | } | ||
138 | return 0; | ||
35 | } | 139 | } |
36 | 140 | ||