65 lines
2.4 KiB
C++
65 lines
2.4 KiB
C++
/***************************************************************************
|
|
* Copyright (C) 2008 by Oliver Groß *
|
|
* z.o.gross@gmx.de *
|
|
* *
|
|
* 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 <QList>
|
|
#include <QHash>
|
|
|
|
#ifndef QFTRANS_COMMON_H
|
|
#define QFTRANS_COMMON_H
|
|
|
|
#define RAWPACKET_SIZE 9
|
|
#define DATA_BLOCK_SIZE (64*1024)
|
|
#define DESCRIPTOR_STRING "QFTH"
|
|
|
|
namespace qftrans {
|
|
enum TransferStatus {TS_SUSPENDED = 0, TS_PENDING = 1, TS_ANNOUNCING = 2, TS_WAITING = 3, TS_TRANSFERING = 4, TS_CLOSING = 5, TS_FINISHED = 6};
|
|
enum HeaderType {HT_ANNOUNCE = 0, HT_DATA = 1, HT_CLOSE = 2, HT_ACK = 3, HT_CANCEL = 4};
|
|
|
|
struct TransferData {
|
|
QString fileDir;
|
|
QString fileName;
|
|
TransferStatus status;
|
|
bool localFile;
|
|
qint64 size;
|
|
qint64 transfered;
|
|
HeaderType lastHeader;
|
|
quint32 id;
|
|
};
|
|
|
|
struct TransferHeader {
|
|
char descriptor[5];
|
|
quint8 type;
|
|
quint32 id;
|
|
quint32 length;
|
|
TransferHeader() {
|
|
descriptor[0] = 'Q';
|
|
descriptor[1] = 'F';
|
|
descriptor[2] = 'T';
|
|
descriptor[3] = 'H';
|
|
descriptor[4] = 0;
|
|
}
|
|
};
|
|
|
|
typedef QList<TransferData *> QTransferDataList;
|
|
typedef QHash<quint32, TransferData *> QTransferDataHash;
|
|
typedef QHash<TransferData *, quint32> QTransferIdHash;
|
|
}
|
|
|
|
#endif
|