[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:41:58
Message-ID: 200407121641.58573.tweakBSD () gmx ! net
[Download RAW message or body]

Am Montag, 12. Juli 2004 16:32 schrieb Michael Pyne:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Monday 12 July 2004 10:11, Mario wrote:
> >  m_lock.lock();
> >
> >     proc->start();
> >     // then append the data
>
> You need to add another m_lock.lock() command here.
>
> >     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;
>
> Regards,
>  - Michael Pyne
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.4 (GNU/Linux)
>
> iD8DBQFA8qEZqjQYp5Omm0oRAoh0AKCZTXVhRSsPN0cDwqsTapC3u97vggCfZ332
> x60orGtoGG1+AfBV/Ug0QGs=
> =6yDX
> -----END PGP SIGNATURE-----
>
> >> Visit http://mail.kde.> >> org/mailman/listinfo/kde-devel#unsub to 
> >> unsubscribe <<

Ok I forgot it but now I have added it but the same problem as before, 
package1 has meta-info for package2 and so on and sometimes the Item
'Files' has a value of a package I never right-clicked !
I will get a headache soon :-(

Implementation now:

#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();    
    
m_lock.lock();
    
    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