summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/devicehandler.cpp
authorzecke <zecke>2002-07-14 18:04:14 (UTC)
committer zecke <zecke>2002-07-14 18:04:14 (UTC)
commit26c7e63572e729b4846e4f7551bb041aa6d4bd83 (patch) (side-by-side diff)
tree5c3bc09142bd19e84fbebb88f2e37b02e6d603cd /noncore/net/opietooth/manager/devicehandler.cpp
parent31e233a6cf72bc853137ea05285f4d0f41665365 (diff)
downloadopie-26c7e63572e729b4846e4f7551bb041aa6d4bd83.zip
opie-26c7e63572e729b4846e4f7551bb041aa6d4bd83.tar.gz
opie-26c7e63572e729b4846e4f7551bb041aa6d4bd83.tar.bz2
- able to configure HCID
- able to save and restore known devices - able to scan servivces and shows the right pixmap too - able to do some more - scan dialog clean up ( tiny )
Diffstat (limited to 'noncore/net/opietooth/manager/devicehandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/devicehandler.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/noncore/net/opietooth/manager/devicehandler.cpp b/noncore/net/opietooth/manager/devicehandler.cpp
new file mode 100644
index 0000000..9c5b817
--- a/dev/null
+++ b/noncore/net/opietooth/manager/devicehandler.cpp
@@ -0,0 +1,87 @@
+
+#include <stdlib.h>
+
+#include <qdir.h>
+#include <qpe/config.h>
+
+#include "devicehandler.h"
+
+using namespace OpieTooth;
+
+DeviceHandler::DeviceHandler() {
+
+};
+DeviceHandler::~DeviceHandler() {
+
+}
+
+RemoteDevice::ValueList DeviceHandler::load() {
+ RemoteDevice::ValueList list;
+QString path = QDir::homeDirPath() + "/Settings/bluetooth";
+ QDir deviceListSave( path);
+
+ // list of .conf files
+ QStringList devicesFileList = deviceListSave.entryList();
+
+
+ // cut .conf of to get the mac and also read the name entry in it.
+ if (!devicesFileList.isEmpty() ) {
+ QString name;
+ QString mac;
+ QStringList::Iterator it;
+ for (it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) {
+ if ( (*it) == "." || (*it) == ".." )
+ continue;
+
+ qDebug((*it).latin1() );
+ Config conf(path + "/"+(*it), Config::File);
+ conf.setGroup("Info");
+ name = conf.readEntry("name", "Error");
+ mac = conf.readEntry("mac", QString::null);
+ qDebug("MAC: " + mac);
+ qDebug("NAME: " + name);
+ if (mac.isEmpty() )
+ continue;
+ RemoteDevice currentDevice( mac , name );
+ list.append( currentDevice );
+ }
+ }
+ return list;
+};
+/*
+ * This is some how rude but make sure all old devices
+ * are getting deleted
+ */
+void DeviceHandler::save( const RemoteDevice::ValueList& list) {
+ QCString rm;
+ rm += "rm -rf ";
+ rm += QDir::homeDirPath() + "/Settings/bluetooth";
+ system ( rm.data() );
+
+ if (list.isEmpty() ) // no need to create the dir
+ return;
+
+ /**
+ * Create a new dir
+ */
+ rm = "mkdir ";
+ rm += QDir::homeDirPath() + "/Settings/bluetooth";
+ qWarning("out %s", rm.data() );
+ system( rm.data() );
+
+ RemoteDevice::ValueList::ConstIterator it;
+ // write the config
+
+ for ( it = list.begin(); it != list.end(); ++it ) {
+ qDebug( "/Settings/bluetooth/" + (*it).mac() + ".conf");
+
+ Config conf( QDir::homeDirPath() +
+ "/Settings/bluetooth/" +
+ (*it).mac() + ".conf", Config::File );
+
+ conf.setGroup( "Info" );
+ conf.writeEntry( "name", (*it).name() );
+ conf.writeEntry( "mac", (*it).mac() );
+ }
+
+}