summaryrefslogtreecommitdiff
authorkorovkin <korovkin>2006-07-06 16:43:35 (UTC)
committer korovkin <korovkin>2006-07-06 16:43:35 (UTC)
commit060b467fb04094352343298688db04d89943f4b3 (patch) (side-by-side diff)
treec04102028174f328f7be033d20a130359ce8d7c8
parent43cd66c08de4447998028179d20fd4817aaf16ca (diff)
downloadopie-060b467fb04094352343298688db04d89943f4b3.zip
opie-060b467fb04094352343298688db04d89943f4b3.tar.gz
opie-060b467fb04094352343298688db04d89943f4b3.tar.bz2
Added connection to a HID device.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bticonloader.cpp1
-rw-r--r--noncore/net/opietooth/manager/hidpopup.cpp105
-rw-r--r--noncore/net/opietooth/manager/hidpopup.h43
-rw-r--r--noncore/net/opietooth/manager/manager.pro4
-rw-r--r--noncore/net/opietooth/manager/popuphelper.cpp1
-rw-r--r--noncore/net/opietooth/manager/stdpopups.cpp5
-rw-r--r--noncore/net/opietooth/manager/stdpopups.h1
7 files changed, 158 insertions, 2 deletions
diff --git a/noncore/net/opietooth/manager/bticonloader.cpp b/noncore/net/opietooth/manager/bticonloader.cpp
index 6bac256..c8a6dd4 100644
--- a/noncore/net/opietooth/manager/bticonloader.cpp
+++ b/noncore/net/opietooth/manager/bticonloader.cpp
@@ -8,48 +8,49 @@ namespace OpieTooth {
BTIconLoader::BTIconLoader() {
// still need to find out real ids
deviceIcons.insert( 100 , "computer_16" );
deviceIcons.insert( 101 , "phone_16" );
deviceIcons.insert( 102 , "brain_16" );
deviceIcons.insert( 103 , "conduit_16" );
serviceIcons.insert( 4357 , "obex_16" ); //OBEXObjectPush
serviceIcons.insert( 4358 , "obex_16" ); //OBEXFileTransfer
serviceIcons.insert( 4369 , "print_16" ); //Fax
serviceIcons.insert( 4353 , "serial_16" ); //SerialPort
serviceIcons.insert( 4356 , "sync_16" ); //IrMCSync
serviceIcons.insert( 4359 , "sync_16" ); //IrMCSyncCommand
serviceIcons.insert( 4354 , "network_16" ); //LANAccessUsingPPP
serviceIcons.insert( 4355 , "network_16"); //DialupNetworking
serviceIcons.insert( 4360 , "phone_16"); // Headset
serviceIcons.insert( 4370 , "audio_16"); //HeadsetAudioGateway
serviceIcons.insert( 4374 , "network_16"); // Network Access Point
serviceIcons.insert( 4361 , "phone_16"); // CordlessTelephony
serviceIcons.insert( 4362 , "audio_16"); // AudioSource
serviceIcons.insert( 4363 , "audio_16"); // AudioSink
+ serviceIcons.insert( 4388 , "other_16" ); //Human Interface Device
serviceIcons.insert( 4390 , "print_16" ); //HCR_Print
serviceIcons.insert( 4392 , "phone_16" ); //Common_ISDN_Access
serviceIcons.insert( 4609 , "network_16" ); //GenericNetworking
serviceIcons.insert( 4610 , "folder_16" ); //GenericFileTransfer
serviceIcons.insert( 4392 , "audio_16" ); //GenericAudio
// serviceIcons.insert( 4392 , "phone_16" ); //GenericTelephony
// the above is duplicated? -zecke
//serviceIcons.insert( "106" , "link_16" );
//serviceIcons.insert( "107" , "misc_16" );
}
BTIconLoader::~BTIconLoader() {
}
QPixmap BTIconLoader::deviceIcon( int deviceClass ) {
QString iconName;
QMap<int, QString>::Iterator it;
it = deviceIcons.find( deviceClass );
iconName = it.data();
diff --git a/noncore/net/opietooth/manager/hidpopup.cpp b/noncore/net/opietooth/manager/hidpopup.cpp
new file mode 100644
index 0000000..98a2fb4
--- a/dev/null
+++ b/noncore/net/opietooth/manager/hidpopup.cpp
@@ -0,0 +1,105 @@
+/* $Id$ */
+/* PAN context menu */
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include <qpe/qcopenvelope_qws.h>
+#include <qmessagebox.h>
+#include <opie2/odebug.h>
+#include <opie2/oprocess.h>
+#include <qpe/qpeapplication.h>
+using namespace Opie::Core;
+
+#include <qtimer.h>
+#include "hidpopup.h"
+
+using namespace OpieTooth;
+
+/*
+ * c'tor init the QAction
+ */
+HidPopup::HidPopup(const OpieTooth::Services&, OpieTooth::BTDeviceItem* item) :
+ QPopupMenu() {
+
+ owarn << "HidPopup c'tor" << oendl;
+
+ m_item = item;
+ QAction* a;
+ QAction* c;
+
+ m_hidConnect = 0l;
+ /* connect action */
+
+ a = new QAction(); // so it's get deleted
+ a->setText( tr("connect") );
+ a->addTo( this );
+ connect( a, SIGNAL( activated() ), this, SLOT( slotConnect() ) );
+
+ c = new QAction();
+ c->setText( tr( "disconnect" ) );
+ c->addTo( this );
+ connect( c, SIGNAL( activated() ), this, SLOT( slotDisconnect() ) );
+
+};
+
+HidPopup::~HidPopup() {
+ delete m_hidConnect;
+}
+
+void HidPopup::slotConnect() {
+ odebug << "connect" << oendl;
+ m_hidConnect = new OProcess();
+ *m_hidConnect << "hidd" << "--connect" << m_item->mac();
+ connect(m_hidConnect,
+ SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)),
+ this, SLOT(fillOutPut(Opie::Core::OProcess*, char*, int)));
+ connect(m_hidConnect,
+ SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)),
+ this, SLOT(fillErr(Opie::Core::OProcess*, char*, int)));
+ connect(m_hidConnect,
+ SIGNAL(processExited(Opie::Core::OProcess*)),
+ this, SLOT(slotProcessExited(Opie::Core::OProcess*)));
+ if (!m_hidConnect->start(OProcess::Block, OProcess::AllOutput)) {
+ QMessageBox::critical(this, tr("HID Connection"),
+ tr("HID Connection\nto device ") + m_item->mac() + tr("\nfailed"));
+ delete m_hidConnect;
+ m_hidConnect = 0l;
+ }
+}
+
+void HidPopup::slotDisconnect() {
+ OProcess hidKill;
+ hidKill << "hidd" << "--kill" << m_item->mac();
+ hidKill.start(OProcess::DontCare, OProcess::NoCommunication);
+ sleep(1);
+ QMessageBox::information(this, tr("HID Disconnect"), tr("HID Disconnected"));
+}
+
+void HidPopup::fillOutPut( OProcess*, char* cha, int len ) {
+ QCString str(cha, len);
+ odebug << str << oendl;
+}
+
+void HidPopup::fillErr(OProcess*, char* buf, int len)
+{
+ QCString str(buf, len);
+ odebug << str << oendl;
+}
+
+void HidPopup::slotProcessExited(OProcess* proc) {
+ if (m_hidConnect->normalExit())
+ QMessageBox::information(this, tr("HID Connection"),
+ tr("HID Connect\nstarted"));
+ else
+ QMessageBox::critical(this, tr("HID Connection"),
+ tr("HID Connection\nto device ") + m_item->mac() + tr("\nfailed"));
+ delete m_hidConnect;
+ m_hidConnect = 0l;
+}
+
+//eof
diff --git a/noncore/net/opietooth/manager/hidpopup.h b/noncore/net/opietooth/manager/hidpopup.h
new file mode 100644
index 0000000..0c51919
--- a/dev/null
+++ b/noncore/net/opietooth/manager/hidpopup.h
@@ -0,0 +1,43 @@
+/* $Id$ */
+/* PAN context menu */
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef HIDPOPUP_H
+#define HIDPOPUP_H
+
+#include <qpopupmenu.h>
+#include <qaction.h>
+#include <opie2/oprocess.h>
+#include <services.h>
+#include "btdeviceitem.h"
+
+namespace OpieTooth {
+
+ class HidPopup : public QPopupMenu {
+
+ Q_OBJECT
+
+ public:
+ HidPopup(const OpieTooth::Services&, OpieTooth::BTDeviceItem*);
+ ~HidPopup();
+
+ private:
+ QAction* m_push;
+ OpieTooth::BTDeviceItem *m_item;
+ Opie::Core::OProcess* m_hidConnect; //HID process
+ private slots:
+ void slotConnect();
+ void slotDisconnect();
+ void fillOutPut( Opie::Core::OProcess* pppDial, char* cha, int len );
+ void fillErr(Opie::Core::OProcess*, char*, int);
+ void slotProcessExited(Opie::Core::OProcess* proc);
+ };
+};
+
+#endif
diff --git a/noncore/net/opietooth/manager/manager.pro b/noncore/net/opietooth/manager/manager.pro
index 09bd10e..dc048c4 100644
--- a/noncore/net/opietooth/manager/manager.pro
+++ b/noncore/net/opietooth/manager/manager.pro
@@ -1,45 +1,45 @@
CONFIG = qt warn_on quick-app
HEADERS = btconnectionitem.h btdeviceitem.h \
btserviceitem.h stdpopups.h \
popuphelper.h bluebase.h \
scandialog.h btlistitem.h filistitem.h \
hciconfwrapper.h bticonloader.h \
pppdialog.h dundialog.h pandialog.h \
obexdialog.h obexftpdialog.h \
rfcommassigndialogimpl.h rfcommassigndialogitem.h \
devicehandler.h rfcpopup.h obexpopup.h obexftpopup.h \
rfcommhelper.h panpopup.h dunpopup.h rfcommconfhandler.h \
- servicesdialog.h btconfhandler.h
+ servicesdialog.h btconfhandler.h hidpopup.h
SOURCES = btconnectionitem.cpp btdeviceitem.cpp \
btserviceitem.cpp filelistitem.cpp stdpopups.cpp \
popuphelper.cpp main.cpp \
bluebase.cpp scandialog.cpp \
btlistitem.cpp hciconfwrapper.cpp \
bticonloader.cpp pppdialog.cpp dundialog.cpp pandialog.cpp \
rfcommassigndialogimpl.cpp rfcommassigndialogitem.cpp \
obexdialog.cpp devicehandler.cpp \
rfcpopup.cpp obexpopup.cpp obexftpopup.cpp obexftpdialog.cpp \
rfcommhelper.cpp panpopup.cpp dunpopup.cpp rfcommconfhandler.cpp \
- servicesdialog.cpp btconfhandler.cpp
+ servicesdialog.cpp btconfhandler.cpp hidpopup.cpp
INCLUDEPATH += $(OPIEDIR)/include
INCLUDEPATH += $(OPIEDIR)/noncore/net/opietooth/lib
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lbluetooth -lopietooth1 -lopiecore2 -lopieui2 -lopenobex
INTERFACES = bluetoothbase.ui devicedialog.ui rfcommassigndialogbase.ui \
rfcommdialogitembase.ui obexftpdialogbase.ui \
servicesdialogbase.ui
TARGET = bluetooth-manager
include( $(OPIEDIR)/include.pro )
!isEmpty( LIBOBEXFTP_INC_DIR ) {
INCLUDEPATH += $$LIBOBEXFTP_INC_DIR
}
!isEmpty( LIBOBEXFTP_LIB_DIR ) {
LIBS += $$LIBOBEXFTP_LIB_DIR/libobexftp.a
LIBS += $$LIBOBEXFTP_LIB_DIR/libmulticobex.a
LIBS += $$LIBOBEXFTP_LIB_DIR/libbfb.a
}
diff --git a/noncore/net/opietooth/manager/popuphelper.cpp b/noncore/net/opietooth/manager/popuphelper.cpp
index b3d7aa5..66f42bc 100644
--- a/noncore/net/opietooth/manager/popuphelper.cpp
+++ b/noncore/net/opietooth/manager/popuphelper.cpp
@@ -12,25 +12,26 @@ PopupHelper::~PopupHelper() {
}
void PopupHelper::insert( int id, popupFactory fact ) {
m_map.insert(id, fact );
}
QPopupMenu* PopupHelper::find( int id, const Services& ser, BTDeviceItem* item ) {
//owarn << "find" << oendl;
FactoryMap::Iterator it = m_map.find(id );
if ( it != m_map.end() ) {
//owarn << "found" << oendl;
popupFactory fact = it.data();
return (*fact)(ser, item);
}
return 0l;
}
void PopupHelper::init() {
insert( 4353, newRfcComPopup );
insert( 4354, newDunPopup );
insert( 4355, newRfcComPopup );
insert( 4357, newObexPushPopup );
insert( 4358, newObexFtpPopup );
insert( 4374, newPanPopup );
+ insert( 4388, newHidPopup );
}
diff --git a/noncore/net/opietooth/manager/stdpopups.cpp b/noncore/net/opietooth/manager/stdpopups.cpp
index f58d3a6..17a7002 100644
--- a/noncore/net/opietooth/manager/stdpopups.cpp
+++ b/noncore/net/opietooth/manager/stdpopups.cpp
@@ -1,29 +1,34 @@
#include "rfcpopup.h"
#include "obexpopup.h"
#include "obexftpopup.h"
#include "panpopup.h"
#include "dunpopup.h"
+#include "hidpopup.h"
#include "stdpopups.h"
extern "C" {
QPopupMenu* newRfcComPopup( const OpieTooth::Services& service, OpieTooth::BTDeviceItem* item ) {
return new OpieTooth::RfcCommPopup(service, item); // fix spellin RfComm vs. RfcComm and paramaters
}
QPopupMenu* newObexPushPopup( const OpieTooth::Services& service, OpieTooth::BTDeviceItem* item) {
return new OpieTooth::ObexPopup(service, item);
}
QPopupMenu* newObexFtpPopup( const OpieTooth::Services& service, OpieTooth::BTDeviceItem* item) {
return new OpieTooth::ObexFtpPopup(service, item);
}
QPopupMenu* newPanPopup( const OpieTooth::Services&, OpieTooth::BTDeviceItem* item ) {
return new OpieTooth::PanPopup( item );
}
QPopupMenu* newDunPopup( const OpieTooth::Services& service, OpieTooth::BTDeviceItem* item ) {
return new OpieTooth::DunPopup(service, item);
}
+
+ QPopupMenu* newHidPopup( const OpieTooth::Services& service, OpieTooth::BTDeviceItem* item ) {
+ return new OpieTooth::HidPopup(service, item);
+ }
}
diff --git a/noncore/net/opietooth/manager/stdpopups.h b/noncore/net/opietooth/manager/stdpopups.h
index 3c361db..f1e1696 100644
--- a/noncore/net/opietooth/manager/stdpopups.h
+++ b/noncore/net/opietooth/manager/stdpopups.h
@@ -1,21 +1,22 @@
#ifndef OPIE_TOOTH_STD_POPUPS
#define OPIE_TOOTH_STD_POPUPS
#include <qlistview.h>
#include <qpopupmenu.h>
#include <services.h>
#include "btdeviceitem.h"
extern "C" {
QPopupMenu* newRfcComPopup( const OpieTooth::Services&, OpieTooth::BTDeviceItem* );
QPopupMenu* newObexPushPopup( const OpieTooth::Services&, OpieTooth::BTDeviceItem* );
QPopupMenu* newPanPopup( const OpieTooth::Services&, OpieTooth::BTDeviceItem* );
QPopupMenu* newDunPopup( const OpieTooth::Services&, OpieTooth::BTDeviceItem* );
+ QPopupMenu* newHidPopup( const OpieTooth::Services&, OpieTooth::BTDeviceItem* );
QPopupMenu* newObexFtpPopup( const OpieTooth::Services&, OpieTooth::BTDeviceItem* );
}
#endif