AmMail.h

Go to the documentation of this file.
00001 /*
00002  * $Id: AmMail.h 711 2008-02-10 18:52:44Z sayer $
00003  *
00004  * Copyright (C) 2002-2003 Fhg Fokus
00005  *
00006  * This file is part of sems, a free SIP media server.
00007  *
00008  * sems is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * For a license to use the ser software under conditions
00014  * other than those described here, or to purchase support for this
00015  * software, please contact iptel.org by e-mail at the following addresses:
00016  *    info@iptel.org
00017  *
00018  * sems is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License 
00024  * along with this program; if not, write to the Free Software 
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  */
00028 #ifndef _AmMail_h_
00029 #define _AmMail_h_
00030 
00031 #include "AmThread.h"
00032 #include <stdio.h>
00033 
00034 #include <string>
00035 #include <vector>
00036 #include <queue>
00037 using std::string;
00038 
00042 struct Attachement
00043 {
00045   //string fullname;
00046   FILE* fp;
00047     
00049   string filename; 
00051   string content_type;
00052 
00053   //     Attachement(const string& _full, const string& _file="", const string& _ct="")
00054   //    : fullname(_full), filename(_file), content_type(_ct) {}
00055 
00056   Attachement(FILE* _fp, const string& _file="", const string& _ct="")
00057     : fp(_fp), filename(_file), content_type(_ct) {}
00058 };
00059 
00060 typedef std::vector<Attachement> Attachements;
00061 
00062 class AmMail;
00063 
00068 typedef void (*MailCleanUpFunction)(AmMail* mail);
00069 
00074 struct AmMail
00075 {
00076 public:
00077   string from;
00078   string subject;
00079   string body;
00080   string to;
00081   string header;
00082 
00084   string charset;
00085 
00086   Attachements attachements;
00087 
00089   MailCleanUpFunction clean_up;
00090 
00091   int error_count;
00092 
00093   AmMail(const string& _from, const string& _subject,
00094          const string& _to, const string& _body = "",
00095          const string& _header = "");
00096 
00097   ~AmMail();
00098 };
00099 
00105 class AmMailDeamon: public AmThread
00106 {
00107   static AmMailDeamon* _instance;
00108 
00109   AmMutex      event_fifo_mut;
00110   std::queue<AmMail*>   event_fifo;
00111   AmCondition<bool> _run_cond;
00112 
00113   AmMailDeamon() : _run_cond(false) {}
00114   AmMailDeamon(const AmMailDeamon&) : _run_cond(false) {}
00115   ~AmMailDeamon() {}
00116 
00117   void run();
00118   void on_stop();
00119 
00120 public:
00121   static AmMailDeamon* instance();
00122 
00130   int sendQueued(AmMail* mail);
00131 };
00132 
00133 #endif
00134 

Generated on Fri May 16 12:02:05 2008 for SEMS by  doxygen 1.5.1
Home |  Recent changes |  Search |  Glossary |  Sitemap |  Login