Exemplo n.º 1
0
/**
  * When we ask to the fileManager some hashes for a given file this
  * slot will be called each time a new hash is available.
  */
void Socket::nextAskedHash(Common::Hash hash)
{
   Protos::Common::Hash hashProto;
   hashProto.set_hash(hash.getData(), Common::Hash::HASH_SIZE);
   this->send(Common::MessageHeader::CORE_HASH, hashProto);

   if (--this->nbHash == 0)
   {
      this->currentHashesResult.clear();
      this->finished();
   }
}
Exemplo n.º 2
0
Arquivo: File.cpp Projeto: Ummon/D-LAN
void File::populateEntry(Protos::Common::Entry* entry, bool setSharedDir, int maxHashes) const
{
   QMutexLocker locker(&this->mutex);

   Entry::populateEntry(entry, setSharedDir);

   entry->set_type(Protos::Common::Entry_Type_FILE);

   entry->clear_chunk();

   int nb = 0;
   for (QVectorIterator<QSharedPointer<Chunk>> i(this->chunks); i.hasNext();)
   {
      Protos::Common::Hash* protoHash = entry->add_chunk();

      Common::Hash hash = i.next()->getHash();
      if (!hash.isNull() && ++nb <= maxHashes)
         protoHash->set_hash(hash.getData(), Common::Hash::HASH_SIZE);
   }
}