From 7c4b912ad8a89d388ed8a9087de80a26f39d9381 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 4 Mar 2009 15:27:00 +0000 Subject: [PATCH] Monotone-Parent: cf83f210bd51772341ff7ea082a7e6bd95fc4bea Monotone-Revision: 38e85c6b518b49dd63fa7fc5c2c1c7a57037cff8 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-03-04T15:27:00 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 10 ++++++ Main/GNUmakefile.preamble | 3 +- Main/sogod.m | 27 ++++++++++++++-- SoObjects/SOGo/GNUmakefile | 14 +++++++-- .../SOGo/SOGoLDAPUserDefaultsBootstrap.m | 31 +++++++++++++++++++ 5 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 SoObjects/SOGo/SOGoLDAPUserDefaultsBootstrap.m diff --git a/ChangeLog b/ChangeLog index 826341e3c..f95eb9c44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-03-04 Wolfgang Sourdeau + + * SoObjects/SOGo/SOGoLDAPUserDefaultsBootstrap.m: new module for + the libSOGoNSUserDefaults.so.1 library built when enabling + ldap-based configuration. + + * Main/sogod.m (BootstrapNSUserDefaults): added function to load a + library named "libSOGoNSUserDefaults.so.1" which would bootstrap + the NSUserDefaults class with an arbitrary "pose class". + 2009-03-04 Ludovic Marcotte * Fixed a small issue when fetching parts where diff --git a/Main/GNUmakefile.preamble b/Main/GNUmakefile.preamble index 89fd3d01a..5686586b3 100644 --- a/Main/GNUmakefile.preamble +++ b/Main/GNUmakefile.preamble @@ -4,7 +4,8 @@ BUILD_DATE = $(shell echo $$USER@$$HOSTNAME; date +"%Y%m%d%H%M") ADDITIONAL_CPPFLAGS += \ -DSOGO_MAJOR_VERSION=$(MAJOR_VERSION) \ -DSOGO_MINOR_VERSION=$(MINOR_VERSION) \ - -DSOGO_SUBMINOR_VERSION=$(SUBMINOR_VERSION) + -DSOGO_SUBMINOR_VERSION=$(SUBMINOR_VERSION) \ + -DSOGO_LIBDIR="\"$(SOGO_LIBDIR)\"" ADDITIONAL_INCLUDE_DIRS += \ -I../SoObjects/ \ diff --git a/Main/sogod.m b/Main/sogod.m index 2898f7a44..52a4018ae 100644 --- a/Main/sogod.m +++ b/Main/sogod.m @@ -19,6 +19,7 @@ 02111-1307, USA. */ +#import #import #import @@ -32,6 +33,28 @@ #import #endif +typedef void (*NSUserDefaultsInitFunction) (); + +#define DIR_SEP "/" + +static void +BootstrapNSUserDefaults () +{ + char *filename; + NSUserDefaultsInitFunction SOGoNSUserDefaultsBootstrap; + void *handle; + + filename = SOGO_LIBDIR DIR_SEP "libSOGoNSUserDefaults.so.1"; + handle = dlopen (filename, RTLD_NOW | RTLD_GLOBAL); + if (handle) + { + SOGoNSUserDefaultsBootstrap = dlsym (handle, + "SOGoNSUserDefaultsBootstrap"); + if (SOGoNSUserDefaultsBootstrap) + SOGoNSUserDefaultsBootstrap (); + } +} + int main (int argc, char **argv, char **env) { @@ -42,9 +65,7 @@ main (int argc, char **argv, char **env) pool = [NSAutoreleasePool new]; -#if defined(LDAP_CONFIG) - [SOGoLDAPUserDefaults poseAsClass: [NSUserDefaults class]]; -#endif + BootstrapNSUserDefaults (); rc = -1; diff --git a/SoObjects/SOGo/GNUmakefile b/SoObjects/SOGo/GNUmakefile index 7b9f8e670..10f486802 100644 --- a/SoObjects/SOGo/GNUmakefile +++ b/SoObjects/SOGo/GNUmakefile @@ -109,8 +109,17 @@ SOGo_RESOURCE_FILES = \ DAVReportMap.plist ifeq ($(ldap_config),yes) -SOGo_OBJC_FILES += SOGoLDAPUserDefaults.m -SOGo_HEADER_FILES += SOGoLDAPUserDefaults.h + +LIBRARY_NAME += \ + SOGoNSUserDefaults + +SOGoNSUserDefaults_VERSION = 1 +SOGoNSUserDefaults_INSTALL_DIR = $(SOGO_LIBDIR) + +SOGoNSUserDefaults_OBJC_FILES = \ + SOGoLDAPUserDefaultsBootstrap.m \ + SOGoLDAPUserDefaults.m + endif # tools @@ -129,5 +138,6 @@ ifneq ($(FHS_INSTALL_ROOT),) GNUSTEP_HEADERS=$(DESTDIR)$(FHS_INSTALL_ROOT)/include endif include $(GNUSTEP_MAKEFILES)/framework.make +include $(GNUSTEP_MAKEFILES)/library.make include $(GNUSTEP_MAKEFILES)/tool.make -include GNUmakefile.postamble diff --git a/SoObjects/SOGo/SOGoLDAPUserDefaultsBootstrap.m b/SoObjects/SOGo/SOGoLDAPUserDefaultsBootstrap.m new file mode 100644 index 000000000..893fd51e7 --- /dev/null +++ b/SoObjects/SOGo/SOGoLDAPUserDefaultsBootstrap.m @@ -0,0 +1,31 @@ +/* SOGoLDAPUserDefaultsBootstrap.m - this file is part of $PROJECT_NAME_HERE$ + * + * Copyright (C) 2009 Inverse inc. + * + * Author: Wolfgang Sourdeau + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import + +#import "SOGoLDAPUserDefaults.h" + +void +SOGoNSUserDefaultsBootstrap () +{ + [SOGoLDAPUserDefaults poseAsClass: [NSUserDefaults class]]; +}