Browse Source

Migration to Firebase.

v1.2.4
Abhishek Banthia 9 years ago
parent
commit
570706d77d
  1. 77
      Clocker/App Feedback/CLAppFeedbackWindowController.m
  2. 13
      Clocker/CLParentPanelController.h
  3. 17
      Clocker/Floating Window/CLFloatingWindowController.h

77
Clocker/App Feedback/CLAppFeedbackWindowController.m

@ -9,6 +9,7 @@
#import "CLAppFeedbackWindowController.h"
#import "CLOneWindowController.h"
#import "CommonStrings.h"
#import <Firebase/Firebase.h>
NSString *const CLAppFeedbackNibIdentifier = @"CLAppFeedbackWindow";
NSString *const CLParseAppFeedbackClassIdentifier = @"CLAppFeedback";
@ -88,39 +89,30 @@ static CLAppFeedbackWindowController *sharedFeedbackWindow = nil;
return;
}
/*
PFObject *feedbackObject = [PFObject objectWithClassName:CLParseAppFeedbackClassIdentifier];
feedbackObject[CLParseAppFeedbackNameProperty] = (self.nameField.stringValue.length > 0) ?
self.nameField.stringValue : CLParseAppFeedbackNoResponseString;
feedbackObject[CLParseAppFeedbackEmailProperty] = (self.emailField.stringValue.length > 0) ?
self.emailField.stringValue : CLParseAppFeedbackNoResponseString;
feedbackObject[CLParseAppFeedbackFeedbackProperty] = self.feedbackTextView.string;
[feedbackObject saveInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) {
self.activityInProgress = NO;
if (!succeeded) {
self.informativeText.stringValue = error.localizedDescription;
[NSTimer scheduledTimerWithTimeInterval:10.0
target:self
selector:@selector(cleanUp)
userInfo:nil
repeats:NO];
}
else
{
NSAlert *alert = [NSAlert new];
alert.messageText = NSLocalizedString(CLFeedbackAlertTitle, @"Thank you for helping make Clocker even better!");
alert.informativeText = CLFeedbackAlertInformativeText;
[alert addButtonWithTitle:CLFeedbackAlertButtonTitle];
[alert beginSheetModalForWindow:self.window
completionHandler:^(NSModalResponse returnCode) {
[self.window close];
}];
}
}];
NSMutableDictionary *feedbackInfo = [[NSMutableDictionary alloc] init];
[feedbackInfo setObject:(self.nameField.stringValue.length > 0) ?
self.nameField.stringValue : CLParseAppFeedbackNoResponseString forKey:CLParseAppFeedbackNameProperty];
[feedbackInfo setObject:(self.emailField.stringValue.length > 0) ?
self.emailField.stringValue : CLParseAppFeedbackNoResponseString forKey:CLParseAppFeedbackEmailProperty];
[feedbackInfo setObject:self.feedbackTextView.string forKey:CLParseAppFeedbackFeedbackProperty ];
// Create a reference to a Firebase database URL
Firebase *myRootRef = [[Firebase alloc] initWithUrl:@"https://fiery-heat-5237.firebaseio.com/Feedback"];
Firebase *feedbackRef = [myRootRef childByAppendingPath:[self getSerialNumber]];
// Write data to Firebase
*/
[feedbackRef setValue:feedbackInfo];
self.activityInProgress = NO;
NSAlert *alert = [NSAlert new];
alert.messageText = NSLocalizedString(CLFeedbackAlertTitle, @"Thank you for helping make Clocker even better!");
alert.informativeText = CLFeedbackAlertInformativeText;
[alert addButtonWithTitle:CLFeedbackAlertButtonTitle];
[alert beginSheetModalForWindow:self.window
completionHandler:^(NSModalResponse returnCode) {
[self.window close];
}];
}
- (void)cleanUp
@ -149,5 +141,28 @@ static CLAppFeedbackWindowController *sharedFeedbackWindow = nil;
}];
}
- (NSString *)getSerialNumber
{
io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault,
IOServiceMatching("IOPlatformExpertDevice"));
CFStringRef serialNumberAsCFString = NULL;
if (platformExpert) {
serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert,
CFSTR(kIOPlatformSerialNumberKey),
kCFAllocatorDefault, 0);
IOObjectRelease(platformExpert);
}
NSString *serialNumberAsNSString = nil;
if (serialNumberAsCFString) {
serialNumberAsNSString = [NSString stringWithString:(__bridge NSString *)serialNumberAsCFString];
CFRelease(serialNumberAsCFString);
}
return serialNumberAsNSString;
}
@end

13
Clocker/CLParentPanelController.h

@ -1,13 +0,0 @@
//
// CLParentPanelController.h
// Clocker
//
// Created by Abhishek Banthia on 4/4/16.
//
//
#import <Cocoa/Cocoa.h>
@interface CLParentPanelController : NSWindowController
@end

17
Clocker/Floating Window/CLFloatingWindowController.h

@ -0,0 +1,17 @@
//
// CLFloatingWindowController.h
// Clocker
//
// Created by Abhishek Banthia on 4/2/16.
//
//
#import <Cocoa/Cocoa.h>
#import "CLParentPanelController.h"
@interface CLFloatingWindowController : CLParentPanelController <NSTableViewDataSource>
+ (instancetype)sharedFloatingWindow;
- (void)updatePanelColor;
@end
Loading…
Cancel
Save