author | korovkin <korovkin> | 2006-11-10 20:53:23 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-11-10 20:53:23 (UTC) |
commit | b06913999f349254ba1c6e182950cb71d0b7aa67 (patch) (unidiff) | |
tree | b91b3ad0745e9e471b244ca56456af56ba1e69a9 /noncore/net/opietooth/manager | |
parent | 961e5561b24452d9cfc2bf7400f6f5952b31431c (diff) | |
download | opie-b06913999f349254ba1c6e182950cb71d0b7aa67.zip opie-b06913999f349254ba1c6e182950cb71d0b7aa67.tar.gz opie-b06913999f349254ba1c6e182950cb71d0b7aa67.tar.bz2 |
Files devicehandler.cpp and devicehandler.h moved from manager to
library to be used by obex to load a list of saved receivers.
-rw-r--r-- | noncore/net/opietooth/manager/devicehandler.cpp | 89 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/devicehandler.h | 41 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/manager.pro | 4 |
3 files changed, 2 insertions, 132 deletions
diff --git a/noncore/net/opietooth/manager/devicehandler.cpp b/noncore/net/opietooth/manager/devicehandler.cpp deleted file mode 100644 index 320ad44..0000000 --- a/noncore/net/opietooth/manager/devicehandler.cpp +++ b/dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | |||
2 | #include <stdlib.h> | ||
3 | |||
4 | #include <qdir.h> | ||
5 | #include <qpe/config.h> | ||
6 | #include <opie2/odebug.h> | ||
7 | using namespace Opie::Core; | ||
8 | |||
9 | #include "devicehandler.h" | ||
10 | |||
11 | using namespace OpieTooth; | ||
12 | |||
13 | DeviceHandler::DeviceHandler() { | ||
14 | |||
15 | }; | ||
16 | DeviceHandler::~DeviceHandler() { | ||
17 | |||
18 | } | ||
19 | |||
20 | RemoteDevice::ValueList DeviceHandler::load() { | ||
21 | RemoteDevice::ValueList list; | ||
22 | QString path = QDir::homeDirPath() + "/Settings/bluetooth"; | ||
23 | QDir deviceListSave( path); | ||
24 | |||
25 | // list of .conf files | ||
26 | QStringList devicesFileList = deviceListSave.entryList(); | ||
27 | |||
28 | |||
29 | // cut .conf of to get the mac and also read the name entry in it. | ||
30 | if (!devicesFileList.isEmpty() ) { | ||
31 | QString name; | ||
32 | QString mac; | ||
33 | QStringList::Iterator it; | ||
34 | for (it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) { | ||
35 | if ( (*it) == "." || (*it) == ".." ) | ||
36 | continue; | ||
37 | |||
38 | odebug << (*it).latin1() << oendl; | ||
39 | Config conf(path + "/"+(*it), Config::File); | ||
40 | conf.setGroup("Info"); | ||
41 | name = conf.readEntry("name", "Error"); | ||
42 | mac = conf.readEntry("mac", QString::null); | ||
43 | odebug << "MAC: " + mac << oendl; | ||
44 | odebug << "NAME: " + name << oendl; | ||
45 | if (mac.isEmpty() ) | ||
46 | continue; | ||
47 | RemoteDevice currentDevice( mac , name ); | ||
48 | list.append( currentDevice ); | ||
49 | } | ||
50 | } | ||
51 | return list; | ||
52 | }; | ||
53 | /* | ||
54 | * This is some how rude but make sure all old devices | ||
55 | * are getting deleted | ||
56 | */ | ||
57 | void DeviceHandler::save( const RemoteDevice::ValueList& list) { | ||
58 | QCString rm; | ||
59 | rm += "rm -rf "; | ||
60 | rm += QDir::homeDirPath() + "/Settings/bluetooth"; | ||
61 | system ( rm.data() ); | ||
62 | |||
63 | if (list.isEmpty() ) // no need to create the dir | ||
64 | return; | ||
65 | |||
66 | /** | ||
67 | * Create a new dir | ||
68 | */ | ||
69 | rm = "mkdir "; | ||
70 | rm += QDir::homeDirPath() + "/Settings/bluetooth"; | ||
71 | owarn << "out " << rm.data() << "" << oendl; | ||
72 | system( rm.data() ); | ||
73 | |||
74 | RemoteDevice::ValueList::ConstIterator it; | ||
75 | // write the config | ||
76 | |||
77 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
78 | odebug << "/Settings/bluetooth/" + (*it).mac() + ".conf" << oendl; | ||
79 | |||
80 | Config conf( QDir::homeDirPath() + | ||
81 | "/Settings/bluetooth/" + | ||
82 | (*it).mac() + ".conf", Config::File ); | ||
83 | |||
84 | conf.setGroup( "Info" ); | ||
85 | conf.writeEntry( "name", (*it).name() ); | ||
86 | conf.writeEntry( "mac", (*it).mac() ); | ||
87 | } | ||
88 | |||
89 | } | ||
diff --git a/noncore/net/opietooth/manager/devicehandler.h b/noncore/net/opietooth/manager/devicehandler.h deleted file mode 100644 index 5cfe048..0000000 --- a/noncore/net/opietooth/manager/devicehandler.h +++ b/dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | |||
2 | #ifndef OPIE_TOOTH_DEVICE_HANDLER_H | ||
3 | #define OPIE_TOOTH_DEVICE_HANDLER_H | ||
4 | |||
5 | #include <qvaluelist.h> | ||
6 | |||
7 | #include <remotedevice.h> | ||
8 | |||
9 | namespace OpieTooth { | ||
10 | /** | ||
11 | * DeviceHandler is responsible for loading | ||
12 | * and saving devices from a config File | ||
13 | */ | ||
14 | class DeviceHandler { | ||
15 | public: | ||
16 | /** | ||
17 | * c'tor | ||
18 | */ | ||
19 | DeviceHandler(); | ||
20 | |||
21 | /** | ||
22 | * d'tor | ||
23 | */ | ||
24 | ~DeviceHandler(); | ||
25 | |||
26 | /** | ||
27 | * loads from $HOME/Settings/bluetooth/ * | ||
28 | */ | ||
29 | RemoteDevice::ValueList load(); | ||
30 | |||
31 | /** | ||
32 | * Saves to $HOME/Settings/bluetooth | ||
33 | */ | ||
34 | void save( const RemoteDevice::ValueList & ); | ||
35 | |||
36 | }; | ||
37 | |||
38 | |||
39 | }; | ||
40 | |||
41 | #endif | ||
diff --git a/noncore/net/opietooth/manager/manager.pro b/noncore/net/opietooth/manager/manager.pro index dc048c4..567932e 100644 --- a/noncore/net/opietooth/manager/manager.pro +++ b/noncore/net/opietooth/manager/manager.pro | |||
@@ -6,9 +6,9 @@ HEADERS = btconnectionitem.h btdeviceitem.h \ | |||
6 | hciconfwrapper.h bticonloader.h \ | 6 | hciconfwrapper.h bticonloader.h \ |
7 | pppdialog.h dundialog.h pandialog.h \ | 7 | pppdialog.h dundialog.h pandialog.h \ |
8 | obexdialog.h obexftpdialog.h \ | 8 | obexdialog.h obexftpdialog.h \ |
9 | rfcommassigndialogimpl.h rfcommassigndialogitem.h \ | 9 | rfcommassigndialogimpl.h rfcommassigndialogitem.h \ |
10 | devicehandler.h rfcpopup.h obexpopup.h obexftpopup.h \ | 10 | rfcpopup.h obexpopup.h obexftpopup.h \ |
11 | rfcommhelper.h panpopup.h dunpopup.h rfcommconfhandler.h \ | 11 | rfcommhelper.h panpopup.h dunpopup.h rfcommconfhandler.h \ |
12 | servicesdialog.h btconfhandler.h hidpopup.h | 12 | servicesdialog.h btconfhandler.h hidpopup.h |
13 | 13 | ||
14 | SOURCES = btconnectionitem.cpp btdeviceitem.cpp \ | 14 | SOURCES = btconnectionitem.cpp btdeviceitem.cpp \ |
@@ -17,9 +17,9 @@ SOURCES = btconnectionitem.cpp btdeviceitem.cpp \ | |||
17 | bluebase.cpp scandialog.cpp \ | 17 | bluebase.cpp scandialog.cpp \ |
18 | btlistitem.cpp hciconfwrapper.cpp \ | 18 | btlistitem.cpp hciconfwrapper.cpp \ |
19 | bticonloader.cpp pppdialog.cpp dundialog.cpp pandialog.cpp \ | 19 | bticonloader.cpp pppdialog.cpp dundialog.cpp pandialog.cpp \ |
20 | rfcommassigndialogimpl.cpp rfcommassigndialogitem.cpp \ | 20 | rfcommassigndialogimpl.cpp rfcommassigndialogitem.cpp \ |
21 | obexdialog.cpp devicehandler.cpp \ | 21 | obexdialog.cpp \ |
22 | rfcpopup.cpp obexpopup.cpp obexftpopup.cpp obexftpdialog.cpp \ | 22 | rfcpopup.cpp obexpopup.cpp obexftpopup.cpp obexftpdialog.cpp \ |
23 | rfcommhelper.cpp panpopup.cpp dunpopup.cpp rfcommconfhandler.cpp \ | 23 | rfcommhelper.cpp panpopup.cpp dunpopup.cpp rfcommconfhandler.cpp \ |
24 | servicesdialog.cpp btconfhandler.cpp hidpopup.cpp | 24 | servicesdialog.cpp btconfhandler.cpp hidpopup.cpp |
25 | INCLUDEPATH += $(OPIEDIR)/include | 25 | INCLUDEPATH += $(OPIEDIR)/include |