[kmobiletools] branches/kmobiletools/kmobiletools-0.5
Marco Gulino
marco at kmobiletools.org
Mon Jun 4 23:39:19 CEST 2007
SVN commit 671492 by gulino:
Copying rfcommsocketdevice into kmobiletools to help in kdebluetooth-dbus usage.
M +1 -0 configure.in.in
M +4 -4 kmobiletools/libkmobiletools/Makefile.am
A kmobiletools/libkmobiletools/deviceaddress.cpp [License: GPL (v2+)]
A kmobiletools/libkmobiletools/deviceaddress.h [License: GPL (v2+)]
A kmobiletools/libkmobiletools/rfcommsocketdevice.cpp [License: GPL (v2+)]
A kmobiletools/libkmobiletools/rfcommsocketdevice.h [License: GPL (v2+)]
M +22 -15 kmobiletools/libkmobiletools/serialdevice.cpp
--- branches/kmobiletools/kmobiletools-0.5/configure.in.in #671491:671492
@@ -138,6 +138,7 @@
KDE_CHECK_HEADER(libkbluetooth/adapter.h, have_new_kbluetooth=yes, have_new_kbluetooth=no)
AM_CONDITIONAL(with_kdebluetooth_new, test x$have_new_kbluetooth = xyes)
if test "$have_new_kbluetooth" = "yes"; then
+ PKG_CHECK_MODULES(BLUEZ, "bluez")
AC_DEFINE(KBLUETOOTH_NEW, 1, [use new kdebluetooth])
AC_SUBST(KBLUETOOTH_NEW)
LIB_KBLUETOOTH="-lkbluetooth"
--- branches/kmobiletools/kmobiletools-0.5/kmobiletools/libkmobiletools/Makefile.am #671491:671492
@@ -1,6 +1,6 @@
KDE_OPTIONS = nofinal
-INCLUDES = $(all_includes)
+INCLUDES = $(all_includes) $(BLUEZ_CFLAGS)
SUBDIRS = icons
METASOURCES = AUTO
lib_LTLIBRARIES = libkmobiletools.la
@@ -14,7 +14,7 @@
mainIFace.stub overlaywidget.cpp pickphonenumberdialog.cpp picksmscenter.cpp \
popupaddressee.cpp popupnumber.cpp popupsms.cpp qserial.cpp \
serialdevice.cpp kmobiletoolsengine.cpp sms.cpp smslist.cpp ui_pickphonenumber.ui weaver.cpp \
- weaverextensions.cpp
+ weaverextensions.cpp rfcommsocketdevice.cpp deviceaddress.cpp
libkmobiletoolsincludedir = $(includedir)/kmobiletools
libkmobiletoolsinclude_HEADERS = kmobiletoolsengine.h sms.h smslist.h \
@@ -23,9 +23,9 @@
noinst_HEADERS = aboutdata.h calendar.h contactptrlist.h crashhandler.h \
deviceIFace.h devicemenu.h engineloader.h engineslist.h homepage.h \
kmobiletoolshelper.h mainIFace.h overlaywidget.h pickphonenumberdialog.h picksmscenter.h \
- popupaddressee.h popupnumber.h popupsms.h serialdevice.h stringcombobox.h
+ popupaddressee.h popupnumber.h popupsms.h serialdevice.h stringcombobox.h rfcommsocketdevice.h deviceaddress.h
-libkmobiletools_la_LIBADD = $(LIB_KBLUETOOTH) $(LIB_KCAL) $(LIB_KHTML) $(LIB_KABC)
+libkmobiletools_la_LIBADD = $(LIB_KBLUETOOTH) $(LIB_KCAL) $(LIB_KHTML) $(LIB_KABC) $(BLUEZ_LIBS)
kde_kcfg_data = kmobiletools_cfg.kcfg kmobiletools_devices.kcfg
KDE_CXXFLAGS = -UQT_NO_ASCII_CAST
--- branches/kmobiletools/kmobiletools-0.5/kmobiletools/libkmobiletools/serialdevice.cpp #671491:671492
@@ -32,12 +32,19 @@
#include <kglobal.h>
#include <kstandarddirs.h>
#include "config.h"
-/*#define KBLUETOOTH 1*/
+#if defined (KBLUETOOTH) || defined (KBLUETOOTH_NEW)
+ #define HAVE_KBLUETOOTH 1
+#endif
#define MAXBUFSIZE 32
-#ifdef KBLUETOOTH
-#include <kdebluetooth/rfcommsocketdevice.h>
-#include <qsocketnotifier.h>
+#ifdef HAVE_KBLUETOOTH
+ #ifdef KBLUETOOTH
+ #include <kdebluetooth/rfcommsocketdevice.h>
+ #endif
+ #ifdef KBLUETOOTH_NEW
+ #include "rfcommsocketdevice.h"
+ #endif
+ #include <qsocketnotifier.h>
#endif
#include <iostream>
@@ -57,7 +64,7 @@
b_connected(false), gotData(0), serial(0L), m_baudrate(QSerial::BAUD_57600), bluetooth(false), errnum(0)
{
mutex=new QMutex(true);
-#ifdef KBLUETOOTH
+#ifdef HAVE_KBLUETOOTH
rfcomm=0L;
#endif
}
@@ -69,7 +76,7 @@
QMutex *mutex;
uint gotData;
QSerial *serial;
-#ifdef KBLUETOOTH
+#ifdef HAVE_KBLUETOOTH
KBluetooth::RfcommSocketDevice *rfcomm;
#endif
QIODevice *device;
@@ -141,7 +148,7 @@
bool SerialManager::open(ThreadWeaver::Job *job)
{
bool isOpen;
-#ifdef KBLUETOOTH
+#ifdef HAVE_KBLUETOOTH
QRegExp addr("bluetooth://\\[(([A-F\\d]{2,2}:*){6,6})\\]:([\\d]+)");
if( addr.search( d->s_devicePath ) != -1 )
{
@@ -171,7 +178,7 @@
d->serial->setParity( QSerial::PARITY_NONE );
connect(d->serial, SIGNAL(gotData()), this, SLOT(gotData()));
isOpen= d->device->open(IO_ReadWrite/* | O_NOCTTY | O_NONBLOCK */);
-#ifdef KBLUETOOTH
+#ifdef HAVE_KBLUETOOTH
}
#endif
if(!isOpen) return false;
@@ -217,7 +224,7 @@
d->device=0;
d->serial=0;
d->logfile.close();
-#ifdef KBLUETOOTH
+#ifdef HAVE_KBLUETOOTH
d->rfcomm=0;
#endif
d->b_connected=false;
@@ -243,7 +250,7 @@
d->buffer=QString::null;
long err;
-#ifdef KBLUETOOTH
+#ifdef HAVE_KBLUETOOTH
if(d->bluetooth)
err=d->rfcomm->writeBlock(cmd.latin1(), cmd.length()); else
#endif
@@ -274,7 +281,7 @@
if( timer.elapsed() >=3000 &&
(timer.elapsed()%3000 == 0) && tryBreakingTimeout)
{
-#ifdef KBLUETOOTH
+#ifdef HAVE_KBLUETOOTH
if(d->bluetooth)
err=d->rfcomm->writeBlock("AT\r", 3); else
#endif
@@ -291,7 +298,7 @@
kdDebug() << "****************** please report to marco AT kmobiletools.org: AT command=" << cmd << endl;
}
if(job
-#ifdef KBLUETOOTH
+#ifdef HAVE_KBLUETOOTH
&& ! d->bluetooth
#endif
)
@@ -300,7 +307,7 @@
{
usleep(1000);
}
-#ifdef KBLUETOOTH
+#ifdef HAVE_KBLUETOOTH
if(d && d->bluetooth)
{
// kdDebug() << "Bluetooth reading: try " << i_try << endl;
@@ -369,7 +376,7 @@
void SerialManager::gotData()
{
uint availData;
-#ifdef KBLUETOOTH
+#ifdef HAVE_KBLUETOOTH
if(d->bluetooth)
availData=d->rfcomm->size(); else
#endif
@@ -380,7 +387,7 @@
char *buffer=new char [availData+1];
memset(buffer, 0, availData+1);
int readdata;
-#ifdef KBLUETOOTH
+#ifdef HAVE_KBLUETOOTH
if(d->bluetooth)
readdata=d->rfcomm->readBlock(buffer, availData);
#endif
More information about the kmobiletools
mailing list