2
* Copyright (C) 2002-2005 the xine-project
2
* Copyright (C) 2002-2006 the xine-project
4
4
* This program is free software; you can redistribute it and/or
5
5
* modify it under the terms of the GNU General Public License as
16
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19
* $Id: desktop_integration.c,v 1.21 2006/03/27 22:11:24 dsalt Exp $
21
19
* helper functions to register gxine with kde and gnome
22
20
* (and possibly cde in the future)
56
57
void (*application_registry_set_value) (const char *app_id, const char *key, const char *value);
57
58
void (*application_registry_set_bool_value) (const char *app_id, const char *key, int value);
58
59
void (*application_registry_remove_mime_type) (const char *app_id, const char *mime_type);
59
#ifndef GNOME_VFS_DISABLE_DEPRECATED
60
60
void (*mime_freeze) (void);
61
61
void (*mime_thaw) (void);
84
83
#define gnome_vfs_application_registry_set_value gnome_vfs->application_registry_set_value
85
84
#define gnome_vfs_application_registry_set_bool_value gnome_vfs->application_registry_set_bool_value
87
#define gnome_vfs_mime_thaw gnome_vfs->mime_thaw
88
#define gnome_vfs_mime_freeze gnome_vfs->mime_freeze
86
#define gnome_vfs_mime_freeze() do { if (gnome_vfs->mime_freeze) gnome_vfs->mime_freeze (); } while (0)
87
#define gnome_vfs_mime_thaw() do { if (gnome_vfs->mime_thaw) gnome_vfs->mime_thaw (); } while (0)
90
89
static void * gnome_vfs_handle = NULL;
91
90
static int gnome_vfs_available = -1;
92
91
static struct gnome_vfs_functions * gnome_vfs = NULL;
93
static void * gnome_ui_handle = NULL;
96
* load the gnome-vfs library and initialize the function pointers
97
* load the GnomeVFS and GnomeUI library
98
* If using the integration wizard, also initialize the function pointers
99
101
typedef void (*func_t) ();
116
118
get_func ("gnome_vfs_" #VAR))) \
117
119
return gnome_vfs_available = 0
119
gboolean di_gnome_vfs_init (void)
121
#define GET_FUNC_S_I(VAR) \
122
gnome_vfs->VAR = (typeof (gnome_vfs->VAR)) get_func ("gnome_vfs_" #VAR)
124
gboolean gxine_vfs_init (void)
121
void (*gnome_vfs_init_func) (void) = NULL;
122
void (*gnome_vfs_mime_get_value) (const char *, const char *) = NULL;
126
void (*init_func) (void) = NULL;
124
128
if (gnome_vfs_available != -1)
125
129
return gnome_vfs_available;
127
131
/* load the gnomevfs library */
128
gnome_vfs_handle = dlopen ("libgnomevfs-2.so.0", RTLD_LAZY);
132
gnome_vfs_handle = dlopen (LIBGNOMEVFS, RTLD_LAZY);
129
133
if (!gnome_vfs_handle)
131
135
fprintf (stderr, "%s.\n", dlerror());
135
139
gnome_vfs = (struct gnome_vfs_functions *) calloc (1, sizeof (struct gnome_vfs_functions));
137
141
/* this call causes gnome-vfs to become initialized */
138
GET_FUNC (gnome_vfs_init_func, "gnome_vfs_init");
139
gnome_vfs_init_func ();
142
GET_FUNC (init_func, "gnome_vfs_init");
145
/* load the gnomeui library (for the authentication bits) */
146
gnome_ui_handle = dlopen (LIBGNOMEUI, RTLD_LAZY);
149
/* this call causes gnome-vfs to become initialized */
150
init_func = dlsym (gnome_ui_handle, "gnome_authentication_manager_init");
154
fprintf (stderr, "%s.\n", dlerror());
157
fprintf (stderr, "%s.\n", dlerror());
159
#ifdef USE_INTEGRATION_WIZARD
160
void (*gnome_vfs_mime_get_value) (const char *, const char *) = NULL;
141
162
GET_FUNC (gnome_vfs_mime_get_value, "gnome_vfs_mime_get_value");
142
163
gnome_vfs_mime_get_value ("text/plain", "description");
144
165
/* extract needed symbols from the library */
145
GET_FUNC_S (mime_freeze);
146
GET_FUNC_S (mime_thaw);
166
GET_FUNC_S_I (mime_freeze);
167
GET_FUNC_S_I (mime_thaw);
147
168
GET_FUNC_S (application_registry_remove_application);
148
169
GET_FUNC_S (application_registry_add_mime_type);
149
170
GET_FUNC_S (application_registry_set_value);
150
171
GET_FUNC_S (application_registry_set_bool_value);
151
172
GET_FUNC_S (application_registry_remove_mime_type);
153
175
return gnome_vfs_available = 1;
173
195
GET_FUNC (gnome_vfs_application_registry_sync, "gnome_vfs_application_registry_sync");
175
197
gnome_vfs_application_registry_sync ();
176
dlclose (gnome_vfs_handle);
198
/* dlclose (gnome_vfs_handle); */
179
201
free (gnome_vfs);