~ubuntu-branches/debian/squeeze/synaptic/squeeze

« back to all changes in this revision

Viewing changes to common/rpackagefilter.cc

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2008-06-18 10:17:31 UTC
  • Revision ID: james.westby@ubuntu.com-20080618101731-fb77n5hy28hcq3g3
Tags: 0.62.1
* po/es.po:
  - updated Spanish translation (thanks to
     Francisco Javier Cuadrado)
* debian/control:
  - added "menu" to the recommends (closes: #478250)
* gtk/glade/window_main.glade:
  - make the main vpane shinkable
* gtk/rgmainwindow.cc:
  - do not loose the keyboard focus after a package 
    action in the listview
* debian/control:
  - switch bzr branch to bzr.debian.org

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
   N_("Suggests"),
54
54
   N_("ReverseDepends"),
55
55
   N_("Origin"),
 
56
   N_("Component"),
56
57
   NULL
57
58
};
58
59
 
62
63
const char *RPFSection = _("Section");
63
64
const char *RPFPriority = _("Priority");
64
65
const char *RPFReducedView = _("ReducedView");
 
66
const char *RPFFile = _("File");
65
67
 
66
68
int RSectionPackageFilter::count()
67
69
{
304
306
   return found;
305
307
}
306
308
 
 
309
bool RPatternPackageFilter::filterComponent(Pattern pat, RPackage *pkg)
 
310
{
 
311
   bool found = false;
 
312
   string origin;
 
313
   origin = pkg->component();
 
314
 
 
315
   if (pat.regexps.size() == 0) {
 
316
      return true;
 
317
   }
 
318
   
 
319
   if(regexec(pat.regexps[0],origin.c_str(), 0, NULL, 0) == 0) {
 
320
      found = true;
 
321
   } 
 
322
 
 
323
   return found;
 
324
}
 
325
 
307
326
bool RPatternPackageFilter::filter(RPackage *pkg)
308
327
{
309
328
   bool found;
355
374
      case Origin:
356
375
         found = filterOrigin(pat, pkg);
357
376
         break;
 
377
      case Component:
 
378
         found = filterComponent(pat, pkg);
 
379
         break;
358
380
      default:
359
381
         cerr << "unknown pattern package filter (shouldn't happen) " << endl;
360
382
      }
590
612
         return true;
591
613
   }
592
614
 
 
615
   if (_status & AutoInstalled) {
 
616
      if (flags & RPackage::FIsAuto)
 
617
         return true;
 
618
   }
 
619
 
 
620
   if (_status & Garbage) {
 
621
      if (flags & RPackage::FIsGarbage)
 
622
         return true;
 
623
   }
 
624
 
 
625
   if (_status & NowPolicyBroken) {
 
626
      if (!(flags & RPackage::FInstalled))
 
627
      {
 
628
         pkgCache::DepIterator D;
 
629
         bool inOr = false;
 
630
         // FIXME: or-dependencies are not considered properly
 
631
         for (D = pkg->package()->RevDependsList(); D.end() == false; D++)
 
632
         {          
 
633
            if ((D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or)
 
634
               inOr = true;
 
635
            else
 
636
               inOr = false;
 
637
            pkgCache::PkgIterator parent = D.ParentPkg();
 
638
            if(parent->CurrentVer != 0)
 
639
            {
 
640
               RPackage *p = pkg->_lister->getPackage(parent);
 
641
               if(p != NULL)
 
642
                  if(p->getFlags() & RPackage::FNowPolicyBroken)
 
643
                     return true;
 
644
            }
 
645
         }
 
646
      }
 
647
   }
 
648
 
593
649
   return false;
594
650
}
595
651
 
722
778
   return true;
723
779
}
724
780
 
 
781
bool RFilePackageFilter::addFile(string file)
 
782
{
 
783
  char str[255];
 
784
  filename = file;
 
785
  ifstream in(file.c_str());
 
786
  if(!in) 
 
787
     return false;
 
788
  while(in) {
 
789
     in.getline(str, 255);  
 
790
     pkgs.insert(pkgs.begin(), string(str));
 
791
  }
 
792
  in.close();
 
793
}
 
794
 
 
795
bool RFilePackageFilter::filter(RPackage *pkg)
 
796
{
 
797
   if (pkgs.size() == 0)
 
798
      return true;
 
799
   return pkgs.find(pkg->name()) != pkgs.end();
 
800
}
 
801
 
 
802
bool RFilePackageFilter::write(ofstream &out, string pad)
 
803
{
 
804
   out << pad + "file {" << endl;
 
805
   out << pad + "  \"" << filename << "\"; " << endl;
 
806
   out << pad + "};" << endl;
 
807
   return true;
 
808
}
 
809
 
 
810
bool RFilePackageFilter::read(Configuration &conf, string key)
 
811
{
 
812
   const Configuration::Item *top;
 
813
 
 
814
   reset();
 
815
 
 
816
   top = conf.Tree(string(key + "::file").c_str());
 
817
   if (top != NULL) {
 
818
      for (top = top->Child; top != NULL; top = top->Next)
 
819
         filename = top->Value;
 
820
   }
 
821
 
 
822
   return true;
 
823
}
725
824
 
726
825
bool RFilter::apply(RPackage *package)
727
826
{
740
839
   if (!reducedview.filter(package))
741
840
      return false;
742
841
 
 
842
   if (!file.filter(package))
 
843
      return false;
 
844
 
743
845
   return true;
744
846
}
745
847
 
835
937
   return res;
836
938
}
837
939
 
 
940
 
 
941
 
838
942
// vim:sts=3:sw=3