Пример #1
0
void Metalink4Writer::write_piece_hash(const MetalinkFile& file)
{
    if(file.get_piece_hashes().empty()) return;
    if(file.get_piece_hash_type().empty()) return;
    start(wxT("pieces"));
    add_attr(wxT("length"),
             wxString::Format(wxT("%lu"), file.get_piece_length()));
    add_attr(wxT("type"), file.get_piece_hash_type());
    close_start();
    const std::vector<wxString>& hashes = file.get_piece_hashes();
    for(std::vector<wxString>::const_iterator i = hashes.begin(),
            eoi = hashes.end(); i != eoi; ++i) {
        add_element(wxT("hash"), *i);
    }
    end(wxT("pieces"));
}
Пример #2
0
void Metalink3Writer::write_piece_hashes(const MetalinkFile& file)
{
    if(!has_piece_hashes(file)) return;
    start(wxT("pieces"));
    add_attr(wxT("length"),
             wxString::Format(wxT("%lu"), file.get_piece_length()));
    add_attr(wxT("type"), file.get_piece_hash_type());
    close_start();
    const std::vector<wxString>& hashes = file.get_piece_hashes();
    long index = 0;
    for(std::vector<wxString>::const_iterator i = hashes.begin(),
            eoi = hashes.end(); i != eoi; ++i) {
        start(wxT("hash"));
        add_attr(wxT("piece"), wxString::Format(wxT("%ld"), index));
        end(wxT("hash"), *i);
        index++;
    }
    end(wxT("pieces"));
}
Пример #3
0
void ChunkPanel::update()
{
    MetalinkFile file = editor_.get_file();
    long num = file.get_piece_hashes().size();
    if(num == 0) {
        label1_->SetLabel(wxT("This file has no chunk checksums."));
        btn_delete_->Enable(false);
    } else {
        wxString type = file.get_piece_hash_type();
        wxString msg;
        msg << wxT("This file has ") << num;
        msg << wxT(" chunk checksum");
        if(num > 1) {
            msg << wxT("s");
        }
        msg << wxT(" of type '") << type << wxT("'.");
        label1_->SetLabel(msg);
        btn_delete_->Enable(true);
    }
}
Пример #4
0
bool Metalink3Writer::has_piece_hashes(const MetalinkFile& file)
{
    if(file.get_piece_hashes().empty()) return false;
    if(file.get_piece_hash_type().empty()) return false;
    return true;
}