Code Search for Developers
 
 
  

RequestProcessor.h from AlphaMail at Krugle


Show RequestProcessor.h syntax highlighted

#ifndef IMAP_REQUEST_PROCESSOR_H
#define IMAP_REQUEST_PROCESSOR_H

#include <boost/regex.hpp>
#include <map>
#include <iostream>
#include <vector>
#include <string>
#include <netxx/netxx.h>
#include <IMAPTypes.h>
#include <Runnable.h>
#include <boost/thread.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/thread/mutex.hpp>

namespace Middleware
{
   // Create one of these on a thread in order to process requests from web 
   // client. This object becomes the owner of the socket, and will delete it on
   // exit.

   class RequestProcessor : public Runnable, private boost::noncopyable
   {
      public:
         RequestProcessor(Netxx::Peer p, bool *sflag);
         virtual ~RequestProcessor() {}
         void operator()();

         // Folder operations
         bool list_subscribed_folders(const std::vector<std::string> &args);
         bool set_subscribed_folders(const std::vector<std::string> &args);
         bool list_all_folders(const std::vector<std::string> &args);
         bool subscribe(const std::vector<std::string> &args);
         bool unsubscribe(const std::vector<std::string> &args);

         bool create_folder(const std::vector<std::string> &args);
         bool delete_folder(const std::vector<std::string> &args);

         // Message reading/manipulation
         bool message_list(const std::vector<std::string> &args);

         bool read_message(const std::vector<std::string> &args) {
            (*client) << "NO Not implemented" << std::endl;
            return true;
         }

         bool cat_message(const std::vector<std::string> &args);
         /**
          * Usage: 
          * append folder
          * size<cr><nl>
          * data 
          */
         bool append_message(const std::vector<std::string> &args);

         bool delete_message(const std::vector<std::string> &args);
         bool undelete_message(const std::vector<std::string> &args);
         bool expunge_folder(const std::vector<std::string> &args);
         bool move_message(const std::vector<std::string> &args);
         bool set_flags(const std::vector<std::string> &args);
         bool date_crop(const std::vector<std::string> &args);

         bool stats(const std::vector<std::string> &args);

         // "completion" commands
         bool shutdown(const std::vector<std::string> &args);
         bool flush(const std::vector<std::string> &args);
         bool logout(const std::vector<std::string> &args) {
            (*client) << "goodbye" << std::endl;
            return false;
         }
      private:
         boost::scoped_ptr<Netxx::Stream> stream;
         boost::scoped_ptr<Netxx::Netbuf<1024> > buffer;
         boost::scoped_ptr<std::iostream> client;
         Netxx::Peer peer;
         std::string user, host, password;

         static boost::recursive_mutex rp_mutex;
         static std::map<std::string, bool (RequestProcessor::*)(const std::vector<std::string>&)> command_map;
         static bool *shutdown_flag;

         // Split an argument string into an argument array
         bool split_args(const std::string &s, 
                         std::vector<std::string> *args);
         void chomp(std::string &line) {
            std::string::size_type n = line.find_first_of("\r\n");
            if(n != std::string::npos) {
               line.erase(n);
            }
         }
         bool getline(std::string &s);
         bool _do_list(std::string folder, bool all);
         void disconnect();

   };

};

#endif




See more files for this project here

AlphaMail

AlphaMail is an accelerated web mail interface with a C++ middleware layer that is more effective than an IMAP proxy which is a highly scalable (10k+ users). The interface includes modern features, Section 508 compliance, and universal browser support.

Project homepage: http://sourceforge.net/projects/alphamail
Programming language(s): C++,Java,JavaScript,Perl
License: other

  CacheManager.h
  IMAPFolder.h
  IMAPParser.h
  IMAPRegexParser.h
  IMAPTypes.h
  MessageAttributes.h
  RequestProcessor.h
  Runnable.h
  imap_debug.h
  middleware.h