src/include/windows/http/WinTransportAgent.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 
00020 /*
00021  How to test SSL connections
00022  ----------------------------
00023 
00024  On the server:
00025  1) create the keystore:
00026     %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
00027  2) In $CATALINA_HOME/conf/server.xml uncomment the lines:
00028     <Connector className="org.apache.catalina.connector.http.HttpConnector"
00029                port="8443" minProcessors="5" maxProcessors="75"
00030                enableLookups="true"
00031                acceptCount="10" debug="0" scheme="https" secure="true">
00032       <Factory className="org.apache.catalina.net.SSLServerSocketFactory" clientAuth="false" protocol="TLS"/>
00033     </Connector>
00034  2) Export the certificate from the key store:
00035     %JAVA_HOME%\bin\keytool -export -alias tomcat -file myroot.cer
00036 
00037  On the client:
00038   [for _WIN32_WCE]
00039    1)  Copy myroot.cer in a device/emulator directory
00040    2) Click on it to import the certificate as a trusted CA
00041   [for WIN32]
00042    1) Connect (via https) to the server using a web-browser (type "https://<server_address>:8443)
00043    2) Accept and install the certificate sent from the server
00044 */
00045 
00046 #ifndef INCL_WIN_TRANSPORT_AGENT
00047 #define INCL_WIN_TRANSPORT_AGENT
00048 
00050 #include "base/fscapi.h"
00051 #include "http/URL.h"
00052 #include "http/Proxy.h"
00053 #include "http/TransportAgent.h"
00054 
00056 #define MAX_RETRIES                     3                       // Max number of attempts sending http requests.
00057 
00058 // FIXME: should these go to http/errors.h ?
00059 #define ERR_HTTP_TIME_OUT               ERR_TRANSPORT_BASE+ 7
00060 #define ERR_HTTP_NOT_FOUND              ERR_TRANSPORT_BASE+60
00061 #define ERR_HTTP_REQUEST_TIMEOUT        ERR_TRANSPORT_BASE+61
00062 #define ERR_HTTP_INFLATE                ERR_TRANSPORT_BASE+70
00063 #define ERR_HTTP_DEFLATE                ERR_TRANSPORT_BASE+71
00064 
00065 #define ERROR_INTERNET_OFFLINE_MODE     0x0002                  // Not sure why it's not defined under wininet.h ...
00066 
00067 
00068 
00074 class WinTransportAgent : public TransportAgent {
00075 
00076 
00077 public:
00078     WinTransportAgent();
00079     WinTransportAgent(URL& url, Proxy& proxy,
00080                       unsigned int responseTimeout = DEFAULT_MAX_TIMEOUT,
00081                       unsigned int maxmsgsize = DEFAULT_MAX_MSG_SIZE);
00082     ~WinTransportAgent();
00083 
00093     char*  sendMessage(const char*  msg);
00094 
00095 private:
00096     BOOL isToDeflate;           // to be zipped
00097     BOOL isFirstMessage;        // first message is clear
00098     BOOL isToInflate;           // to be unzipped
00099 
00100     char* createHttpErrorMessage(DWORD errorCode);
00101     void  dumpMessage(const char* msg, const int msgLen);
00102 };
00103 
00105 #endif

Generated on Fri Nov 9 12:21:26 2007 for Funambol Outlook Plug-in Library by  doxygen 1.5.2