CommandHandler restructure/fr0w

From DrFTPD

Jump to: navigation, search

Contents

New CommandHandler Architeture

This is another attempt to create this new arch to the CommandHandlers. To understand this article, i suggest you reading the following links:

TDSoul's Suggestion

zubov's Suggestion So far, I like fr0w's... mine sucks :) zubov

This article was wrote by fr0w

Basics

There will be a main interface called CommandHandler which is going to do the real job, for example nuking a directory. Implementing this interface we should have 2 abstract classes: IRCCommand and SiteCommand.

Return Type

To make a unique protocol that can talk to both IRCCommand and SiteCommand we need a Type/Object that can be interpreted by both, that's where we are introducing GenericResponse or an Object Array.

  • GenericResponse -> an interface that should be implemented in order to provide an channel of comunication between different means of output, there's just one problem about it, suppose you have lots of CommandHandlers and they all need a specific GenericResponse implementation, you will end up with lots of new classes being created and stuff (is that a real problem?)
  • Object Array -> that's the simplest way to pass the information, and avoid the creation of 100s new implementations on GenericResponse, there will be some examples of how it would work in this article.

The Classes and their methods

CommandHandler

  • CommandHandler(String textRequest, ArrayList<PreFilter>)
  • private boolean processPreFilters() -> modifies the text request, returns error if processing should stop
  • GenericResponse process(String textRequest) -> the core of the command, where the real work happens

IRCCommand/SiteCommand

  • Also can distinguish what's a site command and what's an irc command through "instanceof"

GenericResponse

  • String getOutputForIRC()
  • String getOutputForSite()

NukeResponse Example

  • getNukees() -> ArrayList containing Nukees Object.
  • getPath() -> Affected path.
  • getIssuer() -> The issuer of the command.
  • getMultiplier() -> Return the multiplier.
  • Etc...

Class Hierachy

  • CommandHandler
    • IRCCommand
      • IRCNuke
    • SiteCommand
      • SiteNuke
  • GenericResponse
    • NukeResponse
  • Filter
    • PreFilter
      • IRCPreFilter
      • SitePreFilter
    • PostFilter
      • IRCPostFilter
      • SitePreFilter

Configuration Files

We have to find some real nice syntax, prolly using some similar to UnrealIRCd. Pre/Post hooks/filters should be used to define permissions

Site Commands

pwd {
 class net.sf.drftpd.master.command.plugins.Dir
 method doPWD
 pre org.drftpd.commandhooks.pre.site.PATH.permission *
 pre org.drftpd.thirdparty.hooks.PRE.doPWD1
 pre org.drftpd.thirdparty.hooks.PRE.doPWD2
 post org.drftpd.thirdparty.hooks.POST.doPWD1
 post org.drftpd.thirdparty.hooks.POST.doPWD2
}

PRE/POST Hooks

Pre/Post hooks can be used for permissions Pre hooks will give much more functionality

Personal tools
SourceForge.net Logo