Skip to content

Commit

Permalink
Merge pull request #7 from thiagoelg/electron7
Browse files Browse the repository at this point in the history
Electron7 fix
  • Loading branch information
thiagoelg authored Oct 30, 2019
2 parents e70dc9b + 0879653 commit 66e0df7
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ install:
- cmd: SET JOBS=4
- cmd: SET BUILD_ONLY=true
- cmd: npm ci --build-from-source
- cmd: if %PLATFORM% EQU "x86" (SET TP="ia32") else (set TP="x64")
- cmd: if %PLATFORM% EQU "x86" (SET TP=ia32) else (set TP=x64)
- cmd: npx prebuild --strip -r electron --all --arch %TP% -u %UTO%
- cmd: npx prebuild --strip -r node-webkit --all --arch %TP% -u %UTO%
- cmd: npx prebuild --strip --all --arch %TP% -u %UTO%
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@thiagoelg/node-printer",
"description": "Node.js printer bindings",
"version": "0.5.1",
"version": "0.5.2",
"homepage": "https://github.com/thiagoelg/node-printer",
"author": {
"name": "Ion Lupascu",
Expand Down
54 changes: 27 additions & 27 deletions src/node_printer_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ namespace
{
MY_NODE_MODULE_ISOLATE_DECL
//Common fields
result_printer_job->Set(V8_STRING_NEW_UTF8("id"), V8_VALUE_NEW(Number, job->id));
result_printer_job->Set(V8_STRING_NEW_UTF8("name"), V8_STRING_NEW_UTF8(job->title));
result_printer_job->Set(V8_STRING_NEW_UTF8("printerName"), V8_STRING_NEW_UTF8(job->dest));
result_printer_job->Set(V8_STRING_NEW_UTF8("user"), V8_STRING_NEW_UTF8(job->user));
Nan::Set(result_printer_job, V8_STRING_NEW_UTF8("id"), V8_VALUE_NEW(Number, job->id));
Nan::Set(result_printer_job, V8_STRING_NEW_UTF8("name"), V8_STRING_NEW_UTF8(job->title));
Nan::Set(result_printer_job, V8_STRING_NEW_UTF8("printerName"), V8_STRING_NEW_UTF8(job->dest));
Nan::Set(result_printer_job, V8_STRING_NEW_UTF8("user"), V8_STRING_NEW_UTF8(job->user));
std::string job_format(job->format);

// Try to parse the data format, otherwise will write the unformatted one
Expand All @@ -89,16 +89,16 @@ namespace
}
}

result_printer_job->Set(V8_STRING_NEW_UTF8("format"), V8_STRING_NEW_UTF8(job_format.c_str()));
result_printer_job->Set(V8_STRING_NEW_UTF8("priority"), V8_VALUE_NEW(Number, job->priority));
result_printer_job->Set(V8_STRING_NEW_UTF8("size"), V8_VALUE_NEW(Number, job->size));
Nan::Set(result_printer_job, V8_STRING_NEW_UTF8("format"), V8_STRING_NEW_UTF8(job_format.c_str()));
Nan::Set(result_printer_job, V8_STRING_NEW_UTF8("priority"), V8_VALUE_NEW(Number, job->priority));
Nan::Set(result_printer_job, V8_STRING_NEW_UTF8("size"), V8_VALUE_NEW(Number, job->size));
v8::Local<v8::Array> result_printer_job_status = V8_VALUE_NEW_DEFAULT(Array);
int i_status = 0;
for(StatusMapType::const_iterator itStatus = getJobStatusMap().begin(); itStatus != getJobStatusMap().end(); ++itStatus)
{
if(job->state == itStatus->second)
{
result_printer_job_status->Set(i_status++, V8_STRING_NEW_UTF8(itStatus->first.c_str()));
Nan::Set(result_printer_job_status, i_status++, V8_STRING_NEW_UTF8(itStatus->first.c_str()));
// only one status could be on posix
break;
}
Expand All @@ -108,10 +108,10 @@ namespace
// A new status? report as unsupported
std::ostringstream s;
s << "unsupported job status: " << job->state;
result_printer_job_status->Set(i_status++, V8_STRING_NEW_UTF8(s.str().c_str()));
Nan::Set(result_printer_job_status, i_status++, V8_STRING_NEW_UTF8(s.str().c_str()));
}

result_printer_job->Set(V8_STRING_NEW_UTF8("status"), result_printer_job_status);
Nan::Set(result_printer_job, V8_STRING_NEW_UTF8("status"), result_printer_job_status);

//Specific fields
// Ecmascript store time in milliseconds, but time_t in seconds
Expand All @@ -120,9 +120,9 @@ namespace
double completedTime = ((double)job->completed_time) * 1000;
double processingTime = ((double)job->processing_time) * 1000;

result_printer_job->Set(V8_STRING_NEW_UTF8("completedTime"), Nan::New<v8::Date>(completedTime).ToLocalChecked());
result_printer_job->Set(V8_STRING_NEW_UTF8("creationTime"), Nan::New<v8::Date>(creationTime).ToLocalChecked());
result_printer_job->Set(V8_STRING_NEW_UTF8("processingTime"), Nan::New<v8::Date>(processingTime).ToLocalChecked());
Nan::Set(result_printer_job, V8_STRING_NEW_UTF8("completedTime"), Nan::New<v8::Date>(completedTime).ToLocalChecked());
Nan::Set(result_printer_job, V8_STRING_NEW_UTF8("creationTime"), Nan::New<v8::Date>(creationTime).ToLocalChecked());
Nan::Set(result_printer_job, V8_STRING_NEW_UTF8("processingTime"), Nan::New<v8::Date>(processingTime).ToLocalChecked());

