summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-10-24 21:01:21 (UTC)
committer harlekin <harlekin>2002-10-24 21:01:21 (UTC)
commita8b95086dd331c67c728a346f56416c355142758 (patch) (unidiff)
tree1df20d3dfa7231005f9417c5cd318685d675efad
parent52266c9462d599ab3268bddb301698c90bb0212c (diff)
downloadopie-a8b95086dd331c67c728a346f56416c355142758.zip
opie-a8b95086dd331c67c728a346f56416c355142758.tar.gz
opie-a8b95086dd331c67c728a346f56416c355142758.tar.bz2
give new connection a caption
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp1
-rw-r--r--noncore/apps/opie-console/modemconfigwidget.cpp1
2 files changed, 2 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index ccecdf8..c44b359 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,709 +1,710 @@
1#include <assert.h> 1#include <assert.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qmenubar.h> 4#include <qmenubar.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <qpopupmenu.h> 6#include <qpopupmenu.h>
7#include <qtoolbar.h> 7#include <qtoolbar.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qpushbutton.h> 9#include <qpushbutton.h>
10#include <qwhatsthis.h> 10#include <qwhatsthis.h>
11#include <qfileinfo.h> 11#include <qfileinfo.h>
12 12
13#include <qpe/resource.h> 13#include <qpe/resource.h>
14#include <qpe/qpeapplication.h> 14#include <qpe/qpeapplication.h>
15#include <qpe/filemanager.h> 15#include <qpe/filemanager.h>
16#include <qpe/mimetype.h> 16#include <qpe/mimetype.h>
17 17
18#include <opie/ofiledialog.h> 18#include <opie/ofiledialog.h>
19 19
20#include "keytrans.h" 20#include "keytrans.h"
21#include "profileeditordialog.h" 21#include "profileeditordialog.h"
22#include "configdialog.h" 22#include "configdialog.h"
23#include "default.h" 23#include "default.h"
24#include "metafactory.h" 24#include "metafactory.h"
25#include "profile.h" 25#include "profile.h"
26#include "profilemanager.h" 26#include "profilemanager.h"
27#include "mainwindow.h" 27#include "mainwindow.h"
28#include "tabwidget.h" 28#include "tabwidget.h"
29#include "transferdialog.h" 29#include "transferdialog.h"
30#include "function_keyboard.h" 30#include "function_keyboard.h"
31#include "emulation_handler.h" 31#include "emulation_handler.h"
32#include "script.h" 32#include "script.h"
33 33
34static char * filesave_xpm[] = { 34static char * filesave_xpm[] = {
35"16 16 78 1", 35"16 16 78 1",
36" c None", 36" c None",
37". c #343434", 37". c #343434",
38"+ c #A0A0A0", 38"+ c #A0A0A0",
39"@ c #565656", 39"@ c #565656",
40"# c #9E9E9E", 40"# c #9E9E9E",
41"$ c #525252", 41"$ c #525252",
42"% c #929292", 42"% c #929292",
43"& c #676767", 43"& c #676767",
44"* c #848484", 44"* c #848484",
45"= c #666666", 45"= c #666666",
46"- c #D8D8D8", 46"- c #D8D8D8",
47"; c #FFFFFF", 47"; c #FFFFFF",
48"> c #DBDBDB", 48"> c #DBDBDB",
49", c #636363", 49", c #636363",
50"' c #989898", 50"' c #989898",
51") c #2D2D2D", 51") c #2D2D2D",
52"! c #909090", 52"! c #909090",
53"~ c #AEAEAE", 53"~ c #AEAEAE",
54"{ c #EAEAEA", 54"{ c #EAEAEA",
55"] c #575757", 55"] c #575757",
56"^ c #585858", 56"^ c #585858",
57"/ c #8A8A8A", 57"/ c #8A8A8A",
58"( c #828282", 58"( c #828282",
59"_ c #6F6F6F", 59"_ c #6F6F6F",
60": c #C9C9C9", 60": c #C9C9C9",
61"< c #050505", 61"< c #050505",
62"[ c #292929", 62"[ c #292929",
63"} c #777777", 63"} c #777777",
64"| c #616161", 64"| c #616161",
65"1 c #3A3A3A", 65"1 c #3A3A3A",
66"2 c #BEBEBE", 66"2 c #BEBEBE",
67"3 c #2C2C2C", 67"3 c #2C2C2C",
68"4 c #7C7C7C", 68"4 c #7C7C7C",
69"5 c #F6F6F6", 69"5 c #F6F6F6",
70"6 c #FCFCFC", 70"6 c #FCFCFC",
71"7 c #6B6B6B", 71"7 c #6B6B6B",
72"8 c #959595", 72"8 c #959595",
73"9 c #4F4F4F", 73"9 c #4F4F4F",
74"0 c #808080", 74"0 c #808080",
75"a c #767676", 75"a c #767676",
76"b c #818181", 76"b c #818181",
77"c c #B8B8B8", 77"c c #B8B8B8",
78"d c #FBFBFB", 78"d c #FBFBFB",
79"e c #F9F9F9", 79"e c #F9F9F9",
80"f c #CCCCCC", 80"f c #CCCCCC",
81"g c #030303", 81"g c #030303",
82"h c #737373", 82"h c #737373",
83"i c #7A7A7A", 83"i c #7A7A7A",
84"j c #7E7E7E", 84"j c #7E7E7E",
85"k c #6A6A6A", 85"k c #6A6A6A",
86"l c #FAFAFA", 86"l c #FAFAFA",
87"m c #505050", 87"m c #505050",
88"n c #9D9D9D", 88"n c #9D9D9D",
89"o c #333333", 89"o c #333333",
90"p c #7B7B7B", 90"p c #7B7B7B",
91"q c #787878", 91"q c #787878",
92"r c #696969", 92"r c #696969",
93"s c #494949", 93"s c #494949",
94"t c #555555", 94"t c #555555",
95"u c #949494", 95"u c #949494",
96"v c #E6E6E6", 96"v c #E6E6E6",
97"w c #424242", 97"w c #424242",
98"x c #515151", 98"x c #515151",
99"y c #535353", 99"y c #535353",
100"z c #3E3E3E", 100"z c #3E3E3E",
101"A c #D4D4D4", 101"A c #D4D4D4",
102"B c #0C0C0C", 102"B c #0C0C0C",
103"C c #353535", 103"C c #353535",
104"D c #474747", 104"D c #474747",
105"E c #ECECEC", 105"E c #ECECEC",
106"F c #919191", 106"F c #919191",
107"G c #7D7D7D", 107"G c #7D7D7D",
108"H c #000000", 108"H c #000000",
109"I c #404040", 109"I c #404040",
110"J c #858585", 110"J c #858585",
111"K c #323232", 111"K c #323232",
112"L c #D0D0D0", 112"L c #D0D0D0",
113"M c #1C1C1C", 113"M c #1C1C1C",
114" ...+ ", 114" ...+ ",
115" @#$%&..+ ", 115" @#$%&..+ ",
116" .*=-;;>,..+ ", 116" .*=-;;>,..+ ",
117" ')!~;;;;;;{]..", 117" ')!~;;;;;;{]..",
118" ^/(-;;;;;;;_:<", 118" ^/(-;;;;;;;_:<",
119" [}|;;;;;;;{12$", 119" [}|;;;;;;;{12$",
120" #34-55;;;;678$+", 120" #34-55;;;;678$+",
121" 90ab=c;dd;e1fg ", 121" 90ab=c;dd;e1fg ",
122" [ahij((kbl0mn$ ", 122" [ahij((kbl0mn$ ",
123" op^q^^7r&]s/$+ ", 123" op^q^^7r&]s/$+ ",
124"@btu;vbwxy]zAB ", 124"@btu;vbwxy]zAB ",
125"CzDEvEv;;DssF$ ", 125"CzDEvEv;;DssF$ ",
126"G.H{E{E{IxsJ$+ ", 126"G.H{E{E{IxsJ$+ ",
127" +...vEKxzLM ", 127" +...vEKxzLM ",
128" +...z]n$ ", 128" +...z]n$ ",
129" +... "}; 129" +... "};
130 130
131 131
132 132
133MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 133MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
134 KeyTrans::loadAll(); 134 KeyTrans::loadAll();
135 for (int i = 0; i < KeyTrans::count(); i++ ) { 135 for (int i = 0; i < KeyTrans::count(); i++ ) {
136 KeyTrans* s = KeyTrans::find(i ); 136 KeyTrans* s = KeyTrans::find(i );
137 assert( s ); 137 assert( s );
138 } 138 }
139 m_factory = new MetaFactory(); 139 m_factory = new MetaFactory();
140 Default def(m_factory); 140 Default def(m_factory);
141 m_sessions.setAutoDelete( TRUE ); 141 m_sessions.setAutoDelete( TRUE );
142 m_curSession = 0; 142 m_curSession = 0;
143 m_manager = new ProfileManager( m_factory ); 143 m_manager = new ProfileManager( m_factory );
144 m_manager->load(); 144 m_manager->load();
145 m_scriptsData.setAutoDelete(TRUE); 145 m_scriptsData.setAutoDelete(TRUE);
146 146
147 initUI(); 147 initUI();
148 populateProfiles(); 148 populateProfiles();
149 populateScripts(); 149 populateScripts();
150} 150}
151void MainWindow::initUI() { 151void MainWindow::initUI() {
152 setToolBarsMovable( FALSE ); 152 setToolBarsMovable( FALSE );
153 153
154 /* tool bar for the menu */ 154 /* tool bar for the menu */
155 m_tool = new QToolBar( this ); 155 m_tool = new QToolBar( this );
156 m_tool->setHorizontalStretchable( TRUE ); 156 m_tool->setHorizontalStretchable( TRUE );
157 157
158 m_bar = new QMenuBar( m_tool ); 158 m_bar = new QMenuBar( m_tool );
159 m_console = new QPopupMenu( this ); 159 m_console = new QPopupMenu( this );
160 m_scripts = new QPopupMenu( this ); 160 m_scripts = new QPopupMenu( this );
161 m_sessionsPop= new QPopupMenu( this ); 161 m_sessionsPop= new QPopupMenu( this );
162 m_scriptsPop = new QPopupMenu( this ); 162 m_scriptsPop = new QPopupMenu( this );
163 163
164 /* add a toolbar for icons */ 164 /* add a toolbar for icons */
165 m_icons = new QToolBar(this); 165 m_icons = new QToolBar(this);
166 166
167 /* 167 /*
168 * the settings action 168 * the settings action
169 */ 169 */
170 m_setProfiles = new QAction(tr("Configure Profiles"), 170 m_setProfiles = new QAction(tr("Configure Profiles"),
171 Resource::loadPixmap( "SettingsIcon" ), 171 Resource::loadPixmap( "SettingsIcon" ),
172 QString::null, 0, this, 0); 172 QString::null, 0, this, 0);
173 m_setProfiles->addTo( m_console ); 173 m_setProfiles->addTo( m_console );
174 connect( m_setProfiles, SIGNAL(activated() ), 174 connect( m_setProfiles, SIGNAL(activated() ),
175 this, SLOT(slotConfigure() ) ); 175 this, SLOT(slotConfigure() ) );
176 176
177 m_console->insertSeparator(); 177 m_console->insertSeparator();
178 /* 178 /*
179 * new Action for new sessions 179 * new Action for new sessions
180 */ 180 */
181 QAction* newCon = new QAction(tr("New Connection"), 181 QAction* newCon = new QAction(tr("New Connection"),
182 Resource::loadPixmap( "new" ), 182 Resource::loadPixmap( "new" ),
183 QString::null, 0, this, 0); 183 QString::null, 0, this, 0);
184 newCon->addTo( m_console ); 184 newCon->addTo( m_console );
185 connect( newCon, SIGNAL(activated() ), 185 connect( newCon, SIGNAL(activated() ),
186 this, SLOT(slotNew() ) ); 186 this, SLOT(slotNew() ) );
187 187
188 m_console->insertSeparator(); 188 m_console->insertSeparator();
189 189
190 QAction *saveCon = new QAction(tr("Save Connection"), 190 QAction *saveCon = new QAction(tr("Save Connection"),
191 QPixmap( ( const char** ) filesave_xpm ) , QString::null, 191 QPixmap( ( const char** ) filesave_xpm ) , QString::null,
192 0, this, 0 ); 192 0, this, 0 );
193 saveCon->addTo( m_console ); 193 saveCon->addTo( m_console );
194 connect( saveCon, SIGNAL(activated() ), 194 connect( saveCon, SIGNAL(activated() ),
195 this, SLOT(slotSaveSession() ) ); 195 this, SLOT(slotSaveSession() ) );
196 m_console->insertSeparator(); 196 m_console->insertSeparator();
197 197
198 /* 198 /*
199 * connect action 199 * connect action
200 */ 200 */
201 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), 201 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"),
202 QString::null, 0, this, 0 ); 202 QString::null, 0, this, 0 );
203 m_connect->addTo( m_console ); 203 m_connect->addTo( m_console );
204 connect(m_connect, SIGNAL(activated() ), 204 connect(m_connect, SIGNAL(activated() ),
205 this, SLOT(slotConnect() ) ); 205 this, SLOT(slotConnect() ) );
206 206
207 /* 207 /*
208 * disconnect action 208 * disconnect action
209 */ 209 */
210 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), 210 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"),
211 QString::null, 0, this, 0 ); 211 QString::null, 0, this, 0 );
212 m_disconnect->addTo( m_console ); 212 m_disconnect->addTo( m_console );
213 connect(m_disconnect, SIGNAL(activated() ), 213 connect(m_disconnect, SIGNAL(activated() ),
214 this, SLOT(slotDisconnect() ) ); 214 this, SLOT(slotDisconnect() ) );
215 215
216 m_console->insertSeparator(); 216 m_console->insertSeparator();
217 217
218 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, 218 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null,
219 0, this, 0 ); 219 0, this, 0 );
220 m_transfer->addTo( m_console ); 220 m_transfer->addTo( m_console );
221 connect(m_transfer, SIGNAL(activated() ), 221 connect(m_transfer, SIGNAL(activated() ),
222 this, SLOT(slotTransfer() ) ); 222 this, SLOT(slotTransfer() ) );
223 223
224 224
225 /* 225 /*
226 * fullscreen 226 * fullscreen
227 */ 227 */
228 m_isFullscreen = false; 228 m_isFullscreen = false;
229 229
230 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 230 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
231 , QString::null, 0, this, 0); 231 , QString::null, 0, this, 0);
232 m_fullscreen->addTo( m_console ); 232 m_fullscreen->addTo( m_console );
233 connect( m_fullscreen, SIGNAL( activated() ), 233 connect( m_fullscreen, SIGNAL( activated() ),
234 this, SLOT( slotFullscreen() ) ); 234 this, SLOT( slotFullscreen() ) );
235 235
236 m_console->insertSeparator(); 236 m_console->insertSeparator();
237 /* 237 /*
238 * terminate action 238 * terminate action
239 */ 239 */
240 m_terminate = new QAction(); 240 m_terminate = new QAction();
241 m_terminate->setText( tr("Terminate") ); 241 m_terminate->setText( tr("Terminate") );
242 m_terminate->addTo( m_console ); 242 m_terminate->addTo( m_console );
243 connect(m_terminate, SIGNAL(activated() ), 243 connect(m_terminate, SIGNAL(activated() ),
244 this, SLOT(slotTerminate() ) ); 244 this, SLOT(slotTerminate() ) );
245 245
246 m_closewindow = new QAction(); 246 m_closewindow = new QAction();
247 m_closewindow->setText( tr("Close Window") ); 247 m_closewindow->setText( tr("Close Window") );
248 m_closewindow->addTo( m_console ); 248 m_closewindow->addTo( m_console );
249 connect( m_closewindow, SIGNAL(activated() ), 249 connect( m_closewindow, SIGNAL(activated() ),
250 this, SLOT(slotClose() ) ); 250 this, SLOT(slotClose() ) );
251 251
252 252
253 /* 253 /*
254 * script actions 254 * script actions
255 */ 255 */
256 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); 256 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
257 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); 257 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
258 258
259 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 259 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
260 m_recordScript->addTo(m_scripts); 260 m_recordScript->addTo(m_scripts);
261 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 261 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
262 262
263 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 263 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
264 m_saveScript->addTo(m_scripts); 264 m_saveScript->addTo(m_scripts);
265 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 265 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
266 266
267 267
268 /* 268 /*
269 * action that open/closes the keyboard 269 * action that open/closes the keyboard
270 */ 270 */
271 m_openKeys = new QAction (tr("Open Keyboard..."), 271 m_openKeys = new QAction (tr("Open Keyboard..."),
272 Resource::loadPixmap( "console/keys/keyboard_icon" ), 272 Resource::loadPixmap( "console/keys/keyboard_icon" ),
273 QString::null, 0, this, 0); 273 QString::null, 0, this, 0);
274 m_openKeys->setToggleAction(true); 274 m_openKeys->setToggleAction(true);
275 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); 275 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
276 276
277 /* insert the submenu */ 277 /* insert the submenu */
278 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 278 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
279 -1, 0); 279 -1, 0);
280 280
281 /* insert the connection menu */ 281 /* insert the connection menu */
282 m_bar->insertItem( tr("Connection"), m_console ); 282 m_bar->insertItem( tr("Connection"), m_console );
283 283
284 /* the scripts menu */ 284 /* the scripts menu */
285 m_bar->insertItem( tr("Scripts"), m_scripts ); 285 m_bar->insertItem( tr("Scripts"), m_scripts );
286 286
287 /* and the keyboard */ 287 /* and the keyboard */
288 m_keyBar = new QToolBar(this); 288 m_keyBar = new QToolBar(this);
289 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 289 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
290 m_keyBar->setHorizontalStretchable( TRUE ); 290 m_keyBar->setHorizontalStretchable( TRUE );
291 m_keyBar->hide(); 291 m_keyBar->hide();
292 292
293 m_kb = new FunctionKeyboard(m_keyBar); 293 m_kb = new FunctionKeyboard(m_keyBar);
294 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), 294 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
295 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); 295 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool)));
296 296
297 297
298 QAction *a = new QAction(tr("Copy"), 298 QAction *a = new QAction(tr("Copy"),
299 Resource::loadPixmap("copy"), QString::null, 299 Resource::loadPixmap("copy"), QString::null,
300 0, this, 0 ); 300 0, this, 0 );
301 //a->addTo( m_icons ); 301 //a->addTo( m_icons );
302 connect( a, SIGNAL(activated() ), 302 connect( a, SIGNAL(activated() ),
303 this, SLOT(slotCopy() ) ); 303 this, SLOT(slotCopy() ) );
304 304
305 QAction *paste = new QAction(tr("Paste"), 305 QAction *paste = new QAction(tr("Paste"),
306 Resource::loadPixmap("paste"), QString::null, 306 Resource::loadPixmap("paste"), QString::null,
307 0, this, 0 ); 307 0, this, 0 );
308 connect( paste, SIGNAL(activated() ), 308 connect( paste, SIGNAL(activated() ),
309 this, SLOT(slotPaste() ) ); 309 this, SLOT(slotPaste() ) );
310 310
311 311
312 newCon->addTo( m_icons ); 312 newCon->addTo( m_icons );
313 m_setProfiles->addTo( m_icons ); 313 m_setProfiles->addTo( m_icons );
314 paste->addTo( m_icons ); 314 paste->addTo( m_icons );
315 m_openKeys->addTo(m_icons); 315 m_openKeys->addTo(m_icons);
316 m_fullscreen->addTo( m_icons ); 316 m_fullscreen->addTo( m_icons );
317 317
318 m_connect->setEnabled( false ); 318 m_connect->setEnabled( false );
319 m_disconnect->setEnabled( false ); 319 m_disconnect->setEnabled( false );
320 m_terminate->setEnabled( false ); 320 m_terminate->setEnabled( false );
321 m_transfer->setEnabled( false ); 321 m_transfer->setEnabled( false );
322 m_scripts->setItemEnabled(m_runScript_id, false); 322 m_scripts->setItemEnabled(m_runScript_id, false);
323 m_recordScript->setEnabled( false ); 323 m_recordScript->setEnabled( false );
324 m_saveScript->setEnabled( false ); 324 m_saveScript->setEnabled( false );
325 m_fullscreen->setEnabled( false ); 325 m_fullscreen->setEnabled( false );
326 m_closewindow->setEnabled( false ); 326 m_closewindow->setEnabled( false );
327 327
328 /* 328 /*
329 * connect to the menu activation 329 * connect to the menu activation
330 */ 330 */
331 connect( m_sessionsPop, SIGNAL(activated( int ) ), 331 connect( m_sessionsPop, SIGNAL(activated( int ) ),
332 this, SLOT(slotProfile( int ) ) ); 332 this, SLOT(slotProfile( int ) ) );
333 333
334 m_consoleWindow = new TabWidget( this, "blah"); 334 m_consoleWindow = new TabWidget( this, "blah");
335 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 335 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
336 this, SLOT(slotSessionChanged(Session*) ) ); 336 this, SLOT(slotSessionChanged(Session*) ) );
337 setCentralWidget( m_consoleWindow ); 337 setCentralWidget( m_consoleWindow );
338 338
339} 339}
340 340
341ProfileManager* MainWindow::manager() { 341ProfileManager* MainWindow::manager() {
342 return m_manager; 342 return m_manager;
343} 343}
344TabWidget* MainWindow::tabWidget() { 344TabWidget* MainWindow::tabWidget() {
345 return m_consoleWindow; 345 return m_consoleWindow;
346} 346}
347void MainWindow::populateProfiles() { 347void MainWindow::populateProfiles() {
348 m_sessionsPop->clear(); 348 m_sessionsPop->clear();
349 Profile::ValueList list = manager()->all(); 349 Profile::ValueList list = manager()->all();
350 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 350 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
351 m_sessionsPop->insertItem( (*it).name() ); 351 m_sessionsPop->insertItem( (*it).name() );
352 } 352 }
353 353
354} 354}
355 355
356void MainWindow::populateScripts() { 356void MainWindow::populateScripts() {
357 m_scriptsPop->clear(); 357 m_scriptsPop->clear();
358 m_scriptsData.clear(); 358 m_scriptsData.clear();
359 DocLnkSet files(QPEApplication::documentDir(), "text/plain"); 359 DocLnkSet files(QPEApplication::documentDir(), "text/plain");
360 QListIterator<DocLnk> dit(files.children()); 360 QListIterator<DocLnk> dit(files.children());
361 for (; dit.current(); ++dit) { 361 for (; dit.current(); ++dit) {
362 if (*dit && (*dit)->name().length()>0) { 362 if (*dit && (*dit)->name().length()>0) {
363 QFileInfo info((*dit)->file()); 363 QFileInfo info((*dit)->file());
364 if (info.extension(false) == "script") { 364 if (info.extension(false) == "script") {
365 m_scriptsData.append(new DocLnk(**dit)); 365 m_scriptsData.append(new DocLnk(**dit));
366 m_scriptsPop->insertItem((*dit)->name()); 366 m_scriptsPop->insertItem((*dit)->name());
367 } 367 }
368 } 368 }
369 } 369 }
370 370
371} 371}
372 372
373MainWindow::~MainWindow() { 373MainWindow::~MainWindow() {
374 delete m_factory; 374 delete m_factory;
375 manager()->save(); 375 manager()->save();
376} 376}
377 377
378MetaFactory* MainWindow::factory() { 378MetaFactory* MainWindow::factory() {
379 return m_factory; 379 return m_factory;
380} 380}
381 381
382Session* MainWindow::currentSession() { 382Session* MainWindow::currentSession() {
383 return m_curSession; 383 return m_curSession;
384} 384}
385 385
386QList<Session> MainWindow::sessions() { 386QList<Session> MainWindow::sessions() {
387 return m_sessions; 387 return m_sessions;
388} 388}
389 389
390void MainWindow::slotNew() { 390void MainWindow::slotNew() {
391 ProfileEditorDialog dlg(factory() ); 391 ProfileEditorDialog dlg(factory() );
392 dlg.showMaximized(); 392 dlg.showMaximized();
393 dlg.setCaption( tr("New Connection") );
393 int ret = dlg.exec(); 394 int ret = dlg.exec();
394 395
395 if ( ret == QDialog::Accepted ) { 396 if ( ret == QDialog::Accepted ) {
396 create( dlg.profile() ); 397 create( dlg.profile() );
397 } 398 }
398} 399}
399 400
400void MainWindow::slotRecordScript() { 401void MainWindow::slotRecordScript() {
401 if (currentSession()) { 402 if (currentSession()) {
402 currentSession()->emulationHandler()->startRecording(); 403 currentSession()->emulationHandler()->startRecording();
403 m_saveScript->setEnabled(true); 404 m_saveScript->setEnabled(true);
404 m_recordScript->setEnabled(false); 405 m_recordScript->setEnabled(false);
405 } 406 }
406} 407}
407 408
408void MainWindow::slotSaveScript() { 409void MainWindow::slotSaveScript() {
409 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 410 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
410 QMap<QString, QStringList> map; 411 QMap<QString, QStringList> map;
411 QStringList text; 412 QStringList text;
412 text << "text/plain"; 413 text << "text/plain";
413 map.insert(tr("Script"), text ); 414 map.insert(tr("Script"), text );
414 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 415 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
415 if (!filename.isEmpty()) { 416 if (!filename.isEmpty()) {
416 QFileInfo info(filename); 417 QFileInfo info(filename);
417 if (info.extension(FALSE) != "script") 418 if (info.extension(FALSE) != "script")
418 filename += ".script"; 419 filename += ".script";
419 DocLnk nf; 420 DocLnk nf;
420 nf.setType("text/plain"); 421 nf.setType("text/plain");
421 nf.setFile(filename); 422 nf.setFile(filename);
422 nf.setName(info.fileName()); 423 nf.setName(info.fileName());
423 FileManager fm; 424 FileManager fm;
424 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); 425 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script());
425 currentSession()->emulationHandler()->clearScript(); 426 currentSession()->emulationHandler()->clearScript();
426 m_saveScript->setEnabled(false); 427 m_saveScript->setEnabled(false);
427 m_recordScript->setEnabled(true); 428 m_recordScript->setEnabled(true);
428 populateScripts(); 429 populateScripts();
429 } 430 }
430 } 431 }
431} 432}
432 433
433void MainWindow::slotRunScript(int id) { 434void MainWindow::slotRunScript(int id) {
434 if (currentSession()) { 435 if (currentSession()) {
435 int index = m_scriptsPop->indexOf(id); 436 int index = m_scriptsPop->indexOf(id);
436 DocLnk *lnk = m_scriptsData.at(index); 437 DocLnk *lnk = m_scriptsData.at(index);
437 QString filePath = lnk->file(); 438 QString filePath = lnk->file();
438 Script script(filePath); 439 Script script(filePath);
439 currentSession()->emulationHandler()->runScript(&script); 440 currentSession()->emulationHandler()->runScript(&script);
440 } 441 }
441} 442}
442 443
443void MainWindow::slotConnect() { 444void MainWindow::slotConnect() {
444 if ( currentSession() ) { 445 if ( currentSession() ) {
445 bool ret = currentSession()->layer()->open(); 446 bool ret = currentSession()->layer()->open();
446 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 447 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
447 QObject::tr("Failed"), 448 QObject::tr("Failed"),
448 QObject::tr("Connecting failed for this session.")); 449 QObject::tr("Connecting failed for this session."));
449 else { 450 else {
450 m_connect->setEnabled( false ); 451 m_connect->setEnabled( false );
451 m_disconnect->setEnabled( true ); 452 m_disconnect->setEnabled( true );
452 m_transfer->setEnabled( true ); 453 m_transfer->setEnabled( true );
453 m_recordScript->setEnabled( true ); 454 m_recordScript->setEnabled( true );
454 m_scripts->setItemEnabled(m_runScript_id, true); 455 m_scripts->setItemEnabled(m_runScript_id, true);
455 } 456 }
456 } 457 }
457} 458}
458 459
459void MainWindow::slotDisconnect() { 460void MainWindow::slotDisconnect() {
460 if ( currentSession() ) { 461 if ( currentSession() ) {
461 currentSession()->layer()->close(); 462 currentSession()->layer()->close();
462 m_connect->setEnabled( true ); 463 m_connect->setEnabled( true );
463 m_disconnect->setEnabled( false ); 464 m_disconnect->setEnabled( false );
464 m_transfer->setEnabled( false ); 465 m_transfer->setEnabled( false );
465 m_recordScript->setEnabled( false); 466 m_recordScript->setEnabled( false);
466 m_saveScript->setEnabled( false ); 467 m_saveScript->setEnabled( false );
467 m_scripts->setItemEnabled(m_runScript_id, false); 468 m_scripts->setItemEnabled(m_runScript_id, false);
468 } 469 }
469} 470}
470 471
471void MainWindow::slotTerminate() { 472void MainWindow::slotTerminate() {
472 if ( currentSession() ) 473 if ( currentSession() )
473 currentSession()->layer()->close(); 474 currentSession()->layer()->close();
474 475
475 slotClose(); 476 slotClose();
476 /* FIXME move to the next session */ 477 /* FIXME move to the next session */
477} 478}
478 479
479void MainWindow::slotConfigure() { 480void MainWindow::slotConfigure() {
480 ConfigDialog conf( manager()->all(), factory() ); 481 ConfigDialog conf( manager()->all(), factory() );
481 conf.showMaximized(); 482 conf.showMaximized();
482 483
483 int ret = conf.exec(); 484 int ret = conf.exec();
484 485
485 if ( QDialog::Accepted == ret ) { 486 if ( QDialog::Accepted == ret ) {
486 manager()->setProfiles( conf.list() ); 487 manager()->setProfiles( conf.list() );
487 manager()->save(); 488 manager()->save();
488 populateProfiles(); 489 populateProfiles();
489 } 490 }
490} 491}
491/* 492/*
492 * we will remove 493 * we will remove
493 * this window from the tabwidget 494 * this window from the tabwidget
494 * remove it from the list 495 * remove it from the list
495 * delete it 496 * delete it
496 * and set the currentSession() 497 * and set the currentSession()
497 */ 498 */
498void MainWindow::slotClose() { 499void MainWindow::slotClose() {
499 if (!currentSession() ) 500 if (!currentSession() )
500 return; 501 return;
501 502
502 Session* ses = currentSession(); 503 Session* ses = currentSession();
503 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 504 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
504 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 505 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
505 m_curSession = NULL; 506 m_curSession = NULL;
506 tabWidget()->remove( /*currentSession()*/ses ); 507 tabWidget()->remove( /*currentSession()*/ses );
507 /*it's autodelete */ 508 /*it's autodelete */
508 m_sessions.remove( ses ); 509 m_sessions.remove( ses );
509 qWarning("after remove!!"); 510 qWarning("after remove!!");
510 511
511 if (!currentSession() ) { 512 if (!currentSession() ) {
512 m_connect->setEnabled( false ); 513 m_connect->setEnabled( false );
513 m_disconnect->setEnabled( false ); 514 m_disconnect->setEnabled( false );
514 m_terminate->setEnabled( false ); 515 m_terminate->setEnabled( false );
515 m_transfer->setEnabled( false ); 516 m_transfer->setEnabled( false );
516 m_recordScript->setEnabled( false ); 517 m_recordScript->setEnabled( false );
517 m_saveScript->setEnabled( false ); 518 m_saveScript->setEnabled( false );
518 m_scripts->setItemEnabled(m_runScript_id, false); 519 m_scripts->setItemEnabled(m_runScript_id, false);
519 m_fullscreen->setEnabled( false ); 520 m_fullscreen->setEnabled( false );
520 m_closewindow->setEnabled( false ); 521 m_closewindow->setEnabled( false );
521 } 522 }
522 523
523 m_kb->loadDefaults(); 524 m_kb->loadDefaults();
524} 525}
525 526
526/* 527/*
527 * We will get the name 528 * We will get the name
528 * Then the profile 529 * Then the profile
529 * and then we will make a profile 530 * and then we will make a profile
530 */ 531 */
531void MainWindow::slotProfile( int id) { 532void MainWindow::slotProfile( int id) {
532 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 533 Profile prof = manager()->profile( m_sessionsPop->text( id) );
533 create( prof ); 534 create( prof );
534} 535}
535void MainWindow::create( const Profile& prof ) { 536void MainWindow::create( const Profile& prof ) {
536 Session *ses = manager()->fromProfile( prof, tabWidget() ); 537 Session *ses = manager()->fromProfile( prof, tabWidget() );
537 538
538 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 539 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
539 { 540 {
540 QMessageBox::warning(this, 541 QMessageBox::warning(this,
541 QObject::tr("Session failed"), 542 QObject::tr("Session failed"),
542 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 543 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
543 //if(ses) delete ses; 544 //if(ses) delete ses;
544 return; 545 return;
545 } 546 }
546 547
547 m_sessions.append( ses ); 548 m_sessions.append( ses );
548 tabWidget()->add( ses ); 549 tabWidget()->add( ses );
549 tabWidget()->repaint(); 550 tabWidget()->repaint();
550 m_curSession = ses; 551 m_curSession = ses;
551 552
552 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 553 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
553 m_connect->setEnabled( true ); 554 m_connect->setEnabled( true );
554 m_disconnect->setEnabled( false ); 555 m_disconnect->setEnabled( false );
555 m_terminate->setEnabled( true ); 556 m_terminate->setEnabled( true );
556 m_fullscreen->setEnabled( true ); 557 m_fullscreen->setEnabled( true );
557 m_closewindow->setEnabled( true ); 558 m_closewindow->setEnabled( true );
558 m_transfer->setEnabled( false ); 559 m_transfer->setEnabled( false );
559 m_recordScript->setEnabled( false ); 560 m_recordScript->setEnabled( false );
560 m_saveScript->setEnabled( false ); 561 m_saveScript->setEnabled( false );
561 m_scripts->setItemEnabled(m_runScript_id, false); 562 m_scripts->setItemEnabled(m_runScript_id, false);
562 563
563 // is io_layer wants direct connection, then autoconnect 564 // is io_layer wants direct connection, then autoconnect
564 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 565 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
565 if (prof.autoConnect()) { 566 if (prof.autoConnect()) {
566 slotConnect(); 567 slotConnect();
567 } 568 }
568 569
569 570
570 571
571 QWidget *w = currentSession()->widget(); 572 QWidget *w = currentSession()->widget();
572 if(w) w->setFocus(); 573 if(w) w->setFocus();
573 574
574 m_kb->load(currentSession()->profile()); 575 m_kb->load(currentSession()->profile());
575} 576}
576 577
577void MainWindow::slotTransfer() 578void MainWindow::slotTransfer()
578{ 579{
579 if ( currentSession() ) { 580 if ( currentSession() ) {
580 TransferDialog dlg(currentSession()->widgetStack(), this); 581 TransferDialog dlg(currentSession()->widgetStack(), this);
581 dlg.showMaximized(); 582 dlg.showMaximized();
582 //currentSession()->widgetStack()->add(dlg); 583 //currentSession()->widgetStack()->add(dlg);
583 dlg.exec(); 584 dlg.exec();
584 } 585 }
585} 586}
586 587
587 588
588void MainWindow::slotOpenKeb(bool state) { 589void MainWindow::slotOpenKeb(bool state) {
589 590
590 if (state) m_keyBar->show(); 591 if (state) m_keyBar->show();
591 else m_keyBar->hide(); 592 else m_keyBar->hide();
592 593
593} 594}
594 595
595 596
596void MainWindow::slotOpenButtons( bool state ) { 597void MainWindow::slotOpenButtons( bool state ) {
597 598
598 if ( state ) { 599 if ( state ) {
599 m_buttonBar->show(); 600 m_buttonBar->show();
600 } else { 601 } else {
601 m_buttonBar->hide(); 602 m_buttonBar->hide();
602 } 603 }
603} 604}
604 605
605 606
606 607
607void MainWindow::slotSessionChanged( Session* ses ) { 608void MainWindow::slotSessionChanged( Session* ses ) {
608 qWarning("changed!"); 609 qWarning("changed!");
609 if ( ses ) { 610 if ( ses ) {
610 m_curSession = ses; 611 m_curSession = ses;
611 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 612 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
612 if ( m_curSession->layer()->isConnected() ) { 613 if ( m_curSession->layer()->isConnected() ) {
613 m_connect->setEnabled( false ); 614 m_connect->setEnabled( false );
614 m_disconnect->setEnabled( true ); 615 m_disconnect->setEnabled( true );
615 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); 616 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
616 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); 617 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
617 m_scripts->setItemEnabled(m_runScript_id, true); 618 m_scripts->setItemEnabled(m_runScript_id, true);
618 } else { 619 } else {
619 m_connect->setEnabled( true ); 620 m_connect->setEnabled( true );
620 m_disconnect->setEnabled( false ); 621 m_disconnect->setEnabled( false );
621 m_recordScript->setEnabled( false ); 622 m_recordScript->setEnabled( false );
622 m_saveScript->setEnabled( false ); 623 m_saveScript->setEnabled( false );
623 m_scripts->setItemEnabled(m_runScript_id, false); 624 m_scripts->setItemEnabled(m_runScript_id, false);
624 } 625 }
625 626
626 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 627 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
627 m_transfer->setEnabled( false ); 628 m_transfer->setEnabled( false );
628 } else { 629 } else {
629 m_transfer->setEnabled( true ); 630 m_transfer->setEnabled( true );
630 } 631 }
631 632
632 633
633 634
634 635
635 636
636 QWidget *w = m_curSession->widget(); 637 QWidget *w = m_curSession->widget();
637 if(w) w->setFocus(); 638 if(w) w->setFocus();
638 639
639 m_kb->load(currentSession()->profile()); 640 m_kb->load(currentSession()->profile());
640 } 641 }
641} 642}
642 643
643void MainWindow::slotFullscreen() { 644void MainWindow::slotFullscreen() {
644 645
645 646
646 647
647 if ( m_isFullscreen ) { 648 if ( m_isFullscreen ) {
648 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); 649 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
649 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); 650 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
650 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 651 ( m_curSession->emulationHandler() )->cornerButton()->hide();
651 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 652 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
652 653
653 } else { 654 } else {
654 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 655 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
655 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 656 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
656 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 657 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
657 , QPoint(0,0), false ); 658 , QPoint(0,0), false );
658 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 659 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
659 ( m_curSession->widgetStack() )->setFocus(); 660 ( m_curSession->widgetStack() )->setFocus();
660 ( m_curSession->widgetStack() )->show(); 661 ( m_curSession->widgetStack() )->show();
661 662
662 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 663 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
663 664
664 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 665 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
665 } 666 }
666 667
667 m_isFullscreen = !m_isFullscreen; 668 m_isFullscreen = !m_isFullscreen;
668} 669}
669 670
670 671
671void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { 672void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) {
672 673
673 if ( m_curSession ) { 674 if ( m_curSession ) {
674 675
675 QEvent::Type state; 676 QEvent::Type state;
676 677
677 if (pressed) state = QEvent::KeyPress; 678 if (pressed) state = QEvent::KeyPress;
678 else state = QEvent::KeyRelease; 679 else state = QEvent::KeyRelease;
679 680
680 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); 681 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode)));
681 682
682 // is this the best way to do this? cant figure out any other way to work 683 // is this the best way to do this? cant figure out any other way to work
683 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 684 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
684 ke.ignore(); 685 ke.ignore();
685 } 686 }
686} 687}
687void MainWindow::slotCopy() { 688void MainWindow::slotCopy() {
688 if (!currentSession() ) return; 689 if (!currentSession() ) return;
689 currentSession()->emulationHandler()->copy(); 690 currentSession()->emulationHandler()->copy();
690} 691}
691void MainWindow::slotPaste() { 692void MainWindow::slotPaste() {
692 if (!currentSession() ) return; 693 if (!currentSession() ) return;
693 currentSession()->emulationHandler()->paste(); 694 currentSession()->emulationHandler()->paste();
694} 695}
695 696
696/* 697/*
697 * Save the session 698 * Save the session
698 */ 699 */
699 700
700void MainWindow::slotSaveSession() { 701void MainWindow::slotSaveSession() {
701 if (!currentSession() ) { 702 if (!currentSession() ) {
702 QMessageBox::information(this, tr("Save Connection"), 703 QMessageBox::information(this, tr("Save Connection"),
703 tr("<qt>There is no Connection.</qt>"), 1 ); 704 tr("<qt>There is no Connection.</qt>"), 1 );
704 return; 705 return;
705 } 706 }
706 manager()->add( currentSession()->profile() ); 707 manager()->add( currentSession()->profile() );
707 manager()->save(); 708 manager()->save();
708 populateProfiles(); 709 populateProfiles();
709} 710}
diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp
index da5db83..ec83b9f 100644
--- a/noncore/apps/opie-console/modemconfigwidget.cpp
+++ b/noncore/apps/opie-console/modemconfigwidget.cpp
@@ -1,202 +1,203 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qcombobox.h> 3#include <qcombobox.h>
4#include <qlineedit.h> 4#include <qlineedit.h>
5#include <qpushbutton.h> 5#include <qpushbutton.h>
6#include <qhbox.h> 6#include <qhbox.h>
7#include <qregexp.h> 7#include <qregexp.h>
8 8
9#include "modemconfigwidget.h" 9#include "modemconfigwidget.h"
10#include "dialdialog.h" 10#include "dialdialog.h"
11 11
12namespace { 12namespace {
13 void setCurrent( const QString& str, QComboBox* bo ) { 13 void setCurrent( const QString& str, QComboBox* bo ) {
14 uint b = bo->count(); 14 uint b = bo->count();
15 for (int i = 0; i < bo->count(); i++ ) { 15 for (int i = 0; i < bo->count(); i++ ) {
16 if ( bo->text(i) == str ) { 16 if ( bo->text(i) == str ) {
17 bo->setCurrentItem( i ); 17 bo->setCurrentItem( i );
18 return; 18 return;
19 } 19 }
20 } 20 }
21 bo->insertItem( str ); 21 bo->insertItem( str );
22 bo->setCurrentItem( b ); 22 bo->setCurrentItem( b );
23 } 23 }
24} 24}
25 25
26ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, 26ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent,
27 const char* na ) 27 const char* na )
28 : ProfileDialogConnectionWidget( name, parent, na ) { 28 : ProfileDialogConnectionWidget( name, parent, na ) {
29 29
30 m_lay = new QVBoxLayout( this ); 30 m_lay = new QVBoxLayout( this );
31 m_device = new QLabel(tr( "Modem is attached to:" ), this ); 31 m_device = new QLabel(tr( "Modem is attached to:" ), this );
32 m_deviceCmb = new QComboBox(this ); 32 m_deviceCmb = new QComboBox(this );
33 m_deviceCmb->setEditable( TRUE ); 33 m_deviceCmb->setEditable( TRUE );
34 34
35 QLabel* telLabel = new QLabel( this ); 35 QLabel* telLabel = new QLabel( this );
36 telLabel->setText( tr( "Enter telefon number here:" ) ); 36 telLabel->setText( tr( "Enter telefon number here:" ) );
37 m_telNumber = new QLineEdit( this ); 37 m_telNumber = new QLineEdit( this );
38 QHBox *buttonBox = new QHBox( this ); 38 QHBox *buttonBox = new QHBox( this );
39 QPushButton *atButton = new QPushButton( buttonBox ); 39 QPushButton *atButton = new QPushButton( buttonBox );
40 atButton->setText( tr( "AT commands" ) ); 40 atButton->setText( tr( "AT commands" ) );
41 // disabled for now
41 atButton->hide(); 42 atButton->hide();
42 connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) ); 43 connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) );
43 44
44 QPushButton *dialButton = new QPushButton( buttonBox ); 45 QPushButton *dialButton = new QPushButton( buttonBox );
45 dialButton->setText( tr( "Enter number" ) ); 46 dialButton->setText( tr( "Enter number" ) );
46 connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) ); 47 connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) );
47 48
48 49
49 m_base = new IOLayerBase( this, "base" ); 50 m_base = new IOLayerBase( this, "base" );
50 51
51 m_lay->addWidget( m_device ); 52 m_lay->addWidget( m_device );
52 m_lay->addWidget( m_deviceCmb ); 53 m_lay->addWidget( m_deviceCmb );
53 m_lay->addWidget( telLabel ); 54 m_lay->addWidget( telLabel );
54 m_lay->addWidget( m_telNumber ); 55 m_lay->addWidget( m_telNumber );
55 m_lay->addWidget( buttonBox ); 56 m_lay->addWidget( buttonBox );
56 m_lay->addWidget( m_base ); 57 m_lay->addWidget( m_base );
57 58
58 m_deviceCmb->insertItem( "/dev/ttyS0" ); 59 m_deviceCmb->insertItem( "/dev/ttyS0" );
59 m_deviceCmb->insertItem( "/dev/ttyS1" ); 60 m_deviceCmb->insertItem( "/dev/ttyS1" );
60 m_deviceCmb->insertItem( "/dev/ttyS2" ); 61 m_deviceCmb->insertItem( "/dev/ttyS2" );
61 62
62 atConf = new ATConfigDialog( this, "ATConfig", true ); 63 atConf = new ATConfigDialog( this, "ATConfig", true );
63} 64}
64 65
65ModemConfigWidget::~ModemConfigWidget() { 66ModemConfigWidget::~ModemConfigWidget() {
66 67
67} 68}
68void ModemConfigWidget::load( const Profile& prof ) { 69void ModemConfigWidget::load( const Profile& prof ) {
69 70
70 int rad_flow = prof.readNumEntry( "Flow" ); 71 int rad_flow = prof.readNumEntry( "Flow" );
71 int rad_parity = prof.readNumEntry( "Parity" ); 72 int rad_parity = prof.readNumEntry( "Parity" );
72 int speed = prof.readNumEntry( "Speed" ); 73 int speed = prof.readNumEntry( "Speed" );
73 QString number = prof.readEntry( "Number" ); 74 QString number = prof.readEntry( "Number" );
74 75
75 if ( !number.isEmpty() ) { 76 if ( !number.isEmpty() ) {
76 m_telNumber->setText( number ); 77 m_telNumber->setText( number );
77 } 78 }
78 79
79 if ( rad_flow == 1 ) { 80 if ( rad_flow == 1 ) {
80 m_base->setFlow( IOLayerBase::Hardware ); 81 m_base->setFlow( IOLayerBase::Hardware );
81 } else if (rad_flow == 2) { 82 } else if (rad_flow == 2) {
82 m_base->setFlow( IOLayerBase::Software ); 83 m_base->setFlow( IOLayerBase::Software );
83 } else if (rad_flow == 0) { 84 } else if (rad_flow == 0) {
84 m_base->setFlow( IOLayerBase::None ); 85 m_base->setFlow( IOLayerBase::None );
85 } 86 }
86 87
87 88
88 if ( rad_parity == 1 ) { 89 if ( rad_parity == 1 ) {
89 m_base->setParity( IOLayerBase::Even ); 90 m_base->setParity( IOLayerBase::Even );
90 } else if ( rad_parity == 2 ){ 91 } else if ( rad_parity == 2 ){
91 m_base->setParity( IOLayerBase::Odd ); 92 m_base->setParity( IOLayerBase::Odd );
92 } else { 93 } else {
93 m_base->setParity( IOLayerBase::NonePar ); 94 m_base->setParity( IOLayerBase::NonePar );
94 } 95 }
95 96
96 switch( speed ) { 97 switch( speed ) {
97 case 115200: 98 case 115200:
98 m_base->setSpeed( IOLayerBase::Baud_115200 ); 99 m_base->setSpeed( IOLayerBase::Baud_115200 );
99 break; 100 break;
100 case 57600: 101 case 57600:
101 m_base->setSpeed( IOLayerBase::Baud_57600 ); 102 m_base->setSpeed( IOLayerBase::Baud_57600 );
102 break; 103 break;
103 case 38400: 104 case 38400:
104 m_base->setSpeed( IOLayerBase::Baud_38400 ); 105 m_base->setSpeed( IOLayerBase::Baud_38400 );
105 break; 106 break;
106 case 19200: 107 case 19200:
107 m_base->setSpeed( IOLayerBase::Baud_19200 ); 108 m_base->setSpeed( IOLayerBase::Baud_19200 );
108 break; 109 break;
109 case 9600: 110 case 9600:
110 default: 111 default:
111 m_base->setSpeed( IOLayerBase::Baud_9600 ); 112 m_base->setSpeed( IOLayerBase::Baud_9600 );
112 break; 113 break;
113 } 114 }
114 115
115 if ( prof.readEntry( "Device" ).isEmpty() ) { 116 if ( prof.readEntry( "Device" ).isEmpty() ) {
116 return; 117 return;
117 } 118 }
118 setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); 119 setCurrent( prof.readEntry( "Device" ), m_deviceCmb );
119 120
120 atConf->readConfig( prof ); 121 atConf->readConfig( prof );
121} 122}
122 123
123/* 124/*
124 * save speed, 125 * save speed,
125 * flow, 126 * flow,
126 * parity 127 * parity
127 */ 128 */
128void ModemConfigWidget::save( Profile& prof ) { 129void ModemConfigWidget::save( Profile& prof ) {
129 int flow, parity, speed; 130 int flow, parity, speed;
130 flow = parity = speed = 0; 131 flow = parity = speed = 0;
131 prof.writeEntry( "Device", m_deviceCmb->currentText() ); 132 prof.writeEntry( "Device", m_deviceCmb->currentText() );
132 133
133 134
134 switch( m_base->flow() ) { 135 switch( m_base->flow() ) {
135 case IOLayerBase::None: 136 case IOLayerBase::None:
136 flow = 0; 137 flow = 0;
137 break; 138 break;
138 case IOLayerBase::Software: 139 case IOLayerBase::Software:
139 flow = 2; 140 flow = 2;
140 break; 141 break;
141 case IOLayerBase::Hardware: 142 case IOLayerBase::Hardware:
142 flow = 1; 143 flow = 1;
143 break; 144 break;
144 } 145 }
145 146
146 switch( m_base->parity() ) { 147 switch( m_base->parity() ) {
147 case IOLayerBase::Odd: 148 case IOLayerBase::Odd:
148 parity = 2; 149 parity = 2;
149 break; 150 break;
150 case IOLayerBase::Even: 151 case IOLayerBase::Even:
151 parity = 1; 152 parity = 1;
152 break; 153 break;
153 case IOLayerBase::NonePar: 154 case IOLayerBase::NonePar:
154 parity = 0; 155 parity = 0;
155 break; 156 break;
156 } 157 }
157 158
158 switch( m_base->speed() ) { 159 switch( m_base->speed() ) {
159 case IOLayerBase::Baud_115200: 160 case IOLayerBase::Baud_115200:
160 speed = 115200; 161 speed = 115200;
161 break; 162 break;
162 case IOLayerBase::Baud_57600: 163 case IOLayerBase::Baud_57600:
163 speed = 57600; 164 speed = 57600;
164 break; 165 break;
165 case IOLayerBase::Baud_38400: 166 case IOLayerBase::Baud_38400:
166 speed = 38400; 167 speed = 38400;
167 break; 168 break;
168 case IOLayerBase::Baud_19200: 169 case IOLayerBase::Baud_19200:
169 speed = 19200; 170 speed = 19200;
170 break; 171 break;
171 case IOLayerBase::Baud_9600: 172 case IOLayerBase::Baud_9600:
172 speed = 9600; 173 speed = 9600;
173 break; 174 break;
174 } 175 }
175 176
176 prof.writeEntry( "Flow", flow ); 177 prof.writeEntry( "Flow", flow );
177 prof.writeEntry( "Parity", parity ); 178 prof.writeEntry( "Parity", parity );
178 prof.writeEntry( "Speed", speed ); 179 prof.writeEntry( "Speed", speed );
179 prof.writeEntry( "Number", m_telNumber->text() ); 180 prof.writeEntry( "Number", m_telNumber->text() );
180 181
181 182
182 atConf->writeConfig(prof); 183 atConf->writeConfig(prof);
183} 184}
184 185
185void ModemConfigWidget::slotAT() { 186void ModemConfigWidget::slotAT() {
186 // ATConfigDialog conf( this, "ATConfig", true ); 187 // ATConfigDialog conf( this, "ATConfig", true );
187 atConf->showMaximized(); 188 atConf->showMaximized();
188 if ( atConf->exec() != QDialog::Accepted ) { 189 if ( atConf->exec() != QDialog::Accepted ) {
189 // reload old settings 190 // reload old settings
190 } 191 }
191} 192}
192 193
193void ModemConfigWidget::slotDial() { 194void ModemConfigWidget::slotDial() {
194 DialDialog dial( this, "DialConfig", true ); 195 DialDialog dial( this, "DialConfig", true );
195 if(!m_telNumber->text().isEmpty()) { 196 if(!m_telNumber->text().isEmpty()) {
196 dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ \\.\\,]"), "")); 197 dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ \\.\\,]"), ""));
197 } 198 }
198 dial.showMaximized(); 199 dial.showMaximized();
199 if ( dial.exec() == QDialog::Accepted ) { 200 if ( dial.exec() == QDialog::Accepted ) {
200 m_telNumber->setText( dial.number() ); 201 m_telNumber->setText( dial.number() );
201 } 202 }
202} 203}