3 files changed, 173 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/mainwindow/mainwindow.ui b/noncore/settings/networksettings/mainwindow/mainwindow.ui index a730dd5..185b345 100644 --- a/noncore/settings/networksettings/mainwindow/mainwindow.ui +++ b/noncore/settings/networksettings/mainwindow/mainwindow.ui | |||
@@ -1,67 +1,70 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>MainWindow</class> | 2 | <class>MainWindow</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QWidget</class> | 4 | <class>QWidget</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>MainWindow</cstring> | 7 | <cstring>MainWindow</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
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>240</width> | 14 | <width>340</width> |
15 | <height>289</height> | 15 | <height>289</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> |
20 | <string>Network Settings</string> | 20 | <string>Network Settings</string> |
21 | </property> | 21 | </property> |
22 | <vbox> | 22 | <vbox> |
23 | <property stdset="1"> | 23 | <property stdset="1"> |
24 | <name>margin</name> | 24 | <name>margin</name> |
25 | <number>0</number> | 25 | <number>0</number> |
26 | </property> | 26 | </property> |
27 | <property stdset="1"> | 27 | <property stdset="1"> |
28 | <name>spacing</name> | 28 | <name>spacing</name> |
29 | <number>6</number> | 29 | <number>6</number> |
30 | </property> | 30 | </property> |
31 | <widget> | 31 | <widget> |
32 | <class>QTabWidget</class> | 32 | <class>QTabWidget</class> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>name</name> | 34 | <name>name</name> |
35 | <cstring>tabWidget</cstring> | 35 | <cstring>tabWidget</cstring> |
36 | </property> | 36 | </property> |
37 | <property stdset="1"> | 37 | <property stdset="1"> |
38 | <name>enabled</name> | 38 | <name>enabled</name> |
39 | <bool>true</bool> | 39 | <bool>true</bool> |
40 | </property> | 40 | </property> |
41 | <property> | 41 | <property> |
42 | <name>layoutMargin</name> | 42 | <name>layoutMargin</name> |
43 | </property> | 43 | </property> |
44 | <property> | ||
45 | <name>layoutSpacing</name> | ||
46 | </property> | ||
44 | <widget> | 47 | <widget> |
45 | <class>QWidget</class> | 48 | <class>QWidget</class> |
46 | <property stdset="1"> | 49 | <property stdset="1"> |
47 | <name>name</name> | 50 | <name>name</name> |
48 | <cstring>Widget3</cstring> | 51 | <cstring>Widget3</cstring> |
49 | </property> | 52 | </property> |
50 | <attribute> | 53 | <attribute> |
51 | <name>title</name> | 54 | <name>title</name> |
52 | <string>Connections</string> | 55 | <string>Connections</string> |
53 | </attribute> | 56 | </attribute> |
54 | <vbox> | 57 | <vbox> |
55 | <property stdset="1"> | 58 | <property stdset="1"> |
56 | <name>margin</name> | 59 | <name>margin</name> |
57 | <number>0</number> | 60 | <number>0</number> |
58 | </property> | 61 | </property> |
59 | <property stdset="1"> | 62 | <property stdset="1"> |
60 | <name>spacing</name> | 63 | <name>spacing</name> |
61 | <number>6</number> | 64 | <number>6</number> |
62 | </property> | 65 | </property> |
63 | <widget> | 66 | <widget> |
64 | <class>QListView</class> | 67 | <class>QListView</class> |
65 | <column> | 68 | <column> |
66 | <property> | 69 | <property> |
67 | <name>text</name> | 70 | <name>text</name> |
@@ -411,41 +414,140 @@ | |||
411 | <property stdset="1"> | 414 | <property stdset="1"> |
412 | <name>name</name> | 415 | <name>name</name> |
413 | <cstring>newProfile</cstring> | 416 | <cstring>newProfile</cstring> |
414 | </property> | 417 | </property> |
415 | </widget> | 418 | </widget> |
416 | <widget> | 419 | <widget> |
417 | <class>QPushButton</class> | 420 | <class>QPushButton</class> |
418 | <property stdset="1"> | 421 | <property stdset="1"> |
419 | <name>name</name> | 422 | <name>name</name> |
420 | <cstring>newProfileButton</cstring> | 423 | <cstring>newProfileButton</cstring> |
421 | </property> | 424 | </property> |
422 | <property stdset="1"> | 425 | <property stdset="1"> |
423 | <name>enabled</name> | 426 | <name>enabled</name> |
424 | <bool>false</bool> | 427 | <bool>false</bool> |
425 | </property> | 428 | </property> |
426 | <property stdset="1"> | 429 | <property stdset="1"> |
427 | <name>text</name> | 430 | <name>text</name> |
428 | <string>&Add</string> | 431 | <string>&Add</string> |
429 | </property> | 432 | </property> |
430 | </widget> | 433 | </widget> |
431 | </hbox> | 434 | </hbox> |
432 | </widget> | 435 | </widget> |
433 | </grid> | 436 | </grid> |
434 | </widget> | 437 | </widget> |
438 | <widget> | ||
439 | <class>QWidget</class> | ||
440 | <property stdset="1"> | ||
441 | <name>name</name> | ||
442 | <cstring>devicenametab</cstring> | ||
443 | </property> | ||
444 | <attribute> | ||
445 | <name>title</name> | ||
446 | <string>Device name</string> | ||
447 | </attribute> | ||
448 | <vbox> | ||
449 | <property stdset="1"> | ||
450 | <name>margin</name> | ||
451 | <number>11</number> | ||
452 | </property> | ||
453 | <property stdset="1"> | ||
454 | <name>spacing</name> | ||
455 | <number>6</number> | ||
456 | </property> | ||
457 | <widget> | ||
458 | <class>QLabel</class> | ||
459 | <property stdset="1"> | ||
460 | <name>name</name> | ||
461 | <cstring>m_NameHead</cstring> | ||
462 | </property> | ||
463 | <property stdset="1"> | ||
464 | <name>text</name> | ||
465 | <string><b>Name of the device</b></string> | ||
466 | </property> | ||
467 | </widget> | ||
468 | <widget> | ||
469 | <class>QLineEdit</class> | ||
470 | <property stdset="1"> | ||
471 | <name>name</name> | ||
472 | <cstring>m_Nameinput</cstring> | ||
473 | </property> | ||
474 | </widget> | ||
475 | <widget> | ||
476 | <class>QPushButton</class> | ||
477 | <property stdset="1"> | ||
478 | <name>name</name> | ||
479 | <cstring>m_setButton</cstring> | ||
480 | </property> | ||
481 | <property stdset="1"> | ||
482 | <name>text</name> | ||
483 | <string>Set value</string> | ||
484 | </property> | ||
485 | </widget> | ||
486 | <widget> | ||
487 | <class>QLabel</class> | ||
488 | <property stdset="1"> | ||
489 | <name>name</name> | ||
490 | <cstring>m_Infolabel</cstring> | ||
491 | </property> | ||
492 | <property stdset="1"> | ||
493 | <name>sizePolicy</name> | ||
494 | <sizepolicy> | ||
495 | <hsizetype>3</hsizetype> | ||
496 | <vsizetype>3</vsizetype> | ||
497 | </sizepolicy> | ||
498 | </property> | ||
499 | <property stdset="1"> | ||
500 | <name>text</name> | ||
501 | <string>The name here is that one your device identifying with on | ||
502 | console or infrared.</string> | ||
503 | </property> | ||
504 | </widget> | ||
505 | <spacer> | ||
506 | <property> | ||
507 | <name>name</name> | ||
508 | <cstring>Spacer5</cstring> | ||
509 | </property> | ||
510 | <property stdset="1"> | ||
511 | <name>orientation</name> | ||
512 | <enum>Vertical</enum> | ||
513 | </property> | ||
514 | <property stdset="1"> | ||
515 | <name>sizeType</name> | ||
516 | <enum>Expanding</enum> | ||
517 | </property> | ||
518 | <property> | ||
519 | <name>sizeHint</name> | ||
520 | <size> | ||
521 | <width>20</width> | ||
522 | <height>20</height> | ||
523 | </size> | ||
524 | </property> | ||
525 | </spacer> | ||
526 | </vbox> | ||
527 | </widget> | ||
435 | </widget> | 528 | </widget> |
436 | </vbox> | 529 | </vbox> |
437 | </widget> | 530 | </widget> |
531 | <connections> | ||
532 | <connection> | ||
533 | <sender>m_setButton</sender> | ||
534 | <signal>clicked()</signal> | ||
535 | <receiver>MainWindow</receiver> | ||
536 | <slot>setHostname()</slot> | ||
537 | </connection> | ||
538 | <slot access="protected">setHostname()</slot> | ||
539 | </connections> | ||
438 | <tabstops> | 540 | <tabstops> |
439 | <tabstop>tabWidget</tabstop> | 541 | <tabstop>tabWidget</tabstop> |
440 | <tabstop>connectionList</tabstop> | 542 | <tabstop>connectionList</tabstop> |
441 | <tabstop>informationConnectionButton</tabstop> | 543 | <tabstop>informationConnectionButton</tabstop> |
442 | <tabstop>configureConnectionButton</tabstop> | 544 | <tabstop>configureConnectionButton</tabstop> |
443 | <tabstop>addConnectionButton</tabstop> | 545 | <tabstop>addConnectionButton</tabstop> |
444 | <tabstop>removeConnectionButton</tabstop> | 546 | <tabstop>removeConnectionButton</tabstop> |
445 | <tabstop>profilesList</tabstop> | 547 | <tabstop>profilesList</tabstop> |
446 | <tabstop>setCurrentProfileButton</tabstop> | 548 | <tabstop>setCurrentProfileButton</tabstop> |
447 | <tabstop>removeProfileButton</tabstop> | 549 | <tabstop>removeProfileButton</tabstop> |
448 | <tabstop>newProfile</tabstop> | 550 | <tabstop>newProfile</tabstop> |
449 | <tabstop>newProfileButton</tabstop> | 551 | <tabstop>newProfileButton</tabstop> |
450 | </tabstops> | 552 | </tabstops> |
451 | </UI> | 553 | </UI> |
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp index f83e370..0a3312c 100644 --- a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp | |||
@@ -1,70 +1,78 @@ | |||
1 | 1 | ||
2 | #include "mainwindowimp.h" | 2 | #include "mainwindowimp.h" |
3 | #include "addconnectionimp.h" | 3 | #include "addconnectionimp.h" |
4 | #include "interfaceinformationimp.h" | 4 | #include "interfaceinformationimp.h" |
5 | #include "interfacesetupimp.h" | 5 | #include "interfacesetupimp.h" |
6 | #include "interfaces.h" | 6 | #include "interfaces.h" |
7 | #include "module.h" | 7 | #include "module.h" |
8 | 8 | ||
9 | /* OPIE */ | 9 | /* OPIE */ |
10 | #include <opie2/odebug.h> | 10 | #include <opie2/odebug.h> |
11 | #include <opie2/oprocess.h> | ||
11 | #include <qpe/applnk.h> | 12 | #include <qpe/applnk.h> |
12 | #include <qpe/qcopenvelope_qws.h> | 13 | #include <qpe/qcopenvelope_qws.h> |
13 | #include <qpe/qpeapplication.h> | 14 | #include <qpe/qpeapplication.h> |
14 | #include <qpe/config.h> | 15 | #include <qpe/config.h> |
15 | #include <qpe/qlibrary.h> | 16 | #include <qpe/qlibrary.h> |
16 | #include <qpe/resource.h> | 17 | #include <qpe/resource.h> |
17 | 18 | ||
18 | /* QT */ | 19 | /* QT */ |
19 | #include <qpushbutton.h> | 20 | #include <qpushbutton.h> |
20 | #include <qlistbox.h> | 21 | #include <qlistbox.h> |
21 | #include <qlineedit.h> | 22 | #include <qlineedit.h> |
22 | #include <qlistview.h> | 23 | #include <qlistview.h> |
23 | #include <qheader.h> | 24 | #include <qheader.h> |
24 | #include <qlabel.h> | 25 | #include <qlabel.h> |
25 | #include <qtabwidget.h> // in order to disable the profiles tab | 26 | #include <qtabwidget.h> // in order to disable the profiles tab |
26 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtextstream.h> | ||
27 | 29 | ||
28 | 30 | ||
29 | #if QT_VERSION < 0x030000 | 31 | #if QT_VERSION < 0x030000 |
30 | #include <qlist.h> | 32 | #include <qlist.h> |
31 | #else | 33 | #else |
32 | #include <qptrlist.h> | 34 | #include <qptrlist.h> |
33 | #endif | 35 | #endif |
34 | #include <qdir.h> | 36 | #include <qdir.h> |
35 | #include <qfile.h> | 37 | #include <qfile.h> |
36 | #include <qtextstream.h> | 38 | #include <qtextstream.h> |
37 | #include <qregexp.h> | 39 | #include <qregexp.h> |
38 | 40 | ||
39 | /* STD */ | 41 | /* STD */ |
40 | #include <net/if.h> | 42 | #include <net/if.h> |
41 | #include <sys/ioctl.h> | 43 | #include <sys/ioctl.h> |
42 | #include <sys/socket.h> | 44 | #include <sys/socket.h> |
43 | 45 | ||
44 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" | 46 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" |
45 | #define _PROCNETDEV "/proc/net/dev" | 47 | #define _PROCNETDEV "/proc/net/dev" |
46 | 48 | ||
49 | // is this always right? | ||
50 | #define _HOSTFILE "/etc/hostname" | ||
51 | #define _IRDANAME "/proc/sys/net/irda/devname" | ||
52 | |||
53 | using namespace Opie::Core; | ||
54 | |||
47 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) | 55 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) |
48 | { | 56 | { |
49 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 57 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
50 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 58 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
51 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 59 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
52 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | 60 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); |
53 | 61 | ||
54 | //remove tab with no function | 62 | //remove tab with no function |
55 | tabWidget->removePage( tab ); | 63 | tabWidget->removePage( tab ); |
56 | 64 | ||
57 | // Load connections. | 65 | // Load connections. |
58 | // /usr/local/kde/lib/libinterfaces.la | 66 | // /usr/local/kde/lib/libinterfaces.la |
59 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); | 67 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); |
60 | getAllInterfaces(); | 68 | getAllInterfaces(); |
61 | 69 | ||
62 | Interfaces i; | 70 | Interfaces i; |
63 | QStringList list = i.getInterfaceList(); | 71 | QStringList list = i.getInterfaceList(); |
64 | QMap<QString, Interface*>::Iterator it; | 72 | QMap<QString, Interface*>::Iterator it; |
65 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) | 73 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) |
66 | { | 74 | { |
67 | /* | 75 | /* |
68 | * we skipped it in getAllInterfaces now | 76 | * we skipped it in getAllInterfaces now |
69 | * we need to ignore it as well | 77 | * we need to ignore it as well |
70 | */ | 78 | */ |
@@ -101,48 +109,49 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWi | |||
101 | for ( QStringList::Iterator it = profiles.begin(); | 109 | for ( QStringList::Iterator it = profiles.begin(); |
102 | it != profiles.end(); ++it) | 110 | it != profiles.end(); ++it) |
103 | profilesList->insertItem((*it)); | 111 | profilesList->insertItem((*it)); |
104 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | 112 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); |
105 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 113 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
106 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 114 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
107 | 115 | ||
108 | QFile file(scheme); | 116 | QFile file(scheme); |
109 | if ( file.open(IO_ReadOnly) ) | 117 | if ( file.open(IO_ReadOnly) ) |
110 | { // file opened successfully | 118 | { // file opened successfully |
111 | QTextStream stream( &file ); // use a text stream | 119 | QTextStream stream( &file ); // use a text stream |
112 | while ( !stream.eof() ) | 120 | while ( !stream.eof() ) |
113 | { // until end of file... | 121 | { // until end of file... |
114 | QString line = stream.readLine(); // line of text excluding '\n' | 122 | QString line = stream.readLine(); // line of text excluding '\n' |
115 | if(line.contains("SCHEME")) | 123 | if(line.contains("SCHEME")) |
116 | { | 124 | { |
117 | line = line.mid(7, line.length()); | 125 | line = line.mid(7, line.length()); |
118 | currentProfileLabel->setText(line); | 126 | currentProfileLabel->setText(line); |
119 | break; | 127 | break; |
120 | } | 128 | } |
121 | } | 129 | } |
122 | file.close(); | 130 | file.close(); |
123 | } | 131 | } |
124 | makeChannel(); | 132 | makeChannel(); |
133 | initHostname(); | ||
125 | } | 134 | } |
126 | 135 | ||
127 | /** | 136 | /** |
128 | * Deconstructor. Save profiles. Delete loaded libraries. | 137 | * Deconstructor. Save profiles. Delete loaded libraries. |
129 | */ | 138 | */ |
130 | MainWindowImp::~MainWindowImp() | 139 | MainWindowImp::~MainWindowImp() |
131 | { | 140 | { |
132 | // Save profiles. | 141 | // Save profiles. |
133 | Config cfg("NetworkSetup"); | 142 | Config cfg("NetworkSetup"); |
134 | cfg.setGroup("General"); | 143 | cfg.setGroup("General"); |
135 | cfg.writeEntry("Profiles", profiles.join(" ")); | 144 | cfg.writeEntry("Profiles", profiles.join(" ")); |
136 | 145 | ||
137 | // Delete all interfaces that don't have owners. | 146 | // Delete all interfaces that don't have owners. |
138 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 147 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
139 | for( iIt = items.begin(); iIt != items.end(); ++iIt ) | 148 | for( iIt = items.begin(); iIt != items.end(); ++iIt ) |
140 | { | 149 | { |
141 | if(iIt.key()->getModuleOwner() == NULL) | 150 | if(iIt.key()->getModuleOwner() == NULL) |
142 | delete iIt.key(); | 151 | delete iIt.key(); |
143 | } | 152 | } |
144 | 153 | ||
145 | // Delete Modules and Libraries | 154 | // Delete Modules and Libraries |
146 | QMap<Module*, QLibrary*>::Iterator it; | 155 | QMap<Module*, QLibrary*>::Iterator it; |
147 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 156 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
148 | { | 157 | { |
@@ -693,24 +702,74 @@ void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) | |||
693 | raise(); | 702 | raise(); |
694 | return; | 703 | return; |
695 | } | 704 | } |
696 | 705 | ||
697 | QString dest = msg.left(msg.find("(")); | 706 | QString dest = msg.left(msg.find("(")); |
698 | QCString param = msg.right(msg.length() - msg.find("(") - 1); | 707 | QCString param = msg.right(msg.length() - msg.find("(") - 1); |
699 | param = param.left( param.length() - 1 ); | 708 | param = param.left( param.length() - 1 ); |
700 | odebug << "dest >" << dest.latin1() << "< param >"+param+"<" << oendl; | 709 | odebug << "dest >" << dest.latin1() << "< param >"+param+"<" << oendl; |
701 | 710 | ||
702 | QMap<Module*, QLibrary*>::Iterator it; | 711 | QMap<Module*, QLibrary*>::Iterator it; |
703 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 712 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
704 | { | 713 | { |
705 | odebug << "plugin >" << it.key()->type().latin1() << "<" << oendl; | 714 | odebug << "plugin >" << it.key()->type().latin1() << "<" << oendl; |
706 | if(it.key()->type() == dest) | 715 | if(it.key()->type() == dest) |
707 | { | 716 | { |
708 | it.key()->receive( param, arg ); | 717 | it.key()->receive( param, arg ); |
709 | found = true; | 718 | found = true; |
710 | } | 719 | } |
711 | } | 720 | } |
712 | 721 | ||
713 | 722 | ||
714 | if (found) QPEApplication::setKeepRunning(); | 723 | if (found) QPEApplication::setKeepRunning(); |
715 | else odebug << "Huh what do ya want" << oendl; | 724 | else odebug << "Huh what do ya want" << oendl; |
716 | } | 725 | } |
726 | |||
727 | void MainWindowImp::setHostname() | ||
728 | { | ||
729 | QFile f(_HOSTFILE); | ||
730 | |||
731 | OProcess*h = new OProcess; | ||
732 | _procTemp=""; | ||
733 | *h << "hostname" << m_Nameinput->text(); | ||
734 | connect(h,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int))); | ||
735 | h->start(OProcess::Block,OProcess::Stderr); | ||
736 | odebug << "Got " << _procTemp << " - " << h->exitStatus() << oendl; | ||
737 | _procTemp=""; | ||
738 | delete h; | ||
739 | |||
740 | if (f.open(IO_Truncate|IO_WriteOnly)) | ||
741 | { | ||
742 | QTextStream s(&f); | ||
743 | s << m_Nameinput->text(); | ||
744 | } | ||
745 | f.close(); | ||
746 | f.setName(_IRDANAME); | ||
747 | if (f.open(IO_WriteOnly)) | ||
748 | { | ||
749 | QTextStream s(&f); | ||
750 | s << m_Nameinput->text(); | ||
751 | } | ||
752 | } | ||
753 | |||
754 | void MainWindowImp::initHostname() | ||
755 | { | ||
756 | OProcess h; | ||
757 | _procTemp=""; | ||
758 | |||
759 | h << "hostname"; | ||
760 | connect(&h,SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int))); | ||
761 | h.start(OProcess::Block,OProcess::AllOutput); | ||
762 | odebug << "Got " << _procTemp <<oendl; | ||
763 | m_Nameinput->setText(_procTemp); | ||
764 | _procTemp=""; | ||
765 | } | ||
766 | |||
767 | void MainWindowImp::slotHostname(Opie::Core::OProcess *proc, char *buffer, int buflen) | ||
768 | { | ||
769 | if (buflen < 1 || buffer==0) return; | ||
770 | char*_t = new char[buflen+1]; | ||
771 | ::memset(_t,0,buflen+1); | ||
772 | ::memcpy(_t,buffer,buflen); | ||
773 | _procTemp+=_t; | ||
774 | delete[]_t; | ||
775 | } | ||
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.h b/noncore/settings/networksettings/mainwindow/mainwindowimp.h index f211d6e..da1bb8f 100644 --- a/noncore/settings/networksettings/mainwindow/mainwindowimp.h +++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.h | |||
@@ -1,75 +1,86 @@ | |||
1 | #ifndef MAINWINOWIMP_H | 1 | #ifndef MAINWINOWIMP_H |
2 | #define MAINWINOWIMP_H | 2 | #define MAINWINOWIMP_H |
3 | 3 | ||
4 | #include "mainwindow.h" | 4 | #include "mainwindow.h" |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstringlist.h> | 6 | #include <qstringlist.h> |
7 | 7 | ||
8 | class Module; | 8 | class Module; |
9 | class Interface; | 9 | class Interface; |
10 | class QLibrary; | 10 | class QLibrary; |
11 | class KProcess; | 11 | class KProcess; |
12 | class QCopChannel; | 12 | class QCopChannel; |
13 | #ifdef QWS | 13 | #ifdef QWS |
14 | class QLibrary; | 14 | class QLibrary; |
15 | #else | 15 | #else |
16 | class KLibrary; | 16 | class KLibrary; |
17 | class KLibLoader; | 17 | class KLibLoader; |
18 | #define QLibrary KLibrary | 18 | #define QLibrary KLibrary |
19 | #endif | 19 | #endif |
20 | 20 | ||
21 | namespace Opie { | ||
22 | namespace Core { | ||
23 | class OProcess; | ||
24 | } | ||
25 | } | ||
21 | 26 | ||
22 | class MainWindowImp : public MainWindow { | 27 | class MainWindowImp : public MainWindow { |
23 | Q_OBJECT | 28 | Q_OBJECT |
24 | 29 | ||
25 | public: | 30 | public: |
26 | static QString appName() { return QString::fromLatin1("networksettings"); } | 31 | static QString appName() { return QString::fromLatin1("networksettings"); } |
27 | MainWindowImp(QWidget *parent=0, const char *name=0, WFlags fl = 0); | 32 | MainWindowImp(QWidget *parent=0, const char *name=0, WFlags fl = 0); |
28 | ~MainWindowImp(); | 33 | ~MainWindowImp(); |
29 | 34 | ||
30 | QCopChannel *channel; | 35 | QCopChannel *channel; |
31 | 36 | ||
32 | private slots: | 37 | private slots: |
33 | void getAllInterfaces(); | 38 | void getAllInterfaces(); |
34 | 39 | ||
35 | void addClicked(); | 40 | void addClicked(); |
36 | void removeClicked(); | 41 | void removeClicked(); |
37 | void configureClicked(); | 42 | void configureClicked(); |
38 | void informationClicked(); | 43 | void informationClicked(); |
39 | 44 | ||
40 | void addProfile(); | 45 | void addProfile(); |
41 | void removeProfile(); | 46 | void removeProfile(); |
42 | void changeProfile(); | 47 | void changeProfile(); |
43 | 48 | ||
44 | void updateInterface(Interface *i); | 49 | void updateInterface(Interface *i); |
45 | void newProfileChanged(const QString& newText); | 50 | void newProfileChanged(const QString& newText); |
46 | 51 | ||
47 | void receive (const QCString &, const QByteArray &); | 52 | void receive (const QCString &, const QByteArray &); |
48 | 53 | ||
54 | protected slots: | ||
55 | virtual void setHostname(); | ||
56 | virtual void slotHostname(Opie::Core::OProcess *proc, char *buffer, int buflen); | ||
57 | |||
49 | private: | 58 | private: |
50 | void makeChannel(); | 59 | void makeChannel(); |
51 | void loadModules(const QString &path); | 60 | void loadModules(const QString &path); |
61 | void initHostname(); | ||
52 | 62 | ||
53 | Module* loadPlugin(const QString &pluginFileName, | 63 | Module* loadPlugin(const QString &pluginFileName, |
54 | const QString &resolveString = "create_plugin"); | 64 | const QString &resolveString = "create_plugin"); |
55 | 65 | ||
56 | // For our local list of names | 66 | // For our local list of names |
57 | QMap<QString, Interface*> interfaceNames; | 67 | QMap<QString, Interface*> interfaceNames; |
58 | 68 | ||
59 | QMap<Module*, QLibrary*> libraries; | 69 | QMap<Module*, QLibrary*> libraries; |
60 | QMap<Interface*, QListViewItem*> items; | 70 | QMap<Interface*, QListViewItem*> items; |
61 | QMap<QListViewItem*, Interface*> interfaceItems; | 71 | QMap<QListViewItem*, Interface*> interfaceItems; |
62 | QStringList m_handledIfaces; | 72 | QStringList m_handledIfaces; |
63 | 73 | ||
64 | QMap<KProcess*, QString> threads; | 74 | QMap<KProcess*, QString> threads; |
65 | QStringList profiles; | 75 | QStringList profiles; |
66 | 76 | ||
67 | bool advancedUserMode; | 77 | bool advancedUserMode; |
68 | QString scheme; | 78 | QString scheme; |
79 | QString _procTemp; | ||
69 | #ifndef QWS | 80 | #ifndef QWS |
70 | KLibLoader *loader; | 81 | KLibLoader *loader; |
71 | #endif | 82 | #endif |
72 | }; | 83 | }; |
73 | 84 | ||
74 | #endif // MAINWINOWIMP_H | 85 | #endif // MAINWINOWIMP_H |
75 | 86 | ||