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

Windows report picture retry #324

Merged
merged 1 commit into from
Aug 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);

}