// No error. return an empty string
return "";
Expand All @@ -145,10 +145,10 @@ namespace
j > 0;
--j, ++choice)
{
ppd_suboptions->Set(V8_STRING_NEW_UTF8(choice->choice), V8_VALUE_NEW(Boolean, static_cast<bool>(choice->marked)));
Nan::Set(ppd_suboptions, V8_STRING_NEW_UTF8(choice->choice), V8_VALUE_NEW(Boolean, static_cast<bool>(choice->marked)));
}

ppd_options->Set(V8_STRING_NEW_UTF8(option->keyword), ppd_suboptions);
Nan::Set(ppd_options, V8_STRING_NEW_UTF8(option->keyword), ppd_suboptions);
}

for (i = group->num_subgroups, subgroup = group->subgroups; i > 0; --i, ++subgroup) {
Expand Down Expand Up @@ -202,21 +202,21 @@ namespace
std::string parsePrinterInfo(const cups_dest_t * printer, v8::Local<v8::Object> result_printer)
{
MY_NODE_MODULE_ISOLATE_DECL
result_printer->Set(V8_STRING_NEW_UTF8("name"), V8_STRING_NEW_UTF8(printer->name));
result_printer->Set(V8_STRING_NEW_UTF8("isDefault"), V8_VALUE_NEW(Boolean, static_cast<bool>(printer->is_default)));
Nan::Set(result_printer, V8_STRING_NEW_UTF8("name"), V8_STRING_NEW_UTF8(printer->name));
Nan::Set(result_printer, V8_STRING_NEW_UTF8("isDefault"), V8_VALUE_NEW(Boolean, static_cast<bool>(printer->is_default)));

if(printer->instance)
{
result_printer->Set(V8_STRING_NEW_UTF8("instance"), V8_STRING_NEW_UTF8(printer->instance));
Nan::Set(result_printer, V8_STRING_NEW_UTF8("instance"), V8_STRING_NEW_UTF8(printer->instance));
}

v8::Local<v8::Object> result_printer_options = V8_VALUE_NEW_DEFAULT(Object);
cups_option_t *dest_option = printer->options;
for(int j = 0; j < printer->num_options; ++j, ++dest_option)
{
result_printer_options->Set(V8_STRING_NEW_UTF8(dest_option->name), V8_STRING_NEW_UTF8(dest_option->value));
Nan::Set(result_printer_options, V8_STRING_NEW_UTF8(dest_option->name), V8_STRING_NEW_UTF8(dest_option->value));
}
result_printer->Set(V8_STRING_NEW_UTF8("options"), result_printer_options);
Nan::Set(result_printer, V8_STRING_NEW_UTF8("options"), result_printer_options);
// Get printer jobs
cups_job_t * jobs;
int totalJobs = cupsGetJobs(&jobs, printer->name, 0 /*0 means all users*/, CUPS_WHICHJOBS_ACTIVE);
Expand All @@ -235,9 +235,9 @@ namespace
// got an error? break then.
break;
}
result_priner_jobs->Set(jobi, result_printer_job);
Nan::Set(result_priner_jobs, jobi, result_printer_job);
}
result_printer->Set(V8_STRING_NEW_UTF8("jobs"), result_priner_jobs);
Nan::Set(result_printer, V8_STRING_NEW_UTF8("jobs"), result_priner_jobs);
}
cupsFreeJobs(totalJobs, jobs);
return error_str;
Expand All @@ -264,9 +264,9 @@ namespace
v8::Local<v8::Array> props = Nan::GetPropertyNames(iV8Options).ToLocalChecked();

for(unsigned int i = 0; i < props->Length(); ++i) {
v8::Local<v8::Value> key(props->Get(i));
v8::Local<v8::Value> key(Nan::Get(props, i).ToLocalChecked());
Nan::Utf8String keyStr(V8_LOCAL_STRING_FROM_VALUE(key));
Nan::Utf8String valStr(V8_LOCAL_STRING_FROM_VALUE(iV8Options->Get(key)));
Nan::Utf8String valStr(V8_LOCAL_STRING_FROM_VALUE(Nan::Get(iV8Options, key).ToLocalChecked()));

num_options = cupsAddOption(*keyStr, *valStr, num_options, &_value);
}
Expand Down Expand Up @@ -294,7 +294,7 @@ MY_NODE_MODULE_CALLBACK(getPrinters)
// got an error? break then
break;
}
result->Set(i, result_printer);
Nan::Set(result, i, result_printer);
}
cupsFreeDests(printers_size, printers);
if(!error_str.empty())
Expand Down Expand Up @@ -432,7 +432,7 @@ MY_NODE_MODULE_CALLBACK(getSupportedJobCommands)
MY_NODE_MODULE_HANDLESCOPE;
v8::Local<v8::Array> result = V8_VALUE_NEW_DEFAULT(Array);
int i = 0;
result->Set(i++, V8_STRING_NEW_UTF8("CANCEL"));
Nan::Set(result, i++, V8_STRING_NEW_UTF8("CANCEL"));
MY_NODE_MODULE_RETURN_VALUE(result);
}

Expand All @@ -443,7 +443,7 @@ MY_NODE_MODULE_CALLBACK(getSupportedPrintFormats)
int i = 0;
for(FormatMapType::const_iterator itFormat = getPrinterFormatMap().begin(); itFormat != getPrinterFormatMap().end(); ++itFormat)
{
result->Set(i++, V8_STRING_NEW_UTF8(itFormat->first.c_str()));
Nan::Set(result, i++, V8_STRING_NEW_UTF8(itFormat->first.c_str()));
}
MY_NODE_MODULE_RETURN_VALUE(result);
}
Expand Down
Loading

0 comments on commit 66e0df7

Please sign in to comment.