ftp://ftp.redhat.com/pub/redhat/linux/rawhide/SRPMS/SRPMS/gnome-vfs2-2.3.8-1.src.rpm
[gnome-vfs-httpcaptive.git] / monikers / bonobo-moniker-vfs.c
1 /*
2  * bonobo-moniker-file.c: Sample file-system based Moniker implementation
3  *
4  * This is the file-system based Moniker implementation.
5  *
6  * Author:
7  *      Michael Meeks (michael@helixcode.com)
8  *
9  * Copyright 2000, Helix Code, Inc.
10  */
11 #include <config.h>
12 #include <string.h>
13 #include <bonobo/bonobo-exception.h>
14 #include <bonobo/bonobo-storage.h>
15 #include <bonobo/bonobo-moniker-util.h>
16
17 #include "gnome-moniker-std.h"
18 #include "bonobo-stream-vfs.h"
19 #include "bonobo-storage-vfs.h"
20
21 Bonobo_Unknown
22 bonobo_moniker_vfs_resolve (BonoboMoniker               *moniker,
23                             const Bonobo_ResolveOptions *options,
24                             const CORBA_char            *requested_interface,
25                             CORBA_Environment           *ev)
26 {
27         const char    *fname = bonobo_moniker_get_name (moniker);
28
29         if (!strcmp (requested_interface, "IDL:Bonobo/Stream:1.0")) {
30                 BonoboObject *stream;
31                 
32                 stream = BONOBO_OBJECT (bonobo_stream_vfs_open (
33                         fname, Bonobo_Storage_READ, ev));
34
35                 if (BONOBO_EX (ev))
36                         return CORBA_OBJECT_NIL;
37
38                 if (!stream) {
39                         g_warning ("Failed to open stream '%s'", fname);
40                         CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
41                                              ex_Bonobo_Moniker_InterfaceNotFound, NULL);
42                         return CORBA_OBJECT_NIL;
43                 }
44                 return CORBA_Object_duplicate (BONOBO_OBJREF (stream), ev);
45
46         }
47         else if (!strcmp (requested_interface, "IDL:Bonobo/Storage:1.0")) {
48                 BonoboObject *storage;
49                 
50                 storage = BONOBO_OBJECT (bonobo_storage_vfs_open (
51                         fname, Bonobo_Storage_READ, ev));
52
53                 if (BONOBO_EX (ev))
54                         return CORBA_OBJECT_NIL;
55
56                 if (!storage) {
57                         g_warning ("Failed to open storage '%s'", fname);
58                         CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
59                                              ex_Bonobo_Moniker_InterfaceNotFound, NULL);
60                         return CORBA_OBJECT_NIL;
61                 }
62
63                 return CORBA_Object_duplicate (BONOBO_OBJREF (storage), ev);
64         }
65         else
66                 return bonobo_moniker_use_extender (
67                         "OAFIID:Bonobo_MonikerExtender_stream",
68                         moniker, options, requested_interface, ev);
69 }