unit Sparkle.Android.Import;

{$I Sparkle.Inc}

interface

{$IFDEF ANDROID}

uses
  Androidapi.JNIBridge,
  Androidapi.JNI.JavaTypes;

type
  JURL = interface;
  JBufferedInputStream = interface;
  JBufferedOutputStream = interface;
  JProxySelector = interface;
  JURI = interface;
  JProxy = interface;

  JURLConnectionClass = interface(JObjectClass)
  ['{A6703A72-FA8C-42FE-88FF-BA50C63DE3CC}']
  end;

  [JavaSignature('java/net/URLConnection')]
  JURLConnection = interface(JObject)
  ['{609145E6-184B-4431-94D9-87E33DA18D13}']
    procedure connect;
    procedure disconnect;
    function getContentLength: integer;
    function getHeaderFields: JMap;
    function getErrorStream: JInputStream;
    function getInputStream: JInputStream;
    function getOutputStream: JOutputStream;

    procedure setConnectTimeout(timeoutMS: integer);
    procedure setDoOutput(value: boolean);
    procedure setReadTimeout(timeoutMS: integer);
    procedure setRequestProperty(field, newValue: JString);
  end;

  JHttpURLConnectionClass = interface(JURLConnectionClass)
  ['{44B3D21B-601C-45C2-8810-BA3AB000E041}']
  end;

  [JavaSignature('java/net/HttpURLConnection')]
  JHttpURLConnection = interface(JURLConnection)
  ['{CC5A90C6-238B-4272-A065-0FBFE78323A5}']
    function getResponseCode: integer;
    function getResponseMessage: JString;
    procedure setChunkedStreamingMode(chunkLength: Integer);
    procedure setFixedLengthStreamingMode(contentLength: Integer);
    procedure setInstanceFollowRedirects(followRedirects: boolean);
    procedure setRequestMethod(method: JString);
  end;

  TJHttpURLConnection = class(TJavaGenericImport<JHttpURLConnectionClass, JHttpURLConnection>) end;

  JHttpsURLConnectionClass = interface(JHttpURLConnectionClass)
  ['{44B3D21B-601C-45C2-8810-BA3AB000E041}']
  end;

  [JavaSignature('javax/net/ssl/HttpsURLConnection')]
  JHttpsURLConnection = interface(JHttpURLConnection)
  ['{CC5A90C6-238B-4272-A065-0FBFE78323A5}']
  end;

  TJHttpsURLConnection = class(TJavaGenericImport<JHttpsURLConnectionClass, JHttpsURLConnection>) end;

  JURLClass = interface(JObjectClass)
  ['{E1E70842-B896-42BC-A0FF-CD62639B7E61}']
    function init(spec: JString): JURL;
  end;

  [JavaSignature('java/net/URL')]
  JURL = interface(JObject)
  ['{A441E03F-CB6E-4492-BDCA-C1AA6301DC97}']
    function openConnection: JURLConnection; overload;
    function openConnection(proxy: JProxy): JURLConnection; overload;
  end;

  TJURL = class(TJavaGenericImport<JURLClass, JURL>) end;

  JURIClass = interface(JObjectClass)
  ['{E1E70842-B896-42BC-A0FF-CD62639B7E61}']
    function init(spec: JString): JURI;
  end;

  [JavaSignature('java/net/URI')]
  JURI = interface(JObject)
  ['{A441E03F-CB6E-4492-BDCA-C1AA6301DC97}']
  end;

  TJURI = class(TJavaGenericImport<JURIClass, JURI>) end;

  JFilterInputStreamClass = interface(JInputStreamClass)
  ['{7C7C6AD2-E0EB-496E-9B4A-B55BAD5AD129}']
  end;

  [JavaSignature('java/io/FilterInputStream')]
  JFilterInputStream = interface(JInputStream)
  ['{8B6E7548-6703-465C-A36E-69FA1678179A}']
  end;

  JBufferedInputStreamClass = interface(JFilterInputStreamClass)
  ['{7C7C6AD2-E0EB-496E-9B4A-B55BAD5AD129}']
    function init(inStream: JInputStream): JBufferedInputStream;
  end;

  [JavaSignature('java/io/BufferedInputStream')]
  JBufferedInputStream = interface(JFilterInputStream)
  ['{8B6E7548-6703-465C-A36E-69FA1678179A}']
  end;

  TJBufferedInputStream = class(TJavaGenericImport<JBufferedInputStreamClass, JBufferedInputStream>) end;

  JFilterOutputStreamClass = interface(JOutputStreamClass)
  ['{B6F15E14-6C0B-4BF3-BC07-6F7D9BA5BF92}']
  end;

  [JavaSignature('java/io/FilterOutputStream')]
  JFilterOutputStream = interface(JOutputStream)
  ['{B9892C9F-3FA1-4C96-A439-7497A7376337}']
  end;

  JBufferedOutputStreamClass = interface(JFilterOutputStreamClass)
  ['{BE80BA55-6EAC-4B22-A650-4F88759DF34D}']
    function init(outStream: JOutputStream): JBufferedOutputStream;
  end;

  [JavaSignature('java/io/BufferedOutputStream')]
  JBufferedOutputStream = interface(JFilterOutputStream)
  ['{BA5FEF66-5F51-4BD3-B2D2-0640ACB1662D}']
  end;

  TJBufferedOutputStream = class(TJavaGenericImport<JBufferedOutputStreamClass, JBufferedOutputStream>) end;

  JProxySelectorClass = interface(JObjectClass)
  ['{8EDE5748-D2BA-4D06-B46A-500A38AECB89}']
    function getDefault: JProxySelector;
  end;

  [JavaSignature('java/net/ProxySelector')]
  JProxySelector = interface(JObject)
  ['{0EB60327-C35B-4B64-8328-155EFE14AA51}']
    function select(uri: JURI): JList;
  end;

  TJProxySelector = class(TJavaGenericImport<JProxySelectorClass, JProxySelector>) end;

  JProxyClass = interface(JObjectClass)
  ['{44352A37-B4B6-49AC-9CFE-F27C6D10BD45}']
  end;

  [JavaSignature('java/net/Proxy')]
  JProxy = interface(JObject)
  ['{0EB60327-C35B-4B64-8328-155EFE14AA51}']
  end;

  TJProxy = class(TJavaGenericImport<JProxyClass, JProxy>) end;

{$ENDIF}

implementation

end.
