+- (void) _checkTableWithCM: (GCSChannelManager *) cm
+ tableURL: (NSString *) url
+ andType: (NSString *) tableType
+{
+ NSString *tableName, *descFile;
+ EOAdaptorChannel *tc;
+ NGBundleManager *bm;
+ NSBundle *bundle;
+ unsigned int length;
+
+ bm = [NGBundleManager defaultBundleManager];
+
+ tc = [cm acquireOpenChannelForURL: [NSURL URLWithString: url]];
+
+ tableName = [url lastPathComponent];
+ if ([tc evaluateExpressionX:
+ [NSString stringWithFormat: @"SELECT count(*) FROM %@", tableName]])
+ {
+ bundle = [bm bundleWithName: @"MainUI" type: @"SOGo"];
+ length = [tableType length] - 3;
+ descFile = [bundle pathForResource: [tableType substringToIndex: length]
+ ofType: @"sql"];
+ if (![tc evaluateExpressionX:
+ [NSString stringWithContentsOfFile: descFile]])
+ [self logWithFormat: @"table '%@' successfully created!", tableName];
+ }
+
+ [cm releaseChannel: tc];
+
+// [self terminate];
+// NSLog (@"not yet");
+}
+
+- (BOOL) _checkMandatoryTables
+{
+ GCSChannelManager *cm;
+ NSString *urlStrings[] = {@"AgenorProfileURL", @"OCSFolderInfoURL", nil};
+ NSString **urlString;
+ NSString *value;
+ NSUserDefaults *ud;
+ BOOL ok;
+
+ ud = [NSUserDefaults standardUserDefaults];
+ ok = YES;
+ cm = [GCSChannelManager defaultChannelManager];
+
+ urlString = urlStrings;
+ while (ok && *urlString)
+ {
+ value = [ud stringForKey: *urlString];
+ if (value)
+ {
+ [self _checkTableWithCM: cm tableURL: value andType: *urlString];
+ urlString++;
+ }
+ else
+ {
+ NSLog (@"No value specified for '%@'", *urlString);
+ ok = NO;
+ }
+ }
+
+ return ok;
+}
+
+- (void) run
+{
+ if (!hasCheckedTables)
+ {
+ hasCheckedTables = YES;
+ [self _checkMandatoryTables];
+ }
+ [super run];
+}
+