mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-15 10:54:22 -05:00
add/del
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2517 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0705d9dfc7
commit
ebcc7e4c1c
@ -1,71 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <QStringList>
|
||||
#include "RetroShareLinkAnalyzer.h"
|
||||
|
||||
const QString RetroShareLinkAnalyzer::HEADER_NAME = "retroshare://file|";
|
||||
|
||||
RetroShareLinkAnalyzer::RetroShareLinkAnalyzer (const QString & url)
|
||||
{
|
||||
this->url = url;
|
||||
}
|
||||
|
||||
void RetroShareLinkAnalyzer::setRetroShareLink (const QString & name, const QString & size, const QString & hash)
|
||||
{
|
||||
url.append(HEADER_NAME);
|
||||
url.append(name);
|
||||
url.append("|");
|
||||
url.append(size);
|
||||
url.append("|");
|
||||
url.append(hash);
|
||||
url.append("\n");
|
||||
}
|
||||
|
||||
bool RetroShareLinkAnalyzer::getFileInformation(QVector<RetroShareLinkData>& linkList)
|
||||
{
|
||||
if (!isValid ())
|
||||
return false;
|
||||
|
||||
QStringList urlList = url.split ("\n");
|
||||
|
||||
for (int i = 0, n = urlList.size(); i < n; ++i)
|
||||
{
|
||||
if (urlList[i].isEmpty ())
|
||||
continue;
|
||||
|
||||
QStringList list = urlList[i].split ("|");
|
||||
linkList.push_back (RetroShareLinkData (list.at (NAME_), list.at (SIZE_), list.at (HASH_)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// easy check for now.
|
||||
bool RetroShareLinkAnalyzer::isValid () const
|
||||
{
|
||||
QStringList urlList = url.split ("\n");
|
||||
|
||||
if (urlList.isEmpty ())
|
||||
return false;
|
||||
|
||||
QStringList list = urlList[0].split ("|");
|
||||
|
||||
return (list.size() % NUMBER_OF_PARTITIONS == 0);
|
||||
}
|
||||
|
@ -1,76 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef RETROSHARE_LINK_ANALYZER
|
||||
#define RETROSHARE_LINK_ANALYZER
|
||||
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
struct RetroShareLinkData
|
||||
{
|
||||
public:
|
||||
RetroShareLinkData () {}
|
||||
RetroShareLinkData (const QString& n, const QString& s, const QString& h)
|
||||
: name (n)
|
||||
, size (s)
|
||||
, hash (h)
|
||||
{}
|
||||
|
||||
const QString& getName () const {return name;}
|
||||
const QString& getSize () const {return size;}
|
||||
const QString& getHash () const {return hash;}
|
||||
|
||||
private:
|
||||
QString name;
|
||||
QString size;
|
||||
QString hash;
|
||||
};
|
||||
|
||||
class RetroShareLinkAnalyzer
|
||||
{
|
||||
public:
|
||||
RetroShareLinkAnalyzer(const QString& url = "");
|
||||
|
||||
void setRetroShareLink(const QString& name, const QString& size, const QString& hash);
|
||||
void setRetroShareLink(const QString& url) {this->url = url;}
|
||||
const QString& getRetroShareLink() const {return url;}
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
// Get file name, size, hash from kommute link list.
|
||||
// Return true if kommute link is valid, otherwise return false.
|
||||
bool getFileInformation(QVector<RetroShareLinkData>& linkList);
|
||||
|
||||
private:
|
||||
enum PARTITION
|
||||
{
|
||||
HEADER_,
|
||||
NAME_,
|
||||
SIZE_,
|
||||
HASH_,
|
||||
NUMBER_OF_PARTITIONS
|
||||
};
|
||||
|
||||
static const QString HEADER_NAME;
|
||||
|
||||
QString url;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user