X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fwin32%2Fgwinhttpfileoutputstream.c;h=760a87a1c51da9c5fd2a321b3662723de5ef7639;hb=7103484017ff000d01ed94567539d37fa09b32b2;hp=898a72993ac58d43f7e20b246b374ae04f783652;hpb=af8ebc9e552b6062e916c1bfc3982de8da4340d4;p=platform%2Fupstream%2Fglib.git
diff --git a/gio/win32/gwinhttpfileoutputstream.c b/gio/win32/gwinhttpfileoutputstream.c
index 898a729..760a87a 100644
--- a/gio/win32/gwinhttpfileoutputstream.c
+++ b/gio/win32/gwinhttpfileoutputstream.c
@@ -1,5 +1,5 @@
/* GIO - GLib Input, Output and Streaming Library
- *
+ *
* Copyright (C) 2006-2007 Red Hat, Inc.
* Copyright (C) 2008 Novell, Inc.
*
@@ -14,9 +14,7 @@
* 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 .
*
* Author: Alexander Larsson
* Author: Tor Lillqvist
@@ -26,13 +24,11 @@
#include
-#include "gcancellable.h"
-#include "gioerror.h"
+#include "gio/gcancellable.h"
+#include "gio/gioerror.h"
#include "gwinhttpfileoutputstream.h"
#include "glibintl.h"
-#include "gioalias.h"
-
struct _GWinHttpFileOutputStream
{
GFileOutputStream parent_instance;
@@ -60,11 +56,11 @@ static void
g_winhttp_file_output_stream_finalize (GObject *object)
{
GWinHttpFileOutputStream *winhttp_stream;
-
+
winhttp_stream = G_WINHTTP_FILE_OUTPUT_STREAM (object);
if (winhttp_stream->connection != NULL)
- G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->pWinHttpCloseHandle (winhttp_stream->connection);
+ G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpCloseHandle (winhttp_stream->connection);
G_OBJECT_CLASS (g_winhttp_file_output_stream_parent_class)->finalize (object);
}
@@ -74,7 +70,7 @@ g_winhttp_file_output_stream_class_init (GWinHttpFileOutputStreamClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GOutputStreamClass *stream_class = G_OUTPUT_STREAM_CLASS (klass);
-
+
gobject_class->finalize = g_winhttp_file_output_stream_finalize;
stream_class->write_fn = g_winhttp_file_output_stream_write;
@@ -87,12 +83,12 @@ g_winhttp_file_output_stream_init (GWinHttpFileOutputStream *info)
/**
* g_winhttp_file_output_stream_new:
- * @file: the GWinHttpFile being read
+ * @file: the GWinHttpFile being read
* @connection: handle to the HTTP connection, as from WinHttpConnect()
* @request: handle to the HTTP request, as from WinHttpOpenRequest
- *
+ *
* Returns: #GFileOutputStream for the given request
- **/
+ */
GFileOutputStream *
_g_winhttp_file_output_stream_new (GWinHttpFile *file,
HINTERNET connection)
@@ -121,7 +117,7 @@ g_winhttp_file_output_stream_write (GOutputStream *stream,
wchar_t *wheaders;
DWORD bytes_written;
- request = G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->pWinHttpOpenRequest
+ request = G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpOpenRequest
(winhttp_stream->connection,
L"PUT",
winhttp_stream->file->url.lpszUrlPath,
@@ -132,12 +128,7 @@ g_winhttp_file_output_stream_write (GOutputStream *stream,
if (request == NULL)
{
- char *emsg = _g_winhttp_error_message (GetLastError ());
-
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_FAILED,
- "%s", emsg);
- g_free (emsg);
+ _g_winhttp_set_error (error, GetLastError (), "PUT request");
return -1;
}
@@ -147,58 +138,46 @@ g_winhttp_file_output_stream_write (GOutputStream *stream,
wheaders = g_utf8_to_utf16 (headers, -1, NULL, NULL, NULL);
g_free (headers);
- if (!G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->pWinHttpSendRequest
+ if (!G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpSendRequest
(request,
wheaders, -1,
NULL, 0,
count,
0))
{
- char *emsg = _g_winhttp_error_message (GetLastError ());
-
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_FAILED,
- "%s", emsg);
- g_free (emsg);
-
- G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->pWinHttpCloseHandle (request);
+ _g_winhttp_set_error (error, GetLastError (), "PUT request");
+
+ G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpCloseHandle (request);
g_free (wheaders);
return -1;
}
-
+
g_free (wheaders);
- if (!G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->pWinHttpWriteData
+ if (!G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpWriteData
(request, buffer, count, &bytes_written))
{
- char *emsg = _g_winhttp_error_message (GetLastError ());
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "%s",
- emsg);
- g_free (emsg);
+ _g_winhttp_set_error (error, GetLastError (), "PUT request");
- G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->pWinHttpCloseHandle (request);
+ G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpCloseHandle (request);
return -1;
}
-
+
winhttp_stream->offset += bytes_written;
- if (!G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->pWinHttpReceiveResponse
- (request, NULL))
+ if (!_g_winhttp_response (winhttp_stream->file->vfs,
+ request,
+ error,
+ "PUT request"))
{
- char *emsg = _g_winhttp_error_message (GetLastError ());
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "%s",
- emsg);
- g_free (emsg);
-
- G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->pWinHttpCloseHandle (request);
+ G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpCloseHandle (request);
+
return -1;
}
- G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->pWinHttpCloseHandle (request);
+ G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpCloseHandle (request);
return bytes_written;
}