Skip to content

Commit

Permalink
version 0.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
krist committed May 10, 2011
1 parent 0d76806 commit 6f2d3d7
Show file tree
Hide file tree
Showing 8 changed files with 249 additions and 1,021 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

- (void)prefsNotification:(NSNotification*)aNotification;

- (IBAction) setOverwriteSnapshot:(id)sender;
//- (IBAction) setOverwriteSnapshot:(id)sender;
- (IBAction) aboutWindowController: (id) sender;
- (IBAction) prefWindowController: (id) sender;
- (IBAction) prefTestEmail:(id)sender;
Expand Down
71 changes: 39 additions & 32 deletions Controller.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ - (void)awakeFromNib
NSLog(@"awake from nib");
NSNumber *pref_delay = (NSNumber*)CFPreferencesCopyAppValue( CFSTR("snapshotDelay"), appID);
NSNumber *pref_delayOnlyWakeup = (NSNumber*)CFPreferencesCopyAppValue( CFSTR("isDelayOnlyWakeup"), appID );
NSNumber *alertMeter = (NSNumber *)CFPreferencesCopyAppValue(CFSTR("alertLevel"), appID);
//NSLog(@"network? %d",[[NSUserDefaults standardUserDefaults] boolForKey:@"includeNetwork"]);
NSNumber *alertLevel = (NSNumber *)CFPreferencesCopyAppValue(CFSTR("alertLevel"), appID);

NSLog(@"delay: %d",[pref_delay intValue] );
NSLog(@"do i delay %d",[pref_delayOnlyWakeup boolValue] );
NSLog(@"alert level %d",[alertMeter intValue]);
NSLog(@"alert level %d",[alertLevel intValue]);
NSLog(@"email server %@",(NSString *)CFPreferencesCopyAppValue(CFSTR("smtpURL"), appID));

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(anyThread_handleLoadedSnapshots:) name:LoadSnapshotsFinish object:nil];
Expand All @@ -128,16 +128,13 @@ - (void)awakeFromNib
suspensionBehavior: NSNotificationSuspensionBehaviorCoalesce
];

if([[NSUserDefaults standardUserDefaults] boolForKey:@"isDelayOnlyWakeup"]){
if([pref_delayOnlyWakeup boolValue]){
[self startSneaky:fullPath];
}else{
[self performSelector: @selector(startSneaky:)
withObject:fullPath
afterDelay:[[NSUserDefaults standardUserDefaults] integerForKey:@"snapshotDelay"]];

afterDelay:[pref_delay intValue]];
}


}


Expand Down Expand Up @@ -174,21 +171,25 @@ - (void) machineWillSleep:(NSNotification *)notification{
}

- (void) machineDidWake:(NSNotification *)notification{
NSLog(@"sneaky wake up! %d seconds",[[NSUserDefaults standardUserDefaults] integerForKey:@"snapshotDelay"]);
NSNumber *pref_delay = (NSNumber*)CFPreferencesCopyAppValue( CFSTR("snapshotDelay"), appID);
NSLog(@"sneaky wake up! %d seconds",[pref_delay intValue]);

//[self startSneaky:fullPath];
[self performSelector: @selector(startSneaky:)
withObject:fullPath
afterDelay:[[NSUserDefaults standardUserDefaults] integerForKey:@"snapshotDelay"]];
afterDelay:[pref_delay intValue]];
}

- (void) screenSaverDidStop:(NSNotification *)notification{
NSLog(@"back from idle time %d",[[NSUserDefaults standardUserDefaults] integerForKey:@"alertLevel"]);
if([[NSUserDefaults standardUserDefaults] integerForKey:@"alertLevel"] == 1){
NSNumber *pref_delay = (NSNumber*)CFPreferencesCopyAppValue( CFSTR("snapshotDelay"), appID);
NSNumber *pref_delayOnlyWakeup = (NSNumber*)CFPreferencesCopyAppValue( CFSTR("isDelayOnlyWakeup"), appID );
NSNumber *alertLevel = (NSNumber *)CFPreferencesCopyAppValue(CFSTR("alertLevel"), appID);
NSLog(@"back from idle time %d",[alertLevel intValue]);
if([alertLevel intValue] == 1){

[self performSelector: @selector(startSneaky:)
withObject:fullPath
afterDelay:([[NSUserDefaults standardUserDefaults] boolForKey:@"isDelayOnlyWakeup"]) ? 0.5 : [[NSUserDefaults standardUserDefaults] integerForKey:@"snapshotDelay"]];
afterDelay:([pref_delayOnlyWakeup boolValue]) ? 0.5 : [pref_delay intValue]];
}
}

