[sword-svn] r3368 - trunk/bindings/objc/src

mdbergmann at crosswire.org mdbergmann at crosswire.org
Sat Apr 11 05:46:54 MST 2015


Author: mdbergmann
Date: 2015-04-11 05:46:54 -0700 (Sat, 11 Apr 2015)
New Revision: 3368

Modified:
   trunk/bindings/objc/src/SwordInstallSourceManager.h
   trunk/bindings/objc/src/SwordInstallSourceManager.mm
   trunk/bindings/objc/src/SwordModule.mm
   trunk/bindings/objc/src/SwordVerseManager.mm
Log:
added possibility to override ftp user and password when using InstallMgr.
Some more minor cleanups.

Modified: trunk/bindings/objc/src/SwordInstallSourceManager.h
===================================================================
--- trunk/bindings/objc/src/SwordInstallSourceManager.h	2015-03-23 10:10:59 UTC (rev 3367)
+++ trunk/bindings/objc/src/SwordInstallSourceManager.h	2015-04-11 12:46:54 UTC (rev 3368)
@@ -60,6 +60,7 @@
  */
 - (id)init;
 - (id)initWithPath:(NSString *)aPath createPath:(BOOL)create;
+- (id)initWithFtpUser:(NSString *)aFtpUser ftpPassword:(NSString *)aFtpPassword;
 
 /** re-init after adding or removing new modules */
 - (void)reinitialize;

Modified: trunk/bindings/objc/src/SwordInstallSourceManager.mm
===================================================================
--- trunk/bindings/objc/src/SwordInstallSourceManager.mm	2015-03-23 10:10:59 UTC (rev 3367)
+++ trunk/bindings/objc/src/SwordInstallSourceManager.mm	2015-04-11 12:46:54 UTC (rev 3368)
@@ -19,6 +19,14 @@
 #define INSTALLSOURCE_SECTION_TYPE_FTP  "FTPSource"
 #define INSTALLSOURCE_SECTION_TYPE_HTTP	"HTTPSource"
 
+
+ at interface SwordInstallSourceManager ()
+
+ at property (strong, nonatomic) NSString *ftpUser;
+ at property (strong, nonatomic) NSString *ftpPassword;
+
+ at end
+
 @implementation SwordInstallSourceManager
 
 @dynamic configPath;
@@ -42,17 +50,17 @@
         // check for existence
         NSFileManager *fm = [NSFileManager defaultManager];
         BOOL isDir;
