src/include/common/http/TransportAgent.h

00001 /*
00002  * Copyright (C) 2003-2007 Funambol, Inc
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 version 2 as
00006  * published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00016  * 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         BOOL compression;
00062 
00063     public:
00064         TransportAgent();
00065         TransportAgent(URL& url,
00066                        Proxy& proxy,
00067                        unsigned int responseTimeout = DEFAULT_MAX_TIMEOUT,
00068                        unsigned int maxmsgsize = DEFAULT_MAX_MSG_SIZE);
00069 
00070         virtual ~TransportAgent();
00071 
00072         /*
00073          * Change the URL the subsequent calls to setMessage() should
00074          * use as target url.
00075          *
00076          * @param url the new target url
00077          */
00078         virtual void setURL(URL& newURL);
00079 
00080         /*
00081          * Returns the url.
00082          */
00083         virtual URL& getURL();
00084 
00090         virtual void setTimeout(unsigned int t);
00091 
00095         virtual unsigned int getTimeout();
00096 
00102         virtual void setMaxMsgSize(unsigned int t);
00103 
00107         virtual unsigned int getMaxMsgSize();
00108 
00114         virtual void setReadBufferSize(unsigned int t);
00115 
00116         virtual void setUserAgent(const char*  ua);
00117 
00118         virtual void setCompression(BOOL newCompression);
00119         virtual BOOL getCompression();
00120 
00121         virtual const char* getUserAgent();
00122 
00126         virtual unsigned int getReadBufferSize();
00127 
00128 
00129         /*
00130          * Sends the given SyncML message to the server specified
00131          * by the install property 'url'. Returns the server's response.
00132          * The response string has to be freed with delete [].
00133          * In case of an error, NULL is returned and lastErrorCode/Msg
00134          * is set.
00135          */
00136         virtual char*  sendMessage(const char*  msg) = 0;
00137 
00138     };
00139 
00141 #endif

Generated on Tue Oct 30 15:11:25 2007 for Funambol C++ Client Library by  doxygen 1.5.2