summaryrefslogtreecommitdiff
path: root/bindings/objc/src
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/objc/src')
-rw-r--r--bindings/objc/src/DefaultFilterProvider.h37
-rw-r--r--bindings/objc/src/DefaultFilterProvider.mm44
-rw-r--r--bindings/objc/src/FilterProviderFactory.h24
-rw-r--r--bindings/objc/src/FilterProviderFactory.mm42
-rw-r--r--bindings/objc/src/SwordBible.h17
-rw-r--r--bindings/objc/src/SwordBible.mm104
-rw-r--r--bindings/objc/src/SwordBibleBook.h22
-rw-r--r--bindings/objc/src/SwordBibleBook.mm10
-rw-r--r--bindings/objc/src/SwordBibleChapter.h2
-rw-r--r--bindings/objc/src/SwordBibleTextEntry.h6
-rw-r--r--bindings/objc/src/SwordBibleTextEntry.m4
-rw-r--r--bindings/objc/src/SwordBook.h8
-rw-r--r--bindings/objc/src/SwordBook.mm37
-rw-r--r--bindings/objc/src/SwordCommentary.h6
-rw-r--r--bindings/objc/src/SwordCommentary.mm13
-rw-r--r--bindings/objc/src/SwordDictionary.h6
-rw-r--r--bindings/objc/src/SwordDictionary.mm12
-rw-r--r--bindings/objc/src/SwordFilter.h61
-rw-r--r--bindings/objc/src/SwordFilter.mm142
-rw-r--r--bindings/objc/src/SwordInstallSource.h23
-rw-r--r--bindings/objc/src/SwordInstallSource.mm57
-rwxr-xr-x[-rw-r--r--]bindings/objc/src/SwordInstallSourceManager.h (renamed from bindings/objc/src/SwordInstallSourceController.h)22
-rwxr-xr-x[-rw-r--r--]bindings/objc/src/SwordInstallSourceManager.mm (renamed from bindings/objc/src/SwordInstallSourceController.mm)138
-rw-r--r--bindings/objc/src/SwordKey.h18
-rw-r--r--bindings/objc/src/SwordKey.mm16
-rw-r--r--bindings/objc/src/SwordListKey.h25
-rw-r--r--bindings/objc/src/SwordListKey.mm37
-rw-r--r--bindings/objc/src/SwordLocaleManager.h10
-rw-r--r--bindings/objc/src/SwordLocaleManager.mm16
-rw-r--r--bindings/objc/src/SwordManager.h33
-rw-r--r--bindings/objc/src/SwordManager.mm181
-rw-r--r--bindings/objc/src/SwordModule+Index.h2
-rw-r--r--bindings/objc/src/SwordModule.h91
-rw-r--r--bindings/objc/src/SwordModule.mm147
-rw-r--r--bindings/objc/src/SwordModuleTextEntry.h2
-rw-r--r--bindings/objc/src/SwordModuleTreeEntry.h2
-rw-r--r--bindings/objc/src/SwordUtil.h20
-rw-r--r--bindings/objc/src/SwordUtil.m64
-rw-r--r--bindings/objc/src/SwordVerseKey.h28
-rw-r--r--bindings/objc/src/SwordVerseKey.mm36
-rw-r--r--bindings/objc/src/SwordVerseManager.h10
-rw-r--r--bindings/objc/src/SwordVerseManager.mm14
-rw-r--r--bindings/objc/src/VerseEnumerator.h2
-rw-r--r--bindings/objc/src/VerseEnumerator.mm3
-rw-r--r--bindings/objc/src/services/Configuration.h7
-rw-r--r--bindings/objc/src/services/Configuration.m26
-rw-r--r--bindings/objc/src/services/OSXConfiguration.h2
-rw-r--r--bindings/objc/src/services/iOSConfiguration.h24
-rw-r--r--bindings/objc/src/services/iOSConfiguration.m38
49 files changed, 1103 insertions, 588 deletions
diff --git a/bindings/objc/src/DefaultFilterProvider.h b/bindings/objc/src/DefaultFilterProvider.h
new file mode 100644
index 0000000..435daa0
--- /dev/null
+++ b/bindings/objc/src/DefaultFilterProvider.h
@@ -0,0 +1,37 @@
+//
+// Created by mbergmann on 18.12.12.
+//
+// To change the template use AppCode | Preferences | File Templates.
+//
+
+
+#import <Foundation/Foundation.h>
+#import "SwordFilter.h"
+
+@protocol FilterProvider
+
+- (SwordFilter *)newOsisRenderFilter;
+- (SwordFilter *)newOsisPlainFilter;
+- (SwordFilter *)newGbfRenderFilter;
+- (SwordFilter *)newGbfPlainFilter;
+- (SwordFilter *)newThmlRenderFilter;
+- (SwordFilter *)newThmlPlainFilter;
+- (SwordFilter *)newTeiRenderFilter;
+- (SwordFilter *)newTeiPlainFilter;
+- (SwordFilter *)newHtmlPlainFilter;
+
+@end
+
+@interface DefaultFilterProvider : NSObject <FilterProvider>
+
+- (SwordFilter *)newOsisRenderFilter;
+- (SwordFilter *)newOsisPlainFilter;
+- (SwordFilter *)newGbfRenderFilter;
+- (SwordFilter *)newGbfPlainFilter;
+- (SwordFilter *)newThmlRenderFilter;
+- (SwordFilter *)newThmlPlainFilter;
+- (SwordFilter *)newTeiRenderFilter;
+- (SwordFilter *)newTeiPlainFilter;
+- (SwordFilter *)newHtmlPlainFilter;
+
+@end
diff --git a/bindings/objc/src/DefaultFilterProvider.mm b/bindings/objc/src/DefaultFilterProvider.mm
new file mode 100644
index 0000000..65d8c0a
--- /dev/null
+++ b/bindings/objc/src/DefaultFilterProvider.mm
@@ -0,0 +1,44 @@
+//
+// Created by mbergmann on 18.12.12.
+//
+//
+
+
+#import "DefaultFilterProvider.h"
+#import "SwordFilter.h"
+
+@implementation DefaultFilterProvider
+
+- (SwordFilter *)newOsisRenderFilter {
+ return [SwordOsisHtmlRefFilter filter];
+}
+
+- (SwordFilter *)newOsisPlainFilter {
+ return [SwordOsisPlainFilter filter];
+}
+
+- (SwordFilter *)newGbfRenderFilter {
+ return [SwordGbfHtmlFilter filter];
+}
+
+- (SwordFilter *)newGbfPlainFilter {
+ return [SwordGbfPlainFilter filter];
+}
+
+- (SwordFilter *)newThmlRenderFilter {
+ return [SwordThmlHtmlFilter filter];
+}
+
+- (SwordFilter *)newThmlPlainFilter {
+ return [SwordThmlPlainFilter filter];
+}
+
+- (SwordFilter *)newTeiRenderFilter {
+ return [SwordTeiHtmlFilter filter];
+}
+
+- (SwordFilter *)newTeiPlainFilter {
+ return [SwordTeiPlainFilter filter];
+}
+
+@end \ No newline at end of file
diff --git a/bindings/objc/src/FilterProviderFactory.h b/bindings/objc/src/FilterProviderFactory.h
new file mode 100644
index 0000000..b2a6e65
--- /dev/null
+++ b/bindings/objc/src/FilterProviderFactory.h
@@ -0,0 +1,24 @@
+//
+// Created by mbergmann on 18.12.12.
+//
+//
+
+#import <Foundation/Foundation.h>
+
+#ifdef __cplusplus
+#include <swmgr.h> // C++ Sword API
+#endif
+
+@protocol FilterProvider;
+
+/**
+* This factory has to be initialized before any Modules are loaded through SwordManager.
+*/
+@interface FilterProviderFactory : NSObject
+
++ (FilterProviderFactory *)providerFactory;
+
+- (void)initWithImpl:(id<FilterProvider>)aFilterProvider;
+- (id<FilterProvider>)get;
+
+@end
diff --git a/bindings/objc/src/FilterProviderFactory.mm b/bindings/objc/src/FilterProviderFactory.mm
new file mode 100644
index 0000000..75abc68
--- /dev/null
+++ b/bindings/objc/src/FilterProviderFactory.mm
@@ -0,0 +1,42 @@
+//
+// Created by mbergmann on 18.12.12.
+//
+//
+
+
+#import "FilterProviderFactory.h"
+#import "DefaultFilterProvider.h"
+
+@interface FilterProviderFactory ()
+
+@property(nonatomic, retain) id <FilterProvider> filterProvider;
+
+@end
+
+@implementation FilterProviderFactory
+
++ (FilterProviderFactory *)providerFactory {
+ static FilterProviderFactory *singleton = nil;
+
+ if(singleton == nil) {
+ singleton = [[FilterProviderFactory alloc] init];
+ }
+
+ return singleton;
+}
+
+- (void)initWithImpl:(id <FilterProvider>)aFilterProvider {
+ self.filterProvider = aFilterProvider;
+}
+
+- (id <FilterProvider>)get {
+ return self.filterProvider;
+}
+
+- (void)dealloc {
+ self.filterProvider = nil;
+ [super dealloc];
+}
+
+
+@end \ No newline at end of file
diff --git a/bindings/objc/src/SwordBible.h b/bindings/objc/src/SwordBible.h
index 68bf6bb..f57d322 100644
--- a/bindings/objc/src/SwordBible.h
+++ b/bindings/objc/src/SwordBible.h
@@ -11,14 +11,14 @@
General Public License for more details. (http://www.gnu.org/licenses/gpl.html)
*/
-#import <Cocoa/Cocoa.h>
-#import "SwordModule.h"
+#import <Foundation/Foundation.h>
#ifdef __cplusplus
#import "versekey.h"
#endif
-@class SwordManager, SwordBibleBook, SwordModuleTextEntry, SwordBibleTextEntry;
+@class SwordModule, SwordManager, SwordBibleBook, SwordModuleTextEntry, SwordBibleTextEntry;
+@class SwordKey;
typedef enum {
OldTestament = 1,
@@ -57,8 +57,17 @@ typedef enum {
- (int)versesForBible;
// Text pulling
-- (SwordBibleTextEntry *)textEntryForKey:(SwordKey *)aKey textType:(TextPullType)aType;
+
+/**
+* @return SwordBibleTextEntry
+*/
+- (SwordModuleTextEntry *)textEntryForKey:(SwordKey *)aKey textType:(TextPullType)aType;
- (NSArray *)strippedTextEntriesForRef:(NSString *)reference context:(int)context;
- (NSArray *)renderedTextEntriesForRef:(NSString *)reference context:(int)context;
+/**
+ Override from super class
+ @return Array of SwordBibleTextEntry
+ */
+- (NSArray *)textEntriesForReference:(NSString *)aReference textType:(TextPullType)textType;
@end \ No newline at end of file
diff --git a/bindings/objc/src/SwordBible.mm b/bindings/objc/src/SwordBible.mm
index 8c86626..03e378e 100644
--- a/bindings/objc/src/SwordBible.mm
+++ b/bindings/objc/src/SwordBible.mm
@@ -11,20 +11,11 @@
General Public License for more details. (http://www.gnu.org/licenses/gpl.html)
*/
-#import "SwordBible.h"
-#import "SwordModule.h"
-#import "SwordManager.h"
-#import "SwordBibleBook.h"
-#import "SwordListKey.h"
-#import "SwordModuleTextEntry.h"
-#import "SwordBibleTextEntry.h"
-#import "SwordVerseKey.h"
-#import "SwordListKey.h"
+#import <ObjCSword/ObjCSword.h>
using sword::AttributeTypeList;
using sword::AttributeList;
using sword::AttributeValue;
-#include "versemgr.h"
@interface SwordBible ()
@@ -49,12 +40,20 @@ NSLock *bibleLock = nil;
if(!bibleLock) bibleLock = [[NSLock alloc] init];
[bibleLock lock];
- sword::VerseKey vk([ref UTF8String]);
-
- *bookName = [NSString stringWithUTF8String:vk.getBookName()];
- *book = vk.Book();
- *chapter = vk.Chapter();
- *verse = vk.Verse();
+ SwordVerseKey *key = [SwordVerseKey verseKeyWithRef:ref];
+
+ if(bookName != NULL) {
+ *bookName = [key bookName];
+ }
+ if(book != NULL) {
+ *book = [key book];
+ }
+ if(chapter != NULL) {
+ *chapter = [key chapter];
+ }
+ if(verse != NULL) {
+ *verse = [key verse];
+ }
[bibleLock unlock];
}
@@ -75,25 +74,25 @@ NSLock *bibleLock = nil;
//get parsed simple ref
NSString *first = [SwordBible firstRefName:abbr];
- NSArray *firstbits = [first componentsSeparatedByString:@":"];
+ NSArray *firstBits = [first componentsSeparatedByString:@":"];
//if abbr contains : or . then we are a verse so return a chapter
if([abbr rangeOfString:@":"].location != NSNotFound || [abbr rangeOfString:@"."].location != NSNotFound) {
- return [firstbits objectAtIndex:0];
+ return [firstBits objectAtIndex:0];
}
//otherwise return a book
- firstbits = [first componentsSeparatedByString:@" "];
+ firstBits = [first componentsSeparatedByString:@" "];
- if([firstbits count] > 0) {
- return [firstbits objectAtIndex:0];
+ if([firstBits count] > 0) {
+ return [firstBits objectAtIndex:0];
}
return abbr;
}
/**
- get book index for versekey
+ get book index for verseKey
that is: book number + testament * 100
*/
+ (int)bookIndexForSWKey:(sword::VerseKey *)key {
@@ -125,6 +124,7 @@ NSLock *bibleLock = nil;
}
- (void)dealloc {
+ [books release];
[super dealloc];
}
@@ -133,15 +133,15 @@ NSLock *bibleLock = nil;
- (void)buildBookList {
[moduleLock lock];
- sword::VerseMgr *vmgr = sword::VerseMgr::getSystemVerseMgr();
- const sword::VerseMgr::System *system = vmgr->getVersificationSystem([[self versification] UTF8String]);
+ sword::VersificationMgr *vmgr = sword::VersificationMgr::getSystemVersificationMgr();
+ const sword::VersificationMgr::System *system = vmgr->getVersificationSystem([[self versification] UTF8String]);
NSMutableDictionary *buf = [NSMutableDictionary dictionary];
int bookCount = system->getBookCount();
for(int i = 0;i < bookCount;i++) {
- sword::VerseMgr::Book *book = (sword::VerseMgr::Book *)system->getBook(i);
+ sword::VersificationMgr::Book *book = (sword::VersificationMgr::Book *)system->getBook(i);
- SwordBibleBook *bb = [[SwordBibleBook alloc] initWithBook:book];
+ SwordBibleBook *bb = [[[SwordBibleBook alloc] initWithBook:book] autorelease];
[bb setNumber:i+1];
NSString *bookName = [bb name];
@@ -219,7 +219,7 @@ NSLock *bibleLock = nil;
- (int)chaptersForBookName:(NSString *)bookName {
[moduleLock lock];
- int maxChapters = 0;
+ int maxChapters;
sword::VerseKey *key = (sword::VerseKey *)swModule->CreateKey();
(*key) = [bookName UTF8String];
maxChapters = key->getChapterMax();
@@ -271,28 +271,28 @@ NSLock *bibleLock = nil;
}
- (NSString *)moduleIntroduction {
- NSString *ret = @"";
+ NSString *ret;
// save key
- SwordVerseKey *save = [self getKeyCopy];
+ SwordVerseKey *save = [(SwordVerseKey *)[self getKeyCopy] autorelease];
SwordVerseKey *key = [SwordVerseKey verseKeyWithVersification:[self versification]];
[key setHeadings:YES];
[key setPosition:0];
- [self setKey:key];
+ [self setSwordKey:key];
ret = [self renderedText];
// restore old key
- [self setKey:save];
+ [self setSwordKey:save];
return ret;
}
- (NSString *)bookIntroductionFor:(SwordBibleBook *)aBook {
- NSString *ret = @"";
+ NSString *ret;
// save key
- SwordVerseKey *save = [self getKeyCopy];
+ SwordVerseKey *save = [(SwordVerseKey *)[self getKeyCopy] autorelease];
SwordVerseKey *key = [SwordVerseKey verseKeyWithVersification:[self versification]];
[key setHeadings:YES];
@@ -301,20 +301,20 @@ NSLock *bibleLock = nil;
[key setBook:[aBook numberInTestament]];
[key setChapter:0];
[key setVerse:0];
- [self setKey:key];
+ [self setSwordKey:key];
ret = [self renderedText];
// restore old key
- [self setKey:save];
+ [self setSwordKey:save];
return ret;
}
- (NSString *)chapterIntroductionFor:(SwordBibleBook *)aBook chapter:(int)chapter {
- NSString *ret = @"";
+ NSString *ret;
// save key
- SwordVerseKey *save = [self getKeyCopy];
+ SwordVerseKey *save = [(SwordVerseKey *)[self getKeyCopy] autorelease];
SwordVerseKey *key = [SwordVerseKey verseKeyWithVersification:[self versification]];
[key setHeadings:YES];
@@ -323,23 +323,23 @@ NSLock *bibleLock = nil;
[key setBook:[aBook numberInTestament]];
[key setChapter:chapter];
[key setVerse:0];
- [self setKey:key];
+ [self setSwordKey:key];
ret = [self renderedText];
// restore old key
- [self setKey:save];
+ [self setSwordKey:save];
return ret;
}
-- (SwordBibleTextEntry *)textEntryForKey:(SwordVerseKey *)aKey textType:(TextPullType)aType {
+- (SwordModuleTextEntry *)textEntryForKey:(SwordKey *)aKey textType:(TextPullType)aType {
SwordBibleTextEntry *ret = nil;
if(aKey) {
[moduleLock lock];
- [self setKey:aKey];
+ [self setSwordKey:aKey];
if(![self error]) {
- NSString *txt = @"";
+ NSString *txt;
if(aType == TextTypeRendered) {
txt = [self renderedText];
} else {
@@ -355,7 +355,7 @@ NSLock *bibleLock = nil;
if([swManager globalOption:SW_OPTION_HEADINGS] && [self hasFeature:SWMOD_FEATURE_HEADINGS]) {
NSString *preverseHeading = [self entryAttributeValuePreverse];
if(preverseHeading && [preverseHeading length] > 0) {
- [ret setPreverseHeading:preverseHeading];
+ [ret setPreVerseHeading:preverseHeading];
}
}
}
@@ -385,7 +385,7 @@ NSLock *bibleLock = nil;
#pragma mark - SwordModuleAccess
-- (id)createKey {
+- (SwordKey *)createKey {
sword::VerseKey *vk = (sword::VerseKey *)swModule->CreateKey();
SwordVerseKey *newKey = [SwordVerseKey verseKeyWithSWVerseKey:vk makeCopy:YES];
delete vk;
@@ -393,19 +393,19 @@ NSLock *bibleLock = nil;
return newKey;
}
-- (id)getKey {
+- (SwordKey *)getKey {
return [SwordVerseKey verseKeyWithSWVerseKey:(sword::VerseKey *)swModule->getKey()];
}
-- (id)getKeyCopy {
+- (SwordKey *)getKeyCopy {
return [SwordVerseKey verseKeyWithSWVerseKey:(sword::VerseKey *)swModule->getKey() makeCopy:YES];
}
- (long)entryCount {
swModule->setPosition(sword::TOP);
- unsigned long verseLowIndex = swModule->Index();
+ long verseLowIndex = swModule->Index();
swModule->setPosition(sword::BOTTOM);
- unsigned long verseHighIndex = swModule->Index();
+ long verseHighIndex = swModule->Index();
return verseHighIndex - verseLowIndex;
}
@@ -426,6 +426,10 @@ NSLock *bibleLock = nil;
return [self textEntriesForReference:reference context:context textType:TextTypeRendered];
}
+- (NSArray *)textEntriesForReference:(NSString *)aReference textType:(TextPullType)textType {
+ return [self textEntriesForReference:aReference context:0 textType:textType];
+}
+
- (NSArray *)textEntriesForReference:(NSString *)aReference context:(int)context textType:(TextPullType)textType {
NSMutableArray *ret = [NSMutableArray array];
@@ -441,14 +445,14 @@ NSLock *bibleLock = nil;
long highVerse = lowVerse + (context * 2);
for(;lowVerse <= highVerse;lowVerse++) {
[vk setVerse:lowVerse];
- SwordBibleTextEntry *entry = [self textEntryForKey:vk textType:textType];
+ SwordBibleTextEntry *entry = (SwordBibleTextEntry *) [self textEntryForKey:vk textType:textType];
if(entry) {
[ret addObject:entry];
}
[vk increment];
}
} else {
- SwordBibleTextEntry *entry = [self textEntryForKey:vk textType:textType];
+ SwordBibleTextEntry *entry = (SwordBibleTextEntry *) [self textEntryForKey:vk textType:textType];
if(entry) {
[ret addObject:entry];
}
diff --git a/bindings/objc/src/SwordBibleBook.h b/bindings/objc/src/SwordBibleBook.h
index 824d400..af48bb4 100644
--- a/bindings/objc/src/SwordBibleBook.h
+++ b/bindings/objc/src/SwordBibleBook.h
@@ -6,36 +6,36 @@
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
#ifdef __cplusplus
-#include <versemgr.h>
+#include <versificationmgr.h>
#include <versekey.h>
#include <localemgr.h>
-class sword::VerseMgr::Book;
+class sword::VersificationMgr::Book;
#endif
@interface SwordBibleBook : NSObject {
#ifdef __cplusplus
- sword::VerseMgr::Book *swBook;
+ sword::VersificationMgr::Book *swBook;
#endif
NSString *localizedName;
int number;
- int numberInTestament;
- int testament;
+ char numberInTestament;
+ char testament;
NSArray *chapters;
}
@property (readwrite) int number;
-@property (readwrite) int numberInTestament;
-@property (readwrite) int testament;
+@property (readwrite) char numberInTestament;
+@property (readwrite) char testament;
@property (retain, readwrite) NSString *localizedName;
@property (retain, readwrite) NSArray *chapters;
#ifdef __cplusplus
-- (id)initWithBook:(sword::VerseMgr::Book *)aBook;
-- (sword::VerseMgr::Book *)book;
+- (id)initWithBook:(sword::VersificationMgr::Book *)aBook;
+- (sword::VersificationMgr::Book *)book;
#endif
- (NSString *)name;
@@ -43,7 +43,7 @@ class sword::VerseMgr::Book;
- (int)numberOfChapters;
- (int)numberOfVersesForChapter:(int)chapter;
/**
- get book index for versekey
+ get book index for verseKey
that is: book number + testament * 100
*/
- (int)generatedIndex;
diff --git a/bindings/objc/src/SwordBibleBook.mm b/bindings/objc/src/SwordBibleBook.mm
index 2fb9468..eeb956b 100644
--- a/bindings/objc/src/SwordBibleBook.mm
+++ b/bindings/objc/src/SwordBibleBook.mm
@@ -31,7 +31,7 @@
return self;
}
-- (id)initWithBook:(sword::VerseMgr::Book *)aBook {
+- (id)initWithBook:(sword::VersificationMgr::Book *)aBook {
self = [self init];
if(self) {
swBook = aBook;
@@ -40,7 +40,7 @@
[self setTestament:vk.Testament()];
[self setNumberInTestament:vk.Book()];
- // get system localemgr to be able to translate the english bookname
+ // get system localeMgr to be able to translate the english bookName
sword::LocaleMgr *lmgr = sword::LocaleMgr::getSystemLocaleMgr();
self.localizedName = [NSString stringWithUTF8String:lmgr->translate(swBook->getLongName())];
}
@@ -85,7 +85,7 @@
if(chapters == nil) {
NSMutableArray *temp = [NSMutableArray array];
for(int i = 0;i < swBook->getChapterMax();i++) {
- [temp addObject:[[SwordBibleChapter alloc] initWithBook:self andChapter:i+1]];
+ [temp addObject:[[[SwordBibleChapter alloc] initWithBook:self andChapter:i+1] autorelease]];
}
[self setChapters:[NSArray arrayWithArray:temp]];
}
@@ -93,14 +93,14 @@
}
/**
- get book index for versekey
+ get book index for verseKey
that is: book number + testament * 100
*/
- (int)generatedIndex {
return number + testament * 100;
}
-- (sword::VerseMgr::Book *)book {
+- (sword::VersificationMgr::Book *)book {
return swBook;
}
diff --git a/bindings/objc/src/SwordBibleChapter.h b/bindings/objc/src/SwordBibleChapter.h
index e8f29c2..11e4cff 100644
--- a/bindings/objc/src/SwordBibleChapter.h
+++ b/bindings/objc/src/SwordBibleChapter.h
@@ -6,7 +6,7 @@
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
@class SwordBibleBook;
diff --git a/bindings/objc/src/SwordBibleTextEntry.h b/bindings/objc/src/SwordBibleTextEntry.h
index 467bf18..42969cd 100644
--- a/bindings/objc/src/SwordBibleTextEntry.h
+++ b/bindings/objc/src/SwordBibleTextEntry.h
@@ -6,14 +6,14 @@
// Copyright 2010 Software by MABE. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
#import "SwordModuleTextEntry.h"
@interface SwordBibleTextEntry : SwordModuleTextEntry {
- NSString *preverseHeading;
+ NSString *preVerseHeading;
}
-@property (readwrite, retain) NSString *preverseHeading;
+@property (readwrite, retain) NSString *preVerseHeading;
+ (id)textEntryForKey:(NSString *)aKey andText:(NSString *)aText;
- (id)initWithKey:(NSString *)aKey andText:(NSString *)aText;
diff --git a/bindings/objc/src/SwordBibleTextEntry.m b/bindings/objc/src/SwordBibleTextEntry.m
index 6be2c4e..115a33c 100644
--- a/bindings/objc/src/SwordBibleTextEntry.m
+++ b/bindings/objc/src/SwordBibleTextEntry.m
@@ -10,7 +10,7 @@
@implementation SwordBibleTextEntry
-@synthesize preverseHeading;
+@synthesize preVerseHeading;
+ (id)textEntryForKey:(NSString *)aKey andText:(NSString *)aText {
return [[[SwordBibleTextEntry alloc] initWithKey:aKey andText:aText] autorelease];
@@ -30,7 +30,7 @@
}
- (void)dealloc {
- [self setPreverseHeading:nil];
+ [self setPreVerseHeading:nil];
[super dealloc];
}
diff --git a/bindings/objc/src/SwordBook.h b/bindings/objc/src/SwordBook.h
index e1cd17d..b0c520a 100644
--- a/bindings/objc/src/SwordBook.h
+++ b/bindings/objc/src/SwordBook.h
@@ -11,7 +11,7 @@
General Public License for more details. (http://www.gnu.org/licenses/gpl.html)
*/
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
#import "SwordModule.h"
#ifdef __cplusplus
@@ -29,9 +29,9 @@
@property(readwrite, retain) NSMutableDictionary *contents;
/**
- return the tree content for the given treekey
- the treekey has to be already loaded
- @param[in]: treekey that we should look for, nil for root
+ return the tree content for the given treeKey
+ the treeKey has to be already loaded
+ @param[in]: treeKey that we should look for, nil for root
@return: SwordTreeEntry
*/
- (SwordModuleTreeEntry *)treeEntryForKey:(NSString *)treeKey;
diff --git a/bindings/objc/src/SwordBook.mm b/bindings/objc/src/SwordBook.mm
index 05f622e..bcee1e4 100644
--- a/bindings/objc/src/SwordBook.mm
+++ b/bindings/objc/src/SwordBook.mm
@@ -12,7 +12,6 @@
*/
#import "SwordBook.h"
-#import "SwordModule.h"
#import "SwordModuleTreeEntry.h"
@interface SwordBook ()
@@ -54,14 +53,14 @@
}
- (SwordModuleTreeEntry *)treeEntryForKey:(NSString *)treeKey {
- SwordModuleTreeEntry * ret = nil;
+ SwordModuleTreeEntry * ret;
[moduleLock lock];
if(treeKey == nil) {
ret = [contents objectForKey:@"root"];
if(ret == nil) {
- sword::TreeKeyIdx *treeKey = dynamic_cast<sword::TreeKeyIdx*>((sword::SWKey *)*(swModule));
- ret = [self _treeEntryForKey:treeKey];
+ sword::TreeKeyIdx *tk = dynamic_cast<sword::TreeKeyIdx*>((sword::SWKey *)*(swModule));
+ ret = [self _treeEntryForKey:tk];
// add to content
[contents setObject:ret forKey:@"root"];
}
@@ -87,22 +86,22 @@
}
- (SwordModuleTreeEntry *)_treeEntryForKey:(sword::TreeKeyIdx *)treeKey {
- SwordModuleTreeEntry *ret = [[SwordModuleTreeEntry alloc] init];
+ SwordModuleTreeEntry *ret = [[[SwordModuleTreeEntry alloc] init] autorelease];
char *treeNodeName = (char *)treeKey->getText();
- NSString *nname = @"";
+ NSString *nName;
if(strlen(treeNodeName) == 0) {
- nname = @"root";
+ nName = @"root";
} else {
// key encoding depends on module encoding
- nname = [NSString stringWithUTF8String:treeNodeName];
- if(!nname) {
- nname = [NSString stringWithCString:treeNodeName encoding:NSISOLatin1StringEncoding];
+ nName = [NSString stringWithUTF8String:treeNodeName];
+ if(!nName) {
+ nName = [NSString stringWithCString:treeNodeName encoding:NSISOLatin1StringEncoding];
}
}
// set name
- [ret setKey:nname];
+ [ret setKey:nName];
NSMutableArray *c = [NSMutableArray array];
[ret setContent:c];
@@ -111,15 +110,15 @@
// get first child
treeKey->firstChild();
do {
- NSString *subname = @"";
+ NSString *subName;
// key encoding depends on module encoding
const char *textStr = treeKey->getText();
- subname = [NSString stringWithUTF8String:textStr];
- if(!subname) {
- subname = [NSString stringWithCString:textStr encoding:NSISOLatin1StringEncoding];
+ subName = [NSString stringWithUTF8String:textStr];
+ if(!subName) {
+ subName = [NSString stringWithCString:textStr encoding:NSISOLatin1StringEncoding];
}
- if(subname) {
- [c addObject:subname];
+ if(subName) {
+ [c addObject:subName];
}
}
while(treeKey->nextSibling());
@@ -131,8 +130,8 @@
- (void)testLoop {
SwordModuleTreeEntry *entry = [self treeEntryForKey:nil];
if([[entry content] count] > 0) {
- for(NSString *subkey in [entry content]) {
- entry = [self treeEntryForKey:subkey];
+ for(NSString *subKey in [entry content]) {
+ entry = [self treeEntryForKey:subKey];
if([[entry content] count] > 0) {
} else {
DLog(@"Entry: %@", [entry key]);
diff --git a/bindings/objc/src/SwordCommentary.h b/bindings/objc/src/SwordCommentary.h
index 5177139..feaf619 100644
--- a/bindings/objc/src/SwordCommentary.h
+++ b/bindings/objc/src/SwordCommentary.h
@@ -11,8 +11,8 @@
General Public License for more details. (http://www.gnu.org/licenses/gpl.html)
*/
-#import <Cocoa/Cocoa.h>
-#import "SwordBible.h"
+#import <Foundation/Foundation.h>
+#import <ObjCSword/ObjCSword.h>
#ifdef __cplusplus
#include <rawfiles.h>
@@ -20,6 +20,8 @@ class sword::RawFiles;
class sword::SWConfig;
#endif
+
+
@interface SwordCommentary : SwordBible {
}
diff --git a/bindings/objc/src/SwordCommentary.mm b/bindings/objc/src/SwordCommentary.mm
index fee1a1a..3b81738 100644
--- a/bindings/objc/src/SwordCommentary.mm
+++ b/bindings/objc/src/SwordCommentary.mm
@@ -12,7 +12,6 @@
*/
#import "SwordCommentary.h"
-#import "Configuration.h"
@implementation SwordCommentary
@@ -35,20 +34,20 @@
ret = modPath;
// create folder
- [fm createDirectoryAtPath:modPath attributes:nil];
+ [fm createDirectoryAtPath:modPath withIntermediateDirectories:NO attributes:nil error:NULL];
// create mods.d folder
NSString *modsdPath = [modPath stringByAppendingPathComponent:@"mods.d"];
- [fm createDirectoryAtPath:modsdPath attributes:nil];
+ [fm createDirectoryAtPath:modsdPath withIntermediateDirectories:NO attributes:nil error:NULL];
// create module folder
NSString *dataPath = [modPath stringByAppendingPathComponent:@"modules"];
- [fm createDirectoryAtPath:dataPath attributes:nil];
+ [fm createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:NULL];
dataPath = [dataPath stringByAppendingPathComponent:@"comments"];
- [fm createDirectoryAtPath:dataPath attributes:nil];
+ [fm createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:NULL];
dataPath = [dataPath stringByAppendingPathComponent:@"rawfiles"];
- [fm createDirectoryAtPath:dataPath attributes:nil];
+ [fm createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:NULL];
dataPath = [dataPath stringByAppendingPathComponent:aName];
- [fm createDirectoryAtPath:dataPath attributes:nil];
+ [fm createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:NULL];
// let's create a brand new empty module
sword::RawFiles::createModule([dataPath UTF8String]);
diff --git a/bindings/objc/src/SwordDictionary.h b/bindings/objc/src/SwordDictionary.h
index 77df1e2..6fea741 100644
--- a/bindings/objc/src/SwordDictionary.h
+++ b/bindings/objc/src/SwordDictionary.h
@@ -11,10 +11,9 @@
General Public License for more details. (http://www.gnu.org/licenses/gpl.html)
*/
-#import <Cocoa/Cocoa.h>
-#import "SwordModule.h"
+#import <Foundation/Foundation.h>
-@class SwordManager;
+@class SwordManager, SwordModule;
@interface SwordDictionary : SwordModule {
/** only keys are buffered here */
@@ -24,5 +23,4 @@
- (NSArray *)allKeys;
- (NSString *)entryForKey:(NSString *)aKey;
-
@end
diff --git a/bindings/objc/src/SwordDictionary.mm b/bindings/objc/src/SwordDictionary.mm
index 2876e47..4924d00 100644
--- a/bindings/objc/src/SwordDictionary.mm
+++ b/bindings/objc/src/SwordDictionary.mm
@@ -11,9 +11,7 @@
General Public License for more details. (http://www.gnu.org/licenses/gpl.html)
*/
-#import "SwordDictionary.h"
-#import "SwordModuleTextEntry.h"
-#import "Configuration.h"
+#import <ObjCSword/ObjCSword.h>
@interface SwordDictionary (/* Private, class continuation */)
/** private property */
@@ -78,7 +76,7 @@
- (void)readFromCache {
//open cached file
NSString *cachePath = [[[Configuration config] defaultAppSupportPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"cache-%@", [self name]]];
- NSMutableArray *data = [NSArray arrayWithContentsOfFile:cachePath];
+ NSMutableArray *data = [NSMutableArray arrayWithContentsOfFile:cachePath];
if(data != nil) {
self.keys = data;
} else {
@@ -156,8 +154,12 @@
}
- (id)attributeValueForParsedLinkData:(NSDictionary *)data {
- id ret = nil;
+ return [self attributeValueForParsedLinkData:data withTextRenderType:TextTypeStripped];
+}
+- (id)attributeValueForParsedLinkData:(NSDictionary *)data withTextRenderType:(TextPullType)textType {
+ id ret = nil;
+
NSString *attrType = [data objectForKey:ATTRTYPE_TYPE];
if([attrType isEqualToString:@"scriptRef"] ||
[attrType isEqualToString:@"scripRef"] ||
diff --git a/bindings/objc/src/SwordFilter.h b/bindings/objc/src/SwordFilter.h
new file mode 100644
index 0000000..590c550
--- /dev/null
+++ b/bindings/objc/src/SwordFilter.h
@@ -0,0 +1,61 @@
+//
+// Created by mbergmann on 18.12.12.
+//
+// To change the template use AppCode | Preferences | File Templates.
+//
+
+
+#import <Foundation/Foundation.h>
+
+#ifdef __cplusplus
+#include <swfilter.h>
+#endif
+
+@interface SwordFilter : NSObject
+
+#ifdef __cplusplus
+- (id)initWithSWFilter:(sword::SWFilter *)swFilter;
+- (sword::SWFilter *)swFilter;
+#endif
+
+@end
+
+@interface SwordOsisHtmlRefFilter : SwordFilter
++ (SwordOsisHtmlRefFilter *)filter;
+@end
+
+@interface SwordOsisPlainFilter : SwordFilter
++ (SwordOsisPlainFilter *)filter;
+@end
+
+@interface SwordOsisXHtmlFilter : SwordFilter
++ (SwordOsisXHtmlFilter *)filter;
+@end
+
+@interface SwordThmlHtmlFilter : SwordFilter
++ (SwordThmlHtmlFilter *)filter;
+@end
+
+@interface SwordThmlPlainFilter : SwordFilter
++ (SwordThmlPlainFilter *)filter;
+@end
+
+@interface SwordGbfHtmlFilter : SwordFilter
++ (SwordGbfHtmlFilter *)filter;
+@end
+
+@interface SwordGbfPlainFilter : SwordFilter
++ (SwordGbfPlainFilter *)filter;
+@end
+
+@interface SwordTeiHtmlFilter : SwordFilter
++ (SwordTeiHtmlFilter *)filter;
+@end
+
+@interface SwordTeiXHtmlFilter : SwordFilter
++ (SwordTeiXHtmlFilter *)filter;
+@end
+
+@interface SwordTeiPlainFilter : SwordFilter
++ (SwordTeiPlainFilter *)filter;
+@end
diff --git a/bindings/objc/src/SwordFilter.mm b/bindings/objc/src/SwordFilter.mm
new file mode 100644
index 0000000..7d609bc
--- /dev/null
+++ b/bindings/objc/src/SwordFilter.mm
@@ -0,0 +1,142 @@
+//
+// Created by mbergmann on 18.12.12.
+//
+// To change the template use AppCode | Preferences | File Templates.
+//
+
+
+#import "SwordFilter.h"
+#import "osishtmlhref.h"
+#import "osisplain.h"
+#import "osisxhtml.h"
+#import "thmlhtmlhref.h"
+#import "thmlplain.h"
+#import "gbfhtmlhref.h"
+#import "gbfplain.h"
+#import "teihtmlhref.h"
+#import "teixhtml.h"
+#import "teiplain.h"
+
+@implementation SwordFilter {
+ sword::SWFilter *swFilter;
+}
+
+- (id)initWithSWFilter:(sword::SWFilter *)swFilter1 {
+ self = [super init];
+ if (self) {
+ swFilter = swFilter1;
+ }
+
+ return self;
+}
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+- (sword::SWFilter *)swFilter {
+ return swFilter;
+}
+
+@end
+
+@implementation SwordOsisHtmlRefFilter
++ (SwordOsisHtmlRefFilter *)filter {
+ return [[[SwordOsisHtmlRefFilter alloc] init] autorelease];
+}
+
+- (id)init {
+ return [super initWithSWFilter:new sword::OSISHTMLHREF()];
+}
+@end
+
+@implementation SwordOsisXHtmlFilter
++ (SwordOsisXHtmlFilter *)filter {
+ return [[[SwordOsisXHtmlFilter alloc] init] autorelease];
+}
+
+- (id)init {
+ return [super initWithSWFilter:new sword::OSISXHTML()];
+}
+@end
+
+@implementation SwordOsisPlainFilter
++ (SwordOsisPlainFilter *)filter {
+ return [[[SwordOsisPlainFilter alloc] init] autorelease];
+}
+
+- (id)init {
+ return [super initWithSWFilter:new sword::OSISPlain()];
+}
+@end
+
+@implementation SwordThmlHtmlFilter
++ (SwordThmlHtmlFilter *)filter {
+ return [[[SwordThmlHtmlFilter alloc] init] autorelease];
+}
+
+- (id)init {
+ return [super initWithSWFilter:new sword::ThMLHTMLHREF()];
+}
+@end
+
+@implementation SwordThmlPlainFilter
++ (SwordThmlPlainFilter *)filter {
+ return [[[SwordThmlPlainFilter alloc] init] autorelease];
+}
+
+- (id)init {
+ return [super initWithSWFilter:new sword::ThMLPlain()];
+}
+@end
+
+@implementation SwordGbfHtmlFilter
++ (SwordGbfHtmlFilter *)filter {
+ return [[[SwordGbfHtmlFilter alloc] init] autorelease];
+}
+
+- (id)init {
+ return [super initWithSWFilter:new sword::ThMLHTMLHREF()];
+}
+@end
+
+@implementation SwordGbfPlainFilter
++ (SwordGbfPlainFilter *)filter {
+ return [[[SwordGbfPlainFilter alloc] init] autorelease];
+}
+
+- (id)init {
+ return [super initWithSWFilter:new sword::ThMLPlain()];
+}
+@end
+
+@implementation SwordTeiHtmlFilter
++ (SwordTeiHtmlFilter *)filter {
+ return [[[SwordTeiHtmlFilter alloc] init] autorelease];
+}
+
+- (id)init {
+ return [super initWithSWFilter:new sword::TEIHTMLHREF()];
+}
+@end
+
+@implementation SwordTeiXHtmlFilter
++ (SwordTeiXHtmlFilter *)filter {
+ return [[[SwordTeiXHtmlFilter alloc] init] autorelease];
+}
+
+- (id)init {
+ return [super initWithSWFilter:new sword::TEIXHTML()];
+}
+@end
+
+@implementation SwordTeiPlainFilter
++ (SwordTeiPlainFilter *)filter {
+ return [[[SwordTeiPlainFilter alloc] init] autorelease];
+}
+
+- (id)init {
+ return [super initWithSWFilter:new sword::TEIPlain()];
+}
+@end
+
diff --git a/bindings/objc/src/SwordInstallSource.h b/bindings/objc/src/SwordInstallSource.h
index c0f8659..1b1bdf3 100644
--- a/bindings/objc/src/SwordInstallSource.h
+++ b/bindings/objc/src/SwordInstallSource.h
@@ -6,7 +6,8 @@
// Copyright 2007 __MyCompanyName__. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
+#import "SwordModule.h"
#ifdef __cplusplus
#include <swmgr.h>
@@ -15,7 +16,7 @@ class sword::SWModule;
#endif
@class SwordManager;
-@class SwordInstallSourceController;
+@class SwordInstallSourceManager;
#define INSTALLSOURCE_TYPE_FTP @"FTP"
@@ -25,10 +26,10 @@ class sword::SWModule;
sword::InstallSource *swInstallSource;
#endif
- /** the sword manager for this source */
- SwordManager *swordManager;
-
BOOL temporarySource;
+
+ /** the sword manager for this source */
+ SwordManager *swordManager;
}
// init
@@ -56,14 +57,20 @@ class sword::SWModule;
// install module
- (void)installModuleWithName:(NSString *)mName
usingManager:(SwordManager *)swManager
- withInstallController:(SwordInstallSourceController *)sim;
+ withInstallController:(SwordInstallSourceManager *)sim;
-// list modules of this source
+/** List of available InstallSources */
- (NSArray *)listModules;
+
+/** List of modules for given type */
+- (NSArray *)listModulesForType:(ModuleType)aType;
+
/** list module types */
- (NSArray *)listModuleTypes;
-// get associated SwordManager
+
+/** Returns the SwordManager attached to this SwordInstallSourceController */
- (SwordManager *)swordManager;
+- (void)setSwordManager:(SwordManager *)swManager;
#ifdef __cplusplus
- (sword::InstallSource *)installSource;
diff --git a/bindings/objc/src/SwordInstallSource.mm b/bindings/objc/src/SwordInstallSource.mm
index 5c2c9aa..b1f71d3 100644
--- a/bindings/objc/src/SwordInstallSource.mm
+++ b/bindings/objc/src/SwordInstallSource.mm
@@ -7,30 +7,17 @@
//
#import "SwordInstallSource.h"
-#import "SwordInstallSourceController.h"
+#import "SwordInstallSourceManager.h"
#import "SwordManager.h"
-@interface SwordInstallSource (PrivateAPI)
-
-- (void)setSwordManager:(SwordManager *)swManager;
-
-@end
-
-@implementation SwordInstallSource (PrivateAPI)
-
-- (void)setSwordManager:(SwordManager *)swManager {
- [swManager retain];
- [swordManager release];
- swordManager = swManager;
-}
+@interface SwordInstallSource ()
@end
@implementation SwordInstallSource
// init
-- (id)init
-{
+- (id)init {
self = [super init];
if(self) {
temporarySource = NO;
@@ -75,7 +62,7 @@
- (void)finalize {
if(temporarySource == NO) {
- //LogL(LOG_DEBUG, @"[SwordInstallSource -finalize] deleting swInstalSource");
+ //LogL(LOG_DEBUG, @"[SwordInstallSource -finalize] deleting swInstallSource");
//delete swInstallSource;
}
@@ -83,9 +70,16 @@
}
- (void)dealloc {
+ [swordManager release];
[super dealloc];
}
+- (void)setSwordManager:(SwordManager *)swManager {
+ [swManager retain];
+ [swordManager release];
+ swordManager = swManager;
+}
+
// accessors
- (NSString *)caption {
const char *str = swInstallSource->caption;
@@ -133,16 +127,14 @@
}
/** install module */
-- (void)installModuleWithName:(NSString *)mName usingManager:(SwordManager *)swManager withInstallController:(SwordInstallSourceController *)sim {
+- (void)installModuleWithName:(NSString *)mName usingManager:(SwordManager *)swManager withInstallController:(SwordInstallSourceManager *)sim {
sword::InstallMgr *im = [sim installMgr];
im->installModule([swManager swManager], 0, [mName UTF8String], swInstallSource);
}
/** list all modules of this source */
- (NSArray *)listModules {
- NSArray *ret = nil;
-
- DLog(@"");
+ NSArray *ret = [NSArray array];
SwordManager *sm = [self swordManager];
if(sm) {
@@ -154,14 +146,23 @@
return ret;
}
+- (NSArray *)listModulesForType:(ModuleType)aType {
+ NSArray *ret = [NSArray array];
+
+ SwordManager *sm = [self swordManager];
+ if(sm) {
+ ret = [sm modulesForType:aType];
+ } else {
+ ALog(@"Have nil SwordManager");
+ }
+
+ return ret;
+}
+
/** list module types */
- (NSArray *)listModuleTypes {
- NSArray *ret = nil;
-
- DLog(@"");
- ret = [SwordManager moduleTypes];
-
- return ret;
+ NSArray *ret = [SwordManager moduleTypes];
+ return ret;
}
// get associated SwordManager
@@ -172,7 +173,7 @@
sword::SWMgr *mgr;
if([[self source] isEqualToString:@"localhost"]) {
// create SwordManager from new SWMgr of path
- mgr = (sword::SWMgr *)new sword::SWMgr([[self directory] UTF8String], true, NULL, false, false);
+ mgr = new sword::SWMgr([[self directory] UTF8String], true, NULL, false, false);
} else {
// create SwordManager from the SWMgr of this source
mgr = swInstallSource->getMgr();
diff --git a/bindings/objc/src/SwordInstallSourceController.h b/bindings/objc/src/SwordInstallSourceManager.h
index 1f5dda5..ee22c48 100644..100755
--- a/bindings/objc/src/SwordInstallSourceController.h
+++ b/bindings/objc/src/SwordInstallSourceManager.h
@@ -6,7 +6,7 @@
// Copyright 2007 __MyCompanyName__. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
#ifdef __cplusplus
#include <swmgr.h>
@@ -32,32 +32,30 @@ typedef enum _ModuleStatusConst {
ModStatCipheredKeyPresent = 0x020
}ModuleStatusConst;
-@interface SwordInstallSourceController : NSObject {
+@interface SwordInstallSourceManager : NSObject {
@private
#ifdef __cplusplus
sword::InstallMgr *swInstallMgr;
#endif
-
+
BOOL createPath;
NSString *configPath;
- NSString *configFilePath;
-
- /** the dictionary holding the install sources. caption is the key */
- NSMutableDictionary *installSources;
- NSMutableArray *installSourceList;
}
// ------------------- getter / setter -------------------
@property (retain, readwrite) NSString *configPath;
@property (retain, readwrite) NSString *configFilePath;
-@property (retain, readwrite) NSMutableDictionary *installSources;
@property (retain, readwrite) NSMutableArray *installSourceList;
+/** Dictionary of InstallSources. Key: Caption */
+@property (retain, readwrite) NSMutableDictionary *installSources;
// -------------------- methods --------------------
// initialization
-+ (SwordInstallSourceController *)defaultController;
++ (SwordInstallSourceManager *)defaultController;
++ (SwordInstallSourceManager *)defaultControllerWithPath:(NSString *)aPath;
++ (SwordInstallSourceManager *)controllerWithPath:(NSString *)aPath;
/**
base path of the module installation
@@ -68,7 +66,7 @@ base path of the module installation
/** re-init after adding or removing new modules */
- (void)reinitialize;
-// installation/uninstallation
+// installation/unInstallation
- (int)installModule:(SwordModule *)aModule fromSource:(SwordInstallSource *)is withManager:(SwordManager *)manager;
- (int)uninstallModule:(SwordModule *)aModule fromManager:(SwordManager *)swManager;
@@ -82,7 +80,7 @@ base path of the module installation
// disclaimer
- (BOOL)userDisclaimerConfirmed;
-- (void)setUserDisclainerConfirmed:(BOOL)flag;
+- (void)setUserDisclaimerConfirmed:(BOOL)flag;
// list modules in sources
- (NSArray *)listModulesForSource:(SwordInstallSource *)is;
diff --git a/bindings/objc/src/SwordInstallSourceController.mm b/bindings/objc/src/SwordInstallSourceManager.mm
index 452c005..98d6cac 100644..100755
--- a/bindings/objc/src/SwordInstallSourceController.mm
+++ b/bindings/objc/src/SwordInstallSourceManager.mm
@@ -6,13 +6,10 @@
// Copyright 2007 __MyCompanyName__. All rights reserved.
//
-#import "SwordInstallSourceController.h"
+#import "SwordInstallSourceManager.h"
#import "SwordInstallSource.h"
#import "SwordManager.h"
-#import "SwordModule.h"
-
-#include "installmgr.h"
-//#include "MyInstallMgr.h"
+#import "ObjCSword_Prefix.pch"
#ifdef __cplusplus
typedef std::map<sword::SWBuf, sword::InstallSource *> InstallSourceMap;
@@ -22,12 +19,9 @@ typedef sword::multimapwithdefault<sword::SWBuf, sword::SWBuf, std::less <sword:
#define INSTALLSOURCE_SECTION_TYPE_FTP "FTPSource"
#define INSTALLSOURCE_SECTION_TYPE_HTTP "HTTPSource"
-@implementation SwordInstallSourceController
+@implementation SwordInstallSourceManager
@dynamic configPath;
-@synthesize configFilePath;
-@synthesize installSources;
-@synthesize installSourceList;
// ------------------- getter / setter -------------------
- (NSString *)configPath {
@@ -41,46 +35,48 @@ typedef sword::multimapwithdefault<sword::SWBuf, sword::SWBuf, std::less <sword:
[configPath release];
configPath = [value copy];
- if(value != nil) {
- // check for existence
- NSFileManager *fm = [NSFileManager defaultManager];
- BOOL isDir;
- if(([fm fileExistsAtPath:configPath] == NO) && createPath == YES) {
- // create path
- [fm createDirectoryAtPath:configPath attributes:nil];
- }
+ if(value == nil) {
+ return;
+ }
+
+
+ // check for existence
+ NSFileManager *fm = [NSFileManager defaultManager];
+ BOOL isDir;
+ if(([fm fileExistsAtPath:configPath] == NO) && createPath == YES) {
+ // create path
+ [fm createDirectoryAtPath:configPath withIntermediateDirectories:NO attributes:nil error:NULL];
+ }
+
+ if(([fm fileExistsAtPath:configPath isDirectory:&isDir] == YES) && (isDir)) {
+ // set configFilePath
+ [self setConfigFilePath:[configPath stringByAppendingPathComponent:@"InstallMgr.conf"]];
- if(([fm fileExistsAtPath:configPath isDirectory:&isDir] == YES) && (isDir)) {
- // set configFilePath
- [self setConfigFilePath:[configPath stringByAppendingPathComponent:@"InstallMgr.conf"]];
+ // check config
+ if([fm fileExistsAtPath:self.configFilePath] == NO) {
+ // create config entry
+ sword::SWConfig config([self.configFilePath cStringUsingEncoding:NSUTF8StringEncoding]);
+ config["General"]["PassiveFTP"] = "true";
+ config.Save();
+
+ // create default Install source
+ SwordInstallSource *is = [[[SwordInstallSource alloc] initWithType:INSTALLSOURCE_TYPE_FTP] autorelease];
+ [is setCaption:@"CrossWire"];
+ [is setSource:@"ftp.crosswire.org"];
+ [is setDirectory:@"/pub/sword/raw"];
+
+ // addInstallSource will reinitialize
+ [self addInstallSource:is withReinitialize:NO];
- // check config
- if([fm fileExistsAtPath:configFilePath] == NO) {
- // create config entry
- sword::SWConfig config([configFilePath cStringUsingEncoding:NSUTF8StringEncoding]);
- config["General"]["PassiveFTP"] = "true";
- config.Save();
-
- // create default Install source
- SwordInstallSource *is = [[[SwordInstallSource alloc] initWithType:INSTALLSOURCE_TYPE_FTP] autorelease];
- [is setCaption:@"CrossWire"];
- [is setSource:@"ftp.crosswire.org"];
- [is setDirectory:@"/pub/sword/raw"];
-
- // addInstallSource will reinitialize
- [self addInstallSource:is];
-
- } else {
- // init installMgr
- [self reinitialize];
- }
-
- // sync with master install source list
- //[self refreshMasterRemoteInstallSourceList];
-
- } else {
- ALog(@"Config path does not exist: %@", configPath);
}
+ // init installMgr
+ [self reinitialize];
+
+ // sync with master install source list
+ //[self refreshMasterRemoteInstallSourceList];
+
+ } else {
+ ALog(@"Config path does not exist: %@", configPath);
}
}
}
@@ -88,15 +84,25 @@ typedef sword::multimapwithdefault<sword::SWBuf, sword::SWBuf, std::less <sword:
// -------------------- methods --------------------
// initialization
-+ (SwordInstallSourceController *)defaultController {
- static SwordInstallSourceController *singleton;
++ (SwordInstallSourceManager *)defaultController {
+ static SwordInstallSourceManager *singleton = nil;
if(singleton == nil) {
- singleton = [[SwordInstallSourceController alloc] init];
+ singleton = [[SwordInstallSourceManager alloc] init];
}
return singleton;
}
++ (SwordInstallSourceManager *)defaultControllerWithPath:(NSString *)aPath {
+ SwordInstallSourceManager *m = [SwordInstallSourceManager defaultController];
+ [m setConfigPath:aPath];
+ return m;
+}
+
++ (SwordInstallSourceManager *)controllerWithPath:(NSString *)aPath {
+ return [[[SwordInstallSourceManager alloc] initWithPath:aPath createPath:YES] autorelease];
+}
+
/**
base path of the module installation
*/
@@ -128,7 +134,7 @@ base path of the module installation
/** re-init after adding or removing new modules */
- (void)reinitialize {
- sword::SWConfig config([configFilePath UTF8String]);
+ sword::SWConfig config([self.configFilePath UTF8String]);
config.Load();
// init installMgr
@@ -140,20 +146,20 @@ base path of the module installation
if(swInstallMgr == nil) {
ALog(@"Could not initialize InstallMgr!");
} else {
- [self setUserDisclainerConfirmed:disclaimerConfirmed];
+ [self setUserDisclaimerConfirmed:disclaimerConfirmed];
// empty all lists
- [installSources removeAllObjects];
- [installSourceList removeAllObjects];
+ [self.installSources removeAllObjects];
+ [self.installSourceList removeAllObjects];
// init install sources
for(InstallSourceMap::iterator it = swInstallMgr->sources.begin(); it != swInstallMgr->sources.end(); it++) {
sword::InstallSource *sis = it->second;
- SwordInstallSource *is = [[SwordInstallSource alloc] initWithSource:(id)sis];
+ SwordInstallSource *is = [[[SwordInstallSource alloc] initWithSource:sis] autorelease];
- [installSources setObject:is forKey:[is caption]];
+ [self.installSources setObject:is forKey:[is caption]];
// also add to list
- [installSourceList addObject:is];
+ [self.installSourceList addObject:is];
}
}
}
@@ -187,7 +193,7 @@ base path of the module installation
- (void)addInstallSource:(SwordInstallSource *)is withReinitialize:(BOOL)reinit {
// save at once
- sword::SWConfig config([configFilePath cStringUsingEncoding:NSUTF8StringEncoding]);
+ sword::SWConfig config([self.configFilePath cStringUsingEncoding:NSUTF8StringEncoding]);
if([[is type] isEqualToString:INSTALLSOURCE_TYPE_FTP]) {
config["Sources"].insert(ConfigEntMap::value_type(INSTALLSOURCE_SECTION_TYPE_FTP, [[is configEntry] UTF8String]));
} else {
@@ -206,18 +212,16 @@ base path of the module installation
- (void)removeInstallSource:(SwordInstallSource *)is withReinitialize:(BOOL)reinit {
// remove source
- [installSources removeObjectForKey:[is caption]];
- [installSourceList removeObject:is];
+ [self.installSources removeObjectForKey:[is caption]];
+ [self.installSourceList removeObject:is];
// save at once
- sword::SWConfig config([configFilePath cStringUsingEncoding:NSUTF8StringEncoding]);
+ sword::SWConfig config([self.configFilePath cStringUsingEncoding:NSUTF8StringEncoding]);
config["Sources"].erase(INSTALLSOURCE_SECTION_TYPE_HTTP);
config["Sources"].erase(INSTALLSOURCE_SECTION_TYPE_FTP);
// build up new
- NSEnumerator *iter = [installSources objectEnumerator];
- SwordInstallSource *sis = nil;
- while((sis = [iter nextObject])) {
+ for(SwordInstallSource *sis in self.installSources) {
if([[sis type] isEqualToString:INSTALLSOURCE_TYPE_FTP]) {
config["Sources"].insert(ConfigEntMap::value_type(INSTALLSOURCE_SECTION_TYPE_FTP, [[sis configEntry] UTF8String]));
} else {
@@ -236,10 +240,10 @@ base path of the module installation
[self addInstallSource:is];
}
-// installation/uninstallation
+// installation/unInstallation
- (int)installModule:(SwordModule *)aModule fromSource:(SwordInstallSource *)is withManager:(SwordManager *)manager {
- int stat = -1;
+ int stat;
if([[is source] isEqualToString:@"localhost"]) {
stat = swInstallMgr->installModule([manager swManager], [[is directory] UTF8String], [[aModule name] UTF8String]);
} else {
@@ -305,7 +309,7 @@ base path of the module installation
module = it->first;
status = it->second;
- SwordModule *mod = [[SwordModule alloc] initWithSWModule:module];
+ SwordModule *mod = [[[SwordModule alloc] initWithSWModule:module] autorelease];
[mod setStatus:status];
[ar addObject:mod];
}
@@ -321,7 +325,7 @@ base path of the module installation
return swInstallMgr->isUserDisclaimerConfirmed();
}
-- (void)setUserDisclainerConfirmed:(BOOL)flag {
+- (void)setUserDisclaimerConfirmed:(BOOL)flag {
swInstallMgr->setUserDisclaimerConfirmed(flag);
}
diff --git a/bindings/objc/src/SwordKey.h b/bindings/objc/src/SwordKey.h
index 9761bda..caa4f35 100644
--- a/bindings/objc/src/SwordKey.h
+++ b/bindings/objc/src/SwordKey.h
@@ -6,7 +6,7 @@
// Copyright 2009 Software by MABE. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
#ifdef __cplusplus
#include <swkey.h>
@@ -19,20 +19,20 @@
BOOL created;
}
-+ (id)swordKey;
-+ (id)swordKeyWithRef:(NSString *)aRef;
++ (SwordKey *)swordKey;
++ (SwordKey *)swordKeyWithRef:(NSString *)aRef;
#ifdef __cplusplus
-+ (id)swordKeyWithSWKey:(sword::SWKey *)aSk;
-+ (id)swordKeyWithSWKey:(sword::SWKey *)aSk makeCopy:(BOOL)copy;
-- (id)initWithSWKey:(sword::SWKey *)aSk;
-- (id)initWithSWKey:(sword::SWKey *)aSk makeCopy:(BOOL)copy;
++ (SwordKey *)swordKeyWithSWKey:(sword::SWKey *)aSk;
++ (SwordKey *)swordKeyWithSWKey:(sword::SWKey *)aSk makeCopy:(BOOL)copy;
+- (SwordKey *)initWithSWKey:(sword::SWKey *)aSk;
+- (SwordKey *)initWithSWKey:(sword::SWKey *)aSk makeCopy:(BOOL)copy;
- (sword::SWKey *)swKey;
#endif
-- (id)initWithRef:(NSString *)aRef;
+- (SwordKey *)initWithRef:(NSString *)aRef;
-- (id)clone;
+- (SwordKey *)clone;
- (void)setPersist:(BOOL)flag;
- (BOOL)persist;
diff --git a/bindings/objc/src/SwordKey.mm b/bindings/objc/src/SwordKey.mm
index 2417e93..5254443 100644
--- a/bindings/objc/src/SwordKey.mm
+++ b/bindings/objc/src/SwordKey.mm
@@ -11,19 +11,19 @@
@implementation SwordKey
-+ (id)swordKey {
++ (SwordKey *)swordKey {
return [[[SwordKey alloc] init] autorelease];
}
-+ (id)swordKeyWithRef:(NSString *)aRef {
++ (SwordKey *)swordKeyWithRef:(NSString *)aRef {
return [[[SwordKey alloc] initWithRef:aRef] autorelease];
}
-+ (id)swordKeyWithSWKey:(sword::SWKey *)aSk {
++ (SwordKey *)swordKeyWithSWKey:(sword::SWKey *)aSk {
return [[[SwordKey alloc] initWithSWKey:aSk] autorelease];
}
-+ (id)swordKeyWithSWKey:(sword::SWKey *)aSk makeCopy:(BOOL)copy {
++ (SwordKey *)swordKeyWithSWKey:(sword::SWKey *)aSk makeCopy:(BOOL)copy {
return [[[SwordKey alloc] initWithSWKey:aSk makeCopy:copy] autorelease];
}
@@ -31,11 +31,11 @@
return [self initWithRef:nil];
}
-- (id)initWithSWKey:(sword::SWKey *)aSk {
+- (SwordKey *)initWithSWKey:(sword::SWKey *)aSk {
return [self initWithSWKey:aSk makeCopy:NO];
}
-- (id)initWithSWKey:(sword::SWKey *)aSk makeCopy:(BOOL)copy {
+- (SwordKey *)initWithSWKey:(sword::SWKey *)aSk makeCopy:(BOOL)copy {
self = [super init];
if(self) {
if(copy) {
@@ -53,7 +53,7 @@
return self;
}
-- (id)initWithRef:(NSString *)aRef {
+- (SwordKey *)initWithRef:(NSString *)aRef {
self = [super init];
if(self) {
sk = new sword::SWKey([aRef UTF8String]);
@@ -79,7 +79,7 @@
[super dealloc];
}
-- (id)clone {
+- (SwordKey *)clone {
return [SwordKey swordKeyWithSWKey:sk];
}
diff --git a/bindings/objc/src/SwordListKey.h b/bindings/objc/src/SwordListKey.h
index 0ce68ac..043ea81 100644
--- a/bindings/objc/src/SwordListKey.h
+++ b/bindings/objc/src/SwordListKey.h
@@ -6,7 +6,7 @@
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
#import "SwordKey.h"
#ifdef __cplusplus
@@ -15,31 +15,32 @@
#endif
@class SwordBible, VerseEnumerator;
+@class SwordVerseKey;
@interface SwordListKey : SwordKey {
}
-+ (id)listKeyWithRef:(NSString *)aRef;
-+ (id)listKeyWithRef:(NSString *)aRef v11n:(NSString *)scheme;
-+ (id)listKeyWithRef:(NSString *)aRef headings:(BOOL)headings v11n:(NSString *)scheme;
++ (SwordListKey *)listKeyWithRef:(NSString *)aRef;
++ (SwordListKey *)listKeyWithRef:(NSString *)aRef v11n:(NSString *)scheme;
++ (SwordListKey *)listKeyWithRef:(NSString *)aRef headings:(BOOL)headings v11n:(NSString *)scheme;
#ifdef __cplusplus
-+ (id)listKeyWithSWListKey:(sword::ListKey *)aLk;
-+ (id)listKeyWithSWListKey:(sword::ListKey *)aLk makeCopy:(BOOL)copy;
-- (id)initWithSWListKey:(sword::ListKey *)aLk;
-- (id)initWithSWListKey:(sword::ListKey *)aLk makeCopy:(BOOL)copy;
++ (SwordListKey *)listKeyWithSWListKey:(sword::ListKey *)aLk;
++ (SwordListKey *)listKeyWithSWListKey:(sword::ListKey *)aLk makeCopy:(BOOL)copy;
+- (SwordListKey *)initWithSWListKey:(sword::ListKey *)aLk;
+- (SwordListKey *)initWithSWListKey:(sword::ListKey *)aLk makeCopy:(BOOL)copy;
- (sword::ListKey *)swListKey;
#endif
-- (id)initWithRef:(NSString *)aRef;
-- (id)initWithRef:(NSString *)aRef v11n:(NSString *)scheme;
-- (id)initWithRef:(NSString *)aRef headings:(BOOL)headings v11n:(NSString *)scheme;
+- (SwordListKey *)initWithRef:(NSString *)aRef;
+- (SwordListKey *)initWithRef:(NSString *)aRef v11n:(NSString *)scheme;
+- (SwordListKey *)initWithRef:(NSString *)aRef headings:(BOOL)headings v11n:(NSString *)scheme;
- (void)parse;
- (void)parseWithHeaders;
- (VerseEnumerator *)verseEnumerator;
- (NSInteger)numberOfVerses;
-- (BOOL)containsKey:(SwordKey *)aVerseKey;
+- (BOOL)containsKey:(SwordVerseKey *)aVerseKey;
@end
diff --git a/bindings/objc/src/SwordListKey.mm b/bindings/objc/src/SwordListKey.mm
index 161c6aa..07aa8f8 100644
--- a/bindings/objc/src/SwordListKey.mm
+++ b/bindings/objc/src/SwordListKey.mm
@@ -6,33 +6,27 @@
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
-#import "SwordListKey.h"
-#import "SwordBible.h"
-#import "SwordVerseKey.h"
-#import "VerseEnumerator.h"
-
-@interface SwordListKey ()
-@end
+#import <ObjCSword/ObjCSword.h>
@implementation SwordListKey
-+ (id)listKeyWithRef:(NSString *)aRef {
++ (SwordListKey *)listKeyWithRef:(NSString *)aRef {
return [[[SwordListKey alloc] initWithRef:aRef] autorelease];
}
-+ (id)listKeyWithRef:(NSString *)aRef v11n:(NSString *)scheme {
++ (SwordListKey *)listKeyWithRef:(NSString *)aRef v11n:(NSString *)scheme {
return [[[SwordListKey alloc] initWithRef:aRef v11n:scheme] autorelease];
}
-+ (id)listKeyWithRef:(NSString *)aRef headings:(BOOL)headings v11n:(NSString *)scheme {
++ (SwordListKey *)listKeyWithRef:(NSString *)aRef headings:(BOOL)headings v11n:(NSString *)scheme {
return [[[SwordListKey alloc] initWithRef:aRef headings:headings v11n:scheme] autorelease];
}
-+ (id)listKeyWithSWListKey:(sword::ListKey *)aLk {
++ (SwordListKey *)listKeyWithSWListKey:(sword::ListKey *)aLk {
return [[[SwordListKey alloc] initWithSWListKey:aLk] autorelease];
}
-+ (id)listKeyWithSWListKey:(sword::ListKey *)aLk makeCopy:(BOOL)copy {
++ (SwordListKey *)listKeyWithSWListKey:(sword::ListKey *)aLk makeCopy:(BOOL)copy {
return [[[SwordListKey alloc] initWithSWListKey:aLk makeCopy:copy] autorelease];
}
@@ -40,23 +34,23 @@
return [super init];
}
-- (id)initWithSWListKey:(sword::ListKey *)aLk {
- return [super initWithSWKey:aLk];
+- (SwordListKey *)initWithSWListKey:(sword::ListKey *)aLk {
+ return (SwordListKey *) [super initWithSWKey:aLk];
}
-- (id)initWithSWListKey:(sword::ListKey *)aLk makeCopy:(BOOL)copy {
- return [super initWithSWKey:aLk makeCopy:copy];
+- (SwordListKey *)initWithSWListKey:(sword::ListKey *)aLk makeCopy:(BOOL)copy {
+ return (SwordListKey *) [super initWithSWKey:aLk makeCopy:copy];
}
-- (id)initWithRef:(NSString *)aRef {
+- (SwordListKey *)initWithRef:(NSString *)aRef {
return [self initWithRef:aRef v11n:nil];
}
-- (id)initWithRef:(NSString *)aRef v11n:(NSString *)scheme {
+- (SwordListKey *)initWithRef:(NSString *)aRef v11n:(NSString *)scheme {
return [self initWithRef:aRef headings:NO v11n:scheme];
}
-- (id)initWithRef:(NSString *)aRef headings:(BOOL)headings v11n:(NSString *)scheme {
+- (SwordListKey *)initWithRef:(NSString *)aRef headings:(BOOL)headings v11n:(NSString *)scheme {
sword::VerseKey vk;
vk.Headings((char)headings);
if(scheme) {
@@ -64,7 +58,7 @@
}
sword::ListKey listKey = vk.ParseVerseList([aRef UTF8String], "gen", true);
sword::ListKey *lk = new sword::ListKey(listKey);
- return [super initWithSWKey:lk];
+ return (SwordListKey *) [super initWithSWKey:lk];
}
- (void)finalize {
@@ -90,7 +84,6 @@
}
- (void)parseWithHeaders {
-
}
- (VerseEnumerator *)verseEnumerator {
@@ -99,12 +92,10 @@
- (BOOL)containsKey:(SwordVerseKey *)aVerseKey {
BOOL ret = NO;
-
if(sk) {
*sk = [[aVerseKey osisRef] UTF8String];
ret = !sk->Error();
}
-
return ret;
}
diff --git a/bindings/objc/src/SwordLocaleManager.h b/bindings/objc/src/SwordLocaleManager.h
index ab4395f..dd67a13 100644
--- a/bindings/objc/src/SwordLocaleManager.h
+++ b/bindings/objc/src/SwordLocaleManager.h
@@ -6,7 +6,7 @@
// Copyright 2010 Software by MABE. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
@interface SwordLocaleManager : NSObject {
}
@@ -15,8 +15,14 @@
/**
Initializes the global locale system.
- Any created instance that needs localozed information will use it.
+ Any created instance that needs localized information will use it.
*/
- (void)initLocale;
+/**
+ Initializes global locale system.
+ Loads the locale (locale.d) folder from the specified path.
+ */
+- (void)initLocaleWithLocaledPath:(NSString *)aPath;
+
@end
diff --git a/bindings/objc/src/SwordLocaleManager.mm b/bindings/objc/src/SwordLocaleManager.mm
index 582eee5..18e4eba 100644
--- a/bindings/objc/src/SwordLocaleManager.mm
+++ b/bindings/objc/src/SwordLocaleManager.mm
@@ -14,7 +14,7 @@
@implementation SwordLocaleManager
+ (SwordLocaleManager *)defaultManager {
- static SwordLocaleManager *instance;
+ static SwordLocaleManager *instance = nil;
if(instance == nil) {
// use default path
instance = [[SwordLocaleManager alloc] init];
@@ -27,23 +27,27 @@
// set locale swManager
NSString *resourcePath = [[NSBundle bundleForClass:[SwordLocaleManager class]] resourcePath];
NSString *localePath = [resourcePath stringByAppendingPathComponent:@"locales.d"];
+ [self initLocaleWithLocaledPath:localePath];
+}
+
+- (void)initLocaleWithLocaledPath:(NSString *)aPath {
sword::LocaleMgr *lManager = sword::LocaleMgr::getSystemLocaleMgr();
- lManager->loadConfigDir([localePath UTF8String]);
+ lManager->loadConfigDir([aPath UTF8String]);
//get the language
NSArray *availLocales = [NSLocale preferredLanguages];
NSString *lang = nil;
- NSString *loc = nil;
+ NSString *loc;
BOOL haveLocale = NO;
// for every language, check if we know the locales
- sword::StringList localelist = lManager->getAvailableLocales();
+ sword::StringList localeList = lManager->getAvailableLocales();
NSEnumerator *iter = [availLocales objectEnumerator];
while((loc = [iter nextObject]) && !haveLocale) {
// check if this locale is available in SWORD
sword::StringList::iterator it;
sword::SWBuf locale;
- for(it = localelist.begin(); it != localelist.end(); ++it) {
+ for(it = localeList.begin(); it != localeList.end(); ++it) {
locale = *it;
NSString *swLoc = [NSString stringWithCString:locale.c_str() encoding:NSUTF8StringEncoding];
if([swLoc hasPrefix:loc]) {
@@ -56,7 +60,7 @@
if(haveLocale) {
lManager->setDefaultLocaleName([lang UTF8String]);
- }
+ }
}
@end
diff --git a/bindings/objc/src/SwordManager.h b/bindings/objc/src/SwordManager.h
index 571a7cc..daf8ece 100644
--- a/bindings/objc/src/SwordManager.h
+++ b/bindings/objc/src/SwordManager.h
@@ -17,14 +17,6 @@
#ifdef __cplusplus
#include <swmgr.h> // C++ Sword API
#include <localemgr.h>
-#include <markupfiltmgr.h>
-// Filters
-#include <markupfiltmgr.h>
-#include <osishtmlhref.h>
-#include <thmlhtmlhref.h>
-#include <gbfhtmlhref.h>
-#include <teihtmlhref.h>
-#include <plainhtml.h>
#include <versekey.h>
class sword::SWModule;
#endif
@@ -110,13 +102,12 @@ class sword::SWModule;
// CipherKeys NSUserdefaultsKey
#define DefaultsModuleCipherKeysKey @"DefaultsModuleCipherKeysKey"
-
@interface SwordManager : NSObject {
#ifdef __cplusplus
sword::SWMgr *swManager;
- sword::SWFilter *plainFilter, *thmlFilter, *gbfFilter, *osisFilter, *teiFilter;
- sword::SWFilter *thmlStripFilter, *gbfStripFilter, *osisStripFilter;
+ SwordFilter *plainFilter, *thmlFilter, *gbfFilter, *osisFilter, *teiFilter;
+ SwordFilter *thmlStripFilter, *gbfStripFilter, *osisStripFilter, *teiStripFilter;
#endif
NSDictionary *modules;
@@ -134,7 +125,7 @@ class sword::SWModule;
// --------------------- methods -----------------------
/**
- Conveniance initializer. Creates an instance of SwordManager for a given module path.
+ Convenience initializer. Creates an instance of SwordManager for a given module path.
Internally -initWithPath: is called.
*/
+ (SwordManager *)managerWithPath:(NSString*)path;
@@ -147,30 +138,23 @@ class sword::SWModule;
+ (SwordManager *)defaultManager;
/**
- Retreve a list of known module types.
+ Retrieve a list of known module types.
See SWMOD_CATEGORY_*
*/
+ (NSArray *)moduleTypes;
/**
- Rendered Module text that has links.
- This method will return a dictionary with attribute/value pairs from parameters of the link.
- See ATTRTYPE_* for key types.
- */
-+ (NSDictionary *)linkDataForLinkURL:(NSURL *)aURL;
-
-/**
Initializes this manager for the given module path.
*/
- (id)initWithPath:(NSString *)path;
/**
- Add an additional path to the manager to aument more modules.
+ Add an additional path to the manager to augment more modules.
*/
-- (void)addPath:(NSString*)path;
+- (void)addModulesPath:(NSString*)path;
/**
- reinit - reloads all modules, filters and such
+ re-init - reloads all modules, filters and such
This will be triggered if new module had been installed in the module installer.
*/
- (void)reInit;
@@ -226,13 +210,14 @@ class sword::SWModule;
- (NSArray *)modulesForCategory:(ModuleCategory)cat;
#ifdef __cplusplus
-- (id)initWithSWMgr:(sword::SWMgr *)smgr;
+- (id)initWithSWMgr:(sword::SWMgr *)swMgr;
- (sword::SWModule *)getSWModuleWithName:(NSString *)moduleName;
/**
Returns the underlying sword::SWMgr instance
*/
- (sword::SWMgr *)swManager;
+
#endif
@end
diff --git a/bindings/objc/src/SwordManager.mm b/bindings/objc/src/SwordManager.mm
index a2e8793..c2962fb 100644
--- a/bindings/objc/src/SwordManager.mm
+++ b/bindings/objc/src/SwordManager.mm
@@ -11,22 +11,13 @@
General Public License for more details. (http://www.gnu.org/licenses/gpl.html)
*/
-#import "SwordManager.h"
-#import "Configuration.h"
-#include <string>
-#include <list>
-
-#include "gbfplain.h"
-#include "thmlplain.h"
-#include "osisplain.h"
+#import <ObjCSword/ObjCSword.h>
#import "Notifications.h"
-#import "SwordBook.h"
-#import "SwordModule.h"
-#import "SwordBible.h"
-#import "SwordCommentary.h"
-#import "SwordDictionary.h"
-#import "SwordListKey.h"
-#import "SwordVerseKey.h"
+#import "FilterProviderFactory.h"
+#import "DefaultFilterProvider.h"
+
+#include "encfiltmgr.h"
+#import "SwordFilter.h"
using std::string;
using std::list;
@@ -34,7 +25,7 @@ using std::list;
@interface SwordManager (PrivateAPI)
- (void)refreshModules;
-- (void)addFiltersToModule:(sword::SWModule *)mod;
+- (void)addFiltersToModule:(SwordModule *)mod;
@end
@@ -52,13 +43,12 @@ using std::list;
// temporary instance
SwordModule *swMod = [SwordModule moduleForSWModule:mod];
NSString *type = [swMod typeString];
- NSString *name = [swMod name];
-
+
ModuleType aType = [SwordModule moduleTypeForModuleTypeString:type];
- SwordModule *sm = [SwordModule moduleForType:aType andName:name swModule:mod swordManager:self];
- [dict setObject:sm forKey:[sm name]];
-
- [self addFiltersToModule:mod];
+ SwordModule *sm = [SwordModule moduleForType:aType swModule:mod swordManager:self];
+ [dict setObject:sm forKey:[[sm name] lowercaseString]];
+
+ [self addFiltersToModule:sm];
}
}
@@ -66,51 +56,58 @@ using std::list;
self.modules = dict;
}
-- (void)addFiltersToModule:(sword::SWModule *)mod {
+- (void)addFiltersToModule:(SwordModule *)mod {
// prepare display filters
- switch(mod->Markup()) {
+
+ id<FilterProvider> filterProvider = [[FilterProviderFactory providerFactory] get];
+
+ switch([mod swModule]->Markup()) {
case sword::FMT_GBF:
if(!gbfFilter) {
- gbfFilter = new sword::GBFHTMLHREF();
+ gbfFilter = [filterProvider newGbfRenderFilter];
}
if(!gbfStripFilter) {
- gbfStripFilter = new sword::GBFPlain();
+ gbfStripFilter = [filterProvider newGbfPlainFilter];
}
- mod->AddRenderFilter(gbfFilter);
- mod->AddStripFilter(gbfStripFilter);
+ [mod addRenderFilter:gbfFilter];
+ [mod addStripFilter:gbfStripFilter];
break;
case sword::FMT_THML:
if(!thmlFilter) {
- thmlFilter = new sword::ThMLHTMLHREF();
+ thmlFilter = [filterProvider newThmlRenderFilter];
}
if(!thmlStripFilter) {
- thmlStripFilter = new sword::ThMLPlain();
+ thmlStripFilter = [filterProvider newThmlPlainFilter];
}
- mod->AddRenderFilter(thmlFilter);
- mod->AddStripFilter(thmlStripFilter);
+ [mod addRenderFilter:thmlFilter];
+ [mod addStripFilter:thmlStripFilter];
break;
case sword::FMT_OSIS:
if(!osisFilter) {
- osisFilter = new sword::OSISHTMLHREF();
+ osisFilter = [filterProvider newOsisRenderFilter];
}
if(!osisStripFilter) {
- osisStripFilter = new sword::OSISPlain();
+ osisStripFilter = [filterProvider newOsisPlainFilter];
}
- mod->AddRenderFilter(osisFilter);
- mod->AddStripFilter(osisStripFilter);
+ [mod addRenderFilter:osisFilter];
+ [mod addStripFilter:osisStripFilter];
break;
case sword::FMT_TEI:
if(!teiFilter) {
- teiFilter = new sword::TEIHTMLHREF();
+ teiFilter = [filterProvider newTeiRenderFilter];
+ }
+ if(!teiStripFilter) {
+ teiStripFilter = [filterProvider newTeiPlainFilter];
}
- mod->AddRenderFilter(teiFilter);
+ [mod addRenderFilter:teiFilter];
+ [mod addStripFilter:teiStripFilter];
break;
case sword::FMT_PLAIN:
default:
if(!plainFilter) {
- plainFilter = new sword::PLAINHTML();
+ plainFilter = [filterProvider newHtmlPlainFilter];
}
- mod->AddRenderFilter(plainFilter);
+ [mod addRenderFilter:plainFilter];
break;
}
}
@@ -126,56 +123,6 @@ using std::list;
# pragma mark - class methods
-+ (NSDictionary *)linkDataForLinkURL:(NSURL *)aURL {
- NSMutableDictionary *ret = [NSMutableDictionary dictionary];
-
- NSString *scheme = [aURL scheme];
- if([scheme isEqualToString:@"sword"]) {
- // in this case host is the module and path the reference
- [ret setObject:[aURL host] forKey:ATTRTYPE_MODULE];
- [ret setObject:[[[aURL path] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
- stringByReplacingOccurrencesOfString:@"/" withString:@""]
- forKey:ATTRTYPE_VALUE];
- [ret setObject:@"scriptRef" forKey:ATTRTYPE_TYPE];
- [ret setObject:@"showRef" forKey:ATTRTYPE_ACTION];
- } else if([scheme isEqualToString:@"applewebdata"]) {
- // in this case
- NSString *path = [aURL path];
- NSString *query = [aURL query];
- if([[path lastPathComponent] isEqualToString:@"passagestudy.jsp"]) {
- NSArray *data = [query componentsSeparatedByString:@"&"];
- NSString *type = @"x";
- NSString *module = @"";
- NSString *passage = @"";
- NSString *value = @"1";
- NSString *action = @"";
- for(NSString *entry in data) {
- if([entry hasPrefix:@"type="]) {
- type = [[entry componentsSeparatedByString:@"="] objectAtIndex:1];
- } else if([entry hasPrefix:@"module="]) {
- module = [[entry componentsSeparatedByString:@"="] objectAtIndex:1];
- } else if([entry hasPrefix:@"passage="]) {
- passage = [[entry componentsSeparatedByString:@"="] objectAtIndex:1];
- } else if([entry hasPrefix:@"action="]) {
- action = [[entry componentsSeparatedByString:@"="] objectAtIndex:1];
- } else if([entry hasPrefix:@"value="]) {
- value = [[entry componentsSeparatedByString:@"="] objectAtIndex:1];
- } else {
- ALog(@"Unknown parameter: %@", entry);
- }
- }
-
- [ret setObject:module forKey:ATTRTYPE_MODULE];
- [ret setObject:passage forKey:ATTRTYPE_PASSAGE];
- [ret setObject:value forKey:ATTRTYPE_VALUE];
- [ret setObject:action forKey:ATTRTYPE_ACTION];
- [ret setObject:type forKey:ATTRTYPE_TYPE];
- }
- }
-
- return ret;
-}
-
+ (NSArray *)moduleTypes {
return [NSArray arrayWithObjects:
SWMOD_TYPES_BIBLES,
@@ -190,7 +137,7 @@ using std::list;
}
+ (SwordManager *)defaultManager {
- static SwordManager *instance;
+ static SwordManager *instance = nil;
if(instance == nil) {
// use default path
instance = [[SwordManager alloc] initWithPath:[[Configuration config] defaultModulePath]];
@@ -208,7 +155,7 @@ using std::list;
self.modulesPath = path;
self.modules = [NSDictionary dictionary];
- self.managerLock = [[NSRecursiveLock alloc] init];
+ self.managerLock = (NSLock *)[[[NSRecursiveLock alloc] init] autorelease];
[self reInit];
@@ -230,7 +177,7 @@ using std::list;
temporaryManager = YES;
self.modules = [NSDictionary dictionary];
- self.managerLock = [[NSRecursiveLock alloc] init];
+ self.managerLock = [(NSLock *)[[NSRecursiveLock alloc] init] autorelease];
[self refreshModules];
}
@@ -253,7 +200,16 @@ using std::list;
[self setModules:nil];
[self setModulesPath:nil];
[self setManagerLock:nil];
-
+
+ [gbfFilter release];
+ [gbfStripFilter release];
+ [thmlFilter release];
+ [thmlStripFilter release];
+ [osisFilter release];
+ [osisStripFilter release];
+ [teiFilter release];
+ [teiStripFilter release];
+ [plainFilter release];
[super dealloc];
}
@@ -268,11 +224,11 @@ using std::list;
ALog(@"Cannot create SWMgr instance for default module path!");
} else {
NSFileManager *fm = [NSFileManager defaultManager];
- NSArray *subDirs = [fm directoryContentsAtPath:modulesPath];
+ NSArray *subDirs = [fm contentsOfDirectoryAtPath:modulesPath error:NULL];
// for all sub directories add module
BOOL directory;
- NSString *fullSubDir = nil;
- NSString *subDir = nil;
+ NSString *fullSubDir;
+ NSString *subDir;
for(subDir in subDirs) {
// as long as it's not hidden
if(![subDir hasPrefix:@"."] &&
@@ -296,14 +252,13 @@ using std::list;
// clear some data
[self refreshModules];
- SendNotifyModulesChanged(nil);
+ SendNotifyModulesChanged(NULL);
}
}
[managerLock unlock];
}
-- (void)addPath:(NSString *)path {
-
+- (void)addModulesPath:(NSString *)path {
[managerLock lock];
if(swManager == nil) {
swManager = new sword::SWMgr([path UTF8String], true, new sword::EncodingFilterMgr(sword::ENC_UTF8));
@@ -314,12 +269,12 @@ using std::list;
[self refreshModules];
[managerLock unlock];
- SendNotifyModulesChanged(nil);
+ SendNotifyModulesChanged(NULL);
}
- (SwordModule *)moduleWithName:(NSString *)name {
- SwordModule *ret = [modules objectForKey:name];
+ SwordModule *ret = [modules objectForKey:[name lowercaseString]];
if(ret == nil) {
sword::SWModule *mod = [self getSWModuleWithName:name];
if(mod == NULL) {
@@ -330,11 +285,11 @@ using std::list;
NSString *type = [swMod typeString];
ModuleType aType = [SwordModule moduleTypeForModuleTypeString:type];
- ret = [SwordModule moduleForType:aType andName:name swModule:mod swordManager:self];
+ ret = [SwordModule moduleForType:aType swModule:mod swordManager:self];
if(ret != nil) {
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:modules];
- [dict setObject:ret forKey:name];
+ [dict setObject:ret forKey:[name lowercaseString]];
self.modules = dict;
}
}
@@ -381,8 +336,8 @@ using std::list;
}
// sort
- NSArray *sortDescritors = [NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES]];
- [ret sortUsingDescriptors:sortDescritors];
+ NSArray *sortDescriptors = [NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES] autorelease]];
+ [ret sortUsingDescriptors:sortDescriptors];
return [NSArray arrayWithArray:ret];
}
@@ -390,14 +345,14 @@ using std::list;
- (NSArray *)modulesForType:(ModuleType)type {
NSMutableArray *ret = [NSMutableArray array];
for(SwordModule *mod in [modules allValues]) {
- if([mod type] == type) {
+ if([mod type] == type || type == All) {
[ret addObject:mod];
}
}
// sort
- NSArray *sortDescritors = [NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES]];
- [ret sortUsingDescriptors:sortDescritors];
+ NSArray *sortDescriptors = [NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES] autorelease]];
+ [ret sortUsingDescriptors:sortDescriptors];
return [NSArray arrayWithArray:ret];
}
@@ -411,20 +366,20 @@ using std::list;
}
// sort
- NSArray *sortDescritors = [NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES]];
- [ret sortUsingDescriptors:sortDescritors];
+ NSArray *sortDescriptors = [NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES] autorelease]];
+ [ret sortUsingDescriptors:sortDescriptors];
return [NSArray arrayWithArray:ret];
}
-#pragma mark - lowlevel methods
+#pragma mark - lowLevel methods
- (sword::SWMgr *)swManager {
return swManager;
}
- (sword::SWModule *)getSWModuleWithName:(NSString *)moduleName {
- sword::SWModule *module = NULL;
+ sword::SWModule *module;
[managerLock lock];
module = swManager->Modules[[moduleName UTF8String]];
diff --git a/bindings/objc/src/SwordModule+Index.h b/bindings/objc/src/SwordModule+Index.h
index 879d8cb..df4f7d7 100644
--- a/bindings/objc/src/SwordModule+Index.h
+++ b/bindings/objc/src/SwordModule+Index.h
@@ -6,7 +6,7 @@
// Copyright 2010 Software by MABE. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
#import "SwordModule.h"
@interface SwordModule(Index)
diff --git a/bindings/objc/src/SwordModule.h b/bindings/objc/src/SwordModule.h
index ee47da7..9f1e0ad 100644
--- a/bindings/objc/src/SwordModule.h
+++ b/bindings/objc/src/SwordModule.h
@@ -11,15 +11,13 @@
General Public License for more details. (http://www.gnu.org/licenses/gpl.html)
*/
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
#ifdef __cplusplus
#import "swmodule.h"
#endif
-#define My_SWDYNAMIC_CAST(className, object) (sword::className *)((object)?((object->getClass()->isAssignableFrom(#className))?object:0):0)
-
-// defines for dictionary entries for passagestudy
+// defines for dictionary entries for passage study
#define ATTRTYPE_TYPE @"type"
#define ATTRTYPE_PASSAGE @"passage"
#define ATTRTYPE_MODULE @"modulename"
@@ -33,6 +31,7 @@
@class SwordManager, SwordModuleTextEntry, SwordKey;
+@class SwordFilter;
typedef enum {
TextTypeStripped = 1,
@@ -41,6 +40,7 @@ typedef enum {
/** These are the main module types as returned in -typeString */
typedef enum {
+ All = 0x0000,
Bible = 0x0001,
Commentary = 0x0002,
Dictionary = 0x0004,
@@ -74,7 +74,11 @@ typedef enum {
NSLock *indexLock;
/** we store the name separately */
+ NSString *typeString;
NSString *name;
+ NSString *descr;
+ NSString *lang;
+
/** yes, we have a delegate to report any action to */
id delegate;
@@ -89,19 +93,44 @@ typedef enum {
@property (readwrite) int status;
@property (retain, readwrite) NSRecursiveLock *moduleLock;
@property (retain, readwrite) NSLock *indexLock;
-@property (retain, readwrite) NSString *name;
@property (retain, readwrite) SwordManager *swManager;
+// swmodule properties
+@property (retain, readonly) NSString *name;
+@property (retain, readonly) NSString *typeString;
+@property (retain, readonly) NSString *descr;
+@property (retain, readonly) NSString *lang;
+
#ifdef __cplusplus
+
/**
- Convenience initializers
+ Convenience initializer
*/
+ (id)moduleForSWModule:(sword::SWModule *)aModule;
+ (id)moduleForSWModule:(sword::SWModule *)aModule swordManager:(SwordManager *)aManager;
+
/**
Factory method that creates the correct module type instance for the given type
*/
-+ (id)moduleForType:(ModuleType)aType andName:(NSString *)aName swModule:(sword::SWModule *)swModule swordManager:(SwordManager *)aManager;
++ (id)moduleForType:(ModuleType)aType swModule:(sword::SWModule *)swModule swordManager:(SwordManager *)aManager;
+
+/**
+ Initialize this module with an the SWModule.
+ This initializer should normally not need to be used.
+ */
+- (id)initWithSWModule:(sword::SWModule *)aModule;
+
+/**
+ Initialize this module with an the SWModule and a SwordManager instance.
+ This initializer should normally not need to be used.
+ */
+- (id)initWithSWModule:(sword::SWModule *)aModule swordManager:(SwordManager *)aManager;
+
+/**
+ Retrieve the underlying SWModule instance
+ */
+- (sword::SWModule *)swModule;
+
#endif
/**
@@ -125,22 +154,12 @@ typedef enum {
The SwordManager is needed because the underlying SWModule is retrieved from SwordManager.
*/
- (id)initWithName:(NSString *)aName swordManager:(SwordManager *)aManager;
-#ifdef __cplusplus
-/**
- Initialize this module with an the SWModule.
- This initializer should normally not need to be used.
- */
-- (id)initWithSWModule:(sword::SWModule *)aModule;
-/**
- Initialize this module with an the SWModule and a SwordManager instance.
- This initializer should normally not need to be used.
- */
-- (id)initWithSWModule:(sword::SWModule *)aModule swordManager:(SwordManager *)aManager;
-/**
- Retrieve the underlying SWModule instance
- */
-- (sword::SWModule *)swModule;
-#endif
+
+/** Adds a render filter to this module */
+- (void)addRenderFilter:(SwordFilter *)aFilter;
+
+/** Adds a strip filter to this module */
+- (void)addStripFilter:(SwordFilter *)aFilter;
/**
Any error while processing the module?
@@ -150,18 +169,6 @@ typedef enum {
// --------------- Conf entries --------------
/**
- Module description
- */
-- (NSString *)descr;
-/**
- Module language
- */
-- (NSString *)lang;
-/**
- Module type as string
- */
-- (NSString *)typeString;
-/**
Module category as string
*/
- (NSString *)categoryString;
@@ -254,20 +261,20 @@ typedef enum {
/**
Set position from a key
*/
-- (void)setKey:(SwordKey *)aKey;
+- (void)setSwordKey:(SwordKey *)aKey;
/**
Module key. New instance created by module.
*/
-- (id)createKey;
+- (SwordKey *)createKey;
/**
Module key. Reference only.
*/
-- (id)getKey;
+- (SwordKey *)getKey;
/**
Module key. Reference only but cloned.
*/
-- (id)getKeyCopy;
+- (SwordKey *)getKeyCopy;
// ------------------- module metadata processing ------------------
@@ -286,6 +293,7 @@ typedef enum {
@return NSString for text data
*/
- (id)attributeValueForParsedLinkData:(NSDictionary *)data;
+- (id)attributeValueForParsedLinkData:(NSDictionary *)data withTextRenderType:(TextPullType)textType;
/** returns the pre-verse entry value */
- (NSString *)entryAttributeValuePreverse;
@@ -307,6 +315,11 @@ typedef enum {
Convenience method with a key-string
*/
- (SwordModuleTextEntry *)textEntryForKeyString:(NSString *)aKeyString textType:(TextPullType)aType;
+/**
+ Pulls all text entries for the given reference
+ @return Array of SwordModuleTextEntry
+ */
+- (NSArray *)textEntriesForReference:(NSString *)aReference textType:(TextPullType)textType;
/**
Returns a rendered text for the text at the current module position
diff --git a/bindings/objc/src/SwordModule.mm b/bindings/objc/src/SwordModule.mm
index 1b1bf1c..12e2ad8 100644
--- a/bindings/objc/src/SwordModule.mm
+++ b/bindings/objc/src/SwordModule.mm
@@ -11,6 +11,7 @@
General Public License for more details. (http://www.gnu.org/licenses/gpl.html)
*/
+#import "ObjCSword_Prefix.pch"
#import "SwordModule.h"
#import "SwordManager.h"
#import "SwordModuleTextEntry.h"
@@ -19,21 +20,22 @@
#import "SwordCommentary.h"
#import "SwordDictionary.h"
#import "SwordBook.h"
-
-#import "rtfhtml.h"
-#import "swtext.h"
-#import "versekey.h"
-#import "regex.h"
+#import "SwordFilter.h"
@interface SwordModule ()
+
+@property (retain, readwrite) NSString *name;
+@property (retain, readwrite) NSString *typeString;
+@property (retain, readwrite) NSString *descr;
+@property (retain, readwrite) NSString *lang;
@property(readwrite, retain) NSMutableDictionary *configEntries;
+
- (void)mainInit;
+
@end
@implementation SwordModule
-#pragma mark - Property implementations
-
@synthesize configEntries;
@synthesize type;
@synthesize status;
@@ -41,6 +43,10 @@
@synthesize indexLock;
@synthesize swManager;
@synthesize name;
+@synthesize typeString;
+@synthesize descr;
+@synthesize lang;
+
+ (id)moduleForSWModule:(sword::SWModule *)aModule {
return [[[SwordModule alloc] initWithSWModule:aModule] autorelease];
@@ -50,8 +56,8 @@
return [[[SwordModule alloc] initWithSWModule:aModule swordManager:aManager] autorelease];
}
-+ (id)moduleForType:(ModuleType)aType andName:(NSString *)aName swModule:(sword::SWModule *)swModule swordManager:(SwordManager *)aManager {
- SwordModule *sm = nil;
++ (id)moduleForType:(ModuleType)aType swModule:(sword::SWModule *)swModule swordManager:(SwordManager *)aManager {
+ SwordModule *sm;
if(aType == Bible) {
sm = [[[SwordBible alloc] initWithSWModule:swModule swordManager:aManager] autorelease];
} else if(aType == Commentary) {
@@ -113,15 +119,19 @@
return ret;
}
-#pragma mark - Initializers
+#pragma mark - Initializer
- (void)mainInit {
category = Unset;
- self.type = [SwordModule moduleTypeForModuleTypeString:[self typeString]];
- self.moduleLock = [[NSRecursiveLock alloc] init];
- self.indexLock = [[NSLock alloc] init];
+ self.name = [self retrieveName];
+ self.typeString = [self retrieveType];
+ self.descr = [self retrieveDescr];
+ self.lang = [self retrieveLang];
+
+ self.type = [SwordModule moduleTypeForModuleTypeString:self.typeString];
+ self.moduleLock = [[[NSRecursiveLock alloc] init] autorelease];
+ self.indexLock = [[[NSLock alloc] init] autorelease];
self.configEntries = [NSMutableDictionary dictionary];
- self.name = [NSString stringWithCString:swModule->Name() encoding:NSUTF8StringEncoding];
}
- (id)initWithName:(NSString *)aName swordManager:(SwordManager *)aManager {
@@ -162,10 +172,23 @@
[self setModuleLock:nil];
[self setIndexLock:nil];
[self setName:nil];
+ [self setDescr:nil];
+ [self setTypeString:nil];
+ [self setLang:nil];
[super dealloc];
}
+#pragma mark - Filters
+
+- (void)addRenderFilter:(SwordFilter *)aFilter {
+ swModule->AddRenderFilter([aFilter swFilter]);
+}
+
+- (void)addStripFilter:(SwordFilter *)aFilter {
+ swModule->AddStripFilter([aFilter swFilter]);
+}
+
#pragma mark - Module access semaphores
- (void)lockModuleAccess {
@@ -186,7 +209,15 @@
return swModule->Error();
}
-- (NSString *)descr {
+- (NSString *)retrieveName {
+ NSString *str = [NSString stringWithCString:swModule->Name() encoding:NSUTF8StringEncoding];
+ if(!str) {
+ str = [NSString stringWithCString:swModule->Name() encoding:NSISOLatin1StringEncoding];
+ }
+ return str;
+}
+
+- (NSString *)retrieveDescr {
NSString *str = [NSString stringWithCString:swModule->Description() encoding:NSUTF8StringEncoding];
if(!str) {
str = [NSString stringWithCString:swModule->Description() encoding:NSISOLatin1StringEncoding];
@@ -194,7 +225,7 @@
return str;
}
-- (NSString *)lang {
+- (NSString *)retrieveLang {
NSString *str = [NSString stringWithCString:swModule->Lang() encoding:NSUTF8StringEncoding];
if(!str) {
str = [NSString stringWithCString:swModule->Lang() encoding:NSISOLatin1StringEncoding];
@@ -202,7 +233,7 @@
return str;
}
-- (NSString *)typeString {
+- (NSString *)retrieveType {
NSString *str = [NSString stringWithCString:swModule->Type() encoding:NSUTF8StringEncoding];
if(!str) {
str = [NSString stringWithCString:swModule->Type() encoding:NSISOLatin1StringEncoding];
@@ -289,7 +320,7 @@
if (d == 'u') {
//we have an unicode character!
@try {
- NSUInteger unicodeChar = 0;
+ NSInteger unicodeChar = 0;
NSMutableString *unicodeCharString = [[@"" mutableCopy] autorelease];
int j = 0;
BOOL negative = NO;
@@ -469,11 +500,11 @@
swModule->setKey([aKeyString UTF8String]);
}
-- (void)setKey:(SwordKey *)aKey {
+- (void)setSwordKey:(SwordKey *)aKey {
swModule->setKey([aKey swKey]);
}
-- (id)createKey {
+- (SwordKey *)createKey {
sword::SWKey *sk = swModule->CreateKey();
SwordKey *newKey = [SwordKey swordKeyWithSWKey:sk makeCopy:YES];
delete sk;
@@ -481,17 +512,21 @@
return newKey;
}
-- (id)getKey {
+- (SwordKey *)getKey {
return [SwordKey swordKeyWithSWKey:swModule->getKey()];
}
-- (id)getKeyCopy {
+- (SwordKey *)getKeyCopy {
return [SwordKey swordKeyWithSWKey:swModule->getKey() makeCopy:YES];
}
#pragma mark - Module metadata processing
- (id)attributeValueForParsedLinkData:(NSDictionary *)data {
+ return [self attributeValueForParsedLinkData:data withTextRenderType:TextTypeStripped];
+}
+
+- (id)attributeValueForParsedLinkData:(NSDictionary *)data withTextRenderType:(TextPullType)textType {
id ret = nil;
NSString *passage = [data objectForKey:ATTRTYPE_PASSAGE];
@@ -503,16 +538,22 @@
NSString *footnoteText = [self entryAttributeValueFootnoteOfType:attrType
indexValue:[data objectForKey:ATTRTYPE_VALUE]
forKey:[SwordKey swordKeyWithRef:passage]];
- ret = [self strippedTextFromString:footnoteText];
- } else if([attrType isEqualToString:@"x"]) {
- NSString *refListString = [self entryAttributeValueFootnoteOfType:attrType
- indexValue:[data objectForKey:ATTRTYPE_VALUE]
- forKey:[SwordKey swordKeyWithRef:passage]];
- ret = [self strippedTextEntriesForRef:refListString];
- } else if([attrType isEqualToString:@"scriptRef"] || [attrType isEqualToString:@"scripRef"]) {
- NSString *key = [[[data objectForKey:ATTRTYPE_VALUE] stringByReplacingOccurrencesOfString:@"+"
- withString:@" "] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- ret = [self strippedTextEntriesForRef:key];
+ ret = footnoteText;
+ } else if([attrType isEqualToString:@"x"] || [attrType isEqualToString:@"scriptRef"] || [attrType isEqualToString:@"scripRef"]) {
+ NSString *key = @"";
+ if([attrType isEqualToString:@"x"]) {
+ key = [self entryAttributeValueFootnoteOfType:attrType
+ indexValue:[data objectForKey:ATTRTYPE_VALUE]
+ forKey:[SwordKey swordKeyWithRef:passage]];
+ } else {
+ key = [[[data objectForKey:ATTRTYPE_VALUE] stringByReplacingOccurrencesOfString:@"+"
+ withString:@" "] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+ }
+ if(textType == TextTypeRendered) {
+ ret = [self renderedTextEntriesForRef:key];
+ } else {
+ ret = [self strippedTextEntriesForRef:key];
+ }
}
return ret;
@@ -527,8 +568,7 @@
}
- (NSString *)entryAttributeValuePreverse {
- NSString *ret = @"";
- ret = [NSString stringWithUTF8String:swModule->getEntryAttributes()["Heading"]["Preverse"]["0"].c_str()];
+ NSString *ret = [NSString stringWithUTF8String:swModule->getEntryAttributes()["Heading"]["Preverse"]["0"].c_str()];
return ret;
}
@@ -560,7 +600,7 @@
if (word->second.find("Text") == word->second.end())
continue; // no text? let's skip
}
- NSMutableString *stringValStr = [NSMutableString stringWithUTF8String:strongVal->second];
+ NSMutableString *stringValStr = [NSMutableString stringWithUTF8String:(const char *)strongVal->second];
if(stringValStr) {
[stringValStr replaceOccurrencesOfString:@"|x-Strongs:" withString:@" " options:0 range:NSMakeRange(0, [stringValStr length])];
[array addObject:stringValStr];
@@ -573,7 +613,7 @@
- (NSString *)entryAttributeValuePreverseForKey:(SwordKey *)aKey {
[moduleLock lock];
- [self setKey:aKey];
+ [self setSwordKey:aKey];
swModule->RenderText(); // force processing of key
NSString *value = [self entryAttributeValuePreverse];
[moduleLock unlock];
@@ -582,7 +622,7 @@
- (NSString *)entryAttributeValueFootnoteOfType:(NSString *)fnType indexValue:(NSString *)index forKey:(SwordKey *)aKey {
[moduleLock lock];
- [self setKey:aKey];
+ [self setSwordKey:aKey];
swModule->RenderText(); // force processing of key
NSString *value = [self entryAttributeValueFootnoteOfType:fnType indexValue:index];
[moduleLock unlock];
@@ -633,27 +673,11 @@
}
- (NSArray *)strippedTextEntriesForRef:(NSString *)reference {
- NSArray *ret = nil;
-
- SwordModuleTextEntry *entry = [self textEntryForKey:[SwordKey swordKeyWithRef:reference]
- textType:TextTypeStripped];
- if(entry) {
- ret = [NSArray arrayWithObject:entry];
- }
-
- return ret;
+ return [self textEntriesForReference:reference textType:TextTypeStripped];
}
- (NSArray *)renderedTextEntriesForRef:(NSString *)reference {
- NSArray *ret = nil;
-
- SwordModuleTextEntry *entry = [self textEntryForKey:[SwordKey swordKeyWithRef:reference]
- textType:TextTypeRendered];
- if(entry) {
- ret = [NSArray arrayWithObject:entry];
- }
-
- return ret;
+ return [self textEntriesForReference:reference textType:TextTypeRendered];
}
- (SwordModuleTextEntry *)textEntryForKey:(SwordKey *)aKey textType:(TextPullType)aType {
@@ -661,7 +685,7 @@
if(aKey) {
[moduleLock lock];
- [self setKey:aKey];
+ [self setSwordKey:aKey];
if(![self error]) {
NSString *txt = @"";
if(aType == TextTypeRendered) {
@@ -686,6 +710,17 @@
return [self textEntryForKey:[SwordKey swordKeyWithRef:aKeyString] textType:aType];
}
+- (NSArray *)textEntriesForReference:(NSString *)aReference textType:(TextPullType)textType {
+ NSArray *ret = nil;
+
+ SwordModuleTextEntry *entry = [self textEntryForKey:[SwordKey swordKeyWithRef:aReference]
+ textType:textType];
+ if(entry) {
+ ret = [NSArray arrayWithObject:entry];
+ }
+
+ return ret;
+}
- (void)writeEntry:(SwordModuleTextEntry *)anEntry {}
diff --git a/bindings/objc/src/SwordModuleTextEntry.h b/bindings/objc/src/SwordModuleTextEntry.h
index f13789a..7759be4 100644
--- a/bindings/objc/src/SwordModuleTextEntry.h
+++ b/bindings/objc/src/SwordModuleTextEntry.h
@@ -6,7 +6,7 @@
// Copyright 2009 Software by MABE. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
@class SwordKey;
diff --git a/bindings/objc/src/SwordModuleTreeEntry.h b/bindings/objc/src/SwordModuleTreeEntry.h
index fcd0cae..cd27cbe 100644
--- a/bindings/objc/src/SwordModuleTreeEntry.h
+++ b/bindings/objc/src/SwordModuleTreeEntry.h
@@ -6,7 +6,7 @@
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
@interface SwordModuleTreeEntry : NSObject {
diff --git a/bindings/objc/src/SwordUtil.h b/bindings/objc/src/SwordUtil.h
new file mode 100644
index 0000000..92779bf
--- /dev/null
+++ b/bindings/objc/src/SwordUtil.h
@@ -0,0 +1,20 @@
+//
+// Created by mbergmann on 18.12.12.
+//
+// To change the template use AppCode | Preferences | File Templates.
+//
+
+
+#import <Foundation/Foundation.h>
+
+
+@interface SwordUtil : NSObject
+
+/**
+ Rendered Module texts may have hyperlinks. Those links may have key/value pairs to target data.
+ This method will return a dictionary with attribute/value pairs from parameters of the link.
+ See ATTRTYPE_* for key types.
+ */
++ (NSDictionary *)dictionaryFromUrl:(NSURL *)aURL;
+
+@end
diff --git a/bindings/objc/src/SwordUtil.m b/bindings/objc/src/SwordUtil.m
new file mode 100644
index 0000000..9f53870
--- /dev/null
+++ b/bindings/objc/src/SwordUtil.m
@@ -0,0 +1,64 @@
+//
+// Created by mbergmann on 18.12.12.
+//
+// To change the template use AppCode | Preferences | File Templates.
+//
+
+
+#import <ObjCSword/ObjCSword.h>
+#import "SwordUtil.h"
+
+
+@implementation SwordUtil
+
++ (NSDictionary *)dictionaryFromUrl:(NSURL *)aURL {
+ NSMutableDictionary *ret = [NSMutableDictionary dictionary];
+
+ NSString *scheme = [aURL scheme];
+ if([scheme isEqualToString:@"sword"]) {
+ // in this case host is the module and path the reference
+ [ret setObject:[aURL host] forKey:ATTRTYPE_MODULE];
+ [ret setObject:[[[aURL path] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
+ stringByReplacingOccurrencesOfString:@"/" withString:@""]
+ forKey:ATTRTYPE_VALUE];
+ [ret setObject:@"scriptRef" forKey:ATTRTYPE_TYPE];
+ [ret setObject:@"showRef" forKey:ATTRTYPE_ACTION];
+ } else if([scheme isEqualToString:@"applewebdata"]) {
+ // in this case
+ NSString *path = [aURL path];
+ NSString *query = [aURL query];
+ if([[path lastPathComponent] isEqualToString:@"passagestudy.jsp"]) {
+ NSArray *data = [query componentsSeparatedByString:@"&"];
+ NSString *type = @"x";
+ NSString *module = @"";
+ NSString *passage = @"";
+ NSString *value = @"1";
+ NSString *action = @"";
+ for(NSString *entry in data) {
+ if([entry hasPrefix:@"type="]) {
+ type = [[entry componentsSeparatedByString:@"="] objectAtIndex:1];
+ } else if([entry hasPrefix:@"module="]) {
+ module = [[entry componentsSeparatedByString:@"="] objectAtIndex:1];
+ } else if([entry hasPrefix:@"passage="]) {
+ passage = [[entry componentsSeparatedByString:@"="] objectAtIndex:1];
+ } else if([entry hasPrefix:@"action="]) {
+ action = [[entry componentsSeparatedByString:@"="] objectAtIndex:1];
+ } else if([entry hasPrefix:@"value="]) {
+ value = [[entry componentsSeparatedByString:@"="] objectAtIndex:1];
+ } else {
+ ALog(@"Unknown parameter: %@", entry);
+ }
+ }
+
+ [ret setObject:[module stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:ATTRTYPE_MODULE];
+ [ret setObject:[passage stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:ATTRTYPE_PASSAGE];
+ [ret setObject:[value stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:ATTRTYPE_VALUE];
+ [ret setObject:[action stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:ATTRTYPE_ACTION];
+ [ret setObject:[type stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:ATTRTYPE_TYPE];
+ }
+ }
+
+ return ret;
+}
+
+@end \ No newline at end of file
diff --git a/bindings/objc/src/SwordVerseKey.h b/bindings/objc/src/SwordVerseKey.h
index d915a2a..a72911b 100644
--- a/bindings/objc/src/SwordVerseKey.h
+++ b/bindings/objc/src/SwordVerseKey.h
@@ -6,7 +6,7 @@
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
#import "SwordKey.h"
#ifdef __cplusplus
@@ -16,28 +16,28 @@
@interface SwordVerseKey : SwordKey {
}
-+ (id)verseKey;
-+ (id)verseKeyWithVersification:(NSString *)scheme;
-+ (id)verseKeyWithRef:(NSString *)aRef;
-+ (id)verseKeyWithRef:(NSString *)aRef v11n:(NSString *)scheme;
++ (SwordVerseKey *)verseKey;
++ (SwordVerseKey *)verseKeyWithVersification:(NSString *)scheme;
++ (SwordVerseKey *)verseKeyWithRef:(NSString *)aRef;
++ (SwordVerseKey *)verseKeyWithRef:(NSString *)aRef v11n:(NSString *)scheme;
#ifdef __cplusplus
-+ (id)verseKeyWithSWVerseKey:(sword::VerseKey *)aVk;
-+ (id)verseKeyWithSWVerseKey:(sword::VerseKey *)aVk makeCopy:(BOOL)copy;
-- (id)initWithSWVerseKey:(sword::VerseKey *)aVk;
-- (id)initWithSWVerseKey:(sword::VerseKey *)aVk makeCopy:(BOOL)copy;
++ (SwordVerseKey *)verseKeyWithSWVerseKey:(sword::VerseKey *)aVk;
++ (SwordVerseKey *)verseKeyWithSWVerseKey:(sword::VerseKey *)aVk makeCopy:(BOOL)copy;
+- (SwordVerseKey *)initWithSWVerseKey:(sword::VerseKey *)aVk;
+- (SwordVerseKey *)initWithSWVerseKey:(sword::VerseKey *)aVk makeCopy:(BOOL)copy;
- (sword::VerseKey *)swVerseKey;
#endif
-- (id)initWithVersification:(NSString *)scheme;
-- (id)initWithRef:(NSString *)aRef;
-- (id)initWithRef:(NSString *)aRef v11n:(NSString *)scheme;
+- (SwordVerseKey *)initWithVersification:(NSString *)scheme;
+- (SwordVerseKey *)initWithRef:(NSString *)aRef;
+- (SwordVerseKey *)initWithRef:(NSString *)aRef v11n:(NSString *)scheme;
- (int)index;
- (int)testament;
-- (void)setTestament:(int)val;
+- (void)setTestament:(char)val;
- (int)book;
-- (void)setBook:(int)val;
+- (void)setBook:(char)val;
- (int)chapter;
- (void)setChapter:(int)val;
- (int)verse;
diff --git a/bindings/objc/src/SwordVerseKey.mm b/bindings/objc/src/SwordVerseKey.mm
index b0d3f2d..ca15f17 100644
--- a/bindings/objc/src/SwordVerseKey.mm
+++ b/bindings/objc/src/SwordVerseKey.mm
@@ -11,27 +11,27 @@
@implementation SwordVerseKey
-+ (id)verseKey {
++ (SwordVerseKey *)verseKey {
return [[[SwordVerseKey alloc] init] autorelease];
}
-+ (id)verseKeyWithVersification:(NSString *)scheme {
++ (SwordVerseKey *)verseKeyWithVersification:(NSString *)scheme {
return [[[SwordVerseKey alloc] initWithVersification:scheme] autorelease];
}
-+ (id)verseKeyWithRef:(NSString *)aRef {
++ (SwordVerseKey *)verseKeyWithRef:(NSString *)aRef {
return [[[SwordVerseKey alloc] initWithRef:aRef] autorelease];
}
-+ (id)verseKeyWithRef:(NSString *)aRef v11n:(NSString *)scheme {
++ (SwordVerseKey *)verseKeyWithRef:(NSString *)aRef v11n:(NSString *)scheme {
return [[[SwordVerseKey alloc] initWithRef:aRef v11n:scheme] autorelease];
}
-+ (id)verseKeyWithSWVerseKey:(sword::VerseKey *)aVk {
++ (SwordVerseKey *)verseKeyWithSWVerseKey:(sword::VerseKey *)aVk {
return [[[SwordVerseKey alloc] initWithSWVerseKey:aVk] autorelease];
}
-+ (id)verseKeyWithSWVerseKey:(sword::VerseKey *)aVk makeCopy:(BOOL)copy {
++ (SwordVerseKey *)verseKeyWithSWVerseKey:(sword::VerseKey *)aVk makeCopy:(BOOL)copy {
return [[[SwordVerseKey alloc] initWithSWVerseKey:aVk makeCopy:copy] autorelease];
}
@@ -39,15 +39,15 @@
return [self initWithRef:nil];
}
-- (id)initWithVersification:(NSString *)scheme {
+- (SwordVerseKey *)initWithVersification:(NSString *)scheme {
return [self initWithRef:nil v11n:scheme];
}
-- (id)initWithSWVerseKey:(sword::VerseKey *)aVk {
+- (SwordVerseKey *)initWithSWVerseKey:(sword::VerseKey *)aVk {
return [self initWithSWVerseKey:aVk makeCopy:NO];
}
-- (id)initWithSWVerseKey:(sword::VerseKey *)aVk makeCopy:(BOOL)copy {
+- (SwordVerseKey *)initWithSWVerseKey:(sword::VerseKey *)aVk makeCopy:(BOOL)copy {
self = [super initWithSWKey:aVk makeCopy:copy];
if(self) {
[self swVerseKey]->setVersificationSystem(aVk->getVersificationSystem());
@@ -55,11 +55,11 @@
return self;
}
-- (id)initWithRef:(NSString *)aRef {
+- (SwordVerseKey *)initWithRef:(NSString *)aRef {
return [self initWithRef:aRef v11n:nil];
}
-- (id)initWithRef:(NSString *)aRef v11n:(NSString *)scheme {
+- (SwordVerseKey *)initWithRef:(NSString *)aRef v11n:(NSString *)scheme {
sword::VerseKey *vk = new sword::VerseKey();
self = [super initWithSWKey:vk];
if(self) {
@@ -84,20 +84,16 @@
[super dealloc];
}
-- (id)clone {
+- (SwordKey *)clone {
return [SwordVerseKey verseKeyWithSWVerseKey:(sword::VerseKey *)sk];
}
-- (int)index {
- return sk->Index();
-}
-
- (BOOL)headings {
return (BOOL)((sword::VerseKey *)sk)->Headings();
}
- (void)setHeadings:(BOOL)flag {
- ((sword::VerseKey *)sk)->Headings((int)flag);
+ ((sword::VerseKey *)sk)->Headings(flag);
}
- (BOOL)autoNormalize {
@@ -105,7 +101,7 @@
}
- (void)setAutoNormalize:(BOOL)flag {
- ((sword::VerseKey *)sk)->AutoNormalize((int)flag);
+ ((sword::VerseKey *)sk)->AutoNormalize(flag);
}
- (int)testament {
@@ -124,11 +120,11 @@
return ((sword::VerseKey *)sk)->getVerse();
}
-- (void)setTestament:(int)val {
+- (void)setTestament:(char)val {
((sword::VerseKey *)sk)->setTestament(val);
}
-- (void)setBook:(int)val {
+- (void)setBook:(char)val {
((sword::VerseKey *)sk)->setBook(val);
}
diff --git a/bindings/objc/src/SwordVerseManager.h b/bindings/objc/src/SwordVerseManager.h
index 71eef6a..c9667c5 100644
--- a/bindings/objc/src/SwordVerseManager.h
+++ b/bindings/objc/src/SwordVerseManager.h
@@ -6,18 +6,18 @@
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
#ifdef __cplusplus
-#include <versemgr.h>
-class sword::VerseMgr::Book;
+#include <versificationmgr.h>
+class sword::VersificationMgr::Book;
#endif
#define SW_VERSIFICATION_KJV @"KJV"
@interface SwordVerseManager : NSObject {
#ifdef __cplusplus
- sword::VerseMgr *verseMgr;
+ sword::VersificationMgr *verseMgr;
#endif
NSMutableDictionary *booksPerVersification;
}
@@ -30,7 +30,7 @@ class sword::VerseMgr::Book;
- (NSArray *)booksForVersification:(NSString *)verseScheme;
#ifdef __cplusplus
-- (sword::VerseMgr *)verseMgr;
+- (sword::VersificationMgr *)verseMgr;
#endif
@end
diff --git a/bindings/objc/src/SwordVerseManager.mm b/bindings/objc/src/SwordVerseManager.mm
index a9bc12b..72f26fc 100644
--- a/bindings/objc/src/SwordVerseManager.mm
+++ b/bindings/objc/src/SwordVerseManager.mm
@@ -21,7 +21,7 @@
@synthesize booksPerVersification;
+ (SwordVerseManager *)defaultManager {
- static SwordVerseManager *singleton;
+ static SwordVerseManager *singleton = nil;
if(!singleton) {
singleton = [[SwordVerseManager alloc] init];
}
@@ -33,7 +33,7 @@
self = [super init];
if(self) {
self.booksPerVersification = [NSMutableDictionary dictionary];
- verseMgr = sword::VerseMgr::getSystemVerseMgr();
+ verseMgr = sword::VersificationMgr::getSystemVersificationMgr();
}
return self;
@@ -59,13 +59,13 @@
NSArray *ret = [booksPerVersification objectForKey:verseScheme];
if(ret == nil) {
// hasn't been initialized yet
- const sword::VerseMgr::System *system = verseMgr->getVersificationSystem([verseScheme UTF8String]);
- int bookCount = system->getBookCount();
+ const sword::VersificationMgr::System *system = verseMgr->getVersificationSystem([verseScheme UTF8String]);
+ NSUInteger bookCount = (NSUInteger)system->getBookCount();
NSMutableArray *buf = [NSMutableArray arrayWithCapacity:bookCount];
for(int i = 0;i < bookCount;i++) {
- sword::VerseMgr::Book *book = (sword::VerseMgr::Book *)system->getBook(i);
+ sword::VersificationMgr::Book *book = (sword::VersificationMgr::Book *)system->getBook(i);
- SwordBibleBook *bb = [[SwordBibleBook alloc] initWithBook:book];
+ SwordBibleBook *bb = [[[SwordBibleBook alloc] initWithBook:book] autorelease];
[bb setNumber:i+1]; // VerseKey-Book() starts at index 1
// add to array
@@ -78,7 +78,7 @@
return ret;
}
-- (sword::VerseMgr *)verseMgr {
+- (sword::VersificationMgr *)verseMgr {
return verseMgr;
}
diff --git a/bindings/objc/src/VerseEnumerator.h b/bindings/objc/src/VerseEnumerator.h
index 8eabbe9..52da7ab 100644
--- a/bindings/objc/src/VerseEnumerator.h
+++ b/bindings/objc/src/VerseEnumerator.h
@@ -6,7 +6,7 @@
// Copyright 2010 Software by MABE. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
@class SwordListKey;
diff --git a/bindings/objc/src/VerseEnumerator.mm b/bindings/objc/src/VerseEnumerator.mm
index ca8e40b..cd5c665 100644
--- a/bindings/objc/src/VerseEnumerator.mm
+++ b/bindings/objc/src/VerseEnumerator.mm
@@ -31,6 +31,7 @@
}
- (void)dealloc {
+ [listKey release];
[super dealloc];
}
@@ -39,7 +40,7 @@
for(*[listKey swListKey] = sword::TOP;![listKey swListKey]->Error(); *[listKey swListKey] += 1) {
[t addObject:[listKey keyText]];
}
- // possition TOP again
+ // position TOP again
*[listKey swListKey] = sword::TOP;
return [NSArray arrayWithArray:t];
diff --git a/bindings/objc/src/services/Configuration.h b/bindings/objc/src/services/Configuration.h
index 1734fa6..e967c58 100644
--- a/bindings/objc/src/services/Configuration.h
+++ b/bindings/objc/src/services/Configuration.h
@@ -6,7 +6,7 @@
// Copyright 2010 Software by MABE. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
/*
To define your own configuration:
@@ -27,10 +27,11 @@
@end
@interface Configuration : NSObject <Configuration> {
-
+ Configuration *impl;
}
+ (Configuration *)config;
++ (Configuration *)configWithImpl:(id<Configuration>)configImpl;
- (NSString *)osVersion;
- (NSString *)bundleVersion;
@@ -39,6 +40,6 @@
- (NSString *)tempFolder;
- (NSString *)logFile;
-- (void)setClass:(Class<Configuration>)classImpl;
+- (void)setImpl:(id<Configuration>)configImpl;
@end
diff --git a/bindings/objc/src/services/Configuration.m b/bindings/objc/src/services/Configuration.m
index 8ba2842..67ec709 100644
--- a/bindings/objc/src/services/Configuration.m
+++ b/bindings/objc/src/services/Configuration.m
@@ -11,13 +11,18 @@
@implementation Configuration
+ (Configuration *)config {
- static Configuration *instance;
+ static Configuration *instance = nil;
if(instance == nil) {
instance = [[Configuration alloc] init];
}
return instance;
}
++ (Configuration *)configWithImpl:(id<Configuration>)configImpl {
+ [[Configuration config] setImpl:configImpl];
+ return [Configuration config];
+}
+
- (id)init {
return [super init];
}
@@ -27,20 +32,23 @@
}
- (void)dealloc {
+ [impl release];
+
[super dealloc];
}
-- (void)setClass:(Class<Configuration>)classImpl {
- object_setClass(self, classImpl);
+- (void)setImpl:(id<Configuration>)configImpl {
+ impl = (Configuration *)configImpl;
+ [impl retain];
}
#pragma mark Configuration implementation
-- (NSString *)osVersion {return @"";}
-- (NSString *)bundleVersion {return @"";}
-- (NSString *)defaultModulePath {return @"";}
-- (NSString *)defaultAppSupportPath {return @"";}
-- (NSString *)tempFolder {return @"";}
-- (NSString *)logFile {return @"";}
+- (NSString *)osVersion {return [impl osVersion];}
+- (NSString *)bundleVersion {return [impl bundleVersion];}
+- (NSString *)defaultModulePath {return [impl defaultModulePath];}
+- (NSString *)defaultAppSupportPath {return [impl defaultAppSupportPath];}
+- (NSString *)tempFolder {return [impl tempFolder];}
+- (NSString *)logFile {return [impl logFile];}
@end
diff --git a/bindings/objc/src/services/OSXConfiguration.h b/bindings/objc/src/services/OSXConfiguration.h
index 0fff767..93e02e1 100644
--- a/bindings/objc/src/services/OSXConfiguration.h
+++ b/bindings/objc/src/services/OSXConfiguration.h
@@ -6,7 +6,7 @@
// Copyright 2010 Software by MABE. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
#import "Configuration.h"
@interface OSXConfiguration : Configuration <Configuration> {
diff --git a/bindings/objc/src/services/iOSConfiguration.h b/bindings/objc/src/services/iOSConfiguration.h
new file mode 100644
index 0000000..2f0989b
--- /dev/null
+++ b/bindings/objc/src/services/iOSConfiguration.h
@@ -0,0 +1,24 @@
+//
+// iOSConfiguration.h
+// ObjCSword-iOS
+//
+// Created by Manfred Bergmann on 10.03.11.
+// Copyright 2011 Software by MABE. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import <Foundation/Foundation.h>
+#import "Configuration.h"
+
+
+@interface iOSConfiguration : Configuration <Configuration> {
+}
+
+- (NSString *)osVersion;
+- (NSString *)bundleVersion;
+- (NSString *)defaultModulePath;
+- (NSString *)defaultAppSupportPath;
+- (NSString *)tempFolder;
+- (NSString *)logFile;
+
+@end
diff --git a/bindings/objc/src/services/iOSConfiguration.m b/bindings/objc/src/services/iOSConfiguration.m
new file mode 100644
index 0000000..2f5b439
--- /dev/null
+++ b/bindings/objc/src/services/iOSConfiguration.m
@@ -0,0 +1,38 @@
+//
+// iOSConfiguration.m
+// ObjCSword-iOS
+//
+// Created by Manfred Bergmann on 10.03.11.
+// Copyright 2011 Software by MABE. All rights reserved.
+//
+
+#import "iOSConfiguration.h"
+
+
+@implementation iOSConfiguration
+
+- (NSString *)osVersion {
+ return [[UIDevice currentDevice] systemVersion];
+}
+
+- (NSString *)bundleVersion {
+ return (NSString *)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey);
+}
+
+- (NSString *)defaultModulePath {
+ return [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex: 0] stringByAppendingString: @"/Modules"];
+}
+
+- (NSString *)defaultAppSupportPath {
+ return [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) objectAtIndex: 0] stringByAppendingString: @"/"];
+}
+
+- (NSString *)tempFolder {
+ return [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex: 0] stringByAppendingString: @"/Temp"];
+}
+
+- (NSString *)logFile {
+ return [super logFile];
+}
+
+@end