-        if(([fm fileExistsAtPath:configPath] == NO) && createPath == YES) {
+        if(![fm fileExistsAtPath:configPath] && createPath) {
             // create path
             [fm createDirectoryAtPath:configPath withIntermediateDirectories:NO attributes:nil error:NULL];
         }
         
-        if(([fm fileExistsAtPath:configPath isDirectory:&isDir] == YES) && (isDir)) {
+        if([fm fileExistsAtPath:configPath isDirectory:&isDir] && (isDir)) {
             // set configFilePath
             [self setConfigFilePath:[configPath stringByAppendingPathComponent:@"InstallMgr.conf"]];
             
             // check config
-            if([fm fileExistsAtPath:self.configFilePath] == NO) {
+            if(![fm fileExistsAtPath:self.configFilePath]) {
                 // create config entry
                 sword::SWConfig config([self.configFilePath cStringUsingEncoding:NSUTF8StringEncoding]);
                 config["General"]["PassiveFTP"] = "true";
@@ -113,6 +121,8 @@
         [self setConfigFilePath:nil];
         [self setInstallSources:[NSMutableDictionary dictionary]];
         [self setInstallSourceList:[NSMutableArray array]];
+        [self setFtpUser:@"ftp"];
+        [self setFtpPassword:@"ObjCSword at crosswire.org"];
     }
     
     return self;
@@ -131,6 +141,15 @@
     return self;
 }
 
+- (id)initWithFtpUser:(NSString *)aFtpUser ftpPassword:(NSString *)aFtpPassword {
+    self = [self init];
+    if(self) {
+        [self setFtpUser:aFtpUser];
+        [self setFtpPassword:aFtpPassword];
+    }
+    return self;
+}
+
 /** re-init after adding or removing new modules */
 - (void)reinitialize {
     sword::SWConfig config([self.configFilePath UTF8String]);
@@ -141,7 +160,8 @@
     if(swInstallMgr != nil) {
         disclaimerConfirmed = [self userDisclaimerConfirmed];
     }
-    swInstallMgr = new sword::InstallMgr([configPath UTF8String]);
+    ALog(@"Creating InstallMgr with: %@, %i, %@, %@", configPath, 0, [self ftpUser], [self ftpPassword]);
+    swInstallMgr = new sword::InstallMgr([configPath UTF8String], 0, sword::SWBuf([[self ftpUser] UTF8String]), sword::SWBuf([[self ftpPassword] UTF8String]));
     if(swInstallMgr == nil) {
         ALog(@"Could not initialize InstallMgr!");
     } else {
@@ -156,7 +176,7 @@
             sword::InstallSource *sis = it->second;
             SwordInstallSource *is = [[SwordInstallSource alloc] initWithSource:sis];
             
-            [self.installSources setObject:is forKey:[is caption]];
+            self.installSources[[is caption]] = is;
             // also add to list
             [self.installSourceList addObject:is];
         }
@@ -168,9 +188,6 @@
     if(swInstallMgr != nil) {
         delete swInstallMgr;
     }
-    
-    [self setConfigPath:nil];
-    
 }
 
 - (void)addInstallSource:(SwordInstallSource *)is {
@@ -273,7 +290,7 @@
     if(is == nil) {
         ALog(@"Install source is nil");
     } else {
-        if([[is source] isEqualToString:@"localhost"] == NO) {
+        if(![[is source] isEqualToString:@"localhost"]) {
             ret = swInstallMgr->refreshRemoteSource([is installSource]);
         }
     }

Modified: trunk/bindings/objc/src/SwordModule.mm
===================================================================
--- trunk/bindings/objc/src/SwordModule.mm	2015-03-23 10:10:59 UTC (rev 3367)
+++ trunk/bindings/objc/src/SwordModule.mm	2015-04-11 12:46:54 UTC (rev 3368)
@@ -405,7 +405,7 @@
     if(key != nil) {
         // check user defaults, that's where we store the entered keys
         NSDictionary *cipherKeys = [[NSUserDefaults standardUserDefaults] objectForKey:DefaultsModuleCipherKeysKey];
-        if([key length] == 0 && [[cipherKeys allKeys] containsObject:[self name]] == NO) {
+        if([key length] == 0 && ![[cipherKeys allKeys] containsObject:[self name]]) {
             locked = YES;
         }
     }

Modified: trunk/bindings/objc/src/SwordVerseManager.mm
===================================================================
--- trunk/bindings/objc/src/SwordVerseManager.mm	2015-03-23 10:10:59 UTC (rev 3367)
+++ trunk/bindings/objc/src/SwordVerseManager.mm	2015-04-11 12:46:54 UTC (rev 3368)
@@ -48,7 +48,7 @@
 
 /** books for a versification scheme */
 - (NSArray *)booksForVersification:(NSString *)verseScheme {
-    NSArray *ret = [booksPerVersification objectForKey:verseScheme];
+    NSArray *ret = booksPerVersification[verseScheme];
     if(ret == nil) {
         // hasn't been initialized yet
         const sword::VersificationMgr::System *system = verseMgr->getVersificationSystem([verseScheme UTF8String]);
@@ -63,7 +63,7 @@
             // add to array
             [buf addObject:bb];
         }
-        [booksPerVersification setObject:buf forKey:verseScheme];
+        booksPerVersification[verseScheme] = buf;
         ret = buf;
     }
     




More information about the sword-cvs mailing list