Changeset 960

Show
Ignore:
Timestamp:
09/15/06 01:01:56
Author:
pvanhoof
Message:

Bugfixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r958 r960  
    33        * Bugfixes in the list types found after improving a few unit tests 
    44        * Bugfixes in the stream types found after improving a few unit tests 
     5        * Fixed the TnyFsStream, TnyGtkTextBufferStream and TnyVfsStream types 
    56 
    672006-09-13  Philip Van Hoof <pvanhoof@gnome.org> 
  • trunk/docs/devel/reference/tmpl/tny-session-camel-priv.sgml

    r953 r960  
    1010</para> 
    1111 
    12  
    1312<!-- ##### SECTION See_Also ##### --> 
    1413<para> 
     
    1615</para> 
    1716 
    18  
    1917<!-- ##### SECTION Stability_Level ##### --> 
    2018 
  • trunk/libtinymail-gnomevfs/tny-vfs-stream.c

    r900 r960  
    199199        if (G_LIKELY (res == GNOME_VFS_OK)) 
    200200        { 
    201                 priv->eos = FALSE; 
     201                gchar buf[1]; GnomeVFSResult res2; 
     202                GnomeVFSFileSize curpos, cnt; 
     203                gnome_vfs_tell (priv->handle, &curpos); 
     204                res2 = gnome_vfs_read (priv->handle, buf, 1, &cnt); 
     205                gnome_vfs_seek (priv->handle, GNOME_VFS_SEEK_START, curpos); 
     206                if (res2 == GNOME_VFS_ERROR_EOF) 
     207                        priv->eos = TRUE; 
     208                else priv->eos = FALSE; 
     209             
    202210                return (ssize_t)count; 
    203211 
     
    227235 
    228236        res = gnome_vfs_write (priv->handle, buffer, n, &count); 
     237        priv->eos = FALSE; 
    229238        if (G_LIKELY (res == GNOME_VFS_OK)) 
    230239                return (ssize_t)count; 
     
    251260 
    252261        priv->handle = NULL; 
    253  
     262        priv->eos = TRUE; 
     263     
    254264        if (res == GNOME_VFS_OK) 
    255265                return 0; 
     
    260270} 
    261271 
    262 /* 
    263  
    264 static off_t 
    265 tny_vfs_stream_seek (TnySeekableStream *stream, off_t offset, TnyStreamSeekPolicy policy) 
    266 { 
    267         TnyVfsStreamPriv *priv = TNY_VFS_STREAM_GET_PRIVATE (self); 
    268         GnomeVFSSeekPosition vpolicy; 
    269         GnomeVFSFileSize pos; 
    270         GnomeVFSResult res; 
    271  
    272         if (priv->handle == NULL)  
    273         { 
    274                 errno = EINVAL; 
    275                 return -1; 
    276         } 
    277  
    278         switch (policy)  
    279         { 
    280                 case TNY_STREAM_SET: 
    281                 default: 
    282                         vpolicy = GNOME_VFS_SEEK_START; 
    283                         break; 
    284                 case TNY_STREAM_CUR: 
    285                         vpolicy = GNOME_VFS_SEEK_CURRENT; 
    286                         break; 
    287                 case TNY_STREAM_END: 
    288                         vpolicy = GNOME_VFS_SEEK_END; 
    289                         break; 
    290         } 
    291  
    292         if ( (res = gnome_vfs_seek (priv->handle, vpolicy, offset)) == GNOME_VFS_OK 
    293              && (res = gnome_vfs_tell(priv->handle, &pos)) == GNOME_VFS_OK) 
    294                 return pos; 
    295  
    296         tny_vfs_stream_set_errno (res); 
    297  
    298         return -1; 
    299 } 
    300  
    301 static off_t 
    302 tny_vfs_stream_tell (TnySeekableStream *stream) 
    303 { 
    304         TnyVfsStreamPriv *priv = TNY_VFS_STREAM_GET_PRIVATE (self); 
    305         GnomeVFSFileSize pos; 
    306         GnomeVFSResult res; 
    307  
    308         if (priv->handle == NULL)  
    309         { 
    310                 errno = EINVAL; 
    311                 return -1; 
    312         } 
    313  
    314         if ((res = gnome_vfs_tell (priv->handle, &pos)) == GNOME_VFS_OK) 
    315                 return pos; 
    316  
    317         tny_vfs_stream_set_errno (res); 
    318  
    319         return -1; 
    320 } 
    321  
    322 */ 
    323272 
    324273/** 
     
    339288 
    340289        priv->handle = handle; 
    341  
     290        priv->eos = FALSE; 
     291     
    342292        return; 
    343293} 
     
    351301 * Return value: a new #TnyStream instance 
    352302 **/ 
    353 TnyVfsStream* 
     303TnyStream* 
    354304tny_vfs_stream_new (GnomeVFSHandle *handle) 
    355305{ 
     
    358308        tny_vfs_stream_set_handle (self, handle); 
    359309 
    360         return self
     310        return TNY_STREAM (self)
    361311} 
    362312 
     
    421371                retval = -1; 
    422372        } 
    423  
     373        priv->eos = FALSE; 
     374     
    424375        return retval; 
    425376} 
  • trunk/libtinymail-gnomevfs/tny-vfs-stream.h

    r900 r960  
    5050 
    5151GType                   tny_vfs_stream_get_type        (void); 
    52 TnyVfsStream*           tny_vfs_stream_new             (GnomeVFSHandle *handle); 
     52TnyStream*              tny_vfs_stream_new             (GnomeVFSHandle *handle); 
    5353 
    5454void                    tny_vfs_stream_set_handle (TnyVfsStream *self, GnomeVFSHandle *handle); 
  • trunk/libtinymail-test/Makefile.am

    r959 r960  
    66        -I$(top_srcdir)/libtinymailui           \ 
    77        -I$(top_srcdir)/libtinymailui-gtk       \ 
    8         -I$(top_srcdir)/libtinymail-camel 
     8        -I$(top_srcdir)/libtinymail-camel       \ 
     9        -I$(top_srcdir)/libtinymail-gnomevfs 
    910 
    1011if BUILD_GNOME 
  • trunk/libtinymail-test/tny-test-anything.c

    r959 r960  
    1515#include <tny-test-stream.h> 
    1616#include <tny-fs-stream.h> 
     17#include <tny-vfs-stream.h> 
    1718 
    18 static TnyStream *cmstream = NULL, *fstream, *tbstream = NULL, *source = NULL; 
     19static TnyStream *cmstream = NULL, *vfsstream = NULL, *fstream, *tbstream = NULL, *source = NULL; 
    1920 
    2021 
     
    2526        gchar *tmpl = g_strdup ("/tmp/tinymail-stream-test.XXXXXX"); 
    2627        gint filed = g_mkstemp (tmpl); 
     28        gchar *gvfs = g_strdup_printf ("file://%s", tmpl); 
     29        GnomeVFSHandle *handle; 
     30        GnomeVFSResult result; 
    2731     
    2832        if (filed == -1) 
     
    3236     
    3337        gtk_init (&argc, &argv); 
    34         g_thread_init (NULL); 
     38        gnome_vfs_init (); 
     39         
     40        close (filed); 
    3541     
     42        result = gnome_vfs_create (&handle,gvfs,GNOME_VFS_OPEN_WRITE|GNOME_VFS_OPEN_READ,FALSE,0777); 
    3643        view = GTK_TEXT_VIEW (gtk_text_view_new ()); 
    3744        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); 
     
    4653        source = TNY_STREAM (tny_test_stream_new ()); 
    4754        fstream = tny_fs_stream_new (filed); 
     55        if (result == GNOME_VFS_OK) 
     56                vfsstream = tny_vfs_stream_new (handle); 
     57        else printf ("Problem with vfs (%s, %d, %d)\n", gvfs,result,GNOME_VFS_ERROR_INVALID_OPEN_MODE); 
    4858     
    49      TnyStream *streams [1] = { fstream }; 
     59     TnyStream *streams [1] = { vfsstream }; 
    5060    int te=0; 
    5161     
  • trunk/libtinymailui-gtk/tny-gtk-save-strategy.c

    r908 r960  
    5757        GnomeVFSResult result; 
    5858        GnomeVFSHandle *handle; 
    59         TnyVfsStream *stream = NULL; 
     59        TnyStream *stream = NULL; 
    6060 
    6161        result = gnome_vfs_create (&handle, uri,  
     
    6666 
    6767        stream = tny_vfs_stream_new (handle); 
    68         tny_mime_part_decode_to_stream (part, TNY_STREAM (stream)); 
     68        tny_mime_part_decode_to_stream (part, stream); 
    6969 
    7070        /* This also closes the gnome-vfs handle (maybe it shouldn't?) */