示例#1
0
int CFileZillaEngine::Execute(const CCommand &command)
{
	if (command.GetId() != Command::cancel && IsBusy())
		return FZ_REPLY_BUSY;

	m_bIsInCommand = true;

	int res = FZ_REPLY_INTERNALERROR;
	switch (command.GetId())
	{
	case Command::connect:
		res = Connect(reinterpret_cast<const CConnectCommand &>(command));
		break;
	case Command::disconnect:
		res = Disconnect(reinterpret_cast<const CDisconnectCommand &>(command));
		break;
	case Command::cancel:
		res = Cancel(reinterpret_cast<const CCancelCommand &>(command));
		break;
	case Command::list:
		res = List(reinterpret_cast<const CListCommand &>(command));
		break;
	case Command::transfer:
		res = FileTransfer(reinterpret_cast<const CFileTransferCommand &>(command));
		break;
	case Command::raw:
		res = RawCommand(reinterpret_cast<const CRawCommand&>(command));
		break;
	case Command::del:
		res = Delete(reinterpret_cast<const CDeleteCommand&>(command));
		break;
	case Command::removedir:
		res = RemoveDir(reinterpret_cast<const CRemoveDirCommand&>(command));
		break;
	case Command::mkdir:
		res = Mkdir(reinterpret_cast<const CMkdirCommand&>(command));
		break;
	case Command::rename:
		res = Rename(reinterpret_cast<const CRenameCommand&>(command));
		break;
	case Command::chmod:
		res = Chmod(reinterpret_cast<const CChmodCommand&>(command));
		break;
	default:
		return FZ_REPLY_SYNTAXERROR;
	}

	if (res != FZ_REPLY_WOULDBLOCK)
		ResetOperation(res);

	m_bIsInCommand = false;

	if (command.GetId() != Command::disconnect)
		res |= m_nControlSocketError;
	else if (res & FZ_REPLY_DISCONNECTED)
		res = FZ_REPLY_OK;
	m_nControlSocketError = 0;

	return res;
}
示例#2
0
int CFileZillaApi::Command(t_command *pCommand)
{
	//Check if call allowed
	if (!m_bInitialized)
		return FZ_REPLY_NOTINITIALIZED;

	//Dispatch command to command specific functions
	switch(pCommand->id)
	{
	case FZ_COMMAND_LIST:
		if (pCommand->param1!=_MPT(""))
			return List(pCommand->path,pCommand->param1,pCommand->param4);
		else if (!pCommand->path.IsEmpty())
			return List(pCommand->path,pCommand->param4);
		else
			return List(pCommand->param4);
		break;
	case FZ_COMMAND_CONNECT:
		return Connect(pCommand->server);
		break;
	case FZ_COMMAND_DISCONNECT:
		return Disconnect();
		break;
	case FZ_COMMAND_FILETRANSFER:
		return FileTransfer(pCommand->transferfile);
		break;
	case FZ_COMMAND_DELETE:
		return Delete(pCommand->param1, pCommand->path);
		break;
	case FZ_COMMAND_REMOVEDIR:
		return RemoveDir(pCommand->param1, pCommand->path);
		break;
	case FZ_COMMAND_MAKEDIR:
		return MakeDir(pCommand->path);
		break;
	case FZ_COMMAND_RENAME:
		return Rename(pCommand->param1, pCommand->param2, pCommand->path, pCommand->newPath);
		break;
	case FZ_COMMAND_CUSTOMCOMMAND:
		return CustomCommand(pCommand->param1);
		break;
	case FZ_COMMAND_CHMOD:
		return Chmod(pCommand->param4, pCommand->param1, pCommand->path);
		break;
	}
	return FZ_REPLY_INVALIDPARAM;
}
示例#3
0
int CFileZillaEngine::Command(const CCommand &command)
{
    if (command.GetId() != cmd_cancel && IsBusy())
        return FZ_REPLY_BUSY;

    m_bIsInCommand = true;

    int res = FZ_REPLY_INTERNALERROR;

    printf("command id: %d\n", command.GetId());
    switch (command.GetId())
    {
    case cmd_connect:
        res = Connect(reinterpret_cast<const CConnectCommand &>(command));
        break;
    case cmd_disconnect:
        res = Disconnect(reinterpret_cast<const CDisconnectCommand &>(command));
        break;
    case cmd_cancel:
        res = Cancel(reinterpret_cast<const CCancelCommand &>(command));
        break;
    case cmd_list:
        res = List(reinterpret_cast<const CListCommand &>(command));
        break;
    case cmd_transfer:
        res = FileTransfer(reinterpret_cast<const CFileTransferCommand &>(command));
        break;
    case cmd_raw:
        res = RawCommand(reinterpret_cast<const CRawCommand&>(command));
        break;
    case cmd_delete:
        res = Delete(reinterpret_cast<const CDeleteCommand&>(command));
        break;
    case cmd_removedir:
        res = RemoveDir(reinterpret_cast<const CRemoveDirCommand&>(command));
        break;
    case cmd_mkdir:
        res = Mkdir(reinterpret_cast<const CMkdirCommand&>(command));
        break;
    case cmd_rename:
        res = Rename(reinterpret_cast<const CRenameCommand&>(command));
        break;
    case cmd_chmod:
        res = Chmod(reinterpret_cast<const CChmodCommand&>(command));
        break;
    case cmd_checksum:
        printf("recognized the checksum command\n");
        res = Checksum(reinterpret_cast<const CChecksumCommand&>(command));
        break;
    default:
        return FZ_REPLY_SYNTAXERROR;
    }

    if (res != FZ_REPLY_WOULDBLOCK)
        ResetOperation(res);

    m_bIsInCommand = false;

    if (command.GetId() != cmd_disconnect)
        res |= m_nControlSocketError;
    else if (res & FZ_REPLY_DISCONNECTED)
        res = FZ_REPLY_OK;
    m_nControlSocketError = 0;

    return res;
}
示例#4
0
LooseFileTransfer::LooseFileTransfer()
{
  FileTransfer();
}