Expand Down Expand Up @@ -254,17 +255,25 @@ - (void)sendMailStart:(id)sender
NSLog(@"network is not connected");
}else{
NSLog(@"credentials complete");

//NSString *smtpURL = (NSString *)CFPreferencesCopyAppValue(CFSTR("smtpURL"), appID);
//NSNumber *smtpPort = (NSNumber *)CFPreferencesCopyAppValue(CFSTR("smtpPort"), appID);
NSString *smtpUsername = (NSString *)CFPreferencesCopyAppValue(CFSTR("smtpUsername"), appID);
NSString *smtpPassword = (NSString *)CFPreferencesCopyAppValue(CFSTR("smtpPassword"), appID);
NSString *emailFrom = (NSString *)CFPreferencesCopyAppValue(CFSTR("emailFrom"), appID);
NSString *emailAddress = (NSString *)CFPreferencesCopyAppValue(CFSTR("emailAddress"), appID);
NSString *emailSubject = (NSString *)CFPreferencesCopyAppValue(CFSTR("emailSubject"), appID);
NSNumber *includeNetwork = (NSNumber *)CFPreferencesCopyAppValue(CFSTR("includeNetwork"), appID);

// setup smtp credentials
NSMutableDictionary *authInfo = [NSMutableDictionary dictionary];
[authInfo setObject:[[NSUserDefaults standardUserDefaults] stringForKey:@"smtpUsername"] forKey:EDSMTPUserName];
[authInfo setObject:[[NSUserDefaults standardUserDefaults] stringForKey:@"smtpPassword"] forKey:EDSMTPPassword];
[authInfo setObject:smtpUsername forKey:EDSMTPUserName];
[authInfo setObject:smtpPassword forKey:EDSMTPPassword];

// setup email header
// setup email header
NSMutableDictionary *headerFields = [NSMutableDictionary dictionary];
[headerFields setObject:[[NSUserDefaults standardUserDefaults] stringForKey:@"emailFrom"] forKey:@"From"];
[headerFields setObject:[[NSUserDefaults standardUserDefaults] stringForKey:@"emailAddress"] forKey:@"To"];
[headerFields setObject:[[NSUserDefaults standardUserDefaults] stringForKey:@"emailSubject"] forKey:@"Subject"];
[headerFields setObject:emailFrom forKey:@"From"];
[headerFields setObject:emailAddress forKey:@"To"];
[headerFields setObject:emailSubject forKey:@"Subject"];

// setup attachments
id item = NULL;
Expand All @@ -286,7 +295,7 @@ - (void)sendMailStart:(id)sender
[queue cancelAllOperations];
NSLog(@"sending mail");

if([[NSUserDefaults standardUserDefaults] boolForKey:@"includeNetwork"] == true){
if([includeNetwork boolValue] == true){
NSEnumerator *addresses = [[[NSHost currentHost] addresses] objectEnumerator];
NSString *address;
while (address = [addresses nextObject])
Expand Down Expand Up @@ -353,8 +362,8 @@ - (BOOL) useSmtpSettings
(NSNumber *)CFPreferencesCopyAppValue(CFSTR("smtpPort"), appID) != nil &&
(NSString *)CFPreferencesCopyAppValue(CFSTR("smtpUsername"), appID) != nil &&
(NSString *)CFPreferencesCopyAppValue(CFSTR("smtpPassword"), appID) != nil &&
(NSString *)CFPreferencesCopyAppValue(CFSTR("emailFrom"), appID) != nil &&
(NSString *)CFPreferencesCopyAppValue(CFSTR("emailAddress"), appID) != nil &&
(NSString *)CFPreferencesCopyAppValue(CFSTR("emailAddressTo"), appID) != nil &&
(NSString *)CFPreferencesCopyAppValue(CFSTR("emailSubject"), appID) != nil &&
(NSNumber *)CFPreferencesCopyAppValue(CFSTR("includeNetwork"), appID) != nil);
}
Expand Down Expand Up @@ -505,8 +514,8 @@ - (void) actionQuit:(id)sender {
- (void) quickSnap:(id)sender{

NSString *fn;

if([[NSUserDefaults standardUserDefaults] boolForKey:@"overwriteSnapshot"] == 1){
NSNumber *overwriteSnapshots = (NSNumber *)CFPreferencesCopyAppValue(CFSTR("overwriteSnapshot"), appID);
if([overwriteSnapshots boolValue] == 1){
NSDate *now = [NSDate date];

NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
Expand Down Expand Up @@ -577,7 +586,7 @@ - (id)statusItem
NSNumber *showMenu = (NSNumber*)CFPreferencesCopyAppValue( CFSTR("showInMenubar"), appID );
if (_statusItem == nil)
{
if(showMenu){
if([showMenu boolValue]){
NSLog(@"showing menubar icon");
NSImage *img;

Expand Down Expand Up @@ -618,11 +627,11 @@ - (NSString*)searchPrefsPath
return nil;
}

- (IBAction) setOverwriteSnapshot:(id)sender{

NSLog(@"overwrite snapshot %d",[[NSUserDefaults standardUserDefaults] boolForKey:@"overwriteSnapshot"]);

}
//- (IBAction) setOverwriteSnapshot:(id)sender{
//
// NSLog(@"overwrite snapshot %d",[[NSUserDefaults standardUserDefaults] boolForKey:@"overwriteSnapshot"]);
//
//}

- (NSString *)versionString
{
Expand Down Expand Up @@ -671,12 +680,10 @@ -(void)prefsNotification:(NSNotification*)aNotification
{
NSLog(@"notification from prefpane %@",[aNotification name]);
if ([[ aNotification name ] isEqualTo: @"SBShowMenubar" ]) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"showInMenubar"];
NSLog(@"show in menu bar notify");
[self statusItem];
}else if([[ aNotification name] isEqualTo: @"SBHideMenubar" ]){
NSLog(@"hide menubar notify");
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"showInMenubar"];
if(_statusItem != nil){
[[NSStatusBar systemStatusBar] removeStatusItem:_statusItem];
[_statusItem release];
Expand Down
1 change: 1 addition & 0 deletions MailOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extern NSString *EmailSentSuccess;
extern NSString *EmailSentFail;

@interface MailOperation : NSOperation {
CFStringRef appID;
NSArray* attachments;
NSArray* ipAddresses;
NSDictionary* headers;
Expand Down
10 changes: 4 additions & 6 deletions MailOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ - (id)initWithRootPath:(NSString *)pp queue:(NSOperationQueue *)qq
ipAddr:(NSArray *)ipAddress
{
self = [super init];
appID = CFSTR("org.hellowala.sneakybastard");
attachments = [aList retain];
headers = [hList retain];
authInfo = [aInfo retain];
Expand All @@ -59,17 +60,14 @@ - (void)main
if ([self isCancelled] ){
NSLog(@"cancelled");
}
NSLog(@"main email loop");
NSString *smtpURL = (NSString *)CFPreferencesCopyAppValue(CFSTR("smtpURL"), appID);
NSLog(@"main email loop %@",smtpURL);
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];


NSString *text;
text = @"Sent from:\r\n";
text = [text stringByAppendingString:[ipAddresses description]];




text = [text stringByAppendingString:[ipAddresses description]];

EDMailAgent *mailAgent; //= [[EDMailAgent alloc] autorelease];
mailAgent = [EDMailAgent mailAgentForRelayHostWithName:[[NSUserDefaults standardUserDefaults] stringForKey:@"smtpURL"] port:[[NSUserDefaults standardUserDefaults] integerForKey:@"smtpPort"]];
Expand Down
Loading

0 comments on commit 6f2d3d7

Please sign in to comment.