gnome-vfs-sharp [00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00 71 EB 6C 55 75 52 9C BF 72 44 F7 A6 EA 05 62 84 F9 EA E0 3B CF F2 CC 13 2C 9C 49 0A B3 09 EA B0 B5 6B CE 44 9D F5 03 D9 C0 A8 1E 52 05 85 CD BE 70 E2 FB 90 43 4B AC 04 FA 62 22 A8 00 98 B7 A1 A7 B3 AF 99 1A 41 23 24 BB 43 25 F6 B8 65 BB 64 EB F6 D1 C2 06 D5 73 2D DF BC 70 A7 38 9E E5 3E 0C 24 6E 32 79 74 1A D0 05 03 E4 98 42 E1 9B F3 7B 19 8B 40 21 26 CB 36 89 C2 EA 64 96 A4 7C B4] 2.0.0.0 Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. Abstract class used by modules for asking an application for necessary information (authentication for example). using GLib; using Gnome.Vfs; using System; using System.Text; namespace Test.Gnome.Vfs { public class TestCallback { private static MainLoop loop; static void Main (string[] args) { if (args.Length != 1) { Console.WriteLine ("Usage: TestCallback <uri>"); return; } Gnome.Vfs.Vfs.Initialize (); Gnome.Vfs.Uri uri = new Gnome.Vfs.Uri (args[0]); Handle handle; // Test 1: Attempt to access a URI requiring authentication w/o a callback registered. try { handle = Sync.Open (uri, OpenMode.Read); Sync.Close (handle); Console.WriteLine ("Uri '{0}' doesn't require authentication", uri); return; } catch (VfsException ex) { if (ex.Result != Result.ErrorAccessDenied) throw ex; } // Test 2: Attempt an open that requires authentication. ModuleCallbackFullAuthentication cb = new ModuleCallbackFullAuthentication (); cb.Callback += new ModuleCallbackHandler (OnAuthenticate); cb.SetDefault (); handle = Sync.Open (uri, OpenMode.Read); Sync.Close (handle); // Test 3: This call should not require any new authentication. Console.WriteLine ("File info: \n{0}", uri.GetFileInfo ()); // Test 4: Attempt a call to the parent uri. FileInfo[] entries = Directory.GetEntries (uri.Parent); Console.WriteLine ("Directory '{0}' has {1} entries", uri.Parent, entries.Length); // Test 5: Pop the authentication callback and try again. cb.Pop (); try { handle = Sync.Open (uri, OpenMode.Read); } catch (VfsException ex) { if (ex.Result != Result.ErrorAccessDenied) throw ex; } Gnome.Vfs.Vfs.Shutdown (); } private static void OnAuthenticate (ModuleCallback cb) { ModuleCallbackFullAuthentication fcb = cb as ModuleCallbackFullAuthentication; Console.Write ("Enter your username ({0}): ", fcb.Username); string username = Console.ReadLine (); Console.Write ("Enter your password : "); string passwd = Console.ReadLine (); if (username.Length > 0) fcb.Username = username; fcb.Password = passwd; } } } System.Object Method System.Void Set this ModuleCallback as a temporary handler. will be called on the same thread as the gnome-vfs operation that invokes it. The temporary handler is set per-thread. removes the most recently set temporary handler. The temporary handlers are treated as a first-in first-out stack. Use this function to set a temporary callback handler for a single call or a few calls. You can use to set a callback function that will establish a permanent global setting for all threads instead. Method System.Void Remove the temporary handler set with . If another temporary handler was previously set on the same thread, it becomes the current handler. Otherwise, the default handler, if any, becomes current. The temporary handlers are treated as a first-in first-out stack. Method System.Void Set this as the default handler. will be called on the same thread as the gnome-vfs operation that invokes it. The default value is shared for all threads, but setting it is thread-safe. Use this function if you want to set a handler to be used by your whole application. You can use to set a callback function that will temporarily override the default on the current thread instead. Or you can also use to set an async callback function. Method System.Void Set as a temprary async handler. will be called from a callback on the main thread. It will be passed a response function which should be called to signal completion of the callback. The callback function itself may return in the meantime. The temporary async handler is set per-thread. removes the most recently set temporary temporary handler. The temporary async handlers are treated as a first-in first-out stack. Use this function to set a temporary async callback handler for a single call or a few calls. You can use to set an async callback function that will establish a permanent global setting for all threads instead. Method System.Void Remove the temporary async handler most recently set with . If another temporary async handler was previously set on the same thread, it becomes the current handler. Otherwise, the default async handler, if any, becomes current. The temporary async handlers are treated as a first-in first-out stack. Method System.Void Set the default async callback. will be called from a callback on the main thread. It will be passed a response function which should be called to signal completion of the callback. The callback function itself may return in the meantime. The default value is shared for all threads, but setting it is thread-safe. Use this function if you want to globally set a callback handler for use with async operations. You can use to set an async callback function that will temporarily override the default on the current thread instead. Or you can also use to set a regular callback function. Constructor To be added To be added Event Gnome.Vfs.ModuleCallbackHandler Event which is called when a gnome-vfs module requires additional information from an application such as authentication. Implementations of have properties such as which can be retrieved and set from the handler. These properties are only valid during the callback activation.