author | mickeyl <mickeyl> | 2004-04-05 12:48:49 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-05 12:48:49 (UTC) |
commit | f1708be741dfb73ceaffb633b44093f2cb2b3d57 (patch) (side-by-side diff) | |
tree | 0bdcab2ac6c5f0e5cac67eb58807a50bb79d82e0 | |
parent | 0b481957a2eebf28b05d9803780d05ad4232aa00 (diff) | |
download | opie-f1708be741dfb73ceaffb633b44093f2cb2b3d57.zip opie-f1708be741dfb73ceaffb633b44093f2cb2b3d57.tar.gz opie-f1708be741dfb73ceaffb633b44093f2cb2b3d57.tar.bz2 |
convert core/applets/* to Opie debug framework
-rw-r--r-- | core/applets/cardmon/cardmon.cpp | 20 | ||||
-rw-r--r-- | core/applets/clockapplet/clock.cpp | 4 | ||||
-rw-r--r-- | core/applets/irdaapplet/irda.cpp | 4 | ||||
-rw-r--r-- | core/applets/multikeyapplet/multikey.cpp | 2 | ||||
-rw-r--r-- | core/applets/restartapplet/restart.cpp | 2 | ||||
-rw-r--r-- | core/applets/restartapplet/restartappletimpl.cpp | 1 | ||||
-rw-r--r-- | core/applets/rotateapplet/rotate.cpp | 7 | ||||
-rw-r--r-- | core/applets/screenshotapplet/screenshot.cpp | 20 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 34 | ||||
-rw-r--r-- | core/applets/vtapplet/vt.cpp | 25 | ||||
-rw-r--r-- | core/obex/obexsend.cpp | 29 | ||||
-rw-r--r-- | core/obex/receiver.cpp | 41 |
12 files changed, 100 insertions, 89 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index 1ad8b55..3a6ad27 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp @@ -1,76 +1,72 @@ /* * cardmon.cpp * * --------------------- * * copyright : (c) 2002 by Maximilian Reiss * email : max.reiss@gmx.de * based on two apps by Devin Butterfield */ /*************************************************************************** * * * 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 "cardmon.h" /* OPIE */ +#include <opie2/odebug.h> #include <opie2/odevice.h> #include <opie2/otaskbarapplet.h> #include <qpe/applnk.h> #include <qpe/resource.h> +using namespace Opie::Core; +using namespace Opie::Ui; /* QT */ #include <qcopchannel_qws.h> #include <qpainter.h> #include <qfile.h> #include <qtextstream.h> #include <qsound.h> #include <qtimer.h> /* STD */ #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> - #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) #include <sys/vfs.h> #include <mntent.h> #endif -using namespace Opie; - -using namespace Opie::Ui; -using namespace Opie::Ui; -using namespace Opie::Core; - CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ), pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) { QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); connect( pcmciaChannel, SIGNAL( received(const QCString&,const QByteArray&) ), this, SLOT( cardMessage(const QCString&,const QByteArray&) ) ); QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this ); connect( sdChannel, SIGNAL( received(const QCString&,const QByteArray&) ), this, SLOT( cardMessage(const QCString&,const QByteArray&) ) ); cardInPcmcia0 = FALSE; cardInPcmcia1 = FALSE; cardInSd = FALSE; setFocusPolicy( NoFocus ); setFixedWidth ( AppLnk::smallIconSize() ); setFixedHeight ( AppLnk::smallIconSize() ); getStatusPcmcia( TRUE ); @@ -176,54 +172,54 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) if ( err != 0 ) { popUp( tr( "SD/MMC card eject failed!" ) ); } } else if ( opt == 2 ) { cmd = "/sbin/cardctl eject 1"; err = system( ( const char * ) cmd ); if ( err != 0 ) { qDebug( "Could not execute `/sbin/cardctl eject 1'! err=%d", err ); popUp( tr( "CF/PCMCIA card eject failed!" ) ); } } delete menu; } void CardMonitor::cardMessage( const QCString & msg, const QByteArray & ) { if ( msg == "stabChanged()" ) { - // qDebug("Pcmcia: stabchanged"); + // odebug << "Pcmcia: stabchanged" << oendl; getStatusPcmcia(); } else if ( msg == "mtabChanged()" ) { - // qDebug("CARDMONAPPLET: mtabchanged"); + // odebug << "CARDMONAPPLET: mtabchanged" << oendl; getStatusSd(); } } bool CardMonitor::getStatusPcmcia( int showPopUp ) { bool cardWas0 = cardInPcmcia0; // remember last state bool cardWas1 = cardInPcmcia1; QString fileName; // one of these 3 files should exist if ( QFile::exists( "/var/run/stab" ) ) { fileName = "/var/run/stab"; } else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { fileName = "/var/state/pcmcia/stab"; } else { fileName = "/var/lib/pcmcia/stab"; @@ -310,103 +306,103 @@ bool CardMonitor::getStatusPcmcia( int showPopUp ) if ( cardWas1 != cardInPcmcia1 ) { if ( cardInPcmcia1 ) { text += tr( "New card: " ); what = "on"; } else { text += tr( "Ejected: " ); what = "off"; } text += cardInPcmcia1Name; popUp( text, "cardmon/" + cardInPcmcia1Type ); } #ifndef QT_NO_SOUND QSound::play( Resource::findSound( "cardmon/card" + what ) ); #endif } } else { // no file found - qDebug( "no file found" ); + odebug << "no file found" << oendl; cardInPcmcia0 = FALSE; cardInPcmcia1 = FALSE; } repaint( FALSE ); return ( ( cardWas0 == cardInPcmcia0 && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE ); } bool CardMonitor::getStatusSd( int showPopUp ) { bool cardWas = cardInSd; // remember last state cardInSd = FALSE; #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) struct mntent *me; FILE *mntfp = setmntent( "/etc/mtab", "r" ); if ( mntfp ) { while ( ( me = getmntent( mntfp ) ) != 0 ) { QString fs = me->mnt_fsname; - //qDebug( fs ); + //odebug << fs << oendl; if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" || fs.left( 9 ) == "/dev/mmcd" ) { cardInSd = TRUE; show(); } // else { // cardInSd = FALSE; // } } endmntent( mntfp ); } if ( !showPopUp && cardWas != cardInSd ) { QString text = QString::null; QString what = QString::null; if ( cardInSd ) { text += "New card: SD/MMC"; what = "on"; } else { text += "Ejected: SD/MMC"; what = "off"; } - //qDebug("TEXT: " + text ); + //odebug << "TEXT: " + text << oendl; #ifndef QT_NO_SOUND QSound::play( Resource::findSound( "cardmon/card" + what ) ); #endif popUp( text, "cardmon/ide" ); // XX add SD pic } #else #error "Not on Linux" #endif repaint( FALSE ); return ( ( cardWas == cardInSd ) ? FALSE : TRUE ); } void CardMonitor::paintEvent( QPaintEvent * ) { QPainter p( this ); if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { p.drawPixmap( 0, 0, pm ); show(); } else { diff --git a/core/applets/clockapplet/clock.cpp b/core/applets/clockapplet/clock.cpp index 3b13d74..7d396e7 100644 --- a/core/applets/clockapplet/clock.cpp +++ b/core/applets/clockapplet/clock.cpp @@ -1,52 +1,56 @@ /********************************************************************** ** 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 "clock.h" +/* OPIE */ +#include <opie2/odebug.h> #include <opie2/otaskbarapplet.h> #include <qpe/qpeapplication.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/config.h> +using namespace Opie::Core; using namespace Opie::Ui; + LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent ) { // If you want a sunken border around the clock do this: // setFrameStyle( QFrame::Panel | QFrame::Sunken ); //setFont( QFont( "Helvetica", , QFont::Normal ) ); connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime() ) ); connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( slotClockChanged(bool) ) ); readConfig(); timerId = 0; timerEvent( 0 ); show(); } int LauncherClock::position() { return 10; } void LauncherClock::readConfig() { Config config( "qpe" ); config.setGroup( "Time" ); ampmFormat = config.readBoolEntry( "AMPM", TRUE ); config.setGroup( "Date" ); diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp index 2196d18..7122b40 100644 --- a/core/applets/irdaapplet/irda.cpp +++ b/core/applets/irdaapplet/irda.cpp @@ -186,61 +186,61 @@ void IrdaApplet::showDiscovered ( ) QFile discovery ( "/proc/net/irda/discovery" ); if ( discovery. open ( IO_ReadOnly )) { bool qcopsend = false; QString discoveredDevice; QString deviceAddr; // since it is /proc we _must_ use QTextStream QStringList list = QStringList::split ( "\n", QTextStream ( &discovery ). read ( )); QMap <QString, QString>::Iterator it; for ( it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) it. data ( ). prepend ( "+++" ); for ( QStringList::Iterator lit = list. begin ( ); lit != list. end ( ); ++lit ) { const QString &line = *lit; if ( line. startsWith ( "nickname:" )) { discoveredDevice = line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) - line. find ( ':' ) - 2 ); deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 ); - // qDebug(discoveredDevice + "(" + deviceAddr + ")"); + // odebug << discoveredDevice + "(" + deviceAddr + ")" << oendl; if ( !m_devices. contains ( deviceAddr )) { popup ( tr( "Found:" ) + " " + discoveredDevice ); //snd_found. play ( ); qcopsend = true; } m_devices. replace ( deviceAddr, discoveredDevice ); } } for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) { - // qDebug("IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?"); + // odebug << "IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?" << oendl; if ( it. data ( ). left ( 3 ) == "+++" ) { popup ( tr( "Lost:" ) + " " + it. data ( ). mid ( 3 )); //snd_lost. play ( ); QMap <QString, QString>::Iterator tmp = it; tmp++; m_devices. remove ( it ); // in contrast to QValueListIterator this remove doesn't return the next Iterator it = tmp; qcopsend = true; } else it++; } // XXX if( qcopsend ) { QCopEnvelope e ( "QPE/Network", "irdaSend(bool)" ); e << ( m_devices. count ( ) > 0 ); // } } } void IrdaApplet::mousePressEvent ( QMouseEvent * ) { diff --git a/core/applets/multikeyapplet/multikey.cpp b/core/applets/multikeyapplet/multikey.cpp index 195ada5..195d8a4 100644 --- a/core/applets/multikeyapplet/multikey.cpp +++ b/core/applets/multikeyapplet/multikey.cpp @@ -47,49 +47,49 @@ void Multikey::mousePressEvent(QMouseEvent *ev) QPoint p = mapToGlobal(QPoint(0, 0)); QSize s = popupMenu.sizeHint(); int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), p.y() - s.height()), 0); if (opt == -1) return; lang = opt; QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); e << sw_maps[lang]; setText(labels[lang]); } QWidget::mousePressEvent(ev); } void Multikey::mouseReleaseEvent(QMouseEvent *ev) { if (!sw_maps.count()) return; lang = lang < sw_maps.count()-1 ? lang+1 : 0; QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); - //qDebug("Lang=%d, count=%d, lab=%s", lang, sw_maps.count(), labels[lang].ascii()); + //odebug << "Lang=" << lang << ", count=" << sw_maps.count() << ", lab=" << labels[lang].ascii() << "" << oendl; e << sw_maps[lang]; setText(labels[lang]); } void Multikey::message(const QCString &message, const QByteArray &data) { if ( message == "setsw(QString,QString)" ) { QDataStream stream(data, IO_ReadOnly); QString maps, current_map; stream >> maps >> current_map; QStringList sw = QStringList::split(QChar('|'), maps); sw.append(current_map); QDir map_dir(QPEApplication::qpeDir() + "/share/multikey/", "*.keymap"); lang = 0; labels.clear(); sw_maps.clear(); popupMenu.clear(); for (uint i = 0; i < sw.count(); ++i) { QString keymap_map; if (sw[i][0] != '/') { diff --git a/core/applets/restartapplet/restart.cpp b/core/applets/restartapplet/restart.cpp index 226c2a8..2e17608 100644 --- a/core/applets/restartapplet/restart.cpp +++ b/core/applets/restartapplet/restart.cpp @@ -32,41 +32,39 @@ static char *restart_xpm[] = { "& c #FFDCA8", "* c #FFFFC0", "= c #FFFFFF", "- c #585858", " .. ", " .. .++. .. ", " .+@.@##@.@+. ", " .@+$@%%@$+@. ", " .$%%&%&%$. ", " ..+@%&$$%&@+.. ", ".+#@%&%@@&*%@#+.", ".$@+$&*&&=*$+@$.", " .--+$&*=&$+--. ", " .$#++$$++#$. ", " .@=$-$++$-$=@. ", " .+@-..@@..-@+. ", " ... .+=. ... ", " .-$. ", " .. ", " "}; RestartApplet::RestartApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { setFixedHeight( 18 ); setFixedWidth( 16 ); - qDebug("new restartapplet"); show(); } RestartApplet::~RestartApplet() { } void RestartApplet::mousePressEvent( QMouseEvent *) { QCopEnvelope e("QPE/System", "restart()"); } void RestartApplet::paintEvent( QPaintEvent* ) { QPainter p(this); - qDebug("paint RESTART pixmap"); p.drawPixmap( 0, 1, ( const char** ) restart_xpm ); } diff --git a/core/applets/restartapplet/restartappletimpl.cpp b/core/applets/restartapplet/restartappletimpl.cpp index d8e10d3..3adc80c 100644 --- a/core/applets/restartapplet/restartappletimpl.cpp +++ b/core/applets/restartapplet/restartappletimpl.cpp @@ -12,49 +12,48 @@ ** 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 "restart.h" #include "restartappletimpl.h" RestartAppletImpl::RestartAppletImpl() : restart(0) { } RestartAppletImpl::~RestartAppletImpl() { delete restart; } QWidget *RestartAppletImpl::applet( QWidget *parent ) { - qDebug("restart applet"); if ( !restart ) restart = new RestartApplet( parent ); return restart; } int RestartAppletImpl::position() const { return 6; } QRESULT RestartAppletImpl::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; } diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp index f621aa9..f23423d 100644 --- a/core/applets/rotateapplet/rotate.cpp +++ b/core/applets/rotateapplet/rotate.cpp @@ -10,114 +10,115 @@ :=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 <opie2/odebug.h> #include <opie2/odevice.h> #include <qpe/config.h> #include <qpe/power.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/resource.h> using namespace Opie::Core; /* QT */ #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 ); + odebug << "RotateApplet::channelReceived( '" << msg << "' )" << oendl; 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 ); + odebug << "RotateApplet::readHingeSensor = " << (int) status << "" << oendl; 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 ) ); + odebug << "RotateApplet::switchAction " << cfg.readNumEntry( "CloseHingeAction" ) << " performed." << oendl; } 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 diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp index 9aa012a..938ea0c 100644 --- a/core/applets/screenshotapplet/screenshot.cpp +++ b/core/applets/screenshotapplet/screenshot.cpp @@ -1,66 +1,68 @@ /********************************************************************** ** 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" /* OPIE */ +#include <opie2/odebug.h> #include <opie2/otaskbarapplet.h> #include <qpe/qpeapplication.h> #include <qpe/applnk.h> +using namespace Opie::Core; +using namespace Opie::Ui; /* QT */ #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> /* STD */ #include <stdlib.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <unistd.h> /* XPM */ -using namespace Opie::Ui; 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", @@ -341,144 +343,144 @@ void ScreenshotControl::slotScap() { buttonPushed = 2; hide(); if ( delaySpin->value() ) grabTimer->start( delaySpin->value() * 1000, true ); else show(); } void ScreenshotControl::savePixmap() { DocLnk lnk; QString fileName; if ( setFileName) { fileName = FileNamePath; //not sure why this is needed here, but it forgets fileName // if this is below the braces if (fileName.right(3) != "png") fileName = fileName + ".png"; lnk.setFile(fileName); //sets File property - qDebug("saving file " + fileName); + odebug << "saving file " + fileName << oendl; snapshot.save( fileName, "PNG"); QFileInfo fi( fileName); lnk.setName( fi.fileName()); //sets file name if (!lnk.writeLink()) - qDebug("Writing doclink did not work"); + odebug << "Writing doclink did not work" << oendl; } else { fileName = "sc_" + QDateTime::currentDateTime().toString(); fileName.replace(QRegExp("'"), ""); fileName.replace(QRegExp(" "), "_"); fileName.replace(QRegExp(":"), "."); fileName.replace(QRegExp(","), ""); QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; if ( !QDir( dirName).exists() ) { - qDebug("making dir " + dirName); + odebug << "making dir " + dirName << oendl; QString msg = "mkdir -p " + dirName; system(msg.latin1()); } fileName = dirName + fileName; if (fileName.right(3) != "png") fileName = fileName + ".png"; lnk.setFile(fileName); //sets File property - qDebug("saving file " + fileName); + odebug << "saving file " + fileName << oendl; snapshot.save( fileName, "PNG"); QFileInfo fi( fileName); lnk.setName( fi.fileName()); //sets file name if (!lnk.writeLink()) - qDebug("Writing doclink did not work"); + odebug << "Writing doclink did not work" << oendl; } QPEApplication::beep(); } void ScreenshotControl::performGrab() { snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); if (buttonPushed == 1) { - qDebug("grabbing screen"); + odebug << "grabbing screen" << oendl; grabTimer->stop(); show(); qApp->processEvents(); savePixmap(); } else { grabTimer->stop(); struct sockaddr_in raddr; struct hostent *rhost_info; int sock = -1; bool ok = false; QString displayEnv = getenv("QWS_DISPLAY"); - qDebug(displayEnv); + odebug << displayEnv << oendl; if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); raddr. sin_family = rhost_info-> h_addrtype; raddr. sin_port = htons ( SCAP_port ); if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { QString header; QPixmap pix; QString SCAP_model=""; #warning FIXME: model string should be filled with actual device model if( snapshot.width() > 320) SCAP_model ="Corgi"; if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! pix = snapshot.xForm(QWMatrix().rotate(90)); } else pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user "Content-length: %3\n" // 3: content length "Content-Type: image/png\n" "Host: %4\n" // 4: scap host "\n"; header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); - qDebug(header); + odebug << header << oendl; if ( !pix.isNull() ) { const char *ascii = header.latin1( ); uint ascii_len = ::strlen( ascii ); ::write ( sock, ascii, ascii_len ); ::write ( sock, img.bits(), img.numBytes() ); ok = true; } } ::close ( sock ); } } if ( ok ) { QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); } else { QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); } } else { QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); } } } diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 7dd5b4b..622b1df 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp @@ -1,38 +1,42 @@ /************************************************************************************ ** ** 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. ** ************************************************************************************/ // copyright 2002 Jeremy Cowgar <jc@cowgar.com> // copyright 2002 and 2003 L.J.Potter <ljp@llornkcor.com> +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; + extern "C" { #include "adpcm.h" } #include <unistd.h> #include <stdio.h> #include <fcntl.h> #include <sys/ioctl.h> #include <linux/soundcard.h> #include <errno.h> typedef struct _waveheader { u_long main_chunk; /* 'RIFF' */ u_long length; /* filelen */ u_long chunk_type; /* 'WAVE' */ u_long sub_chunk; /* 'fmt ' */ u_long sc_len; /* length of sub_chunk, =16 (chunckSize) format len */ u_short format; /* should be 1 for PCM-code (formatTag) */ u_short modus; /* 1 Mono, 2 Stereo (channels) */ u_long sample_fq; /* samples per second (samplesPerSecond) */ u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ @@ -186,241 +190,241 @@ static char * vmemo_xpm[] = { " o p q r s t u v w n ", " o x y z A B C D E n ", " F G H I J K L M N O ", " P Q R S T U V W X ", " Y Z ` b ...+. ", " @.#.$.%.&. ", " *.B =. ", " n n n n n n n n n "}; using namespace Opie::Ui; VMemo::VMemo( QWidget *parent, const char *_name ) : QWidget( parent, _name ) { setFixedHeight( 18 ); setFixedWidth( 14 ); t_timer = new QTimer( this ); connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); Config vmCfg("Vmemo"); vmCfg.setGroup("Defaults"); int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); - qDebug("toggleKey %d", toggleKey); + odebug << "toggleKey " << toggleKey << "" << oendl; if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) systemZaurus=TRUE; else systemZaurus=FALSE; myChannel = new QCopChannel( "QPE/VMemo", this ); connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); if( toggleKey != -1 ) { // keyRegister(key, channel, message) QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); // e << 4096; // Key_Escape // e << Key_F5; //4148 e << toggleKey; e << QString("QPE/VMemo"); e << QString("toggleRecord()"); } if(toggleKey == 1) usingIcon=TRUE; else usingIcon=FALSE; if( vmCfg.readNumEntry("hideIcon",0) == 1) hide(); recording = FALSE; // } } VMemo::~VMemo() { } int VMemo::position() { return 6; } void VMemo::receive( const QCString &msg, const QByteArray &data ) { - qDebug("receive"); + odebug << "receive" << oendl; QDataStream stream( data, IO_ReadOnly ); if (msg == "toggleRecord()") { if (recording) { fromToggle = TRUE; stopRecording(); } else { fromToggle = TRUE; startRecording(); } } } void VMemo::paintEvent( QPaintEvent* ) { QPainter p(this); p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); } void VMemo::mousePressEvent( QMouseEvent * me) { /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions mousePressEvent and mouseReleaseEvent with a NULL parameter. */ // if (!systemZaurus && me != NULL) // return; // } if(!recording) startRecording(); else stopRecording(); } void VMemo::mouseReleaseEvent( QMouseEvent * ) { } bool VMemo::startRecording() { Config config( "Vmemo" ); config.setGroup( "System" ); useAlerts = config.readBoolEntry("Alert",1); if(useAlerts) { msgLabel = new QLabel( 0, "alertLabel" ); msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); msgLabel->show(); } - qDebug("Start recording engines"); + odebug << "Start recording engines" << oendl; recording = TRUE; if (openDSP() == -1) { recording = FALSE; return FALSE; } config.setGroup("Defaults"); date = TimeString::dateString( QDateTime::currentDateTime(),false,true); date.replace(QRegExp("'"),""); date.replace(QRegExp(" "),"_"); date.replace(QRegExp(":"),"."); date.replace(QRegExp(","),""); QString fName; config.setGroup( "System" ); fName = QPEApplication::documentDir() ; fileName = config.readEntry("RecLocation", fName); int s; s=fileName.find(':'); if(s) fileName=fileName.right(fileName.length()-s-2); - qDebug("pathname will be "+fileName); + odebug << "pathname will be "+fileName << oendl; if( fileName.left(1).find('/') == -1) fileName="/"+fileName; if( fileName.right(1).find('/') == -1) fileName+="/"; fName = "vm_"+ date+ ".wav"; fileName+=fName; - qDebug("filename is "+fileName); + odebug << "filename is "+fileName << oendl; // open tmp file here char *pointer; pointer=tmpnam(NULL); - qDebug("Opening tmp file %s",pointer); + odebug << "Opening tmp file " << pointer << "" << oendl; if(openWAV(pointer ) == -1) { QString err("Could not open the temp file\n"); err += fileName; QMessageBox::critical(0, "vmemo", err, "Abort"); ::close(dsp); return FALSE; } if( record() ) { QString cmd; if( fileName.find(".wav",0,TRUE) == -1) fileName += ".wav"; cmd.sprintf("mv %s "+fileName, pointer); // move tmp file to regular file here system(cmd.latin1()); QArray<int> cats(1); cats[0] = config.readNumEntry("Category", 0); QString dlName("vm_"); dlName += date; DocLnk l; l.setFile(fileName); l.setName(dlName); l.setType("audio/x-wav"); l.setCategories(cats); l.writeLink(); return TRUE; } else return FALSE; } void VMemo::stopRecording() { show(); - qDebug("Stopped recording"); + odebug << "Stopped recording" << oendl; recording = FALSE; if(useAlerts) { msgLabel->close(); msgLabel=0; delete msgLabel; } t_timer->stop(); Config cfg("Vmemo"); cfg.setGroup("Defaults"); if( cfg.readNumEntry("hideIcon",0) == 1 ) hide(); } int VMemo::openDSP() { Config cfg("Vmemo"); cfg.setGroup("Record"); speed = cfg.readNumEntry("SampleRate", 22050); channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) if (cfg.readNumEntry("SixteenBit", 1)==1) { format = AFMT_S16_LE; resolution = 16; } else { format = AFMT_U8; resolution = 8; } - qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); + odebug << "samplerate: " << speed << ", channels " << channels << ", resolution " << resolution << "" << oendl; if(systemZaurus) { dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 channels=1; //zaurus has one input channel } else { dsp = open("/dev/dsp", O_RDONLY); } if(dsp == -1) { msgLabel->close(); msgLabel=0; delete msgLabel; perror("open(\"/dev/dsp\")"); errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); return -1; } if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); return -1; } if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { @@ -462,153 +466,153 @@ int VMemo::openWAV(const char *filename) { wh.sc_len = 16; if(useADPCM) wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; else wh.format = PCM_CODE; wh.modus = channels; wh.sample_fq = speed; wh.byte_p_sec = speed * channels * resolution/8; wh.byte_p_spl = channels * (resolution / 8); wh.bit_p_spl = resolution; wh.data_chunk = DATA; wh.data_length= 0; // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); write (wav, &wh, sizeof(WaveHeader)); return 1; } bool VMemo::record() { length=0; int result, value; QString msg; msg.sprintf("Recording format %d", format); - qDebug(msg); + odebug << msg << oendl; Config config("Vmemo"); config.setGroup("Record"); int sRate=config.readNumEntry("SizeLimit", 30); if(sRate > 0) t_timer->start( sRate * 1000+1000, TRUE); // if(systemZaurus) { // } else { // 16 bit only capabilities msg.sprintf("Recording format other"); - qDebug(msg); + odebug << msg << oendl; int bufsize=1024; int bytesWritten=0; signed short sound[1024], monoBuffer[1024]; char abuf[bufsize/2]; short sbuf[bufsize]; Config vmCfg("Vmemo"); vmCfg.setGroup("Defaults"); useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); while(recording) { if(useADPCM) result = read( dsp, sbuf, bufsize); // 8192 else result = read(dsp, sound, 1024); // 8192 if( result <= 0) { perror("recording error "); -// qDebug(currentFileName); +// odebug << currentFileName << oendl; QMessageBox::message(tr("Note"),tr("error recording")); recording=FALSE; break; return FALSE; } if(useADPCM) { adpcm_coder( sbuf, abuf, result/2, &encoder_state); bytesWritten = ::write(wav, abuf, result/4); } else { for (int i = 0; i < result; i++) { //since Z is mono do normally monoBuffer[i] = sound[i]; } length+=write(wav, monoBuffer, result); } length +=bytesWritten; if(length<0) { recording=false; perror("dev/dsp's is a lookin' messy"); QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); break; return FALSE; } - // printf("%d\r",length); + // odebug << "" << length << "\r" << oendl; // fflush(stdout); qApp->processEvents(); } // qDebug("file has length of %d lasting %d seconds", // length, (( length / speed) / channels) / 2 ); // } //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// value = length+36; lseek(wav, 4, SEEK_SET); write(wav, &value, 4); lseek(wav, 40, SEEK_SET); write(wav, &length, 4); track.close(); - qDebug("Track closed"); + odebug << "Track closed" << oendl; if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) perror("ioctl(\"SNDCTL_DSP_RESET\")"); ::close(dsp); Config cfgO("OpieRec"); cfgO.setGroup("Sounds"); int nFiles = cfgO.readNumEntry( "NumberofFiles",0); QString currentFileName = fileName; QString currentFile = "vm_"+ date; float numberOfRecordedSeconds=(float) length / (float)speed * (float)2; cfgO.writeEntry( "NumberofFiles", nFiles + 1); cfgO.writeEntry( QString::number( nFiles + 1), currentFile); cfgO.writeEntry( currentFile, currentFileName); QString time; time.sprintf("%.2f", numberOfRecordedSeconds); cfgO.writeEntry( currentFileName, time ); - // qDebug("writing config numberOfRecordedSeconds "+time); + // odebug << "writing config numberOfRecordedSeconds "+time << oendl; cfgO.write(); - qDebug("done recording "+fileName); + odebug << "done recording "+fileName << oendl; Config cfg("qpe"); cfg.setGroup("Volume"); QString foo = cfg.readEntry("Mute","TRUE"); if(foo.find("TRUE",0,TRUE) != -1) QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute return TRUE; } int VMemo::setToggleButton(int tog) { for( int i=0; i < 10;i++) { switch (tog) { case 0: return -1; break; case 1: return 0; break; case 2: return Key_F24; //was Escape break; case 3: return Key_Space; diff --git a/core/applets/vtapplet/vt.cpp b/core/applets/vtapplet/vt.cpp index bd39093..aec63c3 100644 --- a/core/applets/vtapplet/vt.cpp +++ b/core/applets/vtapplet/vt.cpp @@ -1,161 +1,164 @@ /********************************************************************** -** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. -** -** Contact me @ mickeyl@handhelds.org +** Copyright (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> ** ** 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 "vt.h" + +/* OPIE */ +#include <opie2/odebug.h> #include <qpe/resource.h> +using namespace Opie::Core; +/* QT */ #include <qpopupmenu.h> +/* STD */ #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" ); + odebug << "VTApplet::popup" << oendl; 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 ); + //odebug << "VTApplet::changeVT( " << index-500 << " )" << oendl; int fd = ::open("/dev/tty0", O_RDWR); if ( fd == -1 ) return; ioctl( fd, VT_ACTIVATE, index-500 ); } void VTApplet::updateMenu() { - //qDebug( "VTApplet::updateMenu()" ); + //odebug << "VTApplet::updateMenu()" << oendl; 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 ); + odebug << "VT " << i << " disallocated == free" << oendl; else - qDebug( "VT %d _not_ disallocated == busy", i ); + odebug << "VT " << i << " _not_ disallocated == busy" << oendl; */ m_subMenu->setItemEnabled( 500+i, result == -1 ); } ::close( fd ); } void VTApplet::activated() { - qDebug( "VTApplet::activated()" ); + odebug << "VTApplet::activated()" << oendl; } 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/obex/obexsend.cpp b/core/obex/obexsend.cpp index cd8d58e..f3dd11c 100644 --- a/core/obex/obexsend.cpp +++ b/core/obex/obexsend.cpp @@ -1,40 +1,41 @@ +#include "obex.h" +#include "obexsend.h" +using namespace OpieObex; + +/* OPIE */ +#include <opie2/odebug.h> +#include <qpe/qcopenvelope_qws.h> +using namespace Opie::Core; + +/* QT */ #include <qpushbutton.h> #include <qlabel.h> #include <qlayout.h> #include <qtimer.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); @@ -83,92 +84,92 @@ void SendWidget::send( const QString& file, const QString& desc ) { 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 "); + owarn << "slot it irda devices " << oendl; 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 ); + owarn << "Start beam? " << name << " " << dev << "" << oendl; 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() ); + owarn << "dispatch irda " << str.data() << "" << oendl; 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!!"); + owarn << "irda sent!!" << oendl; 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(); @@ -183,49 +184,49 @@ DeviceBox::DeviceBox( QWidget* 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() ); + owarn << "SetSource:" << str.toInt() << "" << oendl; 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: diff --git a/core/obex/receiver.cpp b/core/obex/receiver.cpp index ee2668b..8885256 100644 --- a/core/obex/receiver.cpp +++ b/core/obex/receiver.cpp @@ -1,45 +1,48 @@ -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/mman.h> -#include <stdlib.h> // int system -#include <unistd.h> +#include "obex.h" +#include "receiver.h" +using namespace OpieObex; -#include <fcntl.h> +/* OPIE */ +#include <opie2/odebug.h> +#include <qpe/applnk.h> +#include <qpe/qpeapplication.h> +#include <qpe/qcopenvelope_qws.h> +using namespace Opie::Core; +/* QT */ #include <qfileinfo.h> #include <qlabel.h> #include <qtextview.h> #include <qpushbutton.h> -#include <qpe/applnk.h> -#include <qpe/qpeapplication.h> -#include <qpe/qcopenvelope_qws.h> - -#include "obex.h" -#include "receiver.h" - -using namespace OpieObex; +/* STD */ +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/mman.h> +#include <stdlib.h> // int system +#include <unistd.h> +#include <fcntl.h> /* 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 ) { @@ -54,146 +57,146 @@ void Receiver::handleDateTodo( const QString& str ) { 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() ); + owarn << "Executing: " << cmd << "" << oendl; (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() ); + owarn << "check file!! " << file << "" << oendl; 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 ); + owarn << "check it now " << ret << "" << oendl; 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() ); + owarn << " " << lnk.type() << " " << lnk.icon() << "" << oendl; 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() ); + owarn << "src " << src << ", dest " << file << "" << oendl; QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )). arg( Global::shellQuote( file ) ); ::system( cmd.latin1() ); // done } |