Main Page | Modules | Class Hierarchy | Data Structures | File List | Data Fields | Globals | Related Pages

omSmsManager.h

Go to the documentation of this file.
00001 
00002 // This code is part of the MaiaProject free software
00003 //
00004 // Keyboard and Mouse Emulator - Virtual keyboard Engine
00005 //
00006 // Copyright (c) 2002-2003 Luca Clivio <luca.clivio@maiaproject.org>
00007 // Tel. +39-347-2538040
00008 // via B.Croce 2, 20037 Paderno Dugnano (Milano) - Italy
00009 //
00010 // Developers:
00011 //    Simone Mangano <simone.mangano@maiaproject.org>
00012 //    Andrea Tosato  <andrea.tosato@maiaproject.org>
00013 //
00014 //  -----------------------------------------------------------------------------
00015 //  This program is free software; This program is free software; 
00016 //  you can redistribute it and/or modify it under the terms of the 
00017 //  GNU General Public License as published by the Free Software Foundation; 
00018 //  either version 2 of the License, or (at your option) any later version.
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 //  You should have received a copy of the GNU General Public License                           
00023 //  along with this program; if not, write to the Free Software                                 
00024 //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                                   
00026 
00027 #ifndef _OMSMSMANAGER_H_
00028 #define _OMSMSMANAGER_H_
00029 
00030 
00031 #include <openmaia/omSms.h>
00032 #include <wx/wx.h>
00033 
00034 #include <iostream>
00035 #include <fcntl.h>
00036 #include <termios.h>
00037 #include <signal.h>
00038 #include <unistd.h>
00039 
00040 
00041 /* ----------------- constants used for flow control ------ */
00042 /* modem timeout in milliseconds */
00043 #define MAX_TMOT 5000   //10 seconds
00044 #define SLEEPTIME 5
00045 
00046 /* reading tries before error */
00047 #define MAX_RETRY_NUMBER 1500
00048 
00049 /* ------------------ constants used to manage messages -----*/
00050 #define MAX_READMESS_BUFF_LENGHT 10000
00051 
00052 
00061 class omSmsManager
00062 {
00063 public:
00064 
00065   omSmsManager();
00066   virtual ~omSmsManager();
00067 
00068   int InitDevice(wxString port, int bouds=B19200);
00069   wxString GetDevice(); 
00070   void Reset();         
00071   int SendSMS(wxString phone_number, wxString message);
00072   int ReceiveMessages(omSmsArray *messages);
00073 
00074 private:
00075   wxString port;        
00076   int device_init;      
00077   int device;           
00078 
00079 private:
00080   int WriteString(char *s, int how);
00081   int WriteChar(char c, char *answ, int lansw);
00082   
00083   int SendString(char *dom, char *ris, int tmout);
00084 
00085   int QueryPhone(char *qy, char *stop, char *answ, int tmout);
00086   omSms *GetSmsHeader(wxString buf);
00087 
00088 };
00089 
00090 #endif // SMSMANAGER_H