* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Alexander Larsson <alexl@redhat.com>
* Author: Tor Lillqvist <tml@novell.com>
#include <glib.h>
-#include "gcancellable.h"
-#include "gioerror.h"
+#include "gio/gcancellable.h"
+#include "gio/gioerror.h"
#include "gwinhttpfileinputstream.h"
#include "glibintl.h"
-#include "gioalias.h"
-
struct _GWinHttpFileInputStream
{
GFileInputStream parent_instance;
GCancellable *cancellable,
GError **error);
+static gboolean g_winhttp_file_input_stream_close (GInputStream *stream,
+ GCancellable *cancellable,
+ GError **error);
+
static void
g_winhttp_file_input_stream_finalize (GObject *object)
{
if (winhttp_stream->connection != NULL)
G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpCloseHandle (winhttp_stream->connection);
+ g_object_unref (winhttp_stream->file);
+ winhttp_stream->file = NULL;
+
G_OBJECT_CLASS (g_winhttp_file_input_stream_parent_class)->finalize (object);
}
gobject_class->finalize = g_winhttp_file_input_stream_finalize;
stream_class->read_fn = g_winhttp_file_input_stream_read;
+ stream_class->close_fn = g_winhttp_file_input_stream_close;
}
static void
* @request: handle to the HTTP request, as from WinHttpOpenRequest
*
* Returns: #GFileInputStream for the given request
- **/
+ */
GFileInputStream *
_g_winhttp_file_input_stream_new (GWinHttpFile *file,
HINTERNET connection,
stream = g_object_new (G_TYPE_WINHTTP_FILE_INPUT_STREAM, NULL);
- stream->file = file;
+ stream->file = g_object_ref (file);
stream->request_sent = FALSE;
stream->connection = connection;
stream->request = request;
return bytes_read;
}
+
+static gboolean
+g_winhttp_file_input_stream_close (GInputStream *stream,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GWinHttpFileInputStream *winhttp_stream = G_WINHTTP_FILE_INPUT_STREAM (stream);
+
+ if (winhttp_stream->connection != NULL)
+ G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpCloseHandle (winhttp_stream->connection);
+ winhttp_stream->connection = NULL;
+ return TRUE;
+}