summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager
Unidiff
Diffstat (limited to 'noncore/net/opietooth/manager') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/devicehandler.cpp89
-rw-r--r--noncore/net/opietooth/manager/devicehandler.h41
-rw-r--r--noncore/net/opietooth/manager/manager.pro4
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>
7using namespace Opie::Core;
8
9#include "devicehandler.h"
10
11using namespace OpieTooth;
12
13DeviceHandler::DeviceHandler() {
14
15};
16DeviceHandler::~DeviceHandler() {
17
18}
19
20RemoteDevice::ValueList DeviceHandler::load() {
21 RemoteDevice::ValueList list;
22QString 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 */
57void 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
9namespace 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
@@ -9,3 +9,3 @@ HEADERS = btconnectionitem.h btdeviceitem.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 \
@@ -20,3 +20,3 @@ SOURCES = btconnectionitem.cpp btdeviceitem.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 \