//this file is part of eMule
//Copyright (C)2002 Merkur ( merkur-@users.sourceforge.net / http://www.emule-project.net )
//
//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., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "stdafx.h"
#include <math.h>
#include <sys/stat.h>
#include <io.h>
#include <winioctl.h>
#ifdef _DEBUG
#include "DebugHelpers.h"
#endif
#include "emule.h"
#include "PartFile.h"
#include "UpDownClient.h"
#include "ED2KLink.h"
#include "Preview.h"
#include "ArchiveRecovery.h"
#include "SearchList.h"
#include "Kademlia/Kademlia/Kademlia.h"
#include "kademlia/kademlia/search.h"
#include "kademlia/kademlia/SearchManager.h"
#include "kademlia/utils/MiscUtils.h"
#include "kademlia/kademlia/prefs.h"
#include "DownloadQueue.h"
#include "IPFilter.h"
#include "MMServer.h"
#include "UploadQueue.h"
#include "OtherFunctions.h"
#include "Packets.h"
#include "Preferences.h"
#include "SafeFile.h"
#include "SharedFileList.h"
#include "ListenSocket.h"
#include "Sockets.h"
#include "Server.h"
#include "KnownFileList.h"
#ifndef _CONSOLE
#include "emuledlg.h"
#include "TransferWnd.h"
#include "TaskbarNotifier.h"
#endif
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
// Barry - use this constant for both places
#define PROGRESS_HEIGHT 3
CBarShader CPartFile::s_LoadBar(PROGRESS_HEIGHT); // Barry - was 5
CBarShader CPartFile::s_ChunkBar(16);
IMPLEMENT_DYNAMIC(CPartFile, CKnownFile)
CPartFile::CPartFile()
{
Init();
}
CPartFile::CPartFile(CSearchFile* searchresult)
{
Init();
md4cpy(m_abyFileHash, searchresult->GetFileHash());
for (int i = 0; i < searchresult->taglist.GetCount();i++){
const CTag* pTag = searchresult->taglist[i];
switch (pTag->tag.specialtag){
case FT_FILENAME:{
if (pTag->IsStr())
SetFileName(pTag->tag.stringvalue);
break;
}
case FT_FILESIZE:{
if (pTag->IsInt())
SetFileSize(pTag->tag.intvalue);
break;
}
default:{
bool bTagAdded = false;
if (pTag->tag.specialtag != 0 && pTag->tag.tagname == NULL && (pTag->IsStr() || pTag->IsInt()))
{
static const struct
{
uint8 nName;
uint8 nType;
} _aMetaTags[] =
{
{ FT_MEDIA_ARTIST, 2 },
{ FT_MEDIA_ALBUM, 2 },
{ FT_MEDIA_TITLE, 2 },
{ FT_MEDIA_LENGTH, 3 },
{ FT_MEDIA_BITRATE, 3 },
{ FT_MEDIA_CODEC, 2 },
{ FT_FILETYPE, 2 },
{ FT_FILEFORMAT, 2 }
};
for (int t = 0; t < ARRSIZE(_aMetaTags); t++)
{
if (pTag->tag.type == _aMetaTags[t].nType && pTag->tag.specialtag == _aMetaTags[t].nName)
{
// skip string tags with empty string values
if (pTag->IsStr() && (pTag->tag.stringvalue == NULL || pTag->tag.stringvalue[0] == '\0'))
break;
// skip integer tags with '0' values
if (pTag->IsInt() && pTag->tag.intvalue == 0)
break;
TRACE("CPartFile::CPartFile(CSearchFile*): added tag %s\n", pTag->GetFullInfo());
CTag* newtag = new CTag(pTag->tag);
taglist.Add(newtag);
bTagAdded = true;
break;
}
}
}
if (!bTagAdded)
TRACE("CPartFile::CPartFile(CSearchFile*): ignored tag %s\n", pTag->GetFullInfo());
}
}
}
CreatePartFile();
}
CPartFile::CPartFile(CString edonkeylink)
{
CED2KLink* pLink = 0;
try {
pLink = CED2KLink::CreateLinkFromUrl(edonkeylink);
_ASSERT( pLink != 0 );
CED2KFileLink* pFileLink = pLink->GetFileLink();
if (pFileLink==0)
throw GetResString(IDS_ERR_NOTAFILELINK);
InitializeFromLink(pFileLink);
} catch (CString error) {
char buffer[200];
sprintf(buffer,GetResString(IDS_ERR_INVALIDLINK),error.GetBuffer());
AddLogLine(true, GetResString(IDS_ERR_LINKERROR), buffer);
SetStatus(PS_ERROR);
}
delete pLink;
}
void CPartFile::InitializeFromLink(CED2KFileLink* fileLink)
{
Init();
try{
SetFileName(fileLink->GetName());
SetFileSize(fileLink->GetSize());
md4cpy(m_abyFileHash, fileLink->GetHashKey());
if (!theApp.downloadqueue->IsFileExisting(m_abyFileHash))
CreatePartFile();
else
SetStatus(PS_ERROR);
}
catch(CString error){
char buffer[200];
sprintf(buffer, GetResString(IDS_ERR_INVALIDLINK), error.GetBuffer());
AddLogLine(true, GetResString(IDS_ERR_LINKERROR), buffer);
SetStatus(PS_ERROR);
}
}
CPartFile::CPartFile(CED2KFileLink* fileLink)
{
InitializeFromLink(fileLink);
}
void CPartFile::Init(){
newdate = true;
lastsearchtime = 0;
lastsearchtimeKad = 0;
lastpurgetime = ::GetTickCount();
paused = false;
stopped= false;
status = PS_EMPTY;
insufficient = false;
m_bCompletionError = false;
transfered = 0;
m_iLastPausePurge = time(NULL);
m_AllocateThread=NULL;
if(thePrefs.GetNewAutoDown()){
m_iDownPriority = PR_HIGH;
m_bAutoDownPriority = true;
}
else{
m_iDownPriority = PR_NORMAL;
m_bAutoDownPriority = false;
}
srcarevisible = false;
memset(m_anStates,0,sizeof(m_anStates));
datarate = 0;
hashsetneeded = true;
count = 0;
percentcompleted = 0;
completedsize=0;
m_bPreviewing = false;
lastseencomplete = NULL;
availablePartsCount=0;
m_ClientSrcAnswered = 0;
m_LastNoNeededCheck = 0;
m_iRate = 0;
m_strComment = "";
m_nTotalBufferData = 0;
m_nLastBufferFlushTime = 0;
m_bRecoveringArchive = false;
m_iGainDueToCompression = 0;
m_iLostDueToCorruption = 0;
m_iTotalPacketsSavedDueToICH = 0;
hasRating = false;
hasComment = false;
hasBadRating= false;
m_category=0;
m_lastRefreshedDLDisplay = 0;
m_is_A4AF_auto=false;
m_bLocalSrcReqQueued = false;
memset(src_stats,0,sizeof(src_stats));
m_nCompleteSourcesTime = time(NULL);
m_nCompleteSourcesCount = 0;
m_nCompleteSourcesCountLo = 0;
m_nCompleteSourcesCountHi = 0;
m_dwFileAttributes = 0;
m_bDeleteAfterAlloc=false;
m_tActivated = 0;
m_nDlActiveTime = 0;
m_tLastModified = 0;
m_tCreated = 0;
}
CPartFile::~CPartFile()
{
// Barry - Ensure all buffered data is written
try{
if (m_AllocateThread != NULL){
HANDLE hThread = m_AllocateThread->m_hThread;
// 2 minutes to let the thread finish
if (WaitForSingleObject(hThread, 120000) == WAIT_TIMEOUT)
TerminateThread(hThread, 100);
}
if (m_hpartfile.m_hFile != INVALID_HANDLE_VALUE)
FlushBuffer(true);
}
catch(CFileException* e){
e->Delete();
}
if (m_hpartfile.m_hFile != INVALID_HANDLE_VALUE){
// commit file and directory entry
m_hpartfile.Close();
// Update met file (with current directory entry)
SavePartFile();
}
for (POSITION pos = gaplist.GetHeadPosition();pos != 0;)
delete gaplist.GetNext(pos);
pos = m_BufferedData_list.GetHeadPosition();
while (pos){
PartFileBufferedData *item = m_BufferedData_list.GetNext(pos);
delete[] item->data;
delete item;
}
}
#ifdef _DEBUG
void CPartFile::AssertValid() const
{
CKnownFile::AssertValid();
(void)lastsearchtime;
(void)lastsearchtimeKad;
srclist.AssertValid();
A4AFsrclist.AssertValid();
(void)lastseencomplete;
m_hpartfile.AssertValid();
m_FileCompleteMutex.AssertValid();
(void)src_stats;
CHECK_BOOL(m_bPreviewing);
CHECK_BOOL(m_bRecoveringArchive);
CHECK_BOOL(m_bLocalSrcReqQueued);
CHECK_BOOL(srcarevisible);
CHECK_BOOL(hashse
没有合适的资源?快使用搜索试试~ 我知道了~
emule电驴源码(VC)
共642个文件
h:229个
cpp:188个
ico:124个
4星 · 超过85%的资源 需积分: 9 39 下载量 28 浏览量
2009-07-07
15:38:08
上传
评论
收藏 3.22MB RAR 举报
温馨提示
开源下载软件emule的源代码,可用VC编译
资源推荐
资源详情
资源评论
收起资源包目录
emule电驴源码(VC) (642个子文件)
inetdownload.avi 11KB
TRAYBUTTON_LUNA_HOMESTEAD.BMP 11KB
TRAYBUTTON_LUNA_METALLIC.BMP 11KB
TRAYBUTTON_LUNA_BLUE.BMP 11KB
down.bmp 230B
up.bmp 230B
down2x.bmp 230B
up2x.bmp 230B
PartFile.cpp 134KB
StatisticsDlg.cpp 131KB
Preferences.cpp 117KB
WebServer.cpp 101KB
TreeOptionsCtrl.cpp 92KB
DownloadListCtrl.cpp 79KB
emuleDlg.cpp 71KB
ListenSocket.cpp 65KB
BaseClient.cpp 61KB
FileInfoDialog.cpp 60KB
otherfunctions.cpp 59KB
BtnST.cpp 57KB
Scanner.cpp 57KB
IrcWnd.cpp 53KB
DownloadQueue.cpp 53KB
KnownFile.cpp 50KB
SearchListCtrl.cpp 48KB
DownloadClient.cpp 45KB
SearchResultsWnd.cpp 42KB
HyperTextCtrl.cpp 41KB
MuleListCtrl.cpp 41KB
SharedFileList.cpp 39KB
AsyncProxySocketLayer.cpp 37KB
SharedFilesCtrl.cpp 36KB
parser.cpp 36KB
emule.cpp 35KB
EMSocket.cpp 35KB
KademliaUDPListener.cpp 34KB
ximatran.cpp 33KB
LastCommonRouteFinder.cpp 31KB
AsyncSocketEx.cpp 30KB
TransferWnd.cpp 30KB
OScopeCtrl.cpp 30KB
Indexed.cpp 30KB
ColourPopup.cpp 30KB
ArchiveRecovery.cpp 29KB
SearchParamsWnd.cpp 29KB
HttpDownloadDlg.cpp 29KB
ServerListCtrl.cpp 29KB
ServerWnd.cpp 29KB
UploadClient.cpp 28KB
TaskbarNotifier.cpp 27KB
SearchList.cpp 27KB
PPgTweaks.cpp 26KB
UploadQueue.cpp 26KB
MuleToolBarCtrl.cpp 24KB
ListBoxST.cpp 24KB
QueueListCtrl.cpp 23KB
ini2.cpp 23KB
Search.cpp 23KB
ListCtrlX.cpp 23KB
ServerList.cpp 23KB
IrcMain.cpp 22KB
FileDetailDialog.cpp 22KB
ClientListCtrl.cpp 22KB
UploadListCtrl.cpp 21KB
MMServer.cpp 21KB
StatisticsTree.cpp 21KB
ClientCredits.cpp 21KB
RoutingZone.cpp 20KB
ServerSocket.cpp 20KB
UDPSocket.cpp 20KB
UploadBandwidthThrottler.cpp 19KB
ximaenc.cpp 19KB
PartFileConvert.cpp 19KB
ximawnd.cpp 19KB
TreeOptionsCtrlEx.cpp 18KB
sockets.cpp 18KB
ChatSelector.cpp 17KB
CreditsThread.cpp 17KB
DropTarget.cpp 17KB
HTRichEditCtrl.cpp 17KB
PShtWiz1.cpp 17KB
ClientList.cpp 16KB
AsyncSocketExLayer.cpp 16KB
DirectoryTreeCtrl.cpp 15KB
VisualStylesXP.cpp 15KB
DialogMinTrayBtn.cpp 15KB
SearchManager.cpp 15KB
ximapng.cpp 15KB
ximapal.cpp 15KB
PPgConnection.cpp 15KB
SecRunAsUser.cpp 15KB
MuleSystrayDlg.cpp 14KB
PPgIrc.cpp 14KB
LogEditCtrl.cpp 14KB
WebSocket.cpp 14KB
ProgressCtrlX.cpp 13KB
PPgScheduler.cpp 13KB
ColorButton.cpp 13KB
packets.cpp 13KB
ClientUDPSocket.cpp 13KB
共 642 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
- xiaowei_6756589132012-10-16很不错。我用vs2005打不开。。。
- tingfeng20052012-09-19很不错。不过版本比较高,我用vs2005打不开。。。
- sunboy14232015-01-14代码很好,VS2008就可以打开编译,很有学习的价值!
kiowar
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- sony 索尼IMX334摄像头模组电路板AD版硬件PCB图(6层板).zip
- 基于flask和echarts融合交易策略的bitfinex可视化微服务.zip
- 包含了wvp-assist.tar wvp-talk.tar zlmediakit.tar .
- 3r4efgh53wgrf43tw
- 2024新版Java基础从入门到精通全套视频+资料下载
- Spring AI大模型视频教程+ChatGPT视频教程+OpenAI大模型视频教程(资料+视频教程)
- ABB工业机器人教程PDF版本
- 123321123323211
- yolov8实战第八天-pyqt5-yolov8实现车牌识别系统(论文(8700+字+数据集+完整部署代码+代码使用说明)
- 三相桥式全桥整流电路MATALB Simulink仿真文件
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功