summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-05-19 11:59:32 (UTC)
committer mickeyl <mickeyl>2005-05-19 11:59:32 (UTC)
commited7ba8b228d3d0ffae9c9b68900b7f723d7ade4a (patch) (unidiff)
tree83b59755f58747cdb7e543a4c237e9e217b03fbd
parentcb243f00d12c5fc40de02e7f9f20009b52303a66 (diff)
downloadopie-ed7ba8b228d3d0ffae9c9b68900b7f723d7ade4a.zip
opie-ed7ba8b228d3d0ffae9c9b68900b7f723d7ade4a.tar.gz
opie-ed7ba8b228d3d0ffae9c9b68900b7f723d7ade4a.tar.bz2
- add linux pcmcia subsystem wrapper: OPcmciaSystem and OPcmciaCard
- move linux-only subsystems in subdirectory linux - minor header cleanups
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/linux/.cvsignore6
-rw-r--r--libopie2/opiecore/linux/linux.pro10
-rw-r--r--libopie2/opiecore/linux/ofilenotify.cpp (renamed from libopie2/opiecore/ofilenotify.cpp)0
-rw-r--r--libopie2/opiecore/linux/ofilenotify.h (renamed from libopie2/opiecore/ofilenotify.h)0
-rw-r--r--libopie2/opiecore/linux/oinputsystem.cpp (renamed from libopie2/opiecore/oinputsystem.cpp)4
-rw-r--r--libopie2/opiecore/linux/oinputsystem.h (renamed from libopie2/opiecore/oinputsystem.h)10
-rw-r--r--libopie2/opiecore/linux/oinputsystemenums.h405
-rw-r--r--libopie2/opiecore/linux/opcmciasystem.cpp142
-rw-r--r--libopie2/opiecore/linux/opcmciasystem.h129
-rw-r--r--libopie2/opiecore/opiecore.pro16
-rw-r--r--libopie2/opiemm/osoundsystem.cpp12
-rw-r--r--libopie2/opiemm/osoundsystem.h13
-rw-r--r--libopie2/opienet/opcap.cpp2
-rw-r--r--libopie2/opienet/opcap.h1
14 files changed, 718 insertions, 32 deletions
diff --git a/libopie2/opiecore/linux/.cvsignore b/libopie2/opiecore/linux/.cvsignore
new file mode 100644
index 0000000..972e959
--- a/dev/null
+++ b/libopie2/opiecore/linux/.cvsignore
@@ -0,0 +1,6 @@
1Makefile*
2moc*
3*moc
4*.o
5~*
6obj
diff --git a/libopie2/opiecore/linux/linux.pro b/libopie2/opiecore/linux/linux.pro
new file mode 100644
index 0000000..c396e59
--- a/dev/null
+++ b/libopie2/opiecore/linux/linux.pro
@@ -0,0 +1,10 @@
1HEADERS += \
2 linux/ofilenotify.h \
3 linux/oinputsystem.h \
4 linux/opcmciasystem.h
5
6SOURCES += \
7 linux/ofilenotify.cpp \
8 linux/oinputsystem.cpp \
9 linux/opcmciasystem.cpp
10
diff --git a/libopie2/opiecore/ofilenotify.cpp b/libopie2/opiecore/linux/ofilenotify.cpp
index 36ec6bf..36ec6bf 100644
--- a/libopie2/opiecore/ofilenotify.cpp
+++ b/libopie2/opiecore/linux/ofilenotify.cpp
diff --git a/libopie2/opiecore/ofilenotify.h b/libopie2/opiecore/linux/ofilenotify.h
index 05343b9..05343b9 100644
--- a/libopie2/opiecore/ofilenotify.h
+++ b/libopie2/opiecore/linux/ofilenotify.h
diff --git a/libopie2/opiecore/oinputsystem.cpp b/libopie2/opiecore/linux/oinputsystem.cpp
index 7397814..bad27ed 100644
--- a/libopie2/opiecore/oinputsystem.cpp
+++ b/libopie2/opiecore/linux/oinputsystem.cpp
@@ -1,107 +1,107 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11     ._= =}       : or (at your option) any later version. 11     ._= =}       :
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27*/ 27*/
28 28
29#include "oinputsystem.h" 29#include "oinputsystem.h"
30using namespace Opie::Core; 30using namespace Opie::Core;
31 31
32/* QT */ 32/* QT */
33#include <qdir.h> 33#include <qdir.h>
34#include <qfile.h> 34#include <qfile.h>
35 35
36/* STD */ 36/* STD */
37#include <errno.h> 37#include <errno.h>
38#include <string.h> 38#include <string.h>
39#include <sys/fcntl.h> 39#include <sys/fcntl.h>
40#include <sys/ioctl.h> 40#include <sys/ioctl.h>
41#include <unistd.h> 41#include <unistd.h>
42 42
43#define BUFSIZE 256 43#define BUFSIZE 256
44#define BIT_MASK( name, numbits ) \ 44#define BIT_MASK( name, numbits ) \
45 unsigned short name[ ((numbits) - 1) / (sizeof( short ) * 8) + 1 ]; \ 45 unsigned short name[ ((numbits) - 1) / (sizeof( short ) * 8) + 1 ]; \
46 memset( name, 0, sizeof( name ) ) 46 memset( name, 0, sizeof( name ) )
47#define BIT_TEST( bitmask, bit ) \ 47#define BIT_TEST( bitmask, bit ) \
48 ( bitmask[ (bit) / sizeof(short) / 8 ] & (1u << ( (bit) % (sizeof(short) * 8))) ) 48 ( bitmask[ (bit) / sizeof(short) / 8 ] & (1u << ( (bit) % (sizeof(short) * 8))) )
49 49
50/*====================================================================================== 50/*======================================================================================
51 * OInputSystem 51 * OInputSystem
52 *======================================================================================*/ 52 *======================================================================================*/
53 53
54OInputSystem* OInputSystem::_instance = 0; 54OInputSystem* OInputSystem::_instance = 0;
55 55
56OInputSystem::OInputSystem() : QObject() 56OInputSystem::OInputSystem() : QObject()
57{ 57{
58 qDebug( "OInputSystem::OInputSystem()" ); 58 qDebug( "OInputSystem::OInputSystem()" );
59 synchronize(); 59 synchronize();
60} 60}
61 61
62 62
63void OInputSystem::synchronize() 63void OInputSystem::synchronize()
64{ 64{
65 qDebug( "OInputSystem::synchronize()" ); 65 qDebug( "OInputSystem::synchronize()" );
66 QDir devInput( "/dev/input/" ); 66 QDir devInput( "/dev/input/" );
67 if ( devInput.exists() ) 67 if ( devInput.exists() )
68 { 68 {
69 QStringList devInputFiles = devInput.entryList( QDir::System, QDir::Name ); 69 QStringList devInputFiles = devInput.entryList( QDir::System, QDir::Name );
70 for ( QStringList::Iterator it = devInputFiles.begin(); it != devInputFiles.end(); ++it ) 70 for ( QStringList::Iterator it = devInputFiles.begin(); it != devInputFiles.end(); ++it )
71 { 71 {
72 QString absPath = devInput.absFilePath( *it ); 72 QString absPath = devInput.absFilePath( *it );
73 bool isValid = OInputDevice::isValid( absPath ); 73 bool isValid = OInputDevice::isValid( absPath );
74 qDebug( "OInputSystem::synchronize() - checking if '%s' is a valid input system node... '%s' [%s]", 74 qDebug( "OInputSystem::synchronize() - checking if '%s' is a valid input system node... '%s' [%s]",
75 (const char*) absPath, isValid ? "yes" : "no", isValid ? "(ok)" : strerror( errno ) ); 75 (const char*) absPath, isValid ? "yes" : "no", isValid ? "(ok)" : strerror( errno ) );
76 if ( isValid ) _devices.insert( *it, new OInputDevice( this, absPath ) ); 76 if ( isValid ) _devices.insert( *it, new OInputDevice( this, absPath ) );
77 } 77 }
78 } 78 }
79 qDebug( "OInputSystem::synchronize() done" ); 79 qDebug( "OInputSystem::synchronize() done" );
80 if ( !_devices.count() ) 80 if ( !_devices.count() )
81 qWarning( "OInputSystem::no devices found" ); 81 qWarning( "OInputSystem::no devices found" );
82} 82}
83 83
84 84
85OInputSystem::~OInputSystem() 85OInputSystem::~OInputSystem()
86{ 86{
87 qDebug( "OInputSystem::~OInputSystem()" ); 87 qDebug( "OInputSystem::~OInputSystem()" );
88} 88}
89 89
90 90
91int OInputSystem::count() const 91int OInputSystem::count() const
92{ 92{
93 return _devices.count(); 93 return _devices.count();
94} 94}
95 95
96 96
97OInputDevice* OInputSystem::device( const QString& device ) const 97OInputDevice* OInputSystem::device( const QString& device ) const
98{ 98{
99 return _devices[device]; 99 return _devices[device];
100} 100}
101 101
102 102
103OInputSystem* OInputSystem::instance() 103OInputSystem* OInputSystem::instance()
104{ 104{
105 if ( !_instance ) _instance = new OInputSystem(); 105 if ( !_instance ) _instance = new OInputSystem();
106 return _instance; 106 return _instance;
107} 107}
diff --git a/libopie2/opiecore/oinputsystem.h b/libopie2/opiecore/linux/oinputsystem.h
index 6f822a1..9676e73 100644
--- a/libopie2/opiecore/oinputsystem.h
+++ b/libopie2/opiecore/linux/oinputsystem.h
@@ -1,142 +1,142 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11     ._= =}       : or (at your option) any later version. 11     ._= =}       :
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27*/ 27*/
28 28
29#ifndef OINPUTSYSTEM_H 29#ifndef OINPUTSYSTEM_H
30#define OINPUTSYSTEM_H 30#define OINPUTSYSTEM_H
31 31
32#include "linux_input.h" 32#include "linux_input.h"
33 33
34/* QT */ 34/* QT */
35#include <qobject.h> 35#include <qobject.h>
36#include <qdict.h> 36#include <qdict.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40 40
41class OInputDevice; 41class OInputDevice;
42 42
43/** 43/**
44 * @brief A container class for all input devices 44 * @brief A container class for the Linux input device subsystem
45 * 45 *
46 * This class provides access to all available input system devices of your computer. 46 * This class provides access to all available input system devices of your device.
47 * 47 *
48 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 48 * @author Michael 'Mickey' Lauer <mickey@Vanille.de>
49 */ 49 */
50class OInputSystem : public QObject 50class OInputSystem : public QObject
51{ 51{
52 public: 52 public:
53 typedef QDict<OInputDevice> DeviceMap; 53 typedef QDict<OInputDevice> DeviceMap;
54 typedef QDictIterator<OInputDevice> DeviceIterator; 54 typedef QDictIterator<OInputDevice> DeviceIterator;
55 55
56 /** 56 /**
57 * @returns the number of available input devices 57 * @returns the number of available input devices
58 */ 58 */
59 int count() const; 59 int count() const;
60 /** 60 /**
61 * @returns a pointer to the (one and only) @ref OInputSystem instance. 61 * @returns a pointer to the (one and only) @ref OInputSystem instance.
62 */ 62 */
63 static OInputSystem* instance(); 63 static OInputSystem* instance();
64 /** 64 /**
65 * @returns an iterator usable for iterating through all network interfaces. 65 * @returns an iterator usable for iterating through all network interfaces.
66 */ 66 */
67 DeviceIterator iterator() const; 67 DeviceIterator iterator() const;
68 /** 68 /**
69 * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found 69 * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found
70 * @see OAudioInterface 70 * @see OAudioInterface
71 */ 71 */
72 OInputDevice* device( const QString& interface ) const; 72 OInputDevice* device( const QString& interface ) const;
73 /** 73 /**
74 * @internal Rebuild the internal interface database 74 * @internal Rebuild the internal interface database
75 * @note Sometimes it might be useful to call this from client code, 75 * @note Sometimes it might be useful to call this from client code,
76 */ 76 */
77 void synchronize(); 77 void synchronize();
78 /** 78 /**
79 * @internal destructor 79 * @internal destructor
80 */ 80 */
81 ~OInputSystem(); 81 ~OInputSystem();
82 82
83 protected: 83 protected:
84 OInputSystem(); 84 OInputSystem();
85 85
86 static OInputSystem* _instance; 86 static OInputSystem* _instance;
87 DeviceMap _devices; 87 DeviceMap _devices;
88}; 88};
89 89
90 90
91class OInputDevice : public QObject 91class OInputDevice : public QObject
92{ 92{
93 public: 93 public:
94 OInputDevice( QObject* parent, const char* name = 0 ); 94 OInputDevice( QObject* parent, const char* name = 0 );
95 ~OInputDevice(); 95 ~OInputDevice();
96 96
97 #include "oinputsystemenums.h" 97 #include "oinputsystemenums.h"
98 98
99 public: 99 public:
100 /** 100 /**
101 * @returns the identity string of this input device 101 * @returns the identity string of this input device
102 */ 102 */
103 QString identity() const; 103 QString identity() const;
104 /** 104 /**
105 * @returns the path of this input device 105 * @returns the path of this input device
106 */ 106 */
107 QString path() const; 107 QString path() const;
108 /** 108 /**
109 * @returns a unique identifier for this input device 109 * @returns a unique identifier for this input device
110 * @note Only a few devices support this 110 * @note Only a few devices support this
111 */ 111 */
112 QString uniq() const; 112 QString uniq() const;
113 /** 113 /**
114 * @returns whether a certain @a Feature is being supported by this device 114 * @returns whether a certain @a Feature is being supported by this device
115 */ 115 */
116 bool hasFeature( Feature ) const; 116 bool hasFeature( Feature ) const;
117 /** 117 /**
118 * @returns whether a given @a Key or Button is being held at the moment 118 * @returns whether a given @a Key or Button is being held at the moment
119 */ 119 */
120 bool isHeld( Key ) const; 120 bool isHeld( Key ) const;
121 /** 121 /**
122 * @internal 122 * @internal
123 * @returns a string containing a printable form of the global keymask 123 * @returns a string containing a printable form of the global keymask
124 */ 124 */
125 QString globalKeyMask() const; 125 QString globalKeyMask() const;
126 /** 126 /**
127 * @internal 127 * @internal
128 * @returns whether a certain @a path corresponds to an input device 128 * @returns whether a certain @a path corresponds to an input device
129 */ 129 */
130 static bool isValid( const QString& path ); 130 static bool isValid( const QString& path );
131 131
132 private: 132 private:
133 int _fd; 133 int _fd;
134 input_id _id; 134 input_id _id;
135 135
136}; 136};
137 137
138} 138}
139} 139}
140 140
141#endif // OINPUTSYSTEM_H 141#endif // OINPUTSYSTEM_H
142 142
diff --git a/libopie2/opiecore/linux/oinputsystemenums.h b/libopie2/opiecore/linux/oinputsystemenums.h
new file mode 100644
index 0000000..3461e5a
--- a/dev/null
+++ b/libopie2/opiecore/linux/oinputsystemenums.h
@@ -0,0 +1,405 @@
1
2 enum Feature
3 {
4 Synchronous = EV_SYN,
5 Keys = EV_KEY,
6 Relative = EV_REL,
7 Absolute = EV_ABS,
8 Miscellaneous = EV_MSC,
9 Leds = EV_LED,
10 Sound = EV_SND,
11 AutoRepeat = EV_REP,
12 ForceFeedback = EV_FF,
13 PowerManagement = EV_PWR,
14 ForceFeedbackStatus = EV_FF_STATUS,
15 };
16
17 enum Bus
18 {
19 PCI = BUS_PCI,
20 ISAPNP = BUS_ISAPNP,
21 HIL = BUS_HIL,
22 BLUETOOTH = BUS_BLUETOOTH,
23 ISA = BUS_ISA,
24 I8042 = BUS_I8042,
25 XTKBD = BUS_XTKBD,
26 RS232 = BUS_RS232,
27 GAMEPORT = BUS_GAMEPORT,
28 PARPORT = BUS_PARPORT,
29 AMIGA = BUS_AMIGA,
30 ADB = BUS_ADB,
31 I2C = BUS_I2C,
32 HOST = BUS_HOST,
33 };
34
35 enum Key
36 {
37 Key_RESERVED = 0,
38 Key_ESC = 1,
39 Key_1 = 2,
40 Key_2 = 3,
41 Key_3 = 4,
42 Key_4 = 5,
43 Key_5 = 6,
44 Key_6 = 7,
45 Key_7 = 8,
46 Key_8 = 9,
47 Key_9 = 10,
48 Key_0 = 11,
49 Key_MINUS = 12,
50 Key_EQUAL = 13,
51 Key_BACKSPACE = 14,
52 Key_TAB = 15,
53 Key_Q = 16,
54 Key_W = 17,
55 Key_E = 18,
56 Key_R = 19,
57 Key_T = 20,
58 Key_Y = 21,
59 Key_U = 22,
60 Key_I = 23,
61 Key_O = 24,
62 Key_P = 25,
63 Key_LEFTBRACE = 26,
64 Key_RIGHTBRACE = 27,
65 Key_ENTER = 28,
66 Key_LEFTCTRL = 29,
67 Key_A = 30,
68 Key_S = 31,
69 Key_D = 32,
70 Key_F = 33,
71 Key_G = 34,
72 Key_H = 35,
73 Key_J = 36,
74 Key_K = 37,
75 Key_L = 38,
76 Key_SEMICOLON = 39,
77 Key_APOSTROPHE = 40,
78 Key_GRAVE = 41,
79 Key_LEFTSHIFT = 42,
80 Key_BACKSLASH = 43,
81 Key_Z = 44,
82 Key_X = 45,
83 Key_C = 46,
84 Key_V = 47,
85 Key_B = 48,
86 Key_N = 49,
87 Key_M = 50,
88 Key_COMMA = 51,
89 Key_DOT = 52,
90 Key_SLASH = 53,
91 Key_RIGHTSHIFT = 54,
92 Key_KPASTERISK = 55,
93 Key_LEFTALT = 56,
94 Key_SPACE = 57,
95 Key_CAPSLOCK = 58,
96 Key_F1 = 59,
97 Key_F2 = 60,
98 Key_F3 = 61,
99 Key_F4 = 62,
100 Key_F5 = 63,
101 Key_F6 = 64,
102 Key_F7 = 65,
103 Key_F8 = 66,
104 Key_F9 = 67,
105 Key_F10 = 68,
106 Key_NUMLOCK = 69,
107 Key_SCROLLLOCK = 70,
108 Key_KP7 = 71,
109 Key_KP8 = 72,
110 Key_KP9 = 73,
111 Key_KPMINUS = 74,
112 Key_KP4 = 75,
113 Key_KP5 = 76,
114 Key_KP6 = 77,
115 Key_KPPLUS = 78,
116 Key_KP1 = 79,
117 Key_KP2 = 80,
118 Key_KP3 = 81,
119 Key_KP0 = 82,
120 Key_KPDOT = 83,
121
122 Key_ZENKAKUHANKAKU= 85,
123 Key_102ND = 86,
124 Key_F11 = 87,
125 Key_F12 = 88,
126 Key_RO = 89,
127 Key_KATAKANA = 90,
128 Key_HIRAGANA = 91,
129 Key_HENKAN = 92,
130 Key_KATAKANAHIRAGANA= 93,
131 Key_MUHENKAN = 94,
132 Key_KPJPCOMMA = 95,
133 Key_KPENTER = 96,
134 Key_RIGHTCTRL = 97,
135 Key_KPSLASH = 98,
136 Key_SYSRQ = 99,
137 Key_RIGHTALT = 100,
138 Key_LINEFEED = 101,
139 Key_HOME = 102,
140 Key_UP = 103,
141 Key_PAGEUP = 104,
142 Key_LEFT = 105,
143 Key_RIGHT = 106,
144 Key_END = 107,
145 Key_DOWN = 108,
146 Key_PAGEDOWN = 109,
147 Key_INSERT = 110,
148 Key_DELETE = 111,
149 Key_MACRO = 112,
150 Key_MUTE = 113,
151 Key_VOLUMEDOWN = 114,
152 Key_VOLUMEUP = 115,
153 Key_POWER = 116,
154 Key_KPEQUAL = 117,
155 Key_KPPLUSMINUS = 118,
156 Key_PAUSE = 119,
157
158 Key_KPCOMMA = 121,
159 Key_HANGUEL = 122,
160 Key_HANJA = 123,
161 Key_YEN = 124,
162 Key_LEFTMETA = 125,
163 Key_RIGHTMETA = 126,
164 Key_COMPOSE = 127,
165
166 Key_STOP = 128,
167 Key_AGAIN = 129,
168 Key_PROPS = 130,
169 Key_UNDO = 131,
170 Key_FRONT = 132,
171 Key_COPY = 133,
172 Key_OPEN = 134,
173 Key_PASTE = 135,
174 Key_FIND = 136,
175 Key_CUT = 137,
176 Key_HELP = 138,
177 Key_MENU = 139,
178 Key_CALC = 140,
179 Key_SETUP = 141,
180 Key_SLEEP = 142,
181 Key_WAKEUP = 143,
182 Key_FILE = 144,
183 Key_SENDFILE = 145,
184 Key_DELETEFILE = 146,
185 Key_XFER = 147,
186 Key_PROG1 = 148,
187 Key_PROG2 = 149,
188 Key_WWW = 150,
189 Key_MSDOS = 151,
190 Key_COFFEE = 152,
191 Key_DIRECTION = 153,
192 Key_CYCLEWINDOWS= 154,
193 Key_MAIL = 155,
194 Key_BOOKMARKS = 156,
195 Key_COMPUTER = 157,
196 Key_BACK = 158,
197 Key_FORWARD = 159,
198 Key_CLOSECD = 160,
199 Key_EJECTCD = 161,
200 Key_EJECTCLOSECD= 162,
201 Key_NEXTSONG = 163,
202 Key_PLAYPAUSE = 164,
203 Key_PREVIOUSSONG= 165,
204 Key_STOPCD = 166,
205 Key_RECORD = 167,
206 Key_REWIND = 168,
207 Key_PHONE = 169,
208 Key_ISO = 170,
209 Key_CONFIG = 171,
210 Key_HOMEPAGE = 172,
211 Key_REFRESH = 173,
212 Key_EXIT = 174,
213 Key_MOVE = 175,
214 Key_EDIT = 176,
215 Key_SCROLLUP = 177,
216 Key_SCROLLDOWN = 178,
217 Key_KPLEFTPAREN = 179,
218 Key_KPRIGHTPAREN= 180,
219
220 Key_F13 = 183,
221 Key_F14 = 184,
222 Key_F15 = 185,
223 Key_F16 = 186,
224 Key_F17 = 187,
225 Key_F18 = 188,
226 Key_F19 = 189,
227 Key_F20 = 190,
228 Key_F21 = 191,
229 Key_F22 = 192,
230 Key_F23 = 193,
231 Key_F24 = 194,
232
233 Key_PLAYCD = 200,
234 Key_PAUSECD = 201,
235 Key_PROG3 = 202,
236 Key_PROG4 = 203,
237 Key_SUSPEND = 205,
238 Key_CLOSE = 206,
239 Key_PLAY = 207,
240 Key_FASTFORWARD = 208,
241 Key_BASSBOOST = 209,
242 Key_PRINT = 210,
243 Key_HP = 211,
244 Key_CAMERA = 212,
245 Key_SOUND = 213,
246 Key_QUESTION = 214,
247 Key_EMAIL = 215,
248 Key_CHAT = 216,
249 Key_SEARCH = 217,
250 Key_CONNECT = 218,
251 Key_FINANCE = 219,
252 Key_SPORT = 220,
253 Key_SHOP = 221,
254 Key_ALTERASE = 222,
255 Key_CANCEL = 223,
256 Key_BRIGHTNESSDOWN= 224,
257 Key_BRIGHTNESSUP= 225,
258 Key_MEDIA = 226,
259
260 Key_UNKNOWN = 240,
261
262 Button_MISC = 0x100,
263 Button_0 = 0x100,
264 Button_1 = 0x101,
265 Button_2 = 0x102,
266 Button_3 = 0x103,
267 Button_4 = 0x104,
268 Button_5 = 0x105,
269 Button_6 = 0x106,
270 Button_7 = 0x107,
271 Button_8 = 0x108,
272 Button_9 = 0x109,
273
274 Button_MOUSE = 0x110,
275 Button_LEFT = 0x110,
276 Button_RIGHT = 0x111,
277 Button_MIDDLE = 0x112,
278 Button_SIDE = 0x113,
279 Button_EXTRA = 0x114,
280 Button_FORWARD = 0x115,
281 Button_BACK = 0x116,
282 Button_TASK = 0x117,
283
284 Button_JOYSTICK = 0x120,
285 Button_TRIGGER = 0x120,
286 Button_THUMB = 0x121,
287 Button_THUMB2 = 0x122,
288 Button_TOP = 0x123,
289 Button_TOP2 = 0x124,
290 Button_PINKIE = 0x125,
291 Button_BASE = 0x126,
292 Button_BASE2 = 0x127,
293 Button_BASE3 = 0x128,
294 Button_BASE4 = 0x129,
295 Button_BASE5 = 0x12a,
296 Button_BASE6 = 0x12b,
297 Button_DEAD = 0x12f,
298
299 Button_GAMEPAD = 0x130,
300 Button_A = 0x130,
301 Button_B = 0x131,
302 Button_C = 0x132,
303 Button_X = 0x133,
304 Button_Y = 0x134,
305 Button_Z = 0x135,
306 Button_TL = 0x136,
307 Button_TR = 0x137,
308 Button_TL2 = 0x138,
309 Button_TR2 = 0x139,
310 Button_SELECT = 0x13a,
311 Button_START = 0x13b,
312 Button_MODE = 0x13c,
313 Button_THUMBL = 0x13d,
314 Button_THUMBR = 0x13e,
315
316 Button_DIGI = 0x140,
317 Button_TOOL_PEN = 0x140,
318 Button_TOOL_RUBBER = 0x141,
319 Button_TOOL_BRUSH = 0x142,
320 Button_TOOL_PENCIL = 0x143,
321 Button_TOOL_AIRBRUSH= 0x144,
322 Button_TOOL_FINGER = 0x145,
323 Button_TOOL_MOUSE = 0x146,
324 Button_TOOL_LENS = 0x147,
325 Button_TOUCH = 0x14a,
326 Button_STYLUS = 0x14b,
327 Button_STYLUS2 = 0x14c,
328 Button_TOOL_DOUBLETAP= 0x14d,
329 Button_TOOL_TRIPLETAP= 0x14e,
330
331 Button_WHEEL = 0x150,
332 Button_GEAR_DOWN = 0x150,
333 Button_GEAR_UP = 0x151,
334
335 Key_OK = 0x160,
336 Key_SELECT = 0x161,
337 Key_GOTO = 0x162,
338 Key_CLEAR = 0x163,
339 Key_POWER2 = 0x164,
340 Key_OPTION = 0x165,
341 Key_INFO = 0x166,
342 Key_TIME = 0x167,
343 Key_VENDOR = 0x168,
344 Key_ARCHIVE = 0x169,
345 Key_PROGRAM = 0x16a,
346 Key_CHANNEL = 0x16b,
347 Key_FAVORITES = 0x16c,
348 Key_EPG = 0x16d,
349 Key_PVR = 0x16e,
350 Key_MHP = 0x16f,
351 Key_LANGUAGE = 0x170,
352 Key_TITLE = 0x171,
353 Key_SUBTITLE = 0x172,
354 Key_ANGLE = 0x173,
355 Key_ZOOM = 0x174,
356 Key_MODE = 0x175,
357 Key_KEYBOARD = 0x176,
358 Key_SCREEN = 0x177,
359 Key_PC = 0x178,
360 Key_TV = 0x179,
361 Key_TV2 = 0x17a,
362 Key_VCR = 0x17b,
363 Key_VCR2 = 0x17c,
364 Key_SAT = 0x17d,
365 Key_SAT2 = 0x17e,
366 Key_CD = 0x17f,
367 Key_TAPE = 0x180,
368 Key_RADIO = 0x181,
369 Key_TUNER = 0x182,
370 Key_PLAYER = 0x183,
371 Key_TEXT = 0x184,
372 Key_DVD = 0x185,
373 Key_AUX = 0x186,
374 Key_MP3 = 0x187,
375 Key_AUDIO = 0x188,
376 Key_VIDEO = 0x189,
377 Key_DIRECTORY = 0x18a,
378 Key_LIST = 0x18b,
379 Key_MEMO = 0x18c,
380 Key_CALENDAR = 0x18d,
381 Key_RED = 0x18e,
382 Key_GREEN = 0x18f,
383 Key_YELLOW = 0x190,
384 Key_BLUE = 0x191,
385 Key_CHANNELUP = 0x192,
386 Key_CHANNELDOWN = 0x193,
387 Key_FIRST = 0x194,
388 Key_LAST = 0x195,
389 Key_AB = 0x196,
390 Key_NEXT = 0x197,
391 Key_RESTART = 0x198,
392 Key_SLOW = 0x199,
393 Key_SHUFFLE = 0x19a,
394 Key_BREAK = 0x19b,
395 Key_PREVIOUS = 0x19c,
396 Key_DIGITS = 0x19d,
397 Key_TEEN = 0x19e,
398 Key_TWEN = 0x19f,
399
400 Key_DEL_EOL = 0x1c0,
401 Key_DEL_EOS = 0x1c1,
402 Key_INS_LINE = 0x1c2,
403 Key_DEL_LINE = 0x1c3,
404 };
405
diff --git a/libopie2/opiecore/linux/opcmciasystem.cpp b/libopie2/opiecore/linux/opcmciasystem.cpp
new file mode 100644
index 0000000..a924696
--- a/dev/null
+++ b/libopie2/opiecore/linux/opcmciasystem.cpp
@@ -0,0 +1,142 @@
1/*
2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l.
5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; version 2 of the License.
11     ._= =}       :
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#include "opcmciasystem.h"
31using namespace Opie::Core;
32
33/* OPIE */
34#include <opie2/odebug.h>
35
36/* QT */
37#include <qfile.h>
38#include <qtextstream.h>
39
40/* STD */
41#include <errno.h>
42#include <fcntl.h>
43#include <string.h>
44#include <sys/ioctl.h>
45#include <sys/types.h>
46#include <sys/stat.h>
47
48/*======================================================================================
49 * OPcmciaSystem
50 *======================================================================================*/
51
52OPcmciaSystem* OPcmciaSystem::_instance = 0;
53
54OPcmciaSystem::OPcmciaSystem()
55{
56 qDebug( "OPcmciaSystem::OPcmciaSystem()" );
57 synchronize();
58}
59
60void OPcmciaSystem::synchronize()
61{
62 qDebug( "OPcmciaSystem::synchronize()" );
63 _interfaces.clear();
64
65 //FIXME: Use cardmgr subsystem ioctls
66
67 QString fileName;
68 if ( QFile::exists( "/var/run/stab" ) ) { fileName = "/var/run/stab"; }
69 else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { fileName = "/var/state/pcmcia/stab"; }
70 else { fileName = "/var/lib/pcmcia/stab"; }
71 QFile cardinfofile( fileName );
72 if ( !cardinfofile.exists() || !cardinfofile.open( IO_ReadOnly ) )
73 {
74 qWarning( "pcmcia info file not found or unaccessible" );
75 return;
76 }
77 QTextStream cardinfo( &cardinfofile );
78 while ( !cardinfo.atEnd() )
79 {
80 QString line = cardinfo.readLine();
81 if ( line.startsWith( "Socket" ) )
82 {
83 int mid = line.find( ':' );
84 QString name = line.right( line.length() - mid - 1 );
85 QString id = line.right( line.length() - mid + 1 );
86 if ( mid ) _interfaces.insert( name, new OPcmciaCard( this, (const char*) id ) );
87 }
88 else
89 {
90 continue;
91 }
92 }
93}
94
95
96int OPcmciaSystem::count() const
97{
98 return _interfaces.count();
99}
100
101
102OPcmciaCard* OPcmciaSystem::card( const QString& iface ) const
103{
104 return _interfaces[iface];
105}
106
107
108OPcmciaSystem* OPcmciaSystem::instance()
109{
110 if ( !_instance ) _instance = new OPcmciaSystem();
111 return _instance;
112}
113
114
115OPcmciaSystem::CardIterator OPcmciaSystem::iterator() const
116{
117 return OPcmciaSystem::CardIterator( _interfaces );
118}
119
120
121/*======================================================================================
122 * OPcmciaCard
123 *======================================================================================*/
124
125OPcmciaCard::OPcmciaCard( QObject* parent, const char* name )
126 :QObject( parent, name )
127{
128 odebug << "OPcmciaCard::OPcmciaCard()" << oendl;
129 init();
130}
131
132
133OPcmciaCard::~OPcmciaCard()
134{
135}
136
137
138void OPcmciaCard::init()
139{
140}
141
142
diff --git a/libopie2/opiecore/linux/opcmciasystem.h b/libopie2/opiecore/linux/opcmciasystem.h
new file mode 100644
index 0000000..694bf16
--- a/dev/null
+++ b/libopie2/opiecore/linux/opcmciasystem.h
@@ -0,0 +1,129 @@
1/*
2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l.
5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; version 2 of the License.
11     ._= =}       :
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#ifndef OPCMCIASYSTEM_H
31#define OPCMCIASYSTEM_H
32
33#include <qobject.h>
34#include <qdict.h>
35#include <qmap.h>
36
37namespace Opie {
38namespace Core {
39
40class OPcmciaCard;
41
42/*======================================================================================
43 * OPcmciaSystem
44 *======================================================================================*/
45
46/**
47 * @brief A container class for the linux pcmcia subsystem
48 *
49 * This class provides access to all available pcmcia/cf cards on your device.
50 *
51 * @author Michael 'Mickey' Lauer <mickey@Vanille.de>
52 */
53class OPcmciaSystem : public QObject
54{
55 Q_OBJECT
56
57 public:
58 typedef QDict<OPcmciaCard> CardMap;
59 typedef QDictIterator<OPcmciaCard> CardIterator;
60
61 public:
62 /**
63 * @returns the number of available interfaces
64 */
65 int count() const;
66 /**
67 * @returns a pointer to the (one and only) @ref OSystem instance.
68 */
69 static OPcmciaSystem* instance();
70 /**
71 * @returns an iterator usable for iterating through all sound cards.
72 */
73 CardIterator iterator() const;
74 /**
75 * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found
76 * @see OAudioInterface
77 */
78 OPcmciaCard* card( const QString& interface ) const;
79 /**
80 * @internal Rebuild the internal interface database
81 * @note Sometimes it might be useful to call this from client code,
82 * e.g. after issuing a cardctl insert
83 */
84 void synchronize();
85
86 protected:
87 OPcmciaSystem();
88
89 private:
90 static OPcmciaSystem* _instance;
91 CardMap _interfaces;
92 class Private;
93 Private *d;
94};
95
96
97/*======================================================================================
98 * OPcmciaCard
99 *======================================================================================*/
100
101class OPcmciaCard : public QObject
102{
103 Q_OBJECT
104
105 public:
106 /**
107 * Constructor. Normally you don't create @ref OPcmciaCard objects yourself,
108 * but access them via @ref OPcmciaSystem::card().
109 */
110 OPcmciaCard( QObject* parent, const char* name );
111 /**
112 * Destructor.
113 */
114 virtual ~OPcmciaCard();
115
116 protected:
117
118 private:
119 void init();
120 private:
121 class Private;
122 Private *d;
123};
124
125
126}
127}
128
129#endif // OPCMCIASYSTEM_H
diff --git a/libopie2/opiecore/opiecore.pro b/libopie2/opiecore/opiecore.pro
index 84f3343..cbb7e04 100644
--- a/libopie2/opiecore/opiecore.pro
+++ b/libopie2/opiecore/opiecore.pro
@@ -1,65 +1,59 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = oapplication.h \ 4HEADERS = oapplication.h \
5 oconfig.h \ 5 oconfig.h \
6 odebug.h \ 6 odebug.h \
7 oglobal.h \ 7 oglobal.h \
8 oglobalsettings.h \ 8 oglobalsettings.h \
9 oinputsystem.h \
10 okeyconfigmanager.h \ 9 okeyconfigmanager.h \
11 okeyfilter.h \ 10 okeyfilter.h \
12 opluginloader.h \ 11 opluginloader.h \
13 oprocess.h \ 12 oprocess.h \
14 oprocctrl.h \ 13 oprocctrl.h \
15 oresource.h \ 14 oresource.h \
16 osharedpointer.h \ 15 osharedpointer.h \
17 osmartpointer.h \ 16 osmartpointer.h \
18 ostorageinfo.h \ 17 ostorageinfo.h \
19 xmltree.h 18 xmltree.h
20 19
21SOURCES = oapplication.cpp \ 20SOURCES = oapplication.cpp \
22 oconfig.cpp \ 21 oconfig.cpp \
23 odebug.cpp \ 22 odebug.cpp \
24 oglobal.cpp \ 23 oglobal.cpp \
25 oglobalsettings.cpp \ 24 oglobalsettings.cpp \
26 oinputsystem.cpp \
27 okeyconfigmanager.cpp \ 25 okeyconfigmanager.cpp \
28 okeyfilter.cpp \ 26 okeyfilter.cpp \
29 opluginloader.cpp \ 27 opluginloader.cpp \
30 oprocess.cpp \ 28 oprocess.cpp \
31 oprocctrl.cpp \ 29 oprocctrl.cpp \
32 oresource.cpp \ 30 oresource.cpp \
33 osmartpointer.cpp \ 31 osmartpointer.cpp \
34 ostorageinfo.cpp \ 32 ostorageinfo.cpp \
35 xmltree.cpp 33 xmltree.cpp
36 34
37 35
38# The following files are currently not compileable on mac ! 36# Disable Linux-only subsystems for MAC build
39# Therfore I removed them from the build .. (eilers) 37!contains( CONFIG_TARGET_MACOSX, y ) {
40 38include ( linux/linux.pro )
41CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
42!contains( CONFTEST, y ) {
43HEADERS += ofilenotify.h
44SOURCES += ofilenotify.cpp
45} else { 39} else {
46 message( "ofilenotify is not available in a mac build !" ) 40 message( "disabling linux-only subsystems for MAC build" )
47} 41}
48 42
49include( device/device.pro ) 43include( device/device.pro )
50 44
51INTERFACES = 45INTERFACES =
52TARGET = opiecore2 46TARGET = opiecore2
53VERSION = 1.9.3 47VERSION = 1.9.4
54INCLUDEPATH += $(OPIEDIR)/include 48INCLUDEPATH += $(OPIEDIR)/include
55DEPENDPATH += $(OPIEDIR)/include 49DEPENDPATH += $(OPIEDIR)/include
56 50
57!contains( platform, x11 ) { 51!contains( platform, x11 ) {
58 LIBS = -lqpe 52 LIBS = -lqpe
59 include( $(OPIEDIR)/include.pro ) 53 include( $(OPIEDIR)/include.pro )
60} 54}
61 55
62contains( platform, x11 ) { 56contains( platform, x11 ) {
63 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 57 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
64} 58}
65 59
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp
index 2956682..6f849cd 100644
--- a/libopie2/opiemm/osoundsystem.cpp
+++ b/libopie2/opiemm/osoundsystem.cpp
@@ -1,142 +1,144 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =.
5 .=l. 4 .=l.
6           .>+-= 5           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 12    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 19++=   -.     .`     .: details.
21 :     =  ...= . :.=- 20 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
28 27
29*/ 28*/
30 29
31#include <opie2/osoundsystem.h> 30#include "osoundsystem.h"
31using namespace Opie::MM;
32
33/* OPIE */
32#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35using namespace Opie::Core;
33 36
37/* STD */
34#include <errno.h> 38#include <errno.h>
35#include <fcntl.h> 39#include <fcntl.h>
36#include <string.h> 40#include <string.h>
37#include <sys/ioctl.h> 41#include <sys/ioctl.h>
38#include <sys/types.h> 42#include <sys/types.h>
39#include <sys/soundcard.h> 43#include <sys/soundcard.h>
40#include <sys/stat.h> 44#include <sys/stat.h>
41 45
42static const char* device_label[] = SOUND_DEVICE_LABELS; 46static const char* device_label[] = SOUND_DEVICE_LABELS;
43static int max_device_nr = sizeof device_label / sizeof (const char*); 47static int max_device_nr = sizeof device_label / sizeof (const char*);
44 48
45using namespace Opie::Core;
46using namespace Opie::MM;
47/*====================================================================================== 49/*======================================================================================
48 * OSoundSystem 50 * OSoundSystem
49 *======================================================================================*/ 51 *======================================================================================*/
50 52
51OSoundSystem* OSoundSystem::_instance = 0; 53OSoundSystem* OSoundSystem::_instance = 0;
52 54
53OSoundSystem::OSoundSystem() 55OSoundSystem::OSoundSystem()
54{ 56{
55 odebug << "OSoundSystem::OSoundSystem()" << oendl; 57 odebug << "OSoundSystem::OSoundSystem()" << oendl;
56 synchronize(); 58 synchronize();
57} 59}
58 60
59void OSoundSystem::synchronize() 61void OSoundSystem::synchronize()
60{ 62{
61 _interfaces.clear(); 63 _interfaces.clear();
62 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); 64 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) );
63 65
64 /* 66 /*
65 67
66 QString str; 68 QString str;
67 QFile f( "/dev/sound" ); 69 QFile f( "/dev/sound" );
68 bool hasFile = f.open( IO_ReadOnly ); 70 bool hasFile = f.open( IO_ReadOnly );
69 if ( !hasFile ) 71 if ( !hasFile )
70 { 72 {
71 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl; 73 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl;
72 return; 74 return;
73 } 75 }
74 QTextStream s( &f ); 76 QTextStream s( &f );
75 s.readLine(); 77 s.readLine();
76 s.readLine(); 78 s.readLine();
77 while ( !s.atEnd() ) 79 while ( !s.atEnd() )
78 { 80 {
79 s >> str; 81 s >> str;
80 str.truncate( str.find( ':' ) ); 82 str.truncate( str.find( ':' ) );
81 odebug << "OSoundSystem: found interface '" << str << "'" << oendl; 83 odebug << "OSoundSystem: found interface '" << str << "'" << oendl;
82 OAudioInterface* iface; 84 OAudioInterface* iface;
83 iface = new OAudioInterface( this, (const char*) str ); 85 iface = new OAudioInterface( this, (const char*) str );
84 86
85 _interfaces.insert( str, iface ); 87 _interfaces.insert( str, iface );
86 s.readLine(); 88 s.readLine();
87 } 89 }
88*/ 90*/
89} 91}
90 92
91 93
92int OSoundSystem::count() const 94int OSoundSystem::count() const
93{ 95{
94 return _interfaces.count(); 96 return _interfaces.count();
95} 97}
96 98
97 99
98OSoundCard* OSoundSystem::card( const QString& iface ) const 100OSoundCard* OSoundSystem::card( const QString& iface ) const
99{ 101{
100 return _interfaces[iface]; 102 return _interfaces[iface];
101} 103}
102 104
103 105
104OSoundSystem* OSoundSystem::instance() 106OSoundSystem* OSoundSystem::instance()
105{ 107{
106 if ( !_instance ) _instance = new OSoundSystem(); 108 if ( !_instance ) _instance = new OSoundSystem();
107 return _instance; 109 return _instance;
108} 110}
109 111
110 112
111OSoundSystem::CardIterator OSoundSystem::iterator() const 113OSoundSystem::CardIterator OSoundSystem::iterator() const
112{ 114{
113 return OSoundSystem::CardIterator( _interfaces ); 115 return OSoundSystem::CardIterator( _interfaces );
114} 116}
115 117
116 118
117/*====================================================================================== 119/*======================================================================================
118 * OSoundCard 120 * OSoundCard
119 *======================================================================================*/ 121 *======================================================================================*/
120 122
121OSoundCard::OSoundCard( QObject* parent, const char* name ) 123OSoundCard::OSoundCard( QObject* parent, const char* name )
122 :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) 124 :QObject( parent, name ), _audio( 0 ), _mixer( 0 )
123{ 125{
124 odebug << "OSoundCard::OSoundCard()" << oendl; 126 odebug << "OSoundCard::OSoundCard()" << oendl;
125 init(); 127 init();
126} 128}
127 129
128 130
129OSoundCard::~OSoundCard() 131OSoundCard::~OSoundCard()
130{ 132{
131} 133}
132 134
133 135
134void OSoundCard::init() 136void OSoundCard::init()
135{ 137{
136#ifdef QT_QWS_DEVFS 138#ifdef QT_QWS_DEVFS
137 _audio = new OAudioInterface( this, "/dev/sound/dsp" ); 139 _audio = new OAudioInterface( this, "/dev/sound/dsp" );
138 _mixer = new OMixerInterface( this, "/dev/sound/mixer" ); 140 _mixer = new OMixerInterface( this, "/dev/sound/mixer" );
139#else 141#else
140 _audio = new OAudioInterface( this, "/dev/dsp" ); 142 _audio = new OAudioInterface( this, "/dev/dsp" );
141 _mixer = new OMixerInterface( this, "/dev/mixer" ); 143 _mixer = new OMixerInterface( this, "/dev/mixer" );
142#endif 144#endif
diff --git a/libopie2/opiemm/osoundsystem.h b/libopie2/opiemm/osoundsystem.h
index 5f6fb7a..1e48f5c 100644
--- a/libopie2/opiemm/osoundsystem.h
+++ b/libopie2/opiemm/osoundsystem.h
@@ -1,150 +1,149 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =.
5 .=l. 4 .=l.
6           .>+-= 5           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; version 2 of the License.
12     ._= =}       : or (at your option) any later version. 11     ._= =}       :
13    .%`+i>       _;_. 12    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 19++=   -.     .`     .: details.
21 :     =  ...= . :.=- 20 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
28 27
29*/ 28*/
30 29
31#ifndef OSOUNDSYSTEM_H 30#ifndef OSOUNDSYSTEM_H
32#define OSOUNDSYSTEM_H 31#define OSOUNDSYSTEM_H
33 32
34#include <qobject.h> 33#include <qobject.h>
35#include <qdict.h> 34#include <qdict.h>
36#include <qmap.h> 35#include <qmap.h>
37 36
38namespace Opie { 37namespace Opie {
39namespace MM { 38namespace MM {
40 39
41class OAudioInterface; 40class OAudioInterface;
42class OMixerInterface; 41class OMixerInterface;
43class OSoundCard; 42class OSoundCard;
44 43
45/*====================================================================================== 44/*======================================================================================
46 * OSoundSystem 45 * OSoundSystem
47 *======================================================================================*/ 46 *======================================================================================*/
48 47
49/** 48/**
50 * @brief A container class for all audio interfaces 49 * @brief A container class for the Linux OSS/ALSA audio subsystem
51 * 50 *
52 * This class provides access to all available audio/midi/sequencer interfaces of your computer. 51 * This class provides access to all available audio/midi/sequencer interfaces of your device.
53 * 52 *
54 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 53 * @author Michael 'Mickey' Lauer <mickey@Vanille.de>
55 */ 54 */
56class OSoundSystem : public QObject 55class OSoundSystem : public QObject
57{ 56{
58 Q_OBJECT 57 Q_OBJECT
59 58
60 public: 59 public:
61 typedef QDict<OSoundCard> CardMap; 60 typedef QDict<OSoundCard> CardMap;
62 typedef QDictIterator<OSoundCard> CardIterator; 61 typedef QDictIterator<OSoundCard> CardIterator;
63 62
64 public: 63 public:
65 /** 64 /**
66 * @returns the number of available interfaces 65 * @returns the number of available interfaces
67 */ 66 */
68 int count() const; 67 int count() const;
69 /** 68 /**
70 * @returns a pointer to the (one and only) @ref OSystem instance. 69 * @returns a pointer to the (one and only) @ref OSystem instance.
71 */ 70 */
72 static OSoundSystem* instance(); 71 static OSoundSystem* instance();
73 /** 72 /**
74 * @returns an iterator usable for iterating through all sound cards. 73 * @returns an iterator usable for iterating through all sound cards.
75 */ 74 */
76 CardIterator iterator() const; 75 CardIterator iterator() const;
77 /** 76 /**
78 * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found 77 * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found
79 * @see OAudioInterface 78 * @see OAudioInterface
80 */ 79 */
81 OSoundCard* card( const QString& interface ) const; 80 OSoundCard* card( const QString& interface ) const;
82 /** 81 /**
83 * @internal Rebuild the internal interface database 82 * @internal Rebuild the internal interface database
84 * @note Sometimes it might be useful to call this from client code, 83 * @note Sometimes it might be useful to call this from client code,
85 * e.g. after issuing a cardctl insert 84 * e.g. after issuing a cardctl insert
86 */ 85 */
87 void synchronize(); 86 void synchronize();
88 87
89 protected: 88 protected:
90 OSoundSystem(); 89 OSoundSystem();
91 90
92 private: 91 private:
93 static OSoundSystem* _instance; 92 static OSoundSystem* _instance;
94 CardMap _interfaces; 93 CardMap _interfaces;
95 class Private; 94 class Private;
96 Private *d; 95 Private *d;
97}; 96};
98 97
99 98
100/*====================================================================================== 99/*======================================================================================
101 * OSoundCard 100 * OSoundCard
102 *======================================================================================*/ 101 *======================================================================================*/
103 102
104class OSoundCard : public QObject 103class OSoundCard : public QObject
105{ 104{
106 Q_OBJECT 105 Q_OBJECT
107 106
108 public: 107 public:
109 /** 108 /**
110 * Constructor. Normally you don't create @ref OSoundCard objects yourself, 109 * Constructor. Normally you don't create @ref OSoundCard objects yourself,
111 * but access them via @ref OSoundSystem::card(). 110 * but access them via @ref OSoundSystem::card().
112 */ 111 */
113 OSoundCard( QObject* parent, const char* name ); 112 OSoundCard( QObject* parent, const char* name );
114 /** 113 /**
115 * Destructor. 114 * Destructor.
116 */ 115 */
117 virtual ~OSoundCard(); 116 virtual ~OSoundCard();
118 117
119 bool hasMixer() const { return _audio; }; 118 bool hasMixer() const { return _audio; };
120 bool hasAudio() const { return _mixer; }; 119 bool hasAudio() const { return _mixer; };
121 120
122 OAudioInterface* audio() const { return _audio; }; 121 OAudioInterface* audio() const { return _audio; };
123 OMixerInterface* mixer() const { return _mixer; }; 122 OMixerInterface* mixer() const { return _mixer; };
124 123
125 protected: 124 protected:
126 OAudioInterface* _audio; 125 OAudioInterface* _audio;
127 OMixerInterface* _mixer; 126 OMixerInterface* _mixer;
128 127
129 private: 128 private:
130 void init(); 129 void init();
131 private: 130 private:
132 class Private; 131 class Private;
133 Private *d; 132 Private *d;
134}; 133};
135 134
136/*====================================================================================== 135/*======================================================================================
137 * OAudioInterface 136 * OAudioInterface
138 *======================================================================================*/ 137 *======================================================================================*/
139 138
140class OAudioInterface : public QObject 139class OAudioInterface : public QObject
141{ 140{
142 Q_OBJECT 141 Q_OBJECT
143 142
144 public: 143 public:
145 /** 144 /**
146 * Constructor. Normally you don't create @ref OAudioInterface objects yourself, 145 * Constructor. Normally you don't create @ref OAudioInterface objects yourself,
147 * but access them via the @ref OSoundCard interface. 146 * but access them via the @ref OSoundCard interface.
148 */ 147 */
149 OAudioInterface( QObject* parent, const char* name ); 148 OAudioInterface( QObject* parent, const char* name );
150 /** 149 /**
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index eafbeea..c548356 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -1,108 +1,108 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003-2004 by Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003-2004 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
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; version 2 of the License. 11 - .   .-<_>     .<> Foundation; version 2 of the License.
12     ._= =}       : 12     ._= =}       :
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#include "udp_ports.h" 31#include "udp_ports.h"
32#include "opcap.h" 32#include "opcap.h"
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36using namespace Opie::Core; 36using namespace Opie::Core;
37 37
38/* QT */ 38/* QT */
39#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) 39#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects)
40#include <qsocketnotifier.h> 40#include <qsocketnotifier.h>
41#include <qobjectlist.h> 41#include <qobjectlist.h>
42 42
43/* STD */ 43/* STD */
44#include <sys/time.h> 44#include <sys/time.h>
45#include <sys/types.h> 45#include <sys/types.h>
46#include <assert.h> 46#include <assert.h>
47#include <unistd.h> 47#include <unistd.h>
48#include <string.h> 48#include <string.h>
49 49
50namespace Opie { 50namespace Opie {
51namespace Net { 51namespace Net {
52 52
53/*====================================================================================== 53/*======================================================================================
54 * OPacket 54 * OPacket
55 *======================================================================================*/ 55 *======================================================================================*/
56 56
57OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) 57OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent )
58 :QObject( parent, "Generic" ), _hdr( header ), _data( 0 ) 58 :QObject( parent, "Generic" ), _hdr( header ), _data( 0 )
59{ 59{
60 60
61 _data = new unsigned char[ header.len ]; 61 _data = new unsigned char[ header.len ];
62 assert( _data ); 62 assert( _data );
63 memcpy( const_cast<unsigned char*>(_data), data, header.len ); 63 memcpy( const_cast<unsigned char*>(_data), data, header.len );
64 // We have to copy the data structure here, because the 'data' pointer handed by libpcap 64 // We have to copy the data structure here, because the 'data' pointer handed by libpcap
65 // points to an internal region which is reused by lipcap. 65 // points to an internal region which is reused by lipcap.
66 odebug << "OPacket: Length = " << header.len << ", Caplen = " << header.caplen << oendl; 66 odebug << "OPacket: Length = " << header.len << ", Caplen = " << header.caplen << oendl;
67 _end = (unsigned char*) _data + header.len; 67 _end = (unsigned char*) _data + header.len;
68 68
69 switch ( datalink ) 69 switch ( datalink )
70 { 70 {
71 case DLT_EN10MB: 71 case DLT_EN10MB:
72 odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl; 72 odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl;
73 new OEthernetPacket( _end, (const struct ether_header*) _data, this ); 73 new OEthernetPacket( _end, (const struct ether_header*) _data, this );
74 break; 74 break;
75 75
76 case DLT_IEEE802_11: 76 case DLT_IEEE802_11:
77 odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl; 77 odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl;
78 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) _data, this ); 78 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) _data, this );
79 break; 79 break;
80 80
81 case DLT_PRISM_HEADER: 81 case DLT_PRISM_HEADER:
82 odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl; 82 odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl;
83 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) _data, this ); 83 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) _data, this );
84 break; 84 break;
85 85
86 default: 86 default:
87 owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl; 87 owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl;
88 } 88 }
89} 89}
90 90
91 91
92OPacket::~OPacket() 92OPacket::~OPacket()
93{ 93{
94 odebug << "~OPacket( " << name() << " )" << oendl; 94 odebug << "~OPacket( " << name() << " )" << oendl;
95 delete [] _data; 95 delete [] _data;
96} 96}
97 97
98 98
99timevalstruct OPacket::timeval() const 99timevalstruct OPacket::timeval() const
100{ 100{
101 return _hdr.ts; 101 return _hdr.ts;
102} 102}
103 103
104 104
105int OPacket::caplen() const 105int OPacket::caplen() const
106{ 106{
107 return _hdr.caplen; 107 return _hdr.caplen;
108} 108}
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index 149e573..8b415a2 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -1,157 +1,156 @@
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 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
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; version 2 of the License. 11 - .   .-<_>     .<> Foundation; version 2 of the License.
12     ._= =}       : 12     ._= =}       :
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 OPCAP_H 31#ifndef OPCAP_H
32#define OPCAP_H 32#define OPCAP_H
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/onetutils.h> 35#include <opie2/onetutils.h>
36 36
37/* QT */ 37/* QT */
38#include <qevent.h> 38#include <qevent.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qhostaddress.h> 40#include <qhostaddress.h>
41#include <qobject.h> 41#include <qobject.h>
42#include <qstring.h> 42#include <qstring.h>
43#include <qtextstream.h> 43#include <qtextstream.h>
44#include <qmap.h> 44#include <qmap.h>
45 45
46/* STD */ 46/* STD */
47extern "C" // work around a bpf/pcap conflict in recent headers 47extern "C" // work around a bpf/pcap conflict in recent headers
48{ 48{
49 #include <pcap.h> 49 #include <pcap.h>
50} 50}
51#include <netinet/ether.h> 51#include <netinet/ether.h>
52#include <netinet/ip.h> 52#include <netinet/ip.h>
53#include <netinet/udp.h> 53#include <netinet/udp.h>
54#include <netinet/tcp.h> 54#include <netinet/tcp.h>
55#include <time.h> 55#include <time.h>
56 56
57/* Custom Network Includes (must go here, don't reorder!) */ 57/* Custom Network Includes (must go here, don't reorder!) */
58#include "802_11_user.h" 58#include "802_11_user.h"
59#include "dhcp.h" 59#include "dhcp.h"
60 60
61
62/* TYPEDEFS */ 61/* TYPEDEFS */
63typedef struct timeval timevalstruct; 62typedef struct timeval timevalstruct;
64typedef struct pcap_pkthdr packetheaderstruct; 63typedef struct pcap_pkthdr packetheaderstruct;
65 64
66/* FORWARDS */ 65/* FORWARDS */
67class QSocketNotifier; 66class QSocketNotifier;
68namespace Opie { 67namespace Opie {
69namespace Net { 68namespace Net {
70class OPacketCapturer; 69class OPacketCapturer;
71 70
72/*====================================================================================== 71/*======================================================================================
73 * OPacket - A frame on the wire 72 * OPacket - A frame on the wire
74 *======================================================================================*/ 73 *======================================================================================*/
75 74
76/** @brief A class representing a data frame on the wire. 75/** @brief A class representing a data frame on the wire.
77 * 76 *
78 * The whole family of the packet classes are used when capturing frames from a network. 77 * The whole family of the packet classes are used when capturing frames from a network.
79 * Most standard network protocols in use share a common architecture, which mostly is 78 * Most standard network protocols in use share a common architecture, which mostly is
80 * a packet header and then the packet payload. In layered architectures, each lower layer 79 * a packet header and then the packet payload. In layered architectures, each lower layer
81 * encapsulates data from its upper layer - that is it 80 * encapsulates data from its upper layer - that is it
82 * treats the data from its upper layer as payload and prepends an own header to the packet, 81 * treats the data from its upper layer as payload and prepends an own header to the packet,
83 * which - again - is treated as the payload for the layer below. The figure below is an 82 * which - again - is treated as the payload for the layer below. The figure below is an
84 * example for how such a data frame is composed out of packets, e.g. when sending a mail. 83 * example for how such a data frame is composed out of packets, e.g. when sending a mail.
85 * 84 *
86 * <pre> 85 * <pre>
87 * | User Data | == Mail Data 86 * | User Data | == Mail Data
88 * | SMTP Header | User Data | == SMTP 87 * | SMTP Header | User Data | == SMTP
89 * | TCP Header | SMTP Header | User Data | == TCP 88 * | TCP Header | SMTP Header | User Data | == TCP
90 * | IP Header | TCP Header | SMTP Header | User Data | == IP 89 * | IP Header | TCP Header | SMTP Header | User Data | == IP
91 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC 90 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC
92 * 91 *
93 * </pre> 92 * </pre>
94 * 93 *
95 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer 94 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer
96 * also contains a few more levels of encapsulation. 95 * also contains a few more levels of encapsulation.
97 * Since the type of the payload is more or less independent from the encapsulating protocol, 96 * Since the type of the payload is more or less independent from the encapsulating protocol,
98 * the header must be inspected before attempting to decode the payload. Hence, the 97 * the header must be inspected before attempting to decode the payload. Hence, the
99 * encapsulation level varies and can't be deduced without actually looking into the packets. 98 * encapsulation level varies and can't be deduced without actually looking into the packets.
100 * 99 *
101 * For actually working with captured frames, it's useful to identify the packets via names and 100 * For actually working with captured frames, it's useful to identify the packets via names and
102 * insert them into a parent/child - relationship based on the encapsulation. This is why 101 * insert them into a parent/child - relationship based on the encapsulation. This is why
103 * all packet classes derive from QObject. The amount of overhead caused by the QObject is 102 * all packet classes derive from QObject. The amount of overhead caused by the QObject is
104 * not a problem in this case, because we're talking about a theoratical maximum of about 103 * not a problem in this case, because we're talking about a theoratical maximum of about
105 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the 104 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the
106 * QObject also cares about destroying the sub-, (child-) packets. 105 * QObject also cares about destroying the sub-, (child-) packets.
107 * 106 *
108 * This enables us to perform a simple look for packets of a certain type: 107 * This enables us to perform a simple look for packets of a certain type:
109 * @code 108 * @code
110 * OPacketCapturer* pcap = new OPacketCapturer(); 109 * OPacketCapturer* pcap = new OPacketCapturer();
111 * pcap->open( "eth0" ); 110 * pcap->open( "eth0" );
112 * OPacket* p = pcap->next(); 111 * OPacket* p = pcap->next();
113 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists 112 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists
114 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; 113 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl;
115 * 114 *
116 */ 115 */
117 116
118class OPacket : public QObject 117class OPacket : public QObject
119{ 118{
120 Q_OBJECT 119 Q_OBJECT
121 120
122 friend class OPacketCapturer; 121 friend class OPacketCapturer;
123 friend QTextStream& operator<<( QTextStream& s, const OPacket& p ); 122 friend QTextStream& operator<<( QTextStream& s, const OPacket& p );
124 123
125 public: 124 public:
126 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); 125 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent );
127 virtual ~OPacket(); 126 virtual ~OPacket();
128 127
129 timevalstruct timeval() const; 128 timevalstruct timeval() const;
130 129
131 int caplen() const; 130 int caplen() const;
132 int len() const; 131 int len() const;
133 QString dump( int = 32 ) const; //FIXME: remove that 132 QString dump( int = 32 ) const; //FIXME: remove that
134 133
135 void updateStats( QMap<QString,int>&, QObjectList* ); //FIXME: Revise 134 void updateStats( QMap<QString,int>&, QObjectList* ); //FIXME: Revise
136 135
137 QString dumpStructure() const; //FIXME: Revise 136 QString dumpStructure() const; //FIXME: Revise
138 private: 137 private:
139 QString _dumpStructure( QObjectList* ) const; //FIXME: Revise 138 QString _dumpStructure( QObjectList* ) const; //FIXME: Revise
140 139
141 private: 140 private:
142 const packetheaderstruct _hdr; // pcap packet header 141 const packetheaderstruct _hdr; // pcap packet header
143 const unsigned char* _data; // pcap packet data 142 const unsigned char* _data; // pcap packet data
144 const unsigned char* _end; // end of pcap packet data 143 const unsigned char* _end; // end of pcap packet data
145 private: 144 private:
146 class Private; 145 class Private;
147 Private *d; 146 Private *d;
148}; 147};
149 148
150QTextStream& operator<<( QTextStream& s, const OPacket& p ); //FIXME: Revise 149QTextStream& operator<<( QTextStream& s, const OPacket& p ); //FIXME: Revise
151 150
152/*====================================================================================== 151/*======================================================================================
153 * OEthernetPacket - DLT_EN10MB frame 152 * OEthernetPacket - DLT_EN10MB frame
154 *======================================================================================*/ 153 *======================================================================================*/
155 154
156class OEthernetPacket : public QObject 155class OEthernetPacket : public QObject
157{ 156{