//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.

#pragma once

#ifndef __AFXWIN_H__
	#error include 'stdafx.h' before including this file for PCH
#endif

#include "resource.h"
#include "emuleDlg.h"
#include "knownfilelist.h"
#include "preferences.h"
#include "sockets.h"
#include "serverlist.h"
#include "sharedfilelist.h"
#include "searchlist.h"
#include "listensocket.h"
#include "uploadqueue.h"
#include "downloadqueue.h"
#include "clientlist.h"
#include "clientcredits.h"
#include "friendlist.h"
#include "clientudpsocket.h"
#include "ping.h"
#include <afxmt.h>

class CSearchList;
class CUploadQueue;
class CListenSocket;
class CDownloadQueue;

class CemuleApp : public CWinApp
{
public:

	CemuleApp();
	CemuleDlg*			emuledlg;
	CClientList*		clientlist;
	CKnownFileList*		knownfiles;
	CPreferences*		glob_prefs;
	CServerConnect*		serverconnect;
	CServerList*		serverlist;	
	CSharedFileList*	sharedfiles;
	CSearchList*		searchlist;
	CListenSocket*		listensocket;
	CUploadQueue*		uploadqueue;
	CDownloadQueue*		downloadqueue;
	CClientCreditsList*	clientcredits;
	CFriendList*		friendlist;
	CClientUDPSocket*	clientudp;
	CMutex				hashing_mut;
	virtual BOOL		InitInstance();
	CString*			pendinglink;
	tagCOPYDATASTRUCT  sendstruct; //added by Cax2 28/10/02 
	CPingThread*		Dynup;		// Added by Tarod [Hardware]

	uint64				stat_sessionReceivedBytes;
	uint64				stat_sessionSentBytes;
	uint16				stat_reconnects;
	DWORD				stat_transferStarttime;
	DWORD				stat_serverConnectTime;
	HANDLE				m_hMutexOneInstance;
// Implementierung
	// ed2k link functions
	CString		StripInvalidFilenameChars(CString strText, bool bKeepSpaces = true);
	CString		CreateED2kLink( CAbstractFile* f );
	CString		CreateED2kSourceLink( CAbstractFile* f );
	CString		CreateHTMLED2kLink( CAbstractFile* f );
	bool		CopyTextToClipboard( CString strText );
	void		OnlineSig(); 
	void		UpdateReceivedBytes(int32 bytesToAdd);
	void		UpdateSentBytes(int32 bytesToAdd);
	
	// Added by Tarod -new functions
	void		Action(CKnownFile* knownfile, CPartFile* partfile, CSearchFile* searchfile); // Jigle Fake checking

	DECLARE_MESSAGE_MAP()
protected:
	bool ProcessCommandline();
	void SetTimeOnTransfer();
	static BOOL CALLBACK SearchEmuleWindow(HWND hWnd, LPARAM lParam);
	void OnHelp();

};
extern CemuleApp theApp;