forgot file in previous commit
Monotone-Parent: a23f9b6b633e53869f52361213e6478e36384813 Monotone-Revision: dab3668bce4278be22f243f5c2d650104d8d89fe Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2011-10-07T17:11:24 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
8e93dfd24e
commit
220410b446
|
@ -10,6 +10,7 @@ SUBPROJECTS = \
|
|||
SoObjects \
|
||||
Main \
|
||||
UI \
|
||||
Tools
|
||||
Tools \
|
||||
Bundles/Sample
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/aggregate.make
|
||||
|
|
|
@ -4,9 +4,10 @@ include ../config.make
|
|||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
include ../Version
|
||||
|
||||
ADDITIONAL_INCLUDE_DIRS +=
|
||||
ADDITIONAL_INCLUDE_DIRS += -I/usr/include/python2.6/
|
||||
ADDITIONAL_LIB_DIRS += -L../SOPE/GDLContentStore/obj/
|
||||
ADDITIONAL_LDFLAGS += -Wl,--no-as-needed
|
||||
ADDITIONAL_LDFLAGS += -lpython2.6
|
||||
|
||||
SOGOD = sogod
|
||||
TOOL_NAME = $(SOGOD)
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
@interface SOGo : SoApplication
|
||||
{
|
||||
NSMutableArray *bundles;
|
||||
SOGoCache *cache;
|
||||
}
|
||||
|
||||
|
|
117
Main/SOGo.m
117
Main/SOGo.m
|
@ -25,6 +25,8 @@
|
|||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDate.h>
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSFileManager.h>
|
||||
#import <Foundation/NSPathUtilities.h>
|
||||
#import <Foundation/NSProcessInfo.h>
|
||||
#import <Foundation/NSRunLoop.h>
|
||||
#import <Foundation/NSURL.h>
|
||||
|
@ -65,6 +67,8 @@
|
|||
#import <SOGo/WOResourceManager+SOGo.h>
|
||||
#import <SOGo/NSObject+DAV.h>
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#import "NSException+Stacktrace.h"
|
||||
|
||||
#import "SOGo.h"
|
||||
|
@ -147,6 +151,116 @@ static BOOL debugLeaks;
|
|||
[[SOGoProductLoader productLoader] loadAllProducts];
|
||||
}
|
||||
|
||||
- (void) _loadBundles
|
||||
{
|
||||
NSFileManager *aFileManager;
|
||||
NSMutableArray *allPaths;
|
||||
NSArray *allFiles;
|
||||
NSString *aPath;
|
||||
int i, j;
|
||||
|
||||
bundles = [[NSMutableArray alloc] init];
|
||||
|
||||
aFileManager = [NSFileManager defaultManager];
|
||||
allPaths = [[NSMutableArray alloc] initWithArray: NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
|
||||
NSLocalDomainMask|
|
||||
NSNetworkDomainMask|
|
||||
NSSystemDomainMask|
|
||||
NSUserDomainMask,
|
||||
YES)];
|
||||
for (i = 0; i < [allPaths count]; i++)
|
||||
{
|
||||
// We remove any potential duplicate paths in our allPaths array.
|
||||
[allPaths removeObject: [allPaths objectAtIndex: i] inRange: NSMakeRange(i+1, [allPaths count]-i-1)];
|
||||
|
||||
aPath = [NSString stringWithFormat: @"%@/SOGo", [allPaths objectAtIndex: i]];
|
||||
allFiles = [aFileManager directoryContentsAtPath: aPath];
|
||||
|
||||
for (j = 0; j < [allFiles count]; j++)
|
||||
{
|
||||
NSString *aString;
|
||||
|
||||
aString = [allFiles objectAtIndex: j];
|
||||
|
||||
// If we found a bundle, let's load it!
|
||||
if ([[aString pathExtension] isEqualToString: @"bundle"])
|
||||
{
|
||||
NSBundle *aBundle;
|
||||
NSString *path;
|
||||
|
||||
path = [NSString stringWithFormat: @"%@/%@", aPath, aString];
|
||||
aBundle = [NSBundle bundleWithPath: path];
|
||||
|
||||
if (aBundle)
|
||||
{
|
||||
PyObject *pName, *pModule;
|
||||
NSString *ppath;
|
||||
|
||||
NSLog(@"Loaded bundle at path %@ successfully...", path);
|
||||
|
||||
// We add that path to the PYTHONPATH environment
|
||||
ppath = [NSString stringWithFormat: @"%@/Resources/:%s", path, getenv("PYTHONPATH")];
|
||||
NSLog(@"Setting environment to %@", ppath);
|
||||
setenv("PYTHONPATH", [ppath UTF8String], 1);
|
||||
NSLog(@"New environment: %s", getenv("PYTHONPATH"));
|
||||
|
||||
Py_Initialize();
|
||||
pName = PyString_FromString("main");
|
||||
|
||||
if (pName)
|
||||
{
|
||||
NSLog(@"Trying to initialize module...");
|
||||
pModule = PyImport_Import(pName);
|
||||
Py_DECREF(pName);
|
||||
|
||||
if (pModule != NULL)
|
||||
{
|
||||
id aModule;
|
||||
Class c;
|
||||
int len;
|
||||
|
||||
NSLog(@"Loaded main Python file at path %@", path);
|
||||
|
||||
len = [aString length];
|
||||
|
||||
c = NSClassFromString([aString substringToIndex: (len-7)]);
|
||||
aModule = [c new];
|
||||
|
||||
if (aModule)
|
||||
{
|
||||
[bundles addObject: aModule];
|
||||
RELEASE(aModule);
|
||||
|
||||
NSLog(@"Successfully instanciated Sample");
|
||||
|
||||
if ([aModule respondsToSelector: @selector(userWasCreated:atDate:)])
|
||||
{
|
||||
[aModule userWasCreated: @"foo" atDate: @"bar"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Failed to instanciate Sample");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Failed to load module.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Failed to load module. You MUST have main.py in your SOGo Python bundle.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
|
@ -157,6 +271,9 @@ static BOOL debugLeaks;
|
|||
rm = [[WEResourceManager alloc] init];
|
||||
[self setResourceManager:rm];
|
||||
[rm release];
|
||||
|
||||
/* load all bundles */
|
||||
[self _loadBundles];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# compile settings
|
||||
|
||||
ADDITIONAL_CPPFLAGS += \
|
||||
-DSOGO_MAJOR_VERSION=$(MAJOR_VERSION) \
|
||||
-DSOGO_MINOR_VERSION=$(MINOR_VERSION) \
|
||||
-DSOGO_SUBMINOR_VERSION=$(SUBMINOR_VERSION) \
|
||||
-DSOGO_LIBDIR="@\"$(SOGO_LIBDIR)\""
|
||||
|
||||
ADDITIONAL_INCLUDE_DIRS += \
|
||||
-D_GNU_SOURCE -I../../SOPE/ -I../../SoObjects/
|
||||
|
||||
ADDITIONAL_LIB_DIRS += \
|
||||
-L../../SoObjects/SOGo/SOGo.framework -lSOGo \
|
||||
-L../../OGoContentStore/$(GNUSTEP_OBJ_DIR)/ -lOGoContentStore \
|
||||
-L../../SOPE/GDLContentStore/$(GNUSTEP_OBJ_DIR)/ -lGDLContentStore \
|
||||
-L../../SOPE/NGCards/$(GNUSTEP_OBJ_DIR)/ -lNGCards \
|
||||
-L/usr/local/lib -L/usr/lib -lEOControl -lNGStreams -lNGMime -lNGExtensions
|
Loading…
Reference in New Issue