Diffstat (limited to 'noncore/settings/networksettings') (more/less context) (show whitespace changes)
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 | |||
@@ -12,5 +12,5 @@ | |||
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> |
@@ -42,4 +42,7 @@ | |||
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> |
@@ -433,7 +436,106 @@ | |||
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> |
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 | |||
@@ -9,4 +9,5 @@ | |||
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> |
@@ -25,4 +26,5 @@ | |||
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 | ||
@@ -45,4 +47,10 @@ | |||
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 | { |
@@ -123,4 +131,5 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWi | |||
123 | } | 131 | } |
124 | makeChannel(); | 132 | makeChannel(); |
133 | initHostname(); | ||
125 | } | 134 | } |
126 | 135 | ||
@@ -715,2 +724,52 @@ void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) | |||
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 | |||
@@ -19,4 +19,9 @@ class KLibLoader; | |||
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 { |
@@ -47,7 +52,12 @@ private slots: | |||
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, |
@@ -67,4 +77,5 @@ private: | |||
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; |