[kmobiletools] branches/kmobiletools/kmobiletools-0.5
Marco Gulino
marco at kmobiletools.org
Sat Jun 2 19:00:43 CEST 2007
SVN commit 670840 by gulino:
Starting inquiring devices with kdebluetooth-dbus.
Please report if this commit breaks something, as i'm quite confused by the resulting tons of #ifdef
M +6 -6 kmobiletools/mainpart/Makefile.am
A kmobiletools/mainpart/bluemonitor.cpp [License: GPL (v2+)]
A kmobiletools/mainpart/bluemonitor.h [License: GPL (v2+)]
A kmobiletools/mainpart/bluetoothitems.cpp [License: GPL (v2+)]
A kmobiletools/mainpart/bluetoothitems.h [License: GPL (v2+)]
M +37 -47 kmobiletools/mainpart/newdevicewizard.cpp
M +6 -36 kmobiletools/mainpart/newdevicewizard.h
M +1 -1 tests/kserialdeviceemulator/Makefile.am
--- branches/kmobiletools/kmobiletools-0.5/kmobiletools/mainpart/Makefile.am #670839:670840
@@ -7,15 +7,15 @@
METASOURCES = AUTO
kde_module_LTLIBRARIES = libkmobiletoolsmainpart.la
-noinst_HEADERS = deviceconfigdialog.h devicemanager.h kmobiletools_mainpart.h \
- newdevicewizard.h
+noinst_HEADERS = bluemonitor.h bluetoothitems.h deviceconfigdialog.h \
+ devicemanager.h kmobiletools_mainpart.h newdevicewizard.h
libkmobiletoolsmainpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) \
$(KDE_RPATH)
-libkmobiletoolsmainpart_la_SOURCES = cfg_at-engine.ui cfg_filesystem.ui \
- cfg_gammu-engine.ui deviceList.ui deviceconfigdialog.cpp devicemanager.cpp \
- genericDeviceOptions.ui kmobiletools_mainpart.cpp newdevicewizard.cpp ui_newdevicewizard.ui \
- wizDeviceFirst.ui
+libkmobiletoolsmainpart_la_SOURCES = bluemonitor.cpp bluetoothitems.cpp \
+ cfg_at-engine.ui cfg_filesystem.ui cfg_gammu-engine.ui deviceList.ui \
+ deviceconfigdialog.cpp devicemanager.cpp genericDeviceOptions.ui kmobiletools_mainpart.cpp \
+ newdevicewizard.cpp ui_newdevicewizard.ui wizDeviceFirst.ui
libkmobiletoolsmainpart_la_LIBADD = \
../deviceparts/libkmobiletoolsdevicepart.la \
../libkmobiletools/libkmobiletools.la $(LIB_KHTML) $(LIB_KDEUI) $(LIB_KPARTS)
--- branches/kmobiletools/kmobiletools-0.5/kmobiletools/mainpart/newdevicewizard.cpp #670839:670840
@@ -46,18 +46,22 @@
#include <qradiobutton.h>
#include <kplugininfo.h>
#include <qwidgetstack.h>
-#ifdef KBLUETOOTH
-#include <kdebluetooth/namerequest.h>
+#ifdef HAVE_KBLUETOOTH
#define useBT (selBT && ( BTItem || !manualSVC->isChecked() ) )
#define selBT ( btenable->isOn())
-#define BTItem ((BtServiceItem*)btsvcLV->selectedItem())
#else
#define selBT false
-#define BTItem 0
#define useBT false
#endif
+#ifdef KBLUETOOTH
+#include <kdebluetooth/namerequest.h>
+#define BTItem ((BtServiceItem*)btsvcLV->selectedItem())
+#endif
+#ifdef KBLUETOOTH_NEW
+#include "bluemonitor.h"
+#define BTItem (btsvcLV->selectedItem())
+#endif
-
#include "kmobiletools_devices.h"
#include "kmobiletoolshelper.h"
#include "kmobiletoolsengine.h"
@@ -65,6 +69,7 @@
#include "deviceconfigdialog.h"
#include "keycombobox.h"
#include "picksmscenter.h"
+#include "bluetoothitems.h"
#define CONN_USB 1
@@ -101,13 +106,19 @@
connect( smsCenter, SIGNAL(textChanged ( const QString & )), this, SLOT(checkAdvParams()) );
connect( b_skipWizard, SIGNAL(clicked() ), this, SLOT(skipWizard() ) );
connect(btenable, SIGNAL(toggled ( bool)), this, SLOT(bt_checked( bool )));
-#ifdef KBLUETOOTH
+#ifdef HAVE_KBLUETOOTH
connect( btDevicesLV, SIGNAL(clicked(QListViewItem*)), this, SLOT(btDeviceClicked(QListViewItem*)));
connect( btsvcLV, SIGNAL(clicked(QListViewItem*)), this, SLOT(btServiceClicked(QListViewItem*)));
connect( manualSVC, SIGNAL(toggled(bool)), this, SLOT(slotManualServices(bool)));
c_blue->hide();
+#ifdef KBLUETOOTH
inquiry=NULL;
btSocket=NULL;
+#endif
+#ifdef KBLUETOOTH_NEW
+ monitor=0;
+#endif
+
#else
connect( btwizard, SIGNAL(clicked()), this, SLOT(btWizard()));
#endif
@@ -139,7 +150,7 @@
engineNotWorking=i18n("<qt><font color=\"red\"><u><b>IMPORTANT!!</b> Don't even try to select this engine, since at the moment it doesn't run nor compile.</u></font></qt>");
engineDescLabel->setText(i18n("<qt>Select one of the engines to see details</qt>"));
btsvcLV->hide();
-#ifndef KBLUETOOTH
+#ifndef HAVE_KBLUETOOTH
// wizardLogoPixmap.load( KGlobal::dirs ()->findResource("data", "kmobiletools/bticon.png") );
// btwizard->setIconSet(QIconSet (wizardLogoPixmap) );
btStack->raiseWidget(0);
@@ -169,6 +180,9 @@
#ifdef KBLUETOOTH
delete inquiry;
#endif
+#ifdef KBLUETOOTH_NEW
+ delete monitor;
+#endif
}
@@ -266,7 +280,7 @@
setNextEnabled ( currentPage(), !kcfg_atdevices->items().isEmpty() );
break;
case AT_BLUETOOTH_PAGE:
-#ifndef KBLUETOOTH
+#ifndef HAVE_KBLUETOOTH
setNextEnabled ( currentPage(), true);
#else
@@ -454,7 +468,7 @@
{
btStack->setEnabled(on);
// btframe->setEnabled(on);
-#ifdef KBLUETOOTH
+#ifdef HAVE_KBLUETOOTH
setNextEnabled ( currentPage(), (!on) || (btsvcLV->selectedItem()!=0) );
if(on) btWizard();
#endif
@@ -466,20 +480,18 @@
*/
void newDeviceWizard::btWizard()
{
-#ifdef KBLUETOOTH
-// progress=new KProgressDialog(this, "progress", i18n("Bluetooth wizard"),
-// i18n("Searching Bluetooth devices.\nPlease wait."), true);
-// progress->progressBar()->setTotalSteps(0);
-// progress->progressBar()->setTextEnabled(false);
-// progress->setAllowCancel(false);
-// QTimer::singleShot(5, this, SLOT(slotProgress()));
+#ifdef HAVE_KBLUETOOTH
btDevicesLV->clear();
+#ifdef KBLUETOOTH
btSocket=new KBluetooth::HciSocket(inquiry, "");
btSocket->open();
inquiry=new KBluetooth::Inquiry(btSocket);
connect(inquiry, SIGNAL(finnished()), this, SLOT(btScanFinished()));
connect(inquiry, SIGNAL(error(int, QString )), this, SLOT(btScanFinished()));
connect(inquiry, SIGNAL(neighbourFound (const KBluetooth::DeviceAddress&, int)), this, SLOT(btScanItemFound(const KBluetooth::DeviceAddress&, int)));
+#else
+ if(!monitor) monitor=new BlueMonitor(btDevicesLV);
+#endif
btStatusLabel->setText( i18n("Searching for bluetooth devices.") );
btsvcLV->clear();
bturl=QString::null;
@@ -496,6 +508,9 @@
// inquiry->reset();
inquiry->inquiry();
#endif
+#ifdef KBLUETOOTH_NEW
+monitor->restartPeriodicDiscovery();
+#endif
}
void newDeviceWizard::btStopScan()
@@ -513,6 +528,12 @@
delete inquiry;
kdDebug() << "Inquiry deleted\n";
inquiry=NULL;
+
+#endif
+#ifdef KBLUETOOTH_NEW
+ monitor->stopDisco();
+#endif
+#ifdef HAVE_KBLUETOOTH
btStatusLabel->setText( i18n("Search stopped. Please <a href=\"#\">click here</a> to search bluetooth devices again.") );
disconnect(btStatusLabel, SIGNAL(linkClicked ( const QString &)), btStatusLabel, SLOT(openLink( const QString &)));
#endif
@@ -546,37 +567,6 @@
#endif
}
-
-#ifdef KBLUETOOTH
-BtDeviceItem::BtDeviceItem(KListView *parent, const KBluetooth::DeviceAddress &bdaddr)
- : KListViewItem(parent)
-{
- m_bdaddr=bdaddr;
- setText(0, QString(m_bdaddr));
- setText(1, KBluetooth::NameRequest().resolve(m_bdaddr) );
-}
-
-KBluetooth::DeviceAddress BtDeviceItem::bdAddr() const { return m_bdaddr; }
-KBluetooth::SDP::Device * BtDeviceItem::device() { return &m_device; }
-
-BtServiceItem::BtServiceItem(KListView *parent, KBluetooth::SDP::Service *svc, const KBluetooth::DeviceAddress &bdaddr)
- : KListViewItem(parent)
-{
- m_bdaddr=bdaddr;
- p_svc=svc;
- QString svcname, svcdesc;
- uint svcch=0;
- svc->getRfcommChannel(svcch);
- svc->getServiceName(svcname);
- svc->getServiceDescription(svcdesc);
- setText(0, QString::number(svcch) );
- setText(1, svcname );
- setText(2, svcdesc);
-}
-KBluetooth::DeviceAddress BtServiceItem::bdAddr() const { return m_bdaddr; }
-KBluetooth::SDP::Service *BtServiceItem::service() { return p_svc; }
-#endif
-
void newDeviceWizard::btDeviceClicked(QListViewItem* item)
{
#ifdef KBLUETOOTH
--- branches/kmobiletools/kmobiletools-0.5/kmobiletools/mainpart/newdevicewizard.h #670839:670840
@@ -23,13 +23,8 @@
#include <ui_newdevicewizard.h>
#include <qptrlist.h>
#include "config.h"
-#include <qstring.h>
-#ifdef KBLUETOOTH
-#include <kdebluetooth/inquiry.h>
-#include <kdebluetooth/hcisocket.h>
-#include <kdebluetooth/sdpdevice.h>
-#include <klistview.h>
-#endif
+#include "bluetoothitems.h"
+
/**
@author Marco Gulino <marco at kmobiletools.org>
*/
@@ -37,36 +32,8 @@
class engineLoader;
class DeviceInfos;
class DevicesInfoList;
-#ifdef KBLUETOOTH
+class BlueMonitor;
-class BtDeviceItem : public KListViewItem
-{
- public:
- BtDeviceItem(KListView *parent, const KBluetooth::DeviceAddress &bdaddr);
- KBluetooth::DeviceAddress bdAddr() const;
- KBluetooth::SDP::Device *device();
- private:
- KBluetooth::DeviceAddress m_bdaddr;
- KBluetooth::SDP::Device m_device;
-};
-
-class BtServiceItem : public KListViewItem
-{
- public:
- BtServiceItem(KListView *parent, KBluetooth::SDP::Service *svc, const KBluetooth::DeviceAddress &bdaddr);
- KBluetooth::SDP::Service *service();
- KBluetooth::DeviceAddress bdAddr() const;
-
- private:
- KBluetooth::DeviceAddress m_bdaddr;
- KBluetooth::SDP::Service *p_svc;
-};
-#else
-namespace KBluetooth {
- class DeviceAddress;
-}
-#endif
-
class newDeviceWizard : public ui_newdevicewizard
{
Q_OBJECT
@@ -98,6 +65,9 @@
KBluetooth::Inquiry *inquiry;
KBluetooth::HciSocket *btSocket;
#endif
+#ifdef KBLUETOOTH_NEW
+ BlueMonitor *monitor;
+#endif
public slots:
--- branches/kmobiletools/kmobiletools-0.5/tests/kserialdeviceemulator/Makefile.am #670839:670840
@@ -24,7 +24,7 @@
kserialdeviceemulator_SOURCES = main.cpp kserialdeviceemulator.cpp \
kserialdeviceemulatorwidget.cpp kserialdeviceemulatorwidgetbase.ui commandslist.cpp
kserialdeviceemulator_LDFLAGS = $(KDE_RPATH) $(all_libraries)
-kserialdeviceemulator_LDADD = -lkmobiletools $(LIB_KDEUI)
+kserialdeviceemulator_LDADD = ../../kmobiletools/libkmobiletools/libkmobiletools.la $(LIB_KDEUI)
# this is where the desktop file will go
shelldesktopdir = $(kde_appsdir)/Utilities
More information about the kmobiletools
mailing list