author | korovkin <korovkin> | 2006-07-06 16:43:35 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-07-06 16:43:35 (UTC) |
commit | 060b467fb04094352343298688db04d89943f4b3 (patch) (side-by-side diff) | |
tree | c04102028174f328f7be033d20a130359ce8d7c8 /noncore | |
parent | 43cd66c08de4447998028179d20fd4817aaf16ca (diff) | |
download | opie-060b467fb04094352343298688db04d89943f4b3.zip opie-060b467fb04094352343298688db04d89943f4b3.tar.gz opie-060b467fb04094352343298688db04d89943f4b3.tar.bz2 |
Added connection to a HID device.
-rw-r--r-- | noncore/net/opietooth/manager/bticonloader.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/hidpopup.cpp | 105 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/hidpopup.h | 43 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/manager.pro | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/popuphelper.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/stdpopups.cpp | 5 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/stdpopups.h | 1 |
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 @@ -29,6 +29,7 @@ namespace OpieTooth { 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 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 @@ -9,7 +9,7 @@ HEADERS = btconnectionitem.h btdeviceitem.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 \ @@ -21,7 +21,7 @@ SOURCES = btconnectionitem.cpp btdeviceitem.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 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 @@ -33,4 +33,5 @@ void PopupHelper::init() { 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 @@ -4,6 +4,7 @@ #include "obexftpopup.h" #include "panpopup.h" #include "dunpopup.h" +#include "hidpopup.h" #include "stdpopups.h" @@ -25,5 +26,9 @@ extern "C" { 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 @@ -15,6 +15,7 @@ extern "C" { 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* ); } |