Skip to content

Commit

Permalink
Merge pull request #324 from prey/picture-retry
Browse files Browse the repository at this point in the history
Windows report picture retry
  • Loading branch information
javo authored Aug 31, 2017
2 parents f56b7a2 + eef0aac commit f3be5a9
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions lib/agent/providers/webcam/windows/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
var exec = require('child_process').exec,
var fs = require('fs'),
exec = require('child_process').exec,
join = require('path').join;

exports.get_picture = function(file, callback){

var cmd = '"' + join(__dirname, '/prey-webcam.exe') + '"';
cmd += ' -invalid youcam,cyberlink,google -frame 10 -outfile ' + file;
var exes = ['/prey-wecam.exe', '/snapshot.exe'],
opts = [' -invalid youcam,cyberlink,google -frame 10 -outfile ', ' /T '];

exec(cmd, function(err) {
callback(err, 'image/jpeg'); // if err exists, content_type will not matter
})
var picture_command = function(index) {
return '"' + join(__dirname, exes[index]) + '"' + opts[index] + file;
}

}
var take_picture = function(method) {
exec(picture_command(method), function(err) {
if (!fs.existsSync(file) && method == 0) {
file = file.replace(/.jpg/g, '');
take_picture(1);
} else
callback(err, 'image/jpeg'); // if err exists, content_type will not matter
})
}

take_picture(0);

}

0 comments on commit f3be5a9

Please sign in to comment.