author | zecke <zecke> | 2003-04-13 16:25:24 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-04-13 16:25:24 (UTC) |
commit | c27d6327b9be5792fa507557f03997a46f32cc26 (patch) (side-by-side diff) | |
tree | 3332ed2d1c673a898ba1862276d8688918618d7f | |
parent | 3e1f225ed1e515c3425361fdc90ac4d5b6d86941 (diff) | |
download | opie-c27d6327b9be5792fa507557f03997a46f32cc26.zip opie-c27d6327b9be5792fa507557f03997a46f32cc26.tar.gz opie-c27d6327b9be5792fa507557f03997a46f32cc26.tar.bz2 |
Add apie comments
QString -> const QString& fix
-rw-r--r-- | libopie2/opiecore/oapplication.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiecore/oapplication.h | 6 | ||||
-rw-r--r-- | libopie2/opiecore/oglobal.h | 3 | ||||
-rw-r--r-- | libopie2/opiecore/oglobalsettings.h | 7 | ||||
-rw-r--r-- | libopie2/opienet/omanufacturerdb.h | 1 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.h | 3 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 2 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 4 | ||||
-rw-r--r-- | libopie2/opienet/opcap.h | 28 | ||||
-rw-r--r-- | libopie2/opieui/odialog.h | 5 | ||||
-rw-r--r-- | libopie2/opieui/oimageeffect.h | 1 | ||||
-rw-r--r-- | libopie2/opieui/olistview.h | 4 | ||||
-rw-r--r-- | libopie2/opieui/opopupmenu.h | 3 | ||||
-rw-r--r-- | libopie2/qt3/opiecore/opair.h | 1 |
14 files changed, 51 insertions, 19 deletions
diff --git a/libopie2/opiecore/oapplication.cpp b/libopie2/opiecore/oapplication.cpp index d3e04ba..ce26420 100644 --- a/libopie2/opiecore/oapplication.cpp +++ b/libopie2/opiecore/oapplication.cpp @@ -1,124 +1,124 @@ /* This file is part of the Opie Project Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> =. .=l. .>+-= _;:, .> :=|. This program 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 program 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 <opie2/oapplication.h> #include <opie2/oconfig.h> OApplication* OApplication::_instance = 0; /**************************************************************************************************/ /* OApplicationPrivate /**************************************************************************************************/ class OApplicationPrivate { public: OApplicationPrivate() {}; ~OApplicationPrivate() {}; }; /**************************************************************************************************/ /* OApplication /**************************************************************************************************/ OApplication::OApplication( int& argc, char** argv, const QCString& rAppName ) :OApplicationBaseClass( argc, argv ), _appname( rAppName ), _config( 0 ) { init(); } OApplication::~OApplication() { delete d; if ( _config ) delete _config; OApplication::_instance = 0; // after deconstruction of the one-and-only application object, // the construction of another object is allowed } OConfig* OApplication::config() { if ( !_config ) { _config = new OConfig( _appname ); } return _config; } void OApplication::init() { d = new OApplicationPrivate(); if ( !OApplication::_instance ) { OApplication::_instance = this; } else { qFatal( "OApplication: Can't create more than one OApplication object. Aborting." ); } } void OApplication::setMainWidget( QWidget* widget ) { showMainWidget( widget ); } void OApplication::showMainWidget( QWidget* widget, bool nomax ) { #ifdef Q_WS_QWS QPEApplication::showMainWidget( widget, nomax ); #else QApplication::setMainWidget( widget ); widget->show(); #endif widget->setCaption( _appname ); } -void OApplication::setTitle( QString title ) const +void OApplication::setTitle( const QString& title ) const { if ( mainWidget() ) { if ( !title.isNull() ) mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title ); else mainWidget()->setCaption( _appname ); } } diff --git a/libopie2/opiecore/oapplication.h b/libopie2/opiecore/oapplication.h index 4d25202..8326847 100644 --- a/libopie2/opiecore/oapplication.h +++ b/libopie2/opiecore/oapplication.h @@ -1,130 +1,134 @@ /* This file is part of the Opie Project Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> =. .=l. .>+-= _;:, .> :=|. This program 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 program 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 OAPPLICATION_H #define OAPPLICATION_H #define oApp OApplication::oApplication() +// the below stuff will fail with moc because moc does not pre process headers +// This will make usage of signal and slots hard inside QPEApplication -zecke + #ifdef QWS #include <qpe/qpeapplication.h> #define OApplicationBaseClass QPEApplication #else #include <qapplication.h> #define OApplicationBaseClass QApplication #endif class OApplicationPrivate; class OConfig; class OApplication: public OApplicationBaseClass { +// Q_OBJECT would fail -zecke public: /** * Constructor. Parses command-line arguments and sets the window caption. * * @param rAppName application name. Will be used for finding the * associated message, icon and configuration files * */ OApplication( int& argc, char** argv, const QCString& rAppName ); /** * Destructor. Destroys the application object and its children. */ virtual ~OApplication(); /** * Returns the current application object. * * This is similar to the global @ref QApplication pointer qApp. It * allows access to the single global OApplication object, since * more than one cannot be created in the same application. It * saves you the trouble of having to pass the pointer explicitly * to every function that may require it. * * @return the current application object */ static const OApplication* oApplication() { return _instance; }; /** * Returns the application name as given during creation. * * @return A reference to the application name */ const QCString& appName() const { return _appname; }; /** * Returns the application session config object. * * @return A pointer to the application's instance specific * @ref OConfig object. * @see OConfig */ OConfig* config(); /** * Sets the main widget - reimplemented to call showMainWidget() * on Qt/Embedded. * * @param mainWidget the widget to become the main widget * @see QWidget object */ virtual void setMainWidget( QWidget *mainWidget ); /** * Shows the main widget - reimplemented to call setMainWidget() * on platforms other than Qt/Embedded. * * @param mainWidget the widget to become the main widget * @see QWidget object */ virtual void showMainWidget( QWidget* widget, bool nomax = false ); /** * Set the application title. The application title will be concatenated * to the application name given in the constructor. * * @param title the title. If not given, resets caption to appname */ - virtual void setTitle( QString title = QString::null ) const; + virtual void setTitle( const QString& title = QString::null ) const; //virtual void setTitle() const; protected: void init(); private: const QCString _appname; static OApplication* _instance; OConfig* _config; OApplicationPrivate* d; }; #endif // OAPPLICATION_H diff --git a/libopie2/opiecore/oglobal.h b/libopie2/opiecore/oglobal.h index 8345c6a..34f211e 100644 --- a/libopie2/opiecore/oglobal.h +++ b/libopie2/opiecore/oglobal.h @@ -1,48 +1,49 @@ /* This file is part of the Opie Project Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> =. .=l. .>+-= _;:, .> :=|. This program 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 program 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 OGLOBAL_H #define OGLOBAL_H #include <qpe/global.h> #include <opie2/oconfig.h> static OConfig globalconfig = OConfig( "global" ); //FIXME: Is it wise or even necessary to inherit OGlobal from Global? +// once we totally skip libqpe it should ideally swallow Global -zecke class OGlobal : public Global { public: - + // do we want to put that into OApplication as in KApplication -zecke static OConfig* config(); }; #endif // OGLOBAL_H diff --git a/libopie2/opiecore/oglobalsettings.h b/libopie2/opiecore/oglobalsettings.h index 6481251..d3f357e 100644 --- a/libopie2/opiecore/oglobalsettings.h +++ b/libopie2/opiecore/oglobalsettings.h @@ -1,368 +1,373 @@ /* This file is part of the Opie Project Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> Inspired by KDE OGlobalSettings Copyright (C) 2000 David Faure <faure@kde.org> =. .=l. .>+-= _;:, .> :=|. This program 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 program 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 OGLOBALSETTINGS_H #define OGLOBALSETTINGS_H #include <qstring.h> #include <qcolor.h> #include <qfont.h> #define OPIE_DEFAULT_SINGLECLICK true #define OPIE_DEFAULT_INSERTTEAROFFHANDLES true #define OPIE_DEFAULT_AUTOSELECTDELAY -1 #define OPIE_DEFAULT_CHANGECURSOR true #define OPIE_DEFAULT_LARGE_CURSOR false #define OPIE_DEFAULT_VISUAL_ACTIVATE true #define OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED 50 //FIXME: There's still a whole lot of stuff in here which has to be revised //FIXME: before public usage... lack of time to do it at once - so it will //FIXME: happen step-by-step. ML. +// we should not habe too much configure options!!!!!! -zecke /** * Access the OPIE global configuration settings. * */ class OGlobalSettings { public: /** * Returns a threshold in pixels for drag & drop operations. * As long as the mouse movement has not exceeded this number * of pixels in either X or Y direction no drag operation may * be started. This prevents spurious drags when the user intended * to click on something but moved the mouse a bit while doing so. * * For this to work you must save the position of the mouse (oldPos) * in the @ref QWidget::mousePressEvent(). * When the position of the mouse (newPos) * in a @ref QWidget::mouseMoveEvent() exceeds this threshold * you may start a drag * which should originate from oldPos. * * Example code: * <pre> * void OColorCells::mousePressEvent( QMouseEvent *e ) * { * mOldPos = e->pos(); * } * * void OColorCells::mouseMoveEvent( QMouseEvent *e ) * { * if( !(e->state() && LeftButton)) return; * * int delay = OGlobalSettings::dndEventDelay(); * QPoint newPos = e->pos(); * if(newPos.x() > mOldPos.x()+delay || newPos.x() < mOldPos.x()-delay || * newPos.y() > mOldPos.y()+delay || newPos.y() < mOldPos.y()-delay) * { * // Drag color object * int cell = posToCell(mOldPos); // Find color at mOldPos * if ((cell != -1) && colors[cell].isValid()) * { * OColorDrag *d = OColorDrag::makeDrag( colors[cell], this); * d->dragCopy(); * } * } * } * </pre> * */ + // we do not support DND at the momemt -zecke static int dndEventDelay(); /** * Returns whether OPIE runs in single (default) or double click * mode. * * @return @p true if single click mode, or @p false if double click mode. * * see @ref http://opie.handhelds.org/documentation/standards/opie/style/mouse/index.html **/ static bool singleClick(); /** * Returns whether tear-off handles are inserted in OPopupMenus. **/ + // would clutter the small screen -zecke static bool insertTearOffHandle(); /** * @return the OPIE setting for "change cursor over icon" */ static bool changeCursorOverIcon(); /** * @return whether to show some feedback when an item (specifically an * icon) is activated. */ static bool visualActivate(); static unsigned int visualActivateSpeed(); /** * Returns the OPIE setting for the auto-select option * * @return the auto-select delay or -1 if auto-select is disabled. */ static int autoSelectDelay(); /** * Returns the OPIE setting for the shortcut key to open * context menus. * * @return the key that pops up context menus. */ static int contextMenuKey(); /** * Returns the OPIE setting for context menus. * * @return whether context menus should be shown on button press * or button release (click). */ static bool showContextMenusOnPress (); /** * This enum describes the completion mode used for by the @ref OCompletion class. * See <a href="http://opie.handhelds.org/documentation/standards/opie/style/keys/completion.html"> * the styleguide</a>. **/ enum Completion { /** * No completion is used. */ CompletionNone=1, /** * Text is automatically filled in whenever possible. */ CompletionAuto, /** * Same as automatic except shortest match is used for completion. */ CompletionMan, /** * Complete text much in the same way as a typical *nix shell would. */ CompletionShell, /** * Lists all possible matches in a popup list-box to choose from. */ CompletionPopup, /** * Lists all possible matches in a popup list-box to choose from, and automatically * fill the result whenever possible. */ CompletionPopupAuto }; /** * Returns the preferred completion mode setting. * * @return @ref Completion. Default is @p CompletionPopup. */ static Completion completionMode(); /** * This enum describes the debug mode used for by the @ref odbgstream class. * See <a href="http://opie.handhelds.org/documentation/standards/opie/style/debug/debug.html"> * the styleguide</a>. **/ enum Debug { /** * Debug messages are ignored. */ DebugNone=-1, /** * Debug output is sent to files /var/log/***. */ DebugFiles=0, /** * Debug output is written in a QMessageBox. */ DebugMsgBox=1, /** * Debug output is sent to stderr. */ DebugStdErr=2, /** * Debug output is sent to syslog. */ DebugSysLog=3, /** * Debug output is sent via udp over a socket. */ DebugSocket=4 }; /** * Returns the preferred debug mode setting. * * @return @ref Debug. Default is @p DebugStdErr. */ static Debug debugMode(); /** * Returns additional information for debug output (dependent on the debug mode). * * @return Additional debug output information. */ static QString debugOutput(); /** * This is a structure containing the possible mouse settings. */ struct OMouseSettings { enum { RightHanded = 0, LeftHanded = 1 }; int handed; // left or right }; /** * This returns the current mouse settings. */ static OMouseSettings & mouseSettings(); /** * The path to the desktop directory of the current user. */ + // below handled by Global stuff and QPEApplication static QString desktopPath() { initStatic(); return *s_desktopPath; } /** * The path to the autostart directory of the current user. */ static QString autostartPath() { initStatic(); return *s_autostartPath; } /** - * The path to the trash directory of the current user. + * The path to the trash directory of the current user. */ + // we do not have that concept -zecke static QString trashPath() { initStatic(); return *s_trashPath; } /** * The path where documents are stored of the current user. */ static QString documentPath() { initStatic(); return *s_documentPath; } /** * The default color to use when highlighting toolbar buttons */ static QColor toolBarHighlightColor(); static QColor inactiveTitleColor(); static QColor inactiveTextColor(); static QColor activeTitleColor(); static QColor activeTextColor(); static int contrast(); /** * The default colors to use for text and links. */ static QColor baseColor(); // Similair to QColorGroup::base() static QColor textColor(); // Similair to QColorGroup::text() static QColor linkColor(); static QColor visitedLinkColor(); static QColor highlightedTextColor(); // Similair to QColorGroup::hightlightedText() static QColor highlightColor(); // Similair to QColorGroup::highlight() /** * Returns the alternate background color used by @ref OListView with * @ref OListViewItem. Any other list that uses alternating background * colors should use this too, to obey to the user's preferences. Returns * an invalid color if the user doesn't want alternating backgrounds. * @see #calculateAlternateBackgroundColor */ static QColor alternateBackgroundColor(); /** * Calculates a color based on @p base to be used as alternating * color for e.g. listviews. * @see #alternateBackgroundColor */ static QColor calculateAlternateBackgroundColor(const QColor& base); static QFont generalFont(); static QFont fixedFont(); static QFont toolBarFont(); static QFont menuFont(); static QFont windowTitleFont(); static QFont taskbarFont(); /** * Returns if the user specified multihead. In case the display * has multiple screens, the return value of this function specifies * if the user wants OPIE to run on all of them or just on the primary */ static bool isMultiHead(); private: /** * reads in all paths from kdeglobals */ static void initStatic(); /** * initialise kde2Blue */ static void initColors(); /** * drop cached values for fonts (called by OApplication) */ static void rereadFontSettings(); /** * drop cached values for paths (called by OApplication) */ static void rereadPathSettings(); /** * drop cached values for mouse settings (called by OApplication) */ static void rereadMouseSettings(); static QString* s_desktopPath; static QString* s_autostartPath; static QString* s_trashPath; static QString* s_documentPath; static QFont *_generalFont; static QFont *_fixedFont; static QFont *_toolBarFont; static QFont *_menuFont; static QFont *_windowTitleFont; static QFont *_taskbarFont; static QColor * kde2Gray; static QColor * kde2Blue; static QColor * kde2AlternateColor; static OMouseSettings *s_mouseSettings; static QColor * OpieGray; static QColor * OpieBlue; static QColor * OpieAlternate; static QColor * OpieHighlight; friend class OApplication; }; #endif diff --git a/libopie2/opienet/omanufacturerdb.h b/libopie2/opienet/omanufacturerdb.h index 5e66c37..cb0b6c8 100644 --- a/libopie2/opienet/omanufacturerdb.h +++ b/libopie2/opienet/omanufacturerdb.h @@ -1,37 +1,38 @@ /********************************************************************** ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Opie 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. ** **********************************************************************/ #ifndef OMANUFACTURERDB_H #define OMANUFACTURERDB_H #include <qmap.h> class OManufacturerDB { public: + //FIXME make us consistent -zecke I use self(), sandman inst() you use instance() so we need to chose one! static OManufacturerDB* instance(); const QString& lookup( const QString& macaddr ) const; protected: OManufacturerDB(); virtual ~OManufacturerDB(); private: QMap<QString, QString> manufacturers; static OManufacturerDB* _instance; }; #endif diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h index bedea63..9611518 100644 --- a/libopie2/opienet/onetutils.h +++ b/libopie2/opienet/onetutils.h @@ -1,158 +1,161 @@ /* This file is part of the Opie Project (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> =. .=l. .>+-= _;:, .> :=|. This program 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 program 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 ONETUTILS_H #define ONETUTILS_H #include <qdict.h> #include <qmap.h> #include <qstring.h> #include <qhostaddress.h> #include <qobject.h> #include <sys/types.h> struct ifreq; class OWirelessNetworkInterface; /*====================================================================================== * OMacAddress *======================================================================================*/ class OMacAddress { public: + // QString c'tor? -zecke OMacAddress( unsigned char* ); OMacAddress( const unsigned char* ); OMacAddress( struct ifreq& ); ~OMacAddress(); QString manufacturer() const; QString toString( bool substitute = false ) const; const unsigned char* native() const; + // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem? static OMacAddress fromString( const QString& ); public: static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff static const OMacAddress& unknown; // 44:44:44:44:44:44 private: unsigned char _bytes[6]; friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); }; bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); /*====================================================================================== * OHostAddress *======================================================================================*/ class OHostAddress : public QHostAddress { public: OHostAddress(); ~OHostAddress(); }; /*====================================================================================== * OPrivateIOCTL *======================================================================================*/ class OPrivateIOCTL : public QObject { public: OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); ~OPrivateIOCTL(); int numberGetArgs() const; int typeGetArgs() const; int numberSetArgs() const; int typeSetArgs() const; + // FIXME return int? as ::ioctl does? -zecke void invoke() const; void setParameter( int, u_int32_t ); private: u_int32_t _ioctl; u_int16_t _getargs; u_int16_t _setargs; }; /*====================================================================================== * Miscellaneous *======================================================================================*/ /* dump bytes */ void dumpBytes( const unsigned char* data, int num ); /* Network to host order macros */ #ifdef LBL_ALIGN #define EXTRACT_16BITS(p) \ ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ (u_int16_t)*((const u_int8_t *)(p) + 1))) #define EXTRACT_32BITS(p) \ ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ (u_int32_t)*((const u_int8_t *)(p) + 3))) #else #define EXTRACT_16BITS(p) \ ((u_int16_t)ntohs(*(const u_int16_t *)(p))) #define EXTRACT_32BITS(p) \ ((u_int32_t)ntohl(*(const u_int32_t *)(p))) #endif #define EXTRACT_24BITS(p) \ ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ (u_int32_t)*((const u_int8_t *)(p) + 2))) /* Little endian protocol host order macros */ #define EXTRACT_LE_8BITS(p) (*(p)) #define EXTRACT_LE_16BITS(p) \ ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ (u_int16_t)*((const u_int8_t *)(p) + 0))) #define EXTRACT_LE_32BITS(p) \ ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ (u_int32_t)*((const u_int8_t *)(p) + 0))) #endif // ONETUTILS_H diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 73b543b..f0094c7 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp @@ -1,367 +1,367 @@ /* This file is part of the Opie Project Copyright (C) 2003 by the Wellenreiter team: Martin J. Muench <mjm@remote-exploit.org> Max Moser <mmo@remote-exploit.org Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> =. .=l. .>+-= _;:, .> :=|. This program 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 program 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. */ /* OPIE */ #include <opie2/onetwork.h> /* QT */ #include <qfile.h> #include <qtextstream.h> /* UNIX */ #include <arpa/inet.h> #include <cerrno> #include <cstring> #include <cstdlib> #include <math.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/types.h> #include <unistd.h> #include <linux/sockios.h> #include <net/if_arp.h> #include <stdarg.h> using namespace std; /*====================================================================================== * ONetwork *======================================================================================*/ ONetwork* ONetwork::_instance = 0; ONetwork::ONetwork() { qDebug( "ONetwork::ONetwork()" ); synchronize(); } void ONetwork::synchronize() { // gather available interfaces by inspecting /proc/net/dev //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices _interfaces.clear(); QString str; QFile f( "/proc/net/dev" ); bool hasFile = f.open( IO_ReadOnly ); if ( !hasFile ) { qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); return; } QTextStream s( &f ); s.readLine(); s.readLine(); while ( !s.atEnd() ) { s >> str; str.truncate( str.find( ':' ) ); qDebug( "ONetwork: found interface '%s'", (const char*) str ); ONetworkInterface* iface; if ( isWirelessInterface( str ) ) { iface = new OWirelessNetworkInterface( this, (const char*) str ); qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); } else { iface = new ONetworkInterface( this, (const char*) str ); } _interfaces.insert( str, iface ); s.readLine(); } } -ONetworkInterface* ONetwork::interface( QString iface ) const +ONetworkInterface* ONetwork::interface( const QString& iface ) const { return _interfaces[iface]; } ONetwork* ONetwork::instance() { if ( !_instance ) _instance = new ONetwork(); return _instance; } ONetwork::InterfaceIterator ONetwork::iterator() const { return ONetwork::InterfaceIterator( _interfaces ); } bool ONetwork::isWirelessInterface( const char* name ) const { int sfd = socket( AF_INET, SOCK_STREAM, 0 ); struct iwreq iwr; memset( &iwr, 0, sizeof( struct iwreq ) ); strcpy( (char*) &iwr.ifr_name, name ); int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); return result != -1; } /*====================================================================================== * ONetworkInterface *======================================================================================*/ ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) :QObject( parent, name ), _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) { qDebug( "ONetworkInterface::ONetworkInterface()" ); init(); } struct ifreq& ONetworkInterface::ifr() const { return _ifr; } void ONetworkInterface::init() { qDebug( "ONetworkInterface::init()" ); memset( &_ifr, 0, sizeof( struct ifreq ) ); if ( _sfd == -1 ) { qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); return; } } bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const { int result = ::ioctl( _sfd, call, &ifreq ); if ( result == -1 ) qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) ); else qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Ok.", name(), call ); return ( result != -1 ); } bool ONetworkInterface::ioctl( int call ) const { strcpy( _ifr.ifr_name, name() ); return ioctl( call, _ifr ); } bool ONetworkInterface::isLoopback() const { ioctl( SIOCGIFFLAGS ); return _ifr.ifr_flags & IFF_LOOPBACK; } bool ONetworkInterface::setUp( bool b ) { ioctl( SIOCGIFFLAGS ); if ( b ) _ifr.ifr_flags |= IFF_UP; else _ifr.ifr_flags &= (~IFF_UP); return ioctl( SIOCSIFFLAGS ); } bool ONetworkInterface::isUp() const { ioctl( SIOCGIFFLAGS ); return _ifr.ifr_flags & IFF_UP; } QString ONetworkInterface::ipV4Address() const { if ( ioctl( SIOCGIFADDR ) ) { struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; //FIXME: Use QHostAddress here return QString( inet_ntoa( sa->sin_addr ) ); } else return "<unknown>"; } void ONetworkInterface::setMacAddress( const OMacAddress& addr ) { _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); ioctl( SIOCSIFHWADDR ); } OMacAddress ONetworkInterface::macAddress() const { if ( ioctl( SIOCGIFHWADDR ) ) { return OMacAddress( _ifr ); } else { return OMacAddress::unknown; } } int ONetworkInterface::dataLinkType() const { if ( ioctl( SIOCGIFHWADDR ) ) { return _ifr.ifr_hwaddr.sa_family; } else { return -1; } } void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) { _mon = m; qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); } OMonitoringInterface* ONetworkInterface::monitoring() const { return _mon; } ONetworkInterface::~ONetworkInterface() { qDebug( "ONetworkInterface::~ONetworkInterface()" ); if ( _sfd != -1 ) ::close( _sfd ); } bool ONetworkInterface::setPromiscuousMode( bool b ) { ioctl( SIOCGIFFLAGS ); if ( b ) _ifr.ifr_flags |= IFF_PROMISC; else _ifr.ifr_flags &= (~IFF_PROMISC); return ioctl( SIOCSIFFLAGS ); } bool ONetworkInterface::promiscuousMode() const { ioctl( SIOCGIFFLAGS ); return _ifr.ifr_flags & IFF_PROMISC; } bool ONetworkInterface::isWireless() const { return ioctl( SIOCGIWNAME ); } /*====================================================================================== * OChannelHopper *======================================================================================*/ OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) :QObject( 0, "Mickey's funky hopper" ), _iface( iface ), _interval( 0 ), _tid( 0 ) { int _maxChannel = iface->channels()+1; // generate fancy hopping sequence honoring the device capabilities if ( _maxChannel >= 1 ) _channels.append( 1 ); if ( _maxChannel >= 7 ) _channels.append( 7 ); if ( _maxChannel >= 13 ) _channels.append( 13 ); if ( _maxChannel >= 2 ) _channels.append( 2 ); if ( _maxChannel >= 8 ) _channels.append( 8 ); if ( _maxChannel >= 3 ) _channels.append( 3 ); if ( _maxChannel >= 14 ) _channels.append( 14 ); if ( _maxChannel >= 9 ) _channels.append( 9 ); if ( _maxChannel >= 4 ) _channels.append( 4 ); if ( _maxChannel >= 10 ) _channels.append( 10 ); if ( _maxChannel >= 5 ) _channels.append( 5 ); if ( _maxChannel >= 11 ) _channels.append( 11 ); if ( _maxChannel >= 6 ) _channels.append( 6 ); if ( _maxChannel >= 12 ) _channels.append( 12 ); _channel = _channels.begin(); } OChannelHopper::~OChannelHopper() { } bool OChannelHopper::isActive() const { return _tid; } int OChannelHopper::channel() const { return *_channel; } void OChannelHopper::timerEvent( QTimerEvent* ) { _iface->setChannel( *_channel ); emit( hopped( *_channel ) ); qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", *_channel, (const char*) _iface->name() ); if ( ++_channel == _channels.end() ) _channel = _channels.begin(); } void OChannelHopper::setInterval( int interval ) { if ( interval == _interval ) return; if ( _interval ) killTimer( _tid ); _tid = 0; diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index d2cc25d..db8e702 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h @@ -1,362 +1,364 @@ /* This file is part of the Opie Project Copyright (C) 2003 by the Wellenreiter team: Martin J. Muench <mjm@remote-exploit.org> Max Moser <mmo@remote-exploit.org Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> =. .=l. .>+-= _;:, .> :=|. This program 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 program 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 ONETWORK_H #define ONETWORK_H /* QT */ #include <qvaluelist.h> #include <qdict.h> #include <qmap.h> #include <qobject.h> #include <qhostaddress.h> /* OPIE */ #include <opie2/onetutils.h> #ifndef IFNAMSIZ #define IFNAMSIZ 16 #endif #ifndef IW_MAX_PRIV_DEF #define IW_MAX_PRIV_DEF 128 #endif // ML: Yeah, I hate to include kernel headers, but it's necessary here // ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h> // ML: which conflicts with the user header <net/if.h> // ML: We really a user header for the Wireless Extensions, something like <net/wireless.h> // ML: I will drop Jean an mail on that subject #include <net/if.h> #define _LINUX_IF_H #include <linux/wireless.h> class ONetworkInterface; class OWirelessNetworkInterface; class OChannelHopper; class OMonitoringInterface; /*====================================================================================== * ONetwork *======================================================================================*/ /** * @brief A container class for all network devices. * * This class provides access to all available network devices of your computer. * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> */ class ONetwork : public QObject { Q_OBJECT public: typedef QDict<ONetworkInterface> InterfaceMap; typedef QDictIterator<ONetworkInterface> InterfaceIterator; public: /** * @returns a pointer to the (one and only) @ref ONetwork instance. */ static ONetwork* instance(); /** * @returns an iterator usable for iterating through all network interfaces. */ InterfaceIterator iterator() const; /** * @returns true, if the @p interface supports the wireless extension protocol. */ + // FIXME QString? -zecke bool isWirelessInterface( const char* interface ) const; /** * @returns a pointer to the @ref ONetworkInterface object for the specified @p interface or 0, if not found * @see ONetworkInterface */ - ONetworkInterface* interface( QString interface ) const; + // FIXME: const QString& is prefered over QString!!! -zecke + ONetworkInterface* interface( const QString& interface ) const; protected: ONetwork(); void synchronize(); private: static ONetwork* _instance; InterfaceMap _interfaces; }; /*====================================================================================== * ONetworkInterface *======================================================================================*/ /** * @brief A network interface wrapper. * * This class provides a wrapper for a network interface. All the cumbersume details of * Linux ioctls are hidden under a convenient high-level interface. * @warning Most of the setting methods contained in this class require the appropriate * process permissions to work. * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> */ class ONetworkInterface : public QObject { friend class OMonitoringInterface; friend class OCiscoMonitoringInterface; friend class OWlanNGMonitoringInterface; friend class OHostAPMonitoringInterface; friend class OOrinocoMonitoringInterface; public: /** * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, * but access them via @ref ONetwork::interface(). */ ONetworkInterface( QObject* parent, const char* name ); /** * Destructor. */ virtual ~ONetworkInterface(); /** * Associates a @a monitoring interface with this network interface. * @note This is currently only useful with @ref OWirelessNetworkInterface objects. */ void setMonitoring( OMonitoringInterface* monitoring ); /** * @returns the currently associated monitoring interface or 0, if no monitoring is associated. */ OMonitoringInterface* monitoring() const; /** * Setting an interface to promiscuous mode enables the device to receive * all packets on the shared medium - as opposed to packets which are addressed to this interface. */ bool setPromiscuousMode( bool ); /** * @returns true if the interface is set to promiscuous mode. */ bool promiscuousMode() const; /** * Setting an interface to up enables it to receive packets. */ bool setUp( bool ); /** * @returns true if the interface is up. */ bool isUp() const; /* * @returns true if the interface is a loopback interface. */ bool isLoopback() const; /* * @returns true if the interface is featuring supports the wireless extension protocol. */ bool isWireless() const; /* * @returns the IPv4 address associated with this interface. */ QString ipV4Address() const; /* * Associate the MAC address @a addr with the interface. * @note It can be necessary to shut down the interface prior to calling this method. * @warning This is not supported by all drivers. */ void setMacAddress( const OMacAddress& addr ); /* * @returns the MAC address associated with this interface. */ OMacAddress macAddress() const; /* * @returns the data link type currently associated with this interface. * @see #include <net/if_arp.h> for possible values. */ int dataLinkType() const; protected: const int _sfd; mutable ifreq _ifr; OMonitoringInterface* _mon; protected: struct ifreq& ifr() const; virtual void init(); bool ioctl( int call ) const; bool ioctl( int call, struct ifreq& ) const; }; /*====================================================================================== * OChannelHopper *======================================================================================*/ /** * @brief A radio frequency channel hopper. * * This class provides a channel hopper for radio frequencies. A channel hopper frequently * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. * This is necessary when in monitoring mode and scanning for other devices, because * the radio frequency hardware can only detect packets sent on the same frequency. * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> */ class OChannelHopper : public QObject { Q_OBJECT public: OChannelHopper( OWirelessNetworkInterface* ); virtual ~OChannelHopper(); bool isActive() const; int channel() const; virtual void timerEvent( QTimerEvent* ); void setInterval( int ); int interval() const; signals: void hopped( int ); private: OWirelessNetworkInterface* _iface; int _interval; int _tid; QValueList<int> _channels; QValueList<int>::Iterator _channel; }; /*====================================================================================== * OWirelessNetworkInterface *======================================================================================*/ /** * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. * * This class provides a high-level encapsulation of the Linux wireless extension API. */ class OWirelessNetworkInterface : public ONetworkInterface { friend class OMonitoringInterface; friend class OCiscoMonitoringInterface; friend class OWlanNGMonitoringInterface; friend class OHostAPMonitoringInterface; friend class OOrinocoMonitoringInterface; friend class OPrivateIOCTL; public: enum Mode { AdHoc, Managed, Monitor }; /** * Constructor. */ OWirelessNetworkInterface( QObject* parent, const char* name ); /** * Destructor. */ virtual ~OWirelessNetworkInterface(); /** * Setting the @a channel of the interface changes the radio frequency (RF) * of the corresponding wireless network device. */ virtual void setChannel( int channel ) const; /** * @returns the channel index of the current radio frequency. */ virtual int channel() const; /** * @returns the current radio frequency (in MHz). */ virtual double frequency() const; /** * @returns the number of radio frequency channels for the * corresponding wireless network device. * @note European devices usually have 14 channels, while American typically feature 11 channels. */ virtual int channels() const; //virtual double frequency(int) const; virtual void setMode( Mode ) {}; //FIXME: Implement and document this virtual bool mode() const {}; //FIXME: Implement and document this /** * Setting the monitor mode on a wireless network interface enables * listening to IEEE 802.11 data and management frames which normally * are handled by the device firmware. This can be used to detect * other wireless network devices, e.g. Access Points or Ad-hoc stations. * @warning Standard wireless network drives don't support the monitor mode. * @warning You need a patched driver for this to work. * @note Enabling the monitor mode is highly driver dependent and requires * the proper @ref OMonitoringInterface to be associated with the interface. * @see OMonitoringInterface */ virtual void setMonitorMode( bool ); /** * @returns true if the device is listening in IEEE 802.11 monitor mode */ virtual bool monitorMode() const; /** * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. * @see OChannelHopper */ virtual void setChannelHopping( int interval = 0 ); /** * @returns the channel hopping interval or 0, if channel hopping is disabled. */ virtual int channelHopping() const; /** * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before */ virtual OChannelHopper* channelHopper() const; /** * Set the station @a nickname. */ virtual void setNickName( const QString& nickname ) {}; //FIXME: Implement this /** * @returns the current station nickname. */ virtual QString nickName() const; /** * Invoke the private IOCTL @a command with a @number of parameters on the network interface. * @see OPrivateIOCTL */ virtual void setPrivate( const QString& command, int number, ... ); /** * @returns true if the interface is featuring the private IOCTL @command. */ virtual bool hasPrivate( const QString& command ); virtual void getPrivate( const QString& command ); //FIXME: Implement and document this virtual bool isAssociated() const {}; //FIXME: Implement and document this virtual QString associatedAP() const; //FIXME: Implement and document this virtual void setSSID( const QString& ); virtual QString SSID() const; protected: void buildChannelList(); diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h index 99631ba..6bf7416 100644 --- a/libopie2/opienet/opcap.h +++ b/libopie2/opienet/opcap.h @@ -1,507 +1,517 @@ /* This file is part of the Opie Project Copyright (C) 2003 by the Wellenreiter team: Martin J. Muench <mjm@remote-exploit.org> Max Moser <mmo@remote-exploit.org Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> =. .=l. .>+-= _;:, .> :=|. This program 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 program 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 OPCAP_H #define OPCAP_H /* LINUX */ extern "C" // work around a bpf/pcap conflict in recent headers { #include <pcap.h> } #include <netinet/ether.h> #include <netinet/ip.h> #include <netinet/udp.h> #include <netinet/tcp.h> #include <time.h> /* QT */ #include <qevent.h> #include <qfile.h> #include <qhostaddress.h> #include <qobject.h> #include <qstring.h> #include <qmap.h> /* OPIE */ #include <opie2/onetutils.h> #include "802_11_user.h" /* TYPEDEFS */ typedef struct timeval timevalstruct; typedef struct pcap_pkthdr packetheaderstruct; /* FORWARDS */ class OPacketCapturer; class QSocketNotifier; /*====================================================================================== * OPacket - A frame on the wire *======================================================================================*/ - +// FIXME how many OPackets do we've at a time? QObject seams to be a big for that usage class OPacket : public QObject { Q_OBJECT public: OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); virtual ~OPacket(); timevalstruct timeval() const; int caplen() const; int len() const; QString dump( int = 32 ) const; void updateStats( QMap<QString,int>&, QObjectList* ); private: const packetheaderstruct _hdr; // pcap packet header const unsigned char* _data; // pcap packet data const unsigned char* _end; // end of pcap packet data }; /*====================================================================================== * OEthernetPacket - DLT_EN10MB frame *======================================================================================*/ +//FIXME same critic as above -zecke class OEthernetPacket : public QObject { Q_OBJECT public: OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); virtual ~OEthernetPacket(); OMacAddress sourceAddress() const; OMacAddress destinationAddress() const; int type() const; private: const struct ether_header* _ether; }; /*====================================================================================== * OWaveLanPacket - DLT_IEEE802_11 frame *======================================================================================*/ - +//FIXME same class OWaveLanPacket : public QObject { Q_OBJECT public: OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); virtual ~OWaveLanPacket(); int duration() const; bool fromDS() const; bool toDS() const; virtual OMacAddress macAddress1() const; virtual OMacAddress macAddress2() const; virtual OMacAddress macAddress3() const; virtual OMacAddress macAddress4() const; bool usesPowerManagement() const; int type() const; int subType() const; int version() const; bool usesWep() const; private: const struct ieee_802_11_header* _wlanhdr; }; /*====================================================================================== * OWaveLanManagementPacket - type: management (T_MGMT) *======================================================================================*/ - +//FIXME same as above -zecke class OWaveLanManagementPacket : public QObject { Q_OBJECT public: OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); virtual ~OWaveLanManagementPacket(); QString managementType() const; int beaconInterval() const; int capabilities() const; // generic bool canESS() const; bool canIBSS() const; bool canCFP() const; bool canCFP_REQ() const; bool canPrivacy() const; private: const struct ieee_802_11_mgmt_header* _header; const struct ieee_802_11_mgmt_body* _body; }; /*====================================================================================== * OWaveLanManagementSSID *======================================================================================*/ - +//FIXME is QObject necessary? -zecke class OWaveLanManagementSSID : public QObject { Q_OBJECT public: OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementSSID(); QString ID() const; private: const struct ssid_t* _data; }; /*====================================================================================== * OWaveLanManagementRates *======================================================================================*/ - +// FIXME same as above -zecke class OWaveLanManagementRates : public QObject { Q_OBJECT public: OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementRates(); private: const struct rates_t* _data; }; /*====================================================================================== * OWaveLanManagementCF *======================================================================================*/ +//FIXME same.... class OWaveLanManagementCF : public QObject { Q_OBJECT public: OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementCF(); private: const struct cf_t* _data; }; /*====================================================================================== * OWaveLanManagementFH *======================================================================================*/ +//FIXME same class OWaveLanManagementFH : public QObject { Q_OBJECT public: OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementFH(); private: const struct fh_t* _data; }; /*====================================================================================== * OWaveLanManagementDS *======================================================================================*/ - +//FIXME same class OWaveLanManagementDS : public QObject { Q_OBJECT public: OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementDS(); int channel() const; private: const struct ds_t* _data; }; /*====================================================================================== * OWaveLanManagementTim *======================================================================================*/ +//FIXME guess what? class OWaveLanManagementTim : public QObject { Q_OBJECT public: OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementTim(); private: const struct tim_t* _data; }; /*====================================================================================== * OWaveLanManagementIBSS *======================================================================================*/ +//FIXME same as above ( Qobject ) class OWaveLanManagementIBSS : public QObject { Q_OBJECT public: OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementIBSS(); private: const struct ibss_t* _data; }; /*====================================================================================== * OWaveLanManagementChallenge *======================================================================================*/ +// Qobject do we need that?? class OWaveLanManagementChallenge : public QObject { Q_OBJECT public: OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementChallenge(); private: const struct challenge_t* _data; }; /*====================================================================================== * OWaveLanDataPacket - type: data (T_DATA) *======================================================================================*/ - +// Qobject? class OWaveLanDataPacket : public QObject { Q_OBJECT public: OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); virtual ~OWaveLanDataPacket(); private: const struct ieee_802_11_data_header* _header; }; /*====================================================================================== * OWaveLanControlPacket - type: control (T_CTRL) *======================================================================================*/ - +// Qobject needed? class OWaveLanControlPacket : public QObject { Q_OBJECT public: OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); virtual ~OWaveLanControlPacket(); private: const struct ieee_802_11_control_header* _header; }; /*====================================================================================== * OLLCPacket - IEEE 802.2 Link Level Control *======================================================================================*/ +// QObject needed? class OLLCPacket : public QObject { Q_OBJECT public: OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); virtual ~OLLCPacket(); private: + //FIXME how to get that header? const struct ieee_802_11_802_2_header* _header; }; /*====================================================================================== * OIPPacket *======================================================================================*/ +// Qobject as baseclass? class OIPPacket : public QObject { Q_OBJECT public: OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); virtual ~OIPPacket(); QHostAddress fromIPAddress() const; QHostAddress toIPAddress() const; int tos() const; int len() const; int id() const; int offset() const; int ttl() const; int protocol() const; int checksum() const; private: const struct iphdr* _iphdr; }; /*====================================================================================== * OUDPPacket *======================================================================================*/ - +// QObject? class OUDPPacket : public QObject { Q_OBJECT public: OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); virtual ~OUDPPacket(); int fromPort() const; int toPort() const; private: const struct udphdr* _udphdr; }; /*====================================================================================== * OTCPPacket *======================================================================================*/ +// Qobect needed? class OTCPPacket : public QObject { Q_OBJECT public: OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); virtual ~OTCPPacket(); int fromPort() const; int toPort() const; private: const struct tcphdr* _tcphdr; }; /*====================================================================================== * OPacketCapturer *======================================================================================*/ /** * @brief A class based wrapper for network packet capturing. * * This class is the base of a high-level interface to the well known packet capturing * library libpcap. ... */ class OPacketCapturer : public QObject { Q_OBJECT public: /** * Constructor. */ OPacketCapturer( QObject* parent = 0, const char* name = 0 ); /** * Destructor. */ ~OPacketCapturer(); /** * Setting the packet capturer to use blocking IO calls can be useful when * not using the socket notifier, e.g. without an application object. */ void setBlocking( bool ); /** * @returns true if the packet capturer uses blocking IO calls. */ bool blocking() const; /** * Closes the packet capturer. This is automatically done in the destructor. */ void close(); /** * @returns the data link type. * @see <pcap.h> for possible values. */ int dataLink() const; /** * @returns the filedescriptor of the packet capturer. This is only useful, if * not using the socket notifier, e.g. without an application object. */ int fileno() const; /** * @returns the next @ref OPacket from the packet capturer. * @note If blocking mode is true then this call might block. */ OPacket* next(); /** * Open the packet capturer to capture packets in live-mode from @a interface. * If a @a filename is given, all captured packets are output to a tcpdump-compatible capture file. */ bool open( const QString& interface, const QString& filename = QString::null ); /** * Open the packet capturer to capture packets in offline-mode from @a file. */ bool open( const QFile& file ); /** * @returns true if the packet capturer is open */ bool isOpen() const; const QMap<QString,int>& statistics() const; signals: /** * This signal is emitted, when a packet has been received. */ void receivedPacket( OPacket* ); protected slots: void readyToReceive(); protected: QString _name; // devicename bool _open; // check this before doing pcap calls pcap_t* _pch; // pcap library handle pcap_dumper_t* _pcd; // pcap dumper handle QSocketNotifier* _sn; // socket notifier for main loop mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap QMap<QString, int> _stats; // statistics; }; #endif // OPCAP_H diff --git a/libopie2/opieui/odialog.h b/libopie2/opieui/odialog.h index 7947dfb..4116ed7 100644 --- a/libopie2/opieui/odialog.h +++ b/libopie2/opieui/odialog.h @@ -1,88 +1,89 @@ /* This file is part of the Opie Project (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> =. .=l. .>+-= _;:, .> :=|. This program 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 program 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 ODIALOG_H #define ODIALOG_H class QLayoutItem; #include <qdialog.h> /** * Dialog with extended nonmodal support and methods for OPIE standard * compliance. * * The @ref marginHint() and @ref spacingHint() sizes shall be used * whenever you layout the interior of a dialog. One special note. If * you make your own action buttons (OK, Cancel etc), the space * beteween the buttons shall be @ref spacingHint(), whereas the space * above, below, to the right and to the left shall be @ref marginHint(). * If you add a separator line above the buttons, there shall be a * @ref marginHint() between the buttons and the separator and a * @ref marginHint() above the separator as well. * * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> */ + // lets fix up Qt instead! Size does matter. -zecke class ODialog : public QDialog { Q_OBJECT public: /** * Constructor. * * Takes the same arguments as @ref QDialog. */ ODialog(QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags f = 0); /** * Return the number of pixels you shall use between a * dialog edge and the outermost widget(s) according to the KDE standard. **/ static int marginHint(); /** * Return the number of pixels you shall use between * widgets inside a dialog according to the KDE standard. */ static int spacingHint(); private: static int mMarginSize; static int mSpacingSize; - //class ODialogPrivate; - //ODialogPrivate *d; + class ODialogPrivate; + ODialogPrivate *d; // d pointer always needed! -zecke }; #endif // ODIALOG_H diff --git a/libopie2/opieui/oimageeffect.h b/libopie2/opieui/oimageeffect.h index 313ea50..fb4d22d 100644 --- a/libopie2/opieui/oimageeffect.h +++ b/libopie2/opieui/oimageeffect.h @@ -1,258 +1,259 @@ //FIXME: Revise for Opie - do we really need such fancy stuff on PDA's? //FIXME: Maybe not on SL5xxx, but surely on C700 :)) +//FIXME: I think we don#t need that -zecke /* This file is part of the KDE libraries Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@interaccess.com> (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // $Id$ #ifndef OIMAGEEFFECT_H #define OIMAGEEFFECT_H class QImage; class QSize; class QColor; /** * This class includes various @ref QImage based graphical effects. * * Everything is * static, so there is no need to create an instance of this class. You can * just call the static methods. They are encapsulated here merely to provide * a common namespace. */ class OImageEffect { public: enum GradientType { VerticalGradient, HorizontalGradient, DiagonalGradient, CrossDiagonalGradient, PyramidGradient, RectangleGradient, PipeCrossGradient, EllipticGradient }; enum RGBComponent { Red, Green, Blue, Gray, All }; enum Lighting {NorthLite, NWLite, WestLite, SWLite, SouthLite, SELite, EastLite, NELite}; enum ModulationType { Intensity, Saturation, HueShift, Contrast }; enum NoiseType { UniformNoise=0, GaussianNoise, MultiplicativeGaussianNoise, ImpulseNoise, LaplacianNoise, PoissonNoise}; enum RotateDirection{ Rotate90, Rotate180, Rotate270 }; /** * Create a gradient from color a to color b of the specified type. * * @param size The desired size of the gradient. * @param ca Color a * @param cb Color b * @param type The type of gradient. * @param ncols The number of colors to use when not running on a * truecolor display. The gradient will be dithered to this number of * colors. Pass 0 to prevent dithering. */ static QImage gradient(const QSize &size, const QColor &ca, const QColor &cb, GradientType type, int ncols=3); /** * Create an unbalanced gradient. * An unbalanced gradient is a gradient where the transition from * color a to color b is not linear, but in this case, exponential. * * @param size The desired size of the gradient. * @param ca Color a * @param cb Color b * @param type The type of gradient. * @param xfactor The x decay length. Use a value between -200 and 200. * @param yfactor The y decay length. * @param ncols The number of colors. See OPixmapEffect:gradient. */ static QImage unbalancedGradient(const QSize &size, const QColor &ca, const QColor &cb, GradientType type, int xfactor = 100, int yfactor = 100, int ncols = 3); /** * Blends a color into the destination image, using an opacity * value for blending one into another. Very fast direct pixel * manipulation is used. * * @author Karol Szwed (gallium@kde.org) * @param clr source color to be blended into the destination image. * @param dst destination image in which the source will be blended into. * @param opacity opacity (in percent) which determines how much the source * color will be blended into the destination image. * @return The destination image (dst) containing the result. */ static QImage& blend(const QColor& clr, QImage& dst, float opacity); /** * Blend the src image into the destination image, using an opacity * value for blending one into another. Very fast direct pixel * manipulation is used. * * @author Karol Szwed (gallium@kde.org) * @param src source image to be blended into the destination image. * @param dst destination image in which the source will be blended into. * @param opacity opacity (in percent) which determines how much the source * image will be blended into the destination image. * @return The destination image (dst) containing the result. */ static QImage& blend(QImage& src, QImage& dst, float opacity); /** * Blend the provided image into a background of the indicated color. * * @param initial_intensity this parameter takes values from -1 to 1: * a) if positive: how much to fade the image in its * less affected spot * b) if negative: roughly indicates how much of the image * remains unaffected * @param bgnd indicates the color of the background to blend in * @param eff lets you choose what kind of blending you like * @param anti_dir blend in the opposite direction (makes no much sense * with concentric blending effects) * @param image must be 32bpp */ static QImage& blend(QImage &image, float initial_intensity, const QColor &bgnd, GradientType eff, bool anti_dir=false); /** * Blend an image into another one, using a gradient type * for blending from one to another. * * @param image1 source1 and result of blending * @param image2 source2 of blending * @param gt gradient type for blending between source1 and source2 * @param xf x decay length for unbalanced gradient tpye * @param yf y decay length for unbalanced gradient tpye */ static QImage& blend(QImage &image1,QImage &image2, GradientType gt, int xf=100, int yf=100); /** * Blend an image into another one, using a color channel of a * third image for the decision of blending from one to another. * * @param image1 Source 1 and result of blending * @param image2 Source 2 of blending * @param blendImage If the gray value of of pixel is 0, the result * for this pixel is that of image1; for a gray value * of 1, the pixel of image2 is used; for a value * inbetween, a corresponding blending is used. * @param channel The RBG channel to use for the blending decision. */ static QImage& blend(QImage &image1, QImage &image2, QImage &blendImage, RGBComponent channel); /** * Blend an image into another one, using alpha in the expected way. * @author Rik Hemsley (rikkus) <rik@kde.org> */ static bool blend(const QImage & upper, const QImage & lower, QImage & output); // Not yet... static bool blend(const QImage & image1, const QImage & image2, QImage & output, const QRect & destRect); /** * Blend an image into another one, using alpha in the expected way and * over coordinates @p x and @p y with respect to the lower image. * The output is a QImage which is the @p upper image already blended * with the @p lower one, so its size will be (in general) the same than * @p upper instead of the same size than @p lower like the method above. * In fact, the size of @p output is like upper's one only when it can be * painted on lower, if there has to be some clipping, output's size will * be the clipped area and x and y will be set to the correct up-left corner * where the clipped rectangle begins. */ static bool blend(int &x, int &y, const QImage & upper, const QImage & lower, QImage & output); /** * Blend an image into another one, using alpha in the expected way and * over coordinates @p x and @p y with respect to the lower image. * The output is painted in the own @p lower image. This is an optimization * of the blend method above provided by convenience. */ static bool blendOnLower(int x, int y, const QImage & upper, const QImage & lower); /** * Modifies the intensity of a pixmap's RGB channel component. * * @author Daniel M. Duley (mosfet) * @param image The QImage to process. * @param percent Percent value. Use a negative value to dim. * @param channel Which channel(s) should be modified * @return The @p image, provided for convenience. */ static QImage& channelIntensity(QImage &image, float percent, RGBComponent channel); /** * Fade an image to a certain background color. * * The number of colors will not be changed. * * @param image The QImage to process. * @param val The strength of the effect. 0 <= val <= 1. * @param color The background color. * @return Returns the @ref image(), provided for convenience. */ static QImage& fade(QImage &img, float val, const QColor &color); /** * This recolors a pixmap. The most dark color will become color a, * the most bright one color b, and in between. * * @param image A QImage to process. * @param ca Color a * @param cb Color b */ static QImage& flatten(QImage &image, const QColor &ca, const QColor &cb, int ncols=0); /** * Build a hash on any given @ref QImage * * @param image The QImage to process * @param lite The hash faces the indicated lighting (cardinal poles). * @param spacing How many unmodified pixels inbetween hashes. * @return Returns the @ref image(), provided for convenience. */ static QImage& hash(QImage &image, Lighting lite=NorthLite, unsigned int spacing=0); /** * Either brighten or dim the image by a specified percent. * For example, .50 will modify the colors by 50%. * * @author Daniel M. Duley (mosfet) * @param image The QImage to process. * @param percent The percent value. Use a negative value to dim. * @return Returns The @ref image(), provided for convenience. */ static QImage& intensity(QImage &image, float percent); diff --git a/libopie2/opieui/olistview.h b/libopie2/opieui/olistview.h index bafc67c..b62e278 100644 --- a/libopie2/opieui/olistview.h +++ b/libopie2/opieui/olistview.h @@ -1,235 +1,235 @@ /* This file is part of the Opie Project =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> .=l. .>+-= _;:, .> :=|. This program 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 program 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 OLISTVIEW_H #define OLISTVIEW_H #include <qcolor.h> #include <qlistview.h> #include <qpen.h> #include <qdatastream.h> class OListViewItem; /** * A @ref QListView variant featuring visual and functional enhancements * like an alternate background for odd rows, an autostretch mode * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. * * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> * @short OListView list/tree widget. */ class OListView: public QListView { public: /** * Constructor. * * The parameters @p parent and @p name are handled by * @ref QListView, as usual. */ OListView ( QWidget *parent = 0, const char *name = 0 ); /** * Destructor. */ virtual ~OListView(); /** * Let the last column fit exactly all the available width. */ void setFullWidth( bool fullWidth ); /** * Returns whether the last column is set to fit the available width. */ bool fullWidth() const; /** * Reimplemented for full width support */ virtual int addColumn( const QString& label, int width = -1 ); /** * Reimplemented for full width support */ virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); /** * Reimplemented for full width support */ virtual void removeColumn(int index); /** * sets the alternate background background color. * This only has an effect if the items are OListViewItems * * @param c the color to use for every other item. Set to an invalid * color to disable alternate colors. */ void setAlternateBackground( const QColor &c ); /** * sets the column separator pen. * * @param p the pen used to draw the column separator. */ void setColumnSeparator( const QPen &p ); /** * @return the alternate background color */ const QColor& alternateBackground() const; /** * @return the column separator pen */ const QPen& columnSeparator() const; /** * create a list view item as child of this object * @return the new object */ virtual OListViewItem* childFactory(); - #ifndef QT_NO_DATASTREAM +#ifndef QT_NO_DATASTREAM /** * serialize this object to a @ref QDataStream * @param s the stream used to serialize this object. */ virtual void serializeTo( QDataStream& s ) const; /** * serialize this object from a @ref QDataStream * @param s the stream used to serialize this object. */ virtual void serializeFrom( QDataStream& s ); - #endif +#endif private: QColor m_alternateBackground; bool m_fullWidth; QPen m_columnSeparator; }; #ifndef QT_NO_DATASTREAM /** * \relates QListView * Writes a listview to the stream and returns a reference to the stream. */ QDataStream& operator<<( QDataStream& s, const OListView& lv ); /** * \relates QListView * Reads a listview from the stream and returns a reference to the stream. */ QDataStream& operator>>( QDataStream& s, OListView& lv ); #endif // QT_NO_DATASTREAM //****************************** OListViewItem ****************************************************************** class OListViewItem: public QListViewItem { public: OListViewItem( QListView * parent ); OListViewItem( QListViewItem * parent ); OListViewItem( QListView * parent, QListViewItem * after ); OListViewItem( QListViewItem * parent, QListViewItem * after ); OListViewItem( QListView * parent, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); OListViewItem( QListViewItem * parent, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); OListViewItem( QListView * parent, QListViewItem * after, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); OListViewItem( QListViewItem * parent, QListViewItem * after, QString, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); virtual ~OListViewItem(); const QColor& backgroundColor(); bool isAlternate(); void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); void init(); /** * create a list view item as child of this object * @return the new object */ virtual OListViewItem* childFactory(); #ifndef QT_NO_DATASTREAM /** * serialize this object to or from a @ref QDataStream * @param s the stream used to serialize this object. */ virtual void serializeTo( QDataStream& s ) const; /** * serialize this object to or from a @ref QDataStream * @param s the stream used to serialize this object. */ virtual void serializeFrom( QDataStream& s ); #endif private: bool m_known; bool m_odd; }; #ifndef QT_NO_DATASTREAM /** * \relates QListViewItem * Writes a listview item and all subitems recursively to the stream * and returns a reference to the stream. */ QDataStream& operator<<( QDataStream &s, const OListViewItem& lvi ); /** * \relates QListViewItem * Reads a listview item from the stream and returns a reference to the stream. */ QDataStream& operator>>( QDataStream &s, OListViewItem& lvi ); #endif // QT_NO_DATASTREAM #endif // OLISTVIEW_H diff --git a/libopie2/opieui/opopupmenu.h b/libopie2/opieui/opopupmenu.h index 94f05f4..54e4301 100644 --- a/libopie2/opieui/opopupmenu.h +++ b/libopie2/opieui/opopupmenu.h @@ -1,256 +1,259 @@ +//FIXME what is ODE? ODE Desktop Environemt? -zecke +//FIXME do we need titles? space is limited that is only eyecandy? -zecke +//FIXME keyboard navigation is also not that popular on a PDA might be with a keyboard (tuxphone) -zecke /* This file is part of the ODE libraries Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. 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 _OPOPUP_H #define _OPOPUP_H #define INCLUDE_MENUITEM_DEF /* QT */ #include <qpopupmenu.h> /* OPIE */ #include <opie2/opixmapeffect.h> /** * Title widget for use in @ref OPopupMenu. * * You usually don't have to create this manually since * @ref OPopupMenu::insertTitle will do it for you, but it is allowed if * you wish to customize it's look. * * @author Daniel M. Duley <mosfet@kde.org> * @short OPopupMenu title widget. */ class OPopupTitle : public QWidget { Q_OBJECT public: /** * Constructs a title widget with the user specified gradient, pixmap, * and colors. */ OPopupTitle(QWidget *parent=0, const char *name=0); /** * @deprecated * Constructs a title widget with the specified gradient and colors. */ OPopupTitle(OPixmapEffect::GradientType gradient, const QColor &color, const QColor &textColor, QWidget *parent=0, const char *name=0); /** * @deprecated * Constructs a title widget with the specified pixmap and colors. */ OPopupTitle(const OPixmap &background, const QColor &color, const QColor &textColor, QWidget *parent=0, const char *name=0); /** * Sets the title string and optional icon for the title widget. * * You will want to call this before inserting into a menu. */ void setTitle(const QString &text, const QPixmap *icon=NULL); /** * Returns the current title. */ QString title() const { return(titleStr); } /** * Returns the current icon. */ QPixmap icon() const { return(miniicon); } QSize sizeHint() const; public slots: /// @since 3.1 void setText( const QString &text ); /// @since 3.1 void setIcon( const QPixmap &pix ); protected: void paintEvent(QPaintEvent *ev); QString titleStr; QPixmap miniicon; // Remove in KDE4 OPixmapEffect::GradientType grType; QPixmap fill; QColor fgColor, bgColor, grHigh, grLow; bool useGradient; protected: virtual void virtual_hook( int id, void* data ); private: class OPopupTitlePrivate; OPopupTitlePrivate *d; }; /** * OPopupMenu is a class for menus with standard title items and keyboard * accessibility for popups with many options and/or varying options. It acts * identically to QPopupMenu, with the addition of insertTitle(), * changeTitle(), setKeyboardShortcutsEnabled() and * setKeyboardShortcutsExecute() methods. * * The titles support a text string, an icon, plus user defined gradients, * colors, and background pixmaps. * * The keyboard search algorithm is incremental with additional underlining * for user feedback. * * @short A menu with title items. * @author Daniel M. Duley <mosfet@kde.org> * @author Hamish Rodda <meddie@yoyo.its.monash.edu.au> */ class OPopupMenu : public QPopupMenu { Q_OBJECT public: /** * Constructs a OPopupMenu. */ OPopupMenu(QWidget *parent=0, const char *name=0); /** * Destructs the object */ ~OPopupMenu(); /** * Inserts a title item with no icon. */ int insertTitle(const QString &text, int id=-1, int index=-1); /** * Inserts a title item with the given icon and title. */ int insertTitle(const QPixmap &icon, const QString &text, int id=-1, int index=-1); /** * Changes the title of the item at the specified id. If a icon was * previously set it is cleared. */ void changeTitle(int id, const QString &text); /** * Changes the title and icon of the title item at the specified id. */ void changeTitle(int id, const QPixmap &icon, const QString &text); /** * Returns the title of the title item at the specified id. The default * id of -1 is for backwards compatibility only, you should always specify * the id. */ QString title(int id=-1) const; /** * Returns the icon of the title item at the specified id. */ QPixmap titlePixmap(int id) const; /** * Enables keyboard navigation by searching for the entered key sequence. * Also underlines the currently selected item, providing feedback on the search. * * Defaults to off. * * WARNING: calls to text() of currently keyboard-selected items will * contain additional ampersand characters. * * WARNING: though pre-existing keyboard shortcuts will not interfere with the * operation of this feature, they may be confusing to the user as the existing * shortcuts will not work. * @since 3.1 */ void setKeyboardShortcutsEnabled(bool enable); /** * Enables execution of the menu item once it is uniquely specified. * Defaults to off. * @since 3.1 */ void setKeyboardShortcutsExecute(bool enable); /** * Obsolete method provided for backwards compatibility only. Use the * normal constructor and insertTitle instead. */ OPopupMenu(const QString &title, QWidget *parent=0, const char *name=0); /** * Obsolete method provided for backwards compatibility only. Use * insertTitle and changeTitle instead. */ void setTitle(const QString &title); /** * Returns the context menu associated with this menu * @since 3.2 */ QPopupMenu* contextMenu(); /** * Hides the context menu if shown * @since 3.2 */ void cancelContextMenuShow(); /** * Returns the OPopupMenu associated with the current context menu * @since 3.2 */ static OPopupMenu* contextMenuFocus(); /** * returns the ID of the menuitem associated with the current context menu * @since 3.2 */ static int contextMenuFocusItem(); signals: /** * connect to this signal to be notified when a context menu is about to be shown * @param menu The menu that the context menu is about to be shown for * @param menuItem The menu item that the context menu is currently on * @param ctxMenu The context menu itself * @since 3.2 */ void aboutToShowContextMenu(OPopupMenu* menu, int menuItem, QPopupMenu* ctxMenu); protected: virtual void closeEvent(QCloseEvent *); virtual void keyPressEvent(QKeyEvent* e); virtual bool eventFilter(QObject* obj, QEvent* event); virtual void hideEvent(QHideEvent*); virtual void virtual_hook( int id, void* data ); protected slots: /// @since 3.1 QString underlineText(const QString& text, uint length); /// @since 3.1 void resetKeyboardVars(bool noMatches = false); void itemHighlighted(int whichItem); void showCtxMenu(QPoint pos); void ctxMenuHiding(); private: class OPopupMenuPrivate; OPopupMenuPrivate *d; }; #endif diff --git a/libopie2/qt3/opiecore/opair.h b/libopie2/qt3/opiecore/opair.h index 26f617d..a151127 100644 --- a/libopie2/qt3/opiecore/opair.h +++ b/libopie2/qt3/opiecore/opair.h @@ -1,99 +1,100 @@ // QPair minus QT_INLINE_TEMPLATE (instead directly using 'inline' directive) //FIXME: remove and use qpair.h as soon as we're on Qt3 +// name file qpair -zecke /**************************************************************************** ** ** Definition of QPair class ** ** ** Copyright (C) 1992-2001 Trolltech AS. All rights reserved. ** ** This file is part of the tools module of the Qt GUI Toolkit. ** ** This file may be distributed under the terms of the Q Public License ** as defined by Trolltech AS of Norway and appearing in the file ** LICENSE.QPL included in the packaging of this file. ** ** 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. ** ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition ** licenses may use this file in accordance with the Qt Commercial License ** Agreement provided with the Software. ** ** 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/pricing.html or email sales@trolltech.com for ** information about Qt Commercial License Agreements. ** See http://www.trolltech.com/qpl/ for QPL licensing information. ** 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. ** **********************************************************************/ #ifndef QPAIR_H #define QPAIR_H #ifndef QT_H #include "qglobal.h" #include "qdatastream.h" #endif // QT_H template <class T1, class T2> struct QPair { typedef T1 first_type; typedef T2 second_type; QPair() : first( T1() ), second( T2() ) {} QPair( const T1& t1, const T2& t2 ) : first( t1 ), second( t2 ) {} T1 first; T2 second; }; template <class T1, class T2> inline bool operator==( const QPair<T1, T2>& x, const QPair<T1, T2>& y ) { return x.first == y.first && x.second == y.second; } template <class T1, class T2> inline bool operator<( const QPair<T1, T2>& x, const QPair<T1, T2>& y ) { return x.first < y.first || ( !( y.first < x.first ) && x.second < y.second ); } template <class T1, class T2> inline QPair<T1, T2> qMakePair( const T1& x, const T2& y ) { return QPair<T1, T2>( x, y ); } #ifndef QT_NO_DATASTREAM template <class T1, class T2> inline QDataStream& operator>>( QDataStream& s, QPair<T1, T2>& p ) { s >> p.first >> p.second; return s; } template <class T1, class T2> inline QDataStream& operator<<( QDataStream& s, const QPair<T1, T2>& p ) { s << p.first << p.second; return s; } #endif #endif |