Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ node_modules/
npm-debug.log

*.sublime-*
*~
*~

package-lock.json
.vscode/
42 changes: 21 additions & 21 deletions nodegsettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void get_gsetting_keys(const FunctionCallbackInfo<Value>& args) {
Local<Array> togo;
togo = Array::New(isolate, size);
for (i = 0; keys[i]; i++) {
togo->Set(i,String::NewFromOneByte(isolate, (const uint8_t*) keys[i]));
togo->Set(i, String::NewFromOneByte(isolate, (const uint8_t*) keys[i], NewStringType::kNormal).ToLocalChecked() );
}
g_strfreev(keys);
args.GetReturnValue().Set(togo);
Expand All @@ -88,7 +88,7 @@ void get_gsetting(const FunctionCallbackInfo<Value>& args) {
// validate key and schema
GSettingsSchemaSource *schema_source = g_settings_schema_source_get_default();
if ( ! schema_source ) {
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) "No schema source available!")));
isolate->ThrowException(Exception::Error( String::NewFromOneByte(isolate, (const uint8_t*) "No schema source available!", NewStringType::kNormal ).ToLocalChecked() ));
g_free((void *) schema_id);
g_free((void *) key);
args.GetReturnValue().SetUndefined();
Expand All @@ -99,15 +99,15 @@ void get_gsetting(const FunctionCallbackInfo<Value>& args) {
schema_id,
FALSE);
if ( ! schema_source ) {
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) "Schema is not installed!")));
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) "Schema is not installed!", NewStringType::kNormal ).ToLocalChecked() ));
g_free((void *) schema_id);
g_free((void *) key);
args.GetReturnValue().SetUndefined();
return;
}
gboolean has_key = g_settings_schema_has_key (gsettings_schema, key);
if ( ! has_key ) {
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) "Key does not exist!")));
isolate->ThrowException(Exception::Error( String::NewFromOneByte(isolate, (const uint8_t*) "Key does not exist!", NewStringType::kNormal ).ToLocalChecked() ));
g_free((void *) schema_id);
g_free((void *) key);
args.GetReturnValue().SetUndefined();
Expand Down Expand Up @@ -198,7 +198,7 @@ void get_gsetting(const FunctionCallbackInfo<Value>& args) {
return;
}
else {
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) "Need to implement reading that value type")));
isolate->ThrowException(Exception::Error( String::NewFromOneByte(isolate, (const uint8_t*) "Need to implement reading that value type", NewStringType::kNormal ).ToLocalChecked() ));
args.GetReturnValue().SetUndefined();
return;
}
Expand All @@ -212,7 +212,7 @@ void schema_exists(const FunctionCallbackInfo<Value>& args) {

if ( ! schema_source ) {
g_free(schema_id);
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) "No schema sources available!")));
isolate->ThrowException(Exception::Error( String::NewFromOneByte(isolate, (const uint8_t*) "No schema sources available!", NewStringType::kNormal ).ToLocalChecked() ));
args.GetReturnValue().SetUndefined();
return;
}
Expand Down Expand Up @@ -253,7 +253,7 @@ void set_gsetting(const FunctionCallbackInfo<Value>& args) {
if ( ! schema_source ) {
g_free((void *) schema_id);
g_free((void *) key);
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) "No schema source available!")));
isolate->ThrowException(Exception::Error( String::NewFromOneByte(isolate, (const uint8_t*) "No schema source available!", NewStringType::kNormal).ToLocalChecked() ));
args.GetReturnValue().SetUndefined();
return;
}
Expand All @@ -264,15 +264,15 @@ void set_gsetting(const FunctionCallbackInfo<Value>& args) {
if ( ! schema_source ) {
g_free((void *) schema_id);
g_free((void *) key);
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) "Schema is not installed!")));
isolate->ThrowException(Exception::Error( String::NewFromOneByte(isolate, (const uint8_t*) "Schema is not installed!", NewStringType::kNormal).ToLocalChecked() ));
args.GetReturnValue().SetUndefined();
return;
}
gboolean has_key = g_settings_schema_has_key (gsettings_schema, key);
if ( ! has_key ) {
g_free((void *) schema_id);
g_free((void *) key);
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) "Key does not exist!")));
isolate->ThrowException(Exception::Error( String::NewFromOneByte(isolate, (const uint8_t*) "Key does not exist!", NewStringType::kNormal).ToLocalChecked() ));
args.GetReturnValue().SetUndefined();
return;
}
Expand Down Expand Up @@ -307,23 +307,23 @@ void set_gsetting(const FunctionCallbackInfo<Value>& args) {
else if ( g_variant_type_equal(type, G_VARIANT_TYPE_DOUBLE) ) {
if ( value_obj->IsNumber() ) {
validation_success = true;
variant_to_set = g_variant_new_double(value_obj->ToNumber()->Value());
variant_to_set = g_variant_new_double(value_obj->ToNumber(isolate)->Value());
} else {
validation_fail_message = "Key requires a number!";
}
}
else if ( g_variant_type_equal(type, G_VARIANT_TYPE_INT32) ) {
if ( value_obj->IsInt32() ) {
validation_success = true;
variant_to_set = g_variant_new_int32 (value_obj->ToInt32()->Value());
variant_to_set = g_variant_new_int32 (value_obj->ToInt32(isolate)->Value());
} else {
validation_fail_message = "Key requires a integer number!";
}
}
else if ( g_variant_type_equal(type, G_VARIANT_TYPE_UINT32) ) {
if ( value_obj->IsUint32() ) {
validation_success = true;
variant_to_set = g_variant_new_uint32(value_obj->ToUint32()->Value());
variant_to_set = g_variant_new_uint32( value_obj->ToUint32( isolate->GetCurrentContext() ).ToLocalChecked()->Value() );
} else {
validation_fail_message = "Key requires a unsigned integer number!";
}
Expand All @@ -337,7 +337,7 @@ void set_gsetting(const FunctionCallbackInfo<Value>& args) {
Local<Object> obj = value_obj->ToObject();

// get the array length
length = obj->Get(String::NewFromOneByte(isolate, (const uint8_t*) "length"))->ToObject()->Uint32Value();
length = obj->Get(String::NewFromOneByte(isolate, (const uint8_t*) "length", NewStringType::kNormal).ToLocalChecked())->ToObject()->Uint32Value();

g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY);

Expand All @@ -354,7 +354,7 @@ void set_gsetting(const FunctionCallbackInfo<Value>& args) {
}
else {
g_free((void *) key);
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) "Array item have to be strings!")));
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) "Array item have to be strings!", NewStringType::kNormal).ToLocalChecked()));
args.GetReturnValue().SetUndefined();
return;
}
Expand All @@ -371,7 +371,7 @@ void set_gsetting(const FunctionCallbackInfo<Value>& args) {

if ( ! validation_success ) {
g_free((void *) key);
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) validation_fail_message)));
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) validation_fail_message, NewStringType::kNormal).ToLocalChecked()));
args.GetReturnValue().SetUndefined();
return;
}
Expand All @@ -381,7 +381,7 @@ void set_gsetting(const FunctionCallbackInfo<Value>& args) {

if ( ! is_valid ) {
g_free((void *) key);
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) "Invalid range or type!")));
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) "Invalid range or type!", NewStringType::kNormal).ToLocalChecked()));
args.GetReturnValue().SetUndefined();
return;
}
Expand All @@ -393,7 +393,7 @@ void set_gsetting(const FunctionCallbackInfo<Value>& args) {
g_free((void *) key);

if ( ! write_success ) {
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) "Failed to set gsetting! Key is write protected.")));
isolate->ThrowException(Exception::Error(String::NewFromOneByte(isolate, (const uint8_t*) "Failed to set gsetting! Key is write protected.", NewStringType::kNormal).ToLocalChecked()));
}

