src/include/common/http/TransportAgent.h

00001 /*
00002  * Copyright (C) 2003-2007 Funambol
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  */
00018 
00019 #ifndef INCL_TRANSPORT_AGENT
00020     #define INCL_TRANSPORT_AGENT
00021 
00023     #include "base/fscapi.h"
00024 
00025     #include "http/URL.h"
00026     #include "http/Proxy.h"
00027 
00028     //
00029     // number of seconds of waiting response timeout.
00030     //
00031     #define DEFAULT_MAX_TIMEOUT 300
00032 
00033     //
00034     // The max_msg_size parameter. Default is 512k.
00035     // The value is expressed in byte
00036     //
00037     #define DEFAULT_MAX_MSG_SIZE 512000    
00038 
00039     //
00040     // This is the default value for the size of the buffer used to store the 
00041     // incoming stram from server. It is expressed in byte     
00042     //
00043     #define DEFAULT_INTERNET_READ_BUFFER_SIZE  4096
00044 
00045     /*
00046      * This class is the transport agent responsible for messages exchange
00047      * over an HTTP connection.
00048      * This is a generic abtract class which is not bound to any paltform
00049      */
00050 
00051     class TransportAgent {
00052 
00053     protected:
00054         URL url;
00055         Proxy proxy;
00056 
00057         unsigned int timeout;
00058         unsigned int maxmsgsize;
00059         unsigned int readBufferSize;
00060         char userAgent[128];
00061 
00062     public:
00063         TransportAgent() EXTRA_SECTION_03;
00064         TransportAgent(URL& url, 
00065                        Proxy& proxy, 
00066                        unsigned int responseTimeout = DEFAULT_MAX_TIMEOUT, 
00067                        unsigned int maxmsgsize = DEFAULT_MAX_MSG_SIZE) EXTRA_SECTION_03;
00068 
00069         virtual ~TransportAgent() EXTRA_SECTION_03;
00070 
00071         /*
00072          * Change the URL the subsequent calls to setMessage() should
00073          * use as target url.
00074          *
00075          * @param url the new target url
00076          */
00077         virtual void setURL(URL& newURL) EXTRA_SECTION_03;
00078 
00079         /*
00080          * Returns the url.
00081          */
00082         virtual URL& getURL() EXTRA_SECTION_03;
00083 
00089         virtual void setTimeout(unsigned int t) EXTRA_SECTION_03;
00090 
00094         virtual unsigned int getTimeout() EXTRA_SECTION_03;
00095         
00101         virtual void setMaxMsgSize(unsigned int t) EXTRA_SECTION_03;
00102          
00106         virtual unsigned int getMaxMsgSize()EXTRA_SECTION_03;
00107 
00113         virtual void setReadBufferSize(unsigned int t) EXTRA_SECTION_03;
00114         
00115         virtual void setUserAgent(const char*  ua);
00116 
00117         virtual const char* getUserAgent();
00118 
00122         virtual unsigned int getReadBufferSize()EXTRA_SECTION_03;
00123 
00124 
00125         /*
00126          * Sends the given SyncML message to the server specified
00127          * by the install property 'url'. Returns the server's response.
00128          * The response string has to be freed with delete [].
00129          * In case of an error, NULL is returned and lastErrorCode/Msg
00130          * is set.
00131          */
00132         virtual char*  sendMessage(const char*  msg) = 0;
00133 
00134     };
00135 
00137 #endif

Generated on Fri Apr 27 12:29:18 2007 for Funambol C++ Client Library by  doxygen 1.5.2