- /* Create the tinymail stream: */
- /* Presumably tinymai will call gnome_vfs_close (handle) later. */
- result = TNY_STREAM (tny_vfs_stream_new (handle));
+ TnyStream *vfssstream = TNY_STREAM (tny_vfs_stream_new (handle));
+ /* Streams over OBEX (Bluetooth) are not seekable but
+ * we expect them to be (we might need to read them
+ * several times). So if this is a Bluetooth URI just
+ * read the whole file into memory (this is not a fast
+ * protocol so we can assume that these files are not
+ * going to be very big) */
+ if ((g_ascii_strncasecmp (uri, "obex://", 7) == 0)||
+ (g_ascii_strncasecmp (uri, "upnpav://", 9) == 0)) {
+ TnyStream *memstream = tny_camel_mem_stream_new ();
+ tny_stream_write_to_stream (vfssstream, memstream);
+ g_object_unref (vfssstream);
+ result = memstream;
+ } else {
+ result = vfssstream;
+ }