Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications for new devices and folders #54

Draft
wants to merge 13 commits into
base: develop
Choose a base branch
from
Draft
Prev Previous commit
Next Next commit
Initial work which fixes #52
xor-gate committed Jul 3, 2018

Verified

This commit was signed with the committer’s verified signature.
renovate-bot Mend Renovate
commit 74fc8a66c399dc7fc54c220b5e1726475c863baf
2 changes: 2 additions & 0 deletions syncthing/Info.plist
Original file line number Diff line number Diff line change
@@ -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>
26 changes: 24 additions & 2 deletions syncthing/STApplication.m
Original file line number Diff line number Diff line change
@@ -16,6 +16,8 @@ @interface STAppDelegate ()
@implementation STAppDelegate

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

_syncthing = [[XGSyncthing alloc] init];

[self applicationLoadConfiguration];
@@ -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 {
@@ -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];