summaryrefslogtreecommitdiff
path: root/libopie2
authorzecke <zecke>2004-09-10 11:04:46 (UTC)
committer zecke <zecke>2004-09-10 11:04:46 (UTC)
commit224c96feb94acd6a87e1a2463aca9726afe925ef (patch) (side-by-side diff)
tree58addf357217e4e84d7231afed4a901b3a2e0bba /libopie2
parent2ec724fc789cd34f6b3743896516f2fef2731456 (diff)
downloadopie-224c96feb94acd6a87e1a2463aca9726afe925ef.zip
opie-224c96feb94acd6a87e1a2463aca9726afe925ef.tar.gz
opie-224c96feb94acd6a87e1a2463aca9726afe925ef.tar.bz2
Fix warnings about unused parameters
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/oconfig.cpp2
-rw-r--r--libopie2/opiecore/ofilenotify.cpp2
-rw-r--r--libopie2/opiecore/opluginloader.h3
3 files changed, 6 insertions, 1 deletions
diff --git a/libopie2/opiecore/oconfig.cpp b/libopie2/opiecore/oconfig.cpp
index 05d8070..6b57729 100644
--- a/libopie2/opiecore/oconfig.cpp
+++ b/libopie2/opiecore/oconfig.cpp
@@ -20,186 +20,188 @@
  _.=:.       :    :=>`: 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.
*/
/* QT */
#include <qfont.h>
#include <qcolor.h>
/* OPIE */
#include <opie2/oconfig.h>
using namespace Opie::Core;
OConfig::OConfig( const QString &name, Domain domain )
:Config( name, domain )
{
qDebug( "OConfig::OConfig()" );
}
OConfig::~OConfig()
{
qDebug( "OConfig::~OConfig()" );
}
QColor OConfig::readColorEntry( const QString& key, const QColor* pDefault ) const
{
QColor aRetColor;
int nRed = 0, nGreen = 0, nBlue = 0;
QString aValue = readEntry( key );
if( !aValue.isEmpty() )
{
if ( aValue.at(0) == '#' )
{
aRetColor.setNamedColor(aValue);
}
else
{
bool bOK;
// find first part (red)
int nIndex = aValue.find( ',' );
if( nIndex == -1 )
{
// return a sensible default -- Bernd
if( pDefault )
aRetColor = *pDefault;
return aRetColor;
}
nRed = aValue.left( nIndex ).toInt( &bOK );
// find second part (green)
int nOldIndex = nIndex;
nIndex = aValue.find( ',', nOldIndex+1 );
if( nIndex == -1 )
{
// return a sensible default -- Bernd
if( pDefault )
aRetColor = *pDefault;
return aRetColor;
}
nGreen = aValue.mid( nOldIndex+1,
nIndex-nOldIndex-1 ).toInt( &bOK );
// find third part (blue)
nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK );
aRetColor.setRgb( nRed, nGreen, nBlue );
}
}
else {
if( pDefault )
aRetColor = *pDefault;
}
return aRetColor;
}
// FIXME: The whole font handling has to be revised for Opie
QFont OConfig::readFontEntry( const QString& key, const QFont* pDefault ) const
{
+ Q_CONST_UNUSED( key )
+ Q_CONST_UNUSED( pDefault )
/*
QFont aRetFont;
QString aValue = readEntry( key );
if( !aValue.isNull() ) {
if ( aValue.contains( ',' ) > 5 ) {
// KDE3 and upwards entry
if ( !aRetFont.fromString( aValue ) && pDefault )
aRetFont = *pDefault;
}
else {
// backward compatibility with older font formats
// ### remove KDE 3.1 ?
// find first part (font family)
int nIndex = aValue.find( ',' );
if( nIndex == -1 ){
if( pDefault )
aRetFont = *pDefault;
return aRetFont;
}
aRetFont.setFamily( aValue.left( nIndex ) );
// find second part (point size)
int nOldIndex = nIndex;
nIndex = aValue.find( ',', nOldIndex+1 );
if( nIndex == -1 ){
if( pDefault )
aRetFont = *pDefault;
return aRetFont;
}
aRetFont.setPointSize( aValue.mid( nOldIndex+1,
nIndex-nOldIndex-1 ).toInt() );
// find third part (style hint)
nOldIndex = nIndex;
nIndex = aValue.find( ',', nOldIndex+1 );
if( nIndex == -1 ){
if( pDefault )
aRetFont = *pDefault;
return aRetFont;
}
aRetFont.setStyleHint( (QFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() );
// find fourth part (char set)
nOldIndex = nIndex;
nIndex = aValue.find( ',', nOldIndex+1 );
if( nIndex == -1 ){
if( pDefault )
aRetFont = *pDefault;
return aRetFont;
}
QString chStr=aValue.mid( nOldIndex+1,
nIndex-nOldIndex-1 );
// find fifth part (weight)
nOldIndex = nIndex;
nIndex = aValue.find( ',', nOldIndex+1 );
if( nIndex == -1 ){
if( pDefault )
aRetFont = *pDefault;
return aRetFont;
}
aRetFont.setWeight( aValue.mid( nOldIndex+1,
nIndex-nOldIndex-1 ).toUInt() );
// find sixth part (font bits)
uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt();
aRetFont.setItalic( nFontBits & 0x01 );
aRetFont.setUnderline( nFontBits & 0x02 );
aRetFont.setStrikeOut( nFontBits & 0x04 );
aRetFont.setFixedPitch( nFontBits & 0x08 );
aRetFont.setRawMode( nFontBits & 0x20 );
}
}
else
{
if( pDefault )
aRetFont = *pDefault;
}
return aRetFont;
*/
return QFont("Helvetica",10);
}
diff --git a/libopie2/opiecore/ofilenotify.cpp b/libopie2/opiecore/ofilenotify.cpp
index b576c4f..2a9bb8c 100644
--- a/libopie2/opiecore/ofilenotify.cpp
+++ b/libopie2/opiecore/ofilenotify.cpp
@@ -156,165 +156,167 @@ void OFileNotification::stop()
{
::close( _fd );
_type = Single;
_path = QString::null;
_fd = 0;
_active = false;
}
}
OFileNotificationType OFileNotification::type() const
{
return _type;
}
QString OFileNotification::path() const
{
return _path;
}
int OFileNotification::fileno() const
{
return _fd;
}
bool OFileNotification::activate()
{
if ( hasChanged() )
{
emit triggered();
_signal.activate();
return true;
}
else
return false;
}
bool OFileNotification::hasChanged()
{
bool c = false;
struct stat newstat;
::memset( &newstat, 0, sizeof newstat );
int result = ::stat( _path, &newstat ); // may fail if file has been renamed or deleted. that doesn't matter :)
qDebug( "result of newstat call is %d (%s=%d)", result, result == -1 ? strerror( errno ) : "success", errno );
qDebug( "stat.atime = %0lx, newstat.atime = %0lx", (long)_stat.st_atime, (long)newstat.st_atime );
qDebug( "stat.mtime = %0lx, newstat.mtime = %0lx", (long)_stat.st_mtime, (long)newstat.st_mtime );
qDebug( "stat.ctime = %0lx, newstat.ctime = %0lx", (long)_stat.st_ctime, (long)newstat.st_ctime );
if ( !c && (_type & Create) &&
(long)_stat.st_atime == 0 && (long)_stat.st_mtime == 0 && (long)_stat.st_ctime == 0 &&
(long)newstat.st_atime > 0 && (long)newstat.st_mtime > 0 && (long)newstat.st_ctime > 0)
{
qDebug( "OFileNotification::hasChanged(): file has been created" );
c = true;
}
if ( !c && (_type & (Delete|Rename)) && (long)newstat.st_atime == 0 && (long)newstat.st_mtime == 0 && (long)newstat.st_ctime == 0)
{
qDebug( "OFileNotification::hasChanged(): file has been deleted or renamed" );
c = true;
}
if ( !c && (_type & Access) && (long)_stat.st_atime < (long)newstat.st_atime )
{
qDebug( "OFileNotification::hasChanged(): atime changed" );
c = true;
}
if ( !c && (_type & Modify) && (long)_stat.st_mtime < (long)newstat.st_mtime )
{
qDebug( "OFileNotification::hasChanged(): mtime changed" );
c = true;
}
if ( !c && (_type & Attrib) && (long)_stat.st_ctime < (long)newstat.st_ctime )
{
qDebug( "OFileNotification::hasChanged(): ctime changed" );
c = true;
}
return c;
}
void OFileNotification::singleShot( const QString& path, QObject* receiver, const char* member, OFileNotificationType type )
{
OFileNotification* ofn = new OFileNotification();
ofn->_signal.connect( receiver, member );
ofn->start( path, true, type );
}
void OFileNotification::__signalHandler( int sig, siginfo_t *si, void *data )
{
+ Q_UNUSED( sig )
+ Q_UNUSED( data )
qWarning( "OFileNotification::__signalHandler(): reached." );
int fd = si->si_fd;
OFileNotification* fn = notification_list[fd];
if ( fn )
{
// check if it really was the file (dnotify triggers on directory granularity, not file granularity)
if ( !fn->activate() )
{
qDebug( "OFileNotification::__signalHandler(): false alarm ;) Restarting the trigger (if it was single)..." );
if ( !(fn->type() & Multi ) )
{
int result = ::fcntl( fn->fileno(), F_NOTIFY, fn->type() );
if ( result == -1 )
{
qWarning( "OFileNotification::__signalHandler(): Can't restart the trigger: %s.", strerror( errno ) );
}
}
return;
}
#if 1
if ( !(fn->type() & Multi) )
{
qDebug( "OFileNotification::__signalHandler(): '%d' was singleShot. Removing from list.", fd );
notification_list.remove( fd );
if ( notification_list.isEmpty() )
{
OFileNotification::unregisterSignalHandler();
}
}
#endif
}
else
{
qWarning( "OFileNotification::__signalHandler(): D'oh! Called without fd in notification_list. Race condition?" );
}
}
bool OFileNotification::registerSignalHandler()
{
struct sigaction act;
act.sa_sigaction = OFileNotification::__signalHandler;
::sigemptyset( &act.sa_mask );
act.sa_flags = SA_SIGINFO;
if ( ::sigaction( SIGRTMIN, &act, NULL ) == -1 )
{
qWarning( "OFileNotification::registerSignalHandler(): couldn't register signal handler: %s", strerror( errno ) );
return false;
}
qDebug( "OFileNotification::registerSignalHandler(): done" );
return true;
}
void OFileNotification::unregisterSignalHandler()
{
struct sigaction act;
act.sa_sigaction = ( void (*)(int, siginfo_t*, void*) ) SIG_DFL;
::sigemptyset( &act.sa_mask );
if ( ::sigaction( SIGRTMIN, &act, NULL ) == -1 )
{
qWarning( "OFileNotification::unregisterSignalHandler(): couldn't deregister signal handler: %s", strerror( errno ) );
}
qDebug( "OFileNotification::unregisterSignalHandler(): done" );
}
}
}
diff --git a/libopie2/opiecore/opluginloader.h b/libopie2/opiecore/opluginloader.h
index d97f586..ee47733 100644
--- a/libopie2/opiecore/opluginloader.h
+++ b/libopie2/opiecore/opluginloader.h
@@ -1,163 +1,164 @@
/*
* LGPLv2 or later
* zecke@handhelds.org
*/
#ifndef ODP_CORE_OPLUGIN_LOADER_H
#define ODP_CORE_OPLUGIN_LOADER_H
#include <qpe/qlibrary.h>
#include <qptrdict.h>
#include <qstringlist.h>
namespace Opie {
namespace Core {
class OConfig;
namespace Internal {
class OPluginLibraryHolder;
}
/**
* \brief A small item representing the Plugin Information
* This class contains the information about a Plugin. It contains
* a translated name if available to the system, a config key,
* and the path location.
*
* @since 1.2
*
*/
class OPluginItem {
public:
typedef QValueList<OPluginItem> List;
OPluginItem();
OPluginItem( const QString& name, const QString& path, bool enabled = true, int pos = -1 );
~OPluginItem();
bool isEmpty()const;
bool operator==( const OPluginItem& )const;
bool operator!=( const OPluginItem& )const;
QString name()const;
QString path()const;
bool isEnabled()const;
int position()const;
void setName( const QString& );
void setPath( const QString& );
void setEnabled( bool );
void setPosition( int );
private:
QString m_name;
QString m_path;
bool m_enabled : 1;
int m_pos;
struct Private;
Private *d;
};
/**
* \brief A generic class to easily load and manage plugins
*
* This is the generic non sepcialised loader for plugins. Normally
* you would prefer using the OPluginLoader directly. This class
* exists to minimize the application binary size due the usage
- * of templates in the specialized API
+ * of templates in the specialized API.
+ *
*
* @since 1.2
* @see OPluginLoader
*/
class OGenericPluginLoader {
public:
typedef OPluginItem::List List;
OGenericPluginLoader( const QString &name, bool isSorted = false );
virtual ~OGenericPluginLoader();
void setAutoDelete( bool );
bool autoDelete()const;
void clear();
QString name()const;
bool isSorted()const;
bool isInSafeMode()const;
List allAvailable(bool sorted = false )const;
List filtered(bool sorted = false )const;
virtual QUnknownInterface* load( const OPluginItem& item, const QUuid& );
virtual void unload( QUnknownInterface* );
protected:
friend class OPluginManager; // we need the static unlibify
void readConfig();
virtual List plugins( const QString& dir, bool sorted, bool disabled )const;
void setPluginDirs( const QStringList& );
void setPluginDir( const QString& );
void setSafeMode(const QString& app = QString::null, bool b = false);
static QString unlibify( const QString& str );
private:
QStringList languageList();
void installTranslators(const QString& type);
QString m_dir;
QStringList m_plugDirs;
QStringList m_languages;
bool m_autoDelete : 1;
bool m_isSafeMode : 1;
bool m_isSorted : 1;
QPtrDict<QLibrary> m_library;
struct Private;
Private* d;
};
/**
* \brief The class to load your QCOM+ plugins
*
* This class takes care of activation and even the order
* if you need it. It is normally good to place a .directory file
* into your plugin directory if you need order of activation.
*
* You'll create the OPluginLoader and then use it to load the filtered
* plugins.
*
* There is also a GUI for the configuration and a Manager to write the
* mentioned .directory file
*
* On crash the safe mode is activated for the next run. You can then decide
* if you want to load plugins or come up with the Configuration on
* next start yourself then.
*
* @since 1.2
*/
class OPluginLoader : public OGenericPluginLoader {
public:
OPluginLoader( const QString& name, bool sorted = false );
virtual ~OPluginLoader();
template<class IFace>
IFace* load( const OPluginItem& item, const QUuid& );
};
/**
* \brief A class to manage order and activation of plugins
*
* Manage order and activation. This is used by the Opie::Ui::OPluginConfig
* This class controls the activation and order of plugins depending
* on the OPluginLoader you supply.
* You must call load() and save after construnction an instance
*
* @see Opie::Ui::OPluginConfig
*
*/
class OPluginManager {
public:
typedef QValueList<OPluginManager*> List;
OPluginManager( OGenericPluginLoader* );
OPluginManager( const QString& name, const OPluginItem::List&, bool isSorted = false );
virtual ~OPluginManager();
OPluginItem crashedPlugin()const;