📄 uploading.h
字号:
/*
This file is part of KCeasy (http://www.kceasy.com)
Copyright (C) 2002-2004 Markus Kern <mkern@kceasy.com>
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.
*/
//---------------------------------------------------------------------------
#ifndef UploadingH
#define UploadingH
#include "istring.h"
#include "CriticalSection.h"
#include "Transfer.h"
#include "User.h"
#include "Engine.h"
//---------------------------------------------------------------------------
namespace KCeasyEngine {
class TUlSource
{
friend class TUpload;
public:
typedef enum { New, Active, Waiting, Timeout, Cancelled, Complete, QueuedRemote, QueuedLocal, Unused, Paused } TUlSourceState;
void* GetUData() { return UData; }
void SetUData(void* NUData) { UData = NUData; }
unsigned int GetTimeLeft();
string SourceId;
TUser* GetUser() { return User; }
string Network;
TUlSourceState State;
string ProtoState; // free form string provided by respective gift plugin
unsigned int Start;
unsigned int Size;
unsigned int Transmitted;
TThroughput Throughput;
private:
TUlSource();
~TUlSource();
bool SetStateStr(const string& StateStr);
TUser* User;
void* UData;
};
class TUpload
{
friend class TEngine;
public:
typedef enum { New, Queued, Uploading, Completed, Cancelled } TUploadState;
bool Cancel();
unsigned int GetGiftId() { return GiftId; }
TUploadState GetState() { return State; }
bool IsSpecial() { return Special; }
const THashSet* GetHashes() { return Hashes; }
const string& GetNetwork() { return Network; }
const string& GetFileName() { return FileName; }
const string& GetPath() { return Path; }
unsigned int GetFileSize() { return FileSize; }
unsigned int GetTransmitted() { return Transmitted; }
unsigned int GetThroughput() { return Throughput.GetBps(); }
unsigned int GetTimeLeft() { return GetThroughput() ? ((FileSize - Transmitted) / GetThroughput()) : 0; }
TMetaData& GetMetaData() { return MetaData; }
const string& GetMimeType() { return MimeType; }
TFileType GetFileType() { return FileTypeFromMime(MimeType); }
TUlSource* GetSource() { return Source; }
void* GetUData() { return UData; }
void SetUData(void* NUData) { UData = NUData; }
private:
TUpload(TEngine* ParentEngine);
~TUpload();
bool ProcessAddUpload(TGiftCommand* Cmd);
bool ProcessDelUpload(TGiftCommand* Cmd);
bool ProcessChgUpload(TGiftCommand* Cmd);
TEngine* Engine;
void* UData;
unsigned int GiftId;
TUploadState State;
bool Special; // true if upload of non-shared file, e.g. the nodepage
THashSet* Hashes;
string Network;
string FileName; // save file name
string Path; // full path of uploaded file
unsigned int FileSize;
unsigned int Transmitted;
TThroughput Throughput;
TMetaData MetaData;
string MimeType;
TUlSource* Source;
};
} // namespace KCeasyEngine
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -