示例#1
0
void Server :: buildLocalPackages( Server *local )
{
    Package *curr;
    QListIterator<Package> it( packageList );

    QList<Package> *locallist = &local->getPackageList();

    for ( ; it.current(); ++it )
    {
        curr = it.current();
        QString name = curr->getPackageName();

        // If the package name is an ipk name, then convert the filename to a package name
        if ( name.find( ".ipk" ) != -1 )
            name = Utils::getPackageNameFromIpkFilename( curr->getFilename() );

        if ( local )
        {
            Package *p = local->getPackage( name );
            curr->setLocalPackage( p );
            if ( p )
            {
                // Replace local version
                if ( curr->getVersion() > p->getVersion() )
                {
                    int pos = locallist->at();
                    locallist->remove( p );
                    locallist->insert( pos, curr );
                }

                // Set some default stuff like size and things
                if ( p->getInstalledVersion() == curr->getVersion() )
                {
                    p->setPackageSize( curr->getPackageSize() );
                    p->setSection( curr->getSection() );
                    p->setDescription( curr->getDescription() );
                }
            }

        }
        else
            curr->setLocalPackage( 0 );
    }

}