args.GetReturnValue().SetUndefined();
Expand All @@ -404,13 +404,13 @@ void set_gsetting(const FunctionCallbackInfo<Value>& args) {
void init(Local<Object> target) {
Isolate *isolate = target->GetIsolate();

target->Set(String::NewFromOneByte(isolate, (const uint8_t*) "set_gsetting"),
target->Set(String::NewFromOneByte(isolate, (const uint8_t*) "set_gsetting", NewStringType::kNormal).ToLocalChecked(),
FunctionTemplate::New(isolate, set_gsetting)->GetFunction());
target->Set(String::NewFromOneByte(isolate, (const uint8_t*) "get_gsetting"),
target->Set(String::NewFromOneByte(isolate, (const uint8_t*) "get_gsetting", NewStringType::kNormal).ToLocalChecked(),
FunctionTemplate::New(isolate, get_gsetting)->GetFunction());
target->Set(String::NewFromOneByte(isolate, (const uint8_t*) "get_gsetting_keys"),
target->Set(String::NewFromOneByte(isolate, (const uint8_t*) "get_gsetting_keys", NewStringType::kNormal).ToLocalChecked(),
FunctionTemplate::New(isolate, get_gsetting_keys)->GetFunction());
target->Set(String::NewFromOneByte(isolate, (const uint8_t*) "schema_exists"),
target->Set(String::NewFromOneByte(isolate, (const uint8_t*) "schema_exists", NewStringType::kNormal).ToLocalChecked(),
FunctionTemplate::New(isolate, schema_exists)->GetFunction());
}

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "node-gsettings",
"description": "Node binding to gsettings dconf tool",
"version": "0.1.9",
"version": "0.1.10",
"author": "Leopold Burdyl",
"scripts": {
"test": "node tests/test.js"
Expand All @@ -28,9 +28,10 @@
"repository": "https://github.com/vilnius-leopold/node-gsettings.git",
"main": "index.js",
"engines": {
"node": ">=0.1.9"
"node": ">=10.0"
},
"devDependencies": {
"truncate": "^1.0.4"
"truncate": "^1.0.4",
"eslint": "^5.13.0"
}
}