-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | examples/opiecore/onotifytest/main.cpp | 18 | ||||
-rw-r--r-- | examples/opiecore/onotifytest/main.h | 10 | ||||
-rw-r--r-- | libopie2/opiecore/linux/ofilenotify.cpp | 40 | ||||
-rw-r--r-- | libopie2/opiecore/linux/ofilenotify.h | 3 | ||||
-rwxr-xr-x | scripts/addLanguage.sh | 33 | ||||
-rwxr-xr-x | scripts/mkipks | 261 |
7 files changed, 343 insertions, 25 deletions
@@ -26,9 +26,10 @@ Internal -------- * Make BluezApplet use OTaskbarApplet (mickeyl) - * Rewrite OFileNotification to use the upcoming inotify interface instead of the deprecated dnotify (mickeyl) + * libopiecore: rewrite OFileNotification to use the Linux 2.6 inotify interface (mickeyl) + * libopiecore: add ODirNotification - recursive directory notifications (mickeyl) * libopienet: Skip hostap control interfaces 'wifi' and improve robustness in ONetworkInterface (mickeyl) * libopieui: Remove OVersatileView and OVersatileViewItem (mickeyl) * libopienet: Miscellaneous API cleanups (mickeyl) * libopiecore: Add linux pcmcia system abstraction classes (mickeyl) diff --git a/examples/opiecore/onotifytest/main.cpp b/examples/opiecore/onotifytest/main.cpp index b773da9..7b7b0bc 100644 --- a/examples/opiecore/onotifytest/main.cpp +++ b/examples/opiecore/onotifytest/main.cpp @@ -30,23 +30,33 @@ App::App( int argc, char** argv ) : QApplication( argc, argv ) QObject::connect( tmpfoo, SIGNAL(accessed(const QString&)), this, SLOT(quit()) ); QObject::connect( tmpfoo, SIGNAL(closed(const QString&,bool)), this, SLOT(quit()) ); #endif - ODirNotification* tmpfoo = new ODirNotification( 0, 0 ); + tmpfoo = new ODirNotification( 0, 0 ); int result = tmpfoo->watch( "/tmp/foo", false, CreateFile, 2 ); - QObject::connect( tmpfoo, SIGNAL(triggered(const QString&,unsigned int,const QString&)), - this, SLOT(triggered(const QString&,unsigned int,const QString&)) ); + + if ( result != -1 ) + { + QObject::connect( tmpfoo, SIGNAL(triggered(const QString&,unsigned int,const QString&)), + this, SLOT(triggered(const QString&,unsigned int,const QString&)) ); + } + else + { + QMessageBox::warning( qApp->desktop(), "info", "Couldn't watch /tmp/foo\nDoes it exist?" ); + } } App::~App() { odebug << "~App()" << oendl; + delete tmpfoo; } void App::triggered( const QString& str1, unsigned int id, const QString& str2 ) { - QMessageBox::information( qApp->desktop(), "info", QString( "%1\n%2\n%3" ).arg( str1 ).arg( id ).arg( str2 ) ); + QMessageBox::information( qApp->desktop(), "info", QString().sprintf( "%s\n0x%08x\n%s", + (const char*) str1, id, (const char*) str2 ) ); } int main( int argc, char** argv ) { diff --git a/examples/opiecore/onotifytest/main.h b/examples/opiecore/onotifytest/main.h index afad947..7ce4b9f 100644 --- a/examples/opiecore/onotifytest/main.h +++ b/examples/opiecore/onotifytest/main.h @@ -3,21 +3,27 @@ #ifndef MAIN_H #define MAIN_H +/* OPIE */ +#include <opie2/ofilenotify.h> + /* QT */ #include <qapplication.h> #include <qpushbutton.h> #include <qtextstream.h> class App : public QApplication { Q_OBJECT -public: + public: App( int argc, char** argv ); ~App(); -public slots: + public slots: void triggered( const QString&, unsigned int, const QString& ); + + private: + Opie::Core::ODirNotification* tmpfoo; }; #endif diff --git a/libopie2/opiecore/linux/ofilenotify.cpp b/libopie2/opiecore/linux/ofilenotify.cpp index a7820ee..68c5a96 100644 --- a/libopie2/opiecore/linux/ofilenotify.cpp +++ b/libopie2/opiecore/linux/ofilenotify.cpp @@ -235,8 +235,10 @@ bool OFileNotification::isSingleShot() const bool OFileNotification::activate( const OFileNotificationEvent* e ) { qDebug( "OFileNotification::activate(): e = ( %s, %d, 0x%08x, %d, %s )", (const char*) _path, e->descriptor(), e->mask(), e->cookie(), (const char*) e->name() ); + //FIXME: Should we really deliver QueueOverflow and/or Ignore to user level code? + // dumb signal _signal.activate(); // generic signal @@ -244,25 +246,29 @@ bool OFileNotification::activate( const OFileNotificationEvent* e ) // specialized signals switch ( e->mask() ) { - case Access: emit accessed( _path ); break; - case Modify: emit modified( _path ); break; - case Attrib: emit attributed( _path); break; - case CloseWrite: emit closed( _path, true ); break; - case CloseNoWrite: emit closed( _path, false ); break; - case Open: emit opened( _path ); break; - case MovedFrom: emit movedFrom( _path, e->name() ); break; - case MovedTo: emit movedTo( _path, e->name() ); break; - case DeleteSubdir: emit deletedSubdir( _path, e->name() ); break; - case DeleteFile: emit deletedFile( _path, e->name() ); break; - case CreateSubdir: emit createdSubdir( _path, e->name() ); break; - case CreateFile: emit createdFile( _path, e->name() ); break; - case DeleteSelf: emit deleted( _path ); break; - case Unmount: emit unmounted( _path ); break; + case Access: emit accessed( _path ); break; + case Modify: emit modified( _path ); break; + case Attrib: emit attributed( _path); break; + case CloseWrite: emit closed( _path, true ); break; + case CloseNoWrite: emit closed( _path, false ); break; + case Open: emit opened( _path ); break; + case MovedFrom: emit movedFrom( _path, e->name() ); break; + case MovedTo: emit movedTo( _path, e->name() ); break; + case DeleteSubdir: emit deletedSubdir( _path, e->name() ); break; + case DeleteFile: emit deletedFile( _path, e->name() ); break; + case CreateSubdir: emit createdSubdir( _path, e->name() ); break; + case CreateFile: emit createdFile( _path, e->name() ); break; + case DeleteSelf: emit deleted( _path ); break; + case Unmount: emit unmounted( _path ); break; + case _QueueOverflow: qFatal( "OFileNotification::activate() - Inotify Event Queue Overload!" ); break; + case _Ignored: qWarning( "OFileNotification::activate() - Further Events for '%s' will be ignored", (const char*) _path ); break; default: assert( 0 ); } + delete e; + if ( !_multi ) stop(); return true; } @@ -316,9 +322,9 @@ bool OFileNotification::registerEventHandler() qWarning( "OFileNotification::registerEventHandler(): couldn't register event handler: %s", strerror( errno ) ); return false; } - OFileNotification::_sn = new QSocketNotifier( _fd, QSocketNotifier::Read, this, "inotify event" ); + OFileNotification::_sn = new QSocketNotifier( _fd, QSocketNotifier::Read ); connect( OFileNotification::_sn, SIGNAL( activated(int) ), this, SLOT( inotifyEventHandler() ) ); qDebug( "OFileNotification::registerEventHandler(): done" ); return true; @@ -347,9 +353,9 @@ ODirNotification::~ODirNotification() { qDebug( "ODirNotification::~ODirNotification()" ); } -/* +/** Love-Trowbridge recursive directory scanning algorithm: Step 1. Start at initial directory foo. Add watch. @@ -364,9 +370,9 @@ ODirNotification::~ODirNotification() step 1. Step 5. For any CREATE_SUBDIR event on bar, if a watch is not yet created on bar, repeat step 1 on bar. -*/ +**/ int ODirNotification::watch( const QString& path, bool sshot, OFileNotificationType type, int recurse ) { if ( _type == Nothing ) _type = type; // only set it once - for the top level call diff --git a/libopie2/opiecore/linux/ofilenotify.h b/libopie2/opiecore/linux/ofilenotify.h index 17e6b5d..c713b30 100644 --- a/libopie2/opiecore/linux/ofilenotify.h +++ b/libopie2/opiecore/linux/ofilenotify.h @@ -256,9 +256,10 @@ class OFileNotification : public QObject /** * @brief Represents a directory notification * * This class allows to watch for events happening to directories - * It uses the OFileNotification class + * It uses the OFileNotification class and (for recursive watches) + * implements the Love-Trowbridge recursive directory scanning algorithm. * * @see http://www.kernel.org/pub/linux/kernel/people/rml/inotify/ * * @author Michael 'Mickey' Lauer <mickey@vanille.de> diff --git a/scripts/addLanguage.sh b/scripts/addLanguage.sh new file mode 100755 index 0000000..e321804 --- a/dev/null +++ b/scripts/addLanguage.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# (c) 2002 Bruno Rodrigues <bruno.rodrigues@litux.org> +# Under GPL Licence + +# Add a new TRANSLATION line to every .pro file if there +# is already at least one TRANSLATION file and this LANG +# is not present +# The perl line would grab a TRANSLATION = something and +# duplicate it to TRANSLATION += .../LANG/... + +LANG=$1 + +if [ "$1x" == "x" ] ; then + echo "Usage: $0 <LANG>" + exit +fi + +for i in `find . -name "*.pro"` ; do + grep TRANSLATIONS $i > /dev/null + if [ "$?" != 0 ] ; then + echo "$i: No Translations" + else + grep "../i18n/$LANG/" $i > /dev/null + if [ "$?" == 0 ] ; then + echo "$i: $LANG already there" + else + echo "$i: Adding $LANG" + perl -p -i.bak -e 's/^(TRANSLATIONS\s*\+?=\s*)(.+?i18n\/)(.+?)(\/.+?\.ts)(.*)$/$1$2$3$4 \\\n\t $2'$LANG'$4$5/' $i + fi + fi +done + diff --git a/scripts/mkipks b/scripts/mkipks new file mode 100755 index 0000000..f142029 --- a/dev/null +++ b/scripts/mkipks @@ -0,0 +1,261 @@ +#!/bin/sh + +if [ -z "$QTE_BASEVERSION" ] +then + if [ -e $QTDIR/include/qglobal.h ] + then + QTE_BASEVERSION=`cat $QTDIR/include/qglobal.h|grep '^#define QT_VERSION'|grep -v STR|sed -e 's,#define QT_VERSION\t*,,;' -e 's,.*\([0-9]\)\([0-9]\)\([0-9]\).*,\1.\2.\3,;'` + else + QTE_BASEVERSION=2.3.4 + fi +fi +if [ -z "$QTE_VERSION" ] +then + if [ -e $QTDIR/include/qglobal.h ] + then + QTE_VERSION=`cat $QTDIR/include/qglobal.h|grep '^#define QT_VERSION_STR'|sed -e 's,#define QT_VERSION_STR\t*,,;' -e 's,.*"\([^"]*\)".*,\1,;'` + else + QTE_VERSION=2.3.4 + fi +fi +[ -z "$QTE_REVISION" ] && QTE_REVISION=5 +DEB_VERSION=2.0 + +# Have to do this here, since CVS can't store symlinks + +mkdir -p $OPIEDIR/etc/rcS.d +ln -sf ../init.d/bootsplash $OPIEDIR/etc/rcS.d/S01bootsplash + +VERSION_MAJ=$(sed -n -e 's/.*QPE_VERSION "\([0-9]*\)\..*\..*".*/\1/p' <$OPIEDIR/include/qpe/version.h) +VERSION_MIN=$(sed -n -e 's/.*QPE_VERSION ".*\.\([0-9]*\)\..*".*/\1/p' <$OPIEDIR/include/qpe/version.h) +VERSION_PAT=$(sed -n -e 's/.*QPE_VERSION ".*\..*\.\([0-9]*\).*/\1/p' <$OPIEDIR/include/qpe/version.h) +SUB_VERSION=$(sed -n -e 's,.*SUB_VERSION \"\(.*\)\".*,\1,p' <$OPIEDIR/include/qpe/version.h) +if grep -q 'QPE_VERSION .*snapshot' $OPIEDIR/include/qpe/version.h +then + [ -z "$VERSION_CVS" ] && VERSION_CVS="$(date +%Y%m%d)" + SUB_VERSION=$VERSION_CVS +else + VERSION_CVS="" +fi + +QPE_VERSION=$VERSION_MAJ.$VERSION_MIN.$VERSION_PAT + +ARCH=arm +STRIP=arm-linux-strip +STRIP_FILES="*ARM*not stripped" + +TDIR=/tmp/ipk$$ +DATADIR=$TDIR +CTRLDIR=$TDIR/CONTROL + +IMAGEDIR= +VERB= +LIST= +RPM= + +while [ $# -ne 0 ] +do + case "$1" in + -v) + VERB=1 + echo >&2 "Packaging for version $VERSION_MAJ.$VERSION_MIN.$VERSION_PAT$VERSION_CVS" + ;; -l) + LIST=1 + ;; -i) + shift + IMAGEDIR=$1 + DATADIR=$IMAGEDIR + mkdir -p $IMAGEDIR + ;; -classic) + classicopts=-c + ;; -rpm) + if [ "$OPIEDIR" != "/opt/Qtopia" ] + then + echo >&2 '$OPIEDIR is not the standard /usr/Qtopia directory.' + sleep 1 + #exit 1 + fi + RPM=1 + ;; -arch) + shift + ARCH=$1 + STRIP= + STRIP_FILES= + ;; /*) + FILES="$FILES $1" + ;; *) + FILES="$FILES $PWD/$1" + esac + shift +done + +if [ -z "$FILES" ] +then + FILES=`find $OPIEDIR -name "*.control" -print` +fi + +RDIR=$PWD +ORIGDIR=`pwd` +cd $OPIEDIR + +for i in $FILES +do + rm -rf $TDIR + + mkdir -p $DATADIR + mkdir -p $CTRLDIR + + packagename=${i##*/}; packagename=${packagename%.control} + version=$(eval echo '"'$(sed -n -e "s/^Version: *//p" $i)'"') + depends=$(eval echo '"'$(sed -n -e "s/^Depends: *//p" $i)'"') + files=$(eval echo $(sed -n -e "s/^Files://p" $i)) + arch=$(eval echo $(sed -n -e "s/^Arch://p" $i)) + section=$(sed -n -e "s/^Section: *//p" $i) + provides=$(sed -n -e "s/^Provides: *//p" $i) + conflicts=$(sed -n -e "s/^Conflicts: *//p" $i) + license=$(sed -n -e "s/^License: *//p" $i) + summary=$(sed -n -e "s/^Description: *//p" $i) + package=${packagename}_${version}_$ARCH + ERROR= + if [ -z "$files" ] + then + mkdir -p $DATADIR/usr/share/doc/$packagename + else + for f in $files + do + if [ -d $f ] + then + ffiles=$(find $f -type f -o -type b -o -type c -o -type l) + else + ffiles=$f + fi + for ff in $ffiles + do + case $ff in + */CVS/*) + continue + ;; *~) + continue + ;; *.control) + continue + ;; $QTDIR/*) + BASE=$(dirname /opt/QtPalmtop/${ff#$QTDIR/}) + ;; etc/*.d/*) + BASE=$(dirname /$ff) + ;; root/*) + BASE=$(dirname ${ff#root}) + ;; lib/*) + BASE=$(dirname /opt/QtPalmtop/$ff) + ;; $OPIEDIR/lib/*) + BASE=$(dirname /opt/QtPalmtop/${ff#$OPIEDIR/}) + ;; $OPIEDIR/root/*) + BASE=$(dirname /${ff#$OPIEDIR/root/}) + ;; *) + # For SHARP ROM compatibility. Should change to Qtopia. + BASE=/opt/QtPalmtop/$(dirname $ff) + esac + + if [ -f $ff -o -b $ff -o -c $ff ] + then + D=$DATADIR$BASE + if [ -x $ff -a -n "$STRIP" ] + then + case $(file $ff) in + $STRIP_FILES) + $STRIP $ff + ;; *) + esac + fi + if [ -n "$RPM" ] + then + case "$ff" in + /*) RPMFILES="$RPMFILES $ff" + ;; *) RPMFILES="$RPMFILES $OPIEDIR/$ff" + esac + else + mkdir -p $D + if cp -a $ff $D + then + true + else + ERROR=1 + fi + fi + else + echo >&2 "$0: $i: No such file: $ff" + ERROR=1 + fi + done + done + fi + if [ -z "$ERROR" ] + then + if [ -n "$RPM" ] + then + SPEC=/tmp/mkipks-rpm-$$.spec + echo >$SPEC "Summary: $summary" + echo >>$SPEC "Name: $packagename" + echo >>$SPEC "Group: $section" ########## + echo >>$SPEC "License: $license" + echo >>$SPEC "Version: ${version%-*}" + echo >>$SPEC "Release: ${version#*-}" + + echo >>$SPEC "%description" + sed -n -e '/^Description:/,$ p' $i | tail +2 >>$SPEC + echo >>$SPEC "%files" + echo >>$SPEC "%defattr(-,root,root)" + /bin/ls $RPMFILES >>$SPEC + rpm -bb --target $ARCH-unknown-linux $SPEC + # rm $SPEC + elif [ -z "$IMAGEDIR" ] + then + #size=$(du -h -s $DATADIR | sed -e 's/[ ].*//') + if (which mkfs.jffs2 >/dev/null 2>&1); then + size=$(mkfs.jffs2 -r $DATADIR | wc -c) + fi + if ! (cat $i|grep -q ^Package:); then + echo "Package: $packagename" >$CTRLDIR/control + fi + if [ ! -z "$size" ]; then + echo "Installed-Size: $size" >>$CTRLDIR/control + else + if [ -z "$SIZEWARNED" ] + then + echo "Warning, no mkfs.jffs2 found, unable to set Installed-Size." + SIZEWARNED=1 + fi + fi + echo "Architecture: $ARCH" >>$CTRLDIR/control + echo "Version: $version" >>$CTRLDIR/control + [ ! -z "$depends" ] && echo "Depends: $depends" >>$CTRLDIR/control + [ ! -z "$provides" ] && echo "Provides: $provides" >>$CTRLDIR/control + [ ! -z "$conflicts" ] && echo "Conflicts: $conflicts" >>$CTRLDIR/control + egrep -v "^(Files|Version|Depends|Provides|Conflicts|Architecture):" >>$CTRLDIR/control $i + [ -n "$classicopts" ] && echo "$DEB_VERSION" >$TDIR/debian-binary + base=${i%.control} + scripts="preinst postinst prerm postrm" + for pf in $scripts + do + if [ -e ${base}.$pf ] + then + cp ${base}.$pf $CTRLDIR/$pf + chmod 755 $CTRLDIR/$pf + fi + done + cd $ORIGDIR; $OPIEDIR/scripts/ipkg-build $classicopts -o root -g root $TDIR; cd $OPIEDIR; + RESULT=$package.ipk + if [ -n "$VERB" ] + then + echo >&2 "Built $RESULT ($size)" + fi + if [ -n "$LIST" ] + then + echo $RESULT + fi + fi + else + echo >&2 "Not building $package package" + fi +done +# clean up +rm -rf $TDIR |