summaryrefslogtreecommitdiff
path: root/include/LibreOfficeKit
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2015-04-08 22:44:29 +0300
committerTor Lillqvist <tml@collabora.com>2015-04-08 23:20:26 +0300
commit5cc0da153e8516a11bbd3e5809e8dcaf0b0dc7d9 (patch)
tree8cded50f376884a5e3f3f125e72fc2c4263ec160 /include/LibreOfficeKit
parent69b505553331480c0ab97e3776ba31ef11e649a3 (diff)
Add lok_init_2() that takes also the path to a user profile to use
In some LibreOfficeKit use cases it will be useful to use a separate (initially empty) user profile each time, instead of whatever the default might turn out to be. (When using the "instdir" of a LibreOffice build tree, the user profile is the "instdir/user" directory.) Also add a corresponding new function to be looked up, libreofficekit_hook_2. I did not bother with any more descriptive name. After all, "lok_init" already is quite terse, so calling the new function "lok_init_with_user_profile" or something similarly verbose would in my humble opinion have been inconsistent. (And if/when we need to extend the LibreOfficeKit initialisation function with even more parameters, the name would become really long.) But feel free to change this if you feel like it... Make sure to stay backward-compatible with source code calling lok_init() and with binaries looking for only the libreofficekit_hook entry point. Change-Id: Ifa9ce8f72c2f60554fb3431d522e5784afa8d8d3
Diffstat (limited to 'include/LibreOfficeKit')
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitInit.h36
1 files changed, 29 insertions, 7 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKitInit.h b/include/LibreOfficeKit/LibreOfficeKitInit.h
index fe10cd9ffa1b..c0d3d5d06e0e 100644
--- a/include/LibreOfficeKit/LibreOfficeKitInit.h
+++ b/include/LibreOfficeKit/LibreOfficeKitInit.h
@@ -126,11 +126,14 @@ extern "C"
typedef LibreOfficeKit *(HookFunction)( const char *install_path);
-static LibreOfficeKit *lok_init( const char *install_path )
+typedef LibreOfficeKit *(HookFunction2)( const char *install_path, const char *user_profile_path );
+
+static LibreOfficeKit *lok_init_2( const char *install_path, const char *user_profile_path )
{
char *imp_lib;
void *dlhandle;
HookFunction *pSym;
+ HookFunction2 *pSym2;
#if !(defined(__APPLE__) && defined(__arm__))
size_t partial_length;
@@ -173,17 +176,36 @@ static LibreOfficeKit *lok_init( const char *install_path )
dlhandle = RTLD_MAIN_ONLY;
#endif
- pSym = (HookFunction *) _dlsym( dlhandle, "libreofficekit_hook" );
- if (!pSym)
+ pSym2 = (HookFunction2 *) _dlsym( dlhandle, "libreofficekit_hook_2" );
+ if (!pSym2)
{
- fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib );
- _dlclose( dlhandle );
+ if (user_profile_path != NULL)
+ {
+ fprintf( stderr, "the LibreOffice version in '%s' does not support passing a user profile to the hook function\n",
+ imp_lib );
+ _dlclose( dlhandle );
+ free( imp_lib );
+ return NULL;
+ }
+ pSym = (HookFunction *) _dlsym( dlhandle, "libreofficekit_hook" );
+ if (!pSym)
+ {
+ fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib );
+ _dlclose( dlhandle );
+ free( imp_lib );
+ return NULL;
+ }
free( imp_lib );
- return NULL;
+ return pSym( install_path );
}
free( imp_lib );
- return pSym( install_path );
+ return pSym2( install_path, user_profile_path );
+}
+
+static LibreOfficeKit *lok_init( const char *install_path )
+{
+ return lok_init_2( install_path, NULL );
}
#undef SEPARATOR // It is used at least in enum class MenuItemType