Skip to content

Instantly share code, notes, and snippets.

@technolize
Created March 29, 2009 05:22
Show Gist options
  • Save technolize/87290 to your computer and use it in GitHub Desktop.
Save technolize/87290 to your computer and use it in GitHub Desktop.
Mail fetch toggle SBSettings add-on.
#import <Foundation/Foundation.h>
#import <unistd.h>
#import <stdlib.h>
#import <ctype.h>
#import <notify.h>
#define PREF_FILE @"/var/mobile/Library/Preferences/com.apple.persistentconnection.plist"
BOOL isCapable() {
return YES;
}
BOOL isEnabled() {
NSDictionary *config = [NSDictionary dictionaryWithContentsOfFile:PREF_FILE];
BOOL ret = [[config objectForKey:@"PCDefaultPollInterval"] boolValue];
return ret;
}
void setState(BOOL enable) {
NSMutableDictionary *config = [NSMutableDictionary dictionaryWithContentsOfFile:PREF_FILE];
if ( enable == YES )
[config setValue:[NSNumber numberWithInt:900] forKey:@"PCDefaultPollInterval"];
else
[config setValue:[NSNumber numberWithInt:0] forKey:@"PCDefaultPollInterval"];
[config writeToFile:PREF_FILE atomically: YES];
}
float getDelayTime() {
return 0.5f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment