-
Notifications
You must be signed in to change notification settings - Fork 1
Addition of getRegisteredSyncRoots Method to Addon and Exposure as Static Function #151
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9ce1348
Add GetRegisteredSyncRoots functionality to SyncRoot and expose it th…
ArceDanielShok ab48bd0
Refactor error messages in GetRegisteredSyncRootsWrapper for clarity …
ArceDanielShok 941cfee
Merge branch 'master' into static-addon
dajimenezriv-internxt 59939ca
Update SyncRoot identity format and enhance filtering for registered …
ArceDanielShok 7203ba9
Merge branch 'static-addon' of github.com:internxt/node-win into stat…
ArceDanielShok 50d1830
Update filtering logic in GetRegisteredSyncRoots to clarify sync root…
ArceDanielShok 5644d22
Update virtual-drive.ts
dajimenezriv-internxt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,15 @@ | |
| #include "LoggerPath.h" | ||
| #include <Logger.h> | ||
| #include <SyncRoot.h> | ||
| #include <codecvt> | ||
| #include <locale> | ||
| #include <vector> | ||
|
|
||
| std::string WStringToUTF8(const std::wstring &wstr) | ||
| { | ||
| std::wstring_convert<std::codecvt_utf8<wchar_t>> conv; | ||
| return conv.to_bytes(wstr); | ||
| } | ||
|
|
||
| napi_value CreatePlaceholderFile(napi_env env, napi_callback_info args) | ||
| { | ||
|
|
@@ -202,6 +211,71 @@ napi_value RegisterSyncRootWrapper(napi_env env, napi_callback_info args) | |
| return napiResult; | ||
| } | ||
|
|
||
| napi_value GetRegisteredSyncRootsWrapper(napi_env env, napi_callback_info args) | ||
| { | ||
| try | ||
| { | ||
| std::vector<SyncRoots> roots = SyncRoot::GetRegisteredSyncRoots(); | ||
|
|
||
| napi_value jsArray; | ||
| napi_status status = napi_create_array_with_length(env, roots.size(), &jsArray); | ||
| if (status != napi_ok) | ||
| throw std::runtime_error("Error creating the array"); | ||
|
|
||
| for (size_t i = 0; i < roots.size(); i++) | ||
| { | ||
| napi_value jsObj; | ||
| status = napi_create_object(env, &jsObj); | ||
| if (status != napi_ok) | ||
| throw std::runtime_error("Error creating the object"); | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here I assume it should be // Property "id" |
||
| std::string id = WStringToUTF8(roots[i].id); | ||
| napi_value napiId; | ||
| status = napi_create_string_utf8(env, id.c_str(), id.size(), &napiId); | ||
| if (status != napi_ok) | ||
| throw std::runtime_error("Error creating the string id"); | ||
| napi_set_named_property(env, jsObj, "id", napiId); | ||
|
|
||
| std::string path = WStringToUTF8(roots[i].path); | ||
| napi_value napiPath; | ||
| status = napi_create_string_utf8(env, path.c_str(), path.size(), &napiPath); | ||
| if (status != napi_ok) | ||
| throw std::runtime_error("Error creating the string path"); | ||
| napi_set_named_property(env, jsObj, "path", napiPath); | ||
|
|
||
| std::string displayName = WStringToUTF8(roots[i].displayName); | ||
| napi_value napiDisplayName; | ||
| status = napi_create_string_utf8(env, displayName.c_str(), displayName.size(), &napiDisplayName); | ||
| if (status != napi_ok) | ||
| throw std::runtime_error("Error creating the string displayName"); | ||
| napi_set_named_property(env, jsObj, "displayName", napiDisplayName); | ||
|
|
||
| std::string version = WStringToUTF8(roots[i].version); | ||
| napi_value napiVersion; | ||
| status = napi_create_string_utf8(env, version.c_str(), version.size(), &napiVersion); | ||
| if (status != napi_ok) | ||
| throw std::runtime_error("Error creating the string version"); | ||
| napi_set_named_property(env, jsObj, "version", napiVersion); | ||
|
|
||
| status = napi_set_element(env, jsArray, i, jsObj); | ||
| if (status != napi_ok) | ||
| throw std::runtime_error("Error setting the element in the array"); | ||
| } | ||
|
|
||
| return jsArray; | ||
| } | ||
| catch (const std::exception &ex) | ||
| { | ||
| napi_throw_error(env, nullptr, ex.what()); | ||
| return nullptr; | ||
| } | ||
| catch (...) | ||
| { | ||
| napi_throw_error(env, nullptr, "An unknown error occurred in GetRegisteredSyncRootsWrapper"); | ||
| return nullptr; | ||
| } | ||
| } | ||
|
|
||
| napi_value ConnectSyncRootWrapper(napi_env env, napi_callback_info args) | ||
| { | ||
| try | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this write well? SyncRootsRoot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmm it's true that it looks weird but all wrappers have the RootDesc at the end