Exemplo n.º 1
0
int __cdecl CMsnProto::FileCancel(HANDLE hContact, HANDLE hTransfer)
{
	filetransfer* ft = (filetransfer*)hTransfer;

	if (!msnLoggedIn || !p2p_sessionRegistered(ft))
		return 0;

	if  (!(ft->std.flags & PFTS_SENDING) && ft->fileId == -1) 
	{
		if (ft->p2p_appID != 0)
			p2p_sendStatus(ft, 603);
		else
			msnftp_sendAcceptReject (ft, false);
	}
	else 
	{
		ft->bCanceled = true;
		if (ft->p2p_appID != 0)
		{
			p2p_sendCancel(ft);
			if  (!(ft->std.flags & PFTS_SENDING) && ft->p2p_isV2)
				p2p_sessionComplete(ft);
		}
	}

	ft->std.ptszFiles = NULL;
	ft->std.totalFiles = 0;
	return 0;
}
Exemplo n.º 2
0
// MsnFileDeny - rejects the file transfer request
int __cdecl CMsnProto::FileDeny(MCONTACT, HANDLE hTransfer, const TCHAR* /*szReason*/)
{
	filetransfer* ft = (filetransfer*)hTransfer;

	if (ft->tType == SERVER_HTTP) delete ft;
#ifdef OBSOLETE
	else {
		if (!msnLoggedIn || !p2p_sessionRegistered(ft))
			return 1;

		if (!(ft->std.flags & PFTS_SENDING) && ft->fileId == -1) {
			if (ft->p2p_appID != 0)
				p2p_sendStatus(ft, 603);
			else
				msnftp_sendAcceptReject(ft, false);
		}
		else {
			ft->bCanceled = true;
			if (ft->p2p_appID != 0)
				p2p_sendCancel(ft);
		}
	}
#endif

	return 0;
}
Exemplo n.º 3
0
int __cdecl CMsnProto::FileDeny(HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* /*szReason*/)
{
	filetransfer* ft = (filetransfer*)hTransfer;

	if (!msnLoggedIn || !p2p_sessionRegistered(ft))
		return 1;

	if (!(ft->std.flags & PFTS_SENDING) && ft->fileId == -1) 
	{
		if (ft->p2p_appID != 0)
			p2p_sendStatus(ft, 603);
		else
			msnftp_sendAcceptReject (ft, false);
	}
	else 
	{
		ft->bCanceled = true;
		if (ft->p2p_appID != 0)
			p2p_sendCancel(ft);
	}

	return 0;
}
Exemplo n.º 4
0
int __cdecl CMsnProto::FileResume(HANDLE hTransfer, int* action, const PROTOCHAR** szFilename)
{
	filetransfer* ft = (filetransfer*)hTransfer;

	if (!msnLoggedIn || !p2p_sessionRegistered(ft))
		return 1;

	switch (*action) 
	{
	case FILERESUME_SKIP:
		if (ft->p2p_appID != 0)
			p2p_sendStatus(ft, 603);
		else
			msnftp_sendAcceptReject (ft, false);
		break;

	case FILERESUME_RENAME:
		replaceStr(ft->std.tszCurrentFile, *szFilename);

	default:
		bool fcrt = ft->create() != -1;
		if (ft->p2p_appID != 0) 
		{
			if (fcrt)
				p2p_sendFeedStart(ft);

			p2p_sendStatus(ft, fcrt ? 200 : 603);
		}
		else
			msnftp_sendAcceptReject (ft, fcrt);

		SendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, ft, 0);
		break;
	}

	return 0;
}
Exemplo n.º 5
0
HANDLE __cdecl CMsnProto::FileAllow(HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szPath)
{
	filetransfer* ft = (filetransfer*)hTransfer;

	if (!msnLoggedIn || !p2p_sessionRegistered(ft))
		return 0;

	if ((ft->std.tszWorkingDir = mir_tstrdup(szPath)) == NULL) 
	{
		TCHAR szCurrDir[MAX_PATH];
		GetCurrentDirectory(SIZEOF(szCurrDir), szCurrDir);
		ft->std.tszWorkingDir = mir_tstrdup(szCurrDir);
	}
	else 
	{
		size_t len = _tcslen(ft->std.tszWorkingDir) - 1;
		if (ft->std.tszWorkingDir[len] == '\\')
			ft->std.tszWorkingDir[len] = 0;
	}

	ForkThread(&CMsnProto::MsnFileAckThread, ft);

	return ft;
}
Exemplo n.º 6
0
// MsnFileAllow - starts the file transfer
HANDLE __cdecl CMsnProto::FileAllow(MCONTACT, HANDLE hTransfer, const TCHAR* szPath)
{
	filetransfer* ft = (filetransfer*)hTransfer;

#ifdef OBSOLETE
	if (ft->tType != SERVER_HTTP && (!msnLoggedIn || !p2p_sessionRegistered(ft)))
		return 0;
#endif

	if ((ft->std.tszWorkingDir = mir_tstrdup(szPath)) == NULL) {
		TCHAR szCurrDir[MAX_PATH];
		GetCurrentDirectory(_countof(szCurrDir), szCurrDir);
		ft->std.tszWorkingDir = mir_tstrdup(szCurrDir);
	}
	else {
		size_t len = mir_tstrlen(ft->std.tszWorkingDir) - 1;
		if (ft->std.tszWorkingDir[len] == '\\')
			ft->std.tszWorkingDir[len] = 0;
	}

	ForkThread(&CMsnProto::MsnFileAckThread, ft);

	return ft;
}
Exemplo n.º 7
0
// MsnFileResume - renames a file
int __cdecl CMsnProto::FileResume(HANDLE hTransfer, int* action, const TCHAR** szFilename)
{
	filetransfer* ft = (filetransfer*)hTransfer;

	if (ft->tType == SERVER_HTTP) {
		switch (*action) {
			case FILERESUME_SKIP:
				ft->close();
				ft->bCanceled = true;
				break;
			case FILERESUME_RENAME:
				replaceStrT(ft->std.tszCurrentFile, *szFilename);
				break;
			case FILERESUME_OVERWRITE:
				ft->std.currentFileProgress = 0;
				break;
			case FILERESUME_RESUME:
				{
					struct _stati64 statbuf;
					_tstati64(ft->std.tszCurrentFile, &statbuf);
					ft->std.currentFileProgress = statbuf.st_size;
				}
				break;
		}
		SetEvent(ft->hResumeEvt);
	}
#ifdef OBSOLETE
	else {
		if (!msnLoggedIn || !p2p_sessionRegistered(ft))
			return 1;

		switch (*action) {
		case FILERESUME_SKIP:
			if (ft->p2p_appID != 0)
				p2p_sendStatus(ft, 603);
			else
				msnftp_sendAcceptReject(ft, false);
			break;

		case FILERESUME_RENAME:
			replaceStrT(ft->std.tszCurrentFile, *szFilename);

		default:
			bool fcrt = ft->create() != -1;
			if (ft->p2p_appID != 0) {
				if (fcrt)
					p2p_sendFeedStart(ft);

				p2p_sendStatus(ft, fcrt ? 200 : 603);
			}
			else
				msnftp_sendAcceptReject(ft, fcrt);

			ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, ft, 0);
			break;
		}
	}
#endif

	return 0;
}