Skip to content

Commit

Permalink
Merge pull request #494 from prey/lock-with-long-message
Browse files Browse the repository at this point in the history
Lock with long message
  • Loading branch information
patriciojofre authored Apr 8, 2021
2 parents e423bec + 5a90440 commit a9021b3
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/agent/actions/lock/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function lock_binary_path() {
var binary_name = 'prey-lock';

if (is_win) {
binary_name = (release >= '6.2') ? 'new-prey-lock' : 'prey-lock';
binary_name = (release >= '6.1') ? 'new-prey-lock' : 'prey-lock';
} else if (is_linux && system.python_version && system.python_version >= "3.0.0") {
binary_name += "3";
} else if (is_mac && common.os_release >= '11.0') {
Expand Down
34 changes: 30 additions & 4 deletions lib/agent/actions/lock/linux/prey-lock3
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,12 @@ class Lock:
if msgtext != "":
self.label2 = Gtk.Label()
self.label2.set_line_wrap(True)
self.label2.set_justify(2)
self.label2.set_markup('<span foreground="#FFFFFF">'+msgtext+'</span>');
label_width = len(msgtext) * 7
newtext, label_width = setLineBreaks(msgtext, findOccurrences(msgtext, " "), 100)
self.label2.set_markup('<span foreground="#FFFFFF">'+newtext+'</span>')
fixed3 = Gtk.Fixed.new()
fixed3.put(self.label2, main_screen_width/2 - label_width/2, y_position + (100 * scale))
fixed3.put(self.label2, main_screen_width/2 -(label_width*6.5)/2, y_position + (100 * scale))
fixed3.show()
vbox.pack_start(fixed3, False, False, 0)
Expand Down Expand Up @@ -325,6 +324,33 @@ def disable_XF86Switch():
# do nothing if xmodmap is not found or return an error
return
def findOccurrences(str, ch):
return [i for i, letter in enumerate(str) if letter == ch]
def setLineBreaks(string, arr, maxLength):
lineLength = maxLength
longerLine = 0
output = ""
if (len(string) < maxLength):
longerLine = len(string)
return string, longerLine
value0 = 0
for index, value in enumerate(arr):
diff = maxLength - value
if index == len(arr) - 1:
output += string[value0:]
if (diff >= 0 and diff < 10) or diff < 0:
if len(string[value0:value]) > longerLine:
longerLine = len(string[value0:value])
output += string[value0:value] + "\n"
value0 = value
maxLength += lineLength
return " " + output, longerLine
if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions lib/agent/actions/lock/mac/prey-lock
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ class LockView(NSView):
NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(3.0, self, 'hide_message', '', False)

def show_lower(self, message):
width = 500
height = 100
width = 800
height = 150
msg = NSTextField.alloc().initWithFrame_(NSMakeRect(self.getLeftOffset(width), self.getTopOffset(height) - 150, width, height))
msg.setStringValue_(message)
msg.setBezeled_(False)
Expand Down
Binary file modified lib/agent/actions/lock/windows/new-prey-lock.exe
Binary file not shown.
Binary file not shown.
16 changes: 9 additions & 7 deletions lib/agent/utils/prey-actions.app/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>20C69</string>
<string>19H524</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -27,17 +27,19 @@
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>11E801a</string>
<string>12D4e</string>
<key>DTPlatformName</key>
<string>macosx</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<string>11.1</string>
<key>DTSDKBuild</key>
<string>19G68</string>
<string>20C63</string>
<key>DTSDKName</key>
<string>macosx10.15</string>
<string>macosx11.1</string>
<key>DTXcode</key>
<string>1170</string>
<string>1240</string>
<key>DTXcodeBuild</key>
<string>11E801a</string>
<string>12D4e</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
Binary file modified lib/agent/utils/prey-actions.app/Contents/MacOS/prey-actions
Binary file not shown.
Binary file modified lib/agent/utils/prey-actions.app/Contents/Resources/Assets.car
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<dict>
<key>Resources/Assets.car</key>
<data>
PVFSbjVHPT6viCj2oYbs2xxpju8=
pC3yzqieWlX4lH88sYXAIXJ9nbo=
</data>
<key>Resources/bg-lock.png</key>
<data>
Expand All @@ -25,7 +25,7 @@
<dict>
<key>hash</key>
<data>
9O7Jrsbdl5gzFFwjBsaeu8fy9OY=
J36NhHRHpBlb++3/wZl3zSlTlBI=
</data>
<key>optional</key>
<true/>
Expand All @@ -43,7 +43,7 @@
<dict>
<key>hash</key>
<data>
GeE/t8wGDnOggucAFR1pw7FMx+0=
J36NhHRHpBlb++3/wZl3zSlTlBI=
</data>
<key>optional</key>
<true/>
Expand All @@ -55,7 +55,7 @@
<dict>
<key>hash2</key>
<data>
RV3EgFzRmFDDcKwfVc0WS4qJD87KYKLd1ipI7oSQ2g4=
2PoGoFCDY+QOU3dQJk9znJrFcPPSV/JHTuCLOPfc4YQ=
</data>
</dict>
<key>Resources/bg-lock.png</key>
Expand All @@ -78,7 +78,7 @@
<dict>
<key>hash2</key>
<data>
zUGNQ1/abKezXSbIbbhnqvR1Y1s8QQkXNWJx0uLQ+h4=
PvXohkU2YcNtS0UcWcRZ91RXJ5twEdHHliVsoji1a1s=
</data>
<key>optional</key>
<true/>
Expand All @@ -96,7 +96,7 @@
<dict>
<key>hash2</key>
<data>
DV1wMPDsshCziWhl+TslokYZjFqzrY0xDxO1pOwGkLo=
PvXohkU2YcNtS0UcWcRZ91RXJ5twEdHHliVsoji1a1s=
</data>
<key>optional</key>
<true/>
Expand Down
4 changes: 2 additions & 2 deletions test/lib/agent/actions/lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ var win_versions = {
old: {
'xp': '5.1',
'xp 64bit': '5.2',
'vista': '6.0',
'7': '6.1'
'vista': '6.0'
},
new: {
'7': '6.1',
'8': '6.2',
'8.1': '6.3',
'10': '10'
Expand Down

0 comments on commit a9021b3

Please sign in to comment.