Wexus2 0.20
wexus2.src/wexus/FileApp.h
00001 
00002 /*
00003  * Copyright (c) 2011 Aleksander B. Demko
00004  * This source code is distributed under the MIT license.
00005  * See the accompanying file LICENSE.MIT.txt for details.
00006  */
00007 
00008 #ifndef __INCLUDED_WEXUS_FILEAPP_H__
00009 #define __INCLUDED_WEXUS_FILEAPP_H__
00010 
00011 #include <QVector>
00012 
00013 #include <wexus/Application.h>
00014 
00015 namespace wexus
00016 {
00017   class FileApp;
00018 }
00019 
00020 /**
00021  * An application that just servers files from one
00022  * or more directories.
00023  *
00024  * INI parameters:
00025  *   dirX = "."
00026  *   dirX = "dir"
00027  *   dirX = "dir/subdir"
00028  *    X is a number, 1, 2, etc
00029  *   The directory to serve. If none are given then a dir1="." is assumed.
00030  *   All directotories will be relative to the app dir.
00031  *   for any dirX, you can have a optionX. this string can contain a space
00032  *   delimeted list any of the following (case insenstive):
00033  *   optionsX = "IndexHtml AutoDirIndex AllowAllMimeTypes"
00034  *   TODO future allow full absolute dirs?
00035  *
00036  *
00037  * @author Aleksander Demko
00038  */ 
00039 class wexus::FileApp : public wexus::Application
00040 {
00041   public:
00042     /// normal ctor
00043     FileApp(void);
00044 
00045     /**
00046      * Specific ctor called by the mainline.
00047      *
00048      * Do not call init if you use this ctor.
00049      *
00050      * docdir will have some flags set, like auto indexing and loading all files. careful.
00051      * TODO future, add flags parameter
00052      * @author Aleksander Demko
00053      */ 
00054     FileApp(const QString &docdir);
00055 
00056     virtual void init(const QVariantMap &settings);
00057 
00058     virtual void handleApplicationRequest(QString &filteredRequest, wexus::HTTPRequest &req, wexus::HTTPReply &reply);
00059 
00060   protected:
00061     struct DirFlags
00062     {
00063       QString dirname;
00064       int flags;
00065 
00066       DirFlags(void) : flags(0) { }
00067       DirFlags(const QString &_dirname, int _flags = 0) : dirname(_dirname), flags(_flags) { }
00068     };
00069 
00070     QVector<DirFlags> dm_dirs;   // vector, because once its built, it wont change
00071 };
00072 
00073 #endif
00074 
 All Classes Namespaces Functions Variables Enumerations Enumerator