Home | History | Annotate | Download | only in win32
      1 /* GIO - GLib Input, Output and Streaming Library
      2  *
      3  * Copyright (C) 2006-2007 Red Hat, Inc.
      4  * Copyright (C) 2008 Novell, Inc.
      5  *
      6  * This library is free software; you can redistribute it and/or
      7  * modify it under the terms of the GNU Lesser General Public
      8  * License as published by the Free Software Foundation; either
      9  * version 2 of the License, or (at your option) any later version.
     10  *
     11  * This library is distributed in the hope that it will be useful,
     12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14  * Lesser General Public License for more details.
     15  *
     16  * You should have received a copy of the GNU Lesser General
     17  * Public License along with this library; if not, write to the
     18  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
     19  * Boston, MA 02111-1307, USA.
     20  *
     21  * Author: Alexander Larsson <alexl (at) redhat.com>
     22  * Author: Tor Lillqvist <tml (at) novell.com>
     23  */
     24 
     25 #ifndef __G_WINHTTP_VFS_H__
     26 #define __G_WINHTTP_VFS_H__
     27 
     28 #include <gio/giotypes.h>
     29 
     30 #include "gvfs.h"
     31 
     32 #define _WIN32_WINNT 0x0500
     33 #include <windows.h>
     34 
     35 #include "winhttp.h"
     36 
     37 G_BEGIN_DECLS
     38 
     39 #define G_TYPE_WINHTTP_VFS                      (_g_winhttp_vfs_get_type ())
     40 #define G_WINHTTP_VFS(obj)                      (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_WINHTTP_VFS, GWinHttpVfs))
     41 #define G_WINHTTP_VFS_CLASS(klass)              (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_WINHTTP_VFS, GWinHttpVfsClass))
     42 #define G_IS_WINHTTP_VFS(obj)                   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_WINHTTP_VFS))
     43 #define G_IS_WINHTTP_VFS_CLASS(klass)           (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_WINHTTP_VFS))
     44 #define G_WINHTTP_VFS_GET_CLASS(obj)            (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_WINHTTP_VFS, GWinHttpVfsClass))
     45 
     46 typedef struct _GWinHttpVfs       GWinHttpVfs;
     47 typedef struct _GWinHttpDllFuncs  GWinHttpDllFuncs;
     48 typedef struct _GWinHttpVfsClass  GWinHttpVfsClass;
     49 
     50 struct _GWinHttpVfs
     51 {
     52   GVfs parent;
     53 
     54   GVfs *wrapped_vfs;
     55   HINTERNET session;
     56 };
     57 
     58 struct _GWinHttpDllFuncs
     59 {
     60   BOOL (WINAPI *pWinHttpCloseHandle) (HINTERNET);
     61   BOOL (WINAPI *pWinHttpCrackUrl) (LPCWSTR,DWORD,DWORD,LPURL_COMPONENTS);
     62   HINTERNET (WINAPI *pWinHttpConnect) (HINTERNET,LPCWSTR,INTERNET_PORT,DWORD);
     63   BOOL (WINAPI *pWinHttpCreateUrl) (LPURL_COMPONENTS,DWORD,LPWSTR,LPDWORD);
     64   HINTERNET (WINAPI *pWinHttpOpen) (LPCWSTR,DWORD,LPCWSTR,LPCWSTR,DWORD);
     65   HINTERNET (WINAPI *pWinHttpOpenRequest) (HINTERNET,LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR*,DWORD);
     66   BOOL (WINAPI *pWinHttpQueryDataAvailable) (HINTERNET,LPDWORD);
     67   BOOL (WINAPI *pWinHttpQueryHeaders) (HINTERNET,DWORD,LPCWSTR,LPVOID,LPDWORD,LPDWORD);
     68   BOOL (WINAPI *pWinHttpReadData) (HINTERNET,LPVOID,DWORD,LPDWORD);
     69   BOOL (WINAPI *pWinHttpReceiveResponse) (HINTERNET,LPVOID);
     70   BOOL (WINAPI *pWinHttpSendRequest) (HINTERNET,LPCWSTR,DWORD,LPVOID,DWORD,DWORD,DWORD_PTR);
     71   BOOL (WINAPI *pWinHttpWriteData) (HINTERNET,LPCVOID,DWORD,LPDWORD);
     72 };
     73 
     74 struct _GWinHttpVfsClass
     75 {
     76   GVfsClass parent_class;
     77 
     78   /* As there is no import library for winhttp.dll in mingw, and
     79    * winhttp.dll isn't present on Windows 2000 anyway, we must look up
     80    * the functions we need dynamically. Store the pointers here.
     81    */
     82   GWinHttpDllFuncs *funcs;
     83 };
     84 
     85 
     86 GType   _g_winhttp_vfs_get_type  (void) G_GNUC_CONST;
     87 
     88 GVfs *_g_winhttp_vfs_new (void);
     89 
     90 char *_g_winhttp_error_message (DWORD error_code);
     91 
     92 void _g_winhttp_set_error (GError     **error,
     93                            DWORD        error_code,
     94                            const char  *what);
     95 
     96 gboolean _g_winhttp_response (GWinHttpVfs *vfs,
     97                               HINTERNET    request,
     98                               GError     **error,
     99                               const char  *what);
    100 
    101 gboolean _g_winhttp_query_header (GWinHttpVfs *vfs,
    102                                   HINTERNET    request,
    103                                   const char  *request_description,
    104                                   DWORD        which_header,
    105                                   wchar_t    **header,
    106                                   GError     **error);
    107 
    108 G_END_DECLS
    109 
    110 #endif /* __G_WINHTTP_VFS_H__ */
    111