author | mickeyl <mickeyl> | 2005-01-29 14:09:25 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-01-29 14:09:25 (UTC) |
commit | 7b06e36fe27adc6a4fde2004eac13aaf8c0f0f02 (patch) (unidiff) | |
tree | 5b38b6eb9d8430b0a96a2e156995bb421cc1a570 /examples | |
parent | 0db5704f66f0d08f9928f749774ee0f37bb0250d (diff) | |
download | opie-7b06e36fe27adc6a4fde2004eac13aaf8c0f0f02.zip opie-7b06e36fe27adc6a4fde2004eac13aaf8c0f0f02.tar.gz opie-7b06e36fe27adc6a4fde2004eac13aaf8c0f0f02.tar.bz2 |
examples start to appear here
23 files changed, 755 insertions, 0 deletions
diff --git a/examples/config.in b/examples/config.in new file mode 100644 index 0000000..ccaf485 --- a/dev/null +++ b/examples/config.in | |||
@@ -0,0 +1,12 @@ | |||
1 | source examples/applet/config.in | ||
2 | source examples/inputmethod/config.in | ||
3 | source examples/main-tab/config.in | ||
4 | source examples/menuapplet/config.in | ||
5 | source examples/networksettings/config.in | ||
6 | source examples/python/config.in | ||
7 | source examples/simple/config.in | ||
8 | source examples/simple-icon/config.in | ||
9 | source examples/simple-main/config.in | ||
10 | source examples/simple-pim/config.in | ||
11 | source examples/todayplugin/config.in | ||
12 | |||
diff --git a/examples/opiecore/.cvsignore b/examples/opiecore/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/examples/opiecore/.cvsignore | |||
@@ -0,0 +1,6 @@ | |||
1 | Makefile* | ||
2 | moc* | ||
3 | *moc | ||
4 | *.o | ||
5 | ~* | ||
6 | |||
diff --git a/examples/opiedb/.cvsignore b/examples/opiedb/.cvsignore new file mode 100644 index 0000000..972e959 --- a/dev/null +++ b/examples/opiedb/.cvsignore | |||
@@ -0,0 +1,6 @@ | |||
1 | Makefile* | ||
2 | moc* | ||
3 | *moc | ||
4 | *.o | ||
5 | ~* | ||
6 | obj | ||
diff --git a/examples/opiedb/opiedb.pro b/examples/opiedb/opiedb.pro new file mode 100644 index 0000000..85fa6db --- a/dev/null +++ b/examples/opiedb/opiedb.pro | |||
@@ -0,0 +1,3 @@ | |||
1 | TEMPLATE = subdirs | ||
2 | SUBDIRS = sqltest | ||
3 | |||
diff --git a/examples/opiedb/sqltest/.cvsignore b/examples/opiedb/sqltest/.cvsignore new file mode 100644 index 0000000..3290247 --- a/dev/null +++ b/examples/opiedb/sqltest/.cvsignore | |||
@@ -0,0 +1,7 @@ | |||
1 | sqltest | ||
2 | Makefile* | ||
3 | moc* | ||
4 | *moc | ||
5 | *.o | ||
6 | ~* | ||
7 | obj | ||
diff --git a/examples/opiedb/sqltest/main.cpp b/examples/opiedb/sqltest/main.cpp new file mode 100644 index 0000000..f4338e9 --- a/dev/null +++ b/examples/opiedb/sqltest/main.cpp | |||
@@ -0,0 +1,62 @@ | |||
1 | /* | ||
2 | =. This file is part of the Opie Project | ||
3 | .=l. Copyright (C) 2004 Opie Team <opie-devel@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | /* OPIE */ | ||
30 | #include <opie2/osqlmanager.h> | ||
31 | #include <opie2/osqlquery.h> | ||
32 | #include <opie2/osqldriver.h> | ||
33 | #include <opie2/osqlresult.h> | ||
34 | #include <opie2/odebug.h> | ||
35 | |||
36 | #include <qpe/qpeapplication.h> | ||
37 | |||
38 | /* QT */ | ||
39 | #include <qdir.h> | ||
40 | |||
41 | using namespace Opie::DB; | ||
42 | int main( int argc, char* argv[] ) { | ||
43 | |||
44 | QPEApplication app( argc, argv ); | ||
45 | OSQLManager man; | ||
46 | man.registerPath( QDir::currentDirPath() ); | ||
47 | OSQLBackEnd::ValueList list = man.queryBackEnd(); | ||
48 | |||
49 | OSQLDriver *driver = man.standard(); | ||
50 | owarn << "testmain" + driver->id() << oendl; | ||
51 | driver->setUrl("/home/ich/test2vhgytry"); | ||
52 | if ( driver->open() ) { | ||
53 | owarn << "could open" << oendl; | ||
54 | }else | ||
55 | owarn << "wasn't able to open" << oendl; | ||
56 | OSQLRawQuery raw("select * from t2" ); | ||
57 | OSQLResult res = driver->query( &raw ); | ||
58 | |||
59 | OSQLRawQuery raw2( "insert into t2 VALUES(ROWID,'Meine Mutter') "); | ||
60 | res = driver->query(&raw2); | ||
61 | |||
62 | }; | ||
diff --git a/examples/opiedb/sqltest/spaltenweise.cpp b/examples/opiedb/sqltest/spaltenweise.cpp new file mode 100644 index 0000000..c11724c --- a/dev/null +++ b/examples/opiedb/sqltest/spaltenweise.cpp | |||
@@ -0,0 +1,43 @@ | |||
1 | #include <qdir.h> | ||
2 | |||
3 | #include <qpe/qpeapplication.h> | ||
4 | #include <opie2/osqlmanager.h> | ||
5 | #include <opie2/osqlquery.h> | ||
6 | #include <opie2/osqldriver.h> | ||
7 | #include <opie2/osqlresult.h> | ||
8 | |||
9 | using namespace Opie::DB; | ||
10 | |||
11 | int main( int argc, char* argv[] ) { | ||
12 | |||
13 | QPEApplication app( argc, argv ); | ||
14 | OSQLManager man; | ||
15 | man.registerPath( QDir::currentDirPath() ); | ||
16 | OSQLBackEnd::ValueList list = man.queryBackEnd(); | ||
17 | |||
18 | OSQLDriver *driver = man.standard(); | ||
19 | owarn << "testmain" + driver->id() << oendl; | ||
20 | driver->setUrl("/home/ich/spaltenweise"); | ||
21 | if ( driver->open() ) { | ||
22 | owarn << "could open" << oendl; | ||
23 | }else | ||
24 | owarn << "wasn't able to open" << oendl; | ||
25 | OSQLRawQuery *raw = new OSQLRawQuery("create table todolist(" | ||
26 | "uid,categories,completed," | ||
27 | "progress,summary,HasDate," | ||
28 | "DateDay,DateMonth,DateYear," | ||
29 | "priority,description)" ); | ||
30 | |||
31 | OSQLResult res = driver->query( raw ); | ||
32 | delete raw; | ||
33 | for (int i = 0; i< 10000; i++ ) { | ||
34 | int uid = i; | ||
35 | OSQLRawQuery raw("insert into todolist VALUES("+ | ||
36 | QString::number(uid)+ ",'-122324;-12132',1,100,"+ | ||
37 | "'Summary234-"+QString::number(uid)+"',1,5,8,2002,1,"+ | ||
38 | "'Description\n12344')"); | ||
39 | OSQLResult res = driver->query( &raw ); | ||
40 | |||
41 | } | ||
42 | return 0; | ||
43 | }; | ||
diff --git a/examples/opiedb/sqltest/spaltenweise.pro b/examples/opiedb/sqltest/spaltenweise.pro new file mode 100644 index 0000000..0335d16 --- a/dev/null +++ b/examples/opiedb/sqltest/spaltenweise.pro | |||
@@ -0,0 +1,13 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG = qt warn_on | ||
3 | HEADERS = | ||
4 | SOURCES = spaltenweise.cpp | ||
5 | INCLUDEPATH += $(OPIEDIR)/include | ||
6 | DEPENDPATH+= $(OPIEDIR)/include | ||
7 | LIBS += -lqpe -lopiedb2 | ||
8 | TARGET = spaltenweise | ||
9 | |||
10 | |||
11 | |||
12 | |||
13 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/examples/opiedb/sqltest/sqltest.pro b/examples/opiedb/sqltest/sqltest.pro new file mode 100644 index 0000000..a4eee6b --- a/dev/null +++ b/examples/opiedb/sqltest/sqltest.pro | |||
@@ -0,0 +1,17 @@ | |||
1 | TEMPLATE = app | ||
2 | CONFIG = qt warn_on | ||
3 | HEADERS = | ||
4 | SOURCES = main.cpp | ||
5 | INCLUDEPATH += $(OPIEDIR)/include | ||
6 | DEPENDPATH += $(OPIEDIR)/include | ||
7 | LIBS += -lqpe -lopiedb2 -lsqlite3 | ||
8 | TARGET = sqltest | ||
9 | |||
10 | include( $(OPIEDIR)/include.pro ) | ||
11 | |||
12 | !isEmpty( LIBSQLITE_INC_DIR ) { | ||
13 | INCLUDEPATH = $$LIBSQLITE_INC_DIR $$INCLUDEPATH | ||
14 | } | ||
15 | !isEmpty( LIBSQLITE_LIB_DIR ) { | ||
16 | LIBS = -L$$LIBSQLITE_LIB_DIR $$LIBS | ||
17 | } | ||
diff --git a/examples/opiedb/sqltest/test.osql b/examples/opiedb/sqltest/test.osql new file mode 100644 index 0000000..340e4f2 --- a/dev/null +++ b/examples/opiedb/sqltest/test.osql | |||
@@ -0,0 +1,4 @@ | |||
1 | Name = Test1 | ||
2 | Vendor = Zecke | ||
3 | License = ZPL | ||
4 | Preference = 15 | ||
diff --git a/examples/opiedb/sqltest/test2.osql b/examples/opiedb/sqltest/test2.osql new file mode 100644 index 0000000..952c99b --- a/dev/null +++ b/examples/opiedb/sqltest/test2.osql | |||
@@ -0,0 +1,5 @@ | |||
1 | Name = Test2 | ||
2 | Vendor = Schaf | ||
3 | License = SPL | ||
4 | Preference = 15 | ||
5 | Default = 0 | ||
diff --git a/examples/opiedb/sqltest/zeilenweise.cpp b/examples/opiedb/sqltest/zeilenweise.cpp new file mode 100644 index 0000000..126e797 --- a/dev/null +++ b/examples/opiedb/sqltest/zeilenweise.cpp | |||
@@ -0,0 +1,86 @@ | |||
1 | #include <qdir.h> | ||
2 | |||
3 | #include <qpe/qpeapplication.h> | ||
4 | #include <opie2/osqlmanager.h> | ||
5 | #include <opie2/osqlquery.h> | ||
6 | #include <opie2/osqldriver.h> | ||
7 | #include <opie2/osqlresult.h> | ||
8 | |||
9 | using namespace Opie::DB; | ||
10 | |||
11 | int main( int argc, char* argv[] ) { | ||
12 | |||
13 | QPEApplication app( argc, argv ); | ||
14 | OSQLManager man; | ||
15 | man.registerPath( QDir::currentDirPath() ); | ||
16 | OSQLBackEnd::ValueList list = man.queryBackEnd(); | ||
17 | |||
18 | OSQLDriver *driver = man.standard(); | ||
19 | owarn << "testmain" + driver->id() << oendl; | ||
20 | driver->setUrl("/home/ich/zeilenweise"); | ||
21 | if ( driver->open() ) { | ||
22 | owarn << "could open" << oendl; | ||
23 | }else | ||
24 | owarn << "wasn't able to open" << oendl; | ||
25 | OSQLRawQuery raw2("BEGIN TRANSACTION"); | ||
26 | OSQLRawQuery *raw = new OSQLRawQuery("create table todolist(uid,key,value)"); | ||
27 | OSQLResult res = driver->query( &raw2 ); | ||
28 | res = driver->query( raw ); | ||
29 | delete raw; | ||
30 | for (int i = 0; i< 10000; i++ ) { | ||
31 | int uid = i; | ||
32 | OSQLRawQuery *raw; | ||
33 | raw = new OSQLRawQuery("insert into todolist VALUES("+QString::number(uid)+",'Categories',"+"'-122324;-12132')"); | ||
34 | OSQLResult res = driver->query(raw ); | ||
35 | delete raw; | ||
36 | |||
37 | raw = new OSQLRawQuery("insert into todolist VALUES("+QString::number(uid) + | ||
38 | ",'Completed',1)" ); | ||
39 | res = driver->query(raw ); | ||
40 | delete raw; | ||
41 | |||
42 | raw = new OSQLRawQuery("insert into todolist VALUES("+ | ||
43 | QString::number(uid)+",'Progress',100)" ); | ||
44 | res = driver->query( raw ); | ||
45 | delete raw; | ||
46 | |||
47 | raw = new OSQLRawQuery("insert into todolist VALUES("+ | ||
48 | QString::number(uid)+",'Summary',"+ | ||
49 | "'Summary234-"+ QString::number(uid) + "')"); | ||
50 | res = driver->query( raw ); | ||
51 | delete raw; | ||
52 | |||
53 | raw = new OSQLRawQuery("insert into todolist VALUES("+ | ||
54 | QString::number(uid)+",'HasDate',1)"); | ||
55 | res = driver->query( raw ); | ||
56 | delete raw; | ||
57 | |||
58 | raw = new OSQLRawQuery("insert into todolist VALUES("+ | ||
59 | QString::number(uid)+",'DateDay',5)"); | ||
60 | res = driver->query( raw ); | ||
61 | delete raw; | ||
62 | |||
63 | raw = new OSQLRawQuery("insert into todolist VALUES("+ | ||
64 | QString::number(uid)+",'DateMonth',8)"); | ||
65 | res = driver->query( raw ); | ||
66 | delete raw; | ||
67 | |||
68 | raw = new OSQLRawQuery("insert into todolist VALUES("+ | ||
69 | QString::number(uid)+",'DateYear',2002)"); | ||
70 | res = driver->query( raw ); | ||
71 | delete raw; | ||
72 | |||
73 | raw = new OSQLRawQuery("insert into todolist VALUES("+ | ||
74 | QString::number(uid)+",'Priority',1)"); | ||
75 | res = driver->query( raw ); | ||
76 | delete raw; | ||
77 | |||
78 | raw = new OSQLRawQuery("insert into todolist VALUES("+ | ||
79 | QString::number(uid)+",'Description','" + | ||
80 | QString::number(uid) + "Description\n12344')"); | ||
81 | res = driver->query( raw ); | ||
82 | delete raw; | ||
83 | } | ||
84 | OSQLRawQuery raw3("COMMIT"); | ||
85 | res = driver->query(&raw3 ); | ||
86 | }; | ||
diff --git a/examples/opiedb/sqltest/zeilenweise.pro b/examples/opiedb/sqltest/zeilenweise.pro new file mode 100644 index 0000000..1fa17cd --- a/dev/null +++ b/examples/opiedb/sqltest/zeilenweise.pro | |||
@@ -0,0 +1,13 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG = qt warn_on | ||
3 | HEADERS = | ||
4 | SOURCES = zeilenweise.cpp | ||
5 | INCLUDEPATH += $(OPIEDIR)/include | ||
6 | DEPENDPATH+= $(OPIEDIR)/include | ||
7 | LIBS += -lqpe -lopiedb2 | ||
8 | TARGET = zeilenweise | ||
9 | |||
10 | |||
11 | |||
12 | |||
13 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/examples/opiemm/.cvsignore b/examples/opiemm/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/examples/opiemm/.cvsignore | |||
@@ -0,0 +1,6 @@ | |||
1 | Makefile* | ||
2 | moc* | ||
3 | *moc | ||
4 | *.o | ||
5 | ~* | ||
6 | |||
diff --git a/examples/opienet/.cvsignore b/examples/opienet/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/examples/opienet/.cvsignore | |||
@@ -0,0 +1,6 @@ | |||
1 | Makefile* | ||
2 | moc* | ||
3 | *moc | ||
4 | *.o | ||
5 | ~* | ||
6 | |||
diff --git a/examples/opienet/miniwellenreiter/.cvsignore b/examples/opienet/miniwellenreiter/.cvsignore new file mode 100644 index 0000000..e0e629a --- a/dev/null +++ b/examples/opienet/miniwellenreiter/.cvsignore | |||
@@ -0,0 +1,8 @@ | |||
1 | miniwellenreiter | ||
2 | Makefile* | ||
3 | obj | ||
4 | moc* | ||
5 | *moc | ||
6 | *.o | ||
7 | ~* | ||
8 | |||
diff --git a/examples/opienet/miniwellenreiter/miniwellenreiter.cpp b/examples/opienet/miniwellenreiter/miniwellenreiter.cpp new file mode 100644 index 0000000..ebd3b5f --- a/dev/null +++ b/examples/opienet/miniwellenreiter/miniwellenreiter.cpp | |||
@@ -0,0 +1,234 @@ | |||
1 | #include <qdict.h> | ||
2 | #include <qsocketnotifier.h> | ||
3 | #include <qstring.h> | ||
4 | #include <opie2/onetwork.h> | ||
5 | #include <qapplication.h> | ||
6 | #include <opie2/opcap.h> | ||
7 | #include <cerrno> | ||
8 | #include <cstdio> | ||
9 | #include <cstdlib> | ||
10 | #include <cstring> | ||
11 | |||
12 | |||
13 | using namespace Opie::Net; | ||
14 | //======================== Station help class =============================== | ||
15 | |||
16 | class Station | ||
17 | { | ||
18 | public: | ||
19 | Station( QString t, int c, bool w ) : type(t), channel(c), wep(w), beacons(1) {}; | ||
20 | ~Station() {}; | ||
21 | |||
22 | QString type; | ||
23 | int channel; | ||
24 | bool wep; | ||
25 | int beacons; | ||
26 | }; | ||
27 | |||
28 | QDict<Station> stations; | ||
29 | |||
30 | //======================== Application class =============================== | ||
31 | |||
32 | class Wellenreiter : public QApplication | ||
33 | { | ||
34 | Q_OBJECT | ||
35 | public: | ||
36 | Wellenreiter( int argc, char** argv ) : QApplication( argc, argv ), channel( 1 ) | ||
37 | { | ||
38 | |||
39 | ONetwork* net = ONetwork::instance(); | ||
40 | |||
41 | if ( argc < 3 ) | ||
42 | { | ||
43 | printf( "Usage: ./%s <interface> <driver> <interval>\n", argv[0] ); | ||
44 | printf( "\n" ); | ||
45 | printf( "Valid wireless interfaces (detected) are:\n" ); | ||
46 | |||
47 | ONetwork::InterfaceIterator it = net->iterator(); | ||
48 | while ( it.current() ) | ||
49 | { | ||
50 | if ( it.current()->isWireless() ) | ||
51 | { | ||
52 | printf( " - '%s' (MAC=%s) (IPv4=%s)\n", (const char*) it.current()->name(), | ||
53 | (const char*) it.current()->macAddress().toString(), | ||
54 | (const char*) it.current()->ipV4Address() ); | ||
55 | } | ||
56 | ++it; | ||
57 | } | ||
58 | exit( -1 ); | ||
59 | } | ||
60 | |||
61 | printf( "*******************************************************************\n" ); | ||
62 | printf( "* Wellenreiter mini edition 1.0.0 (C) 2003 Michael 'Mickey' Lauer *\n" ); | ||
63 | printf( "*******************************************************************\n" ); | ||
64 | printf( "\n\n" ); | ||
65 | |||
66 | QString interface( argv[1] ); | ||
67 | QString driver( argv[2] ); | ||
68 | |||
69 | printf( "Trying to use '%s' as %s-controlled device...\n", (const char*) interface, (const char*) driver ); | ||
70 | |||
71 | // sanity checks before downcasting | ||
72 | ONetworkInterface* iface = net->interface( interface ); | ||
73 | if ( !iface ) | ||
74 | { | ||
75 | printf( "Interface '%s' doesn't exist. Exiting.\n", (const char*) interface ); | ||
76 | exit( -1 ); | ||
77 | } | ||
78 | if ( !iface->isWireless() ) | ||
79 | { | ||
80 | printf( "Interface '%s' doesn't support wireless extensions. Exiting.\n", (const char*) interface ); | ||
81 | exit( -1 ); | ||
82 | } | ||
83 | |||
84 | // downcast should be safe now | ||
85 | wiface = (OWirelessNetworkInterface*) iface; | ||
86 | printf( "Using wireless interface '%s' for scanning (current SSID is '%s')...\n", (const char*) interface, (const char*) wiface->SSID() ); | ||
87 | |||
88 | // ifconfig +promisc the interface to receive all packets | ||
89 | if ( !wiface->promiscuousMode() ) | ||
90 | { | ||
91 | printf( "Interface status is not promisc... switching to promisc... " ); | ||
92 | wiface->setPromiscuousMode( true ); | ||
93 | if ( !wiface->promiscuousMode() ) | ||
94 | { | ||
95 | printf( "failed (%s). Exiting.\n", strerror( errno ) ); | ||
96 | exit( -1 ); | ||
97 | } | ||
98 | else | ||
99 | { | ||
100 | printf( "ok.\n" ); | ||
101 | } | ||
102 | } | ||
103 | else | ||
104 | printf( "Interface status is already promisc - good.\n" ); | ||
105 | |||
106 | // connect a monitoring strategy to the interface | ||
107 | if ( driver == "orinoco" ) | ||
108 | new OOrinocoMonitoringInterface( wiface, false ); | ||
109 | else | ||
110 | if ( driver == "hostap" ) | ||
111 | new OHostAPMonitoringInterface( wiface, false ); | ||
112 | else | ||
113 | if ( driver == "wlan-ng" ) | ||
114 | new OWlanNGMonitoringInterface( wiface, false ); | ||
115 | else | ||
116 | { | ||
117 | printf( "Unknown driver. Exiting\n" ); | ||
118 | exit( -1 ); | ||
119 | } | ||
120 | |||
121 | // enable monitoring mode | ||
122 | printf( "Enabling monitor mode...\n" ); | ||
123 | wiface->setMode( "monitor" ); | ||
124 | |||
125 | // open a packet capturer | ||
126 | cap = new OPacketCapturer(); | ||
127 | cap->open( interface ); | ||
128 | if ( !cap->isOpen() ) | ||
129 | { | ||
130 | printf( "Unable to open libpcap (%s). Exiting.\n", strerror( errno ) ); | ||
131 | exit( -1 ); | ||
132 | } | ||
133 | |||
134 | // set capturer to non-blocking mode | ||
135 | cap->setBlocking( false ); | ||
136 | |||
137 | // start channel hopper | ||
138 | //wiface->setChannelHopping( 1000 ); | ||
139 | |||
140 | // connect | ||
141 | connect( cap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | ||
142 | // timer | ||
143 | startTimer( 1000 ); | ||
144 | |||
145 | } | ||
146 | |||
147 | ~Wellenreiter() {}; | ||
148 | |||
149 | public slots: | ||
150 | virtual void timerEvent(QTimerEvent* e) | ||
151 | { | ||
152 | wiface->setChannel( channel++ ); | ||
153 | if ( channel == 14 ) channel = 1; | ||
154 | } | ||
155 | |||
156 | void receivePacket(OPacket* p) | ||
157 | { | ||
158 | if (!p) | ||
159 | { | ||
160 | printf( "(empty packet received)\n" ); | ||
161 | return; | ||
162 | } | ||
163 | |||
164 | OWaveLanManagementPacket* beacon = (OWaveLanManagementPacket*) p->child( "802.11 Management" ); | ||
165 | if ( beacon ) | ||
166 | { | ||
167 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | ||
168 | QString essid = ssid ? ssid->ID() : QString::fromLatin1( "<unknown>" ); | ||
169 | |||
170 | if ( stations.find( essid ) ) | ||
171 | stations[essid]->beacons++; | ||
172 | else | ||
173 | { | ||
174 | printf( "found new network @ channel %d, SSID = '%s'\n", wiface->channel(), (const char*) essid ); | ||
175 | stations.insert( essid, new Station( "unknown", wiface->channel(), | ||
176 | ((OWaveLanPacket*) beacon->parent())->usesWep() ) ); | ||
177 | } | ||
178 | return; | ||
179 | } | ||
180 | |||
181 | OWaveLanDataPacket* data = (OWaveLanDataPacket*) p->child( "802.11 Data" ); | ||
182 | if ( data ) | ||
183 | { | ||
184 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | ||
185 | if ( wlan->fromDS() && !wlan->toDS() ) | ||
186 | { | ||
187 | printf( "FromDS: '%s' -> '%s' via '%s'\n", | ||
188 | (const char*) wlan->macAddress3().toString(true), | ||
189 | (const char*) wlan->macAddress1().toString(true), | ||
190 | (const char*) wlan->macAddress2().toString(true) ); | ||
191 | } | ||
192 | else | ||
193 | if ( !wlan->fromDS() && wlan->toDS() ) | ||
194 | { | ||
195 | printf( "ToDS: '%s' -> '%s' via '%s'\n", | ||
196 | (const char*) wlan->macAddress2().toString(true), | ||
197 | (const char*) wlan->macAddress3().toString(true), | ||
198 | (const char*) wlan->macAddress1().toString(true) ); | ||
199 | } | ||
200 | else | ||
201 | if ( wlan->fromDS() && wlan->toDS() ) | ||
202 | { | ||
203 | printf( "WSD(bridge): '%s' -> '%s' via '%s' and '%s'\n", | ||
204 | (const char*) wlan->macAddress4().toString(true), | ||
205 | (const char*) wlan->macAddress3().toString(true), | ||
206 | (const char*) wlan->macAddress1().toString(true), | ||
207 | (const char*) wlan->macAddress2().toString(true) ); | ||
208 | } | ||
209 | else | ||
210 | { | ||
211 | printf( "IBSS(AdHoc): '%s' -> '%s' (Cell: '%s')'\n", | ||
212 | (const char*) wlan->macAddress2().toString(true), | ||
213 | (const char*) wlan->macAddress1().toString(true), | ||
214 | (const char*) wlan->macAddress3().toString(true) ); | ||
215 | } | ||
216 | return; | ||
217 | } | ||
218 | } | ||
219 | private: | ||
220 | OPacketCapturer* cap; | ||
221 | OWirelessNetworkInterface* wiface; | ||
222 | int channel; | ||
223 | }; | ||
224 | |||
225 | |||
226 | int main( int argc, char** argv ) | ||
227 | { | ||
228 | Wellenreiter w( argc, argv ); | ||
229 | w.exec(); | ||
230 | return 0; | ||
231 | } | ||
232 | |||
233 | #include "miniwellenreiter.moc" | ||
234 | |||
diff --git a/examples/opienet/miniwellenreiter/miniwellenreiter.pro b/examples/opienet/miniwellenreiter/miniwellenreiter.pro new file mode 100644 index 0000000..d7c1fc2 --- a/dev/null +++ b/examples/opienet/miniwellenreiter/miniwellenreiter.pro | |||
@@ -0,0 +1,19 @@ | |||
1 | TEMPLATE = app | ||
2 | CONFIG = qt warn_on | ||
3 | HEADERS = | ||
4 | SOURCES = miniwellenreiter.cpp | ||
5 | INCLUDEPATH += $(OPIEDIR)/include | ||
6 | DEPENDPATH += $(OPIEDIR)/include | ||
7 | LIBS += -lopiecore2 -lopienet2 | ||
8 | TARGET = miniwellenreiter | ||
9 | MOC_DIR = moc | ||
10 | OBJECTS_DIR = obj | ||
11 | |||
12 | include( $(OPIEDIR)/include.pro ) | ||
13 | |||
14 | !isEmpty( LIBPCAP_INC_DIR ) { | ||
15 | INCLUDEPATH = $$LIBPCAP_INC_DIR $$INCLUDEPATH | ||
16 | } | ||
17 | !isEmpty( LIBPCAP_LIB_DIR ) { | ||
18 | LIBS = -L$$LIBPCAP_LIB_DIR $$LIBS | ||
19 | } | ||
diff --git a/examples/opienet/onetworkdemo/.cvsignore b/examples/opienet/onetworkdemo/.cvsignore new file mode 100644 index 0000000..c2638e5 --- a/dev/null +++ b/examples/opienet/onetworkdemo/.cvsignore | |||
@@ -0,0 +1,8 @@ | |||
1 | onetworkdemo | ||
2 | Makefile* | ||
3 | obj | ||
4 | moc* | ||
5 | *moc | ||
6 | *.o | ||
7 | ~* | ||
8 | |||
diff --git a/examples/opienet/onetworkdemo/onetworkdemo.cpp b/examples/opienet/onetworkdemo/onetworkdemo.cpp new file mode 100644 index 0000000..e0c93a2 --- a/dev/null +++ b/examples/opienet/onetworkdemo/onetworkdemo.cpp | |||
@@ -0,0 +1,176 @@ | |||
1 | /* | ||
2 | =. This file is part of the Opie Project | ||
3 | .=l. Copyright (C) 2004 Opie Team <opie-devel@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | /* OPIE */ | ||
30 | #include <opie2/onetwork.h> | ||
31 | #include <opie2/ostation.h> | ||
32 | #include <opie2/omanufacturerdb.h> | ||
33 | #include <opie2/odebug.h> | ||
34 | |||
35 | /* STD */ | ||
36 | #include <unistd.h> | ||
37 | |||
38 | using namespace Opie::Net; | ||
39 | |||
40 | int main( int argc, char** argv ) | ||
41 | { | ||
42 | odebug << "OPIE Network Demo" << oendl; | ||
43 | |||
44 | ONetwork* net = ONetwork::instance(); | ||
45 | |||
46 | ONetwork::InterfaceIterator it = net->iterator(); | ||
47 | |||
48 | while ( it.current() ) | ||
49 | { | ||
50 | odebug << "DEMO: ONetwork contains Interface '" << it.current()->name() << "'" << oendl; | ||
51 | odebug << "DEMO: Datalink code is '" << it.current()->dataLinkType() << "'" << oendl; | ||
52 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString() << "'" << oendl; | ||
53 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString(true) << "'" << oendl; | ||
54 | odebug << "DEMO: MAC Manufacturer seems to be '" << it.current()->macAddress().manufacturer() << "'" << oendl; | ||
55 | odebug << "DEMO: Manufacturertest1 = '" << OManufacturerDB::instance()->lookupExt( "08:00:87" ) << "'" << oendl; | ||
56 | odebug << "DEMO: Manufacturertest2 = '" << OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) << "'" << oendl; | ||
57 | odebug << "Demo: IPv4 Address is '" << it.current()->ipV4Address() << "'" << oendl; | ||
58 | if ( it.current()->isWireless() ) | ||
59 | { | ||
60 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); | ||
61 | odebug << "DEMO: '" << iface->name() << "' seems to feature the wireless extensions." << oendl; | ||
62 | odebug << "DEMO: Current SSID is '" << iface->SSID() << "'" << oendl; | ||
63 | odebug << "DEMO: Antenna is tuned to '" << iface->frequency() << "', that is channel " << iface->channel() << "" << oendl; | ||
64 | |||
65 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) | ||
66 | //{ | ||
67 | //odebug << "DEMO: Associated AP has MAC Address '" << iface->associatedAP().toString() << "'" << oendl; | ||
68 | //} | ||
69 | |||
70 | /* | ||
71 | |||
72 | // nickname | ||
73 | odebug << "DEMO: Current NickName is '" << iface->nickName() << "'" << oendl; | ||
74 | iface->setNickName( "MyNickName" ); | ||
75 | if ( iface->nickName() != "MyNickName" ) | ||
76 | odebug << "DEMO: Warning! Can't change nickname" << oendl; | ||
77 | else | ||
78 | odebug << "DEMO: Nickname change successful." << oendl; | ||
79 | |||
80 | /* | ||
81 | |||
82 | // operation mode | ||
83 | odebug << "DEMO: Current OperationMode is '" << iface->mode() << "'" << oendl; | ||
84 | iface->setMode( "adhoc" ); | ||
85 | if ( iface->mode() != "adhoc" ) | ||
86 | odebug << "DEMO: Warning! Can't change operation mode" << oendl; | ||
87 | else | ||
88 | odebug << "DEMO: Operation Mode change successful." << oendl; | ||
89 | |||
90 | // RF channel | ||
91 | odebug << "DEMO: Current Channel is '" << iface->channel() << "'" << oendl; | ||
92 | iface->setChannel( 1 ); | ||
93 | if ( iface->channel() != 1 ) | ||
94 | odebug << "DEMO: Warning! Can't change RF channel" << oendl; | ||
95 | else | ||
96 | odebug << "DEMO: RF channel change successful." << oendl; | ||
97 | |||
98 | iface->setMode( "managed" ); | ||
99 | |||
100 | */ | ||
101 | |||
102 | /* | ||
103 | |||
104 | // network scan | ||
105 | |||
106 | OStationList* stations = iface->scanNetwork(); | ||
107 | if ( stations ) | ||
108 | { | ||
109 | odebug << "DEMO: # of stations around = " << stations->count() << "" << oendl; | ||
110 | OStation* station; | ||
111 | for ( station = stations->first(); station != 0; station = stations->next() ) | ||
112 | { | ||
113 | odebug << "DEMO: station dump following..." << oendl; | ||
114 | station->dump(); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | else | ||
119 | { | ||
120 | odebug << "DEMO: Warning! Scan didn't work!" << oendl; | ||
121 | } | ||
122 | |||
123 | /* | ||
124 | |||
125 | // first some wrong calls to check if this is working | ||
126 | iface->setPrivate( "seppel", 10 ); | ||
127 | iface->setPrivate( "monitor", 0 ); | ||
128 | |||
129 | // now the real deal | ||
130 | iface->setPrivate( "monitor", 2, 2, 3 ); | ||
131 | |||
132 | // trying to set hw address to 12:34:56:AB:CD:EF | ||
133 | |||
134 | /* | ||
135 | |||
136 | OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); | ||
137 | iface->setUp( false ); | ||
138 | iface->setMacAddress( addr ); | ||
139 | iface->setUp( true ); | ||
140 | odebug << "DEMO: MAC Address now is '" << iface->macAddress().toString() << "'" << oendl; | ||
141 | |||
142 | */ | ||
143 | |||
144 | // monitor test | ||
145 | |||
146 | |||
147 | |||
148 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | ||
149 | iface->setMode( "monitor" ); | ||
150 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | ||
151 | |||
152 | sleep( 1 ); | ||
153 | |||
154 | iface->setChannel( 1 ); | ||
155 | iface->setMode( "managed" ); | ||
156 | |||
157 | //sleep( 1 ); | ||
158 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | ||
159 | |||
160 | /*iface->setMode( "adhoc" ); | ||
161 | sleep( 1 ); | ||
162 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | ||
163 | iface->setMode( "managed" ); | ||
164 | sleep( 1 ); | ||
165 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | ||
166 | iface->setMode( "master" ); | ||
167 | sleep( 1 ); | ||
168 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; */ | ||
169 | |||
170 | } | ||
171 | ++it; | ||
172 | } | ||
173 | |||
174 | return 0; | ||
175 | |||
176 | } | ||
diff --git a/examples/opienet/onetworkdemo/onetworkdemo.pro b/examples/opienet/onetworkdemo/onetworkdemo.pro new file mode 100644 index 0000000..cf293b5 --- a/dev/null +++ b/examples/opienet/onetworkdemo/onetworkdemo.pro | |||
@@ -0,0 +1,12 @@ | |||
1 | TEMPLATE = app | ||
2 | CONFIG = qt warn_on | ||
3 | HEADERS = | ||
4 | SOURCES = onetworkdemo.cpp | ||
5 | INCLUDEPATH += $(OPIEDIR)/include | ||
6 | DEPENDPATH += $(OPIEDIR)/include | ||
7 | LIBS += -lopiecore2 -lopienet2 | ||
8 | TARGET = onetworkdemo | ||
9 | MOC_DIR = moc | ||
10 | OBJECTS_DIR = obj | ||
11 | |||
12 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/examples/opienet/opienet.pro b/examples/opienet/opienet.pro new file mode 100644 index 0000000..c7800a9 --- a/dev/null +++ b/examples/opienet/opienet.pro | |||
@@ -0,0 +1,3 @@ | |||
1 | TEMPLATE = subdirs | ||
2 | SUBDIRS = miniwellenreiter onetworkdemo | ||
3 | |||
diff --git a/examples/opieui/.cvsignore b/examples/opieui/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/examples/opieui/.cvsignore | |||
@@ -0,0 +1,6 @@ | |||
1 | Makefile* | ||
2 | moc* | ||
3 | *moc | ||
4 | *.o | ||
5 | ~* | ||
6 | |||