[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: KFile plugin problem !!
From:       Mario <tweakBSD () gmx ! net>
Date:       2004-07-12 14:11:35
Message-ID: 200407121611.35438.tweakBSD () gmx ! net
[Download RAW message or body]

Am Montag, 12. Juli 2004 16:02 schrieb Michael Pyne:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Monday 12 July 2004 09:55, Mario wrote:
> > I have tried to figure it in but now I have following compile errors !
> >
> > request for member `lock' in `
> >    this->tweakBSDpkgPlugin::m_lock', which is of non-aggregate type
> > `QMutex*'
> >
> > should I change m_lock.lock() to m_lock->lock() ???
>
> Well yes.  My example assumed the QMutex wasn't a pointer.  Since you're
> using a pointer, make sure you initialize the m_lock in your constructor by
> calling new QMutex.
>
> Regards,
>  - Michael Pyne
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.4 (GNU/Linux)
>
> iD8DBQFA8poHqjQYp5Omm0oRAn4aAJ9mVKR0fsqRy3sfKeBZ6G5K1cRdCACaAnq1
> H91F/HZNRG7JiYok0gCrZcY=
> =e+j3
> -----END PGP SIGNATURE-----
>
> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
> >> unsubscribe <<

Ok I figured it in but I have the same problems as without QMutex, the new 
code follows perhaps you see the problem

#ifndef __tweakBSD_pkg_H
#define __tweakBSD_pkg_H

#include <kfilemetainfo.h>
#include <qprocess.h>
#include <qmutex.h>


class QTextView;
class QString;

class tweakBSDpkgPlugin: public KFilePlugin
{
    Q_OBJECT

public:
    tweakBSDpkgPlugin(QObject *parent, const char *name, const QStringList& 
args);
    virtual bool readInfo(KFileMetaInfo& info, uint what);
    QTextView *output;
    QProcess *proc;
    
public slots:
    void readfrom_pkginfo();
private:
    QString getComment(QString path);
    QString getDescription();
    QString getFiles();
protected:
    QMutex m_lock;
};

#endif

#include "tweakBSD_pkg.h"

#include <kgenericfactory.h>
#include <kdebug.h>
#include <qstring.h>
#include <qtextview.h>

#include <qregexp.h>


typedef KGenericFactory<tweakBSDpkgPlugin> tweakBSDpkgFactory;

K_EXPORT_COMPONENT_FACTORY(tweakBSD_pkg, tweakBSDpkgFactory("tweakBSD_pkg"))

tweakBSDpkgPlugin::tweakBSDpkgPlugin(QObject *parent, const char *name,
        const QStringList &args) : KFilePlugin(parent, name, args)
{
    //m_lock = new QMutex ( false );
    
         output = new QTextView(0, "textview");
        proc = new QProcess( 0 );
         connect( proc, SIGNAL(readyReadStdout()),
                this, SLOT(readfrom_pkginfo()) );


    KFileMimeTypeInfo* info = addMimeTypeInfo("application/pkg");

    KFileMimeTypeInfo::GroupInfo* group =
            addGroupInfo(info, "General", i18n("General"));

    KFileMimeTypeInfo::ItemInfo* item;
    item = addItemInfo(group, "Name", i18n("Name"), QVariant::String);
    setAttributes(item, KFileMimeTypeInfo::MultiLine);
    item = addItemInfo(group, "Comment", i18n("Comment"), QVariant::String);
    setAttributes(item, KFileMimeTypeInfo::MultiLine);
    item = addItemInfo(group, "Description", i18n("Description"), 
QVariant::String);
    setAttributes(item, KFileMimeTypeInfo::MultiLine );
    item = addItemInfo(group, "Files", i18n("Files"), QVariant::String);
    setAttributes(item, KFileMimeTypeInfo::MultiLine);
}



void tweakBSDpkgPlugin::readfrom_pkginfo() {


output->append( proc->readStdout() );
m_lock.unlock();
}


QString tweakBSDpkgPlugin::getFiles() {

QRegExp rx( "*Files:\n", false, true );
QRegExp rx2( "THEEND", false, true );


QString out = output->text();
out.append( "THEEND" );
int j = out.find(rx2);


QString str = out.left( j );
str.replace(rx, "");
str.replace("\n\n", "");
return str;

}

QString tweakBSDpkgPlugin::getComment(QString path) {


      
QRegExp rx( "Information*Comment:\n", false, true );
QRegExp rx2( "Description:", false, true );


QString out = output->text();
int j = out.find(rx2);


QString str = out.left( j );
str.replace(rx, "");
str.replace("\n\n", "");
return str;

}

QString tweakBSDpkgPlugin::getDescription() {

     
                         
QRegExp rx( "*Description:\n", false, true );
QRegExp rx2( "Files:", false, true );


QString out = output->text();
int j = out.find(rx2);


QString str = out.left( j );
str.replace(rx, "");
str.replace("\n\n", "");
return str;

}


bool tweakBSDpkgPlugin::readInfo(KFileMetaInfo& info, uint)
{
         
       proc->addArgument( "pkg_info" );
      proc->addArgument( "-cdL" );
       proc->addArgument( info.path() );
           

 m_lock.lock();

    proc->start();    
    // then append the data

    
    KFileMetaInfoGroup group = appendGroup(info, "General");
     appendItem(group, "Name", info.path() );
      appendItem(group, "Comment", getComment(info.path()) );
       appendItem(group, "Description", getDescription() ); 
        appendItem(group, "Files", getFiles());
          m_lock.unlock();
	return true;

    
}

#include "tweakBSD_pkg.moc"
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic