-rw-r--r-- | libopie2/opiecore/oapplication.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiecore/oapplication.h | 6 | ||||
-rw-r--r-- | libopie2/opiecore/oglobal.h | 3 | ||||
-rw-r--r-- | libopie2/opiecore/oglobalsettings.h | 7 | ||||
-rw-r--r-- | libopie2/opienet/omanufacturerdb.h | 1 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.h | 3 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 2 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 4 | ||||
-rw-r--r-- | libopie2/opienet/opcap.h | 28 | ||||
-rw-r--r-- | libopie2/opieui/odialog.h | 5 | ||||
-rw-r--r-- | libopie2/opieui/oimageeffect.h | 1 | ||||
-rw-r--r-- | libopie2/opieui/olistview.h | 4 | ||||
-rw-r--r-- | libopie2/opieui/opopupmenu.h | 3 | ||||
-rw-r--r-- | libopie2/qt3/opiecore/opair.h | 1 |
14 files changed, 51 insertions, 19 deletions
diff --git a/libopie2/opiecore/oapplication.cpp b/libopie2/opiecore/oapplication.cpp index d3e04ba..ce26420 100644 --- a/libopie2/opiecore/oapplication.cpp +++ b/libopie2/opiecore/oapplication.cpp | |||
@@ -1,124 +1,124 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <opie2/oapplication.h> | 31 | #include <opie2/oapplication.h> |
32 | #include <opie2/oconfig.h> | 32 | #include <opie2/oconfig.h> |
33 | 33 | ||
34 | OApplication* OApplication::_instance = 0; | 34 | OApplication* OApplication::_instance = 0; |
35 | 35 | ||
36 | /**************************************************************************************************/ | 36 | /**************************************************************************************************/ |
37 | /* OApplicationPrivate | 37 | /* OApplicationPrivate |
38 | /**************************************************************************************************/ | 38 | /**************************************************************************************************/ |
39 | 39 | ||
40 | class OApplicationPrivate | 40 | class OApplicationPrivate |
41 | { | 41 | { |
42 | public: | 42 | public: |
43 | OApplicationPrivate() {}; | 43 | OApplicationPrivate() {}; |
44 | ~OApplicationPrivate() {}; | 44 | ~OApplicationPrivate() {}; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | /**************************************************************************************************/ | 47 | /**************************************************************************************************/ |
48 | /* OApplication | 48 | /* OApplication |
49 | /**************************************************************************************************/ | 49 | /**************************************************************************************************/ |
50 | 50 | ||
51 | 51 | ||
52 | OApplication::OApplication( int& argc, char** argv, const QCString& rAppName ) | 52 | OApplication::OApplication( int& argc, char** argv, const QCString& rAppName ) |
53 | :OApplicationBaseClass( argc, argv ), | 53 | :OApplicationBaseClass( argc, argv ), |
54 | _appname( rAppName ), | 54 | _appname( rAppName ), |
55 | _config( 0 ) | 55 | _config( 0 ) |
56 | { | 56 | { |
57 | init(); | 57 | init(); |
58 | } | 58 | } |
59 | 59 | ||
60 | 60 | ||
61 | OApplication::~OApplication() | 61 | OApplication::~OApplication() |
62 | { | 62 | { |
63 | delete d; | 63 | delete d; |
64 | if ( _config ) | 64 | if ( _config ) |
65 | delete _config; | 65 | delete _config; |
66 | OApplication::_instance = 0; | 66 | OApplication::_instance = 0; |
67 | // after deconstruction of the one-and-only application object, | 67 | // after deconstruction of the one-and-only application object, |
68 | // the construction of another object is allowed | 68 | // the construction of another object is allowed |
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | OConfig* OApplication::config() | 72 | OConfig* OApplication::config() |
73 | { | 73 | { |
74 | if ( !_config ) | 74 | if ( !_config ) |
75 | { | 75 | { |
76 | _config = new OConfig( _appname ); | 76 | _config = new OConfig( _appname ); |
77 | } | 77 | } |
78 | return _config; | 78 | return _config; |
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||
82 | void OApplication::init() | 82 | void OApplication::init() |
83 | { | 83 | { |
84 | d = new OApplicationPrivate(); | 84 | d = new OApplicationPrivate(); |
85 | if ( !OApplication::_instance ) | 85 | if ( !OApplication::_instance ) |
86 | { | 86 | { |
87 | OApplication::_instance = this; | 87 | OApplication::_instance = this; |
88 | } | 88 | } |
89 | else | 89 | else |
90 | { | 90 | { |
91 | qFatal( "OApplication: Can't create more than one OApplication object. Aborting." ); | 91 | qFatal( "OApplication: Can't create more than one OApplication object. Aborting." ); |
92 | } | 92 | } |
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | void OApplication::setMainWidget( QWidget* widget ) | 96 | void OApplication::setMainWidget( QWidget* widget ) |
97 | { | 97 | { |
98 | showMainWidget( widget ); | 98 | showMainWidget( widget ); |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | void OApplication::showMainWidget( QWidget* widget, bool nomax ) | 102 | void OApplication::showMainWidget( QWidget* widget, bool nomax ) |
103 | { | 103 | { |
104 | #ifdef Q_WS_QWS | 104 | #ifdef Q_WS_QWS |
105 | QPEApplication::showMainWidget( widget, nomax ); | 105 | QPEApplication::showMainWidget( widget, nomax ); |
106 | #else | 106 | #else |
107 | QApplication::setMainWidget( widget ); | 107 | QApplication::setMainWidget( widget ); |
108 | widget->show(); | 108 | widget->show(); |
109 | #endif | 109 | #endif |
110 | widget->setCaption( _appname ); | 110 | widget->setCaption( _appname ); |
111 | } | 111 | } |
112 | 112 | ||
113 | 113 | ||
114 | void OApplication::setTitle( QString title ) const | 114 | void OApplication::setTitle( const QString& title ) const |
115 | { | 115 | { |
116 | if ( mainWidget() ) | 116 | if ( mainWidget() ) |
117 | { | 117 | { |
118 | if ( !title.isNull() ) | 118 | if ( !title.isNull() ) |
119 | mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title ); | 119 | mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title ); |
120 | else | 120 | else |
121 | mainWidget()->setCaption( _appname ); | 121 | mainWidget()->setCaption( _appname ); |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
diff --git a/libopie2/opiecore/oapplication.h b/libopie2/opiecore/oapplication.h index 4d25202..8326847 100644 --- a/libopie2/opiecore/oapplication.h +++ b/libopie2/opiecore/oapplication.h | |||
@@ -1,130 +1,134 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef OAPPLICATION_H | 31 | #ifndef OAPPLICATION_H |
32 | #define OAPPLICATION_H | 32 | #define OAPPLICATION_H |
33 | 33 | ||
34 | #define oApp OApplication::oApplication() | 34 | #define oApp OApplication::oApplication() |
35 | 35 | ||
36 | // the below stuff will fail with moc because moc does not pre process headers | ||
37 | // This will make usage of signal and slots hard inside QPEApplication -zecke | ||
38 | |||
36 | #ifdef QWS | 39 | #ifdef QWS |
37 | #include <qpe/qpeapplication.h> | 40 | #include <qpe/qpeapplication.h> |
38 | #define OApplicationBaseClass QPEApplication | 41 | #define OApplicationBaseClass QPEApplication |
39 | #else | 42 | #else |
40 | #include <qapplication.h> | 43 | #include <qapplication.h> |
41 | #define OApplicationBaseClass QApplication | 44 | #define OApplicationBaseClass QApplication |
42 | #endif | 45 | #endif |
43 | 46 | ||
44 | class OApplicationPrivate; | 47 | class OApplicationPrivate; |
45 | class OConfig; | 48 | class OConfig; |
46 | 49 | ||
47 | class OApplication: public OApplicationBaseClass | 50 | class OApplication: public OApplicationBaseClass |
48 | { | 51 | { |
52 | // Q_OBJECT would fail -zecke | ||
49 | public: | 53 | public: |
50 | 54 | ||
51 | /** | 55 | /** |
52 | * Constructor. Parses command-line arguments and sets the window caption. | 56 | * Constructor. Parses command-line arguments and sets the window caption. |
53 | * | 57 | * |
54 | * @param rAppName application name. Will be used for finding the | 58 | * @param rAppName application name. Will be used for finding the |
55 | * associated message, icon and configuration files | 59 | * associated message, icon and configuration files |
56 | * | 60 | * |
57 | */ | 61 | */ |
58 | OApplication( int& argc, char** argv, const QCString& rAppName ); | 62 | OApplication( int& argc, char** argv, const QCString& rAppName ); |
59 | /** | 63 | /** |
60 | * Destructor. Destroys the application object and its children. | 64 | * Destructor. Destroys the application object and its children. |
61 | */ | 65 | */ |
62 | virtual ~OApplication(); | 66 | virtual ~OApplication(); |
63 | 67 | ||
64 | /** | 68 | /** |
65 | * Returns the current application object. | 69 | * Returns the current application object. |
66 | * | 70 | * |
67 | * This is similar to the global @ref QApplication pointer qApp. It | 71 | * This is similar to the global @ref QApplication pointer qApp. It |
68 | * allows access to the single global OApplication object, since | 72 | * allows access to the single global OApplication object, since |
69 | * more than one cannot be created in the same application. It | 73 | * more than one cannot be created in the same application. It |
70 | * saves you the trouble of having to pass the pointer explicitly | 74 | * saves you the trouble of having to pass the pointer explicitly |
71 | * to every function that may require it. | 75 | * to every function that may require it. |
72 | * | 76 | * |
73 | * @return the current application object | 77 | * @return the current application object |
74 | */ | 78 | */ |
75 | static const OApplication* oApplication() { return _instance; }; | 79 | static const OApplication* oApplication() { return _instance; }; |
76 | 80 | ||
77 | /** | 81 | /** |
78 | * Returns the application name as given during creation. | 82 | * Returns the application name as given during creation. |
79 | * | 83 | * |
80 | * @return A reference to the application name | 84 | * @return A reference to the application name |
81 | */ | 85 | */ |
82 | const QCString& appName() const { return _appname; }; | 86 | const QCString& appName() const { return _appname; }; |
83 | 87 | ||
84 | /** | 88 | /** |
85 | * Returns the application session config object. | 89 | * Returns the application session config object. |
86 | * | 90 | * |
87 | * @return A pointer to the application's instance specific | 91 | * @return A pointer to the application's instance specific |
88 | * @ref OConfig object. | 92 | * @ref OConfig object. |
89 | * @see OConfig | 93 | * @see OConfig |
90 | */ | 94 | */ |
91 | OConfig* config(); | 95 | OConfig* config(); |
92 | 96 | ||
93 | /** | 97 | /** |
94 | * Sets the main widget - reimplemented to call showMainWidget() | 98 | * Sets the main widget - reimplemented to call showMainWidget() |
95 | * on Qt/Embedded. | 99 | * on Qt/Embedded. |
96 | * | 100 | * |
97 | * @param mainWidget the widget to become the main widget | 101 | * @param mainWidget the widget to become the main widget |
98 | * @see QWidget object | 102 | * @see QWidget object |
99 | */ | 103 | */ |
100 | virtual void setMainWidget( QWidget *mainWidget ); | 104 | virtual void setMainWidget( QWidget *mainWidget ); |
101 | 105 | ||
102 | /** | 106 | /** |
103 | * Shows the main widget - reimplemented to call setMainWidget() | 107 | * Shows the main widget - reimplemented to call setMainWidget() |
104 | * on platforms other than Qt/Embedded. | 108 | * on platforms other than Qt/Embedded. |
105 | * | 109 | * |
106 | * @param mainWidget the widget to become the main widget | 110 | * @param mainWidget the widget to become the main widget |
107 | * @see QWidget object | 111 | * @see QWidget object |
108 | */ | 112 | */ |
109 | virtual void showMainWidget( QWidget* widget, bool nomax = false ); | 113 | virtual void showMainWidget( QWidget* widget, bool nomax = false ); |
110 | 114 | ||
111 | /** | 115 | /** |
112 | * Set the application title. The application title will be concatenated | 116 | * Set the application title. The application title will be concatenated |
113 | * to the application name given in the constructor. | 117 | * to the application name given in the constructor. |
114 | * | 118 | * |
115 | * @param title the title. If not given, resets caption to appname | 119 | * @param title the title. If not given, resets caption to appname |
116 | */ | 120 | */ |
117 | virtual void setTitle( QString title = QString::null ) const; | 121 | virtual void setTitle( const QString& title = QString::null ) const; |
118 | //virtual void setTitle() const; | 122 | //virtual void setTitle() const; |
119 | 123 | ||
120 | protected: | 124 | protected: |
121 | void init(); | 125 | void init(); |
122 | 126 | ||
123 | private: | 127 | private: |
124 | const QCString _appname; | 128 | const QCString _appname; |
125 | static OApplication* _instance; | 129 | static OApplication* _instance; |
126 | OConfig* _config; | 130 | OConfig* _config; |
127 | OApplicationPrivate* d; | 131 | OApplicationPrivate* d; |
128 | }; | 132 | }; |
129 | 133 | ||
130 | #endif // OAPPLICATION_H | 134 | #endif // OAPPLICATION_H |
diff --git a/libopie2/opiecore/oglobal.h b/libopie2/opiecore/oglobal.h index 8345c6a..34f211e 100644 --- a/libopie2/opiecore/oglobal.h +++ b/libopie2/opiecore/oglobal.h | |||
@@ -1,48 +1,49 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef OGLOBAL_H | 31 | #ifndef OGLOBAL_H |
32 | #define OGLOBAL_H | 32 | #define OGLOBAL_H |
33 | 33 | ||
34 | #include <qpe/global.h> | 34 | #include <qpe/global.h> |
35 | #include <opie2/oconfig.h> | 35 | #include <opie2/oconfig.h> |
36 | 36 | ||
37 | static OConfig globalconfig = OConfig( "global" ); | 37 | static OConfig globalconfig = OConfig( "global" ); |
38 | 38 | ||
39 | //FIXME: Is it wise or even necessary to inherit OGlobal from Global? | 39 | //FIXME: Is it wise or even necessary to inherit OGlobal from Global? |
40 | // once we totally skip libqpe it should ideally swallow Global -zecke | ||
40 | 41 | ||
41 | class OGlobal : public Global | 42 | class OGlobal : public Global |
42 | { | 43 | { |
43 | public: | 44 | public: |
44 | 45 | // do we want to put that into OApplication as in KApplication -zecke | |
45 | static OConfig* config(); | 46 | static OConfig* config(); |
46 | }; | 47 | }; |
47 | 48 | ||
48 | #endif // OGLOBAL_H | 49 | #endif // OGLOBAL_H |
diff --git a/libopie2/opiecore/oglobalsettings.h b/libopie2/opiecore/oglobalsettings.h index 6481251..d3f357e 100644 --- a/libopie2/opiecore/oglobalsettings.h +++ b/libopie2/opiecore/oglobalsettings.h | |||
@@ -1,368 +1,373 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> | 3 | Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> |
4 | Inspired by KDE OGlobalSettings | 4 | Inspired by KDE OGlobalSettings |
5 | Copyright (C) 2000 David Faure <faure@kde.org> | 5 | Copyright (C) 2000 David Faure <faure@kde.org> |
6 | =. | 6 | =. |
7 | .=l. | 7 | .=l. |
8 | .>+-= | 8 | .>+-= |
9 | _;:, .> :=|. This program is free software; you can | 9 | _;:, .> :=|. This program is free software; you can |
10 | .> <`_, > . <= redistribute it and/or modify it under | 10 | .> <`_, > . <= redistribute it and/or modify it under |
11 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 11 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
12 | .="- .-=="i, .._ License as published by the Free Software | 12 | .="- .-=="i, .._ License as published by the Free Software |
13 | - . .-<_> .<> Foundation; either version 2 of the License, | 13 | - . .-<_> .<> Foundation; either version 2 of the License, |
14 | ._= =} : or (at your option) any later version. | 14 | ._= =} : or (at your option) any later version. |
15 | .%`+i> _;_. | 15 | .%`+i> _;_. |
16 | .i_,=:_. -<s. This program is distributed in the hope that | 16 | .i_,=:_. -<s. This program is distributed in the hope that |
17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
18 | : .. .:, . . . without even the implied warranty of | 18 | : .. .:, . . . without even the implied warranty of |
19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
21 | ..}^=.= = ; Library General Public License for more | 21 | ..}^=.= = ; Library General Public License for more |
22 | ++= -. .` .: details. | 22 | ++= -. .` .: details. |
23 | : = ...= . :.=- | 23 | : = ...= . :.=- |
24 | -. .:....=;==+<; You should have received a copy of the GNU | 24 | -. .:....=;==+<; You should have received a copy of the GNU |
25 | -_. . . )=. = Library General Public License along with | 25 | -_. . . )=. = Library General Public License along with |
26 | -- :-=` this library; see the file COPYING.LIB. | 26 | -- :-=` this library; see the file COPYING.LIB. |
27 | If not, write to the Free Software Foundation, | 27 | If not, write to the Free Software Foundation, |
28 | Inc., 59 Temple Place - Suite 330, | 28 | Inc., 59 Temple Place - Suite 330, |
29 | Boston, MA 02111-1307, USA. | 29 | Boston, MA 02111-1307, USA. |
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef OGLOBALSETTINGS_H | 32 | #ifndef OGLOBALSETTINGS_H |
33 | #define OGLOBALSETTINGS_H | 33 | #define OGLOBALSETTINGS_H |
34 | 34 | ||
35 | #include <qstring.h> | 35 | #include <qstring.h> |
36 | #include <qcolor.h> | 36 | #include <qcolor.h> |
37 | #include <qfont.h> | 37 | #include <qfont.h> |
38 | 38 | ||
39 | #define OPIE_DEFAULT_SINGLECLICK true | 39 | #define OPIE_DEFAULT_SINGLECLICK true |
40 | #define OPIE_DEFAULT_INSERTTEAROFFHANDLES true | 40 | #define OPIE_DEFAULT_INSERTTEAROFFHANDLES true |
41 | #define OPIE_DEFAULT_AUTOSELECTDELAY -1 | 41 | #define OPIE_DEFAULT_AUTOSELECTDELAY -1 |
42 | #define OPIE_DEFAULT_CHANGECURSOR true | 42 | #define OPIE_DEFAULT_CHANGECURSOR true |
43 | #define OPIE_DEFAULT_LARGE_CURSOR false | 43 | #define OPIE_DEFAULT_LARGE_CURSOR false |
44 | #define OPIE_DEFAULT_VISUAL_ACTIVATE true | 44 | #define OPIE_DEFAULT_VISUAL_ACTIVATE true |
45 | #define OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED 50 | 45 | #define OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED 50 |
46 | 46 | ||
47 | //FIXME: There's still a whole lot of stuff in here which has to be revised | 47 | //FIXME: There's still a whole lot of stuff in here which has to be revised |
48 | //FIXME: before public usage... lack of time to do it at once - so it will | 48 | //FIXME: before public usage... lack of time to do it at once - so it will |
49 | //FIXME: happen step-by-step. ML. | 49 | //FIXME: happen step-by-step. ML. |
50 | // we should not habe too much configure options!!!!!! -zecke | ||
50 | 51 | ||
51 | /** | 52 | /** |
52 | * Access the OPIE global configuration settings. | 53 | * Access the OPIE global configuration settings. |
53 | * | 54 | * |
54 | */ | 55 | */ |
55 | class OGlobalSettings | 56 | class OGlobalSettings |
56 | { | 57 | { |
57 | public: | 58 | public: |
58 | 59 | ||
59 | /** | 60 | /** |
60 | * Returns a threshold in pixels for drag & drop operations. | 61 | * Returns a threshold in pixels for drag & drop operations. |
61 | * As long as the mouse movement has not exceeded this number | 62 | * As long as the mouse movement has not exceeded this number |
62 | * of pixels in either X or Y direction no drag operation may | 63 | * of pixels in either X or Y direction no drag operation may |
63 | * be started. This prevents spurious drags when the user intended | 64 | * be started. This prevents spurious drags when the user intended |
64 | * to click on something but moved the mouse a bit while doing so. | 65 | * to click on something but moved the mouse a bit while doing so. |
65 | * | 66 | * |
66 | * For this to work you must save the position of the mouse (oldPos) | 67 | * For this to work you must save the position of the mouse (oldPos) |
67 | * in the @ref QWidget::mousePressEvent(). | 68 | * in the @ref QWidget::mousePressEvent(). |
68 | * When the position of the mouse (newPos) | 69 | * When the position of the mouse (newPos) |
69 | * in a @ref QWidget::mouseMoveEvent() exceeds this threshold | 70 | * in a @ref QWidget::mouseMoveEvent() exceeds this threshold |
70 | * you may start a drag | 71 | * you may start a drag |
71 | * which should originate from oldPos. | 72 | * which should originate from oldPos. |
72 | * | 73 | * |
73 | * Example code: | 74 | * Example code: |
74 | * <pre> | 75 | * <pre> |
75 | * void OColorCells::mousePressEvent( QMouseEvent *e ) | 76 | * void OColorCells::mousePressEvent( QMouseEvent *e ) |
76 | * { | 77 | * { |
77 | * mOldPos = e->pos(); | 78 | * mOldPos = e->pos(); |
78 | * } | 79 | * } |
79 | * | 80 | * |
80 | * void OColorCells::mouseMoveEvent( QMouseEvent *e ) | 81 | * void OColorCells::mouseMoveEvent( QMouseEvent *e ) |
81 | * { | 82 | * { |
82 | * if( !(e->state() && LeftButton)) return; | 83 | * if( !(e->state() && LeftButton)) return; |
83 | * | 84 | * |
84 | * int delay = OGlobalSettings::dndEventDelay(); | 85 | * int delay = OGlobalSettings::dndEventDelay(); |
85 | * QPoint newPos = e->pos(); | 86 | * QPoint newPos = e->pos(); |
86 | * if(newPos.x() > mOldPos.x()+delay || newPos.x() < mOldPos.x()-delay || | 87 | * if(newPos.x() > mOldPos.x()+delay || newPos.x() < mOldPos.x()-delay || |
87 | * newPos.y() > mOldPos.y()+delay || newPos.y() < mOldPos.y()-delay) | 88 | * newPos.y() > mOldPos.y()+delay || newPos.y() < mOldPos.y()-delay) |
88 | * { | 89 | * { |
89 | * // Drag color object | 90 | * // Drag color object |
90 | * int cell = posToCell(mOldPos); // Find color at mOldPos | 91 | * int cell = posToCell(mOldPos); // Find color at mOldPos |
91 | * if ((cell != -1) && colors[cell].isValid()) | 92 | * if ((cell != -1) && colors[cell].isValid()) |
92 | * { | 93 | * { |
93 | * OColorDrag *d = OColorDrag::makeDrag( colors[cell], this); | 94 | * OColorDrag *d = OColorDrag::makeDrag( colors[cell], this); |
94 | * d->dragCopy(); | 95 | * d->dragCopy(); |
95 | * } | 96 | * } |
96 | * } | 97 | * } |
97 | * } | 98 | * } |
98 | * </pre> | 99 | * </pre> |
99 | * | 100 | * |
100 | */ | 101 | */ |
101 | 102 | ||
103 | // we do not support DND at the momemt -zecke | ||
102 | static int dndEventDelay(); | 104 | static int dndEventDelay(); |
103 | 105 | ||
104 | /** | 106 | /** |
105 | * Returns whether OPIE runs in single (default) or double click | 107 | * Returns whether OPIE runs in single (default) or double click |
106 | * mode. | 108 | * mode. |
107 | * | 109 | * |
108 | * @return @p true if single click mode, or @p false if double click mode. | 110 | * @return @p true if single click mode, or @p false if double click mode. |
109 | * | 111 | * |
110 | * see @ref http://opie.handhelds.org/documentation/standards/opie/style/mouse/index.html | 112 | * see @ref http://opie.handhelds.org/documentation/standards/opie/style/mouse/index.html |
111 | **/ | 113 | **/ |
112 | static bool singleClick(); | 114 | static bool singleClick(); |
113 | 115 | ||
114 | /** | 116 | /** |
115 | * Returns whether tear-off handles are inserted in OPopupMenus. | 117 | * Returns whether tear-off handles are inserted in OPopupMenus. |
116 | **/ | 118 | **/ |
119 | // would clutter the small screen -zecke | ||
117 | static bool insertTearOffHandle(); | 120 | static bool insertTearOffHandle(); |
118 | 121 | ||
119 | /** | 122 | /** |
120 | * @return the OPIE setting for "change cursor over icon" | 123 | * @return the OPIE setting for "change cursor over icon" |
121 | */ | 124 | */ |
122 | static bool changeCursorOverIcon(); | 125 | static bool changeCursorOverIcon(); |
123 | 126 | ||
124 | /** | 127 | /** |
125 | * @return whether to show some feedback when an item (specifically an | 128 | * @return whether to show some feedback when an item (specifically an |
126 | * icon) is activated. | 129 | * icon) is activated. |
127 | */ | 130 | */ |
128 | static bool visualActivate(); | 131 | static bool visualActivate(); |
129 | static unsigned int visualActivateSpeed(); | 132 | static unsigned int visualActivateSpeed(); |
130 | 133 | ||
131 | /** | 134 | /** |
132 | * Returns the OPIE setting for the auto-select option | 135 | * Returns the OPIE setting for the auto-select option |
133 | * | 136 | * |
134 | * @return the auto-select delay or -1 if auto-select is disabled. | 137 | * @return the auto-select delay or -1 if auto-select is disabled. |
135 | */ | 138 | */ |
136 | static int autoSelectDelay(); | 139 | static int autoSelectDelay(); |
137 | 140 | ||
138 | /** | 141 | /** |
139 | * Returns the OPIE setting for the shortcut key to open | 142 | * Returns the OPIE setting for the shortcut key to open |
140 | * context menus. | 143 | * context menus. |
141 | * | 144 | * |
142 | * @return the key that pops up context menus. | 145 | * @return the key that pops up context menus. |
143 | */ | 146 | */ |
144 | static int contextMenuKey(); | 147 | static int contextMenuKey(); |
145 | 148 | ||
146 | /** | 149 | /** |
147 | * Returns the OPIE setting for context menus. | 150 | * Returns the OPIE setting for context menus. |
148 | * | 151 | * |
149 | * @return whether context menus should be shown on button press | 152 | * @return whether context menus should be shown on button press |
150 | * or button release (click). | 153 | * or button release (click). |
151 | */ | 154 | */ |
152 | static bool showContextMenusOnPress (); | 155 | static bool showContextMenusOnPress (); |
153 | 156 | ||
154 | /** | 157 | /** |
155 | * This enum describes the completion mode used for by the @ref OCompletion class. | 158 | * This enum describes the completion mode used for by the @ref OCompletion class. |
156 | * See <a href="http://opie.handhelds.org/documentation/standards/opie/style/keys/completion.html"> | 159 | * See <a href="http://opie.handhelds.org/documentation/standards/opie/style/keys/completion.html"> |
157 | * the styleguide</a>. | 160 | * the styleguide</a>. |
158 | **/ | 161 | **/ |
159 | enum Completion { | 162 | enum Completion { |
160 | /** | 163 | /** |
161 | * No completion is used. | 164 | * No completion is used. |
162 | */ | 165 | */ |
163 | CompletionNone=1, | 166 | CompletionNone=1, |
164 | /** | 167 | /** |
165 | * Text is automatically filled in whenever possible. | 168 | * Text is automatically filled in whenever possible. |
166 | */ | 169 | */ |
167 | CompletionAuto, | 170 | CompletionAuto, |
168 | /** | 171 | /** |
169 | * Same as automatic except shortest match is used for completion. | 172 | * Same as automatic except shortest match is used for completion. |
170 | */ | 173 | */ |
171 | CompletionMan, | 174 | CompletionMan, |
172 | /** | 175 | /** |
173 | * Complete text much in the same way as a typical *nix shell would. | 176 | * Complete text much in the same way as a typical *nix shell would. |
174 | */ | 177 | */ |
175 | CompletionShell, | 178 | CompletionShell, |
176 | /** | 179 | /** |
177 | * Lists all possible matches in a popup list-box to choose from. | 180 | * Lists all possible matches in a popup list-box to choose from. |
178 | */ | 181 | */ |
179 | CompletionPopup, | 182 | CompletionPopup, |
180 | /** | 183 | /** |
181 | * Lists all possible matches in a popup list-box to choose from, and automatically | 184 | * Lists all possible matches in a popup list-box to choose from, and automatically |
182 | * fill the result whenever possible. | 185 | * fill the result whenever possible. |
183 | */ | 186 | */ |
184 | CompletionPopupAuto | 187 | CompletionPopupAuto |
185 | }; | 188 | }; |
186 | /** | 189 | /** |
187 | * Returns the preferred completion mode setting. | 190 | * Returns the preferred completion mode setting. |
188 | * | 191 | * |
189 | * @return @ref Completion. Default is @p CompletionPopup. | 192 | * @return @ref Completion. Default is @p CompletionPopup. |
190 | */ | 193 | */ |
191 | static Completion completionMode(); | 194 | static Completion completionMode(); |
192 | 195 | ||
193 | /** | 196 | /** |
194 | * This enum describes the debug mode used for by the @ref odbgstream class. | 197 | * This enum describes the debug mode used for by the @ref odbgstream class. |
195 | * See <a href="http://opie.handhelds.org/documentation/standards/opie/style/debug/debug.html"> | 198 | * See <a href="http://opie.handhelds.org/documentation/standards/opie/style/debug/debug.html"> |
196 | * the styleguide</a>. | 199 | * the styleguide</a>. |
197 | **/ | 200 | **/ |
198 | enum Debug { | 201 | enum Debug { |
199 | /** | 202 | /** |
200 | * Debug messages are ignored. | 203 | * Debug messages are ignored. |
201 | */ | 204 | */ |
202 | DebugNone=-1, | 205 | DebugNone=-1, |
203 | /** | 206 | /** |
204 | * Debug output is sent to files /var/log/***. | 207 | * Debug output is sent to files /var/log/***. |
205 | */ | 208 | */ |
206 | DebugFiles=0, | 209 | DebugFiles=0, |
207 | /** | 210 | /** |
208 | * Debug output is written in a QMessageBox. | 211 | * Debug output is written in a QMessageBox. |
209 | */ | 212 | */ |
210 | DebugMsgBox=1, | 213 | DebugMsgBox=1, |
211 | /** | 214 | /** |
212 | * Debug output is sent to stderr. | 215 | * Debug output is sent to stderr. |
213 | */ | 216 | */ |
214 | DebugStdErr=2, | 217 | DebugStdErr=2, |
215 | /** | 218 | /** |
216 | * Debug output is sent to syslog. | 219 | * Debug output is sent to syslog. |
217 | */ | 220 | */ |
218 | DebugSysLog=3, | 221 | DebugSysLog=3, |
219 | /** | 222 | /** |
220 | * Debug output is sent via udp over a socket. | 223 | * Debug output is sent via udp over a socket. |
221 | */ | 224 | */ |
222 | DebugSocket=4 | 225 | DebugSocket=4 |
223 | }; | 226 | }; |
224 | /** | 227 | /** |
225 | * Returns the preferred debug mode setting. | 228 | * Returns the preferred debug mode setting. |
226 | * | 229 | * |
227 | * @return @ref Debug. Default is @p DebugStdErr. | 230 | * @return @ref Debug. Default is @p DebugStdErr. |
228 | */ | 231 | */ |
229 | static Debug debugMode(); | 232 | static Debug debugMode(); |
230 | 233 | ||
231 | /** | 234 | /** |
232 | * Returns additional information for debug output (dependent on the debug mode). | 235 | * Returns additional information for debug output (dependent on the debug mode). |
233 | * | 236 | * |
234 | * @return Additional debug output information. | 237 | * @return Additional debug output information. |
235 | */ | 238 | */ |
236 | static QString debugOutput(); | 239 | static QString debugOutput(); |
237 | /** | 240 | /** |
238 | * This is a structure containing the possible mouse settings. | 241 | * This is a structure containing the possible mouse settings. |
239 | */ | 242 | */ |
240 | struct OMouseSettings | 243 | struct OMouseSettings |
241 | { | 244 | { |
242 | enum { RightHanded = 0, LeftHanded = 1 }; | 245 | enum { RightHanded = 0, LeftHanded = 1 }; |
243 | int handed; // left or right | 246 | int handed; // left or right |
244 | }; | 247 | }; |
245 | 248 | ||
246 | /** | 249 | /** |
247 | * This returns the current mouse settings. | 250 | * This returns the current mouse settings. |
248 | */ | 251 | */ |
249 | static OMouseSettings & mouseSettings(); | 252 | static OMouseSettings & mouseSettings(); |
250 | 253 | ||
251 | /** | 254 | /** |
252 | * The path to the desktop directory of the current user. | 255 | * The path to the desktop directory of the current user. |
253 | */ | 256 | */ |
257 | // below handled by Global stuff and QPEApplication | ||
254 | static QString desktopPath() { initStatic(); return *s_desktopPath; } | 258 | static QString desktopPath() { initStatic(); return *s_desktopPath; } |
255 | 259 | ||
256 | /** | 260 | /** |
257 | * The path to the autostart directory of the current user. | 261 | * The path to the autostart directory of the current user. |
258 | */ | 262 | */ |
259 | static QString autostartPath() { initStatic(); return *s_autostartPath; } | 263 | static QString autostartPath() { initStatic(); return *s_autostartPath; } |
260 | 264 | ||
261 | /** | 265 | /** |
262 | * The path to the trash directory of the current user. | 266 | * The path to the trash directory of the current user. |
263 | */ | 267 | */ |
268 | // we do not have that concept -zecke | ||
264 | static QString trashPath() { initStatic(); return *s_trashPath; } | 269 | static QString trashPath() { initStatic(); return *s_trashPath; } |
265 | 270 | ||
266 | /** | 271 | /** |
267 | * The path where documents are stored of the current user. | 272 | * The path where documents are stored of the current user. |
268 | */ | 273 | */ |
269 | static QString documentPath() { initStatic(); return *s_documentPath; } | 274 | static QString documentPath() { initStatic(); return *s_documentPath; } |
270 | 275 | ||
271 | 276 | ||
272 | /** | 277 | /** |
273 | * The default color to use when highlighting toolbar buttons | 278 | * The default color to use when highlighting toolbar buttons |
274 | */ | 279 | */ |
275 | static QColor toolBarHighlightColor(); | 280 | static QColor toolBarHighlightColor(); |
276 | static QColor inactiveTitleColor(); | 281 | static QColor inactiveTitleColor(); |
277 | static QColor inactiveTextColor(); | 282 | static QColor inactiveTextColor(); |
278 | static QColor activeTitleColor(); | 283 | static QColor activeTitleColor(); |
279 | static QColor activeTextColor(); | 284 | static QColor activeTextColor(); |
280 | static int contrast(); | 285 | static int contrast(); |
281 | 286 | ||
282 | /** | 287 | /** |
283 | * The default colors to use for text and links. | 288 | * The default colors to use for text and links. |
284 | */ | 289 | */ |
285 | static QColor baseColor(); // Similair to QColorGroup::base() | 290 | static QColor baseColor(); // Similair to QColorGroup::base() |
286 | static QColor textColor(); // Similair to QColorGroup::text() | 291 | static QColor textColor(); // Similair to QColorGroup::text() |
287 | static QColor linkColor(); | 292 | static QColor linkColor(); |
288 | static QColor visitedLinkColor(); | 293 | static QColor visitedLinkColor(); |
289 | static QColor highlightedTextColor(); // Similair to QColorGroup::hightlightedText() | 294 | static QColor highlightedTextColor(); // Similair to QColorGroup::hightlightedText() |
290 | static QColor highlightColor(); // Similair to QColorGroup::highlight() | 295 | static QColor highlightColor(); // Similair to QColorGroup::highlight() |
291 | 296 | ||
292 | /** | 297 | /** |
293 | * Returns the alternate background color used by @ref OListView with | 298 | * Returns the alternate background color used by @ref OListView with |
294 | * @ref OListViewItem. Any other list that uses alternating background | 299 | * @ref OListViewItem. Any other list that uses alternating background |
295 | * colors should use this too, to obey to the user's preferences. Returns | 300 | * colors should use this too, to obey to the user's preferences. Returns |
296 | * an invalid color if the user doesn't want alternating backgrounds. | 301 | * an invalid color if the user doesn't want alternating backgrounds. |
297 | * @see #calculateAlternateBackgroundColor | 302 | * @see #calculateAlternateBackgroundColor |
298 | */ | 303 | */ |
299 | static QColor alternateBackgroundColor(); | 304 | static QColor alternateBackgroundColor(); |
300 | /** | 305 | /** |
301 | * Calculates a color based on @p base to be used as alternating | 306 | * Calculates a color based on @p base to be used as alternating |
302 | * color for e.g. listviews. | 307 | * color for e.g. listviews. |
303 | * @see #alternateBackgroundColor | 308 | * @see #alternateBackgroundColor |
304 | */ | 309 | */ |
305 | static QColor calculateAlternateBackgroundColor(const QColor& base); | 310 | static QColor calculateAlternateBackgroundColor(const QColor& base); |
306 | 311 | ||
307 | 312 | ||
308 | static QFont generalFont(); | 313 | static QFont generalFont(); |
309 | static QFont fixedFont(); | 314 | static QFont fixedFont(); |
310 | static QFont toolBarFont(); | 315 | static QFont toolBarFont(); |
311 | static QFont menuFont(); | 316 | static QFont menuFont(); |
312 | static QFont windowTitleFont(); | 317 | static QFont windowTitleFont(); |
313 | static QFont taskbarFont(); | 318 | static QFont taskbarFont(); |
314 | 319 | ||
315 | /** | 320 | /** |
316 | * Returns if the user specified multihead. In case the display | 321 | * Returns if the user specified multihead. In case the display |
317 | * has multiple screens, the return value of this function specifies | 322 | * has multiple screens, the return value of this function specifies |
318 | * if the user wants OPIE to run on all of them or just on the primary | 323 | * if the user wants OPIE to run on all of them or just on the primary |
319 | */ | 324 | */ |
320 | static bool isMultiHead(); | 325 | static bool isMultiHead(); |
321 | 326 | ||
322 | private: | 327 | private: |
323 | /** | 328 | /** |
324 | * reads in all paths from kdeglobals | 329 | * reads in all paths from kdeglobals |
325 | */ | 330 | */ |
326 | static void initStatic(); | 331 | static void initStatic(); |
327 | /** | 332 | /** |
328 | * initialise kde2Blue | 333 | * initialise kde2Blue |
329 | */ | 334 | */ |
330 | static void initColors(); | 335 | static void initColors(); |
331 | /** | 336 | /** |
332 | * drop cached values for fonts (called by OApplication) | 337 | * drop cached values for fonts (called by OApplication) |
333 | */ | 338 | */ |
334 | static void rereadFontSettings(); | 339 | static void rereadFontSettings(); |
335 | /** | 340 | /** |
336 | * drop cached values for paths (called by OApplication) | 341 | * drop cached values for paths (called by OApplication) |
337 | */ | 342 | */ |
338 | static void rereadPathSettings(); | 343 | static void rereadPathSettings(); |
339 | /** | 344 | /** |
340 | * drop cached values for mouse settings (called by OApplication) | 345 | * drop cached values for mouse settings (called by OApplication) |
341 | */ | 346 | */ |
342 | static void rereadMouseSettings(); | 347 | static void rereadMouseSettings(); |
343 | 348 | ||
344 | 349 | ||
345 | static QString* s_desktopPath; | 350 | static QString* s_desktopPath; |
346 | static QString* s_autostartPath; | 351 | static QString* s_autostartPath; |
347 | static QString* s_trashPath; | 352 | static QString* s_trashPath; |
348 | static QString* s_documentPath; | 353 | static QString* s_documentPath; |
349 | static QFont *_generalFont; | 354 | static QFont *_generalFont; |
350 | static QFont *_fixedFont; | 355 | static QFont *_fixedFont; |
351 | static QFont *_toolBarFont; | 356 | static QFont *_toolBarFont; |
352 | static QFont *_menuFont; | 357 | static QFont *_menuFont; |
353 | static QFont *_windowTitleFont; | 358 | static QFont *_windowTitleFont; |
354 | static QFont *_taskbarFont; | 359 | static QFont *_taskbarFont; |
355 | static QColor * kde2Gray; | 360 | static QColor * kde2Gray; |
356 | static QColor * kde2Blue; | 361 | static QColor * kde2Blue; |
357 | static QColor * kde2AlternateColor; | 362 | static QColor * kde2AlternateColor; |
358 | static OMouseSettings *s_mouseSettings; | 363 | static OMouseSettings *s_mouseSettings; |
359 | 364 | ||
360 | static QColor * OpieGray; | 365 | static QColor * OpieGray; |
361 | static QColor * OpieBlue; | 366 | static QColor * OpieBlue; |
362 | static QColor * OpieAlternate; | 367 | static QColor * OpieAlternate; |
363 | static QColor * OpieHighlight; | 368 | static QColor * OpieHighlight; |
364 | 369 | ||
365 | friend class OApplication; | 370 | friend class OApplication; |
366 | }; | 371 | }; |
367 | 372 | ||
368 | #endif | 373 | #endif |
diff --git a/libopie2/opienet/omanufacturerdb.h b/libopie2/opienet/omanufacturerdb.h index 5e66c37..cb0b6c8 100644 --- a/libopie2/opienet/omanufacturerdb.h +++ b/libopie2/opienet/omanufacturerdb.h | |||
@@ -1,37 +1,38 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #ifndef OMANUFACTURERDB_H | 16 | #ifndef OMANUFACTURERDB_H |
17 | #define OMANUFACTURERDB_H | 17 | #define OMANUFACTURERDB_H |
18 | 18 | ||
19 | #include <qmap.h> | 19 | #include <qmap.h> |
20 | 20 | ||
21 | class OManufacturerDB | 21 | class OManufacturerDB |
22 | { | 22 | { |
23 | public: | 23 | public: |
24 | //FIXME make us consistent -zecke I use self(), sandman inst() you use instance() so we need to chose one! | ||
24 | static OManufacturerDB* instance(); | 25 | static OManufacturerDB* instance(); |
25 | const QString& lookup( const QString& macaddr ) const; | 26 | const QString& lookup( const QString& macaddr ) const; |
26 | 27 | ||
27 | protected: | 28 | protected: |
28 | OManufacturerDB(); | 29 | OManufacturerDB(); |
29 | virtual ~OManufacturerDB(); | 30 | virtual ~OManufacturerDB(); |
30 | 31 | ||
31 | private: | 32 | private: |
32 | QMap<QString, QString> manufacturers; | 33 | QMap<QString, QString> manufacturers; |
33 | static OManufacturerDB* _instance; | 34 | static OManufacturerDB* _instance; |
34 | }; | 35 | }; |
35 | 36 | ||
36 | #endif | 37 | #endif |
37 | 38 | ||
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h index bedea63..9611518 100644 --- a/libopie2/opienet/onetutils.h +++ b/libopie2/opienet/onetutils.h | |||
@@ -1,158 +1,161 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef ONETUTILS_H | 32 | #ifndef ONETUTILS_H |
33 | #define ONETUTILS_H | 33 | #define ONETUTILS_H |
34 | 34 | ||
35 | #include <qdict.h> | 35 | #include <qdict.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | #include <qstring.h> | 37 | #include <qstring.h> |
38 | #include <qhostaddress.h> | 38 | #include <qhostaddress.h> |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | 40 | ||
41 | #include <sys/types.h> | 41 | #include <sys/types.h> |
42 | 42 | ||
43 | struct ifreq; | 43 | struct ifreq; |
44 | class OWirelessNetworkInterface; | 44 | class OWirelessNetworkInterface; |
45 | 45 | ||
46 | /*====================================================================================== | 46 | /*====================================================================================== |
47 | * OMacAddress | 47 | * OMacAddress |
48 | *======================================================================================*/ | 48 | *======================================================================================*/ |
49 | 49 | ||
50 | class OMacAddress | 50 | class OMacAddress |
51 | { | 51 | { |
52 | public: | 52 | public: |
53 | // QString c'tor? -zecke | ||
53 | OMacAddress( unsigned char* ); | 54 | OMacAddress( unsigned char* ); |
54 | OMacAddress( const unsigned char* ); | 55 | OMacAddress( const unsigned char* ); |
55 | OMacAddress( struct ifreq& ); | 56 | OMacAddress( struct ifreq& ); |
56 | ~OMacAddress(); | 57 | ~OMacAddress(); |
57 | 58 | ||
58 | QString manufacturer() const; | 59 | QString manufacturer() const; |
59 | QString toString( bool substitute = false ) const; | 60 | QString toString( bool substitute = false ) const; |
60 | const unsigned char* native() const; | 61 | const unsigned char* native() const; |
61 | 62 | ||
63 | // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem? | ||
62 | static OMacAddress fromString( const QString& ); | 64 | static OMacAddress fromString( const QString& ); |
63 | 65 | ||
64 | public: | 66 | public: |
65 | static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff | 67 | static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff |
66 | static const OMacAddress& unknown; // 44:44:44:44:44:44 | 68 | static const OMacAddress& unknown; // 44:44:44:44:44:44 |
67 | 69 | ||
68 | private: | 70 | private: |
69 | unsigned char _bytes[6]; | 71 | unsigned char _bytes[6]; |
70 | 72 | ||
71 | friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); | 73 | friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); |
72 | 74 | ||
73 | }; | 75 | }; |
74 | 76 | ||
75 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); | 77 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); |
76 | 78 | ||
77 | 79 | ||
78 | /*====================================================================================== | 80 | /*====================================================================================== |
79 | * OHostAddress | 81 | * OHostAddress |
80 | *======================================================================================*/ | 82 | *======================================================================================*/ |
81 | 83 | ||
82 | class OHostAddress : public QHostAddress | 84 | class OHostAddress : public QHostAddress |
83 | { | 85 | { |
84 | public: | 86 | public: |
85 | OHostAddress(); | 87 | OHostAddress(); |
86 | ~OHostAddress(); | 88 | ~OHostAddress(); |
87 | }; | 89 | }; |
88 | 90 | ||
89 | 91 | ||
90 | /*====================================================================================== | 92 | /*====================================================================================== |
91 | * OPrivateIOCTL | 93 | * OPrivateIOCTL |
92 | *======================================================================================*/ | 94 | *======================================================================================*/ |
93 | 95 | ||
94 | class OPrivateIOCTL : public QObject | 96 | class OPrivateIOCTL : public QObject |
95 | { | 97 | { |
96 | public: | 98 | public: |
97 | OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); | 99 | OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); |
98 | ~OPrivateIOCTL(); | 100 | ~OPrivateIOCTL(); |
99 | 101 | ||
100 | int numberGetArgs() const; | 102 | int numberGetArgs() const; |
101 | int typeGetArgs() const; | 103 | int typeGetArgs() const; |
102 | int numberSetArgs() const; | 104 | int numberSetArgs() const; |
103 | int typeSetArgs() const; | 105 | int typeSetArgs() const; |
104 | 106 | ||
107 | // FIXME return int? as ::ioctl does? -zecke | ||
105 | void invoke() const; | 108 | void invoke() const; |
106 | void setParameter( int, u_int32_t ); | 109 | void setParameter( int, u_int32_t ); |
107 | 110 | ||
108 | private: | 111 | private: |
109 | u_int32_t _ioctl; | 112 | u_int32_t _ioctl; |
110 | u_int16_t _getargs; | 113 | u_int16_t _getargs; |
111 | u_int16_t _setargs; | 114 | u_int16_t _setargs; |
112 | 115 | ||
113 | }; | 116 | }; |
114 | 117 | ||
115 | /*====================================================================================== | 118 | /*====================================================================================== |
116 | * Miscellaneous | 119 | * Miscellaneous |
117 | *======================================================================================*/ | 120 | *======================================================================================*/ |
118 | 121 | ||
119 | /* dump bytes */ | 122 | /* dump bytes */ |
120 | 123 | ||
121 | void dumpBytes( const unsigned char* data, int num ); | 124 | void dumpBytes( const unsigned char* data, int num ); |
122 | 125 | ||
123 | /* Network to host order macros */ | 126 | /* Network to host order macros */ |
124 | 127 | ||
125 | #ifdef LBL_ALIGN | 128 | #ifdef LBL_ALIGN |
126 | #define EXTRACT_16BITS(p) \ | 129 | #define EXTRACT_16BITS(p) \ |
127 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ | 130 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ |
128 | (u_int16_t)*((const u_int8_t *)(p) + 1))) | 131 | (u_int16_t)*((const u_int8_t *)(p) + 1))) |
129 | #define EXTRACT_32BITS(p) \ | 132 | #define EXTRACT_32BITS(p) \ |
130 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ | 133 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ |
131 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ | 134 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ |
132 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ | 135 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ |
133 | (u_int32_t)*((const u_int8_t *)(p) + 3))) | 136 | (u_int32_t)*((const u_int8_t *)(p) + 3))) |
134 | #else | 137 | #else |
135 | #define EXTRACT_16BITS(p) \ | 138 | #define EXTRACT_16BITS(p) \ |
136 | ((u_int16_t)ntohs(*(const u_int16_t *)(p))) | 139 | ((u_int16_t)ntohs(*(const u_int16_t *)(p))) |
137 | #define EXTRACT_32BITS(p) \ | 140 | #define EXTRACT_32BITS(p) \ |
138 | ((u_int32_t)ntohl(*(const u_int32_t *)(p))) | 141 | ((u_int32_t)ntohl(*(const u_int32_t *)(p))) |
139 | #endif | 142 | #endif |
140 | 143 | ||
141 | #define EXTRACT_24BITS(p) \ | 144 | #define EXTRACT_24BITS(p) \ |
142 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ | 145 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ |
143 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ | 146 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ |
144 | (u_int32_t)*((const u_int8_t *)(p) + 2))) | 147 | (u_int32_t)*((const u_int8_t *)(p) + 2))) |
145 | 148 | ||
146 | /* Little endian protocol host order macros */ | 149 | /* Little endian protocol host order macros */ |
147 | #define EXTRACT_LE_8BITS(p) (*(p)) | 150 | #define EXTRACT_LE_8BITS(p) (*(p)) |
148 | #define EXTRACT_LE_16BITS(p) \ | 151 | #define EXTRACT_LE_16BITS(p) \ |
149 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ | 152 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ |
150 | (u_int16_t)*((const u_int8_t *)(p) + 0))) | 153 | (u_int16_t)*((const u_int8_t *)(p) + 0))) |
151 | #define EXTRACT_LE_32BITS(p) \ | 154 | #define EXTRACT_LE_32BITS(p) \ |
152 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ | 155 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ |
153 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ | 156 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ |
154 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ | 157 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ |
155 | (u_int32_t)*((const u_int8_t *)(p) + 0))) | 158 | (u_int32_t)*((const u_int8_t *)(p) + 0))) |
156 | 159 | ||
157 | #endif // ONETUTILS_H | 160 | #endif // ONETUTILS_H |
158 | 161 | ||
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 73b543b..f0094c7 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -1,495 +1,495 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003 by the Wellenreiter team: | 3 | Copyright (C) 2003 by the Wellenreiter team: |
4 | Martin J. Muench <mjm@remote-exploit.org> | 4 | Martin J. Muench <mjm@remote-exploit.org> |
5 | Max Moser <mmo@remote-exploit.org | 5 | Max Moser <mmo@remote-exploit.org |
6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | 35 | ||
36 | #include <opie2/onetwork.h> | 36 | #include <opie2/onetwork.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | 39 | ||
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | 42 | ||
43 | /* UNIX */ | 43 | /* UNIX */ |
44 | 44 | ||
45 | #include <arpa/inet.h> | 45 | #include <arpa/inet.h> |
46 | #include <cerrno> | 46 | #include <cerrno> |
47 | #include <cstring> | 47 | #include <cstring> |
48 | #include <cstdlib> | 48 | #include <cstdlib> |
49 | #include <math.h> | 49 | #include <math.h> |
50 | #include <sys/ioctl.h> | 50 | #include <sys/ioctl.h> |
51 | #include <sys/socket.h> | 51 | #include <sys/socket.h> |
52 | #include <sys/types.h> | 52 | #include <sys/types.h> |
53 | #include <unistd.h> | 53 | #include <unistd.h> |
54 | #include <linux/sockios.h> | 54 | #include <linux/sockios.h> |
55 | #include <net/if_arp.h> | 55 | #include <net/if_arp.h> |
56 | #include <stdarg.h> | 56 | #include <stdarg.h> |
57 | 57 | ||
58 | using namespace std; | 58 | using namespace std; |
59 | 59 | ||
60 | /*====================================================================================== | 60 | /*====================================================================================== |
61 | * ONetwork | 61 | * ONetwork |
62 | *======================================================================================*/ | 62 | *======================================================================================*/ |
63 | 63 | ||
64 | ONetwork* ONetwork::_instance = 0; | 64 | ONetwork* ONetwork::_instance = 0; |
65 | 65 | ||
66 | ONetwork::ONetwork() | 66 | ONetwork::ONetwork() |
67 | { | 67 | { |
68 | qDebug( "ONetwork::ONetwork()" ); | 68 | qDebug( "ONetwork::ONetwork()" ); |
69 | synchronize(); | 69 | synchronize(); |
70 | } | 70 | } |
71 | 71 | ||
72 | void ONetwork::synchronize() | 72 | void ONetwork::synchronize() |
73 | { | 73 | { |
74 | // gather available interfaces by inspecting /proc/net/dev | 74 | // gather available interfaces by inspecting /proc/net/dev |
75 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | 75 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices |
76 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | 76 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices |
77 | 77 | ||
78 | _interfaces.clear(); | 78 | _interfaces.clear(); |
79 | QString str; | 79 | QString str; |
80 | QFile f( "/proc/net/dev" ); | 80 | QFile f( "/proc/net/dev" ); |
81 | bool hasFile = f.open( IO_ReadOnly ); | 81 | bool hasFile = f.open( IO_ReadOnly ); |
82 | if ( !hasFile ) | 82 | if ( !hasFile ) |
83 | { | 83 | { |
84 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); | 84 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); |
85 | return; | 85 | return; |
86 | } | 86 | } |
87 | QTextStream s( &f ); | 87 | QTextStream s( &f ); |
88 | s.readLine(); | 88 | s.readLine(); |
89 | s.readLine(); | 89 | s.readLine(); |
90 | while ( !s.atEnd() ) | 90 | while ( !s.atEnd() ) |
91 | { | 91 | { |
92 | s >> str; | 92 | s >> str; |
93 | str.truncate( str.find( ':' ) ); | 93 | str.truncate( str.find( ':' ) ); |
94 | qDebug( "ONetwork: found interface '%s'", (const char*) str ); | 94 | qDebug( "ONetwork: found interface '%s'", (const char*) str ); |
95 | ONetworkInterface* iface; | 95 | ONetworkInterface* iface; |
96 | if ( isWirelessInterface( str ) ) | 96 | if ( isWirelessInterface( str ) ) |
97 | { | 97 | { |
98 | iface = new OWirelessNetworkInterface( this, (const char*) str ); | 98 | iface = new OWirelessNetworkInterface( this, (const char*) str ); |
99 | qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); | 99 | qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); |
100 | } | 100 | } |
101 | else | 101 | else |
102 | { | 102 | { |
103 | iface = new ONetworkInterface( this, (const char*) str ); | 103 | iface = new ONetworkInterface( this, (const char*) str ); |
104 | } | 104 | } |
105 | _interfaces.insert( str, iface ); | 105 | _interfaces.insert( str, iface ); |
106 | s.readLine(); | 106 | s.readLine(); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | ONetworkInterface* ONetwork::interface( QString iface ) const | 111 | ONetworkInterface* ONetwork::interface( const QString& iface ) const |
112 | { | 112 | { |
113 | return _interfaces[iface]; | 113 | return _interfaces[iface]; |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | ONetwork* ONetwork::instance() | 117 | ONetwork* ONetwork::instance() |
118 | { | 118 | { |
119 | if ( !_instance ) _instance = new ONetwork(); | 119 | if ( !_instance ) _instance = new ONetwork(); |
120 | return _instance; | 120 | return _instance; |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | ONetwork::InterfaceIterator ONetwork::iterator() const | 124 | ONetwork::InterfaceIterator ONetwork::iterator() const |
125 | { | 125 | { |
126 | return ONetwork::InterfaceIterator( _interfaces ); | 126 | return ONetwork::InterfaceIterator( _interfaces ); |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | bool ONetwork::isWirelessInterface( const char* name ) const | 130 | bool ONetwork::isWirelessInterface( const char* name ) const |
131 | { | 131 | { |
132 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); | 132 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); |
133 | struct iwreq iwr; | 133 | struct iwreq iwr; |
134 | memset( &iwr, 0, sizeof( struct iwreq ) ); | 134 | memset( &iwr, 0, sizeof( struct iwreq ) ); |
135 | strcpy( (char*) &iwr.ifr_name, name ); | 135 | strcpy( (char*) &iwr.ifr_name, name ); |
136 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); | 136 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); |
137 | return result != -1; | 137 | return result != -1; |
138 | } | 138 | } |
139 | 139 | ||
140 | /*====================================================================================== | 140 | /*====================================================================================== |
141 | * ONetworkInterface | 141 | * ONetworkInterface |
142 | *======================================================================================*/ | 142 | *======================================================================================*/ |
143 | 143 | ||
144 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) | 144 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) |
145 | :QObject( parent, name ), | 145 | :QObject( parent, name ), |
146 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) | 146 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) |
147 | { | 147 | { |
148 | qDebug( "ONetworkInterface::ONetworkInterface()" ); | 148 | qDebug( "ONetworkInterface::ONetworkInterface()" ); |
149 | init(); | 149 | init(); |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | struct ifreq& ONetworkInterface::ifr() const | 153 | struct ifreq& ONetworkInterface::ifr() const |
154 | { | 154 | { |
155 | return _ifr; | 155 | return _ifr; |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | void ONetworkInterface::init() | 159 | void ONetworkInterface::init() |
160 | { | 160 | { |
161 | qDebug( "ONetworkInterface::init()" ); | 161 | qDebug( "ONetworkInterface::init()" ); |
162 | 162 | ||
163 | memset( &_ifr, 0, sizeof( struct ifreq ) ); | 163 | memset( &_ifr, 0, sizeof( struct ifreq ) ); |
164 | 164 | ||
165 | if ( _sfd == -1 ) | 165 | if ( _sfd == -1 ) |
166 | { | 166 | { |
167 | qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); | 167 | qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); |
168 | return; | 168 | return; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const | 173 | bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const |
174 | { | 174 | { |
175 | int result = ::ioctl( _sfd, call, &ifreq ); | 175 | int result = ::ioctl( _sfd, call, &ifreq ); |
176 | if ( result == -1 ) | 176 | if ( result == -1 ) |
177 | qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) ); | 177 | qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) ); |
178 | else | 178 | else |
179 | qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Ok.", name(), call ); | 179 | qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Ok.", name(), call ); |
180 | return ( result != -1 ); | 180 | return ( result != -1 ); |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | bool ONetworkInterface::ioctl( int call ) const | 184 | bool ONetworkInterface::ioctl( int call ) const |
185 | { | 185 | { |
186 | strcpy( _ifr.ifr_name, name() ); | 186 | strcpy( _ifr.ifr_name, name() ); |
187 | return ioctl( call, _ifr ); | 187 | return ioctl( call, _ifr ); |
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | ||
191 | bool ONetworkInterface::isLoopback() const | 191 | bool ONetworkInterface::isLoopback() const |
192 | { | 192 | { |
193 | ioctl( SIOCGIFFLAGS ); | 193 | ioctl( SIOCGIFFLAGS ); |
194 | return _ifr.ifr_flags & IFF_LOOPBACK; | 194 | return _ifr.ifr_flags & IFF_LOOPBACK; |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | bool ONetworkInterface::setUp( bool b ) | 198 | bool ONetworkInterface::setUp( bool b ) |
199 | { | 199 | { |
200 | ioctl( SIOCGIFFLAGS ); | 200 | ioctl( SIOCGIFFLAGS ); |
201 | if ( b ) _ifr.ifr_flags |= IFF_UP; | 201 | if ( b ) _ifr.ifr_flags |= IFF_UP; |
202 | else _ifr.ifr_flags &= (~IFF_UP); | 202 | else _ifr.ifr_flags &= (~IFF_UP); |
203 | return ioctl( SIOCSIFFLAGS ); | 203 | return ioctl( SIOCSIFFLAGS ); |
204 | } | 204 | } |
205 | 205 | ||
206 | 206 | ||
207 | bool ONetworkInterface::isUp() const | 207 | bool ONetworkInterface::isUp() const |
208 | { | 208 | { |
209 | ioctl( SIOCGIFFLAGS ); | 209 | ioctl( SIOCGIFFLAGS ); |
210 | return _ifr.ifr_flags & IFF_UP; | 210 | return _ifr.ifr_flags & IFF_UP; |
211 | } | 211 | } |
212 | 212 | ||
213 | 213 | ||
214 | QString ONetworkInterface::ipV4Address() const | 214 | QString ONetworkInterface::ipV4Address() const |
215 | { | 215 | { |
216 | if ( ioctl( SIOCGIFADDR ) ) | 216 | if ( ioctl( SIOCGIFADDR ) ) |
217 | { | 217 | { |
218 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 218 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
219 | //FIXME: Use QHostAddress here | 219 | //FIXME: Use QHostAddress here |
220 | return QString( inet_ntoa( sa->sin_addr ) ); | 220 | return QString( inet_ntoa( sa->sin_addr ) ); |
221 | } | 221 | } |
222 | else | 222 | else |
223 | return "<unknown>"; | 223 | return "<unknown>"; |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) | 227 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) |
228 | { | 228 | { |
229 | _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; | 229 | _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; |
230 | memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); | 230 | memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); |
231 | ioctl( SIOCSIFHWADDR ); | 231 | ioctl( SIOCSIFHWADDR ); |
232 | } | 232 | } |
233 | 233 | ||
234 | 234 | ||
235 | OMacAddress ONetworkInterface::macAddress() const | 235 | OMacAddress ONetworkInterface::macAddress() const |
236 | { | 236 | { |
237 | if ( ioctl( SIOCGIFHWADDR ) ) | 237 | if ( ioctl( SIOCGIFHWADDR ) ) |
238 | { | 238 | { |
239 | return OMacAddress( _ifr ); | 239 | return OMacAddress( _ifr ); |
240 | } | 240 | } |
241 | else | 241 | else |
242 | { | 242 | { |
243 | return OMacAddress::unknown; | 243 | return OMacAddress::unknown; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | int ONetworkInterface::dataLinkType() const | 248 | int ONetworkInterface::dataLinkType() const |
249 | { | 249 | { |
250 | if ( ioctl( SIOCGIFHWADDR ) ) | 250 | if ( ioctl( SIOCGIFHWADDR ) ) |
251 | { | 251 | { |
252 | return _ifr.ifr_hwaddr.sa_family; | 252 | return _ifr.ifr_hwaddr.sa_family; |
253 | } | 253 | } |
254 | else | 254 | else |
255 | { | 255 | { |
256 | return -1; | 256 | return -1; |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) | 261 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) |
262 | { | 262 | { |
263 | _mon = m; | 263 | _mon = m; |
264 | qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); | 264 | qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); |
265 | } | 265 | } |
266 | 266 | ||
267 | 267 | ||
268 | OMonitoringInterface* ONetworkInterface::monitoring() const | 268 | OMonitoringInterface* ONetworkInterface::monitoring() const |
269 | { | 269 | { |
270 | return _mon; | 270 | return _mon; |
271 | } | 271 | } |
272 | 272 | ||
273 | 273 | ||
274 | ONetworkInterface::~ONetworkInterface() | 274 | ONetworkInterface::~ONetworkInterface() |
275 | { | 275 | { |
276 | qDebug( "ONetworkInterface::~ONetworkInterface()" ); | 276 | qDebug( "ONetworkInterface::~ONetworkInterface()" ); |
277 | if ( _sfd != -1 ) ::close( _sfd ); | 277 | if ( _sfd != -1 ) ::close( _sfd ); |
278 | } | 278 | } |
279 | 279 | ||
280 | 280 | ||
281 | bool ONetworkInterface::setPromiscuousMode( bool b ) | 281 | bool ONetworkInterface::setPromiscuousMode( bool b ) |
282 | { | 282 | { |
283 | ioctl( SIOCGIFFLAGS ); | 283 | ioctl( SIOCGIFFLAGS ); |
284 | if ( b ) _ifr.ifr_flags |= IFF_PROMISC; | 284 | if ( b ) _ifr.ifr_flags |= IFF_PROMISC; |
285 | else _ifr.ifr_flags &= (~IFF_PROMISC); | 285 | else _ifr.ifr_flags &= (~IFF_PROMISC); |
286 | return ioctl( SIOCSIFFLAGS ); | 286 | return ioctl( SIOCSIFFLAGS ); |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | bool ONetworkInterface::promiscuousMode() const | 290 | bool ONetworkInterface::promiscuousMode() const |
291 | { | 291 | { |
292 | ioctl( SIOCGIFFLAGS ); | 292 | ioctl( SIOCGIFFLAGS ); |
293 | return _ifr.ifr_flags & IFF_PROMISC; | 293 | return _ifr.ifr_flags & IFF_PROMISC; |
294 | } | 294 | } |
295 | 295 | ||
296 | 296 | ||
297 | bool ONetworkInterface::isWireless() const | 297 | bool ONetworkInterface::isWireless() const |
298 | { | 298 | { |
299 | return ioctl( SIOCGIWNAME ); | 299 | return ioctl( SIOCGIWNAME ); |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | /*====================================================================================== | 303 | /*====================================================================================== |
304 | * OChannelHopper | 304 | * OChannelHopper |
305 | *======================================================================================*/ | 305 | *======================================================================================*/ |
306 | 306 | ||
307 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) | 307 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) |
308 | :QObject( 0, "Mickey's funky hopper" ), | 308 | :QObject( 0, "Mickey's funky hopper" ), |
309 | _iface( iface ), _interval( 0 ), _tid( 0 ) | 309 | _iface( iface ), _interval( 0 ), _tid( 0 ) |
310 | { | 310 | { |
311 | int _maxChannel = iface->channels()+1; | 311 | int _maxChannel = iface->channels()+1; |
312 | // generate fancy hopping sequence honoring the device capabilities | 312 | // generate fancy hopping sequence honoring the device capabilities |
313 | if ( _maxChannel >= 1 ) _channels.append( 1 ); | 313 | if ( _maxChannel >= 1 ) _channels.append( 1 ); |
314 | if ( _maxChannel >= 7 ) _channels.append( 7 ); | 314 | if ( _maxChannel >= 7 ) _channels.append( 7 ); |
315 | if ( _maxChannel >= 13 ) _channels.append( 13 ); | 315 | if ( _maxChannel >= 13 ) _channels.append( 13 ); |
316 | if ( _maxChannel >= 2 ) _channels.append( 2 ); | 316 | if ( _maxChannel >= 2 ) _channels.append( 2 ); |
317 | if ( _maxChannel >= 8 ) _channels.append( 8 ); | 317 | if ( _maxChannel >= 8 ) _channels.append( 8 ); |
318 | if ( _maxChannel >= 3 ) _channels.append( 3 ); | 318 | if ( _maxChannel >= 3 ) _channels.append( 3 ); |
319 | if ( _maxChannel >= 14 ) _channels.append( 14 ); | 319 | if ( _maxChannel >= 14 ) _channels.append( 14 ); |
320 | if ( _maxChannel >= 9 ) _channels.append( 9 ); | 320 | if ( _maxChannel >= 9 ) _channels.append( 9 ); |
321 | if ( _maxChannel >= 4 ) _channels.append( 4 ); | 321 | if ( _maxChannel >= 4 ) _channels.append( 4 ); |
322 | if ( _maxChannel >= 10 ) _channels.append( 10 ); | 322 | if ( _maxChannel >= 10 ) _channels.append( 10 ); |
323 | if ( _maxChannel >= 5 ) _channels.append( 5 ); | 323 | if ( _maxChannel >= 5 ) _channels.append( 5 ); |
324 | if ( _maxChannel >= 11 ) _channels.append( 11 ); | 324 | if ( _maxChannel >= 11 ) _channels.append( 11 ); |
325 | if ( _maxChannel >= 6 ) _channels.append( 6 ); | 325 | if ( _maxChannel >= 6 ) _channels.append( 6 ); |
326 | if ( _maxChannel >= 12 ) _channels.append( 12 ); | 326 | if ( _maxChannel >= 12 ) _channels.append( 12 ); |
327 | _channel = _channels.begin(); | 327 | _channel = _channels.begin(); |
328 | 328 | ||
329 | } | 329 | } |
330 | 330 | ||
331 | 331 | ||
332 | OChannelHopper::~OChannelHopper() | 332 | OChannelHopper::~OChannelHopper() |
333 | { | 333 | { |
334 | } | 334 | } |
335 | 335 | ||
336 | 336 | ||
337 | bool OChannelHopper::isActive() const | 337 | bool OChannelHopper::isActive() const |
338 | { | 338 | { |
339 | return _tid; | 339 | return _tid; |
340 | } | 340 | } |
341 | 341 | ||
342 | 342 | ||
343 | int OChannelHopper::channel() const | 343 | int OChannelHopper::channel() const |
344 | { | 344 | { |
345 | return *_channel; | 345 | return *_channel; |
346 | } | 346 | } |
347 | 347 | ||
348 | 348 | ||
349 | void OChannelHopper::timerEvent( QTimerEvent* ) | 349 | void OChannelHopper::timerEvent( QTimerEvent* ) |
350 | { | 350 | { |
351 | _iface->setChannel( *_channel ); | 351 | _iface->setChannel( *_channel ); |
352 | emit( hopped( *_channel ) ); | 352 | emit( hopped( *_channel ) ); |
353 | qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", | 353 | qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", |
354 | *_channel, (const char*) _iface->name() ); | 354 | *_channel, (const char*) _iface->name() ); |
355 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); | 355 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); |
356 | } | 356 | } |
357 | 357 | ||
358 | 358 | ||
359 | void OChannelHopper::setInterval( int interval ) | 359 | void OChannelHopper::setInterval( int interval ) |
360 | { | 360 | { |
361 | if ( interval == _interval ) | 361 | if ( interval == _interval ) |
362 | return; | 362 | return; |
363 | 363 | ||
364 | if ( _interval ) | 364 | if ( _interval ) |
365 | killTimer( _tid ); | 365 | killTimer( _tid ); |
366 | 366 | ||
367 | _tid = 0; | 367 | _tid = 0; |
368 | _interval = interval; | 368 | _interval = interval; |
369 | 369 | ||
370 | if ( _interval ) | 370 | if ( _interval ) |
371 | { | 371 | { |
372 | _tid = startTimer( interval ); | 372 | _tid = startTimer( interval ); |
373 | } | 373 | } |
374 | } | 374 | } |
375 | 375 | ||
376 | 376 | ||
377 | int OChannelHopper::interval() const | 377 | int OChannelHopper::interval() const |
378 | { | 378 | { |
379 | return _interval; | 379 | return _interval; |
380 | } | 380 | } |
381 | 381 | ||
382 | 382 | ||
383 | /*====================================================================================== | 383 | /*====================================================================================== |
384 | * OWirelessNetworkInterface | 384 | * OWirelessNetworkInterface |
385 | *======================================================================================*/ | 385 | *======================================================================================*/ |
386 | 386 | ||
387 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) | 387 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) |
388 | :ONetworkInterface( parent, name ), _hopper( 0 ) | 388 | :ONetworkInterface( parent, name ), _hopper( 0 ) |
389 | { | 389 | { |
390 | qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); | 390 | qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); |
391 | init(); | 391 | init(); |
392 | } | 392 | } |
393 | 393 | ||
394 | 394 | ||
395 | OWirelessNetworkInterface::~OWirelessNetworkInterface() | 395 | OWirelessNetworkInterface::~OWirelessNetworkInterface() |
396 | { | 396 | { |
397 | } | 397 | } |
398 | 398 | ||
399 | 399 | ||
400 | struct iwreq& OWirelessNetworkInterface::iwr() const | 400 | struct iwreq& OWirelessNetworkInterface::iwr() const |
401 | { | 401 | { |
402 | return _iwr; | 402 | return _iwr; |
403 | } | 403 | } |
404 | 404 | ||
405 | 405 | ||
406 | void OWirelessNetworkInterface::init() | 406 | void OWirelessNetworkInterface::init() |
407 | { | 407 | { |
408 | qDebug( "OWirelessNetworkInterface::init()" ); | 408 | qDebug( "OWirelessNetworkInterface::init()" ); |
409 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 409 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
410 | buildChannelList(); | 410 | buildChannelList(); |
411 | buildPrivateList(); | 411 | buildPrivateList(); |
412 | } | 412 | } |
413 | 413 | ||
414 | 414 | ||
415 | QString OWirelessNetworkInterface::associatedAP() const | 415 | QString OWirelessNetworkInterface::associatedAP() const |
416 | { | 416 | { |
417 | //FIXME: use OMacAddress | 417 | //FIXME: use OMacAddress |
418 | QString mac; | 418 | QString mac; |
419 | 419 | ||
420 | if ( ioctl( SIOCGIWAP ) ) | 420 | if ( ioctl( SIOCGIWAP ) ) |
421 | { | 421 | { |
422 | mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 422 | mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
423 | _ifr.ifr_hwaddr.sa_data[0]&0xff, | 423 | _ifr.ifr_hwaddr.sa_data[0]&0xff, |
424 | _ifr.ifr_hwaddr.sa_data[1]&0xff, | 424 | _ifr.ifr_hwaddr.sa_data[1]&0xff, |
425 | _ifr.ifr_hwaddr.sa_data[2]&0xff, | 425 | _ifr.ifr_hwaddr.sa_data[2]&0xff, |
426 | _ifr.ifr_hwaddr.sa_data[3]&0xff, | 426 | _ifr.ifr_hwaddr.sa_data[3]&0xff, |
427 | _ifr.ifr_hwaddr.sa_data[4]&0xff, | 427 | _ifr.ifr_hwaddr.sa_data[4]&0xff, |
428 | _ifr.ifr_hwaddr.sa_data[5]&0xff ); | 428 | _ifr.ifr_hwaddr.sa_data[5]&0xff ); |
429 | } | 429 | } |
430 | else | 430 | else |
431 | { | 431 | { |
432 | mac = "<Unknown>"; | 432 | mac = "<Unknown>"; |
433 | } | 433 | } |
434 | return mac; | 434 | return mac; |
435 | } | 435 | } |
436 | 436 | ||
437 | 437 | ||
438 | void OWirelessNetworkInterface::buildChannelList() | 438 | void OWirelessNetworkInterface::buildChannelList() |
439 | { | 439 | { |
440 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck | 440 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck |
441 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete | 441 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete |
442 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". | 442 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". |
443 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate | 443 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate |
444 | //ML: _too much_ space. This is damn shitty crap *sigh* | 444 | //ML: _too much_ space. This is damn shitty crap *sigh* |
445 | //ML: We allocate a large memory region in RAM and check whether the | 445 | //ML: We allocate a large memory region in RAM and check whether the |
446 | //ML: driver pollutes this extra space. The complaint will be made on stdout, | 446 | //ML: driver pollutes this extra space. The complaint will be made on stdout, |
447 | //ML: so please forward this... | 447 | //ML: so please forward this... |
448 | 448 | ||
449 | struct iwreq wrq; | 449 | struct iwreq wrq; |
450 | int len = sizeof( struct iw_range )*2; | 450 | int len = sizeof( struct iw_range )*2; |
451 | char *buffer = (char*) malloc( len ); | 451 | char *buffer = (char*) malloc( len ); |
452 | //FIXME: Validate if we actually got the memory block | 452 | //FIXME: Validate if we actually got the memory block |
453 | memset( buffer, 0, len ); | 453 | memset( buffer, 0, len ); |
454 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); | 454 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); |
455 | wrq.u.data.pointer = (caddr_t) buffer; | 455 | wrq.u.data.pointer = (caddr_t) buffer; |
456 | wrq.u.data.length = sizeof( struct iw_range ); | 456 | wrq.u.data.length = sizeof( struct iw_range ); |
457 | wrq.u.data.flags = 0; | 457 | wrq.u.data.flags = 0; |
458 | 458 | ||
459 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) | 459 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) |
460 | { | 460 | { |
461 | qDebug( "OWirelessNetworkInterface::buildChannelList(): SIOCGIWRANGE failed (%s) - defaulting to 11 channels", strerror( errno ) ); | 461 | qDebug( "OWirelessNetworkInterface::buildChannelList(): SIOCGIWRANGE failed (%s) - defaulting to 11 channels", strerror( errno ) ); |
462 | _channels.insert( 2412, 1 ); // 2.412 GHz | 462 | _channels.insert( 2412, 1 ); // 2.412 GHz |
463 | _channels.insert( 2417, 2 ); // 2.417 GHz | 463 | _channels.insert( 2417, 2 ); // 2.417 GHz |
464 | _channels.insert( 2422, 3 ); // 2.422 GHz | 464 | _channels.insert( 2422, 3 ); // 2.422 GHz |
465 | _channels.insert( 2427, 4 ); // 2.427 GHz | 465 | _channels.insert( 2427, 4 ); // 2.427 GHz |
466 | _channels.insert( 2432, 5 ); // 2.432 GHz | 466 | _channels.insert( 2432, 5 ); // 2.432 GHz |
467 | _channels.insert( 2437, 6 ); // 2.437 GHz | 467 | _channels.insert( 2437, 6 ); // 2.437 GHz |
468 | _channels.insert( 2442, 7 ); // 2.442 GHz | 468 | _channels.insert( 2442, 7 ); // 2.442 GHz |
469 | _channels.insert( 2447, 8 ); // 2.447 GHz | 469 | _channels.insert( 2447, 8 ); // 2.447 GHz |
470 | _channels.insert( 2452, 9 ); // 2.452 GHz | 470 | _channels.insert( 2452, 9 ); // 2.452 GHz |
471 | _channels.insert( 2457, 10 ); // 2.457 GHz | 471 | _channels.insert( 2457, 10 ); // 2.457 GHz |
472 | _channels.insert( 2462, 11 ); // 2.462 GHz | 472 | _channels.insert( 2462, 11 ); // 2.462 GHz |
473 | } | 473 | } |
474 | else | 474 | else |
475 | { | 475 | { |
476 | // <check if the driver overwrites stuff> | 476 | // <check if the driver overwrites stuff> |
477 | int max = 0; | 477 | int max = 0; |
478 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) | 478 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) |
479 | if (buffer[r] != 0) | 479 | if (buffer[r] != 0) |
480 | max = r; | 480 | max = r; |
481 | if (max > 0) | 481 | if (max > 0) |
482 | { | 482 | { |
483 | qWarning( "OWirelessNetworkInterface::buildChannelList(): Driver for wireless interface '%s'" | 483 | qWarning( "OWirelessNetworkInterface::buildChannelList(): Driver for wireless interface '%s'" |
484 | "overwrote buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) ); | 484 | "overwrote buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) ); |
485 | } | 485 | } |
486 | // </check if the driver overwrites stuff> | 486 | // </check if the driver overwrites stuff> |
487 | 487 | ||
488 | struct iw_range range; | 488 | struct iw_range range; |
489 | memcpy( &range, buffer, sizeof range ); | 489 | memcpy( &range, buffer, sizeof range ); |
490 | 490 | ||
491 | qDebug( "OWirelessNetworkInterface::buildChannelList(): Interface %s reported to have %d channels.", name(), range.num_frequency ); | 491 | qDebug( "OWirelessNetworkInterface::buildChannelList(): Interface %s reported to have %d channels.", name(), range.num_frequency ); |
492 | for ( int i = 0; i < range.num_frequency; ++i ) | 492 | for ( int i = 0; i < range.num_frequency; ++i ) |
493 | { | 493 | { |
494 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); | 494 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); |
495 | _channels.insert( freq, i+1 ); | 495 | _channels.insert( freq, i+1 ); |
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index d2cc25d..db8e702 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -1,470 +1,472 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003 by the Wellenreiter team: | 3 | Copyright (C) 2003 by the Wellenreiter team: |
4 | Martin J. Muench <mjm@remote-exploit.org> | 4 | Martin J. Muench <mjm@remote-exploit.org> |
5 | Max Moser <mmo@remote-exploit.org | 5 | Max Moser <mmo@remote-exploit.org |
6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef ONETWORK_H | 34 | #ifndef ONETWORK_H |
35 | #define ONETWORK_H | 35 | #define ONETWORK_H |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | 38 | ||
39 | #include <qvaluelist.h> | 39 | #include <qvaluelist.h> |
40 | #include <qdict.h> | 40 | #include <qdict.h> |
41 | #include <qmap.h> | 41 | #include <qmap.h> |
42 | #include <qobject.h> | 42 | #include <qobject.h> |
43 | #include <qhostaddress.h> | 43 | #include <qhostaddress.h> |
44 | 44 | ||
45 | /* OPIE */ | 45 | /* OPIE */ |
46 | 46 | ||
47 | #include <opie2/onetutils.h> | 47 | #include <opie2/onetutils.h> |
48 | 48 | ||
49 | #ifndef IFNAMSIZ | 49 | #ifndef IFNAMSIZ |
50 | #define IFNAMSIZ 16 | 50 | #define IFNAMSIZ 16 |
51 | #endif | 51 | #endif |
52 | #ifndef IW_MAX_PRIV_DEF | 52 | #ifndef IW_MAX_PRIV_DEF |
53 | #define IW_MAX_PRIV_DEF 128 | 53 | #define IW_MAX_PRIV_DEF 128 |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | // ML: Yeah, I hate to include kernel headers, but it's necessary here | 56 | // ML: Yeah, I hate to include kernel headers, but it's necessary here |
57 | // ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h> | 57 | // ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h> |
58 | // ML: which conflicts with the user header <net/if.h> | 58 | // ML: which conflicts with the user header <net/if.h> |
59 | // ML: We really a user header for the Wireless Extensions, something like <net/wireless.h> | 59 | // ML: We really a user header for the Wireless Extensions, something like <net/wireless.h> |
60 | // ML: I will drop Jean an mail on that subject | 60 | // ML: I will drop Jean an mail on that subject |
61 | 61 | ||
62 | #include <net/if.h> | 62 | #include <net/if.h> |
63 | #define _LINUX_IF_H | 63 | #define _LINUX_IF_H |
64 | #include <linux/wireless.h> | 64 | #include <linux/wireless.h> |
65 | 65 | ||
66 | class ONetworkInterface; | 66 | class ONetworkInterface; |
67 | class OWirelessNetworkInterface; | 67 | class OWirelessNetworkInterface; |
68 | class OChannelHopper; | 68 | class OChannelHopper; |
69 | class OMonitoringInterface; | 69 | class OMonitoringInterface; |
70 | 70 | ||
71 | /*====================================================================================== | 71 | /*====================================================================================== |
72 | * ONetwork | 72 | * ONetwork |
73 | *======================================================================================*/ | 73 | *======================================================================================*/ |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * @brief A container class for all network devices. | 76 | * @brief A container class for all network devices. |
77 | * | 77 | * |
78 | * This class provides access to all available network devices of your computer. | 78 | * This class provides access to all available network devices of your computer. |
79 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 79 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
80 | */ | 80 | */ |
81 | class ONetwork : public QObject | 81 | class ONetwork : public QObject |
82 | { | 82 | { |
83 | Q_OBJECT | 83 | Q_OBJECT |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QDict<ONetworkInterface> InterfaceMap; | 86 | typedef QDict<ONetworkInterface> InterfaceMap; |
87 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; | 87 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; |
88 | 88 | ||
89 | public: | 89 | public: |
90 | /** | 90 | /** |
91 | * @returns a pointer to the (one and only) @ref ONetwork instance. | 91 | * @returns a pointer to the (one and only) @ref ONetwork instance. |
92 | */ | 92 | */ |
93 | static ONetwork* instance(); | 93 | static ONetwork* instance(); |
94 | /** | 94 | /** |
95 | * @returns an iterator usable for iterating through all network interfaces. | 95 | * @returns an iterator usable for iterating through all network interfaces. |
96 | */ | 96 | */ |
97 | InterfaceIterator iterator() const; | 97 | InterfaceIterator iterator() const; |
98 | /** | 98 | /** |
99 | * @returns true, if the @p interface supports the wireless extension protocol. | 99 | * @returns true, if the @p interface supports the wireless extension protocol. |
100 | */ | 100 | */ |
101 | // FIXME QString? -zecke | ||
101 | bool isWirelessInterface( const char* interface ) const; | 102 | bool isWirelessInterface( const char* interface ) const; |
102 | /** | 103 | /** |
103 | * @returns a pointer to the @ref ONetworkInterface object for the specified @p interface or 0, if not found | 104 | * @returns a pointer to the @ref ONetworkInterface object for the specified @p interface or 0, if not found |
104 | * @see ONetworkInterface | 105 | * @see ONetworkInterface |
105 | */ | 106 | */ |
106 | ONetworkInterface* interface( QString interface ) const; | 107 | // FIXME: const QString& is prefered over QString!!! -zecke |
108 | ONetworkInterface* interface( const QString& interface ) const; | ||
107 | 109 | ||
108 | protected: | 110 | protected: |
109 | ONetwork(); | 111 | ONetwork(); |
110 | void synchronize(); | 112 | void synchronize(); |
111 | 113 | ||
112 | private: | 114 | private: |
113 | static ONetwork* _instance; | 115 | static ONetwork* _instance; |
114 | InterfaceMap _interfaces; | 116 | InterfaceMap _interfaces; |
115 | }; | 117 | }; |
116 | 118 | ||
117 | 119 | ||
118 | /*====================================================================================== | 120 | /*====================================================================================== |
119 | * ONetworkInterface | 121 | * ONetworkInterface |
120 | *======================================================================================*/ | 122 | *======================================================================================*/ |
121 | 123 | ||
122 | /** | 124 | /** |
123 | * @brief A network interface wrapper. | 125 | * @brief A network interface wrapper. |
124 | * | 126 | * |
125 | * This class provides a wrapper for a network interface. All the cumbersume details of | 127 | * This class provides a wrapper for a network interface. All the cumbersume details of |
126 | * Linux ioctls are hidden under a convenient high-level interface. | 128 | * Linux ioctls are hidden under a convenient high-level interface. |
127 | * @warning Most of the setting methods contained in this class require the appropriate | 129 | * @warning Most of the setting methods contained in this class require the appropriate |
128 | * process permissions to work. | 130 | * process permissions to work. |
129 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 131 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
130 | */ | 132 | */ |
131 | class ONetworkInterface : public QObject | 133 | class ONetworkInterface : public QObject |
132 | { | 134 | { |
133 | friend class OMonitoringInterface; | 135 | friend class OMonitoringInterface; |
134 | friend class OCiscoMonitoringInterface; | 136 | friend class OCiscoMonitoringInterface; |
135 | friend class OWlanNGMonitoringInterface; | 137 | friend class OWlanNGMonitoringInterface; |
136 | friend class OHostAPMonitoringInterface; | 138 | friend class OHostAPMonitoringInterface; |
137 | friend class OOrinocoMonitoringInterface; | 139 | friend class OOrinocoMonitoringInterface; |
138 | 140 | ||
139 | public: | 141 | public: |
140 | /** | 142 | /** |
141 | * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, | 143 | * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, |
142 | * but access them via @ref ONetwork::interface(). | 144 | * but access them via @ref ONetwork::interface(). |
143 | */ | 145 | */ |
144 | ONetworkInterface( QObject* parent, const char* name ); | 146 | ONetworkInterface( QObject* parent, const char* name ); |
145 | /** | 147 | /** |
146 | * Destructor. | 148 | * Destructor. |
147 | */ | 149 | */ |
148 | virtual ~ONetworkInterface(); | 150 | virtual ~ONetworkInterface(); |
149 | /** | 151 | /** |
150 | * Associates a @a monitoring interface with this network interface. | 152 | * Associates a @a monitoring interface with this network interface. |
151 | * @note This is currently only useful with @ref OWirelessNetworkInterface objects. | 153 | * @note This is currently only useful with @ref OWirelessNetworkInterface objects. |
152 | */ | 154 | */ |
153 | void setMonitoring( OMonitoringInterface* monitoring ); | 155 | void setMonitoring( OMonitoringInterface* monitoring ); |
154 | /** | 156 | /** |
155 | * @returns the currently associated monitoring interface or 0, if no monitoring is associated. | 157 | * @returns the currently associated monitoring interface or 0, if no monitoring is associated. |
156 | */ | 158 | */ |
157 | OMonitoringInterface* monitoring() const; | 159 | OMonitoringInterface* monitoring() const; |
158 | /** | 160 | /** |
159 | * Setting an interface to promiscuous mode enables the device to receive | 161 | * Setting an interface to promiscuous mode enables the device to receive |
160 | * all packets on the shared medium - as opposed to packets which are addressed to this interface. | 162 | * all packets on the shared medium - as opposed to packets which are addressed to this interface. |
161 | */ | 163 | */ |
162 | bool setPromiscuousMode( bool ); | 164 | bool setPromiscuousMode( bool ); |
163 | /** | 165 | /** |
164 | * @returns true if the interface is set to promiscuous mode. | 166 | * @returns true if the interface is set to promiscuous mode. |
165 | */ | 167 | */ |
166 | bool promiscuousMode() const; | 168 | bool promiscuousMode() const; |
167 | /** | 169 | /** |
168 | * Setting an interface to up enables it to receive packets. | 170 | * Setting an interface to up enables it to receive packets. |
169 | */ | 171 | */ |
170 | bool setUp( bool ); | 172 | bool setUp( bool ); |
171 | /** | 173 | /** |
172 | * @returns true if the interface is up. | 174 | * @returns true if the interface is up. |
173 | */ | 175 | */ |
174 | bool isUp() const; | 176 | bool isUp() const; |
175 | /* | 177 | /* |
176 | * @returns true if the interface is a loopback interface. | 178 | * @returns true if the interface is a loopback interface. |
177 | */ | 179 | */ |
178 | bool isLoopback() const; | 180 | bool isLoopback() const; |
179 | /* | 181 | /* |
180 | * @returns true if the interface is featuring supports the wireless extension protocol. | 182 | * @returns true if the interface is featuring supports the wireless extension protocol. |
181 | */ | 183 | */ |
182 | bool isWireless() const; | 184 | bool isWireless() const; |
183 | /* | 185 | /* |
184 | * @returns the IPv4 address associated with this interface. | 186 | * @returns the IPv4 address associated with this interface. |
185 | */ | 187 | */ |
186 | QString ipV4Address() const; | 188 | QString ipV4Address() const; |
187 | /* | 189 | /* |
188 | * Associate the MAC address @a addr with the interface. | 190 | * Associate the MAC address @a addr with the interface. |
189 | * @note It can be necessary to shut down the interface prior to calling this method. | 191 | * @note It can be necessary to shut down the interface prior to calling this method. |
190 | * @warning This is not supported by all drivers. | 192 | * @warning This is not supported by all drivers. |
191 | */ | 193 | */ |
192 | void setMacAddress( const OMacAddress& addr ); | 194 | void setMacAddress( const OMacAddress& addr ); |
193 | /* | 195 | /* |
194 | * @returns the MAC address associated with this interface. | 196 | * @returns the MAC address associated with this interface. |
195 | */ | 197 | */ |
196 | OMacAddress macAddress() const; | 198 | OMacAddress macAddress() const; |
197 | /* | 199 | /* |
198 | * @returns the data link type currently associated with this interface. | 200 | * @returns the data link type currently associated with this interface. |
199 | * @see #include <net/if_arp.h> for possible values. | 201 | * @see #include <net/if_arp.h> for possible values. |
200 | */ | 202 | */ |
201 | int dataLinkType() const; | 203 | int dataLinkType() const; |
202 | 204 | ||
203 | protected: | 205 | protected: |
204 | const int _sfd; | 206 | const int _sfd; |
205 | mutable ifreq _ifr; | 207 | mutable ifreq _ifr; |
206 | OMonitoringInterface* _mon; | 208 | OMonitoringInterface* _mon; |
207 | 209 | ||
208 | protected: | 210 | protected: |
209 | struct ifreq& ifr() const; | 211 | struct ifreq& ifr() const; |
210 | virtual void init(); | 212 | virtual void init(); |
211 | bool ioctl( int call ) const; | 213 | bool ioctl( int call ) const; |
212 | bool ioctl( int call, struct ifreq& ) const; | 214 | bool ioctl( int call, struct ifreq& ) const; |
213 | }; | 215 | }; |
214 | 216 | ||
215 | /*====================================================================================== | 217 | /*====================================================================================== |
216 | * OChannelHopper | 218 | * OChannelHopper |
217 | *======================================================================================*/ | 219 | *======================================================================================*/ |
218 | 220 | ||
219 | /** | 221 | /** |
220 | * @brief A radio frequency channel hopper. | 222 | * @brief A radio frequency channel hopper. |
221 | * | 223 | * |
222 | * This class provides a channel hopper for radio frequencies. A channel hopper frequently | 224 | * This class provides a channel hopper for radio frequencies. A channel hopper frequently |
223 | * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. | 225 | * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. |
224 | * This is necessary when in monitoring mode and scanning for other devices, because | 226 | * This is necessary when in monitoring mode and scanning for other devices, because |
225 | * the radio frequency hardware can only detect packets sent on the same frequency. | 227 | * the radio frequency hardware can only detect packets sent on the same frequency. |
226 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 228 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
227 | */ | 229 | */ |
228 | class OChannelHopper : public QObject | 230 | class OChannelHopper : public QObject |
229 | { | 231 | { |
230 | Q_OBJECT | 232 | Q_OBJECT |
231 | 233 | ||
232 | public: | 234 | public: |
233 | OChannelHopper( OWirelessNetworkInterface* ); | 235 | OChannelHopper( OWirelessNetworkInterface* ); |
234 | virtual ~OChannelHopper(); | 236 | virtual ~OChannelHopper(); |
235 | bool isActive() const; | 237 | bool isActive() const; |
236 | int channel() const; | 238 | int channel() const; |
237 | virtual void timerEvent( QTimerEvent* ); | 239 | virtual void timerEvent( QTimerEvent* ); |
238 | void setInterval( int ); | 240 | void setInterval( int ); |
239 | int interval() const; | 241 | int interval() const; |
240 | 242 | ||
241 | signals: | 243 | signals: |
242 | void hopped( int ); | 244 | void hopped( int ); |
243 | 245 | ||
244 | private: | 246 | private: |
245 | OWirelessNetworkInterface* _iface; | 247 | OWirelessNetworkInterface* _iface; |
246 | int _interval; | 248 | int _interval; |
247 | int _tid; | 249 | int _tid; |
248 | QValueList<int> _channels; | 250 | QValueList<int> _channels; |
249 | QValueList<int>::Iterator _channel; | 251 | QValueList<int>::Iterator _channel; |
250 | }; | 252 | }; |
251 | 253 | ||
252 | 254 | ||
253 | /*====================================================================================== | 255 | /*====================================================================================== |
254 | * OWirelessNetworkInterface | 256 | * OWirelessNetworkInterface |
255 | *======================================================================================*/ | 257 | *======================================================================================*/ |
256 | 258 | ||
257 | /** | 259 | /** |
258 | * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. | 260 | * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. |
259 | * | 261 | * |
260 | * This class provides a high-level encapsulation of the Linux wireless extension API. | 262 | * This class provides a high-level encapsulation of the Linux wireless extension API. |
261 | */ | 263 | */ |
262 | class OWirelessNetworkInterface : public ONetworkInterface | 264 | class OWirelessNetworkInterface : public ONetworkInterface |
263 | { | 265 | { |
264 | friend class OMonitoringInterface; | 266 | friend class OMonitoringInterface; |
265 | friend class OCiscoMonitoringInterface; | 267 | friend class OCiscoMonitoringInterface; |
266 | friend class OWlanNGMonitoringInterface; | 268 | friend class OWlanNGMonitoringInterface; |
267 | friend class OHostAPMonitoringInterface; | 269 | friend class OHostAPMonitoringInterface; |
268 | friend class OOrinocoMonitoringInterface; | 270 | friend class OOrinocoMonitoringInterface; |
269 | 271 | ||
270 | friend class OPrivateIOCTL; | 272 | friend class OPrivateIOCTL; |
271 | 273 | ||
272 | public: | 274 | public: |
273 | enum Mode { AdHoc, Managed, Monitor }; | 275 | enum Mode { AdHoc, Managed, Monitor }; |
274 | 276 | ||
275 | /** | 277 | /** |
276 | * Constructor. | 278 | * Constructor. |
277 | */ | 279 | */ |
278 | OWirelessNetworkInterface( QObject* parent, const char* name ); | 280 | OWirelessNetworkInterface( QObject* parent, const char* name ); |
279 | /** | 281 | /** |
280 | * Destructor. | 282 | * Destructor. |
281 | */ | 283 | */ |
282 | virtual ~OWirelessNetworkInterface(); | 284 | virtual ~OWirelessNetworkInterface(); |
283 | /** | 285 | /** |
284 | * Setting the @a channel of the interface changes the radio frequency (RF) | 286 | * Setting the @a channel of the interface changes the radio frequency (RF) |
285 | * of the corresponding wireless network device. | 287 | * of the corresponding wireless network device. |
286 | */ | 288 | */ |
287 | virtual void setChannel( int channel ) const; | 289 | virtual void setChannel( int channel ) const; |
288 | /** | 290 | /** |
289 | * @returns the channel index of the current radio frequency. | 291 | * @returns the channel index of the current radio frequency. |
290 | */ | 292 | */ |
291 | virtual int channel() const; | 293 | virtual int channel() const; |
292 | /** | 294 | /** |
293 | * @returns the current radio frequency (in MHz). | 295 | * @returns the current radio frequency (in MHz). |
294 | */ | 296 | */ |
295 | virtual double frequency() const; | 297 | virtual double frequency() const; |
296 | /** | 298 | /** |
297 | * @returns the number of radio frequency channels for the | 299 | * @returns the number of radio frequency channels for the |
298 | * corresponding wireless network device. | 300 | * corresponding wireless network device. |
299 | * @note European devices usually have 14 channels, while American typically feature 11 channels. | 301 | * @note European devices usually have 14 channels, while American typically feature 11 channels. |
300 | */ | 302 | */ |
301 | virtual int channels() const; | 303 | virtual int channels() const; |
302 | //virtual double frequency(int) const; | 304 | //virtual double frequency(int) const; |
303 | 305 | ||
304 | virtual void setMode( Mode ) {}; //FIXME: Implement and document this | 306 | virtual void setMode( Mode ) {}; //FIXME: Implement and document this |
305 | virtual bool mode() const {}; //FIXME: Implement and document this | 307 | virtual bool mode() const {}; //FIXME: Implement and document this |
306 | 308 | ||
307 | /** | 309 | /** |
308 | * Setting the monitor mode on a wireless network interface enables | 310 | * Setting the monitor mode on a wireless network interface enables |
309 | * listening to IEEE 802.11 data and management frames which normally | 311 | * listening to IEEE 802.11 data and management frames which normally |
310 | * are handled by the device firmware. This can be used to detect | 312 | * are handled by the device firmware. This can be used to detect |
311 | * other wireless network devices, e.g. Access Points or Ad-hoc stations. | 313 | * other wireless network devices, e.g. Access Points or Ad-hoc stations. |
312 | * @warning Standard wireless network drives don't support the monitor mode. | 314 | * @warning Standard wireless network drives don't support the monitor mode. |
313 | * @warning You need a patched driver for this to work. | 315 | * @warning You need a patched driver for this to work. |
314 | * @note Enabling the monitor mode is highly driver dependent and requires | 316 | * @note Enabling the monitor mode is highly driver dependent and requires |
315 | * the proper @ref OMonitoringInterface to be associated with the interface. | 317 | * the proper @ref OMonitoringInterface to be associated with the interface. |
316 | * @see OMonitoringInterface | 318 | * @see OMonitoringInterface |
317 | */ | 319 | */ |
318 | virtual void setMonitorMode( bool ); | 320 | virtual void setMonitorMode( bool ); |
319 | /** | 321 | /** |
320 | * @returns true if the device is listening in IEEE 802.11 monitor mode | 322 | * @returns true if the device is listening in IEEE 802.11 monitor mode |
321 | */ | 323 | */ |
322 | virtual bool monitorMode() const; | 324 | virtual bool monitorMode() const; |
323 | /** | 325 | /** |
324 | * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. | 326 | * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. |
325 | * @see OChannelHopper | 327 | * @see OChannelHopper |
326 | */ | 328 | */ |
327 | virtual void setChannelHopping( int interval = 0 ); | 329 | virtual void setChannelHopping( int interval = 0 ); |
328 | /** | 330 | /** |
329 | * @returns the channel hopping interval or 0, if channel hopping is disabled. | 331 | * @returns the channel hopping interval or 0, if channel hopping is disabled. |
330 | */ | 332 | */ |
331 | virtual int channelHopping() const; | 333 | virtual int channelHopping() const; |
332 | /** | 334 | /** |
333 | * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before | 335 | * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before |
334 | */ | 336 | */ |
335 | virtual OChannelHopper* channelHopper() const; | 337 | virtual OChannelHopper* channelHopper() const; |
336 | /** | 338 | /** |
337 | * Set the station @a nickname. | 339 | * Set the station @a nickname. |
338 | */ | 340 | */ |
339 | virtual void setNickName( const QString& nickname ) {}; //FIXME: Implement this | 341 | virtual void setNickName( const QString& nickname ) {}; //FIXME: Implement this |
340 | /** | 342 | /** |
341 | * @returns the current station nickname. | 343 | * @returns the current station nickname. |
342 | */ | 344 | */ |
343 | virtual QString nickName() const; | 345 | virtual QString nickName() const; |
344 | /** | 346 | /** |
345 | * Invoke the private IOCTL @a command with a @number of parameters on the network interface. | 347 | * Invoke the private IOCTL @a command with a @number of parameters on the network interface. |
346 | * @see OPrivateIOCTL | 348 | * @see OPrivateIOCTL |
347 | */ | 349 | */ |
348 | virtual void setPrivate( const QString& command, int number, ... ); | 350 | virtual void setPrivate( const QString& command, int number, ... ); |
349 | /** | 351 | /** |
350 | * @returns true if the interface is featuring the private IOCTL @command. | 352 | * @returns true if the interface is featuring the private IOCTL @command. |
351 | */ | 353 | */ |
352 | virtual bool hasPrivate( const QString& command ); | 354 | virtual bool hasPrivate( const QString& command ); |
353 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this | 355 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this |
354 | 356 | ||
355 | virtual bool isAssociated() const {}; //FIXME: Implement and document this | 357 | virtual bool isAssociated() const {}; //FIXME: Implement and document this |
356 | virtual QString associatedAP() const; //FIXME: Implement and document this | 358 | virtual QString associatedAP() const; //FIXME: Implement and document this |
357 | 359 | ||
358 | virtual void setSSID( const QString& ); | 360 | virtual void setSSID( const QString& ); |
359 | virtual QString SSID() const; | 361 | virtual QString SSID() const; |
360 | 362 | ||
361 | protected: | 363 | protected: |
362 | void buildChannelList(); | 364 | void buildChannelList(); |
363 | void buildPrivateList(); | 365 | void buildPrivateList(); |
364 | virtual void init(); | 366 | virtual void init(); |
365 | struct iwreq& iwr() const; | 367 | struct iwreq& iwr() const; |
366 | bool wioctl( int call ) const; | 368 | bool wioctl( int call ) const; |
367 | bool wioctl( int call, struct iwreq& ) const; | 369 | bool wioctl( int call, struct iwreq& ) const; |
368 | 370 | ||
369 | protected: | 371 | protected: |
370 | mutable struct iwreq _iwr; | 372 | mutable struct iwreq _iwr; |
371 | QMap<int,int> _channels; | 373 | QMap<int,int> _channels; |
372 | 374 | ||
373 | private: | 375 | private: |
374 | OChannelHopper* _hopper; | 376 | OChannelHopper* _hopper; |
375 | }; | 377 | }; |
376 | 378 | ||
377 | 379 | ||
378 | /*====================================================================================== | 380 | /*====================================================================================== |
379 | * OMonitoringInterface | 381 | * OMonitoringInterface |
380 | *======================================================================================*/ | 382 | *======================================================================================*/ |
381 | 383 | ||
382 | 384 | ||
383 | class OMonitoringInterface | 385 | class OMonitoringInterface |
384 | { | 386 | { |
385 | public: | 387 | public: |
386 | OMonitoringInterface(); | 388 | OMonitoringInterface(); |
387 | OMonitoringInterface( ONetworkInterface* ); | 389 | OMonitoringInterface( ONetworkInterface* ); |
388 | virtual ~OMonitoringInterface(); | 390 | virtual ~OMonitoringInterface(); |
389 | 391 | ||
390 | public: | 392 | public: |
391 | virtual void setEnabled( bool ); | 393 | virtual void setEnabled( bool ); |
392 | virtual bool enabled() const; | 394 | virtual bool enabled() const; |
393 | virtual void setChannel( int ); | 395 | virtual void setChannel( int ); |
394 | 396 | ||
395 | virtual QString name() const = 0; | 397 | virtual QString name() const = 0; |
396 | 398 | ||
397 | protected: | 399 | protected: |
398 | OWirelessNetworkInterface* _if; | 400 | OWirelessNetworkInterface* _if; |
399 | 401 | ||
400 | }; | 402 | }; |
401 | 403 | ||
402 | 404 | ||
403 | /*====================================================================================== | 405 | /*====================================================================================== |
404 | * OCiscoMonitoring | 406 | * OCiscoMonitoring |
405 | *======================================================================================*/ | 407 | *======================================================================================*/ |
406 | 408 | ||
407 | 409 | ||
408 | class OCiscoMonitoringInterface : public OMonitoringInterface | 410 | class OCiscoMonitoringInterface : public OMonitoringInterface |
409 | { | 411 | { |
410 | public: | 412 | public: |
411 | OCiscoMonitoringInterface( ONetworkInterface* ); | 413 | OCiscoMonitoringInterface( ONetworkInterface* ); |
412 | virtual ~OCiscoMonitoringInterface(); | 414 | virtual ~OCiscoMonitoringInterface(); |
413 | 415 | ||
414 | virtual void setEnabled( bool ); | 416 | virtual void setEnabled( bool ); |
415 | virtual QString name() const; | 417 | virtual QString name() const; |
416 | virtual void setChannel( int ); | 418 | virtual void setChannel( int ); |
417 | 419 | ||
418 | }; | 420 | }; |
419 | 421 | ||
420 | /*====================================================================================== | 422 | /*====================================================================================== |
421 | * OWlanNGMonitoringInterface | 423 | * OWlanNGMonitoringInterface |
422 | *======================================================================================*/ | 424 | *======================================================================================*/ |
423 | 425 | ||
424 | class OWlanNGMonitoringInterface : public OMonitoringInterface | 426 | class OWlanNGMonitoringInterface : public OMonitoringInterface |
425 | { | 427 | { |
426 | public: | 428 | public: |
427 | OWlanNGMonitoringInterface( ONetworkInterface* ); | 429 | OWlanNGMonitoringInterface( ONetworkInterface* ); |
428 | virtual ~OWlanNGMonitoringInterface(); | 430 | virtual ~OWlanNGMonitoringInterface(); |
429 | 431 | ||
430 | public: | 432 | public: |
431 | virtual void setEnabled( bool ); | 433 | virtual void setEnabled( bool ); |
432 | virtual QString name() const; | 434 | virtual QString name() const; |
433 | virtual void setChannel( int ); | 435 | virtual void setChannel( int ); |
434 | 436 | ||
435 | }; | 437 | }; |
436 | 438 | ||
437 | /*====================================================================================== | 439 | /*====================================================================================== |
438 | * OHostAPMonitoringInterface | 440 | * OHostAPMonitoringInterface |
439 | *======================================================================================*/ | 441 | *======================================================================================*/ |
440 | 442 | ||
441 | class OHostAPMonitoringInterface : public OMonitoringInterface | 443 | class OHostAPMonitoringInterface : public OMonitoringInterface |
442 | { | 444 | { |
443 | public: | 445 | public: |
444 | OHostAPMonitoringInterface( ONetworkInterface* ); | 446 | OHostAPMonitoringInterface( ONetworkInterface* ); |
445 | virtual ~OHostAPMonitoringInterface(); | 447 | virtual ~OHostAPMonitoringInterface(); |
446 | 448 | ||
447 | public: | 449 | public: |
448 | virtual void setEnabled( bool ); | 450 | virtual void setEnabled( bool ); |
449 | virtual QString name() const; | 451 | virtual QString name() const; |
450 | }; | 452 | }; |
451 | 453 | ||
452 | /*====================================================================================== | 454 | /*====================================================================================== |
453 | * OOrinocoMonitoringInterface | 455 | * OOrinocoMonitoringInterface |
454 | *======================================================================================*/ | 456 | *======================================================================================*/ |
455 | 457 | ||
456 | class OOrinocoMonitoringInterface : public OMonitoringInterface | 458 | class OOrinocoMonitoringInterface : public OMonitoringInterface |
457 | { | 459 | { |
458 | public: | 460 | public: |
459 | OOrinocoMonitoringInterface( ONetworkInterface* ); | 461 | OOrinocoMonitoringInterface( ONetworkInterface* ); |
460 | virtual ~OOrinocoMonitoringInterface(); | 462 | virtual ~OOrinocoMonitoringInterface(); |
461 | 463 | ||
462 | public: | 464 | public: |
463 | virtual void setChannel( int ); | 465 | virtual void setChannel( int ); |
464 | virtual void setEnabled( bool ); | 466 | virtual void setEnabled( bool ); |
465 | virtual QString name() const; | 467 | virtual QString name() const; |
466 | 468 | ||
467 | }; | 469 | }; |
468 | 470 | ||
469 | #endif // ONETWORK_H | 471 | #endif // ONETWORK_H |
470 | 472 | ||
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h index 99631ba..6bf7416 100644 --- a/libopie2/opienet/opcap.h +++ b/libopie2/opienet/opcap.h | |||
@@ -1,507 +1,517 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003 by the Wellenreiter team: | 3 | Copyright (C) 2003 by the Wellenreiter team: |
4 | Martin J. Muench <mjm@remote-exploit.org> | 4 | Martin J. Muench <mjm@remote-exploit.org> |
5 | Max Moser <mmo@remote-exploit.org | 5 | Max Moser <mmo@remote-exploit.org |
6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef OPCAP_H | 34 | #ifndef OPCAP_H |
35 | #define OPCAP_H | 35 | #define OPCAP_H |
36 | 36 | ||
37 | /* LINUX */ | 37 | /* LINUX */ |
38 | extern "C" // work around a bpf/pcap conflict in recent headers | 38 | extern "C" // work around a bpf/pcap conflict in recent headers |
39 | { | 39 | { |
40 | #include <pcap.h> | 40 | #include <pcap.h> |
41 | } | 41 | } |
42 | #include <netinet/ether.h> | 42 | #include <netinet/ether.h> |
43 | #include <netinet/ip.h> | 43 | #include <netinet/ip.h> |
44 | #include <netinet/udp.h> | 44 | #include <netinet/udp.h> |
45 | #include <netinet/tcp.h> | 45 | #include <netinet/tcp.h> |
46 | #include <time.h> | 46 | #include <time.h> |
47 | 47 | ||
48 | /* QT */ | 48 | /* QT */ |
49 | #include <qevent.h> | 49 | #include <qevent.h> |
50 | #include <qfile.h> | 50 | #include <qfile.h> |
51 | #include <qhostaddress.h> | 51 | #include <qhostaddress.h> |
52 | #include <qobject.h> | 52 | #include <qobject.h> |
53 | #include <qstring.h> | 53 | #include <qstring.h> |
54 | #include <qmap.h> | 54 | #include <qmap.h> |
55 | 55 | ||
56 | /* OPIE */ | 56 | /* OPIE */ |
57 | #include <opie2/onetutils.h> | 57 | #include <opie2/onetutils.h> |
58 | #include "802_11_user.h" | 58 | #include "802_11_user.h" |
59 | 59 | ||
60 | /* TYPEDEFS */ | 60 | /* TYPEDEFS */ |
61 | typedef struct timeval timevalstruct; | 61 | typedef struct timeval timevalstruct; |
62 | typedef struct pcap_pkthdr packetheaderstruct; | 62 | typedef struct pcap_pkthdr packetheaderstruct; |
63 | 63 | ||
64 | /* FORWARDS */ | 64 | /* FORWARDS */ |
65 | class OPacketCapturer; | 65 | class OPacketCapturer; |
66 | class QSocketNotifier; | 66 | class QSocketNotifier; |
67 | 67 | ||
68 | /*====================================================================================== | 68 | /*====================================================================================== |
69 | * OPacket - A frame on the wire | 69 | * OPacket - A frame on the wire |
70 | *======================================================================================*/ | 70 | *======================================================================================*/ |
71 | 71 | // FIXME how many OPackets do we've at a time? QObject seams to be a big for that usage | |
72 | class OPacket : public QObject | 72 | class OPacket : public QObject |
73 | { | 73 | { |
74 | Q_OBJECT | 74 | Q_OBJECT |
75 | 75 | ||
76 | public: | 76 | public: |
77 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); | 77 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); |
78 | virtual ~OPacket(); | 78 | virtual ~OPacket(); |
79 | 79 | ||
80 | timevalstruct timeval() const; | 80 | timevalstruct timeval() const; |
81 | 81 | ||
82 | int caplen() const; | 82 | int caplen() const; |
83 | int len() const; | 83 | int len() const; |
84 | QString dump( int = 32 ) const; | 84 | QString dump( int = 32 ) const; |
85 | 85 | ||
86 | void updateStats( QMap<QString,int>&, QObjectList* ); | 86 | void updateStats( QMap<QString,int>&, QObjectList* ); |
87 | 87 | ||
88 | private: | 88 | private: |
89 | const packetheaderstruct _hdr; // pcap packet header | 89 | const packetheaderstruct _hdr; // pcap packet header |
90 | const unsigned char* _data; // pcap packet data | 90 | const unsigned char* _data; // pcap packet data |
91 | const unsigned char* _end; // end of pcap packet data | 91 | const unsigned char* _end; // end of pcap packet data |
92 | }; | 92 | }; |
93 | 93 | ||
94 | /*====================================================================================== | 94 | /*====================================================================================== |
95 | * OEthernetPacket - DLT_EN10MB frame | 95 | * OEthernetPacket - DLT_EN10MB frame |
96 | *======================================================================================*/ | 96 | *======================================================================================*/ |
97 | 97 | ||
98 | //FIXME same critic as above -zecke | ||
98 | class OEthernetPacket : public QObject | 99 | class OEthernetPacket : public QObject |
99 | { | 100 | { |
100 | Q_OBJECT | 101 | Q_OBJECT |
101 | 102 | ||
102 | public: | 103 | public: |
103 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); | 104 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); |
104 | virtual ~OEthernetPacket(); | 105 | virtual ~OEthernetPacket(); |
105 | 106 | ||
106 | OMacAddress sourceAddress() const; | 107 | OMacAddress sourceAddress() const; |
107 | OMacAddress destinationAddress() const; | 108 | OMacAddress destinationAddress() const; |
108 | int type() const; | 109 | int type() const; |
109 | 110 | ||
110 | private: | 111 | private: |
111 | const struct ether_header* _ether; | 112 | const struct ether_header* _ether; |
112 | }; | 113 | }; |
113 | 114 | ||
114 | 115 | ||
115 | /*====================================================================================== | 116 | /*====================================================================================== |
116 | * OWaveLanPacket - DLT_IEEE802_11 frame | 117 | * OWaveLanPacket - DLT_IEEE802_11 frame |
117 | *======================================================================================*/ | 118 | *======================================================================================*/ |
118 | 119 | //FIXME same | |
119 | class OWaveLanPacket : public QObject | 120 | class OWaveLanPacket : public QObject |
120 | { | 121 | { |
121 | Q_OBJECT | 122 | Q_OBJECT |
122 | 123 | ||
123 | public: | 124 | public: |
124 | OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); | 125 | OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); |
125 | virtual ~OWaveLanPacket(); | 126 | virtual ~OWaveLanPacket(); |
126 | 127 | ||
127 | int duration() const; | 128 | int duration() const; |
128 | bool fromDS() const; | 129 | bool fromDS() const; |
129 | bool toDS() const; | 130 | bool toDS() const; |
130 | virtual OMacAddress macAddress1() const; | 131 | virtual OMacAddress macAddress1() const; |
131 | virtual OMacAddress macAddress2() const; | 132 | virtual OMacAddress macAddress2() const; |
132 | virtual OMacAddress macAddress3() const; | 133 | virtual OMacAddress macAddress3() const; |
133 | virtual OMacAddress macAddress4() const; | 134 | virtual OMacAddress macAddress4() const; |
134 | bool usesPowerManagement() const; | 135 | bool usesPowerManagement() const; |
135 | int type() const; | 136 | int type() const; |
136 | int subType() const; | 137 | int subType() const; |
137 | int version() const; | 138 | int version() const; |
138 | bool usesWep() const; | 139 | bool usesWep() const; |
139 | 140 | ||
140 | private: | 141 | private: |
141 | const struct ieee_802_11_header* _wlanhdr; | 142 | const struct ieee_802_11_header* _wlanhdr; |
142 | }; | 143 | }; |
143 | 144 | ||
144 | 145 | ||
145 | /*====================================================================================== | 146 | /*====================================================================================== |
146 | * OWaveLanManagementPacket - type: management (T_MGMT) | 147 | * OWaveLanManagementPacket - type: management (T_MGMT) |
147 | *======================================================================================*/ | 148 | *======================================================================================*/ |
148 | 149 | //FIXME same as above -zecke | |
149 | class OWaveLanManagementPacket : public QObject | 150 | class OWaveLanManagementPacket : public QObject |
150 | { | 151 | { |
151 | Q_OBJECT | 152 | Q_OBJECT |
152 | 153 | ||
153 | public: | 154 | public: |
154 | OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); | 155 | OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); |
155 | virtual ~OWaveLanManagementPacket(); | 156 | virtual ~OWaveLanManagementPacket(); |
156 | 157 | ||
157 | QString managementType() const; | 158 | QString managementType() const; |
158 | 159 | ||
159 | int beaconInterval() const; | 160 | int beaconInterval() const; |
160 | int capabilities() const; // generic | 161 | int capabilities() const; // generic |
161 | 162 | ||
162 | bool canESS() const; | 163 | bool canESS() const; |
163 | bool canIBSS() const; | 164 | bool canIBSS() const; |
164 | bool canCFP() const; | 165 | bool canCFP() const; |
165 | bool canCFP_REQ() const; | 166 | bool canCFP_REQ() const; |
166 | bool canPrivacy() const; | 167 | bool canPrivacy() const; |
167 | 168 | ||
168 | private: | 169 | private: |
169 | const struct ieee_802_11_mgmt_header* _header; | 170 | const struct ieee_802_11_mgmt_header* _header; |
170 | const struct ieee_802_11_mgmt_body* _body; | 171 | const struct ieee_802_11_mgmt_body* _body; |
171 | }; | 172 | }; |
172 | 173 | ||
173 | 174 | ||
174 | /*====================================================================================== | 175 | /*====================================================================================== |
175 | * OWaveLanManagementSSID | 176 | * OWaveLanManagementSSID |
176 | *======================================================================================*/ | 177 | *======================================================================================*/ |
177 | 178 | //FIXME is QObject necessary? -zecke | |
178 | class OWaveLanManagementSSID : public QObject | 179 | class OWaveLanManagementSSID : public QObject |
179 | { | 180 | { |
180 | Q_OBJECT | 181 | Q_OBJECT |
181 | 182 | ||
182 | public: | 183 | public: |
183 | OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); | 184 | OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); |
184 | virtual ~OWaveLanManagementSSID(); | 185 | virtual ~OWaveLanManagementSSID(); |
185 | 186 | ||
186 | QString ID() const; | 187 | QString ID() const; |
187 | 188 | ||
188 | private: | 189 | private: |
189 | const struct ssid_t* _data; | 190 | const struct ssid_t* _data; |
190 | }; | 191 | }; |
191 | 192 | ||
192 | /*====================================================================================== | 193 | /*====================================================================================== |
193 | * OWaveLanManagementRates | 194 | * OWaveLanManagementRates |
194 | *======================================================================================*/ | 195 | *======================================================================================*/ |
195 | 196 | // FIXME same as above -zecke | |
196 | class OWaveLanManagementRates : public QObject | 197 | class OWaveLanManagementRates : public QObject |
197 | { | 198 | { |
198 | Q_OBJECT | 199 | Q_OBJECT |
199 | 200 | ||
200 | public: | 201 | public: |
201 | OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); | 202 | OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); |
202 | virtual ~OWaveLanManagementRates(); | 203 | virtual ~OWaveLanManagementRates(); |
203 | 204 | ||
204 | private: | 205 | private: |
205 | const struct rates_t* _data; | 206 | const struct rates_t* _data; |
206 | }; | 207 | }; |
207 | 208 | ||
208 | /*====================================================================================== | 209 | /*====================================================================================== |
209 | * OWaveLanManagementCF | 210 | * OWaveLanManagementCF |
210 | *======================================================================================*/ | 211 | *======================================================================================*/ |
211 | 212 | ||
213 | //FIXME same.... | ||
212 | class OWaveLanManagementCF : public QObject | 214 | class OWaveLanManagementCF : public QObject |
213 | { | 215 | { |
214 | Q_OBJECT | 216 | Q_OBJECT |
215 | 217 | ||
216 | public: | 218 | public: |
217 | OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); | 219 | OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); |
218 | virtual ~OWaveLanManagementCF(); | 220 | virtual ~OWaveLanManagementCF(); |
219 | 221 | ||
220 | private: | 222 | private: |
221 | const struct cf_t* _data; | 223 | const struct cf_t* _data; |
222 | }; | 224 | }; |
223 | 225 | ||
224 | /*====================================================================================== | 226 | /*====================================================================================== |
225 | * OWaveLanManagementFH | 227 | * OWaveLanManagementFH |
226 | *======================================================================================*/ | 228 | *======================================================================================*/ |
227 | 229 | ||
230 | //FIXME same | ||
228 | class OWaveLanManagementFH : public QObject | 231 | class OWaveLanManagementFH : public QObject |
229 | { | 232 | { |
230 | Q_OBJECT | 233 | Q_OBJECT |
231 | 234 | ||
232 | public: | 235 | public: |
233 | OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); | 236 | OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); |
234 | virtual ~OWaveLanManagementFH(); | 237 | virtual ~OWaveLanManagementFH(); |
235 | 238 | ||
236 | private: | 239 | private: |
237 | const struct fh_t* _data; | 240 | const struct fh_t* _data; |
238 | }; | 241 | }; |
239 | 242 | ||
240 | /*====================================================================================== | 243 | /*====================================================================================== |
241 | * OWaveLanManagementDS | 244 | * OWaveLanManagementDS |
242 | *======================================================================================*/ | 245 | *======================================================================================*/ |
243 | 246 | //FIXME same | |
244 | class OWaveLanManagementDS : public QObject | 247 | class OWaveLanManagementDS : public QObject |
245 | { | 248 | { |
246 | Q_OBJECT | 249 | Q_OBJECT |
247 | 250 | ||
248 | public: | 251 | public: |
249 | OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); | 252 | OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); |
250 | virtual ~OWaveLanManagementDS(); | 253 | virtual ~OWaveLanManagementDS(); |
251 | 254 | ||
252 | int channel() const; | 255 | int channel() const; |
253 | 256 | ||
254 | private: | 257 | private: |
255 | const struct ds_t* _data; | 258 | const struct ds_t* _data; |
256 | }; | 259 | }; |
257 | 260 | ||
258 | /*====================================================================================== | 261 | /*====================================================================================== |
259 | * OWaveLanManagementTim | 262 | * OWaveLanManagementTim |
260 | *======================================================================================*/ | 263 | *======================================================================================*/ |
261 | 264 | ||
265 | //FIXME guess what? | ||
262 | class OWaveLanManagementTim : public QObject | 266 | class OWaveLanManagementTim : public QObject |
263 | { | 267 | { |
264 | Q_OBJECT | 268 | Q_OBJECT |
265 | 269 | ||
266 | public: | 270 | public: |
267 | OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); | 271 | OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); |
268 | virtual ~OWaveLanManagementTim(); | 272 | virtual ~OWaveLanManagementTim(); |
269 | 273 | ||
270 | private: | 274 | private: |
271 | const struct tim_t* _data; | 275 | const struct tim_t* _data; |
272 | }; | 276 | }; |
273 | 277 | ||
274 | /*====================================================================================== | 278 | /*====================================================================================== |
275 | * OWaveLanManagementIBSS | 279 | * OWaveLanManagementIBSS |
276 | *======================================================================================*/ | 280 | *======================================================================================*/ |
277 | 281 | ||
282 | //FIXME same as above ( Qobject ) | ||
278 | class OWaveLanManagementIBSS : public QObject | 283 | class OWaveLanManagementIBSS : public QObject |
279 | { | 284 | { |
280 | Q_OBJECT | 285 | Q_OBJECT |
281 | 286 | ||
282 | public: | 287 | public: |
283 | OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); | 288 | OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); |
284 | virtual ~OWaveLanManagementIBSS(); | 289 | virtual ~OWaveLanManagementIBSS(); |
285 | 290 | ||
286 | private: | 291 | private: |
287 | const struct ibss_t* _data; | 292 | const struct ibss_t* _data; |
288 | }; | 293 | }; |
289 | 294 | ||
290 | /*====================================================================================== | 295 | /*====================================================================================== |
291 | * OWaveLanManagementChallenge | 296 | * OWaveLanManagementChallenge |
292 | *======================================================================================*/ | 297 | *======================================================================================*/ |
293 | 298 | ||
299 | // Qobject do we need that?? | ||
294 | class OWaveLanManagementChallenge : public QObject | 300 | class OWaveLanManagementChallenge : public QObject |
295 | { | 301 | { |
296 | Q_OBJECT | 302 | Q_OBJECT |
297 | 303 | ||
298 | public: | 304 | public: |
299 | OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); | 305 | OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); |
300 | virtual ~OWaveLanManagementChallenge(); | 306 | virtual ~OWaveLanManagementChallenge(); |
301 | 307 | ||
302 | private: | 308 | private: |
303 | const struct challenge_t* _data; | 309 | const struct challenge_t* _data; |
304 | }; | 310 | }; |
305 | 311 | ||
306 | /*====================================================================================== | 312 | /*====================================================================================== |
307 | * OWaveLanDataPacket - type: data (T_DATA) | 313 | * OWaveLanDataPacket - type: data (T_DATA) |
308 | *======================================================================================*/ | 314 | *======================================================================================*/ |
309 | 315 | // Qobject? | |
310 | class OWaveLanDataPacket : public QObject | 316 | class OWaveLanDataPacket : public QObject |
311 | { | 317 | { |
312 | Q_OBJECT | 318 | Q_OBJECT |
313 | 319 | ||
314 | public: | 320 | public: |
315 | OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); | 321 | OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); |
316 | virtual ~OWaveLanDataPacket(); | 322 | virtual ~OWaveLanDataPacket(); |
317 | 323 | ||
318 | private: | 324 | private: |
319 | const struct ieee_802_11_data_header* _header; | 325 | const struct ieee_802_11_data_header* _header; |
320 | }; | 326 | }; |
321 | 327 | ||
322 | /*====================================================================================== | 328 | /*====================================================================================== |
323 | * OWaveLanControlPacket - type: control (T_CTRL) | 329 | * OWaveLanControlPacket - type: control (T_CTRL) |
324 | *======================================================================================*/ | 330 | *======================================================================================*/ |
325 | 331 | // Qobject needed? | |
326 | class OWaveLanControlPacket : public QObject | 332 | class OWaveLanControlPacket : public QObject |
327 | { | 333 | { |
328 | Q_OBJECT | 334 | Q_OBJECT |
329 | 335 | ||
330 | public: | 336 | public: |
331 | OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); | 337 | OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); |
332 | virtual ~OWaveLanControlPacket(); | 338 | virtual ~OWaveLanControlPacket(); |
333 | 339 | ||
334 | private: | 340 | private: |
335 | const struct ieee_802_11_control_header* _header; | 341 | const struct ieee_802_11_control_header* _header; |
336 | }; | 342 | }; |
337 | 343 | ||
338 | /*====================================================================================== | 344 | /*====================================================================================== |
339 | * OLLCPacket - IEEE 802.2 Link Level Control | 345 | * OLLCPacket - IEEE 802.2 Link Level Control |
340 | *======================================================================================*/ | 346 | *======================================================================================*/ |
341 | 347 | ||
348 | // QObject needed? | ||
342 | class OLLCPacket : public QObject | 349 | class OLLCPacket : public QObject |
343 | { | 350 | { |
344 | Q_OBJECT | 351 | Q_OBJECT |
345 | 352 | ||
346 | public: | 353 | public: |
347 | OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); | 354 | OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); |
348 | virtual ~OLLCPacket(); | 355 | virtual ~OLLCPacket(); |
349 | 356 | ||
350 | private: | 357 | private: |
358 | //FIXME how to get that header? | ||
351 | const struct ieee_802_11_802_2_header* _header; | 359 | const struct ieee_802_11_802_2_header* _header; |
352 | }; | 360 | }; |
353 | 361 | ||
354 | /*====================================================================================== | 362 | /*====================================================================================== |
355 | * OIPPacket | 363 | * OIPPacket |
356 | *======================================================================================*/ | 364 | *======================================================================================*/ |
357 | 365 | ||
366 | // Qobject as baseclass? | ||
358 | class OIPPacket : public QObject | 367 | class OIPPacket : public QObject |
359 | { | 368 | { |
360 | Q_OBJECT | 369 | Q_OBJECT |
361 | 370 | ||
362 | public: | 371 | public: |
363 | OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); | 372 | OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); |
364 | virtual ~OIPPacket(); | 373 | virtual ~OIPPacket(); |
365 | 374 | ||
366 | QHostAddress fromIPAddress() const; | 375 | QHostAddress fromIPAddress() const; |
367 | QHostAddress toIPAddress() const; | 376 | QHostAddress toIPAddress() const; |
368 | 377 | ||
369 | int tos() const; | 378 | int tos() const; |
370 | int len() const; | 379 | int len() const; |
371 | int id() const; | 380 | int id() const; |
372 | int offset() const; | 381 | int offset() const; |
373 | int ttl() const; | 382 | int ttl() const; |
374 | int protocol() const; | 383 | int protocol() const; |
375 | int checksum() const; | 384 | int checksum() const; |
376 | 385 | ||
377 | private: | 386 | private: |
378 | const struct iphdr* _iphdr; | 387 | const struct iphdr* _iphdr; |
379 | }; | 388 | }; |
380 | 389 | ||
381 | /*====================================================================================== | 390 | /*====================================================================================== |
382 | * OUDPPacket | 391 | * OUDPPacket |
383 | *======================================================================================*/ | 392 | *======================================================================================*/ |
384 | 393 | // QObject? | |
385 | class OUDPPacket : public QObject | 394 | class OUDPPacket : public QObject |
386 | { | 395 | { |
387 | Q_OBJECT | 396 | Q_OBJECT |
388 | 397 | ||
389 | public: | 398 | public: |
390 | OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); | 399 | OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); |
391 | virtual ~OUDPPacket(); | 400 | virtual ~OUDPPacket(); |
392 | 401 | ||
393 | int fromPort() const; | 402 | int fromPort() const; |
394 | int toPort() const; | 403 | int toPort() const; |
395 | 404 | ||
396 | private: | 405 | private: |
397 | const struct udphdr* _udphdr; | 406 | const struct udphdr* _udphdr; |
398 | }; | 407 | }; |
399 | 408 | ||
400 | /*====================================================================================== | 409 | /*====================================================================================== |
401 | * OTCPPacket | 410 | * OTCPPacket |
402 | *======================================================================================*/ | 411 | *======================================================================================*/ |
403 | 412 | ||
413 | // Qobect needed? | ||
404 | class OTCPPacket : public QObject | 414 | class OTCPPacket : public QObject |
405 | { | 415 | { |
406 | Q_OBJECT | 416 | Q_OBJECT |
407 | 417 | ||
408 | public: | 418 | public: |
409 | OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); | 419 | OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); |
410 | virtual ~OTCPPacket(); | 420 | virtual ~OTCPPacket(); |
411 | 421 | ||
412 | int fromPort() const; | 422 | int fromPort() const; |
413 | int toPort() const; | 423 | int toPort() const; |
414 | 424 | ||
415 | private: | 425 | private: |
416 | const struct tcphdr* _tcphdr; | 426 | const struct tcphdr* _tcphdr; |
417 | }; | 427 | }; |
418 | 428 | ||
419 | 429 | ||
420 | /*====================================================================================== | 430 | /*====================================================================================== |
421 | * OPacketCapturer | 431 | * OPacketCapturer |
422 | *======================================================================================*/ | 432 | *======================================================================================*/ |
423 | 433 | ||
424 | /** | 434 | /** |
425 | * @brief A class based wrapper for network packet capturing. | 435 | * @brief A class based wrapper for network packet capturing. |
426 | * | 436 | * |
427 | * This class is the base of a high-level interface to the well known packet capturing | 437 | * This class is the base of a high-level interface to the well known packet capturing |
428 | * library libpcap. ... | 438 | * library libpcap. ... |
429 | */ | 439 | */ |
430 | class OPacketCapturer : public QObject | 440 | class OPacketCapturer : public QObject |
431 | { | 441 | { |
432 | Q_OBJECT | 442 | Q_OBJECT |
433 | 443 | ||
434 | public: | 444 | public: |
435 | /** | 445 | /** |
436 | * Constructor. | 446 | * Constructor. |
437 | */ | 447 | */ |
438 | OPacketCapturer( QObject* parent = 0, const char* name = 0 ); | 448 | OPacketCapturer( QObject* parent = 0, const char* name = 0 ); |
439 | /** | 449 | /** |
440 | * Destructor. | 450 | * Destructor. |
441 | */ | 451 | */ |
442 | ~OPacketCapturer(); | 452 | ~OPacketCapturer(); |
443 | /** | 453 | /** |
444 | * Setting the packet capturer to use blocking IO calls can be useful when | 454 | * Setting the packet capturer to use blocking IO calls can be useful when |
445 | * not using the socket notifier, e.g. without an application object. | 455 | * not using the socket notifier, e.g. without an application object. |
446 | */ | 456 | */ |
447 | void setBlocking( bool ); | 457 | void setBlocking( bool ); |
448 | /** | 458 | /** |
449 | * @returns true if the packet capturer uses blocking IO calls. | 459 | * @returns true if the packet capturer uses blocking IO calls. |
450 | */ | 460 | */ |
451 | bool blocking() const; | 461 | bool blocking() const; |
452 | /** | 462 | /** |
453 | * Closes the packet capturer. This is automatically done in the destructor. | 463 | * Closes the packet capturer. This is automatically done in the destructor. |
454 | */ | 464 | */ |
455 | void close(); | 465 | void close(); |
456 | /** | 466 | /** |
457 | * @returns the data link type. | 467 | * @returns the data link type. |
458 | * @see <pcap.h> for possible values. | 468 | * @see <pcap.h> for possible values. |
459 | */ | 469 | */ |
460 | int dataLink() const; | 470 | int dataLink() const; |
461 | /** | 471 | /** |
462 | * @returns the filedescriptor of the packet capturer. This is only useful, if | 472 | * @returns the filedescriptor of the packet capturer. This is only useful, if |
463 | * not using the socket notifier, e.g. without an application object. | 473 | * not using the socket notifier, e.g. without an application object. |
464 | */ | 474 | */ |
465 | int fileno() const; | 475 | int fileno() const; |
466 | /** | 476 | /** |
467 | * @returns the next @ref OPacket from the packet capturer. | 477 | * @returns the next @ref OPacket from the packet capturer. |
468 | * @note If blocking mode is true then this call might block. | 478 | * @note If blocking mode is true then this call might block. |
469 | */ | 479 | */ |
470 | OPacket* next(); | 480 | OPacket* next(); |
471 | /** | 481 | /** |
472 | * Open the packet capturer to capture packets in live-mode from @a interface. | 482 | * Open the packet capturer to capture packets in live-mode from @a interface. |
473 | * If a @a filename is given, all captured packets are output to a tcpdump-compatible capture file. | 483 | * If a @a filename is given, all captured packets are output to a tcpdump-compatible capture file. |
474 | */ | 484 | */ |
475 | bool open( const QString& interface, const QString& filename = QString::null ); | 485 | bool open( const QString& interface, const QString& filename = QString::null ); |
476 | /** | 486 | /** |
477 | * Open the packet capturer to capture packets in offline-mode from @a file. | 487 | * Open the packet capturer to capture packets in offline-mode from @a file. |
478 | */ | 488 | */ |
479 | bool open( const QFile& file ); | 489 | bool open( const QFile& file ); |
480 | /** | 490 | /** |
481 | * @returns true if the packet capturer is open | 491 | * @returns true if the packet capturer is open |
482 | */ | 492 | */ |
483 | bool isOpen() const; | 493 | bool isOpen() const; |
484 | 494 | ||
485 | const QMap<QString,int>& statistics() const; | 495 | const QMap<QString,int>& statistics() const; |
486 | 496 | ||
487 | signals: | 497 | signals: |
488 | /** | 498 | /** |
489 | * This signal is emitted, when a packet has been received. | 499 | * This signal is emitted, when a packet has been received. |
490 | */ | 500 | */ |
491 | void receivedPacket( OPacket* ); | 501 | void receivedPacket( OPacket* ); |
492 | 502 | ||
493 | protected slots: | 503 | protected slots: |
494 | void readyToReceive(); | 504 | void readyToReceive(); |
495 | 505 | ||
496 | protected: | 506 | protected: |
497 | QString _name; // devicename | 507 | QString _name; // devicename |
498 | bool _open; // check this before doing pcap calls | 508 | bool _open; // check this before doing pcap calls |
499 | pcap_t* _pch; // pcap library handle | 509 | pcap_t* _pch; // pcap library handle |
500 | pcap_dumper_t* _pcd; // pcap dumper handle | 510 | pcap_dumper_t* _pcd; // pcap dumper handle |
501 | QSocketNotifier* _sn; // socket notifier for main loop | 511 | QSocketNotifier* _sn; // socket notifier for main loop |
502 | mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap | 512 | mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap |
503 | QMap<QString, int> _stats; // statistics; | 513 | QMap<QString, int> _stats; // statistics; |
504 | }; | 514 | }; |
505 | 515 | ||
506 | #endif // OPCAP_H | 516 | #endif // OPCAP_H |
507 | 517 | ||
diff --git a/libopie2/opieui/odialog.h b/libopie2/opieui/odialog.h index 7947dfb..4116ed7 100644 --- a/libopie2/opieui/odialog.h +++ b/libopie2/opieui/odialog.h | |||
@@ -1,88 +1,89 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef ODIALOG_H | 32 | #ifndef ODIALOG_H |
33 | #define ODIALOG_H | 33 | #define ODIALOG_H |
34 | 34 | ||
35 | class QLayoutItem; | 35 | class QLayoutItem; |
36 | 36 | ||
37 | #include <qdialog.h> | 37 | #include <qdialog.h> |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * Dialog with extended nonmodal support and methods for OPIE standard | 40 | * Dialog with extended nonmodal support and methods for OPIE standard |
41 | * compliance. | 41 | * compliance. |
42 | * | 42 | * |
43 | * The @ref marginHint() and @ref spacingHint() sizes shall be used | 43 | * The @ref marginHint() and @ref spacingHint() sizes shall be used |
44 | * whenever you layout the interior of a dialog. One special note. If | 44 | * whenever you layout the interior of a dialog. One special note. If |
45 | * you make your own action buttons (OK, Cancel etc), the space | 45 | * you make your own action buttons (OK, Cancel etc), the space |
46 | * beteween the buttons shall be @ref spacingHint(), whereas the space | 46 | * beteween the buttons shall be @ref spacingHint(), whereas the space |
47 | * above, below, to the right and to the left shall be @ref marginHint(). | 47 | * above, below, to the right and to the left shall be @ref marginHint(). |
48 | * If you add a separator line above the buttons, there shall be a | 48 | * If you add a separator line above the buttons, there shall be a |
49 | * @ref marginHint() between the buttons and the separator and a | 49 | * @ref marginHint() between the buttons and the separator and a |
50 | * @ref marginHint() above the separator as well. | 50 | * @ref marginHint() above the separator as well. |
51 | * | 51 | * |
52 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 52 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
53 | */ | 53 | */ |
54 | // lets fix up Qt instead! Size does matter. -zecke | ||
54 | 55 | ||
55 | class ODialog : public QDialog | 56 | class ODialog : public QDialog |
56 | { | 57 | { |
57 | Q_OBJECT | 58 | Q_OBJECT |
58 | 59 | ||
59 | public: | 60 | public: |
60 | 61 | ||
61 | /** | 62 | /** |
62 | * Constructor. | 63 | * Constructor. |
63 | * | 64 | * |
64 | * Takes the same arguments as @ref QDialog. | 65 | * Takes the same arguments as @ref QDialog. |
65 | */ | 66 | */ |
66 | ODialog(QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags f = 0); | 67 | ODialog(QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags f = 0); |
67 | 68 | ||
68 | /** | 69 | /** |
69 | * Return the number of pixels you shall use between a | 70 | * Return the number of pixels you shall use between a |
70 | * dialog edge and the outermost widget(s) according to the KDE standard. | 71 | * dialog edge and the outermost widget(s) according to the KDE standard. |
71 | **/ | 72 | **/ |
72 | static int marginHint(); | 73 | static int marginHint(); |
73 | 74 | ||
74 | /** | 75 | /** |
75 | * Return the number of pixels you shall use between | 76 | * Return the number of pixels you shall use between |
76 | * widgets inside a dialog according to the KDE standard. | 77 | * widgets inside a dialog according to the KDE standard. |
77 | */ | 78 | */ |
78 | static int spacingHint(); | 79 | static int spacingHint(); |
79 | 80 | ||
80 | private: | 81 | private: |
81 | static int mMarginSize; | 82 | static int mMarginSize; |
82 | static int mSpacingSize; | 83 | static int mSpacingSize; |
83 | 84 | ||
84 | //class ODialogPrivate; | 85 | class ODialogPrivate; |
85 | //ODialogPrivate *d; | 86 | ODialogPrivate *d; // d pointer always needed! -zecke |
86 | 87 | ||
87 | }; | 88 | }; |
88 | #endif // ODIALOG_H | 89 | #endif // ODIALOG_H |
diff --git a/libopie2/opieui/oimageeffect.h b/libopie2/opieui/oimageeffect.h index 313ea50..fb4d22d 100644 --- a/libopie2/opieui/oimageeffect.h +++ b/libopie2/opieui/oimageeffect.h | |||
@@ -1,386 +1,387 @@ | |||
1 | //FIXME: Revise for Opie - do we really need such fancy stuff on PDA's? | 1 | //FIXME: Revise for Opie - do we really need such fancy stuff on PDA's? |
2 | //FIXME: Maybe not on SL5xxx, but surely on C700 :)) | 2 | //FIXME: Maybe not on SL5xxx, but surely on C700 :)) |
3 | //FIXME: I think we don#t need that -zecke | ||
3 | 4 | ||
4 | /* This file is part of the KDE libraries | 5 | /* This file is part of the KDE libraries |
5 | Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@interaccess.com> | 6 | Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@interaccess.com> |
6 | (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> | 7 | (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> |
7 | (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> | 8 | (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> |
8 | 9 | ||
9 | Redistribution and use in source and binary forms, with or without | 10 | Redistribution and use in source and binary forms, with or without |
10 | modification, are permitted provided that the following conditions | 11 | modification, are permitted provided that the following conditions |
11 | are met: | 12 | are met: |
12 | 13 | ||
13 | 1. Redistributions of source code must retain the above copyright | 14 | 1. Redistributions of source code must retain the above copyright |
14 | notice, this list of conditions and the following disclaimer. | 15 | notice, this list of conditions and the following disclaimer. |
15 | 2. Redistributions in binary form must reproduce the above copyright | 16 | 2. Redistributions in binary form must reproduce the above copyright |
16 | notice, this list of conditions and the following disclaimer in the | 17 | notice, this list of conditions and the following disclaimer in the |
17 | documentation and/or other materials provided with the distribution. | 18 | documentation and/or other materials provided with the distribution. |
18 | 19 | ||
19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 20 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 21 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 23 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 24 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 25 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | 30 | ||
30 | */ | 31 | */ |
31 | 32 | ||
32 | // $Id$ | 33 | // $Id$ |
33 | 34 | ||
34 | #ifndef OIMAGEEFFECT_H | 35 | #ifndef OIMAGEEFFECT_H |
35 | #define OIMAGEEFFECT_H | 36 | #define OIMAGEEFFECT_H |
36 | 37 | ||
37 | class QImage; | 38 | class QImage; |
38 | class QSize; | 39 | class QSize; |
39 | class QColor; | 40 | class QColor; |
40 | 41 | ||
41 | /** | 42 | /** |
42 | * This class includes various @ref QImage based graphical effects. | 43 | * This class includes various @ref QImage based graphical effects. |
43 | * | 44 | * |
44 | * Everything is | 45 | * Everything is |
45 | * static, so there is no need to create an instance of this class. You can | 46 | * static, so there is no need to create an instance of this class. You can |
46 | * just call the static methods. They are encapsulated here merely to provide | 47 | * just call the static methods. They are encapsulated here merely to provide |
47 | * a common namespace. | 48 | * a common namespace. |
48 | */ | 49 | */ |
49 | 50 | ||
50 | class OImageEffect | 51 | class OImageEffect |
51 | { | 52 | { |
52 | public: | 53 | public: |
53 | enum GradientType { VerticalGradient, HorizontalGradient, | 54 | enum GradientType { VerticalGradient, HorizontalGradient, |
54 | DiagonalGradient, CrossDiagonalGradient, | 55 | DiagonalGradient, CrossDiagonalGradient, |
55 | PyramidGradient, RectangleGradient, | 56 | PyramidGradient, RectangleGradient, |
56 | PipeCrossGradient, EllipticGradient }; | 57 | PipeCrossGradient, EllipticGradient }; |
57 | enum RGBComponent { Red, Green, Blue, Gray, All }; | 58 | enum RGBComponent { Red, Green, Blue, Gray, All }; |
58 | 59 | ||
59 | enum Lighting {NorthLite, NWLite, WestLite, SWLite, | 60 | enum Lighting {NorthLite, NWLite, WestLite, SWLite, |
60 | SouthLite, SELite, EastLite, NELite}; | 61 | SouthLite, SELite, EastLite, NELite}; |
61 | 62 | ||
62 | enum ModulationType { Intensity, Saturation, HueShift, Contrast }; | 63 | enum ModulationType { Intensity, Saturation, HueShift, Contrast }; |
63 | 64 | ||
64 | enum NoiseType { UniformNoise=0, GaussianNoise, MultiplicativeGaussianNoise, | 65 | enum NoiseType { UniformNoise=0, GaussianNoise, MultiplicativeGaussianNoise, |
65 | ImpulseNoise, LaplacianNoise, PoissonNoise}; | 66 | ImpulseNoise, LaplacianNoise, PoissonNoise}; |
66 | 67 | ||
67 | enum RotateDirection{ Rotate90, Rotate180, Rotate270 }; | 68 | enum RotateDirection{ Rotate90, Rotate180, Rotate270 }; |
68 | 69 | ||
69 | /** | 70 | /** |
70 | * Create a gradient from color a to color b of the specified type. | 71 | * Create a gradient from color a to color b of the specified type. |
71 | * | 72 | * |
72 | * @param size The desired size of the gradient. | 73 | * @param size The desired size of the gradient. |
73 | * @param ca Color a | 74 | * @param ca Color a |
74 | * @param cb Color b | 75 | * @param cb Color b |
75 | * @param type The type of gradient. | 76 | * @param type The type of gradient. |
76 | * @param ncols The number of colors to use when not running on a | 77 | * @param ncols The number of colors to use when not running on a |
77 | * truecolor display. The gradient will be dithered to this number of | 78 | * truecolor display. The gradient will be dithered to this number of |
78 | * colors. Pass 0 to prevent dithering. | 79 | * colors. Pass 0 to prevent dithering. |
79 | */ | 80 | */ |
80 | static QImage gradient(const QSize &size, const QColor &ca, | 81 | static QImage gradient(const QSize &size, const QColor &ca, |
81 | const QColor &cb, GradientType type, int ncols=3); | 82 | const QColor &cb, GradientType type, int ncols=3); |
82 | 83 | ||
83 | /** | 84 | /** |
84 | * Create an unbalanced gradient. | 85 | * Create an unbalanced gradient. |
85 | 86 | ||
86 | * An unbalanced gradient is a gradient where the transition from | 87 | * An unbalanced gradient is a gradient where the transition from |
87 | * color a to color b is not linear, but in this case, exponential. | 88 | * color a to color b is not linear, but in this case, exponential. |
88 | * | 89 | * |
89 | * @param size The desired size of the gradient. | 90 | * @param size The desired size of the gradient. |
90 | * @param ca Color a | 91 | * @param ca Color a |
91 | * @param cb Color b | 92 | * @param cb Color b |
92 | * @param type The type of gradient. | 93 | * @param type The type of gradient. |
93 | * @param xfactor The x decay length. Use a value between -200 and 200. | 94 | * @param xfactor The x decay length. Use a value between -200 and 200. |
94 | * @param yfactor The y decay length. | 95 | * @param yfactor The y decay length. |
95 | * @param ncols The number of colors. See OPixmapEffect:gradient. | 96 | * @param ncols The number of colors. See OPixmapEffect:gradient. |
96 | */ | 97 | */ |
97 | static QImage unbalancedGradient(const QSize &size, const QColor &ca, | 98 | static QImage unbalancedGradient(const QSize &size, const QColor &ca, |
98 | const QColor &cb, GradientType type, int xfactor = 100, | 99 | const QColor &cb, GradientType type, int xfactor = 100, |
99 | int yfactor = 100, int ncols = 3); | 100 | int yfactor = 100, int ncols = 3); |
100 | 101 | ||
101 | /** | 102 | /** |
102 | * Blends a color into the destination image, using an opacity | 103 | * Blends a color into the destination image, using an opacity |
103 | * value for blending one into another. Very fast direct pixel | 104 | * value for blending one into another. Very fast direct pixel |
104 | * manipulation is used. | 105 | * manipulation is used. |
105 | * | 106 | * |
106 | * @author Karol Szwed (gallium@kde.org) | 107 | * @author Karol Szwed (gallium@kde.org) |
107 | * @param clr source color to be blended into the destination image. | 108 | * @param clr source color to be blended into the destination image. |
108 | * @param dst destination image in which the source will be blended into. | 109 | * @param dst destination image in which the source will be blended into. |
109 | * @param opacity opacity (in percent) which determines how much the source | 110 | * @param opacity opacity (in percent) which determines how much the source |
110 | * color will be blended into the destination image. | 111 | * color will be blended into the destination image. |
111 | * @return The destination image (dst) containing the result. | 112 | * @return The destination image (dst) containing the result. |
112 | */ | 113 | */ |
113 | static QImage& blend(const QColor& clr, QImage& dst, float opacity); | 114 | static QImage& blend(const QColor& clr, QImage& dst, float opacity); |
114 | 115 | ||
115 | /** | 116 | /** |
116 | * Blend the src image into the destination image, using an opacity | 117 | * Blend the src image into the destination image, using an opacity |
117 | * value for blending one into another. Very fast direct pixel | 118 | * value for blending one into another. Very fast direct pixel |
118 | * manipulation is used. | 119 | * manipulation is used. |
119 | * | 120 | * |
120 | * @author Karol Szwed (gallium@kde.org) | 121 | * @author Karol Szwed (gallium@kde.org) |
121 | * @param src source image to be blended into the destination image. | 122 | * @param src source image to be blended into the destination image. |
122 | * @param dst destination image in which the source will be blended into. | 123 | * @param dst destination image in which the source will be blended into. |
123 | * @param opacity opacity (in percent) which determines how much the source | 124 | * @param opacity opacity (in percent) which determines how much the source |
124 | * image will be blended into the destination image. | 125 | * image will be blended into the destination image. |
125 | * @return The destination image (dst) containing the result. | 126 | * @return The destination image (dst) containing the result. |
126 | */ | 127 | */ |
127 | static QImage& blend(QImage& src, QImage& dst, float opacity); | 128 | static QImage& blend(QImage& src, QImage& dst, float opacity); |
128 | 129 | ||
129 | /** | 130 | /** |
130 | * Blend the provided image into a background of the indicated color. | 131 | * Blend the provided image into a background of the indicated color. |
131 | * | 132 | * |
132 | * @param initial_intensity this parameter takes values from -1 to 1: | 133 | * @param initial_intensity this parameter takes values from -1 to 1: |
133 | * a) if positive: how much to fade the image in its | 134 | * a) if positive: how much to fade the image in its |
134 | * less affected spot | 135 | * less affected spot |
135 | * b) if negative: roughly indicates how much of the image | 136 | * b) if negative: roughly indicates how much of the image |
136 | * remains unaffected | 137 | * remains unaffected |
137 | * @param bgnd indicates the color of the background to blend in | 138 | * @param bgnd indicates the color of the background to blend in |
138 | * @param eff lets you choose what kind of blending you like | 139 | * @param eff lets you choose what kind of blending you like |
139 | * @param anti_dir blend in the opposite direction (makes no much sense | 140 | * @param anti_dir blend in the opposite direction (makes no much sense |
140 | * with concentric blending effects) | 141 | * with concentric blending effects) |
141 | * @param image must be 32bpp | 142 | * @param image must be 32bpp |
142 | */ | 143 | */ |
143 | static QImage& blend(QImage &image, float initial_intensity, | 144 | static QImage& blend(QImage &image, float initial_intensity, |
144 | const QColor &bgnd, GradientType eff, | 145 | const QColor &bgnd, GradientType eff, |
145 | bool anti_dir=false); | 146 | bool anti_dir=false); |
146 | 147 | ||
147 | /** | 148 | /** |
148 | * Blend an image into another one, using a gradient type | 149 | * Blend an image into another one, using a gradient type |
149 | * for blending from one to another. | 150 | * for blending from one to another. |
150 | * | 151 | * |
151 | * @param image1 source1 and result of blending | 152 | * @param image1 source1 and result of blending |
152 | * @param image2 source2 of blending | 153 | * @param image2 source2 of blending |
153 | * @param gt gradient type for blending between source1 and source2 | 154 | * @param gt gradient type for blending between source1 and source2 |
154 | * @param xf x decay length for unbalanced gradient tpye | 155 | * @param xf x decay length for unbalanced gradient tpye |
155 | * @param yf y decay length for unbalanced gradient tpye | 156 | * @param yf y decay length for unbalanced gradient tpye |
156 | */ | 157 | */ |
157 | static QImage& blend(QImage &image1,QImage &image2, | 158 | static QImage& blend(QImage &image1,QImage &image2, |
158 | GradientType gt, int xf=100, int yf=100); | 159 | GradientType gt, int xf=100, int yf=100); |
159 | 160 | ||
160 | /** | 161 | /** |
161 | * Blend an image into another one, using a color channel of a | 162 | * Blend an image into another one, using a color channel of a |
162 | * third image for the decision of blending from one to another. | 163 | * third image for the decision of blending from one to another. |
163 | * | 164 | * |
164 | * @param image1 Source 1 and result of blending | 165 | * @param image1 Source 1 and result of blending |
165 | * @param image2 Source 2 of blending | 166 | * @param image2 Source 2 of blending |
166 | * @param blendImage If the gray value of of pixel is 0, the result | 167 | * @param blendImage If the gray value of of pixel is 0, the result |
167 | * for this pixel is that of image1; for a gray value | 168 | * for this pixel is that of image1; for a gray value |
168 | * of 1, the pixel of image2 is used; for a value | 169 | * of 1, the pixel of image2 is used; for a value |
169 | * inbetween, a corresponding blending is used. | 170 | * inbetween, a corresponding blending is used. |
170 | * @param channel The RBG channel to use for the blending decision. | 171 | * @param channel The RBG channel to use for the blending decision. |
171 | */ | 172 | */ |
172 | static QImage& blend(QImage &image1, QImage &image2, | 173 | static QImage& blend(QImage &image1, QImage &image2, |
173 | QImage &blendImage, RGBComponent channel); | 174 | QImage &blendImage, RGBComponent channel); |
174 | 175 | ||
175 | /** | 176 | /** |
176 | * Blend an image into another one, using alpha in the expected way. | 177 | * Blend an image into another one, using alpha in the expected way. |
177 | * @author Rik Hemsley (rikkus) <rik@kde.org> | 178 | * @author Rik Hemsley (rikkus) <rik@kde.org> |
178 | */ | 179 | */ |
179 | static bool blend(const QImage & upper, const QImage & lower, QImage & output); | 180 | static bool blend(const QImage & upper, const QImage & lower, QImage & output); |
180 | // Not yet... static bool blend(const QImage & image1, const QImage & image2, QImage & output, const QRect & destRect); | 181 | // Not yet... static bool blend(const QImage & image1, const QImage & image2, QImage & output, const QRect & destRect); |
181 | 182 | ||
182 | /** | 183 | /** |
183 | * Blend an image into another one, using alpha in the expected way and | 184 | * Blend an image into another one, using alpha in the expected way and |
184 | * over coordinates @p x and @p y with respect to the lower image. | 185 | * over coordinates @p x and @p y with respect to the lower image. |
185 | * The output is a QImage which is the @p upper image already blended | 186 | * The output is a QImage which is the @p upper image already blended |
186 | * with the @p lower one, so its size will be (in general) the same than | 187 | * with the @p lower one, so its size will be (in general) the same than |
187 | * @p upper instead of the same size than @p lower like the method above. | 188 | * @p upper instead of the same size than @p lower like the method above. |
188 | * In fact, the size of @p output is like upper's one only when it can be | 189 | * In fact, the size of @p output is like upper's one only when it can be |
189 | * painted on lower, if there has to be some clipping, output's size will | 190 | * painted on lower, if there has to be some clipping, output's size will |
190 | * be the clipped area and x and y will be set to the correct up-left corner | 191 | * be the clipped area and x and y will be set to the correct up-left corner |
191 | * where the clipped rectangle begins. | 192 | * where the clipped rectangle begins. |
192 | */ | 193 | */ |
193 | static bool blend(int &x, int &y, const QImage & upper, const QImage & lower, QImage & output); | 194 | static bool blend(int &x, int &y, const QImage & upper, const QImage & lower, QImage & output); |
194 | /** | 195 | /** |
195 | * Blend an image into another one, using alpha in the expected way and | 196 | * Blend an image into another one, using alpha in the expected way and |
196 | * over coordinates @p x and @p y with respect to the lower image. | 197 | * over coordinates @p x and @p y with respect to the lower image. |
197 | * The output is painted in the own @p lower image. This is an optimization | 198 | * The output is painted in the own @p lower image. This is an optimization |
198 | * of the blend method above provided by convenience. | 199 | * of the blend method above provided by convenience. |
199 | */ | 200 | */ |
200 | static bool blendOnLower(int x, int y, const QImage & upper, const QImage & lower); | 201 | static bool blendOnLower(int x, int y, const QImage & upper, const QImage & lower); |
201 | 202 | ||
202 | /** | 203 | /** |
203 | * Modifies the intensity of a pixmap's RGB channel component. | 204 | * Modifies the intensity of a pixmap's RGB channel component. |
204 | * | 205 | * |
205 | * @author Daniel M. Duley (mosfet) | 206 | * @author Daniel M. Duley (mosfet) |
206 | * @param image The QImage to process. | 207 | * @param image The QImage to process. |
207 | * @param percent Percent value. Use a negative value to dim. | 208 | * @param percent Percent value. Use a negative value to dim. |
208 | * @param channel Which channel(s) should be modified | 209 | * @param channel Which channel(s) should be modified |
209 | * @return The @p image, provided for convenience. | 210 | * @return The @p image, provided for convenience. |
210 | */ | 211 | */ |
211 | static QImage& channelIntensity(QImage &image, float percent, | 212 | static QImage& channelIntensity(QImage &image, float percent, |
212 | RGBComponent channel); | 213 | RGBComponent channel); |
213 | 214 | ||
214 | /** | 215 | /** |
215 | * Fade an image to a certain background color. | 216 | * Fade an image to a certain background color. |
216 | * | 217 | * |
217 | * The number of colors will not be changed. | 218 | * The number of colors will not be changed. |
218 | * | 219 | * |
219 | * @param image The QImage to process. | 220 | * @param image The QImage to process. |
220 | * @param val The strength of the effect. 0 <= val <= 1. | 221 | * @param val The strength of the effect. 0 <= val <= 1. |
221 | * @param color The background color. | 222 | * @param color The background color. |
222 | * @return Returns the @ref image(), provided for convenience. | 223 | * @return Returns the @ref image(), provided for convenience. |
223 | */ | 224 | */ |
224 | static QImage& fade(QImage &img, float val, const QColor &color); | 225 | static QImage& fade(QImage &img, float val, const QColor &color); |
225 | 226 | ||
226 | 227 | ||
227 | /** | 228 | /** |
228 | * This recolors a pixmap. The most dark color will become color a, | 229 | * This recolors a pixmap. The most dark color will become color a, |
229 | * the most bright one color b, and in between. | 230 | * the most bright one color b, and in between. |
230 | * | 231 | * |
231 | * @param image A QImage to process. | 232 | * @param image A QImage to process. |
232 | * @param ca Color a | 233 | * @param ca Color a |
233 | * @param cb Color b | 234 | * @param cb Color b |
234 | */ | 235 | */ |
235 | static QImage& flatten(QImage &image, const QColor &ca, | 236 | static QImage& flatten(QImage &image, const QColor &ca, |
236 | const QColor &cb, int ncols=0); | 237 | const QColor &cb, int ncols=0); |
237 | 238 | ||
238 | /** | 239 | /** |
239 | * Build a hash on any given @ref QImage | 240 | * Build a hash on any given @ref QImage |
240 | * | 241 | * |
241 | * @param image The QImage to process | 242 | * @param image The QImage to process |
242 | * @param lite The hash faces the indicated lighting (cardinal poles). | 243 | * @param lite The hash faces the indicated lighting (cardinal poles). |
243 | * @param spacing How many unmodified pixels inbetween hashes. | 244 | * @param spacing How many unmodified pixels inbetween hashes. |
244 | * @return Returns the @ref image(), provided for convenience. | 245 | * @return Returns the @ref image(), provided for convenience. |
245 | */ | 246 | */ |
246 | static QImage& hash(QImage &image, Lighting lite=NorthLite, | 247 | static QImage& hash(QImage &image, Lighting lite=NorthLite, |
247 | unsigned int spacing=0); | 248 | unsigned int spacing=0); |
248 | 249 | ||
249 | /** | 250 | /** |
250 | * Either brighten or dim the image by a specified percent. | 251 | * Either brighten or dim the image by a specified percent. |
251 | * For example, .50 will modify the colors by 50%. | 252 | * For example, .50 will modify the colors by 50%. |
252 | * | 253 | * |
253 | * @author Daniel M. Duley (mosfet) | 254 | * @author Daniel M. Duley (mosfet) |
254 | * @param image The QImage to process. | 255 | * @param image The QImage to process. |
255 | * @param percent The percent value. Use a negative value to dim. | 256 | * @param percent The percent value. Use a negative value to dim. |
256 | * @return Returns The @ref image(), provided for convenience. | 257 | * @return Returns The @ref image(), provided for convenience. |
257 | */ | 258 | */ |
258 | static QImage& intensity(QImage &image, float percent); | 259 | static QImage& intensity(QImage &image, float percent); |
259 | 260 | ||
260 | /** | 261 | /** |
261 | * Modulate the image with a color channel of another image. | 262 | * Modulate the image with a color channel of another image. |
262 | * | 263 | * |
263 | * @param image The QImage to modulate and result. | 264 | * @param image The QImage to modulate and result. |
264 | * @param modImage The QImage to use for modulation. | 265 | * @param modImage The QImage to use for modulation. |
265 | * @param reverse Invert the meaning of image/modImage; result is image! | 266 | * @param reverse Invert the meaning of image/modImage; result is image! |
266 | * @param type The modulation Type to use. | 267 | * @param type The modulation Type to use. |
267 | * @param factor The modulation amplitude; with 0 no effect [-200;200]. | 268 | * @param factor The modulation amplitude; with 0 no effect [-200;200]. |
268 | * @param channel The RBG channel of image2 to use for modulation. | 269 | * @param channel The RBG channel of image2 to use for modulation. |
269 | * @return Returns the @ref image(), provided for convenience. | 270 | * @return Returns the @ref image(), provided for convenience. |
270 | */ | 271 | */ |
271 | static QImage& modulate(QImage &image, QImage &modImage, bool reverse, | 272 | static QImage& modulate(QImage &image, QImage &modImage, bool reverse, |
272 | ModulationType type, int factor, RGBComponent channel); | 273 | ModulationType type, int factor, RGBComponent channel); |
273 | 274 | ||
274 | /** | 275 | /** |
275 | * Convert an image to grayscale. | 276 | * Convert an image to grayscale. |
276 | * | 277 | * |
277 | * @author Daniel M. Duley (mosfet) | 278 | * @author Daniel M. Duley (mosfet) |
278 | * @param image The @ref QImage to process. | 279 | * @param image The @ref QImage to process. |
279 | * @param fast Set to @p true in order to use a faster but non-photographic | 280 | * @param fast Set to @p true in order to use a faster but non-photographic |
280 | * quality algorithm. Appropriate for things such as toolbar icons. | 281 | * quality algorithm. Appropriate for things such as toolbar icons. |
281 | * @return Returns the @ref image(), provided for convenience. | 282 | * @return Returns the @ref image(), provided for convenience. |
282 | */ | 283 | */ |
283 | static QImage& toGray(QImage &image, bool fast = false); | 284 | static QImage& toGray(QImage &image, bool fast = false); |
284 | 285 | ||
285 | /** | 286 | /** |
286 | * Desaturate an image evenly. | 287 | * Desaturate an image evenly. |
287 | * | 288 | * |
288 | * @param image The QImage to process. | 289 | * @param image The QImage to process. |
289 | * @param desat A value between 0 and 1 setting the degree of desaturation | 290 | * @param desat A value between 0 and 1 setting the degree of desaturation |
290 | * @return Returns the @ref image(), provided for convenience. | 291 | * @return Returns the @ref image(), provided for convenience. |
291 | */ | 292 | */ |
292 | static QImage& desaturate(QImage &image, float desat = 0.3); | 293 | static QImage& desaturate(QImage &image, float desat = 0.3); |
293 | 294 | ||
294 | /** | 295 | /** |
295 | * Fast, but low quality contrast of an image. Also see contrastHSV. | 296 | * Fast, but low quality contrast of an image. Also see contrastHSV. |
296 | * | 297 | * |
297 | * @author Daniel M. Duley (mosfet) | 298 | * @author Daniel M. Duley (mosfet) |
298 | * @param image The QImage to process. | 299 | * @param image The QImage to process. |
299 | * @param c A contrast value between -255 to 255. | 300 | * @param c A contrast value between -255 to 255. |
300 | * @return The @ref image(), provided for convenience. | 301 | * @return The @ref image(), provided for convenience. |
301 | */ | 302 | */ |
302 | static QImage& contrast(QImage &image, int c); | 303 | static QImage& contrast(QImage &image, int c); |
303 | 304 | ||
304 | /** | 305 | /** |
305 | * Dither an image using Floyd-Steinberg dithering for low-color | 306 | * Dither an image using Floyd-Steinberg dithering for low-color |
306 | * situations. | 307 | * situations. |
307 | * | 308 | * |
308 | * @param image The QImage to process. | 309 | * @param image The QImage to process. |
309 | * @param palette The color palette to use | 310 | * @param palette The color palette to use |
310 | * @param size The size of the palette | 311 | * @param size The size of the palette |
311 | * @return Returns the @ref image(), provided for convenience. | 312 | * @return Returns the @ref image(), provided for convenience. |
312 | */ | 313 | */ |
313 | static QImage& dither(QImage &img, const QColor *palette, int size); | 314 | static QImage& dither(QImage &img, const QColor *palette, int size); |
314 | 315 | ||
315 | /** | 316 | /** |
316 | * Calculate the image for a selected image, for instance a selected icon | 317 | * Calculate the image for a selected image, for instance a selected icon |
317 | * on the desktop. | 318 | * on the desktop. |
318 | * @param img the QImage to select | 319 | * @param img the QImage to select |
319 | * @param col the selected color, usually from QColorGroup::highlight(). | 320 | * @param col the selected color, usually from QColorGroup::highlight(). |
320 | */ | 321 | */ |
321 | static QImage& selectedImage( QImage &img, const QColor &col ); | 322 | static QImage& selectedImage( QImage &img, const QColor &col ); |
322 | 323 | ||
323 | /** | 324 | /** |
324 | * High quality, expensive HSV contrast. You can do a faster one by just | 325 | * High quality, expensive HSV contrast. You can do a faster one by just |
325 | * taking a intensity threshold (ie: 128) and incrementing RGB color | 326 | * taking a intensity threshold (ie: 128) and incrementing RGB color |
326 | * channels above it and decrementing those below it, but this gives much | 327 | * channels above it and decrementing those below it, but this gives much |
327 | * better results. | 328 | * better results. |
328 | * | 329 | * |
329 | * @author Daniel M. Duley (mosfet) | 330 | * @author Daniel M. Duley (mosfet) |
330 | * @param img The QImage to process. | 331 | * @param img The QImage to process. |
331 | * @param sharpen If true sharpness is increase, (spiffed). Otherwise | 332 | * @param sharpen If true sharpness is increase, (spiffed). Otherwise |
332 | * it is decreased, (dulled). | 333 | * it is decreased, (dulled). |
333 | */ | 334 | */ |
334 | static void contrastHSV(QImage &img, bool sharpen=true); | 335 | static void contrastHSV(QImage &img, bool sharpen=true); |
335 | 336 | ||
336 | /** | 337 | /** |
337 | * Normalizes the pixel values to span the full range of color values. | 338 | * Normalizes the pixel values to span the full range of color values. |
338 | * This is a contrast enhancement technique. | 339 | * This is a contrast enhancement technique. |
339 | * @author Daniel M. Duley (mosfet) | 340 | * @author Daniel M. Duley (mosfet) |
340 | */ | 341 | */ |
341 | static void normalize(QImage &img); | 342 | static void normalize(QImage &img); |
342 | 343 | ||
343 | /** | 344 | /** |
344 | * Performs histogram equalization on the reference | 345 | * Performs histogram equalization on the reference |
345 | * image. | 346 | * image. |
346 | * @author Daniel M. Duley (mosfet) | 347 | * @author Daniel M. Duley (mosfet) |
347 | */ | 348 | */ |
348 | static void equalize(QImage &img); | 349 | static void equalize(QImage &img); |
349 | 350 | ||
350 | /** | 351 | /** |
351 | * Thresholds the reference image. You can also threshold images by using | 352 | * Thresholds the reference image. You can also threshold images by using |
352 | * ThresholdDither in the various QPixmap/QImage convert methods, but this | 353 | * ThresholdDither in the various QPixmap/QImage convert methods, but this |
353 | * lets you specify a threshold value. | 354 | * lets you specify a threshold value. |
354 | * | 355 | * |
355 | * @author Daniel M. Duley (mosfet) | 356 | * @author Daniel M. Duley (mosfet) |
356 | * @param img The QImage to process. | 357 | * @param img The QImage to process. |
357 | * @param value The threshold value. | 358 | * @param value The threshold value. |
358 | */ | 359 | */ |
359 | static void threshold(QImage &img, unsigned int value=128); | 360 | static void threshold(QImage &img, unsigned int value=128); |
360 | 361 | ||
361 | /** | 362 | /** |
362 | * Produces a 'solarization' effect seen when exposing a photographic | 363 | * Produces a 'solarization' effect seen when exposing a photographic |
363 | * film to light during the development process. | 364 | * film to light during the development process. |
364 | * | 365 | * |
365 | * @author Daniel M. Duley (mosfet) | 366 | * @author Daniel M. Duley (mosfet) |
366 | * @param img The QImage to process. | 367 | * @param img The QImage to process. |
367 | * @param factor The extent of the solarization (0-99.9) | 368 | * @param factor The extent of the solarization (0-99.9) |
368 | */ | 369 | */ |
369 | static void solarize(QImage &img, double factor=50.0); | 370 | static void solarize(QImage &img, double factor=50.0); |
370 | 371 | ||
371 | /** | 372 | /** |
372 | * Embosses the source image. This involves highlighting the edges | 373 | * Embosses the source image. This involves highlighting the edges |
373 | * and applying various other enhancements in order to get a metal | 374 | * and applying various other enhancements in order to get a metal |
374 | * effect. | 375 | * effect. |
375 | * | 376 | * |
376 | * @author Daniel M. Duley (mosfet) | 377 | * @author Daniel M. Duley (mosfet) |
377 | * @param src The QImage to process. | 378 | * @param src The QImage to process. |
378 | * @return The embossed image. The original is not changed. | 379 | * @return The embossed image. The original is not changed. |
379 | */ | 380 | */ |
380 | static QImage emboss(QImage &src); | 381 | static QImage emboss(QImage &src); |
381 | 382 | ||
382 | /** | 383 | /** |
383 | * Minimizes speckle noise in the source image using the 8 hull | 384 | * Minimizes speckle noise in the source image using the 8 hull |
384 | * algorithm. | 385 | * algorithm. |
385 | * | 386 | * |
386 | * @author Daniel M. Duley (mosfet) | 387 | * @author Daniel M. Duley (mosfet) |
diff --git a/libopie2/opieui/olistview.h b/libopie2/opieui/olistview.h index bafc67c..b62e278 100644 --- a/libopie2/opieui/olistview.h +++ b/libopie2/opieui/olistview.h | |||
@@ -1,235 +1,235 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef OLISTVIEW_H | 31 | #ifndef OLISTVIEW_H |
32 | #define OLISTVIEW_H | 32 | #define OLISTVIEW_H |
33 | 33 | ||
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qlistview.h> | 35 | #include <qlistview.h> |
36 | #include <qpen.h> | 36 | #include <qpen.h> |
37 | #include <qdatastream.h> | 37 | #include <qdatastream.h> |
38 | 38 | ||
39 | class OListViewItem; | 39 | class OListViewItem; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * A @ref QListView variant featuring visual and functional enhancements | 42 | * A @ref QListView variant featuring visual and functional enhancements |
43 | * like an alternate background for odd rows, an autostretch mode | 43 | * like an alternate background for odd rows, an autostretch mode |
44 | * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. | 44 | * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. |
45 | * | 45 | * |
46 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 46 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
47 | * @short OListView list/tree widget. | 47 | * @short OListView list/tree widget. |
48 | */ | 48 | */ |
49 | class OListView: public QListView | 49 | class OListView: public QListView |
50 | { | 50 | { |
51 | public: | 51 | public: |
52 | /** | 52 | /** |
53 | * Constructor. | 53 | * Constructor. |
54 | * | 54 | * |
55 | * The parameters @p parent and @p name are handled by | 55 | * The parameters @p parent and @p name are handled by |
56 | * @ref QListView, as usual. | 56 | * @ref QListView, as usual. |
57 | */ | 57 | */ |
58 | OListView ( QWidget *parent = 0, const char *name = 0 ); | 58 | OListView ( QWidget *parent = 0, const char *name = 0 ); |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Destructor. | 61 | * Destructor. |
62 | */ | 62 | */ |
63 | virtual ~OListView(); | 63 | virtual ~OListView(); |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * Let the last column fit exactly all the available width. | 66 | * Let the last column fit exactly all the available width. |
67 | */ | 67 | */ |
68 | void setFullWidth( bool fullWidth ); | 68 | void setFullWidth( bool fullWidth ); |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Returns whether the last column is set to fit the available width. | 71 | * Returns whether the last column is set to fit the available width. |
72 | */ | 72 | */ |
73 | bool fullWidth() const; | 73 | bool fullWidth() const; |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Reimplemented for full width support | 76 | * Reimplemented for full width support |
77 | */ | 77 | */ |
78 | virtual int addColumn( const QString& label, int width = -1 ); | 78 | virtual int addColumn( const QString& label, int width = -1 ); |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * Reimplemented for full width support | 81 | * Reimplemented for full width support |
82 | */ | 82 | */ |
83 | virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); | 83 | virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * Reimplemented for full width support | 86 | * Reimplemented for full width support |
87 | */ | 87 | */ |
88 | virtual void removeColumn(int index); | 88 | virtual void removeColumn(int index); |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * sets the alternate background background color. | 91 | * sets the alternate background background color. |
92 | * This only has an effect if the items are OListViewItems | 92 | * This only has an effect if the items are OListViewItems |
93 | * | 93 | * |
94 | * @param c the color to use for every other item. Set to an invalid | 94 | * @param c the color to use for every other item. Set to an invalid |
95 | * color to disable alternate colors. | 95 | * color to disable alternate colors. |
96 | */ | 96 | */ |
97 | void setAlternateBackground( const QColor &c ); | 97 | void setAlternateBackground( const QColor &c ); |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * sets the column separator pen. | 100 | * sets the column separator pen. |
101 | * | 101 | * |
102 | * @param p the pen used to draw the column separator. | 102 | * @param p the pen used to draw the column separator. |
103 | */ | 103 | */ |
104 | void setColumnSeparator( const QPen &p ); | 104 | void setColumnSeparator( const QPen &p ); |
105 | 105 | ||
106 | /** | 106 | /** |
107 | * @return the alternate background color | 107 | * @return the alternate background color |
108 | */ | 108 | */ |
109 | const QColor& alternateBackground() const; | 109 | const QColor& alternateBackground() const; |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * @return the column separator pen | 112 | * @return the column separator pen |
113 | */ | 113 | */ |
114 | const QPen& columnSeparator() const; | 114 | const QPen& columnSeparator() const; |
115 | 115 | ||
116 | /** | 116 | /** |
117 | * create a list view item as child of this object | 117 | * create a list view item as child of this object |
118 | * @return the new object | 118 | * @return the new object |
119 | */ | 119 | */ |
120 | virtual OListViewItem* childFactory(); | 120 | virtual OListViewItem* childFactory(); |
121 | 121 | ||
122 | #ifndef QT_NO_DATASTREAM | 122 | #ifndef QT_NO_DATASTREAM |
123 | /** | 123 | /** |
124 | * serialize this object to a @ref QDataStream | 124 | * serialize this object to a @ref QDataStream |
125 | * @param s the stream used to serialize this object. | 125 | * @param s the stream used to serialize this object. |
126 | */ | 126 | */ |
127 | virtual void serializeTo( QDataStream& s ) const; | 127 | virtual void serializeTo( QDataStream& s ) const; |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * serialize this object from a @ref QDataStream | 130 | * serialize this object from a @ref QDataStream |
131 | * @param s the stream used to serialize this object. | 131 | * @param s the stream used to serialize this object. |
132 | */ | 132 | */ |
133 | virtual void serializeFrom( QDataStream& s ); | 133 | virtual void serializeFrom( QDataStream& s ); |
134 | #endif | 134 | #endif |
135 | 135 | ||
136 | private: | 136 | private: |
137 | QColor m_alternateBackground; | 137 | QColor m_alternateBackground; |
138 | bool m_fullWidth; | 138 | bool m_fullWidth; |
139 | QPen m_columnSeparator; | 139 | QPen m_columnSeparator; |
140 | }; | 140 | }; |
141 | 141 | ||
142 | #ifndef QT_NO_DATASTREAM | 142 | #ifndef QT_NO_DATASTREAM |
143 | /** | 143 | /** |
144 | * \relates QListView | 144 | * \relates QListView |
145 | * Writes a listview to the stream and returns a reference to the stream. | 145 | * Writes a listview to the stream and returns a reference to the stream. |
146 | */ | 146 | */ |
147 | QDataStream& operator<<( QDataStream& s, const OListView& lv ); | 147 | QDataStream& operator<<( QDataStream& s, const OListView& lv ); |
148 | /** | 148 | /** |
149 | * \relates QListView | 149 | * \relates QListView |
150 | * Reads a listview from the stream and returns a reference to the stream. | 150 | * Reads a listview from the stream and returns a reference to the stream. |
151 | */ | 151 | */ |
152 | QDataStream& operator>>( QDataStream& s, OListView& lv ); | 152 | QDataStream& operator>>( QDataStream& s, OListView& lv ); |
153 | #endif // QT_NO_DATASTREAM | 153 | #endif // QT_NO_DATASTREAM |
154 | 154 | ||
155 | //****************************** OListViewItem ****************************************************************** | 155 | //****************************** OListViewItem ****************************************************************** |
156 | 156 | ||
157 | class OListViewItem: public QListViewItem | 157 | class OListViewItem: public QListViewItem |
158 | { | 158 | { |
159 | public: | 159 | public: |
160 | OListViewItem( QListView * parent ); | 160 | OListViewItem( QListView * parent ); |
161 | OListViewItem( QListViewItem * parent ); | 161 | OListViewItem( QListViewItem * parent ); |
162 | OListViewItem( QListView * parent, QListViewItem * after ); | 162 | OListViewItem( QListView * parent, QListViewItem * after ); |
163 | OListViewItem( QListViewItem * parent, QListViewItem * after ); | 163 | OListViewItem( QListViewItem * parent, QListViewItem * after ); |
164 | 164 | ||
165 | OListViewItem( QListView * parent, | 165 | OListViewItem( QListView * parent, |
166 | QString, QString = QString::null, | 166 | QString, QString = QString::null, |
167 | QString = QString::null, QString = QString::null, | 167 | QString = QString::null, QString = QString::null, |
168 | QString = QString::null, QString = QString::null, | 168 | QString = QString::null, QString = QString::null, |
169 | QString = QString::null, QString = QString::null ); | 169 | QString = QString::null, QString = QString::null ); |
170 | 170 | ||
171 | OListViewItem( QListViewItem * parent, | 171 | OListViewItem( QListViewItem * parent, |
172 | QString, QString = QString::null, | 172 | QString, QString = QString::null, |
173 | QString = QString::null, QString = QString::null, | 173 | QString = QString::null, QString = QString::null, |
174 | QString = QString::null, QString = QString::null, | 174 | QString = QString::null, QString = QString::null, |
175 | QString = QString::null, QString = QString::null ); | 175 | QString = QString::null, QString = QString::null ); |
176 | 176 | ||
177 | OListViewItem( QListView * parent, QListViewItem * after, | 177 | OListViewItem( QListView * parent, QListViewItem * after, |
178 | QString, QString = QString::null, | 178 | QString, QString = QString::null, |
179 | QString = QString::null, QString = QString::null, | 179 | QString = QString::null, QString = QString::null, |
180 | QString = QString::null, QString = QString::null, | 180 | QString = QString::null, QString = QString::null, |
181 | QString = QString::null, QString = QString::null ); | 181 | QString = QString::null, QString = QString::null ); |
182 | 182 | ||
183 | OListViewItem( QListViewItem * parent, QListViewItem * after, | 183 | OListViewItem( QListViewItem * parent, QListViewItem * after, |
184 | QString, QString = QString::null, | 184 | QString, QString = QString::null, |
185 | QString = QString::null, QString = QString::null, | 185 | QString = QString::null, QString = QString::null, |
186 | QString = QString::null, QString = QString::null, | 186 | QString = QString::null, QString = QString::null, |
187 | QString = QString::null, QString = QString::null ); | 187 | QString = QString::null, QString = QString::null ); |
188 | 188 | ||
189 | virtual ~OListViewItem(); | 189 | virtual ~OListViewItem(); |
190 | 190 | ||
191 | const QColor& backgroundColor(); | 191 | const QColor& backgroundColor(); |
192 | bool isAlternate(); | 192 | bool isAlternate(); |
193 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); | 193 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); |
194 | void init(); | 194 | void init(); |
195 | 195 | ||
196 | /** | 196 | /** |
197 | * create a list view item as child of this object | 197 | * create a list view item as child of this object |
198 | * @return the new object | 198 | * @return the new object |
199 | */ | 199 | */ |
200 | virtual OListViewItem* childFactory(); | 200 | virtual OListViewItem* childFactory(); |
201 | 201 | ||
202 | #ifndef QT_NO_DATASTREAM | 202 | #ifndef QT_NO_DATASTREAM |
203 | /** | 203 | /** |
204 | * serialize this object to or from a @ref QDataStream | 204 | * serialize this object to or from a @ref QDataStream |
205 | * @param s the stream used to serialize this object. | 205 | * @param s the stream used to serialize this object. |
206 | */ | 206 | */ |
207 | virtual void serializeTo( QDataStream& s ) const; | 207 | virtual void serializeTo( QDataStream& s ) const; |
208 | 208 | ||
209 | /** | 209 | /** |
210 | * serialize this object to or from a @ref QDataStream | 210 | * serialize this object to or from a @ref QDataStream |
211 | * @param s the stream used to serialize this object. | 211 | * @param s the stream used to serialize this object. |
212 | */ | 212 | */ |
213 | virtual void serializeFrom( QDataStream& s ); | 213 | virtual void serializeFrom( QDataStream& s ); |
214 | #endif | 214 | #endif |
215 | 215 | ||
216 | private: | 216 | private: |
217 | bool m_known; | 217 | bool m_known; |
218 | bool m_odd; | 218 | bool m_odd; |
219 | }; | 219 | }; |
220 | 220 | ||
221 | #ifndef QT_NO_DATASTREAM | 221 | #ifndef QT_NO_DATASTREAM |
222 | /** | 222 | /** |
223 | * \relates QListViewItem | 223 | * \relates QListViewItem |
224 | * Writes a listview item and all subitems recursively to the stream | 224 | * Writes a listview item and all subitems recursively to the stream |
225 | * and returns a reference to the stream. | 225 | * and returns a reference to the stream. |
226 | */ | 226 | */ |
227 | QDataStream& operator<<( QDataStream &s, const OListViewItem& lvi ); | 227 | QDataStream& operator<<( QDataStream &s, const OListViewItem& lvi ); |
228 | /** | 228 | /** |
229 | * \relates QListViewItem | 229 | * \relates QListViewItem |
230 | * Reads a listview item from the stream and returns a reference to the stream. | 230 | * Reads a listview item from the stream and returns a reference to the stream. |
231 | */ | 231 | */ |
232 | QDataStream& operator>>( QDataStream &s, OListViewItem& lvi ); | 232 | QDataStream& operator>>( QDataStream &s, OListViewItem& lvi ); |
233 | #endif // QT_NO_DATASTREAM | 233 | #endif // QT_NO_DATASTREAM |
234 | 234 | ||
235 | #endif // OLISTVIEW_H | 235 | #endif // OLISTVIEW_H |
diff --git a/libopie2/opieui/opopupmenu.h b/libopie2/opieui/opopupmenu.h index 94f05f4..54e4301 100644 --- a/libopie2/opieui/opopupmenu.h +++ b/libopie2/opieui/opopupmenu.h | |||
@@ -1,256 +1,259 @@ | |||
1 | //FIXME what is ODE? ODE Desktop Environemt? -zecke | ||
2 | //FIXME do we need titles? space is limited that is only eyecandy? -zecke | ||
3 | //FIXME keyboard navigation is also not that popular on a PDA might be with a keyboard (tuxphone) -zecke | ||
1 | /* This file is part of the ODE libraries | 4 | /* This file is part of the ODE libraries |
2 | Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> | 5 | Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> |
3 | 6 | ||
4 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
6 | License version 2 as published by the Free Software Foundation. | 9 | License version 2 as published by the Free Software Foundation. |
7 | 10 | ||
8 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 | Library General Public License for more details. | 14 | Library General Public License for more details. |
12 | 15 | ||
13 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
14 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
16 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
17 | */ | 20 | */ |
18 | #ifndef _OPOPUP_H | 21 | #ifndef _OPOPUP_H |
19 | #define _OPOPUP_H | 22 | #define _OPOPUP_H |
20 | 23 | ||
21 | #define INCLUDE_MENUITEM_DEF | 24 | #define INCLUDE_MENUITEM_DEF |
22 | 25 | ||
23 | /* QT */ | 26 | /* QT */ |
24 | 27 | ||
25 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
26 | 29 | ||
27 | /* OPIE */ | 30 | /* OPIE */ |
28 | 31 | ||
29 | #include <opie2/opixmapeffect.h> | 32 | #include <opie2/opixmapeffect.h> |
30 | 33 | ||
31 | /** | 34 | /** |
32 | * Title widget for use in @ref OPopupMenu. | 35 | * Title widget for use in @ref OPopupMenu. |
33 | * | 36 | * |
34 | * You usually don't have to create this manually since | 37 | * You usually don't have to create this manually since |
35 | * @ref OPopupMenu::insertTitle will do it for you, but it is allowed if | 38 | * @ref OPopupMenu::insertTitle will do it for you, but it is allowed if |
36 | * you wish to customize it's look. | 39 | * you wish to customize it's look. |
37 | * | 40 | * |
38 | * @author Daniel M. Duley <mosfet@kde.org> | 41 | * @author Daniel M. Duley <mosfet@kde.org> |
39 | * @short OPopupMenu title widget. | 42 | * @short OPopupMenu title widget. |
40 | */ | 43 | */ |
41 | class OPopupTitle : public QWidget | 44 | class OPopupTitle : public QWidget |
42 | { | 45 | { |
43 | Q_OBJECT | 46 | Q_OBJECT |
44 | 47 | ||
45 | public: | 48 | public: |
46 | /** | 49 | /** |
47 | * Constructs a title widget with the user specified gradient, pixmap, | 50 | * Constructs a title widget with the user specified gradient, pixmap, |
48 | * and colors. | 51 | * and colors. |
49 | */ | 52 | */ |
50 | OPopupTitle(QWidget *parent=0, const char *name=0); | 53 | OPopupTitle(QWidget *parent=0, const char *name=0); |
51 | /** | 54 | /** |
52 | * @deprecated | 55 | * @deprecated |
53 | * Constructs a title widget with the specified gradient and colors. | 56 | * Constructs a title widget with the specified gradient and colors. |
54 | */ | 57 | */ |
55 | OPopupTitle(OPixmapEffect::GradientType gradient, const QColor &color, | 58 | OPopupTitle(OPixmapEffect::GradientType gradient, const QColor &color, |
56 | const QColor &textColor, QWidget *parent=0, | 59 | const QColor &textColor, QWidget *parent=0, |
57 | const char *name=0); | 60 | const char *name=0); |
58 | /** | 61 | /** |
59 | * @deprecated | 62 | * @deprecated |
60 | * Constructs a title widget with the specified pixmap and colors. | 63 | * Constructs a title widget with the specified pixmap and colors. |
61 | */ | 64 | */ |
62 | OPopupTitle(const OPixmap &background, const QColor &color, | 65 | OPopupTitle(const OPixmap &background, const QColor &color, |
63 | const QColor &textColor, QWidget *parent=0, | 66 | const QColor &textColor, QWidget *parent=0, |
64 | const char *name=0); | 67 | const char *name=0); |
65 | /** | 68 | /** |
66 | * Sets the title string and optional icon for the title widget. | 69 | * Sets the title string and optional icon for the title widget. |
67 | * | 70 | * |
68 | * You will want to call this before inserting into a menu. | 71 | * You will want to call this before inserting into a menu. |
69 | */ | 72 | */ |
70 | void setTitle(const QString &text, const QPixmap *icon=NULL); | 73 | void setTitle(const QString &text, const QPixmap *icon=NULL); |
71 | /** | 74 | /** |
72 | * Returns the current title. | 75 | * Returns the current title. |
73 | */ | 76 | */ |
74 | QString title() const { return(titleStr); } | 77 | QString title() const { return(titleStr); } |
75 | /** | 78 | /** |
76 | * Returns the current icon. | 79 | * Returns the current icon. |
77 | */ | 80 | */ |
78 | QPixmap icon() const { return(miniicon); } | 81 | QPixmap icon() const { return(miniicon); } |
79 | 82 | ||
80 | QSize sizeHint() const; | 83 | QSize sizeHint() const; |
81 | 84 | ||
82 | public slots: | 85 | public slots: |
83 | /// @since 3.1 | 86 | /// @since 3.1 |
84 | void setText( const QString &text ); | 87 | void setText( const QString &text ); |
85 | /// @since 3.1 | 88 | /// @since 3.1 |
86 | void setIcon( const QPixmap &pix ); | 89 | void setIcon( const QPixmap &pix ); |
87 | 90 | ||
88 | protected: | 91 | protected: |
89 | void paintEvent(QPaintEvent *ev); | 92 | void paintEvent(QPaintEvent *ev); |
90 | 93 | ||
91 | QString titleStr; | 94 | QString titleStr; |
92 | QPixmap miniicon; | 95 | QPixmap miniicon; |
93 | 96 | ||
94 | // Remove in KDE4 | 97 | // Remove in KDE4 |
95 | OPixmapEffect::GradientType grType; | 98 | OPixmapEffect::GradientType grType; |
96 | QPixmap fill; | 99 | QPixmap fill; |
97 | QColor fgColor, bgColor, grHigh, grLow; | 100 | QColor fgColor, bgColor, grHigh, grLow; |
98 | bool useGradient; | 101 | bool useGradient; |
99 | 102 | ||
100 | protected: | 103 | protected: |
101 | virtual void virtual_hook( int id, void* data ); | 104 | virtual void virtual_hook( int id, void* data ); |
102 | private: | 105 | private: |
103 | class OPopupTitlePrivate; | 106 | class OPopupTitlePrivate; |
104 | OPopupTitlePrivate *d; | 107 | OPopupTitlePrivate *d; |
105 | }; | 108 | }; |
106 | 109 | ||
107 | /** | 110 | /** |
108 | * OPopupMenu is a class for menus with standard title items and keyboard | 111 | * OPopupMenu is a class for menus with standard title items and keyboard |
109 | * accessibility for popups with many options and/or varying options. It acts | 112 | * accessibility for popups with many options and/or varying options. It acts |
110 | * identically to QPopupMenu, with the addition of insertTitle(), | 113 | * identically to QPopupMenu, with the addition of insertTitle(), |
111 | * changeTitle(), setKeyboardShortcutsEnabled() and | 114 | * changeTitle(), setKeyboardShortcutsEnabled() and |
112 | * setKeyboardShortcutsExecute() methods. | 115 | * setKeyboardShortcutsExecute() methods. |
113 | * | 116 | * |
114 | * The titles support a text string, an icon, plus user defined gradients, | 117 | * The titles support a text string, an icon, plus user defined gradients, |
115 | * colors, and background pixmaps. | 118 | * colors, and background pixmaps. |
116 | * | 119 | * |
117 | * The keyboard search algorithm is incremental with additional underlining | 120 | * The keyboard search algorithm is incremental with additional underlining |
118 | * for user feedback. | 121 | * for user feedback. |
119 | * | 122 | * |
120 | * @short A menu with title items. | 123 | * @short A menu with title items. |
121 | * @author Daniel M. Duley <mosfet@kde.org> | 124 | * @author Daniel M. Duley <mosfet@kde.org> |
122 | * @author Hamish Rodda <meddie@yoyo.its.monash.edu.au> | 125 | * @author Hamish Rodda <meddie@yoyo.its.monash.edu.au> |
123 | */ | 126 | */ |
124 | class OPopupMenu : public QPopupMenu { | 127 | class OPopupMenu : public QPopupMenu { |
125 | Q_OBJECT | 128 | Q_OBJECT |
126 | public: | 129 | public: |
127 | /** | 130 | /** |
128 | * Constructs a OPopupMenu. | 131 | * Constructs a OPopupMenu. |
129 | */ | 132 | */ |
130 | OPopupMenu(QWidget *parent=0, const char *name=0); | 133 | OPopupMenu(QWidget *parent=0, const char *name=0); |
131 | 134 | ||
132 | /** | 135 | /** |
133 | * Destructs the object | 136 | * Destructs the object |
134 | */ | 137 | */ |
135 | ~OPopupMenu(); | 138 | ~OPopupMenu(); |
136 | 139 | ||
137 | /** | 140 | /** |
138 | * Inserts a title item with no icon. | 141 | * Inserts a title item with no icon. |
139 | */ | 142 | */ |
140 | int insertTitle(const QString &text, int id=-1, int index=-1); | 143 | int insertTitle(const QString &text, int id=-1, int index=-1); |
141 | /** | 144 | /** |
142 | * Inserts a title item with the given icon and title. | 145 | * Inserts a title item with the given icon and title. |
143 | */ | 146 | */ |
144 | int insertTitle(const QPixmap &icon, const QString &text, int id=-1, | 147 | int insertTitle(const QPixmap &icon, const QString &text, int id=-1, |
145 | int index=-1); | 148 | int index=-1); |
146 | /** | 149 | /** |
147 | * Changes the title of the item at the specified id. If a icon was | 150 | * Changes the title of the item at the specified id. If a icon was |
148 | * previously set it is cleared. | 151 | * previously set it is cleared. |
149 | */ | 152 | */ |
150 | void changeTitle(int id, const QString &text); | 153 | void changeTitle(int id, const QString &text); |
151 | /** | 154 | /** |
152 | * Changes the title and icon of the title item at the specified id. | 155 | * Changes the title and icon of the title item at the specified id. |
153 | */ | 156 | */ |
154 | void changeTitle(int id, const QPixmap &icon, const QString &text); | 157 | void changeTitle(int id, const QPixmap &icon, const QString &text); |
155 | /** | 158 | /** |
156 | * Returns the title of the title item at the specified id. The default | 159 | * Returns the title of the title item at the specified id. The default |
157 | * id of -1 is for backwards compatibility only, you should always specify | 160 | * id of -1 is for backwards compatibility only, you should always specify |
158 | * the id. | 161 | * the id. |
159 | */ | 162 | */ |
160 | QString title(int id=-1) const; | 163 | QString title(int id=-1) const; |
161 | /** | 164 | /** |
162 | * Returns the icon of the title item at the specified id. | 165 | * Returns the icon of the title item at the specified id. |
163 | */ | 166 | */ |
164 | QPixmap titlePixmap(int id) const; | 167 | QPixmap titlePixmap(int id) const; |
165 | 168 | ||
166 | /** | 169 | /** |
167 | * Enables keyboard navigation by searching for the entered key sequence. | 170 | * Enables keyboard navigation by searching for the entered key sequence. |
168 | * Also underlines the currently selected item, providing feedback on the search. | 171 | * Also underlines the currently selected item, providing feedback on the search. |
169 | * | 172 | * |
170 | * Defaults to off. | 173 | * Defaults to off. |
171 | * | 174 | * |
172 | * WARNING: calls to text() of currently keyboard-selected items will | 175 | * WARNING: calls to text() of currently keyboard-selected items will |
173 | * contain additional ampersand characters. | 176 | * contain additional ampersand characters. |
174 | * | 177 | * |
175 | * WARNING: though pre-existing keyboard shortcuts will not interfere with the | 178 | * WARNING: though pre-existing keyboard shortcuts will not interfere with the |
176 | * operation of this feature, they may be confusing to the user as the existing | 179 | * operation of this feature, they may be confusing to the user as the existing |
177 | * shortcuts will not work. | 180 | * shortcuts will not work. |
178 | * @since 3.1 | 181 | * @since 3.1 |
179 | */ | 182 | */ |
180 | void setKeyboardShortcutsEnabled(bool enable); | 183 | void setKeyboardShortcutsEnabled(bool enable); |
181 | 184 | ||
182 | /** | 185 | /** |
183 | * Enables execution of the menu item once it is uniquely specified. | 186 | * Enables execution of the menu item once it is uniquely specified. |
184 | * Defaults to off. | 187 | * Defaults to off. |
185 | * @since 3.1 | 188 | * @since 3.1 |
186 | */ | 189 | */ |
187 | void setKeyboardShortcutsExecute(bool enable); | 190 | void setKeyboardShortcutsExecute(bool enable); |
188 | 191 | ||
189 | /** | 192 | /** |
190 | * Obsolete method provided for backwards compatibility only. Use the | 193 | * Obsolete method provided for backwards compatibility only. Use the |
191 | * normal constructor and insertTitle instead. | 194 | * normal constructor and insertTitle instead. |
192 | */ | 195 | */ |
193 | OPopupMenu(const QString &title, QWidget *parent=0, const char *name=0); | 196 | OPopupMenu(const QString &title, QWidget *parent=0, const char *name=0); |
194 | /** | 197 | /** |
195 | * Obsolete method provided for backwards compatibility only. Use | 198 | * Obsolete method provided for backwards compatibility only. Use |
196 | * insertTitle and changeTitle instead. | 199 | * insertTitle and changeTitle instead. |
197 | */ | 200 | */ |
198 | void setTitle(const QString &title); | 201 | void setTitle(const QString &title); |
199 | 202 | ||
200 | /** | 203 | /** |
201 | * Returns the context menu associated with this menu | 204 | * Returns the context menu associated with this menu |
202 | * @since 3.2 | 205 | * @since 3.2 |
203 | */ | 206 | */ |
204 | QPopupMenu* contextMenu(); | 207 | QPopupMenu* contextMenu(); |
205 | 208 | ||
206 | /** | 209 | /** |
207 | * Hides the context menu if shown | 210 | * Hides the context menu if shown |
208 | * @since 3.2 | 211 | * @since 3.2 |
209 | */ | 212 | */ |
210 | void cancelContextMenuShow(); | 213 | void cancelContextMenuShow(); |
211 | 214 | ||
212 | /** | 215 | /** |
213 | * Returns the OPopupMenu associated with the current context menu | 216 | * Returns the OPopupMenu associated with the current context menu |
214 | * @since 3.2 | 217 | * @since 3.2 |
215 | */ | 218 | */ |
216 | static OPopupMenu* contextMenuFocus(); | 219 | static OPopupMenu* contextMenuFocus(); |
217 | 220 | ||
218 | /** | 221 | /** |
219 | * returns the ID of the menuitem associated with the current context menu | 222 | * returns the ID of the menuitem associated with the current context menu |
220 | * @since 3.2 | 223 | * @since 3.2 |
221 | */ | 224 | */ |
222 | static int contextMenuFocusItem(); | 225 | static int contextMenuFocusItem(); |
223 | 226 | ||
224 | signals: | 227 | signals: |
225 | /** | 228 | /** |
226 | * connect to this signal to be notified when a context menu is about to be shown | 229 | * connect to this signal to be notified when a context menu is about to be shown |
227 | * @param menu The menu that the context menu is about to be shown for | 230 | * @param menu The menu that the context menu is about to be shown for |
228 | * @param menuItem The menu item that the context menu is currently on | 231 | * @param menuItem The menu item that the context menu is currently on |
229 | * @param ctxMenu The context menu itself | 232 | * @param ctxMenu The context menu itself |
230 | * @since 3.2 | 233 | * @since 3.2 |
231 | */ | 234 | */ |
232 | void aboutToShowContextMenu(OPopupMenu* menu, int menuItem, QPopupMenu* ctxMenu); | 235 | void aboutToShowContextMenu(OPopupMenu* menu, int menuItem, QPopupMenu* ctxMenu); |
233 | 236 | ||
234 | protected: | 237 | protected: |
235 | virtual void closeEvent(QCloseEvent *); | 238 | virtual void closeEvent(QCloseEvent *); |
236 | virtual void keyPressEvent(QKeyEvent* e); | 239 | virtual void keyPressEvent(QKeyEvent* e); |
237 | virtual bool eventFilter(QObject* obj, QEvent* event); | 240 | virtual bool eventFilter(QObject* obj, QEvent* event); |
238 | virtual void hideEvent(QHideEvent*); | 241 | virtual void hideEvent(QHideEvent*); |
239 | 242 | ||
240 | virtual void virtual_hook( int id, void* data ); | 243 | virtual void virtual_hook( int id, void* data ); |
241 | 244 | ||
242 | protected slots: | 245 | protected slots: |
243 | /// @since 3.1 | 246 | /// @since 3.1 |
244 | QString underlineText(const QString& text, uint length); | 247 | QString underlineText(const QString& text, uint length); |
245 | /// @since 3.1 | 248 | /// @since 3.1 |
246 | void resetKeyboardVars(bool noMatches = false); | 249 | void resetKeyboardVars(bool noMatches = false); |
247 | void itemHighlighted(int whichItem); | 250 | void itemHighlighted(int whichItem); |
248 | void showCtxMenu(QPoint pos); | 251 | void showCtxMenu(QPoint pos); |
249 | void ctxMenuHiding(); | 252 | void ctxMenuHiding(); |
250 | 253 | ||
251 | private: | 254 | private: |
252 | class OPopupMenuPrivate; | 255 | class OPopupMenuPrivate; |
253 | OPopupMenuPrivate *d; | 256 | OPopupMenuPrivate *d; |
254 | }; | 257 | }; |
255 | 258 | ||
256 | #endif | 259 | #endif |
diff --git a/libopie2/qt3/opiecore/opair.h b/libopie2/qt3/opiecore/opair.h index 26f617d..a151127 100644 --- a/libopie2/qt3/opiecore/opair.h +++ b/libopie2/qt3/opiecore/opair.h | |||
@@ -1,99 +1,100 @@ | |||
1 | // QPair minus QT_INLINE_TEMPLATE (instead directly using 'inline' directive) | 1 | // QPair minus QT_INLINE_TEMPLATE (instead directly using 'inline' directive) |
2 | //FIXME: remove and use qpair.h as soon as we're on Qt3 | 2 | //FIXME: remove and use qpair.h as soon as we're on Qt3 |
3 | // name file qpair -zecke | ||
3 | 4 | ||
4 | /**************************************************************************** | 5 | /**************************************************************************** |
5 | ** | 6 | ** |
6 | ** Definition of QPair class | 7 | ** Definition of QPair class |
7 | ** | 8 | ** |
8 | ** | 9 | ** |
9 | ** Copyright (C) 1992-2001 Trolltech AS. All rights reserved. | 10 | ** Copyright (C) 1992-2001 Trolltech AS. All rights reserved. |
10 | ** | 11 | ** |
11 | ** This file is part of the tools module of the Qt GUI Toolkit. | 12 | ** This file is part of the tools module of the Qt GUI Toolkit. |
12 | ** | 13 | ** |
13 | ** This file may be distributed under the terms of the Q Public License | 14 | ** This file may be distributed under the terms of the Q Public License |
14 | ** as defined by Trolltech AS of Norway and appearing in the file | 15 | ** as defined by Trolltech AS of Norway and appearing in the file |
15 | ** LICENSE.QPL included in the packaging of this file. | 16 | ** LICENSE.QPL included in the packaging of this file. |
16 | ** | 17 | ** |
17 | ** This file may be distributed and/or modified under the terms of the | 18 | ** This file may be distributed and/or modified under the terms of the |
18 | ** GNU General Public License version 2 as published by the Free Software | 19 | ** GNU General Public License version 2 as published by the Free Software |
19 | ** Foundation and appearing in the file LICENSE.GPL included in the | 20 | ** Foundation and appearing in the file LICENSE.GPL included in the |
20 | ** packaging of this file. | 21 | ** packaging of this file. |
21 | ** | 22 | ** |
22 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 23 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition |
23 | ** licenses may use this file in accordance with the Qt Commercial License | 24 | ** licenses may use this file in accordance with the Qt Commercial License |
24 | ** Agreement provided with the Software. | 25 | ** Agreement provided with the Software. |
25 | ** | 26 | ** |
26 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 27 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
27 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 28 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
28 | ** | 29 | ** |
29 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 30 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
30 | ** information about Qt Commercial License Agreements. | 31 | ** information about Qt Commercial License Agreements. |
31 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 32 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
32 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 33 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
33 | ** | 34 | ** |
34 | ** Contact info@trolltech.com if any conditions of this licensing are | 35 | ** Contact info@trolltech.com if any conditions of this licensing are |
35 | ** not clear to you. | 36 | ** not clear to you. |
36 | ** | 37 | ** |
37 | **********************************************************************/ | 38 | **********************************************************************/ |
38 | 39 | ||
39 | #ifndef QPAIR_H | 40 | #ifndef QPAIR_H |
40 | #define QPAIR_H | 41 | #define QPAIR_H |
41 | 42 | ||
42 | #ifndef QT_H | 43 | #ifndef QT_H |
43 | #include "qglobal.h" | 44 | #include "qglobal.h" |
44 | #include "qdatastream.h" | 45 | #include "qdatastream.h" |
45 | #endif // QT_H | 46 | #endif // QT_H |
46 | 47 | ||
47 | template <class T1, class T2> | 48 | template <class T1, class T2> |
48 | struct QPair | 49 | struct QPair |
49 | { | 50 | { |
50 | typedef T1 first_type; | 51 | typedef T1 first_type; |
51 | typedef T2 second_type; | 52 | typedef T2 second_type; |
52 | 53 | ||
53 | QPair() | 54 | QPair() |
54 | : first( T1() ), second( T2() ) | 55 | : first( T1() ), second( T2() ) |
55 | {} | 56 | {} |
56 | QPair( const T1& t1, const T2& t2 ) | 57 | QPair( const T1& t1, const T2& t2 ) |
57 | : first( t1 ), second( t2 ) | 58 | : first( t1 ), second( t2 ) |
58 | {} | 59 | {} |
59 | 60 | ||
60 | T1 first; | 61 | T1 first; |
61 | T2 second; | 62 | T2 second; |
62 | }; | 63 | }; |
63 | 64 | ||
64 | template <class T1, class T2> | 65 | template <class T1, class T2> |
65 | inline bool operator==( const QPair<T1, T2>& x, const QPair<T1, T2>& y ) | 66 | inline bool operator==( const QPair<T1, T2>& x, const QPair<T1, T2>& y ) |
66 | { | 67 | { |
67 | return x.first == y.first && x.second == y.second; | 68 | return x.first == y.first && x.second == y.second; |
68 | } | 69 | } |
69 | 70 | ||
70 | template <class T1, class T2> | 71 | template <class T1, class T2> |
71 | inline bool operator<( const QPair<T1, T2>& x, const QPair<T1, T2>& y ) | 72 | inline bool operator<( const QPair<T1, T2>& x, const QPair<T1, T2>& y ) |
72 | { | 73 | { |
73 | return x.first < y.first || | 74 | return x.first < y.first || |
74 | ( !( y.first < x.first ) && x.second < y.second ); | 75 | ( !( y.first < x.first ) && x.second < y.second ); |
75 | } | 76 | } |
76 | 77 | ||
77 | template <class T1, class T2> | 78 | template <class T1, class T2> |
78 | inline QPair<T1, T2> qMakePair( const T1& x, const T2& y ) | 79 | inline QPair<T1, T2> qMakePair( const T1& x, const T2& y ) |
79 | { | 80 | { |
80 | return QPair<T1, T2>( x, y ); | 81 | return QPair<T1, T2>( x, y ); |
81 | } | 82 | } |
82 | 83 | ||
83 | #ifndef QT_NO_DATASTREAM | 84 | #ifndef QT_NO_DATASTREAM |
84 | template <class T1, class T2> | 85 | template <class T1, class T2> |
85 | inline QDataStream& operator>>( QDataStream& s, QPair<T1, T2>& p ) | 86 | inline QDataStream& operator>>( QDataStream& s, QPair<T1, T2>& p ) |
86 | { | 87 | { |
87 | s >> p.first >> p.second; | 88 | s >> p.first >> p.second; |
88 | return s; | 89 | return s; |
89 | } | 90 | } |
90 | 91 | ||
91 | template <class T1, class T2> | 92 | template <class T1, class T2> |
92 | inline QDataStream& operator<<( QDataStream& s, const QPair<T1, T2>& p ) | 93 | inline QDataStream& operator<<( QDataStream& s, const QPair<T1, T2>& p ) |
93 | { | 94 | { |
94 | s << p.first << p.second; | 95 | s << p.first << p.second; |
95 | return s; | 96 | return s; |
96 | } | 97 | } |
97 | #endif | 98 | #endif |
98 | 99 | ||
99 | #endif | 100 | #endif |