summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2
authorwimpie <wimpie>2005-01-04 01:43:13 (UTC)
committer wimpie <wimpie>2005-01-04 01:43:13 (UTC)
commitb65cbb7c8b45d57f849722d22f8f165cc202ceb5 (patch) (side-by-side diff)
tree12634fa9f91357b1da501634d8c6d8072bde0ba6 /noncore/settings/networksettings2
parent2487b0a05f502e7410715460f390cc80e7e76fd9 (diff)
downloadopie-b65cbb7c8b45d57f849722d22f8f165cc202ceb5.zip
opie-b65cbb7c8b45d57f849722d22f8f165cc202ceb5.tar.gz
opie-b65cbb7c8b45d57f849722d22f8f165cc202ceb5.tar.bz2
New OPietooth bluetooth applet
Diffstat (limited to 'noncore/settings/networksettings2') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/opietooth2_applet/config.in4
-rw-r--r--noncore/settings/networksettings2/opietooth2_applet/opie-bluetoothapplet.control10
-rw-r--r--noncore/settings/networksettings2/opietooth2_applet/opietooth2_applet.pro12
-rw-r--r--noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.cpp241
-rw-r--r--noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.h99
-rw-r--r--noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.cpp72
-rw-r--r--noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.h55
7 files changed, 493 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/opietooth2_applet/config.in b/noncore/settings/networksettings2/opietooth2_applet/config.in
new file mode 100644
index 0000000..b60b01c
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2_applet/config.in
@@ -0,0 +1,4 @@
+ config NS2OPIETOOTHAPPLET
+ boolean "opietooth2 bluetooth applet"
+ default "y"
+ depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2OPIETOOTH
diff --git a/noncore/settings/networksettings2/opietooth2_applet/opie-bluetoothapplet.control b/noncore/settings/networksettings2/opietooth2_applet/opie-bluetoothapplet.control
new file mode 100644
index 0000000..ed13081
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2_applet/opie-bluetoothapplet.control
@@ -0,0 +1,10 @@
+Package: opie-opietooth2applet
+Files: plugins/applets/libopietooth2applet.so*
+Priority: optional
+Section: opie/applets
+Maintainer: Maximilian Reiss <max.reiss@gmx.de>
+Architecture: arm
+Depends: task-opie-minimal, libopietooth2
+Description: Bluetooth Applet
+ An bluetooth taskbar applet for the Opie environment using opietooth2
+Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/settings/networksettings2/opietooth2_applet/opietooth2_applet.pro b/noncore/settings/networksettings2/opietooth2_applet/opietooth2_applet.pro
new file mode 100644
index 0000000..90422c8
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2_applet/opietooth2_applet.pro
@@ -0,0 +1,12 @@
+TEMPLATE = lib
+CONFIG += qt plugin warn_on
+HEADERS = opietoothapplet.h opietoothappletimpl.h
+SOURCES = opietoothapplet.cpp opietoothappletimpl.cpp
+TARGET = opietooth2applet
+DESTDIR = $(OPIEDIR)/plugins/applets
+INCLUDEPATH += $(OPIEDIR)/include ../opietooth2
+DEPENDPATH += $(OPIEDIR)/include ../opietooth2
+LIBS += -lqpe -lopietooth2
+VERSION = 0.0.3
+
+include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.cpp b/noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.cpp
new file mode 100644
index 0000000..e419942
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.cpp
@@ -0,0 +1,241 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de>
+           .>+-=
+ _;:,     .>    :=|. This library is free software; you can
+.> <,   >  .   <= redistribute it and/or modify it under
+:=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%+i>       _;_.
+    .i_,=:_.      -<s. This library is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-= this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+
+#include <qapplication.h>
+
+#include <qpe/qcopenvelope_qws.h>
+#include <qpe/config.h>
+
+#include <qpoint.h>
+#include <qpainter.h>
+#include <qlayout.h>
+#include <qframe.h>
+#include <qpixmap.h>
+#include <qstring.h>
+#include <qpopupmenu.h>
+
+#include <OTGateway.h>
+#include <OTIcons.h>
+#include <opietoothapplet.h>
+
+namespace Opietooth2 {
+
+//
+//
+// Panel
+//
+//
+
+MessagePanel::MessagePanel( const QString & Msg,
+ QWidget* parent, const char* name ):
+ QLabel( parent, name, WType_Popup ){
+
+ QLabel * L = new QLabel( Msg, this );
+ L->setAlignment( Qt::WordBreak | Qt::AlignCenter );
+
+ QVBoxLayout * VL = new QVBoxLayout( this );
+ VL->addWidget( this );
+ VL->setMargin( 3 );
+
+ setFrameStyle( WinPanel|Raised );
+ setAlignment( AlignCenter );
+
+ resize(150,100);
+
+ moves = 0;
+}
+
+void MessagePanel::mouseReleaseEvent( QMouseEvent * e){
+
+ if (rect().contains( e->pos() ) || moves > 5)
+ close();
+}
+
+void MessagePanel::closeEvent( QCloseEvent *e ){
+
+ e->accept();
+
+ moves = 0;
+
+ if (!popupParent)
+ return;
+
+ /*
+ remember that we (as a popup) might recieve the mouse
+ release event instead of the popupParent. This is due to
+ the fact that the popupParent popped us up in its
+ mousePressEvent handler. To avoid the button remaining in
+ pressed state we simply send a faked mouse button release
+ event to it.
+ */
+
+ QMouseEvent me( QEvent::MouseButtonRelease,
+ QPoint(0,0),
+ QPoint(0,0),
+ QMouseEvent::LeftButton,
+ QMouseEvent::NoButton);
+ QApplication::sendEvent( popupParent, &me );
+}
+
+void MessagePanel::popup( QWidget* parent) {
+
+ popupParent = parent;
+
+ if (popupParent)
+ move( popupParent->mapToGlobal(
+ popupParent->rect().bottomLeft() )
+ );
+ show();
+}
+
+
+//
+//
+// Applet code
+//
+//
+
+Opietooth2Applet::Opietooth2Applet( QWidget *parent, const char *name ) : QWidget( parent, name ) {
+ OTIcons Ic;
+ setFixedHeight( 18 );
+ setFixedWidth( 14 );
+
+ OT = OTGateway::getOTGateway();
+
+ OnP = Ic.loadPixmap( "bluezon" );
+ OffP = Ic.loadPixmap( "bluezoff" );
+
+ // sent when bluetooth on device is enabled/disabled
+ connect( OT,
+ SIGNAL( deviceEnabled( bool ) ),
+ this,
+ SLOT( SLOT_StateChange( bool ) ) );
+
+ // sent when error
+ connect( OT,
+ SIGNAL( error( const QString & ) ),
+ this,
+ SLOT( SLOT_Error( const QString & ) ) );
+}
+
+Opietooth2Applet::~Opietooth2Applet() {
+ OTGateway::releaseOTGateway();
+}
+
+void Opietooth2Applet::mousePressEvent( QMouseEvent *) {
+
+ QPopupMenu *menu = new QPopupMenu();
+ // QPopupMenu *signal = new QPopupMenu();
+ int ret=0;
+
+ /* Refresh active state */
+ menu->insertItem( ( (OT->isEnabled()) ?
+ tr("Disable") :
+ tr("Enable")
+ ),
+ 1 );
+ menu->insertItem( tr("Launch manager"), 2 );
+
+ //menu->insertItem( tr("Signal strength"), signal, 5);
+ //menu->insertSeparator(8);
+
+ /*
+ menu->insertItem( ( (DiscoveryActive) ?
+ tr("Disable discovery") :
+ tr("Enable discovery")
+ ),
+ 3 );
+ */
+
+ QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) );
+
+ ret = menu->exec(p, 0);
+
+ switch(ret) {
+ case 1:
+ // toggle enabling of BT
+ OT->SLOT_SetEnabled( ! OT->isEnabled() );
+ break;
+ case 2:
+ // start bluetoothmanager
+ launchManager();
+ break;
+ //case 3:
+ // DiscoveryActive = 1 - DiscoveryActive;
+ // setDiscoveryStatus( DiscoveryActive );
+ // break;
+ // case 7:
+ // With table of currently-detected devices.
+ }
+ // delete signal;
+ delete menu;
+}
+
+
+void Opietooth2Applet::SLOT_Error( const QString & S ) {
+ MessagePanel * MP = new MessagePanel( S );
+
+ QPoint p = mapToGlobal(
+ QPoint(1, - MP->sizeHint().height()-1) );
+ MP->move( p );
+
+ MP->popup( 0 );
+ delete MP;
+}
+
+/**
+* Launches the bluetooth manager
+*/
+void Opietooth2Applet::launchManager() {
+ QCopEnvelope e("QPE/System", "execute(QString)");
+ e << QString("networksettings2-opietooth");
+}
+
+void Opietooth2Applet::SLOT_StateChange( bool ) {
+ // changed
+
+ // trigger painting
+ update();
+}
+
+/**
+* Implementation of the paint event
+* @param the QPaintEvent
+*/
+void Opietooth2Applet::paintEvent( QPaintEvent* ) {
+ QPainter p(this);
+
+ p.drawPixmap( 0, 1, (( OT->isEnabled() ) ? OnP : OffP) );
+}
+
+//
+// end of namespace
+//
+
+};
diff --git a/noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.h b/noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.h
new file mode 100644
index 0000000..92ae612
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2_applet/opietoothapplet.h
@@ -0,0 +1,99 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de>
+           .>+-=
+ _;:,     .>    :=|. This library is free software; you can
+.> <,   >  .   <= redistribute it and/or modify it under
+:=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%+i>       _;_.
+    .i_,=:_.      -<s. This library is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-= this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef __OPIETOOTH2APPLET_H__
+#define __OPIETOOTH2APPLET_H__
+
+#include <qwidget.h>
+#include <qpixmap.h>
+#include <qlabel.h>
+#include <qtimer.h>
+
+namespace Opietooth2 {
+
+class OTGateway;
+
+class MessagePanel : public QLabel {
+
+ Q_OBJECT
+
+public:
+
+ MessagePanel( const QString & Msg,
+ QWidget* parent = 0,
+ const char* name=0);
+
+ void popup( QWidget* parent = 0);
+
+protected:
+
+ virtual void mouseReleaseEvent( QMouseEvent * );
+ virtual void closeEvent( QCloseEvent * );
+
+private:
+
+ QWidget* popupParent;
+ int moves;
+
+};
+
+class Opietooth2Applet : public QWidget {
+
+ Q_OBJECT
+
+public:
+
+ Opietooth2Applet( QWidget *parent = 0, const char *name=0 );
+ ~Opietooth2Applet();
+
+public slots:
+
+ // sent when device changes state
+ void SLOT_StateChange( bool );
+ void SLOT_Error( const QString & );
+
+private:
+
+ void mousePressEvent( QMouseEvent * );
+ void paintEvent( QPaintEvent* );
+
+ void launchManager();
+
+private:
+
+ OTGateway * OT;
+ QPixmap OnP;
+ QPixmap OffP;
+
+};
+
+};
+
+
+#endif
+
diff --git a/noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.cpp b/noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.cpp
new file mode 100644
index 0000000..f9cee4d
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.cpp
@@ -0,0 +1,72 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de>
+           .>+-=
+ _;:,     .>    :=|. This library is free software; you can
+.> <,   >  .   <= redistribute it and/or modify it under
+:=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%+i>       _;_.
+    .i_,=:_.      -<s. This library is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-= this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#include "opietoothapplet.h"
+#include "opietoothappletimpl.h"
+
+namespace Opietooth2 {
+
+ BluezAppletImpl::BluezAppletImpl() : bluetooth(0), ref(0) {
+ }
+
+ BluezAppletImpl::~BluezAppletImpl() {
+ delete bluetooth;
+ }
+
+ QWidget *BluezAppletImpl::applet( QWidget *parent ) {
+ if ( !bluetooth ) {
+ bluetooth = new Opietooth2Applet( parent );
+ }
+ return bluetooth;
+ }
+
+ int BluezAppletImpl::position() const {
+ return 6;
+ }
+
+ QRESULT BluezAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) {
+ *iface = 0;
+ if ( uuid == IID_QUnknown ) {
+ *iface = this;
+ } else if ( uuid == IID_TaskbarApplet ) {
+ *iface = this;
+ }
+
+ if ( *iface ) {
+ (*iface)->addRef();
+ }
+ return QS_OK;
+ }
+
+ Q_EXPORT_INTERFACE() {
+ Q_CREATE_INSTANCE( BluezAppletImpl )
+ }
+
+};
+
+
diff --git a/noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.h b/noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.h
new file mode 100644
index 0000000..8a4d9ab
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2_applet/opietoothappletimpl.h
@@ -0,0 +1,55 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de>
+           .>+-=
+ _;:,     .>    :=|. This library is free software; you can
+.> <,   >  .   <= redistribute it and/or modify it under
+:=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%+i>       _;_.
+    .i_,=:_.      -<s. This library is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-= this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+#ifndef OPIETOOTH2APPLETIMPL_H
+#define OPIETOOTH2APPLETIMPL_H
+
+#include <qpe/taskbarappletinterface.h>
+
+namespace Opietooth2 {
+
+ class Opietooth2Applet;
+
+ class BluezAppletImpl : public TaskbarAppletInterface {
+ public:
+ BluezAppletImpl();
+ virtual ~BluezAppletImpl();
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+ Q_REFCOUNT
+
+ virtual QWidget *applet( QWidget *parent );
+ virtual int position() const;
+
+ private:
+ Opietooth2Applet *bluetooth;
+ ulong ref;
+ };
+};
+
+#endif