Skip to content

Commit

Permalink
Initial work which fixes #52
Browse files Browse the repository at this point in the history
  • Loading branch information
xor-gate committed Jul 3, 2018
1 parent 401cac4 commit 74fc8a6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions syncthing/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
<string>https://xor-gate.github.io/syncthing-macosx/appcast.xml</string>
<key>SUScheduledCheckInterval</key>
<integer>86400</integer>
<key>NSUserNotificationAlertStyle</key>
<string>alert</string>
<key>CFBundleGetInfoString</key>
<string>syncthing project Group</string>
</dict>
Expand Down
26 changes: 24 additions & 2 deletions syncthing/STApplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ @interface STAppDelegate ()
@implementation STAppDelegate

- (void) applicationDidFinishLaunching:(NSNotification *)aNotification {
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];

_syncthing = [[XGSyncthing alloc] init];

[self applicationLoadConfiguration];
Expand All @@ -25,6 +27,28 @@ - (void) applicationDidFinishLaunching:(NSNotification *)aNotification {
_statusMonitor.syncthing = _syncthing;
_statusMonitor.delegate = self;
[_statusMonitor startMonitoring];

NSUserNotification *n = [[NSUserNotification alloc] init];
n.title = @"Syncthing";
n.informativeText = @"Add folder NewFolder";
n.hasActionButton = true;
n.actionButtonTitle = @"Accept";
n.otherButtonTitle = @"Decline";
// XXX: Seems undocumented API hack or else the buttons are not shown
[n setValue:@YES forKey:@"_showsButtons"];

[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:n];
}

- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification{
return YES;
}

- (void) userNotificationCenter:(NSUserNotificationCenter *)center
didActivateNotification:(NSUserNotification *)notification
{

NSLog(@"geklikt");
}

- (void) clickedFolder:(id)sender {
Expand Down Expand Up @@ -125,9 +149,7 @@ - (void) syncMonitorStatusChanged:(SyncthingStatus)status {
}

- (void) syncMonitorEventReceived:(NSDictionary *)event {
NSNumber *eventId = [event objectForKey:@"id"];
NSString *eventType = [event objectForKey:@"type"];
NSDictionary *eventData = [event objectForKey:@"data"];

if ([eventType isEqualToString:@"ConfigSaved"]) {
[self refreshDevices];
Expand Down

0 comments on commit 74fc8a6

Please sign in to comment.