Re: Support for major_mime_type/*
- From: ERDI Gergo <cactus cactus rulez org>
- To: Michael Meeks <michael ximian com>
- Cc: gnome-components-list gnome org
- Subject: Re: Support for major_mime_type/*
- Date: Wed, 2 May 2001 21:06:25 +0200 (CEST)
On Wed, 2 May 2001, Michael Meeks wrote:
> Apart from that, it looks fine - can you make the changes, and
> send me a patch as you commit - also if you could checkout tmpbonobo and
See it attached
> make the mods to the moniker code there [blind] that'd be great - just so
> I remember it for G2.
I figured G2 would mean GNOME2. I don't think this should go in as-is into
the would-be-g2-bonobo (see my original mail for the explanation)
--
.--= ULLA! =---------------------. `We are not here to give users what
\ http://cactus.rulez.org \ they want' -- RMS, at GUADEC 2001
`---= cactus cactus rulez org =---'
Well I think so Brain, but if they called them sad meals the kids wouldn't buy them.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/bonobo/ChangeLog,v
retrieving revision 1.1051
diff -u -u -r1.1051 ChangeLog
--- ChangeLog 2001/05/01 18:54:49 1.1051
+++ ChangeLog 2001/05/02 18:29:53
@@ -1,3 +1,11 @@
+2001-05-02 ERDI Gergo <cactus cactus rulez org>
+
+ * monikers/bonobo-moniker-extender-file.c:
+ * monikers/bonobo-moniker-extender-stream.c: Query for components
+ that support every mime type that has the major mime type of the
+ current stream (e.g. query for text/* if the stream is of type
+ text/frobozz)
+
+ * bonobo/bonobo-stream.c (bonobo_internal_get_major_mime_type):
+ new internal function to get the major mime type (i.e. to get
+ `foo' from `foo/bar')
2001-05-01 Michael Meeks <michael ximian com>
* Version 1.0.3
Index: bonobo/bonobo-stream.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-stream.c,v
retrieving revision 1.31
diff -u -u -r1.31 bonobo-stream.c
--- bonobo/bonobo-stream.c 2000/12/13 16:29:01 1.31
+++ bonobo/bonobo-stream.c 2001/05/02 18:29:55
@@ -272,3 +272,27 @@
return bonobo_object_activate_servant (object, servant);
}
+
+/**
+ * bonobo_internal_get_major_mime_type:
+ *
+ * This is not the function you are looking for. In fact, you've never
+ * even heard of this function.
+ * But when you wake up, you will remember to g_free the result.
+ */
+gchar *
+bonobo_internal_get_major_mime_type (const char *mime_type)
+{
+ char *major_end;
+ char *major;
+ int major_length;
+
+ major_end = strchr (mime_type, '/');
+ if (!major_end)
+ return g_strdup (mime_type);
+
+ major_length = major_end - mime_type;
+ major = g_strndup (mime_type, major_length);
+
+ return major;
+}
Index: monikers/bonobo-moniker-extender-file.c
===================================================================
RCS file: /cvs/gnome/bonobo/monikers/bonobo-moniker-extender-file.c,v
retrieving revision 1.9
diff -u -u -r1.9 bonobo-moniker-extender-file.c
--- monikers/bonobo-moniker-extender-file.c 2001/03/16 12:26:31 1.9
+++ monikers/bonobo-moniker-extender-file.c 2001/05/02 18:30:03
@@ -17,6 +17,8 @@
#include "bonobo-moniker-std.h"
+extern gchar * bonobo_internal_get_major_mime_type (const char *mime_type);
+
Bonobo_Unknown
bonobo_file_extender_resolve (BonoboMonikerExtender *extender,
const Bonobo_Moniker m,
@@ -26,6 +28,7 @@
CORBA_Environment *ev)
{
const char *mime_type;
+ char *mime_type_major;
char *oaf_requirements;
Bonobo_Unknown object;
Bonobo_Persist persist;
@@ -42,19 +45,23 @@
g_warning ("Filename : '%s'", fname);
mime_type = gnome_mime_type (fname);
-
+ mime_type_major = bonobo_internal_get_major_mime_type (mime_type);
+
oaf_requirements = g_strdup_printf (
- "bonobo:supported_mime_types.has ('%s') AND repo_ids.has ('%s') AND "
+ "bonobo:supported_mime_types.has_one (['%s', '%s/*']) AND "
+ "repo_ids.has ('%s') AND "
"repo_ids.has ('IDL:Bonobo/PersistFile:1.0')",
- mime_type, requested_interface);
-
+ mime_type, mime_type_major,
+ requested_interface);
+
result = oaf_query (oaf_requirements, NULL, ev);
if (BONOBO_EX (ev) || result == NULL || result->_buffer == NULL ||
!result->_buffer[0].iid)
return CORBA_OBJECT_NIL;
g_free (oaf_requirements);
-
+ g_free (mime_type_major);
+
oafiid = g_strdup (result->_buffer[0].iid);
CORBA_free (result);
Index: monikers/bonobo-moniker-extender-stream.c
===================================================================
RCS file: /cvs/gnome/bonobo/monikers/bonobo-moniker-extender-stream.c,v
retrieving revision 1.4
diff -u -u -r1.4 bonobo-moniker-extender-stream.c
--- monikers/bonobo-moniker-extender-stream.c 2001/02/05 20:53:52 1.4
+++ monikers/bonobo-moniker-extender-stream.c 2001/05/02 18:30:03
@@ -17,23 +17,25 @@
#include "bonobo-moniker-std.h"
+extern gchar * bonobo_internal_get_major_mime_type (const char *mime_type);
+
static gchar *
get_stream_type (Bonobo_Stream stream, CORBA_Environment *ev)
{
Bonobo_StorageInfo *info;
gchar *type;
-
+
g_return_val_if_fail (stream != CORBA_OBJECT_NIL, NULL);
-
+
info = Bonobo_Stream_getInfo (stream, Bonobo_FIELD_CONTENT_TYPE, ev);
if (BONOBO_EX (ev)) /* FIXME: we could try and do it ourselfs here */
return NULL;
-
+
type = g_strdup (info->content_type);
-
+
CORBA_free (info);
-
+
return type;
}
@@ -46,6 +48,7 @@
CORBA_Environment *ev)
{
const char *mime_type;
+ char *mime_type_major;
char *oaf_requirements;
Bonobo_Unknown object;
Bonobo_Unknown stream;
@@ -66,15 +69,20 @@
if (!mime_type)
goto unref_stream_exception;
+ mime_type_major = bonobo_internal_get_major_mime_type (mime_type);
+
oaf_requirements = g_strdup_printf (
- "bonobo:supported_mime_types.has ('%s') AND repo_ids.has ('%s') AND "
+ "bonobo:supported_mime_types.has_one (['%s', '%s/*']) AND "
+ "repo_ids.has ('%s') AND "
"repo_ids.has ('IDL:Bonobo/PersistStream:1.0')",
- mime_type, requested_interface);
+ mime_type, mime_type_major, requested_interface);
object = oaf_activate (oaf_requirements, NULL, 0, &ret_id, ev);
g_warning ("Attempt activate object satisfying '%s': %p",
oaf_requirements, object);
+
g_free (oaf_requirements);
+ g_free (mime_type_major);
if (ev->_major != CORBA_NO_EXCEPTION)
goto unref_stream_exception;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]