Re: Vfs::Transfer callback argument





Murray Cumming wrote:
On Tue, 2007-06-05 at 22:11 +0200, Sergio Perticone wrote:
John Spray wrote:
Hello,

 > ---8<--------
Surely this argument should either be mandatory, or have a default value
that works?
Uhm, I think it shouldn't be mandatory (theoretically), in gtk when you call gnome_vfs_xfer_uri() you can ignore the callback using NULL, NULL as last 2 arguments.
Maybe Vfs::Transfer::transfer() should be wrapped following this way...

We could add a method overload that does not have that last parameter. A
patch would be welcome.


Well, I tried this (see attachments).
Basically the "old" transfer() is overloaded with a new transfer() :

transfer(const <string or uri> src, const <string or uri> target,
           TransferOptions options = XFER_DEFAULT,
           ErrorMode error_mode = XFER_ERROR_MODE_ABORT,
           OverwriteMode overwrite_mode = XFER_OVERWRITE_MODE_ABORT)

The "old" function now is:

transfer(const <string or uri> src, const <string or uri> target,
           TransferOptions options,
           ErrorMode error_mode,
           OverwriteMode overwrite_mode,
           const SlotProgress& progress_callback)

The arguments are mandatory (to avoid ambiguity), if you don't like this
we can "move" SlotProgress argument back...

I changed also functions with std::auto_ptr<> parameter

The patches are against gnome-vfsmm-2.18.0

Bye,

s.





--- gnome-vfsmm-2.18.0-orig/libgnomevfs/libgnomevfsmm/transfer.h	2007-03-10 00:26:56.000000000 +0100
+++ gnome-vfsmm-2.18.0/libgnomevfs/libgnomevfsmm/transfer.h	2007-06-06 16:09:28.000000000 +0200
@@ -98,16 +98,45 @@
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
 void transfer(const Glib::ustring& source_uri, const Glib::ustring& target_uri,
+      TransferOptions options,
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode,
+      const SlotProgress& progress_callback);
+#else
+void transfer(const Glib::ustring& source_uri, const Glib::ustring& target_uri,
+      TransferOptions options,
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode,
+      const SlotProgress& progress_callback,
+      std::auto_ptr<Gnome::Vfs::exception>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+      
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+void transfer(const Glib::RefPtr<const Uri>& source_uri, const Glib::RefPtr<const Uri>& target_uri,
+      TransferOptions options,
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode,
+      const SlotProgress& progress_callback);
+#else
+void transfer(const Glib::RefPtr<const Uri>& source_uri, const Glib::RefPtr<const Uri>& target_uri,
+      TransferOptions options,
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode,
+      const SlotProgress& progress_callback,
+      std::auto_ptr<Gnome::Vfs::exception>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+void transfer(const Glib::ustring& source_uri, const Glib::ustring& target_uri,
       TransferOptions options = XFER_DEFAULT, //TODO: Does Default do anything useful?
       ErrorMode error_mode = XFER_ERROR_MODE_ABORT,
-      OverwriteMode overwrite_mode = XFER_OVERWRITE_MODE_ABORT,
-      const SlotProgress& progress_callback = SlotProgress());
+      OverwriteMode overwrite_mode = XFER_OVERWRITE_MODE_ABORT);
+
 #else
 void transfer(const Glib::ustring& source_uri, const Glib::ustring& target_uri,
-      TransferOptions options, //TODO: Does Default do anything useful?
+      TransferOptions options, 
       ErrorMode error_mode,
       OverwriteMode overwrite_mode,
-      const SlotProgress& progress_callback,
       std::auto_ptr<Gnome::Vfs::exception>& error);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
       
@@ -115,14 +144,12 @@
 void transfer(const Glib::RefPtr<const Uri>& source_uri, const Glib::RefPtr<const Uri>& target_uri,
       TransferOptions options = XFER_DEFAULT, //TODO: Does Default do anything useful?
       ErrorMode error_mode = XFER_ERROR_MODE_ABORT,
-      OverwriteMode overwrite_mode = XFER_OVERWRITE_MODE_ABORT,
-      const SlotProgress& progress_callback = SlotProgress());
+      OverwriteMode overwrite_mode = XFER_OVERWRITE_MODE_ABORT);
 #else
 void transfer(const Glib::RefPtr<const Uri>& source_uri, const Glib::RefPtr<const Uri>& target_uri,
-      TransferOptions options, //TODO: Does Default do anything useful?
+      TransferOptions options, 
       ErrorMode error_mode,
       OverwriteMode overwrite_mode,
-      const SlotProgress& progress_callback,
       std::auto_ptr<Gnome::Vfs::exception>& error);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
 
@@ -168,7 +195,7 @@
 void remove_list_uris(const ListHandleUris& source_uri_list,
       TransferOptions options,
       ErrorMode error_mode,
-      const SlotProgress& progress_callbacki,
+      const SlotProgress& progress_callback,
       std::auto_ptr<Gnome::Vfs::exception>& error);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
 




--- gnome-vfsmm-2.18.0-orig/libgnomevfs/libgnomevfsmm/transfer.cc	2007-03-10 00:26:56.000000000 +0100
+++ gnome-vfsmm-2.18.0/libgnomevfs/libgnomevfsmm/transfer.cc	2007-06-06 15:46:41.000000000 +0200
@@ -203,6 +203,53 @@
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
+void transfer(const Glib::ustring& source_uri, const Glib::ustring& target_uri,
+      TransferOptions options,
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode)
+#else
+void transfer(const Glib::ustring& source_uri, const Glib::ustring& target_uri,
+      TransferOptions options,
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode,
+      std::auto_ptr<Gnome::Vfs::exception>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+  return transfer( Uri::create(source_uri), Uri::create(target_uri), options, error_mode, overwrite_mode);
+  #else
+  return transfer( Uri::create(source_uri), Uri::create(target_uri), options, error_mode, overwrite_mode, error);
+  #endif //GLIBMM_EXCEPTIONS_ENABLED
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+void transfer(const Glib::RefPtr<const Uri>& source_uri, const Glib::RefPtr<const Uri>& target_uri,
+      TransferOptions options, 
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode)
+
+#else
+void transfer(const Glib::RefPtr<const Uri>& source_uri, const Glib::RefPtr<const Uri>& target_uri,
+      TransferOptions options, 
+      ErrorMode error_mode,
+      OverwriteMode overwrite_mode,
+      std::auto_ptr<Gnome::Vfs::exception>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+  GnomeVFSResult result = gnome_vfs_xfer_uri(source_uri->gobj(), target_uri->gobj(),
+    static_cast<GnomeVFSXferOptions>(options),
+    static_cast<GnomeVFSXferErrorMode>(error_mode),
+    static_cast<GnomeVFSXferOverwriteMode>(overwrite_mode),
+    NULL, NULL);
+    
+  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+  handle_result(result);
+  #else
+  handle_result(result, error);
+  #endif //GLIBMM_EXCEPTIONS_ENABLED
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
 void remove(const Glib::ustring& source_uri,
       TransferOptions options,
       ErrorMode error_mode,





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]