Skip to content

Commit

Permalink
Merge pull request #107 from capecodnative/Sync-Sleep-Status
Browse files Browse the repository at this point in the history
Added "Sync Sleep Status" option
  • Loading branch information
johndbritton authored Feb 1, 2022
2 parents 9695ffa + 0e3c7e3 commit 5d37110
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 4 deletions.
11 changes: 11 additions & 0 deletions Base.lproj/teleportPref.xib
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,17 @@
<binding destination="297" name="value" keyPath="selection.prefs.syncLockStatus" id="Nv7-V2-bSN"/>
</connections>
</button>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KHF-53-IwL">
<rect key="frame" x="613" y="457" width="133" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Sync sleep status" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="GXj-JD-8n2">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="297" name="value" keyPath="selection.prefs.syncSleepStatus" id="3a4-83-9Fl"/>
</connections>
</button>
</subviews>
</view>
<point key="canvasLocation" x="588" y="515.5"/>
Expand Down
2 changes: 1 addition & 1 deletion TPMainController.m
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ - (void)screensDidSleep:(NSNotification*)notification
[self _invalidateTimer];
TPClientController * clientController = [TPClientController defaultController];
TPMessage *message = [TPMessage messageWithType:TPControlSleepType];
if ([clientController currentConnection] != nil) {
if ([clientController currentConnection] != nil && [[TPPreferencesManager sharedPreferencesManager] boolForPref:SYNC_SLEEP_STATUS]) {
[[clientController currentConnection] sendMessage:message];
}
}
Expand Down
1 change: 1 addition & 0 deletions TPPreferencesManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define PREFS_VERSION @"prefsVersion"
#define SHARE_PASTEBOARD @"sharePasteboard"
#define SYNC_LOCK_STATUS @"syncLockStatus"
#define SYNC_SLEEP_STATUS @"syncSleepStatus"
#define ALLOW_CONTROL @"allowControl"
#define REQUIRE_KEY @"requireKey"
#define DELAYED_SWITCH @"delayedSwitch"
Expand Down
1 change: 1 addition & 0 deletions TPPreferencesManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ - (NSUserDefaultsController*)_defaultsController

[_userDefaultsController setInitialValues:@{SHARE_PASTEBOARD: @YES,
SYNC_LOCK_STATUS: @NO,
SYNC_SLEEP_STATUS: @NO,
ALLOW_CONTROL: @NO,
REQUIRE_KEY: @NO,
DELAYED_SWITCH: @NO,
Expand Down
2 changes: 2 additions & 0 deletions TPServerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,9 @@ - (void)connection:(TPNetworkConnection*)connection receivedMessage:(TPMessage*)
switch(type) {
case TPControlSleepType:
DebugLog(@"received sleep msg");
if ([[TPPreferencesManager sharedPreferencesManager] boolForPref:SYNC_SLEEP_STATUS]) {
[[TPLocalHost localHost] sleepScreen];
}
break;
case TPControlWakeType:
DebugLog(@"received wake msg");
Expand Down
6 changes: 6 additions & 0 deletions TPStatusItemController.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ - (void)setShowStatusItem:(BOOL)showStatusItem
[syncLockStatusMenuItem setRepresentedObject:SYNC_LOCK_STATUS];
[syncLockStatusMenuItem bind:@"state" toObject:[TPPreferencesManager sharedPreferencesManager] withKeyPath:SYNC_LOCK_STATUS options:nil];
[menu addItem:syncLockStatusMenuItem];

NSMenuItem * syncSleepStatusMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Sync sleep status", nil) action:@selector(switchMenuItem:) keyEquivalent:@""];
[syncSleepStatusMenuItem setTarget:self];
[syncSleepStatusMenuItem setRepresentedObject:SYNC_SLEEP_STATUS];
[syncSleepStatusMenuItem bind:@"state" toObject:[TPPreferencesManager sharedPreferencesManager] withKeyPath:SYNC_SLEEP_STATUS options:nil];
[menu addItem:syncSleepStatusMenuItem];

[menu addItem:[NSMenuItem separatorItem]];

Expand Down
6 changes: 3 additions & 3 deletions teleport.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 1.3.4;
CURRENT_PROJECT_VERSION = 1.3.5;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
EXCLUDED_ARCHS = "";
Expand Down Expand Up @@ -1167,7 +1167,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.3.4;
CURRENT_PROJECT_VERSION = 1.3.5;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
EXCLUDED_ARCHS = "";
Expand Down Expand Up @@ -1280,7 +1280,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.3.4;
CURRENT_PROJECT_VERSION = 1.3.5;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
EXCLUDED_ARCHS = "";
Expand Down

0 comments on commit 5d37110

Please sign in to comment.