summaryrefslogtreecommitdiff
authorchicken <chicken>2004-03-01 16:23:00 (UTC)
committer chicken <chicken>2004-03-01 16:23:00 (UTC)
commit032f2d909293fb29e6c7e3cf9cce1a12484c80f7 (patch) (side-by-side diff)
tree368c696aff4d167727aaa564176b6ab1eb0df5cd
parent9bc70bb8a0bdd3a7bc0013f2cacce7c039b88b38 (diff)
downloadopie-032f2d909293fb29e6c7e3cf9cce1a12484c80f7.zip
opie-032f2d909293fb29e6c7e3cf9cce1a12484c80f7.tar.gz
opie-032f2d909293fb29e6c7e3cf9cce1a12484c80f7.tar.bz2
fix includes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/rotateapplet/rotate.cpp4
-rw-r--r--core/applets/rotateapplet/rotate.h1
-rw-r--r--core/applets/screenshotapplet/inputDialog.cpp3
-rw-r--r--core/applets/screenshotapplet/screenshot.cpp1
-rw-r--r--core/applets/suspendapplet/suspend.cpp2
-rw-r--r--core/applets/volumeapplet/oledbox.cpp1
-rw-r--r--core/applets/volumeapplet/volume.cpp4
-rw-r--r--core/applets/volumeapplet/volumeappletimpl.cpp2
-rw-r--r--core/applets/vtapplet/vt.cpp3
-rw-r--r--core/apps/calibrate/main.cpp1
-rw-r--r--core/obex/obex.cc4
-rw-r--r--core/obex/obexhandler.cpp1
-rw-r--r--core/obex/obexsend.cpp4
-rw-r--r--core/obex/receiver.cpp4
14 files changed, 0 insertions, 35 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp
index cf3f28b..dcbf809 100644
--- a/core/applets/rotateapplet/rotate.cpp
+++ b/core/applets/rotateapplet/rotate.cpp
@@ -1,256 +1,252 @@
/*
This file is part of the OPIE Project
Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org>
Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net>
               =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de>
             .=l.
           .>+-=
 _;:,     .>    :=|. 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 "rotate.h"
/* OPIE */
#include <opie/odevice.h>
-#include <qpe/applnk.h>
#include <qpe/config.h>
#include <qpe/power.h>
-#include <qpe/qpeapplication.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/resource.h>
using namespace Opie;
/* QT */
-#include <qiconset.h>
-#include <qpopupmenu.h>
#include <time.h>
RotateApplet::RotateApplet()
:QObject( 0, "RotateApplet" ), m_flipped( false )
{
#if !defined(QT_NO_COP)
QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this );
connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ),
this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) );
#endif
}
RotateApplet::~RotateApplet ( )
{}
/**
* Qcop receive method.
*/
void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data )
{
qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg );
if ( ODevice::inst()->hasHingeSensor() )
{
struct timespec interval;
struct timespec remain;
interval.tv_sec = 0;
interval.tv_nsec = 600000;
::nanosleep( &interval, &remain );
OHingeStatus status = ODevice::inst()->readHingeSensor();
qDebug( "RotateApplet::readHingeSensor = %d", (int) status );
Config cfg( "apm" );
cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" );
int action = cfg.readNumEntry( "CloseHingeAction", 0 );
if ( status == CASE_CLOSED )
{
switch ( action )
{
case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break;
case 2: /* SUSPEND */ ODevice::inst()->suspend(); break;
default: /* IGNORE */ break;
}
}
else /* status != CASE_CLOSED */
{
switch ( action )
{
case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break;
case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break;
default: /* IGNORE */ break;
}
}
qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) );
}
QDataStream stream( data, IO_ReadOnly );
if ( msg == "flip()" )
{
activated ( );
}
else if ( msg == "rotateDefault()")
{
rotateDefault();
}
}
int RotateApplet::position() const
{
return 3;
}
QString RotateApplet::name() const
{
return tr( "Rotate shortcut" );
}
QString RotateApplet::text() const
{
return tr( "Rotate" );
}
/*QString RotateApplet::tr( const char* s ) const
{
return qApp->translate( "RotateApplet", s, 0 );
}
QString RotateApplet::tr( const char* s, const char* p ) const
{
return qApp->translate( "RotateApplet", s, p );
}
*/
QIconSet RotateApplet::icon() const
{
QPixmap pix;
QImage img = Resource::loadImage( "Rotation" );
if ( !img.isNull() )
pix.convertFromImage( img.smoothScale( 14, 14 ) );
return pix;
}
QPopupMenu* RotateApplet::popup(QWidget*) const
{
return 0;
}
void RotateApplet::rotateDefault()
{
int rot = ODevice::inst()->rotation();
switch (rot)
{
case Rot0: rot=0; break;
case Rot90: rot=90; break;
case Rot180: rot=180; break;
case Rot270: rot=270; break;
default: rot=0; break;
}
Config cfg( "qpe" );
cfg.setGroup( "Appearance" );
bool rotateEnabled = cfg.readBoolEntry( "rotateEnabled",true );
if ( !rotateEnabled) return;
// hide inputs methods before rotation
QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" );
QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" );
env << rot;
m_flipped = false;
}
void RotateApplet::activated()
{
int defaultRotation = QPEApplication::defaultRotation();
int newRotation = defaultRotation;
Config cfg( "qpe" );
cfg.setGroup( "Appearance" );
int rotDirection = cfg.readNumEntry( "rotatedir" );
ODirection rot = CW;
if (rotDirection == -1)
{
rot = ODevice::inst()->direction();
}
else
{
rot = (ODirection) rotDirection;
}
// hide inputs methods before rotation
QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" );
if ( m_flipped )
{
// if flipped, flip back to the original state,
// regardless of rotation direction
newRotation = defaultRotation;
}
else
{
if ( rot == CCW )
{
newRotation = ( defaultRotation + 90 ) % 360;
}
else if ( rot == CW )
{
newRotation = ( defaultRotation + 270 ) % 360;
}
else if ( rot == Flip )
{
newRotation = ( defaultRotation + 180 ) % 360;
}
}
QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" );
env << newRotation;
m_flipped = !m_flipped;
}
QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
{
*iface = 0;
if ( uuid == IID_QUnknown )
*iface = this;
else if ( uuid == IID_MenuApplet )
*iface = this;
else
return QS_FALSE;
if ( *iface )
(*iface)->addRef();
return QS_OK;
}
Q_EXPORT_INTERFACE()
{
Q_CREATE_INSTANCE( RotateApplet )
}
diff --git a/core/applets/rotateapplet/rotate.h b/core/applets/rotateapplet/rotate.h
index 2396993..bdccea0 100644
--- a/core/applets/rotateapplet/rotate.h
+++ b/core/applets/rotateapplet/rotate.h
@@ -1,71 +1,70 @@
/*
               =. This file is part of the OPIE Project
             .=l. Copyright (c) 2003 Maximilian Reiss <harlekin@handhelds.org>
           .>+-=
 _;:,     .>    :=|. 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 __OPIE_ROTATE_APPLET_H__
#define __OPIE_ROTATE_APPLET_H__
#include <qpe/menuappletinterface.h>
#include <qobject.h>
-#include <qobject.h>
class RotateApplet : public QObject, public MenuAppletInterface
{
Q_OBJECT
public:
RotateApplet ( );
virtual ~RotateApplet ( );
QRESULT queryInterface( const QUuid&, QUnknownInterface** );
Q_REFCOUNT
virtual int position() const;
virtual QString name ( ) const;
virtual QIconSet icon ( ) const;
virtual QString text ( ) const;
/* virtual QString tr( const char* ) const;
virtual QString tr( const char*, const char* ) const;
*/
virtual QPopupMenu *popup ( QWidget *parent ) const;
virtual void activated ( );
virtual void rotateDefault ( );
private slots:
void channelReceived( const QCString &msg, const QByteArray & data );
private:
bool m_flipped : 1;
};
#endif
diff --git a/core/applets/screenshotapplet/inputDialog.cpp b/core/applets/screenshotapplet/inputDialog.cpp
index f506dfd..73ec773 100644
--- a/core/applets/screenshotapplet/inputDialog.cpp
+++ b/core/applets/screenshotapplet/inputDialog.cpp
@@ -1,67 +1,64 @@
/****************************************************************************
** Form implementation generated from reading ui file 'inputDialog.ui'
**
** Created: Sat Mar 2 07:55:03 2002
** by: The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#include "inputDialog.h"
#include <qpe/resource.h>
#include <opie2/ofiledialog.h>
#include <qlineedit.h>
-#include <qlayout.h>
-#include <qvariant.h>
#include <qpushbutton.h>
-#include <qwhatsthis.h>
InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "InputDialog" );
resize( 234, 115);
setMaximumSize( QSize( 240, 40));
setCaption( tr(name ) );
QPushButton *browserButton;
browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton");
browserButton->setGeometry( QRect( 205, 10, 22, 22));
connect( browserButton, SIGNAL(released()),this,SLOT(browse()));
LineEdit1 = new QLineEdit( this, "LineEdit1" );
LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
}
/*
* Destroys the object and frees any allocated resources
*/
InputDialog::~InputDialog()
{
inputText= LineEdit1->text();
}
void InputDialog::browse() {
MimeTypes types;
QStringList audio, video, all;
audio << "audio/*";
audio << "playlist/plain";
audio << "audio/x-mpegurl";
video << "video/*";
video << "playlist/plain";
all += audio;
all += video;
types.insert("All Media Files", all );
types.insert("Audio", audio );
types.insert("Video", video );
QString str = Opie::OFileDialog::getOpenFileName( 1,"/","", types, 0 );
LineEdit1->setText(str);
}
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp
index 5f83539..56a031c 100644
--- a/core/applets/screenshotapplet/screenshot.cpp
+++ b/core/applets/screenshotapplet/screenshot.cpp
@@ -1,292 +1,291 @@
/**********************************************************************
** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com
** All rights reserved.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#include "screenshot.h"
#include "inputDialog.h"
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <qpe/qpeapplication.h>
#include <qpe/applnk.h>
#include <qlineedit.h>
#include <qdir.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qpainter.h>
#include <qspinbox.h>
#include <qlayout.h>
#include <qcheckbox.h>
#include <qmessagebox.h>
-#include <qimage.h>
/* XPM */
static char * snapshot_xpm[] = {
"32 32 177 2",
" c None",
". c #042045",
"+ c #0D2B47",
"@ c #0E325E",
"# c #0D2E50",
"$ c #0A1C32",
"% c #0F3A69",
"& c #164680",
"* c #165EAE",
"= c #134D89",
"- c #0A3A6E",
"; c #031024",
"> c #031B36",
", c #1A5EA3",
"' c #1862B1",
") c #1866B9",
"! c #0F5AAC",
"~ c #0F56A8",
"{ c #0C4C96",
"] c #030918",
"^ c #060206",
"/ c #20242C",
"( c #3E3B3B",
"_ c #186ABD",
": c #115EB3",
"< c #082644",
"[ c #222C38",
"} c #5A5859",
"| c #091921",
"1 c #1E7EDE",
"2 c #1A7ADA",
"3 c #1970CD",
"4 c #1758A1",
"5 c #0E529A",
"6 c #094388",
"7 c #22364E",
"8 c #384454",
"9 c #04162C",
"0 c #123451",
"a c #3296B4",
"b c #298AB1",
"c c #2484AC",
"d c #033D86",
"e c #033677",
"f c #072C58",
"g c #525862",
"h c #5E5E5E",
"i c #23492A",
"j c #4FBD3F",
"k c #50B24C",
"l c #51C72E",
"m c #42C64A",
"n c #2686CA",
"o c #0B52A4",
"p c #054A9A",
"q c #053B7C",
"r c #2B2325",
"s c #6E7070",
"t c #0D240E",
"u c #1E423E",
"v c #468ABE",
"w c #6A8AC2",
"x c #7EAA8E",
"y c #84BE4E",
"z c #65C639",
"A c #064EA0",
"B c #0A4DA0",
"C c #4E5242",
"D c #62362E",
"E c #721A1A",
"F c #6E0A0A",
"G c #3E0E0E",
"H c #6AB85E",
"I c #7E8ECA",
"J c #929CD4",
"K c #9EAECA",
"L c #9EBEAE",
"M c #8EC26A",
"N c #32A276",
"O c #20518C",
"P c #46566E",
"Q c #614A51",
"R c #AE2A26",
"S c #C41C1A",
"T c #CE0A0A",
"U c #A60606",
"V c #921616",
"W c #863735",
"X c #866A66",
"Y c #9E9EA2",
"Z c #1E5212",
"` c #7EC652",
" . c #B2B2F2",
".. c #CACAF6",
"+. c #AECEC6",
"@. c #92CE72",
"#. c #42AA86",
"$. c #365E96",
"%. c #B82420",
"&. c #E20E0E",
"*. c #EF0E0B",
"=. c #566A86",
"-. c #92929A",
";. c #16260E",
">. c #2E571A",
",. c #7ED64E",
"'. c #9ECEB2",
"). c #C6D5EF",
"!. c #E2E0FE",
"~. c #A2DE8A",
"{. c #4AAA5B",
"]. c #2A6AB2",
"^. c #9A7A6E",
"/. c #D25A52",
"(. c #F62626",
"_. c #FA0206",
":. c #DE1E16",
"<. c #B63A26",
"[. c #865A2E",
"}. c #26568E",
"|. c #435F7D",
"1. c #7AE246",
"2. c #96EA6E",
"3. c #BEEAAE",
"4. c #D0EADC",
"5. c #B6CEFE",
"6. c #9ADE8A",
"7. c #2A609A",
"8. c #7E623E",
"9. c #CA7A72",
"0. c #F26E6E",
"a. c #FE5252",
"b. c #FA3638",
"c. c #DA2E28",
"d. c #9E3E3A",
"e. c #3E7656",
"f. c #76CB3A",
"g. c #90DE44",
"h. c #A2EE6A",
"i. c #9EEA9A",
"j. c #92BEDE",
"k. c #7ADA7E",
"l. c #5ECE52",
"m. c #6A5E52",
"n. c #A83238",
"o. c #FA5656",
"p. c #F29A92",
"q. c #D29E92",
"r. c #8A7A62",
"s. c #05336B",
"t. c #59C631",
"u. c #8AD23A",
"v. c #66E242",
"w. c #1D6FC1",
"x. c #E61212",
"y. c #CA261E",
"z. c #5A763E",
"A. c #1E6E9A",
"B. c #023272",
"C. c #329696",
"D. c #2074B6",
"E. c #3E4E76",
"F. c #5A525E",
"G. c #425868",
"H. c #04448E",
"I. c #28828A",
"J. c #2D8593",
"K. c #12427A",
"L. c #054696",
"M. c #042B5E",
"N. c #134F95",
"O. c #1E6ABB",
"P. c #1A5E96",
"Q. c #022E67",
"R. c #0C3E7C",
"S. c #023E8A",
"T. c #021A3E",
" ",
" ",
" ",
" . + @ # + ",
" $ # % & * * = - # $ ",
"; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ",
"; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ",
"| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ",
"9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ",
"| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ",
"t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ",
"| u H I J K L M H k N 3 3 : ~ o o 5 O P Q R S T T U V W X Y ",
"| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ",
";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ",
";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ",
";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ",
"t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ",
"| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ",
"; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ",
"9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ",
"9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ",
"; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ",
"; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ",
" ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ",
" # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ",
" + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ",
" < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ",
" $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ",
" ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ",
" | > e L.d L.H.e M.. ; ] ] ",
" > 9 . S.Q.. ; ] ",
" T.; ] "};
static const char *SCAP_hostname = "www.handhelds.org";
static const int SCAP_port = 80;
ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name )
: QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
{
setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 );
QHBoxLayout *hbox;
hbox = new QHBoxLayout ( vbox );
QLabel *l = new QLabel ( tr( "Delay" ), this );
hbox-> addWidget ( l );
delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" );
delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus );
delaySpin-> setSuffix ( tr( "sec" ));
delaySpin-> setFocusPolicy( QWidget::NoFocus );
delaySpin-> setValue ( 1 );
hbox-> addWidget ( delaySpin );
saveNamedCheck = new QCheckBox ( tr( "Save named" ), this);
saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus );
vbox->addWidget( saveNamedCheck);
vbox-> addSpacing ( 3 );
l = new QLabel ( tr( "Save screenshot as..." ), this );
vbox-> addWidget ( l, AlignCenter );
hbox = new QHBoxLayout ( vbox );
grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" );
grabItButton ->setFocusPolicy( QWidget::TabFocus );
hbox-> addWidget ( grabItButton );
scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" );
scapButton ->setFocusPolicy( QWidget::TabFocus );
hbox-> addWidget ( scapButton );
diff --git a/core/applets/suspendapplet/suspend.cpp b/core/applets/suspendapplet/suspend.cpp
index e17142b..0eb94cb 100644
--- a/core/applets/suspendapplet/suspend.cpp
+++ b/core/applets/suspendapplet/suspend.cpp
@@ -1,87 +1,85 @@
#include <qpe/resource.h>
#include <qpe/qcopenvelope_qws.h>
#include <qapplication.h>
-#include <qiconset.h>
-#include <qpopupmenu.h>
#include "suspend.h"
SuspendApplet::SuspendApplet ( )
: QObject ( 0, "SuspendApplet" )
{
}
SuspendApplet::~SuspendApplet ( )
{
}
int SuspendApplet::position ( ) const
{
return 2;
}
QString SuspendApplet::name ( ) const
{
return tr( "Suspend shortcut" );
}
QString SuspendApplet::text ( ) const
{
return tr( "Suspend" );
}
QString SuspendApplet::tr( const char* s ) const
{
return qApp->translate( "SuspendApplet", s, 0 );
}
QString SuspendApplet::tr( const char* s, const char* p ) const
{
return qApp->translate( "SuspendApplet", s, p );
}
QIconSet SuspendApplet::icon ( ) const
{
QPixmap pix;
QImage img = Resource::loadImage ( "suspend" );
if ( !img. isNull ( ))
pix. convertFromImage ( img. smoothScale ( 14, 14 ));
return pix;
}
QPopupMenu *SuspendApplet::popup ( QWidget * ) const
{
return 0;
}
void SuspendApplet::activated ( )
{
// suspend
QCopEnvelope ( "QPE/System", "suspend()" );
}
QRESULT SuspendApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
{
*iface = 0;
if ( uuid == IID_QUnknown )
*iface = this;
else if ( uuid == IID_MenuApplet )
*iface = this;
else
return QS_FALSE;
if ( *iface )
(*iface)-> addRef ( );
return QS_OK;
}
Q_EXPORT_INTERFACE( )
{
Q_CREATE_INSTANCE( SuspendApplet )
}
diff --git a/core/applets/volumeapplet/oledbox.cpp b/core/applets/volumeapplet/oledbox.cpp
index 7547287..bf275a9 100644
--- a/core/applets/volumeapplet/oledbox.cpp
+++ b/core/applets/volumeapplet/oledbox.cpp
@@ -1,258 +1,257 @@
-#include <qpixmap.h>
#include <qbitmap.h>
#include <qpainter.h>
#include "oledbox.h"
#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
/* XPM */
static const char * ledborder_xpm[] = {
"16 16 11 1",
" c None",
". c #626562",
"+ c #7B7D7B",
"@ c #949594",
"# c #ACAEAC",
"$ c #CDCACD",
"% c #CDCECD",
"; c #E6E6E6",
"> c #FFFFFF",
", c #E6E2E6",
"' c #FFFAFF",
" .++@@# ",
" ...++@@##$ ",
" .....+@##$$% ",
" ..... #$%%% ",
" ... %%; ",
".... ;;;;",
"++. ;>>",
"+++ >>>",
"@@@ >>>",
"@@# >>>",
"#### >>>>",
" #$$ >>> ",
" $$,,' >>>>> ",
" ,,,''>>>>>>> ",
" ,''>>>>>>> ",
" '>>>>> "};
QPixmap *OLedBox::s_border_pix = 0;
#endif
OLedBox::OLedBox ( const QColor &col, QWidget *parent, const char *name ) : QWidget ( parent, name )
{
m_color = col;
m_on = false;
m_pix [ 0 ] = m_pix [ 1 ] = false;
setBackgroundMode ( PaletteBackground );
#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
if ( !s_border_pix )
s_border_pix = new QPixmap ( ledborder_xpm );
#endif
}
OLedBox::~OLedBox ( )
{
delete m_pix [ 0 ];
delete m_pix [ 1 ];
}
QSize OLedBox::sizeHint ( ) const
{
return QSize ( 16, 16 );
}
bool OLedBox::isOn ( ) const
{
return m_on;
}
QColor OLedBox::color ( ) const
{
return m_color;
}
void OLedBox::setOn ( bool b )
{
if ( m_on != b ) {
m_on = b;
update ( );
}
}
void OLedBox::toggle ( )
{
setOn ( !isOn ( ) );
}
void OLedBox::setColor ( const QColor &col )
{
if ( m_color != col ) {
m_color = col;
delete m_pix [ 0 ];
delete m_pix [ 1 ];
update ( );
}
}
void OLedBox::mousePressEvent ( QMouseEvent *e )
{
if ( e-> button ( ) == LeftButton ) {
m_on = !m_on;
update ( );
emit toggled ( m_on );
}
}
void OLedBox::resizeEvent ( QResizeEvent * )
{
delete m_pix [ 0 ];
delete m_pix [ 1 ];
update ( );
}
void OLedBox::paintEvent ( QPaintEvent *e )
{
int ind = m_on ? 1 : 0;
if ( !m_pix [ ind ] ) {
m_pix [ ind ] = new QPixmap ( size ( ));
drawLed ( m_pix [ ind ], m_on ? m_color : m_color. dark ( 300 ) );
}
if ( !e-> erased ( ))
erase ( );
QPainter p ( this );
p. drawPixmap ( 0, 0, *m_pix [ ind ] );
}
// From KDE libkdeui / led.cpp
void OLedBox::drawLed ( QPixmap *pix, const QColor &col ) // paint a ROUND SUNKEN led lamp
{
QPainter paint;
QColor color;
QBrush brush;
QPen pen;
pix-> fill ( black );
// First of all we want to know what area should be updated
// Initialize coordinates, width, and height of the LED
int width = pix-> width ( );
// Make sure the LED is round!
if ( width > pix-> height ( ))
width = pix-> height ( );
width -= 2; // leave one pixel border
if ( width < 0 )
width = 0;
// maybe we could stop HERE, if width <=0 ?
// start painting widget
//
paint.begin( pix );
// Set the color of the LED according to given parameters
color = col;
// Set the brush to SolidPattern, this fills the entire area
// of the ellipse which is drawn first
brush.setStyle( QBrush::SolidPattern );
brush.setColor( color );
paint.setBrush( brush ); // Assign the brush to the painter
// Draws a "flat" LED with the given color:
paint.drawEllipse( 1, 1, width, width );
// Draw the bright light spot of the LED now, using modified "old"
// painter routine taken from KDEUIs KLed widget:
// Setting the new width of the pen is essential to avoid "pixelized"
// shadow like it can be observed with the old LED code
pen.setWidth( 2 );
// shrink the light on the LED to a size about 2/3 of the complete LED
int pos = width / 5 + 1;
int light_width = width;
light_width *= 2;
light_width /= 3;
// Calculate the LEDs "light factor":
int light_quote = ( 130 * 2 / ( light_width ? light_width : 1 ) ) + 100;
// Now draw the bright spot on the LED:
while ( light_width )
{
color = color.light( light_quote ); // make color lighter
pen.setColor( color ); // set color as pen color
paint.setPen( pen ); // select the pen for drawing
paint.drawEllipse( pos, pos, light_width, light_width ); // draw the ellipse (circle)
light_width--;
if ( !light_width )
break;
paint.drawEllipse( pos, pos, light_width, light_width );
light_width--;
if ( !light_width )
break;
paint.drawEllipse( pos, pos, light_width, light_width );
pos++;
light_width--;
}
// Drawing of bright spot finished, now draw a thin border
// around the LED which resembles a shadow with light coming
// from the upper left.
#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
paint. drawPixmap ( 0, 0, *s_border_pix );
paint. end ( );
pix-> setMask ( pix-> createHeuristicMask ( ));
#else
pen.setWidth( 3 );
brush.setStyle( QBrush::NoBrush ); // Switch off the brush
paint.setBrush( brush ); // This avoids filling of the ellipse
// Set the initial color value to 200 (bright) and start
// drawing the shadow border at 45 (45*16 = 720).
int shadow_color = 200, angle;
for ( angle = 720; angle < 6480; angle += 240 )
{
color.setRgb( shadow_color, shadow_color, shadow_color );
pen.setColor( color );
paint.setPen( pen );
paint.drawArc( 0, 0, width+2, width+2, angle, 240 );
paint.drawArc( 1, 1, width, width, angle, 240 );
paint.drawArc( 2, 2, width-2, width-2, angle, 240 );
if ( angle < 2320 ) {
shadow_color -= 25; // set color to a darker value
if ( shadow_color < 100 )
shadow_color = 100;
}
else if ( ( angle > 2320 ) && ( angle < 5760 ) ) {
shadow_color += 25; // set color to a brighter value
if ( shadow_color > 255 )
shadow_color = 255;
}
else {
shadow_color -= 25; // set color to a darker value again
if ( shadow_color < 100 )
shadow_color = 100;
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index 38f827e..c736437 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -1,298 +1,294 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include <stdio.h>
#include "volume.h"
#include <qpe/resource.h>
-#include <qpe/qpeapplication.h>
#include <qpe/applnk.h>
#include <qpe/config.h>
#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
#include <qpe/qcopenvelope_qws.h>
#endif
#include <qpainter.h>
#include <qcheckbox.h>
#include <qslider.h>
#include <qlayout.h>
-#include <qframe.h>
-#include <qpixmap.h>
#include <qvbox.h>
#include <qlabel.h>
-#include <qtoolbutton.h>
#include <qpushbutton.h>
#include <qtimer.h>
#include <opie/odevice.h>
#include "oledbox.h"
using namespace Opie;
#define RATE_TIMER_INTERVAL 100
// Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time
// results in "hanging" buttons on the iPAQ due to quite high CPU consumption.
/* XPM */
static const char * vol_xpm[] = {
"20 20 3 1",
" c None",
". c #0000FF",
"+ c #000000",
" ",
" . ",
" . . . . ",
" . . . . . . ",
" . . . . . . . ",
" . . ..... . . ",
" . ... ..... ... ",
" ........... .... ",
" ................. ",
"++++++++++++++++++++",
" .................. ",
" . ............. . ",
" . ..... ....... ",
" . ... ..... . ",
" . ... ..... . ",
" . ... ..... ",
" . . . . . ",
" . . . ",
" . . . ",
" "};
/* XPM */
static const char * mic_xpm[] = {
"20 20 21 1",
" c None",
". c #000000",
"+ c #EEEEEE",
"@ c #B4B6B4",
"# c #8B8D8B",
"$ c #D5D6D5",
"% c #E6E6E6",
"& c #9C9D9C",
"* c #6A696A",
"= c #E6E2E6",
"- c #F6F2F6",
"; c #CDC6CD",
"> c #737573",
", c #4A484A",
"' c #DEDEDE",
") c #F6EEF6",
"! c #414041",
"~ c #202020",
"{ c #ACAEAC",
"] c #838583",
"^ c #6A656A",
" ",
" .... ",
" .+@+#. ",
" ..$%&%*. ",
" .=-.;=>=,. ",
" .'+).&+!+. ",
" .+;+;.~+~. ",
" ..%{%,.... ",
" ..&=>=~.. ",
" .+..]^,.. ",
" .+....... ",
" .%... ",
" .=... ",
" .+... ",
" .+... ",
" .... ",
" .... ",
" .. ",
" . ",
". "};
static const char * bass_xpm[] = {
"20 20 3 1",
" c None",
". c #000000",
"+ c #0000FF",
" ",
" ",
" ",
"..... +++ ......",
" +++++++ ",
" ++ ++ ",
"... ++ ... ++ ++ .",
" +++ ++ ++ ",
" ++++ ++ ",
"... ++++ .. ++ .....",
" ++ ++ ",
" ++ ++ ",
"..........++ ++ .",
" ++ ",
" ++ ",
"...... ++ .........",
" + ",
" ",
" ",
" "};
static const char * treble_xpm[] = {
"20 20 3 1",
" c None",
". c #0000FF",
"+ c #000000",
" .. ",
" . .. ",
" . .. ",
"++++++++ . .. ++++++",
" . . ",
" ... ",
"++++++++ . +++++++",
" .. ",
" .. . ",
"+++ .. ... +++++++",
" .. .. .. ",
" .. . . .. ",
"+++ .. . . + . +++++",
" .. . .. ",
" .. . .. ",
"++++ ...... +++++++",
" . ",
" .. . ",
" .. . ",
" .. "};
/* XPM */
static const char * alarm_xpm[] = {
"20 20 33 1",
" c None",
". c #080602",
"+ c #AAA602",
"@ c #252002",
"# c #434202",
"$ c #795602",
"% c #C3C20D",
"& c #DADAC2",
"* c #826002",
"= c #740502",
"- c #D6D602",
"; c #322E02",
"> c #826A02",
", c #F1F195",
"' c #959215",
") c #423602",
"! c #4B0302",
"~ c #844315",
"{ c #AAAA2A",
"] c #E2DE42",
"^ c #BA7E04",
"/ c #7F7502",
"( c #828276",
"_ c #FEFE4E",
": c #7D1902",
"< c #989656",
"[ c #260B02",
"} c #F7F7D8",
"| c #DCDA5A",
"1 c #823102",
"2 c #B1AC6B",
"3 c #F7F710",
"4 c #838204",
" ",
" ",
" 4'4/ ",
" /-^= ",
" 42{4>4 ",
" '2|+*$44 ",
" +2&3+$1*44 ",
" (%_}_+/$:>/4 ",
" 4%_}3+#;>:*4 ",
" 4%_}&+#[1$/4 ",
" 4%_,2')[~~>4 ",
" 4%33'4#@~1>4 ",
" 4%3344#[:>/4 ",
" 42&_3'4#@>:*44 ",
" 42|}}3'4#[;$)$44 ",
"444{]]2^~~:!!#.@##/ ",
"4444-%*:==!!=...../ ",
" /:[.. ",
" /@. ",
" "};
VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name )
: QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup )
{
m_icon = icon;
bool has_wav_alarm = true;
bool has_bass = true;
bool has_treble = true;
switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually
case Model_Zaurus_SL5000:
has_wav_alarm = false; //poor guys probably feeling left out...
break;
default:
break;
}
if ( !ODevice::inst ( )-> series ( ) == Model_iPAQ ) {
has_bass = false;
has_treble = false;
}
setFrameStyle ( QFrame::PopupPanel | QFrame::Raised );
QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 );
grid-> setSpacing ( 4 );
grid-> setMargin ( 6 );
QVBoxLayout *vbox;
QLabel *l;
vbox = new QVBoxLayout ( );
vbox-> setSpacing ( 4 );
grid-> addLayout ( vbox, 1, 0 );
upButton = new QPushButton ( this );
upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
upButton-> setPixmap ( Resource::loadPixmap ( "up" ));
upButton-> setFocusPolicy ( QWidget::NoFocus );
vbox-> addWidget ( upButton );
downButton = new QPushButton ( this );
downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
downButton-> setPixmap ( Resource::loadPixmap ( "down" ));
downButton-> setFocusPolicy ( QWidget::NoFocus );
vbox-> addWidget ( downButton );
volSlider = new QSlider ( this );
volSlider-> setRange ( 0, 100 );
volSlider-> setTickmarks ( QSlider::Both );
volSlider-> setTickInterval ( 20 );
volSlider-> setFocusPolicy ( QWidget::NoFocus );
l = new QLabel ( this );
diff --git a/core/applets/volumeapplet/volumeappletimpl.cpp b/core/applets/volumeapplet/volumeappletimpl.cpp
index 4cbab31..9c7dea3 100644
--- a/core/applets/volumeapplet/volumeappletimpl.cpp
+++ b/core/applets/volumeapplet/volumeappletimpl.cpp
@@ -1,67 +1,65 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "volume.h"
#include "volumeappletimpl.h"
-#include <qpe/qcopenvelope_qws.h>
-#include <qpe/config.h>
VolumeAppletImpl::VolumeAppletImpl()
: volume(0)
{
}
VolumeAppletImpl::~VolumeAppletImpl()
{
delete volume;
}
QWidget *VolumeAppletImpl::applet( QWidget *parent )
{
if ( !volume )
volume = new VolumeApplet( parent );
return volume;
}
int VolumeAppletImpl::position() const
{
return 6;
}
QRESULT VolumeAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
{
*iface = 0;
if ( uuid == IID_QUnknown )
*iface = this;
else if ( uuid == IID_TaskbarApplet )
*iface = this;
else
return QS_FALSE;
if ( *iface )
(*iface)->addRef();
return QS_OK;
}
Q_EXPORT_INTERFACE()
{
Q_CREATE_INSTANCE( VolumeAppletImpl )
}
diff --git a/core/applets/vtapplet/vt.cpp b/core/applets/vtapplet/vt.cpp
index 881eb41..bd39093 100644
--- a/core/applets/vtapplet/vt.cpp
+++ b/core/applets/vtapplet/vt.cpp
@@ -1,164 +1,161 @@
/**********************************************************************
** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
**
** Contact me @ mickeyl@handhelds.org
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#include <qpe/resource.h>
-#include <qpe/qcopenvelope_qws.h>
-#include <qapplication.h>
-#include <qiconset.h>
#include <qpopupmenu.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
#include "vt.h"
VTApplet::VTApplet ( )
: QObject ( 0, "VTApplet" )
{
}
VTApplet::~VTApplet ( )
{
}
int VTApplet::position ( ) const
{
return 2;
}
QString VTApplet::name ( ) const
{
return tr( "VT shortcut" );
}
QString VTApplet::text ( ) const
{
return tr( "Terminal" );
}
/*
QString VTApplet::tr( const char* s ) const
{
return qApp->translate( "VTApplet", s, 0 );
}
QString VTApplet::tr( const char* s, const char* p ) const
{
return qApp->translate( "VTApplet", s, p );
}
*/
QIconSet VTApplet::icon ( ) const
{
QPixmap pix;
QImage img = Resource::loadImage ( "terminal" );
if ( !img. isNull ( ))
pix. convertFromImage ( img. smoothScale ( 14, 14 ));
return pix;
}
QPopupMenu *VTApplet::popup ( QWidget* parent ) const
{
qDebug( "VTApplet::popup" );
struct vt_stat vtstat;
int fd = ::open( "/dev/tty0", O_RDWR );
if ( fd == -1 ) return 0;
if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0;
m_subMenu = new QPopupMenu( parent );
m_subMenu->setCheckable( true );
for ( int i = 1; i < 10; ++i )
{
int id = m_subMenu->insertItem( QString::number( i ), 500+i );
m_subMenu->setItemChecked( id, id-500 == vtstat.v_active );
}
::close( fd );
connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) );
connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) );
return m_subMenu;
}
void VTApplet::changeVT( int index )
{
//qDebug( "VTApplet::changeVT( %d )", index-500 );
int fd = ::open("/dev/tty0", O_RDWR);
if ( fd == -1 ) return;
ioctl( fd, VT_ACTIVATE, index-500 );
}
void VTApplet::updateMenu()
{
//qDebug( "VTApplet::updateMenu()" );
int fd = ::open( "/dev/console", O_RDONLY );
if ( fd == -1 ) return;
for ( int i = 1; i < 10; ++i )
{
int result = ioctl( fd, VT_DISALLOCATE, i );
/*
if ( result == -1 )
qDebug( "VT %d disallocated == free", i );
else
qDebug( "VT %d _not_ disallocated == busy", i );
*/
m_subMenu->setItemEnabled( 500+i, result == -1 );
}
::close( fd );
}
void VTApplet::activated()
{
qDebug( "VTApplet::activated()" );
}
QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
{
*iface = 0;
if ( uuid == IID_QUnknown )
*iface = this;
else if ( uuid == IID_MenuApplet )
*iface = this;
else
return QS_FALSE;
if ( *iface )
(*iface)-> addRef ( );
return QS_OK;
}
Q_EXPORT_INTERFACE( )
{
Q_CREATE_INSTANCE( VTApplet )
}
diff --git a/core/apps/calibrate/main.cpp b/core/apps/calibrate/main.cpp
index ec9b5ec..0da0fe0 100644
--- a/core/apps/calibrate/main.cpp
+++ b/core/apps/calibrate/main.cpp
@@ -1,47 +1,46 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "calibrate.h"
-#include <qfile.h>
#include <qpe/qpeapplication.h>
#ifdef QWS
#include <qwindowsystem_qws.h>
#endif
int main( int argc, char ** argv )
{
QPEApplication a( argc, argv );
int retval = 0;
#ifdef QWS
if ( QWSServer::mouseHandler() &&
QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) {
#endif
// Make sure calibration widget starts on top.
Calibrate cal;
a.setMainWidget(&cal);
a.showMainWidget(&cal);
return a.exec();
#ifdef QWS
}
#endif
}
diff --git a/core/obex/obex.cc b/core/obex/obex.cc
index 2a306de..50e5201 100644
--- a/core/obex/obex.cc
+++ b/core/obex/obex.cc
@@ -1,203 +1,199 @@
-#include <qapplication.h>
-#include <qfile.h>
#include <qfileinfo.h>
-#include <qtextcodec.h>
-#include <qpe/qcopenvelope_qws.h>
#include <opie/oprocess.h>
#include "obex.h"
using namespace OpieObex;
/* TRANSLATOR OpieObex::Obex */
Obex::Obex( QObject *parent, const char* name )
: QObject(parent, name )
{
m_rec = 0;
m_send=0;
m_count = 0;
m_receive = false;
connect( this, SIGNAL(error(int) ), // for recovering to receive
SLOT(slotError() ) );
connect( this, SIGNAL(sent(bool) ),
SLOT(slotError() ) );
};
Obex::~Obex() {
delete m_rec;
delete m_send;
}
void Obex::receive() {
m_receive = true;
m_outp = QString::null;
qWarning("Receive" );
m_rec = new OProcess();
*m_rec << "irobex_palm3";
// connect to the necessary slots
connect(m_rec, SIGNAL(processExited(OProcess*) ),
this, SLOT(slotExited(OProcess*) ) );
connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ),
this, SLOT(slotStdOut(OProcess*, char*, int) ) );
if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
qWarning("could not start :(");
emit done( false );
delete m_rec;
m_rec = 0;
}
// emit currentTry(m_count );
}
void Obex::send( const QString& fileName) { // if currently receiving stop it send receive
m_count = 0;
m_file = fileName;
qWarning("send %s", fileName.latin1() );
if (m_rec != 0 ) {
qWarning("running");
if (m_rec->isRunning() ) {
emit error(-1 );
qWarning("is running");
delete m_rec;
m_rec = 0;
}else{
qWarning("is not running");
emit error( -1 ); // we did not delete yet but it's not running slotExited is pending
return;
}
}
sendNow();
}
void Obex::sendNow(){
qWarning("sendNow");
if ( m_count >= 25 ) { // could not send
emit error(-1 );
emit sent(false);
return;
}
// OProcess inititialisation
m_send = new OProcess();
*m_send << "irobex_palm3";
*m_send << QFile::encodeName(m_file);
// connect to slots Exited and and StdOut
connect(m_send, SIGNAL(processExited(OProcess*) ),
this, SLOT(slotExited(OProcess*)) );
connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )),
this, SLOT(slotStdOut(OProcess*, char*, int) ) );
// now start it
if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) {
qWarning("could not send" );
m_count = 25;
emit error(-1 );
delete m_send;
m_send=0;
}
// end
m_count++;
emit currentTry( m_count );
}
void Obex::slotExited(OProcess* proc ){
if (proc == m_rec ) { // receive process
received();
}else if ( proc == m_send ) {
sendEnd();
}
}
void Obex::slotStdOut(OProcess* proc, char* buf, int len){
if ( proc == m_rec ) { // only receive
QByteArray ar( len );
memcpy( ar.data(), buf, len );
qWarning("parsed: %s", ar.data() );
m_outp.append( ar );
}
}
void Obex::received() {
if (m_rec->normalExit() ) {
if ( m_rec->exitStatus() == 0 ) { // we got one
QString filename = parseOut();
qWarning("ACHTUNG %s", filename.latin1() );
emit receivedFile( filename );
}
}else{
emit done(false);
};
delete m_rec;
m_rec = 0;
receive();
}
void Obex::sendEnd() {
if (m_send->normalExit() ) {
if ( m_send->exitStatus() == 0 ) {
delete m_send;
m_send=0;
qWarning("done" );
emit sent(true);
}else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready
// let's try it again
delete m_send;
m_send = 0;
qWarning("try sending again" );
sendNow();
}
}else {
emit error( -1 );
delete m_send;
m_send = 0;
}
}
QString Obex::parseOut( ){
QString path;
QStringList list = QStringList::split("\n", m_outp);
QStringList::Iterator it;
for (it = list.begin(); it != list.end(); ++it ) {
if ( (*it).startsWith("Wrote" ) ) {
int pos = (*it).findRev('(' );
if ( pos > 0 ) {
qWarning( "%d %s", pos, (*it).mid(6 ).latin1() ) ;
qWarning("%d %d", (*it).length(), (*it).length()-pos );
path = (*it).remove( pos, (*it).length() - pos );
qWarning("%s", path.latin1() );
path = path.mid(6 );
path = path.stripWhiteSpace();
qWarning("path %s", path.latin1() );
}
}
}
return path;
}
/**
* when sent is done slotError is called we will start receive again
*/
void Obex::slotError() {
qWarning("slotError");
if ( m_receive )
receive();
};
void Obex::setReceiveEnabled( bool receive ) {
if ( !receive ) { //
m_receive = false;
shutDownReceive();
}
}
void Obex::shutDownReceive() {
if (m_rec != 0 ) {
qWarning("running");
if (m_rec->isRunning() ) {
emit error(-1 );
qWarning("is running");
delete m_rec;
m_rec = 0;
}
}
}
diff --git a/core/obex/obexhandler.cpp b/core/obex/obexhandler.cpp
index c237555..4034560 100644
--- a/core/obex/obexhandler.cpp
+++ b/core/obex/obexhandler.cpp
@@ -1,68 +1,67 @@
-#include <qcopchannel_qws.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include "obexsend.h"
#include "receiver.h"
#include "obexhandler.h"
using namespace OpieObex;
/* TRANSLATOR OpieObex::ObexHandler */
ObexHandler::ObexHandler() {
m_wasRec = false;
m_sender = 0l;
m_receiver = 0l;
QCopChannel* chan = new QCopChannel("QPE/Obex");
connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
this, SLOT(irdaMessage(const QCString&, const QByteArray& ) ) );
}
ObexHandler::~ObexHandler() {
delete m_sender;
delete m_receiver;
}
void ObexHandler::doSend(const QString& str, const QString& desc) {
delete m_sender;
m_sender = new SendWidget;
m_sender->raise();
QPEApplication::showWidget( m_sender );
connect(m_sender, SIGNAL(done() ),
this, SLOT(slotSent() ) );
m_sender->send( str, desc );
}
void ObexHandler::doReceive(bool b) {
if (m_receiver && b ) return; // we should enable receiver and it is on
else if (!m_receiver && !b ) return; // we should disbale receiver and it is off
else if (m_receiver && !b ) {
delete m_receiver;
m_receiver=0;
}else if (!m_receiver && b ) {
m_receiver= new Receiver;
}
}
void ObexHandler::slotSent() {
QString file = m_sender->file();
delete m_sender;
m_sender = 0;
QCopEnvelope e ("QPE/Obex", "done(QString)" );
e << file;
doReceive(m_wasRec );
m_wasRec = false;
}
void ObexHandler::irdaMessage( const QCString& msg, const QByteArray& data) {
QDataStream stream( data, IO_ReadOnly );
if ( msg == "send(QString,QString,QString)" ) {
QString name, desc;
stream >> desc;
stream >> name;
m_wasRec = (m_receiver != 0 );
doReceive( false );
doSend(name, desc);
}else if (msg == "receive(int)") {
int rec;
stream >> rec;
doReceive(rec);
}
}
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp
index cf5d958..6b8d467 100644
--- a/core/obex/obexsend.cpp
+++ b/core/obex/obexsend.cpp
@@ -1,266 +1,262 @@
#include <qpushbutton.h>
#include <qlabel.h>
-#include <qhbox.h>
#include <qlayout.h>
#include <qtimer.h>
-#include <qtl.h>
-#include <qcopchannel_qws.h>
-#include <qpe/resource.h>
#include <qpe/qcopenvelope_qws.h>
#include "obex.h"
#include "obexsend.h"
using namespace OpieObex;
/* TRANSLATOR OpieObex::SendWidget */
SendWidget::SendWidget( QWidget* parent, const char* name )
: QWidget( parent, name ) {
initUI();
}
SendWidget::~SendWidget() {
}
void SendWidget::initUI() {
m_obex = new Obex(this, "obex");
connect(m_obex, SIGNAL(error(int) ),
this, SLOT(slotIrError(int) ) );
connect(m_obex, SIGNAL(sent(bool) ),
this, SLOT(slotIrSent(bool) ) );
connect(m_obex, SIGNAL(currentTry(unsigned int ) ),
this, SLOT(slotIrTry(unsigned int ) ) );
QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this );
connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
this, SLOT(dispatchIrda(const QCString&, const QByteArray& ) ) );
chan = new QCopChannel("QPE/BluetoothBack", this );
connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
this, SLOT(dispatchBt(const QCString&, const QByteArray& ) ) );
QVBoxLayout* lay = new QVBoxLayout(this);
QHBox* nameBox = new QHBox(this);
QLabel* name = new QLabel(nameBox);
name->setText( tr("<qt><h1>Sending:</h1></qt>") );
name->setAlignment( AlignLeft | AlignTop );
m_lblFile = new QLabel(nameBox);
lay->addWidget(nameBox, 0);
QFrame* frame = new QFrame(this);
frame->setFrameShape( QFrame::HLine );
frame->setFrameShadow( QFrame::Sunken );
lay->addWidget(frame, 10);
QLabel* devices = new QLabel(this);
devices->setText("<qt><b>Devices:</b></qt>");
devices->setAlignment( AlignLeft | AlignTop );
lay->addWidget( devices,10 );
m_devBox = new DeviceBox(this);
lay->addWidget( m_devBox, 50 );
connect(m_devBox, SIGNAL(selectedDevice(int, int ) ),
this, SLOT(slotSelectedDevice(int, int) ) );
QPushButton *but = new QPushButton(this);
but->setText(tr("Done") );
connect(but, SIGNAL(clicked() ),
this, SLOT(slotDone() ) );
lay->addWidget( but );
m_lay = lay;
// QT does not like if you add items to an layout which already exits....
// and was layouted invalidate() does not help too
// so we use RichText....
}
/*
* in send we'll first set everything up
* and then wait for a list of devices.
*/
void SendWidget::send( const QString& file, const QString& desc ) {
m_file = file;
m_irDa.clear();
m_start = 0;
m_lblFile->setText(desc.isEmpty() ? file : desc );
if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) {
m_irDeSearch = m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error );
m_start++;
}else
m_irDeSearch = m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search );
if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) {
m_btDeSearch = m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error );
m_start++;
}else
m_btDeSearch = m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search );
if (m_start != 2 ) {
QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()");
QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()");
QCopEnvelope e2("QPE/IrDaApplet", "listDevices()");
QCopEnvelope e3("QPE/Bluetooth", "listDevices()");
}
}
void SendWidget::slotIrDaDevices( const QStringList& list) {
qWarning("slot it irda devices ");
for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) {
int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") );
m_irDa.insert( id, (*it) );
}
m_devBox->removeDevice( m_irDeSearch );
m_irDaIt = m_irDa.begin();
slotStartIrda();
}
void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) {
for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) {
int id = m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") );
m_bt.insert( id, Pair( it.key(), it.data() ) );
}
m_devBox->removeDevice( m_btDeSearch );
}
void SendWidget::slotSelectedDevice( int name, int dev ) {
qWarning("Start beam? %d %d", name, dev );
if ( name == m_irDeSearch ) {
for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it )
m_devBox->removeDevice( it.key() );
QCopEnvelope e2("QPE/IrDaApplet", "listDevices()");
}
}
void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) {
qWarning("dispatch irda %s", str.data() );
if ( str == "devices(QStringList)" ) {
QDataStream stream( ar, IO_ReadOnly );
QStringList list;
stream >> list;
slotIrDaDevices( list );
}
}
void SendWidget::dispatchBt( const QCString&, const QByteArray& ) {
}
void SendWidget::slotIrError( int ) {
}
void SendWidget::slotIrSent( bool b) {
qWarning("irda sent!!");
QString text = b ? tr("Sent") : tr("Failure");
m_devBox->setStatus( m_irDaIt.key(), text );
++m_irDaIt;
slotStartIrda();
}
void SendWidget::slotIrTry(unsigned int trI) {
m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) );
}
void SendWidget::slotStartIrda() {
if (m_irDaIt == m_irDa.end() ) {
m_irDeSearch = m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search );
return;
}
m_devBox->setStatus( m_irDaIt.key(), tr("Start sending") );
m_obex->send( m_file );
}
void SendWidget::closeEvent( QCloseEvent* e) {
e->accept(); // make sure
QTimer::singleShot(0, this, SLOT(slotDone() ) );
}
void SendWidget::slotDone() {
QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()");
QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()");
emit done();
}
QString SendWidget::file()const {
return m_file;
}
DeviceBox::DeviceBox( QWidget* parent )
: QTextBrowser( parent ) {
}
DeviceBox::~DeviceBox() {
}
int DeviceBox::addDevice( const QString& name, int dev, const QString& status ) {
/* return a id for a range of devices */
int id = idFor ( dev );
DeviceItem item( name, status, dev,id );
m_dev.insert( id, item );
setText( allText() );
return id;
}
void DeviceBox::removeDevice( int id ) {
if (!m_dev.contains(id) ) return;
m_dev.remove( id );
setText( allText() );
}
void DeviceBox::setStatus( int id, const QString& status ) {
if ( !m_dev.contains(id) ) return;
m_dev[id].setStatus(status );
setText( allText() );
}
void DeviceBox::setSource( const QString& str ) {
qWarning("SetSource:%d", str.toInt() );
int id = str.toInt();
emit selectedDevice( id, m_dev[id].device() );
}
int DeviceBox::idFor ( int id ) {
static int irId = 1501;
static int irBT = 1001;
static int irSr = 501;
static int irEr = 0;
int ret = -1;
switch(id ) {
case IrDa:
ret = irId;
irId++;
break;
case BT:
ret = irBT;
irBT++;
break;
case Search:
ret = irSr;
irSr++;
break;
case Error:
ret = irEr;
irEr++;
break;
}
return ret;
}
QString DeviceBox::allText() {
QString str;
typedef QMap<int, DeviceItem> DeviceMap;
for (QMap<int, DeviceItem>::Iterator it = m_dev.begin(); it != m_dev.end(); ++it ) {
str += it.data().toString() + "<br>";
}
return str;
}
DeviceItem::DeviceItem( const QString& name,
const QString& status, int dev, int id)
{
m_name = name;
m_status = status;
m_dev = dev;
m_id = id;
}
int DeviceItem::id()const {
return m_id;
}
QString DeviceItem::name()const {
return m_name;
}
QString DeviceItem::status()const {
diff --git a/core/obex/receiver.cpp b/core/obex/receiver.cpp
index bf9e30c..7d9f7ec 100644
--- a/core/obex/receiver.cpp
+++ b/core/obex/receiver.cpp
@@ -1,203 +1,199 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <stdlib.h> // int system
#include <unistd.h>
#include <fcntl.h>
-#include <qfile.h>
#include <qfileinfo.h>
#include <qlabel.h>
-#include <qhbox.h>
-#include <qregexp.h>
#include <qtextview.h>
#include <qpushbutton.h>
#include <qpe/applnk.h>
#include <qpe/qpeapplication.h>
#include <qpe/qcopenvelope_qws.h>
-#include <qpe/global.h>
#include "obex.h"
#include "receiver.h"
using namespace OpieObex;
/* TRANSLATOR OpieObex::Receiver */
Receiver::Receiver() {
m_obex = new Obex(this, "Receiver");
connect(m_obex, SIGNAL(receivedFile(const QString& ) ),
this, SLOT(slotReceived(const QString& ) ) );
m_obex->receive();
}
Receiver::~Receiver() {
m_obex->setReceiveEnabled( false );
delete m_obex;
}
void Receiver::slotReceived( const QString& _file ) {
QString file = _file;
int check = checkFile(file);
if ( check == AddressBook )
handleAddr( file );
else if ( check == Datebook )
handleDateTodo( file );
else
handleOther( file );
}
void Receiver::handleAddr( const QString& str ) {
QCopEnvelope e("QPE/Application/addressbook", "setDocument(QString)" );
e << str;
}
/* we can not say for sure if it's a VEevent ot VTodo */
void Receiver::handleDateTodo( const QString& str ) {
QCopEnvelope e0("QPE/Application/todolist", "setDocument(QString)");
e0 << str;
QCopEnvelope e1("QPE/Application/datebook", "setDocument(QString)" );
e1 << str;
}
/*
* Handle other asks if it should accept the
* beamed object and creates a DocLnk
*/
void Receiver::handleOther( const QString& other ) {
OtherHandler* hand = new OtherHandler();
hand->handle( other );
}
void Receiver::tidyUp( QString& _file, const QString& ending) {
/* libversit fails on BASE64 encoding we try to sed it away */
QString file = _file;
char foo[24]; // big enough
(void)::strcpy(foo, "/tmp/opie-XXXXXX");
int fd = ::mkstemp(foo);
if ( fd == -1 )
return;
(void)::strncat( foo, ending.latin1(), 4 );
_file = QString::fromLatin1( foo );
QString cmd = QString("sed -e \"s/^\\(X-MICROSOFT-BODYINK\\)\\;/\\1:/;\" < %2 > %2 ").arg( Global::shellQuote(file)).arg( Global::shellQuote(_file) );
qWarning("Executing: %s", cmd.latin1() );
(void)::system( cmd.latin1() );
cmd = QString("rm %1").arg( Global::shellQuote(file) );
(void)::system( cmd.latin1() );
}
int Receiver::checkFile( QString& file ) {
qWarning("check file!! %s", file.latin1() );
int ret;
QString ending;
if (file.right(4) == ".vcs" ) {
ret = Datebook;
ending = QString::fromLatin1(".vcs");
}else if ( file.right(4) == ".vcf") {
ret = AddressBook;
ending = QString::fromLatin1(".vcf");
}else
ret = Other;
if (ending.isEmpty() )
return ret;
/**
* currently the parser is broken in regard of BASE64 encoding
* and M$ likes to send that. So we will executed a small
* tidy up system sed script
* At this point we can also remove umlaute from the filename
*/
tidyUp( file, ending );
qWarning("check it now %d", ret );
return ret;
}
/* TRANSLATOR OpieObex::OtherHandler */
OtherHandler::OtherHandler()
: QVBox()
{
QHBox* box = new QHBox(this);
QLabel* lbl = new QLabel(box);
lbl->setText(tr("<qt><b>Received:</b></qt>"));
m_na = new QLabel(box);
QFrame* frame = new QFrame(this);
frame->setFrameShape( QFrame::HLine );
frame->setFrameShadow( QFrame::Sunken );
m_view = new QTextView(this);
box = new QHBox(this);
QPushButton *but = new QPushButton(box);
but->setText(tr("Accept") );
connect(but, SIGNAL(clicked() ),
this, SLOT(accept()) );
but = new QPushButton(box);
but->setText(tr("Deny") );
connect(but, SIGNAL(clicked() ),
this, SLOT(deny() ) );
raise();
showMaximized();
}
OtherHandler::~OtherHandler() {
}
void OtherHandler::handle( const QString& file ) {
m_file = file;
m_na->setText(file);
DocLnk lnk(file);
qWarning(" %s %s", lnk.type().latin1(), lnk.icon().latin1() );
QString str = tr("<p>You received a file of type %1 (<img src=\"%2\"> )What do you want to do?").arg(lnk.type() ).arg(lnk.icon() );
m_view->setText( str );
}
/*
* hehe evil evil mmap ahead :)
* we quickly copy the file and then we'll create a DocLnk for it
*/
void OtherHandler::accept() {
QString na = targetName( m_file );
copy(m_file, na );
DocLnk lnk(na);
lnk.writeLink();
QFile::remove(m_file);
delete this;
}
void OtherHandler::deny() {
QFile::remove( m_file );
delete this;
}
QString OtherHandler::targetName( const QString& file ) {
QFileInfo info( file );
/* $HOME needs to be set!!!! */
Global::createDocDir();
QString newFile = QPEApplication::documentDir()+ "/"+ info.baseName();
QString newFileBase = newFile;
int trie = 0;
while (QFile::exists(newFile + "."+info.extension() ) ) {
newFile = newFileBase + "_"+QString::number(trie) ;
trie++;
}
newFile += "." + info.extension();
return newFile;
}
/* fast cpy */
void OtherHandler::copy(const QString& src, const QString& file) {
qWarning("src %s, dest %s", src.latin1(),file.latin1() );
QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )).
arg( Global::shellQuote( file ) );
::system( cmd.latin1() );
// done
}