Skip to content

Commit

Permalink
Fixed some things
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Ulrich committed Jul 5, 2009
1 parent 7426411 commit f3bcd6a
Showing 1 changed file with 19 additions and 34 deletions.
53 changes: 19 additions & 34 deletions ThingsPlugin.m
Expand Up @@ -32,7 +32,6 @@ @interface ThingsPlugin : NSObject <PluginDelegate> {
NSMutableDictionary *preferences;
int queryLimit;
//bool preferencesChanged;
bool enabled;
}

- (NSDictionary*) data;
Expand All @@ -49,7 +48,6 @@ - (id)init {
preferences = [[NSMutableDictionary alloc] initWithContentsOfFile:preferencesPath];

queryLimit = [[preferences valueForKey:@"Limit"] intValue];
enabled = [[preferences valueForKey:@"Enabled"] boolValue];

NSString* databasePath = [preferences objectForKey:@"databasePath"];
if(databasePath == nil || [databasePath length] == 0) {
Expand Down Expand Up @@ -158,54 +156,41 @@ - (NSDictionary*) readFromDatabase {
- (NSDictionary*) data {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

if(enabled == true) {
NSDictionary *fileAttributes = [[NSFileManager defaultManager]
fileAttributesAtPath:[preferences objectForKey:@"databasePath"]
traverseLink:YES];

NSDictionary *fileAttributes = [[NSFileManager defaultManager]
fileAttributesAtPath:[preferences objectForKey:@"databasePath"]
traverseLink:YES];
NSDate* lastModified = [fileAttributes objectForKey:NSFileModificationDate];

NSDate* lastModified = [fileAttributes objectForKey:NSFileModificationDate];
if(lastCheckout == nil || lastData == nil ||
[lastModified compare:lastCheckout] == NSOrderedDescending) {
NSLog(@"We don't have the last time or data, updating");

if(lastCheckout == nil || lastData == nil ||
[lastModified compare:lastCheckout] == NSOrderedDescending) {
NSLog(@"We don't have the last time or data, updating");

NSDictionary* dict = [self readFromDatabase];
NSDictionary* dict = [self readFromDatabase];

if(lastData != nil)
[lastData release];
lastData = [dict retain];
if(lastData != nil)
[lastData release];
lastData = [dict retain];

if(lastCheckout != nil)
[lastCheckout release];
lastCheckout = [lastModified retain];
if(lastCheckout != nil)
[lastCheckout release];
lastCheckout = [lastModified retain];

NSLog(@"Succesfully got new data");
} else {
NSLog(@"No update");
}

[pool drain];

return lastData;
NSLog(@"Succesfully got new data");
} else {
[pool drain];
NSLog(@"ThingsPlugin is disabled.");
return [NSDictionary dictionaryWithObjectsAndKeys:
// preferences, @"preferences",
[NSArray array], @"todos",
nil];
NSLog(@"No update");
}

[pool drain];

return lastData;
}

- (void) setPreferences:(NSDictionary*) prefs {
[preferences release];
preferences = [prefs retain];

queryLimit = [[preferences valueForKey:@"Limit"] intValue];
enabled = [[preferences valueForKey:@"Enabled"] boolValue];


//Force an update of the data
if(lastData != nil) {
Expand Down

0 comments on commit f3bcd6a

Please sign in to comment.