Back to index

lightning-sunbird  0.9+nobinonly
JMURLConnection.h
Go to the documentation of this file.
00001 /*
00002     JMURLConnection.h
00003  */
00004 
00005 #pragma once
00006 
00007 #ifndef       __JMURLConnection__
00008 #define       __JMURLConnection__
00009 
00010 #ifdef __cplusplus
00011 extern "C" {
00012 #endif
00013 
00014 #if PRAGMA_IMPORT_SUPPORTED
00015 #pragma import on
00016 #endif
00017 
00018 #if PRAGMA_ALIGN_SUPPORTED
00019 #pragma options align=mac68k
00020 #endif
00021 
00022 typedef void* JMURLConnectionRef;
00023 typedef void* JMURLInputStreamRef;
00024 typedef void* JMURLOutputStreamRef;
00025 
00026 enum JMURLConnectionOptions
00027 {
00028        eDefault                    = 0,
00029        eNoCaching                  = (1 << 2),
00030        eNoUserInteraction   = (1 << 3),
00031        eNoRedirection              = (1 << 4)
00032 };
00033 
00034 typedef enum JMURLConnectionOptions JMURLConnectionOptions;
00035 
00036 typedef CALLBACK_API_C(OSStatus, JMURLOpenConnectionProcPtr)(
00037        /* in URL = */ JMTextRef url,
00038        /* in RequestMethod = */ JMTextRef requestMethod,
00039        /* in ConnectionOptions = */ JMURLConnectionOptions options,
00040        /* in AppletViewer = */ JMAppletViewerRef appletViewer,
00041        /* out URLConnectionRef = */ JMURLConnectionRef* urlConnectionRef
00042        );
00043 
00044 typedef CALLBACK_API_C(OSStatus, JMURLCloseConnectionProcPtr)(
00045        /* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef
00046        );
00047 
00048 typedef CALLBACK_API_C(Boolean, JMURLUsingProxyProcPtr)(
00049        /* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef
00050        );
00051 
00052 typedef CALLBACK_API_C(OSStatus, JMURLGetCookieProcPtr)(
00053        /* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
00054        /* out CookieValue = */ JMTextRef* cookie
00055        );
00056 
00057 typedef CALLBACK_API_C(OSStatus, JMURLSetCookieProcPtr)(
00058        /* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
00059        /* in CookieValue = */ JMTextRef cookie
00060        );
00061 
00062 typedef CALLBACK_API_C(OSStatus, JMURLSetRequestPropertiesProcPtr)(
00063        /* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
00064        /* in NumberOfProperties = */ int numberOfProperties,
00065        /* in PropertyNames = */ JMTextRef* keys,
00066        /* in Values = */ JMTextRef* value
00067        );
00068 
00069 typedef CALLBACK_API_C(OSStatus, JMURLGetResponsePropertiesCountProcPtr)(
00070        /* in URLConnectionRef = */ JMURLInputStreamRef iStreamRef,
00071        /* out numberOfProperties = */ int* numberOfProperties
00072        );
00073 
00074 /*
00075  * JManager allocates memory to hold the specified number of (properties)
00076  * JMTextRefs. The proc is expected to create new JMTextRefs that should
00077  * be shoved in the array passed. The JManager takes care of disposing
00078  * these JMTextRefs.
00079  */
00080 typedef CALLBACK_API_C(OSStatus, JMURLGetResponsePropertiesProcPtr)(
00081        /* in URLConnectionRef = */ JMURLInputStreamRef iStreamRef,
00082        /* in numberOfProperties = */ int numberOfProperties,
00083        /* out PropertyNames = */ JMTextRef* keys,
00084        /* out Values = */ JMTextRef* values
00085        );
00086 
00087 typedef CALLBACK_API_C(OSStatus, JMURLOpenInputStreamProcPtr)(
00088        /* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
00089        /* out URLStreamRef = */ JMURLInputStreamRef* urlInputStreamRef
00090        );
00091 
00092 typedef CALLBACK_API_C(OSStatus, JMURLOpenOutputStreamProcPtr)(
00093        /* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
00094        /* out URLOutputStreamRef = */ JMURLOutputStreamRef* urlOutputStreamRef
00095        );
00096 
00097 typedef CALLBACK_API_C(OSStatus, JMURLCloseInputStreamProcPtr)(
00098        /* in URLInputStreamRef = */ JMURLInputStreamRef urlInputStreamRef
00099        );
00100 
00101 typedef CALLBACK_API_C(OSStatus, JMURLCloseOutputStreamProcPtr)(
00102        /* in URLOutputStreamRef = */ JMURLOutputStreamRef urlOutputStreamRef
00103        );
00104 
00105 typedef CALLBACK_API_C(OSStatus, JMURLReadProcPtr)(
00106        /* in URLConnectionRef = */ JMURLInputStreamRef iStreamRef,
00107        /* out Buffer = */ void* buffer,
00108        /* in BufferSize = */ UInt32 bufferSize,
00109        /* out BytesRead = */ SInt32* bytesRead
00110        );
00111 
00112 typedef CALLBACK_API_C(OSStatus, JMURLWriteProcPtr)(
00113        /* in URLConnectionRef = */ JMURLOutputStreamRef oStreamRef,
00114        /* in Buffer = */ void* buffer,
00115        /* in BytesToWrite = */ SInt32 bytesToWrite
00116        );
00117 
00118 struct JMURLCallbacks {
00119        UInt32                                                                fVersion;     /* should be set to kJMVersion */
00120        JMURLOpenConnectionProcPtr                       fOpenConnection;
00121        JMURLCloseConnectionProcPtr                      fCloseConnection;
00122        JMURLUsingProxyProcPtr                                  fUsingProxy;
00123        JMURLGetCookieProcPtr                                   fGetCookie;
00124        JMURLSetCookieProcPtr                                   fSetCookie;
00125        JMURLSetRequestPropertiesProcPtr          fSetRequestProperties;
00126        JMURLGetResponsePropertiesCountProcPtr    fGetResponsePropertiesCount;
00127        JMURLGetResponsePropertiesProcPtr         fGetResponseProperties;
00128        JMURLOpenInputStreamProcPtr                      fOpenInputStream;
00129        JMURLOpenOutputStreamProcPtr                     fOpenOutputStream;
00130        JMURLCloseInputStreamProcPtr                     fCloseInputStream;
00131        JMURLCloseOutputStreamProcPtr                    fCloseOutputStream;
00132        JMURLReadProcPtr                                        fRead;
00133        JMURLWriteProcPtr                                       fWrite;
00134 };
00135 
00136 typedef struct JMURLCallbacks             JMURLCallbacks;
00137 
00138 EXTERN_API_C(OSStatus)
00139 JMURLSetCallbacks(
00140        JMSessionRef session,
00141        const char* protocol,
00142        JMURLCallbacks* cb
00143        );
00144 
00145 EXTERN_API_C(OSStatus)
00146 JMURLOpenConnection(
00147        /* in JMSessionRef = */ JMSessionRef session,
00148        /* in URL = */ JMTextRef url,
00149        /* in RequestMethod = */ JMTextRef requestMethod,
00150        /* in ConnectionOptions = */ JMURLConnectionOptions options,
00151        /* in AppletViewer = */ JMAppletViewerRef appletViewer,
00152        /* out URLConnectionRef = */ JMURLConnectionRef* urlConnectionRef
00153        );
00154 
00155 EXTERN_API_C(OSStatus)
00156 JMURLCloseConnection(
00157        /* in JMSessionRef = */ JMSessionRef session,
00158        /* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef
00159        );
00160 
00161 EXTERN_API_C(Boolean)
00162 JMURLUsingProxy(
00163        /* in JMSessionRef = */ JMSessionRef session,
00164        /* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef
00165        );
00166 
00167 EXTERN_API_C(OSStatus)
00168 JMURLGetCookie(
00169        /* in JMSessionRef = */ JMSessionRef session,
00170        /* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
00171        /* out CookieValue = */ JMTextRef* cookie
00172        );
00173 
00174 EXTERN_API_C(OSStatus)
00175 JMURLSetCookie(
00176        /* in JMSessionRef = */ JMSessionRef session,
00177        /* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
00178        /* in CookieValue = */ JMTextRef cookie
00179        );
00180 
00181 EXTERN_API_C(OSStatus)
00182 JMURLSetRequestProperties(
00183        /* in JMSessionRef = */ JMSessionRef session,
00184        /* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
00185        /* in NumberOfProperties = */ int numberOfProperties,
00186        /* in PropertyNames = */ JMTextRef* keys,
00187        /* in Values = */ JMTextRef* value
00188        );
00189 
00190 EXTERN_API_C(OSStatus)
00191 JMURLGetResponsePropertiesCount(
00192        /* in JMSessionRef = */ JMSessionRef session,
00193        /* in InputStreamRef = */ JMURLInputStreamRef iStreamRef,
00194        /* out numberOfProperties = */ int* numberOfProperties
00195        );
00196 
00197 EXTERN_API_C(OSStatus)
00198 JMURLGetResponseProperties(
00199        /* in JMSessionRef = */ JMSessionRef session,
00200        /* in InputStreamRef = */ JMURLInputStreamRef iStreamRef,
00201        /* in numberOfProperties = */ int numberOfProperties,
00202        /* out PropertyNames = */ JMTextRef* keys,
00203        /* out Values = */ JMTextRef* values
00204        );
00205 
00206 EXTERN_API_C(OSStatus)
00207 JMURLOpenInputStream(
00208        /* in JMSessionRef = */ JMSessionRef session,
00209        /* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
00210        /* out URLInputStreamRef = */ JMURLInputStreamRef* urlInputStreamRef
00211        );
00212 
00213 EXTERN_API_C(OSStatus)
00214 JMURLOpenOutputStream(
00215        /* in JMSessionRef = */ JMSessionRef session,
00216        /* in URLConnectionRef = */ JMURLConnectionRef urlConnectionRef,
00217        /* out URLOutputStreamRef = */ JMURLOutputStreamRef* urlOutputStreamRef
00218        );
00219 
00220 EXTERN_API_C(OSStatus)
00221 JMURLCloseInputStream(
00222        /* in JMSessionRef = */ JMSessionRef session,
00223        /* in URLInputStreamRef = */ JMURLInputStreamRef urlInputStreamRef
00224        );
00225 
00226 EXTERN_API_C(OSStatus)
00227 JMURLCloseOutputStream(
00228        /* in JMSessionRef = */ JMSessionRef session,
00229        /* in URLOutputStreamRef = */ JMURLOutputStreamRef urlOutputStreamRef
00230        );
00231 
00232 EXTERN_API_C(OSStatus)
00233 JMURLRead(
00234        /* in JMSessionRef = */ JMSessionRef session,
00235        /* in URLInputStreamRef = */ JMURLInputStreamRef urlInputStreamRef,
00236        /* out Buffer = */ void* buffer,
00237        /* in BufferSize = */ UInt32 bufferSize,
00238        /* out BytesRead = */ SInt32* bytesRead
00239        );
00240 
00241 EXTERN_API_C(OSStatus)
00242 JMURLWrite(
00243        /* in JMSessionRef = */ JMSessionRef session,
00244        /* in URLOutputStreamRef = */ JMURLOutputStreamRef urlOutputStreamRef,
00245        /* in Buffer = */ void* buffer,
00246        /* in BytesToWrite = */ SInt32 bytesToWrite
00247        );
00248 
00249 #if PRAGMA_ALIGN_SUPPORTED
00250 #pragma options align=reset
00251 #endif
00252 
00253 #if PRAGMA_IMPORT_SUPPORTED
00254 #pragma import off
00255 #endif
00256 
00257 #ifdef __cplusplus
00258 }
00259 #endif
00260 
00261 #endif /* __JMURLConnection__ */
00262