Reverted AGAIN temporary stuff from previous commit
Monotone-Parent: dab3668bce4278be22f243f5c2d650104d8d89fe Monotone-Revision: 04a0346af8290ab531d44883c56b4b27443baade Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2011-10-07T17:13:50 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
220410b446
commit
8324533cdb
|
@ -10,7 +10,6 @@ SUBPROJECTS = \
|
||||||
SoObjects \
|
SoObjects \
|
||||||
Main \
|
Main \
|
||||||
UI \
|
UI \
|
||||||
Tools \
|
Tools
|
||||||
Bundles/Sample
|
|
||||||
|
|
||||||
include $(GNUSTEP_MAKEFILES)/aggregate.make
|
include $(GNUSTEP_MAKEFILES)/aggregate.make
|
||||||
|
|
|
@ -4,10 +4,9 @@ include ../config.make
|
||||||
include $(GNUSTEP_MAKEFILES)/common.make
|
include $(GNUSTEP_MAKEFILES)/common.make
|
||||||
include ../Version
|
include ../Version
|
||||||
|
|
||||||
ADDITIONAL_INCLUDE_DIRS += -I/usr/include/python2.6/
|
ADDITIONAL_INCLUDE_DIRS +=
|
||||||
ADDITIONAL_LIB_DIRS += -L../SOPE/GDLContentStore/obj/
|
ADDITIONAL_LIB_DIRS += -L../SOPE/GDLContentStore/obj/
|
||||||
ADDITIONAL_LDFLAGS += -Wl,--no-as-needed
|
ADDITIONAL_LDFLAGS += -Wl,--no-as-needed
|
||||||
ADDITIONAL_LDFLAGS += -lpython2.6
|
|
||||||
|
|
||||||
SOGOD = sogod
|
SOGOD = sogod
|
||||||
TOOL_NAME = $(SOGOD)
|
TOOL_NAME = $(SOGOD)
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
|
|
||||||
@interface SOGo : SoApplication
|
@interface SOGo : SoApplication
|
||||||
{
|
{
|
||||||
NSMutableArray *bundles;
|
|
||||||
SOGoCache *cache;
|
SOGoCache *cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
117
Main/SOGo.m
117
Main/SOGo.m
|
@ -25,8 +25,6 @@
|
||||||
#import <Foundation/NSData.h>
|
#import <Foundation/NSData.h>
|
||||||
#import <Foundation/NSDate.h>
|
#import <Foundation/NSDate.h>
|
||||||
#import <Foundation/NSEnumerator.h>
|
#import <Foundation/NSEnumerator.h>
|
||||||
#import <Foundation/NSFileManager.h>
|
|
||||||
#import <Foundation/NSPathUtilities.h>
|
|
||||||
#import <Foundation/NSProcessInfo.h>
|
#import <Foundation/NSProcessInfo.h>
|
||||||
#import <Foundation/NSRunLoop.h>
|
#import <Foundation/NSRunLoop.h>
|
||||||
#import <Foundation/NSURL.h>
|
#import <Foundation/NSURL.h>
|
||||||
|
@ -67,8 +65,6 @@
|
||||||
#import <SOGo/WOResourceManager+SOGo.h>
|
#import <SOGo/WOResourceManager+SOGo.h>
|
||||||
#import <SOGo/NSObject+DAV.h>
|
#import <SOGo/NSObject+DAV.h>
|
||||||
|
|
||||||
#include <Python.h>
|
|
||||||
|
|
||||||
#import "NSException+Stacktrace.h"
|
#import "NSException+Stacktrace.h"
|
||||||
|
|
||||||
#import "SOGo.h"
|
#import "SOGo.h"
|
||||||
|
@ -151,116 +147,6 @@ static BOOL debugLeaks;
|
||||||
[[SOGoProductLoader productLoader] loadAllProducts];
|
[[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
|
- (id) init
|
||||||
{
|
{
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
|
@ -271,9 +157,6 @@ static BOOL debugLeaks;
|
||||||
rm = [[WEResourceManager alloc] init];
|
rm = [[WEResourceManager alloc] init];
|
||||||
[self setResourceManager:rm];
|
[self setResourceManager:rm];
|
||||||
[rm release];
|
[rm release];
|
||||||
|
|
||||||
/* load all bundles */
|
|
||||||
[self _loadBundles];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
|
Loading…
Reference in New Issue