Re: Opie bluetooth applet.

Slavek Banko <[email protected]>
Newsgroups gmane.comp.handhelds.opie.devel
Organization axis, spol. s r. o.
Message-ID <[email protected]>
Hi.

Here is patch to add simple support for /etc/sysconfig/bluetooth. If 
configuration file exists, values BLUETOOTH_(PORT|PROTOCOL|SPEED) is 
readed and used to create device. If file not exists, is used previous 
code with switch by model.

Note: Configuration file is readed as text file, not executed as shell 
script (see GPE, /etc/bluetooth/hciattach).

Slavek
-- 
Dne pátek 16 červen 2006 22:01 Dmitriy Korovkin napsal(a):
> Hi Slavek,
> May be this is a good idea. Let me do this. I'm currently working on
> OPIe BT stuff.
> Regards,
> Dmitriy.
>
> On Thu, 15 Jun 2006, Slavek Banko wrote:
> > Date: Thu, 15 Jun 2006 20:53:55 +0200
> > From: Slavek Banko <[email protected]>
> > To: [email protected]
> > Subject: Re: [Opie-devel] Opie bluetooth applet.
> >
> > Hi.
> >
> > Opie bluetooth applet yet not use /etc/sysconfig/bluetooth.
> > Parameters for hciattach now must be directly in "bluezapplet.cpp". I
> > am going to create patch, that add support for
> > /etc/sysconfig/bluetooth.
> >
> > Slavek

_______________________________________________

http://opie.handhelds.org/cgi-bin/moin.cgi/DeveloperWikiIndex

Opie-devel mailing list
[email protected]
https://handhelds.org/mailman/listinfo/opie-devel
sysconfig-bluetooth.patch (text/x-diff, 2.6 KB)
diff -aruN opie-bluetoothapplet.orig/opie/noncore/net/opietooth/applet/bluezapplet.cpp opie-bluetoothapplet/opie/noncore/net/opietooth/applet/bluezapplet.cpp
--- opie-bluetoothapplet.orig/opie/noncore/net/opietooth/applet/bluezapplet.cpp	2006-05-30 17:08:53.000000000 +0200
+++ opie-bluetoothapplet/opie/noncore/net/opietooth/applet/bluezapplet.cpp	2006-06-21 19:45:17.000000000 +0200
@@ -49,6 +49,8 @@
 #include <qstring.h>
 #include <qtimer.h>
 #include <qpopupmenu.h>
+#include <qfile.h>
+#include <qtextstream.h>
 
 /* STD */
 #include <device.h>
@@ -103,22 +105,41 @@
     int BluezApplet::setBluezStatus(int c) {
 
         if ( c == 1 ) {
-            switch ( ODevice::inst()->model() ) {
-            case Model_iPAQ_H39xx:
-                btDevice = new Device( "/dev/tts/1", "bcsp", "921600" );
-                break;
-
-	    case Model_iPAQ_H5xxx:
-	        btDevice = new Device( "/dev/tts/1", "any", "921600" );
-		break;
-
-	    case Model_iPAQ_H22xx:
-		btDevice = new Device( "/dev/tts/3", "any", "921600" );
-		break;
-
-            default:
-                btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" );
-                break;
+	    QFile cfg("/etc/sysconfig/bluetooth");
+	    if(cfg.open(IO_ReadOnly)) {
+	        QTextStream stream (&cfg);
+    		QString streamIn = stream.read();
+        	QStringList list = QStringList::split("\n", streamIn);
+		cfg.close();
+		if(list.grep("BLUETOOTH_PORT=").count() > 0 &&
+                   list.grep("BLUETOOTH_PROTOCOL=").count() > 0 &&
+                   list.grep("BLUETOOTH_SPEED=").count() > 0) {
+		    btDevice = new Device( list.grep("BLUETOOTH_PORT=")[0].
+                                           replace((QString)"BLUETOOTH_PORT=", ""),
+                                           list.grep("BLUETOOTH_PROTOCOL=")[0].
+                                           replace((QString)"BLUETOOTH_PROTOCOL=", ""),
+                                           list.grep("BLUETOOTH_SPEED=")[0].
+                                           replace((QString)"BLUETOOTH_SPEED=", ""));
+		}
+	    }
+	    if(!btDevice) {
+                switch ( ODevice::inst()->model() ) {
+	        case Model_iPAQ_H39xx:
+    	    	    btDevice = new Device( "/dev/tts/1", "bcsp", "921600" );
+            	    break;
+
+		case Model_iPAQ_H5xxx:
+	    	    btDevice = new Device( "/dev/tts/1", "any", "921600" );
+		    break;
+
+		case Model_iPAQ_H22xx:
+		    btDevice = new Device( "/dev/tts/3", "any", "921600" );
+		    break;
+
+        	default:
+            	    btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" );
+            	    break;
+		}
             }
         } else {
             if ( btDevice ) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.