Exemple #1
0
bool entryLessThan(const Protos::Common::Entry& e1, const Protos::Common::Entry& e2)
{
   std::string s1;
   std::string s2;

   if (e1.has_shared_dir() && e2.has_shared_dir())
   {
      s1 = e1.shared_dir().shared_name();
      s2 = e2.shared_dir().shared_name();
      std::transform(s1.begin(), s1.end(), s1.begin(), tolower);
      std::transform(s2.begin(), s2.end(), s2.begin(), tolower);
   }

   if (s1 == s2)
   {
      std::string p1 = e1.path();
      std::string p2 = e2.path();
      std::transform(p1.begin(), p1.end(), p1.begin(), tolower);
      std::transform(p2.begin(), p2.end(), p2.begin(), tolower);

      if (p1 == p2)
      {
         std::string n1 = e1.name();
         std::string n2 = e2.name();
         std::transform(n1.begin(), n1.end(), n1.begin(), tolower);
         std::transform(n2.begin(), n2.end(), n2.begin(), tolower);
         return n1 < n2;
      }
      else
         return p1 < p2;
   }
   else
      return s1 < s2;
}
Exemple #2
0
/**
  * To know if a given entry is already in queue. It depends of (shared dir id, name, path).
  */
bool DownloadQueue::isEntryAlreadyQueued(const Protos::Common::Entry& localEntry)
{
   QMap<std::string, Download*>::const_iterator i = this->downloadsIndexedByName.constFind(localEntry.name());

   while (i != this->downloadsIndexedByName.constEnd() && i.key() == localEntry.name())
   {
      if (
         i.value()->getLocalEntry().path() == localEntry.path() &&
         (!localEntry.has_shared_dir() || i.value()->getLocalEntry().shared_dir().id().hash() == localEntry.shared_dir().id().hash())
      )
         return true;

       ++i;
   }

   return false;
}