Skip to content

A native macOS / windows / Linux database IDE built with Swift and AppKit. Connect to PostgreSQL, MySQL, SQLite, and Redis from a single app with a fast, keyboard-driven interface.

C++

feat(import): port connection import from macOS (DBeaver / DataGrip / Navicat + TablePlus stub)

DangHuynh4c479924f095
diff --git a/windows/Gridex/Gridex.items.props b/windows/Gridex/Gridex.items.props
index 8d28af1..7fa53bd 100644
--- a/windows/Gridex/Gridex.items.props
+++ b/windows/Gridex/Gridex.items.props
@@ -65,6 +65,12 @@
<ClInclude Include="$(MSBuildThisFileDirectory)Services\MCP\Tools\Tier3\ExecuteWriteQueryTool.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Services\MCP\MCPServerHost.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Services\TrayIconService.h" />
+ <!-- Connection importers — TablePlus / DBeaver / DataGrip / Navicat. -->
+ <ClInclude Include="$(MSBuildThisFileDirectory)Models\Import\ImportedConnection.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)Services\Import\DBeaverImporter.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)Services\Import\DataGripImporter.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)Services\Import\NavicatImporter.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)Services\Import\TablePlusImporter.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Models\DatabaseAdapter.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Models\ConnectionManager.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Models\PostgreSQLAdapter.h" />
@@ -397,6 +403,18 @@
<ClCompile Include="$(MSBuildThisFileDirectory)Services\TrayIconService.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
+ <ClCompile Include="$(MSBuildThisFileDirectory)Services\Import\DBeaverImporter.cpp">
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ </ClCompile>
+ <ClCompile Include="$(MSBuildThisFileDirectory)Services\Import\DataGripImporter.cpp">
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ </ClCompile>
+ <ClCompile Include="$(MSBuildThisFileDirectory)Services\Import\NavicatImporter.cpp">
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ </ClCompile>
+ <ClCompile Include="$(MSBuildThisFileDirectory)Services\Import\TablePlusImporter.cpp">
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ </ClCompile>
<!-- MCP Phase 6 UI — WinUI 3 Page with 5 tabs. -->
<ClCompile Include="$(MSBuildThisFileDirectory)MCPPage.cpp">
<DependentUpon>MCPPage.xaml</DependentUpon>
diff --git a/windows/Gridex/HomePage.cpp b/windows/Gridex/HomePage.cpp
index 1ba1a67..4ef5fca 100644
--- a/windows/Gridex/HomePage.cpp
+++ b/windows/Gridex/HomePage.cpp
@@ -17,6 +17,12 @@
#include "App.xaml.h"
#include "Models/ConnectionStore.h"
#include "Models/ConnectionManager.h"
+#include "Services/Import/DBeaverImporter.h"
+#include "Services/Import/DataGripImporter.h"
+#include "Services/Import/NavicatImporter.h"
+#include "Services/Import/TablePlusImporter.h"
+#include <winrt/Microsoft.Windows.Storage.Pickers.h>
+#include <random>
namespace winrt::Gridex::implementation
{
@@ -556,4 +562,238 @@ namespace winrt::Gridex::implementation
{
RefreshList(std::wstring(sender.Text()));
}
+
+ // ── Import Connections wizard ──────────────────────────────
+ // Builds a ContentDialog with a source switcher + list of
+ // ImportedConnections with per-row CheckBoxes. Import button
+ // writes selected rows into ConnectionStore and refreshes the
+ // sidebar list. Navicat branches through an .ncx file picker.
+
+ namespace
+ {
+ std::wstring newConnectionId()
+ {
+ std::random_device rd;
+ std::mt19937_64 gen(rd());
+ std::uniform_int_distribution<uint64_t> dist;
+ wchar_t buf[32];
+ swprintf_s(buf, 32, L"%016llx%016llx",
+ (unsigned long long)dist(gen), (unsigned long long)dist(gen));
+ return buf;
+ }
+
+ // Shared builder for a single importer-result row. The
+ // CheckBox instance is stored in `row.first` so the Import
+ // button can poll IsChecked when the user clicks confirm.
+ std::pair<muxc::CheckBox, winrt::Microsoft::UI::Xaml::Controls::Border>
+ buildImportedRow(const DBModels::ImportedConnection& c)
+ {
+ using namespace winrt::Microsoft::UI::Xaml;
+ using namespace winrt::Microsoft::UI::Xaml::Controls;
+
+ muxc::Grid row;
+ row.Padding(Thickness{ 8, 6, 8, 6 });
+ row.ColumnSpacing(10);
+
+ ColumnDefinition c0, c1, c2;
+ c0.Width(GridLengthHelper::FromPixels(36));
+ c1.Width(GridLengthHelper::FromValueAndType(1, GridUnitType::Star));
+ c2.Width(GridLengthHelper::FromPixels(90));
+ row.ColumnDefinitions().Append(c0);
+ row.ColumnDefinitions().Append(c1);
+ row.ColumnDefinitions().Append(c2);
+
+ muxc::CheckBox chk; chk.IsChecked(true);
+ muxc::Grid::SetColumn(chk, 0); row.Children().Append(chk);
+
+ muxc::StackPanel sp; sp.Spacing(2);
+ muxc::TextBlock name; name.Text(winrt::hstring(c.name));
+ name.FontSize(13); name.FontWeight(Windows::UI::Text::FontWeights::SemiBold());
+ sp.Children().Append(name);
+ std::wstring sub = !c.host.empty()
+ ? c.host + (c.port.has_value() ? L":" + std::to_wstring(*c.port) : L"")
+ : c.filePath;
+ if (!c.database.empty()) sub += L" / " + c.database;
+ if (sub.empty()) sub = L"(no host)";
+ muxc::TextBlock subt; subt.Text(winrt::hstring(sub));
+ subt.FontSize(11);
+ subt.Foreground(winrt::Microsoft::UI::Xaml::Media::SolidColorBrush(
+ winrt::Windows::UI::ColorHelper::FromArgb(255, 150, 150, 150)));
+ sp.Children().Append(subt);
+ muxc::Grid::SetColumn(sp, 1); row.Children().Append(sp);
+
+ muxc::TextBlock type; type.Text(winrt::hstring(
+ DBModels::DatabaseTypeDisplayName(c.databaseType)));
+ type.FontSize(11); type.VerticalAlignment(VerticalAlignment::Center);
+ type.Foreground(winrt::Microsoft::UI::Xaml::Media::SolidColorBrush(
+ winrt::Windows::UI::ColorHelper::FromArgb(255, 150, 150, 150)));
+ muxc::Grid::SetColumn(type, 2); row.Children().Append(type);
+
+ muxc::Border wrap;
+ wrap.Child(row);
+ wrap.BorderBrush(winrt::Microsoft::UI::Xaml::Media::SolidColorBrush(
+ winrt::Windows::UI::ColorHelper::FromArgb(30, 128, 128, 128)));
+ wrap.BorderThickness(Thickness{ 0, 0, 0, 1 });
+ return { chk, wrap };
+ }
+ }
+
+ winrt::fire_and_forget HomePage::ImportConnections_Click(
+ winrt::Windows::Foundation::IInspectable const&,
+ mux::RoutedEventArgs const&)
+ {
+ auto self = get_strong();
+
+ // Dialog chrome + source-picker ComboBox + rows container.
+ muxc::ContentDialog dlg;
+ dlg.Title(winrt::box_value(winrt::hstring(L"Import Connections")));
+ dlg.PrimaryButtonText(L"Import Selected");
+ dlg.CloseButtonText(L"Cancel");
+ dlg.DefaultButton(muxc::ContentDialogButton::Primary);
+ dlg.XamlRoot(this->XamlRoot());
+ dlg.Resources().Insert(winrt::box_value(L"ContentDialogMaxWidth"), winrt::box_value(720.0));
+
+ muxc::StackPanel content; content.Spacing(10); content.MinWidth(520);
+
+ muxc::TextBlock intro;
+ intro.Text(L"Pick a source, review detected connections, then Import.");
+ intro.FontSize(12);
+ intro.Foreground(winrt::Microsoft::UI::Xaml::Media::SolidColorBrush(
+ winrt::Windows::UI::ColorHelper::FromArgb(255, 150, 150, 150)));
+ content.Children().Append(intro);
+
+ muxc::ComboBox sourceCombo; sourceCombo.MinWidth(240);
+ auto addSource = [&](const wchar_t* label, bool installed)
+ {
+ muxc::ComboBoxItem item;
+ item.Content(winrt::box_value(winrt::hstring(
+ installed ? label : std::wstring(label) + L" (not detected)")));
+ sourceCombo.Items().Append(item);
+ };
+ addSource(L"DBeaver", DBModels::DBeaverImporter::isInstalled());
+ addSource(L"DataGrip", DBModels::DataGripImporter::isInstalled());
+ addSource(L"Navicat (pick .ncx)", true);
+ addSource(L"TablePlus", DBModels::TablePlusImporter::isInstalled());
+ sourceCombo.SelectedIndex(0);
+ content.Children().Append(sourceCombo);
+
+ muxc::TextBlock status; status.FontSize(11);
+ status.Foreground(winrt::Microsoft::UI::Xaml::Media::SolidColorBrush(
+ winrt::Windows::UI::ColorHelper::FromArgb(255, 180, 180, 180)));
+ content.Children().Append(status);
+
+ muxc::ScrollViewer sv;
+ sv.HorizontalScrollMode(muxc::ScrollMode::Disabled);
+ sv.VerticalScrollBarVisibility(muxc::ScrollBarVisibility::Auto);
+ sv.MaxHeight(360);
+ muxc::StackPanel rows; rows.Spacing(0);
+ sv.Content(rows);
+ content.Children().Append(sv);
+
+ dlg.Content(content);
+
+ // Holder for imported rows currently displayed (parallel
+ // with CheckBox widgets so we can zip on confirm).
+ auto imported = std::make_shared<std::vector<DBModels::ImportedConnection>>();
+ auto checks = std::make_shared<std::vector<muxc::CheckBox>>();
+
+ auto loadSource = [self, imported, checks, &rows, &status, this](int idx) -> winrt::fire_and_forget
+ {
+ imported->clear();
+ checks->clear();
+ rows.Children().Clear();
+ status.Text(L"Scanning...");
+
+ try
+ {
+ if (idx == 0) *imported = DBModels::DBeaverImporter::importConnections();
+ else if (idx == 1) *imported = DBModels::DataGripImporter::importConnections();
+ else if (idx == 2)
+ {
+ // Open file picker for .ncx file.
+ using namespace winrt::Microsoft::Windows::Storage::Pickers;
+ winrt::Microsoft::UI::WindowId windowId{
+ reinterpret_cast<uint64_t>(
+ winrt::Gridex::implementation::App::MainHwnd) };
+ FileOpenPicker picker(windowId);
+ picker.FileTypeFilter().Append(L".ncx");
+ picker.FileTypeFilter().Append(L".xml");
+ auto result = co_await picker.PickSingleFileAsync();
+ if (result.Path().empty()) { status.Text(L"Cancelled."); co_return; }
+ *imported = DBModels::NavicatImporter::importFromNCX(std::wstring(result.Path()));
+ }
+ else if (idx == 3)
+ {
+ *imported = DBModels::TablePlusImporter::importConnections();
+ if (imported->empty())
+ {
+ status.Text(winrt::hstring(DBModels::TablePlusImporter::windowsSupportNote()));
+ co_return;
+ }
+ }
+ }
+ catch (const std::exception& e)
+ {
+ std::string msg = e.what();
+ status.Text(winrt::hstring(L"Error: " +
+ std::wstring(msg.begin(), msg.end())));
+ co_return;
+ }
+
+ if (imported->empty())
+ {
+ status.Text(L"No connections detected.");
+ co_return;
+ }
+ status.Text(winrt::hstring(
+ std::to_wstring(imported->size()) + L" connection(s) detected. Untick any you want to skip."));
+ for (const auto& c : *imported)
+ {
+ auto [chk, wrap] = buildImportedRow(c);
+ checks->push_back(chk);
+ rows.Children().Append(wrap);
+ }
+ };
+
+ sourceCombo.SelectionChanged(
+ [loadSource](auto&& s, auto&&) mutable
+ {
+ if (auto cb = s.try_as<muxc::ComboBox>())
+ loadSource(cb.SelectedIndex());
+ });
+ loadSource(0);
+
+ // Show dialog + on Import merge into ConnectionStore.
+ auto op = dlg.ShowAsync();
+ auto result = co_await op;
+ if (result != muxc::ContentDialogResult::Primary) co_return;
+
+ int added = 0;
+ for (size_t i = 0; i < imported->size() && i < checks->size(); ++i)
+ {
+ auto chkBox = (*checks)[i];
+ auto ib = chkBox.IsChecked();
+ if (!ib || !ib.Value()) continue;
+
+ auto cfg = (*imported)[i].toConnectionConfig();
+ if (cfg.id.empty()) cfg.id = newConnectionId();
+ DBModels::ConnectionStore::Save(cfg);
+ ++added;
+ }
+
+ RefreshList();
+
+ // Brief result toast via another mini-dialog (mac uses
+ // NSAlert; ContentDialog is closest native match).
+ muxc::ContentDialog done;
+ done.Title(winrt::box_value(winrt::hstring(L"Import Complete")));
+ done.Content(winrt::box_value(winrt::hstring(
+ L"Imported " + std::to_wstring(added) + L" connection(s). Passwords "
+ L"may need to be re-entered for some sources (DataGrip, Navicat) "
+ L"because the original tools keep them in their own credential "
+ L"store.")));
+ done.CloseButtonText(L"OK");
+ done.XamlRoot(this->XamlRoot());
+ done.ShowAsync();
+ }
}
diff --git a/windows/Gridex/HomePage.h b/windows/Gridex/HomePage.h
index 072b6f8..286394a 100644
--- a/windows/Gridex/HomePage.h
+++ b/windows/Gridex/HomePage.h
@@ -23,6 +23,13 @@ namespace winrt::Gridex::implementation
void OpenMcp_Click(
winrt::Windows::Foundation::IInspectable const& sender,
winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
+
+ // Opens the import wizard for TablePlus / DBeaver /
+ // DataGrip / Navicat connections. See ImportConnections.cpp
+ // for the dialog build-up; too much UI code to keep inline.
+ winrt::fire_and_forget ImportConnections_Click(
+ winrt::Windows::Foundation::IInspectable const& sender,
+ winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
void ConnectionItem_Click(
winrt::Windows::Foundation::IInspectable const& sender,
winrt::Microsoft::UI::Xaml::Controls::ItemClickEventArgs const& e);
diff --git a/windows/Gridex/HomePage.xaml b/windows/Gridex/HomePage.xaml
index 59b67de..2036052 100644
--- a/windows/Gridex/HomePage.xaml
+++ b/windows/Gridex/HomePage.xaml
@@ -65,6 +65,20 @@
Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
</StackPanel>
</Button>
+ <Button HorizontalAlignment="Stretch"
+ HorizontalContentAlignment="Left"
+ Padding="8,8"
+ Background="Transparent"
+ BorderThickness="0"
+ Click="ImportConnections_Click"
+ ToolTipService.ToolTip="Import connections from TablePlus / DBeaver / DataGrip / Navicat">
+ <StackPanel Orientation="Horizontal" Spacing="10">
+ <FontIcon Glyph="&#xE8B5;" FontSize="14"
+ Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
+ <TextBlock Text="Import Connections"
+ Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
+ </StackPanel>
+ </Button>
<Button HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left"
Padding="8,8"
diff --git a/windows/Gridex/Models/Import/ImportedConnection.h b/windows/Gridex/Models/Import/ImportedConnection.h
new file mode 100644
index 0000000..9d5a6a9
--- /dev/null
+++ b/windows/Gridex/Models/Import/ImportedConnection.h
@@ -0,0 +1,103 @@
+#pragma once
+//
+// ImportedConnection.h
+// Gridex
+//
+// Shared data model for connections read from external GUI tools
+// (TablePlus, DBeaver, DataGrip, Navicat). Kept separate from
+// ConnectionConfig so the pre-import preview list doesn't pollute
+// the active store — user ticks rows in the wizard, then we
+// convert to ConnectionConfig on Import.
+//
+// Mirrors macos/Services/Import/ImportedConnection.swift 1:1; same
+// field names so cross-platform UI code can read either.
+
+#include <string>
+#include <optional>
+#include <vector>
+#include <cstdint>
+#include "../ConnectionConfig.h"
+
+namespace DBModels
+{
+ enum class ImportSource
+ {
+ TablePlus,
+ DBeaver,
+ DataGrip,
+ Navicat
+ };
+
+ inline std::wstring ImportSourceDisplayName(ImportSource s)
+ {
+ switch (s)
+ {
+ case ImportSource::TablePlus: return L"TablePlus";
+ case ImportSource::DBeaver: return L"DBeaver";
+ case ImportSource::DataGrip: return L"DataGrip";
+ case ImportSource::Navicat: return L"Navicat";
+ }
+ return L"Unknown";
+ }
+
+ inline std::wstring ImportSourceBadge(ImportSource s)
+ {
+ switch (s)
+ {
+ case ImportSource::TablePlus: return L"T+";
+ case ImportSource::DBeaver: return L"DB";
+ case ImportSource::DataGrip: return L"DG";
+ case ImportSource::Navicat: return L"N";
+ }
+ return L"?";
+ }
+
+ struct ImportedConnection
+ {
+ std::wstring id;
+ ImportSource source = ImportSource::DBeaver;
+ std::wstring name;
+ DatabaseType databaseType = DatabaseType::PostgreSQL;
+ std::wstring host;
+ std::optional<uint16_t> port;
+ std::wstring database;
+ std::wstring username;
+ std::wstring password; // may be empty when tool hides it
+ bool sslEnabled = false;
+ std::wstring filePath; // SQLite
+ std::wstring sshHost;
+ std::optional<uint16_t> sshPort;
+ std::wstring sshUser;
+ std::wstring group; // optional folder/group name
+
+ // Convert to ConnectionConfig ready to Save() into
+ // ConnectionStore. Caller should generate a fresh id if
+ // merging into an already-populated store (mac uses UUID —
+ // Windows ConnectionStore keys on wstring id).
+ ConnectionConfig toConnectionConfig() const
+ {
+ ConnectionConfig c;
+ c.id = id;
+ c.name = name;
+ c.databaseType = databaseType;
+ c.host = host;
+ c.port = port.value_or(DatabaseTypeDefaultPort(databaseType));
+ c.database = database;
+ c.username = username;
+ c.password = password;
+ c.sslEnabled = sslEnabled;
+ c.filePath = filePath;
+ c.group = group;
+ if (!sshHost.empty() && !sshUser.empty())
+ {
+ SSHTunnelConfig ssh;
+ ssh.host = sshHost;
+ ssh.port = sshPort.value_or(22);
+ ssh.username = sshUser;
+ ssh.authMethod = SSHAuthMethod::Password;
+ c.sshConfig = ssh;
+ }
+ return c;
+ }
+ };
+}
diff --git a/windows/Gridex/Services/Import/DBeaverImporter.cpp b/windows/Gridex/Services/Import/DBeaverImporter.cpp
new file mode 100644
index 0000000..ebb45fb
--- /dev/null
+++ b/windows/Gridex/Services/Import/DBeaverImporter.cpp
@@ -0,0 +1,256 @@
+//
+// DBeaverImporter.cpp
+//
+
+#include "DBeaverImporter.h"
+
+#include <windows.h>
+#include <shlobj.h>
+#include <fstream>
+#include <string>
+#include <unordered_map>
+#include <nlohmann/json.hpp>
+
+namespace DBModels { namespace DBeaverImporter {
+
+namespace {
+ std::wstring appDataDir()
+ {
+ wchar_t* p = nullptr;
+ if (SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, nullptr, &p) != S_OK)
+ return {};
+ std::wstring out(p);
+ CoTaskMemFree(p);
+ return out;
+ }
+
+ std::wstring dataSourcesPath()
+ {
+ auto r = appDataDir();
+ if (r.empty()) return {};
+ return r + L"\\DBeaverData\\workspace6\\General\\.dbeaver\\data-sources.json";
+ }
+ std::wstring credentialsPath()
+ {
+ auto r = appDataDir();
+ if (r.empty()) return {};
+ return r + L"\\DBeaverData\\workspace6\\General\\.dbeaver\\credentials-config.json";
+ }
+
+ std::wstring fromUtf8(const std::string& s)
+ {
+ if (s.empty()) return {};
+ int sz = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), (int)s.size(), nullptr, 0);
+ std::wstring out(sz, L'\0');
+ MultiByteToWideChar(CP_UTF8, 0, s.c_str(), (int)s.size(), &out[0], sz);
+ return out;
+ }
+
+ DatabaseType mapProvider(const std::string& p)
+ {
+ std::string lower; lower.reserve(p.size());
+ for (char c : p) lower.push_back(static_cast<char>(std::tolower((unsigned char)c)));
+ if (lower.find("postgres") != std::string::npos) return DatabaseType::PostgreSQL;
+ if (lower.find("mysql") != std::string::npos || lower.find("maria") != std::string::npos)
+ return DatabaseType::MySQL;
+ if (lower.find("sqlite") != std::string::npos) return DatabaseType::SQLite;
+ if (lower.find("redis") != std::string::npos) return DatabaseType::Redis;
+ if (lower.find("mongo") != std::string::npos) return DatabaseType::MongoDB;
+ if (lower.find("sqlserver") != std::string::npos || lower.find("mssql") != std::string::npos)
+ return DatabaseType::MSSQLServer;
+ return DatabaseType::PostgreSQL;
+ }
+
+ // Base64 decode (stateless, std-only). Accepts the single-line
+ // form DBeaver emits; newlines/whitespace ignored.
+ std::vector<uint8_t> base64Decode(const std::string& s)
+ {
+ int map[256];
+ for (int i = 0; i < 256; ++i) map[i] = -1;
+ const char* cs = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ for (int i = 0; i < 64; ++i) map[(unsigned char)cs[i]] = i;
+
+ std::vector<uint8_t> out;
+ uint32_t buf = 0; int bits = 0;
+ for (unsigned char c : s)
+ {
+ if (c == '=' || c == '\n' || c == '\r' || c == ' ' || c == '\t') continue;
+ int v = map[c];
+ if (v < 0) continue;
+ buf = (buf << 6) | v;
+ bits += 6;
+ if (bits >= 8) { bits -= 8; out.push_back(static_cast<uint8_t>((buf >> bits) & 0xFF)); }
+ }
+ return out;
+ }
+
+ // DBeaver ships a fixed 8-byte XOR key for its credentials file.
+ // Constant is reverse-engineered from the upstream Java source.
+ std::string xorDecrypt(const std::vector<uint8_t>& cipher)
+ {
+ static const uint8_t K[8] = { 0xBA, 0xBB, 0x4A, 0x9F, 0x7A, 0xEE, 0x8F, 0xC1 };
+ std::string out(cipher.size(), '\0');
+ for (size_t i = 0; i < cipher.size(); ++i)
+ out[i] = static_cast<char>(cipher[i] ^ K[i % 8]);
+ return out;
+ }
+
+ // key in credentials-config.json is "data-source|<connId>"; we
+ // strip the prefix so lookups match the connection UUID from
+ // data-sources.json.
+ std::unordered_map<std::string, std::pair<std::string, std::string>> loadCredentials()
+ {
+ std::unordered_map<std::string, std::pair<std::string, std::string>> out;
+ const auto path = credentialsPath();
+ if (path.empty() || GetFileAttributesW(path.c_str()) == INVALID_FILE_ATTRIBUTES)
+ return out;
+ std::ifstream in(path, std::ios::binary);
+ if (!in.is_open()) return out;
+ std::string cipher((std::istreambuf_iterator<char>(in)),
+ std::istreambuf_iterator<char>());
+ if (cipher.empty()) return out;
+ auto bytes = base64Decode(cipher);
+ auto json = xorDecrypt(bytes);
+ try
+ {
+ auto j = nlohmann::json::parse(json, nullptr, false);
+ if (j.is_discarded() || !j.is_object()) return out;
+ for (auto it = j.begin(); it != j.end(); ++it)
+ {
+ std::string key = it.key();
+ const std::string prefix = "data-source|";
+ if (key.rfind(prefix, 0) == 0) key.erase(0, prefix.size());
+ if (!it.value().is_object()) continue;
+ const auto& v = it.value();
+ out[key] = {
+ v.value("user", std::string{}),
+ v.value("password", std::string{})
+ };
+ }
+ }
+ catch (...) { out.clear(); }
+ return out;
+ }
+
+ // DBeaver sometimes ships host/port/db inside a bare JDBC URL
+ // rather than discrete fields. Pull each piece with a tiny
+ // substring scanner — std::regex would work but this avoids
+ // the compile-once cost on an already-hot import path.
+ struct JdbcParts { std::string host; std::optional<int> port; std::string db; };
+ JdbcParts parseJdbcUrl(const std::string& url)
+ {
+ JdbcParts p;
+ auto colSlash = url.find("://");
+ if (colSlash == std::string::npos) return p;
+ size_t i = colSlash + 3;
+ size_t endHost = url.find_first_of(":/;?", i);
+ if (endHost == std::string::npos) endHost = url.size();
+ p.host = url.substr(i, endHost - i);
+
+ if (endHost < url.size() && url[endHost] == ':')
+ {
+ size_t j = endHost + 1;
+ std::string numStr;
+ while (j < url.size() && std::isdigit((unsigned char)url[j])) numStr += url[j++];
+ if (!numStr.empty()) { try { p.port = std::stoi(numStr); } catch (...) {} }
+ endHost = j;
+ }
+ if (endHost < url.size() && url[endHost] == '/')
+ {
+ size_t j = endHost + 1;
+ size_t endDb = url.find_first_of("?;", j);
+ if (endDb == std::string::npos) endDb = url.size();
+ p.db = url.substr(j, endDb - j);
+ }
+ return p;
+ }
+}
+
+bool isInstalled()
+{
+ const auto p = dataSourcesPath();
+ return !p.empty() && GetFileAttributesW(p.c_str()) != INVALID_FILE_ATTRIBUTES;
+}
+
+std::vector<ImportedConnection> importConnections()
+{
+ std::vector<ImportedConnection> out;
+ const auto path = dataSourcesPath();
+ if (path.empty()) return out;
+ std::ifstream in(path, std::ios::binary);
+ if (!in.is_open()) return out;
+
+ nlohmann::json root;
+ try { in >> root; } catch (...) { return out; }
+ if (!root.is_object()) return out;
+
+ const auto creds = loadCredentials();
+
+ // Top-level object groups by folder name. Each folder has a
+ // `connections` map keyed by UUID.
+ for (auto fit = root.begin(); fit != root.end(); ++fit)
+ {
+ if (!fit.value().is_object()) continue;
+ const auto& folder = fit.value();
+ if (!folder.contains("connections") || !folder["connections"].is_object()) continue;
+
+ const auto& conns = folder["connections"];
+ for (auto cit = conns.begin(); cit != conns.end(); ++cit)
+ {
+ if (!cit.value().is_object()) continue;
+ const std::string connId = cit.key();
+ const auto& c = cit.value();
+
+ std::string name = c.value("name", std::string{});
+ std::string provider = c.value("provider", std::string{});
+ if (name.empty()) continue;
+
+ const auto& conf = c.contains("configuration") && c["configuration"].is_object()
+ ? c["configuration"] : nlohmann::json::object();
+
+ std::string host = conf.value("host", std::string{});
+ std::string portStr = conf.value("port", std::string{});
+ std::string database = conf.value("database", std::string{});
+ std::string url = conf.value("url", std::string{});
+ std::string sslStr = conf.value("ssl", std::string{});
+ std::string authModel= conf.value("auth-model", std::string{});
+
+ ImportedConnection r;
+ r.id = fromUtf8(connId);
+ r.source = ImportSource::DBeaver;
+ r.name = fromUtf8(name);
+ r.databaseType = mapProvider(provider);
+ r.sslEnabled = (sslStr == "true");
+
+ if (!host.empty()) r.host = fromUtf8(host);
+ if (!portStr.empty()) { try { r.port = static_cast<uint16_t>(std::stoi(portStr)); } catch (...) {} }
+ if (!database.empty()) r.database = fromUtf8(database);
+
+ // Fallback: scrape host/port/db from the bare JDBC URL
+ // when DBeaver doesn't surface the discrete fields.
+ if ((r.host.empty() || !r.port.has_value() || r.database.empty()) && !url.empty())
+ {
+ const auto p = parseJdbcUrl(url);
+ if (r.host.empty() && !p.host.empty()) r.host = fromUtf8(p.host);
+ if (!r.port.has_value() && p.port.has_value())
+ r.port = static_cast<uint16_t>(*p.port);
+ if (r.database.empty() && !p.db.empty()) r.database = fromUtf8(p.db);
+ }
+
+ if (authModel == "native")
+ {
+ auto it = creds.find(connId);
+ if (it != creds.end())
+ {
+ r.username = fromUtf8(it->second.first);
+ r.password = fromUtf8(it->second.second);
+ }
+ }
+
+ out.push_back(std::move(r));
+ }
+ }
+ return out;
+}
+
+}} // namespace
diff --git a/windows/Gridex/Services/Import/DBeaverImporter.h b/windows/Gridex/Services/Import/DBeaverImporter.h
new file mode 100644
index 0000000..6c67dec
--- /dev/null
+++ b/windows/Gridex/Services/Import/DBeaverImporter.h
@@ -0,0 +1,20 @@
+#pragma once
+//
+// DBeaverImporter.h
+// Gridex
+//
+// Reads %APPDATA%\DBeaverData\workspace6\General\.dbeaver\
+// data-sources.json and credentials-config.json, returns the
+// connections as ImportedConnection. Mirrors mac DBeaverImporter.
+// The credentials file uses a fixed 8-byte XOR key — same key
+// across mac + Windows installs since DBeaver is Java.
+
+#include <vector>
+#include "../../Models/Import/ImportedConnection.h"
+
+namespace DBModels { namespace DBeaverImporter {
+
+bool isInstalled();
+std::vector<ImportedConnection> importConnections();
+
+}} // namespace
diff --git a/windows/Gridex/Services/Import/DataGripImporter.cpp b/windows/Gridex/Services/Import/DataGripImporter.cpp
new file mode 100644
index 0000000..ff5d3c7
--- /dev/null
+++ b/windows/Gridex/Services/Import/DataGripImporter.cpp
@@ -0,0 +1,251 @@
+//
+// DataGripImporter.cpp
+//
+// Scans %APPDATA%\JetBrains for any directory starting with
+// "DataGrip" (e.g. "DataGrip2024.3"), reads options/dataSources.xml,
+// and yields ImportedConnection rows. Hand-rolls the XML scan —
+// DataGrip's file shape is stable (top-level <data-source name=
+// uuid=>, child <driver>...</driver> + <jdbc-url>...</jdbc-url>)
+// and bringing in MSXML via COM for a few tag extractions would
+// be overkill.
+
+#include "DataGripImporter.h"
+
+#include <windows.h>
+#include <shlobj.h>
+#include <fstream>
+#include <sstream>
+#include <string>
+#include <filesystem>
+#include <algorithm>
+
+namespace fs = std::filesystem;
+
+namespace DBModels { namespace DataGripImporter {
+
+namespace {
+ std::wstring jetbrainsDir()
+ {
+ wchar_t* p = nullptr;
+ if (SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, nullptr, &p) != S_OK)
+ return {};
+ std::wstring out(p);
+ CoTaskMemFree(p);
+ return out + L"\\JetBrains";
+ }
+
+ // Pick the newest DataGrip* subdir (lexicographic sort works
+ // because JetBrains name-versions monotonically: DataGrip2023.1,
+ // DataGrip2024.2, DataGrip2025.1, ...).
+ std::optional<fs::path> newestDataGripDir()
+ {
+ const auto jb = jetbrainsDir();
+ if (jb.empty()) return std::nullopt;
+ std::error_code ec;
+ if (!fs::exists(jb, ec)) return std::nullopt;
+
+ std::vector<fs::path> hits;
+ for (auto it = fs::directory_iterator(jb, ec);
+ !ec && it != fs::directory_iterator();
+ ++it)
+ {
+ if (!it->is_directory()) continue;
+ const auto name = it->path().filename().wstring();
+ if (name.rfind(L"DataGrip", 0) == 0) hits.push_back(it->path());
+ }
+ if (hits.empty()) return std::nullopt;
+ std::sort(hits.begin(), hits.end(),
+ [](const fs::path& a, const fs::path& b) {
+ return a.filename().wstring() > b.filename().wstring();
+ });
+ return hits.front();
+ }
+
+ std::wstring fromUtf8(const std::string& s)
+ {
+ if (s.empty()) return {};
+ int sz = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), (int)s.size(), nullptr, 0);
+ std::wstring out(sz, L'\0');
+ MultiByteToWideChar(CP_UTF8, 0, s.c_str(), (int)s.size(), &out[0], sz);
+ return out;
+ }
+
+ std::string toLower(std::string s)
+ {
+ std::transform(s.begin(), s.end(), s.begin(),
+ [](unsigned char c) { return (char)std::tolower(c); });
+ return s;
+ }
+
+ DatabaseType mapDriverUrl(const std::string& driver, const std::string& url)
+ {
+ const std::string combined = toLower(driver + url);
+ if (combined.find("postgres") != std::string::npos) return DatabaseType::PostgreSQL;
+ if (combined.find("mysql") != std::string::npos || combined.find("maria") != std::string::npos)
+ return DatabaseType::MySQL;
+ if (combined.find("sqlite") != std::string::npos) return DatabaseType::SQLite;
+ if (combined.find("redis") != std::string::npos) return DatabaseType::Redis;
+ if (combined.find("mongo") != std::string::npos) return DatabaseType::MongoDB;
+ if (combined.find("sqlserver") != std::string::npos || combined.find("mssql") != std::string::npos)
+ return DatabaseType::MSSQLServer;
+ return DatabaseType::PostgreSQL;
+ }
+
+ // Return substring between tag open and close — cheap and
+ // good enough for the stable DataGrip schema. Returns "" if
+ // either anchor is missing.
+ std::string extractTag(const std::string& s, const std::string& open, const std::string& close,
+ size_t from = 0)
+ {
+ auto o = s.find(open, from);
+ if (o == std::string::npos) return {};
+ o += open.size();
+ auto c = s.find(close, o);
+ if (c == std::string::npos) return {};
+ return s.substr(o, c - o);
+ }
+
+ // Pull an XML attribute value from a single element open tag.
+ // Assumes double-quoted values (JetBrains always double-quotes).
+ std::string extractAttr(const std::string& tag, const std::string& attr)
+ {
+ const std::string needle = attr + "=\"";
+ auto p = tag.find(needle);
+ if (p == std::string::npos) return {};
+ p += needle.size();
+ auto e = tag.find('"', p);
+ if (e == std::string::npos) return {};
+ return tag.substr(p, e - p);
+ }
+
+ struct JdbcParts { std::string host; std::optional<int> port; std::string db; };
+ JdbcParts parseJdbcUrl(const std::string& url)
+ {
+ JdbcParts p;
+ auto colSlash = url.find("://");
+ if (colSlash == std::string::npos) return p;
+ size_t i = colSlash + 3;
+ size_t endHost = url.find_first_of(":/;?", i);
+ if (endHost == std::string::npos) endHost = url.size();
+ p.host = url.substr(i, endHost - i);
+
+ if (endHost < url.size() && url[endHost] == ':')
+ {
+ size_t j = endHost + 1;
+ std::string num;
+ while (j < url.size() && std::isdigit((unsigned char)url[j])) num += url[j++];
+ if (!num.empty()) { try { p.port = std::stoi(num); } catch (...) {} }
+ endHost = j;
+ }
+ if (endHost < url.size() && url[endHost] == '/')
+ {
+ size_t j = endHost + 1;
+ size_t endDb = url.find_first_of("?;", j);
+ if (endDb == std::string::npos) endDb = url.size();
+ p.db = url.substr(j, endDb - j);
+ }
+ return p;
+ }
+
+ // Walk every <data-source ...>...</data-source> block in the
+ // XML, pull name / uuid / driver / url, and emit one row each.
+ std::vector<ImportedConnection> parseXml(const std::string& xml)
+ {
+ std::vector<ImportedConnection> out;
+ size_t pos = 0;
+ while (true)
+ {
+ auto start = xml.find("<data-source", pos);
+ if (start == std::string::npos) break;
+ auto headerEnd = xml.find('>', start);
+ if (headerEnd == std::string::npos) break;
+ auto blockEnd = xml.find("</data-source>", headerEnd);
+ if (blockEnd == std::string::npos) break;
+
+ const std::string header = xml.substr(start, headerEnd - start + 1);
+ const std::string body = xml.substr(headerEnd + 1, blockEnd - (headerEnd + 1));
+
+ const std::string name = extractAttr(header, "name");
+ const std::string uuid = extractAttr(header, "uuid");
+ // driver may be an element (<driver-ref>pg</driver-ref>)
+ // or attribute. Accept either.
+ std::string driver = extractTag(body, "<driver-ref>", "</driver-ref>");
+ if (driver.empty()) driver = extractTag(body, "<jdbc-driver>", "</jdbc-driver>");
+ std::string url = extractTag(body, "<jdbc-url>", "</jdbc-url>");
+
+ if (!name.empty())
+ {
+ ImportedConnection c;
+ c.source = ImportSource::DataGrip;
+ c.id = uuid.empty() ? L"" : fromUtf8(uuid);
+ c.name = fromUtf8(name);
+ c.databaseType = mapDriverUrl(driver, url);
+ c.sslEnabled = url.find("ssl=true") != std::string::npos;
+
+ if (!url.empty())
+ {
+ auto jp = parseJdbcUrl(url);
+ if (!jp.host.empty()) c.host = fromUtf8(jp.host);
+ if (jp.port.has_value()) c.port = static_cast<uint16_t>(*jp.port);
+ if (!jp.db.empty()) c.database = fromUtf8(jp.db);
+ }
+
+ out.push_back(std::move(c));
+ }
+
+ pos = blockEnd + strlen("</data-source>");
+ }
+ return out;
+ }
+
+ std::vector<ImportedConnection> parseFile(const fs::path& path)
+ {
+ std::ifstream in(path, std::ios::binary);
+ if (!in.is_open()) return {};
+ std::stringstream ss; ss << in.rdbuf();
+ return parseXml(ss.str());
+ }
+}
+
+bool isInstalled() { return newestDataGripDir().has_value(); }
+
+std::vector<ImportedConnection> importConnections()
+{
+ std::vector<ImportedConnection> out;
+ auto base = newestDataGripDir();
+ if (!base) return out;
+
+ // Global options/dataSources.xml — shared across projects.
+ {
+ const auto p = *base / L"options" / L"dataSources.xml";
+ std::error_code ec;
+ if (fs::exists(p, ec))
+ {
+ auto rows = parseFile(p);
+ out.insert(out.end(), rows.begin(), rows.end());
+ }
+ }
+ // Per-project .idea/dataSources.xml (best effort; some users
+ // keep connections in project scope rather than IDE-global).
+ {
+ const auto projRoot = *base / L"projects";
+ std::error_code ec;
+ if (fs::exists(projRoot, ec))
+ {
+ for (auto it = fs::directory_iterator(projRoot, ec);
+ !ec && it != fs::directory_iterator(); ++it)
+ {
+ if (!it->is_directory()) continue;
+ const auto p = it->path() / L".idea" / L"dataSources.xml";
+ if (fs::exists(p, ec))
+ {
+ auto rows = parseFile(p);
+ out.insert(out.end(), rows.begin(), rows.end());
+ }
+ }
+ }
+ }
+ return out;
+}
+
+}} // namespace
diff --git a/windows/Gridex/Services/Import/DataGripImporter.h b/windows/Gridex/Services/Import/DataGripImporter.h
new file mode 100644
index 0000000..0fa5bc4
--- /dev/null
+++ b/windows/Gridex/Services/Import/DataGripImporter.h
@@ -0,0 +1,19 @@
+#pragma once
+//
+// DataGripImporter.h
+// Gridex
+//
+// Reads %APPDATA%\JetBrains\DataGrip<VERSION>\options\dataSources.xml
+// and project-level .idea/dataSources.xml files. Passwords are kept
+// by IntelliJ's encrypted credential store, not in the XML — we
+// skip them; user re-enters after import.
+
+#include <vector>
+#include "../../Models/Import/ImportedConnection.h"
+
+namespace DBModels { namespace DataGripImporter {
+
+bool isInstalled();
+std::vector<ImportedConnection> importConnections();
+
+}} // namespace
diff --git a/windows/Gridex/Services/Import/NavicatImporter.cpp b/windows/Gridex/Services/Import/NavicatImporter.cpp
new file mode 100644
index 0000000..1c7a6ae
--- /dev/null
+++ b/windows/Gridex/Services/Import/NavicatImporter.cpp
@@ -0,0 +1,153 @@
+//
+// NavicatImporter.cpp
+//
+// Parses .ncx export files. Same XML shape as the mac importer —
+// <Connection ConnType="..."> blocks with <Host>, <Port>, <UserName>,
+// <Password>, <SSL>, SSH_Host/Port/User fields. Passwords are
+// Blowfish-encrypted (key "3DC5CA39"); on Windows we skip decryption
+// because Blowfish isn't in BCrypt and OpenSSL 3.0 keeps it behind
+// the legacy provider — user re-enters after import.
+
+#include "NavicatImporter.h"
+
+#include <windows.h>
+#include <fstream>
+#include <sstream>
+#include <string>
+#include <algorithm>
+
+namespace DBModels { namespace NavicatImporter {
+
+namespace {
+ std::wstring fromUtf8(const std::string& s)
+ {
+ if (s.empty()) return {};
+ int sz = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), (int)s.size(), nullptr, 0);
+ std::wstring out(sz, L'\0');
+ MultiByteToWideChar(CP_UTF8, 0, s.c_str(), (int)s.size(), &out[0], sz);
+ return out;
+ }
+
+ // Map Navicat's internal connType codes (seen in both older XML
+ // string form and the newer integer form).
+ DatabaseType mapConnType(const std::string& connType)
+ {
+ std::string lower; lower.reserve(connType.size());
+ for (char c : connType) lower.push_back((char)std::tolower((unsigned char)c));
+
+ if (lower.find("postgres") != std::string::npos) return DatabaseType::PostgreSQL;
+ if (lower.find("mysql") != std::string::npos || lower.find("maria") != std::string::npos)
+ return DatabaseType::MySQL;
+ if (lower.find("sqlite") != std::string::npos) return DatabaseType::SQLite;
+ if (lower.find("redis") != std::string::npos) return DatabaseType::Redis;
+ if (lower.find("mongo") != std::string::npos) return DatabaseType::MongoDB;
+ if (lower.find("sqlserver") != std::string::npos || lower.find("mssql") != std::string::npos)
+ return DatabaseType::MSSQLServer;
+ // Legacy numeric codes.
+ if (lower == "1") return DatabaseType::MySQL;
+ if (lower == "2") return DatabaseType::PostgreSQL;
+ if (lower == "3") return DatabaseType::SQLite;
+ if (lower == "7") return DatabaseType::MSSQLServer;
+ if (lower == "8") return DatabaseType::MongoDB;
+ return DatabaseType::PostgreSQL;
+ }
+
+ std::string extractAttr(const std::string& tag, const std::string& attr)
+ {
+ const std::string needle = attr + "=\"";
+ auto p = tag.find(needle);
+ if (p == std::string::npos) return {};
+ p += needle.size();
+ auto e = tag.find('"', p);
+ if (e == std::string::npos) return {};
+ return tag.substr(p, e - p);
+ }
+
+ // Inside a single <Connection>...</Connection> body, read the
+ // text content of a child element by name. Returns empty when
+ // the tag is absent. Handles both open/close (<Foo>bar</Foo>)
+ // and self-closing empty tags (<Foo/>).
+ std::string readChild(const std::string& body, const std::string& tag)
+ {
+ const std::string open = "<" + tag + ">";
+ const std::string close = "</" + tag + ">";
+ auto o = body.find(open);
+ if (o == std::string::npos) return {};
+ o += open.size();
+ auto c = body.find(close, o);
+ if (c == std::string::npos) return {};
+ std::string v = body.substr(o, c - o);
+ // Trim whitespace.
+ while (!v.empty() && std::isspace((unsigned char)v.front())) v.erase(v.begin());
+ while (!v.empty() && std::isspace((unsigned char)v.back())) v.pop_back();
+ return v;
+ }
+
+ std::vector<ImportedConnection> parseXml(const std::string& xml)
+ {
+ std::vector<ImportedConnection> out;
+ size_t pos = 0;
+ while (true)
+ {
+ auto start = xml.find("<Connection", pos);
+ if (start == std::string::npos) break;
+ auto headerEnd = xml.find('>', start);
+ if (headerEnd == std::string::npos) break;
+ auto blockEnd = xml.find("</Connection>", headerEnd);
+ if (blockEnd == std::string::npos) break;
+
+ const std::string header = xml.substr(start, headerEnd - start + 1);
+ const std::string body = xml.substr(headerEnd + 1, blockEnd - (headerEnd + 1));
+
+ std::string name = readChild(body, "ConnectionName");
+ if (name.empty()) name = readChild(body, "Name");
+ if (name.empty()) { pos = blockEnd + 13; continue; }
+
+ std::string connType = extractAttr(header, "ConnType");
+ if (connType.empty()) connType = readChild(body, "ConnType");
+
+ ImportedConnection c;
+ c.source = ImportSource::Navicat;
+ c.name = fromUtf8(name);
+ c.databaseType = mapConnType(connType);
+ c.host = fromUtf8(readChild(body, "Host"));
+ const auto portStr = readChild(body, "Port");
+ if (!portStr.empty())
+ { try { c.port = (uint16_t)std::stoi(portStr); } catch (...) {} }
+ auto db = readChild(body, "DatabaseName");
+ if (db.empty()) db = readChild(body, "InitialDatabase");
+ c.database = fromUtf8(db);
+ c.username = fromUtf8(readChild(body, "UserName"));
+ c.filePath = fromUtf8(readChild(body, "DatabaseFile"));
+
+ const auto sslStr = readChild(body, "SSL");
+ const auto useSslStr = readChild(body, "UseSSL");
+ c.sslEnabled = (sslStr == "true") || (useSslStr == "1");
+
+ c.sshHost = fromUtf8(readChild(body, "SSH_Host"));
+ const auto sshPortStr = readChild(body, "SSH_Port");
+ if (!sshPortStr.empty())
+ { try { c.sshPort = (uint16_t)std::stoi(sshPortStr); } catch (...) {} }
+ c.sshUser = fromUtf8(readChild(body, "SSH_UserName"));
+
+ // Password field is Blowfish-encrypted; skipped on Windows
+ // (see header). Leave c.password empty.
+
+ out.push_back(std::move(c));
+ pos = blockEnd + std::string("</Connection>").size();
+ }
+ return out;
+ }
+}
+
+bool isInstalled() { return true; }
+
+std::vector<ImportedConnection> importFromNCX(const std::wstring& ncxPath)
+{
+ std::ifstream in(ncxPath, std::ios::binary);
+ if (!in.is_open()) return {};
+ std::stringstream ss; ss << in.rdbuf();
+ return parseXml(ss.str());
+}
+
+}} // namespace
diff --git a/windows/Gridex/Services/Import/NavicatImporter.h b/windows/Gridex/Services/Import/NavicatImporter.h
new file mode 100644
index 0000000..ee186d4
--- /dev/null
+++ b/windows/Gridex/Services/Import/NavicatImporter.h
@@ -0,0 +1,24 @@
+#pragma once
+//
+// NavicatImporter.h
+// Gridex
+//
+// Imports Navicat connections from a user-picked .ncx export file.
+// Mac parses the same XML shape; on Windows we additionally skip
+// Blowfish password decryption (CommonCrypto-only) and leave the
+// password empty — the user re-enters after import.
+
+#include <vector>
+#include <string>
+#include "../../Models/Import/ImportedConnection.h"
+
+namespace DBModels { namespace NavicatImporter {
+
+// Always true — the feature is gated by the user picking an .ncx.
+bool isInstalled();
+
+// Parse the .ncx file at `ncxPath` and return the embedded
+// connections. Passwords are left empty on Windows.
+std::vector<ImportedConnection> importFromNCX(const std::wstring& ncxPath);
+
+}} // namespace
diff --git a/windows/Gridex/Services/Import/TablePlusImporter.cpp b/windows/Gridex/Services/Import/TablePlusImporter.cpp
new file mode 100644
index 0000000..db9ac7d
--- /dev/null
+++ b/windows/Gridex/Services/Import/TablePlusImporter.cpp
@@ -0,0 +1,47 @@
+//
+// TablePlusImporter.cpp
+//
+// Windows v1 stub. Detects TablePlus via its %APPDATA% folder but
+// doesn't parse the store yet — different encrypted format from
+// mac, needs reverse engineering.
+
+#include "TablePlusImporter.h"
+
+#include <windows.h>
+#include <shlobj.h>
+
+namespace DBModels { namespace TablePlusImporter {
+
+namespace {
+ std::wstring tablePlusDataDir()
+ {
+ wchar_t* p = nullptr;
+ if (SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, nullptr, &p) != S_OK)
+ return {};
+ std::wstring out(p);
+ CoTaskMemFree(p);
+ return out + L"\\com.tinyapp.TablePlus";
+ }
+}
+
+bool isInstalled()
+{
+ const auto d = tablePlusDataDir();
+ if (d.empty()) return false;
+ return GetFileAttributesW(d.c_str()) != INVALID_FILE_ATTRIBUTES;
+}
+
+std::vector<ImportedConnection> importConnections()
+{
+ // Parsing the Windows TablePlus store is not implemented yet —
+ // see windowsSupportNote() for the UI-facing explanation.
+ return {};
+}
+
+std::wstring windowsSupportNote()
+{
+ return L"TablePlus import is macOS-only for now. On Windows, export your connections "
+ L"from TablePlus and use the Navicat NCX / DBeaver path instead.";
+}
+
+}} // namespace
diff --git a/windows/Gridex/Services/Import/TablePlusImporter.h b/windows/Gridex/Services/Import/TablePlusImporter.h
new file mode 100644
index 0000000..2e872a1
--- /dev/null
+++ b/windows/Gridex/Services/Import/TablePlusImporter.h
@@ -0,0 +1,27 @@
+#pragma once
+//
+// TablePlusImporter.h
+// Gridex
+//
+// Windows v1 stub. TablePlus on macOS stores connections in a
+// plist under com.tinyapp.TablePlus; the Windows build uses a
+// different encrypted store (SQLite + DPAPI-wrapped passwords)
+// that we haven't reverse-engineered yet. For now we detect
+// installation but return an empty list + surface an "UI note"
+// string so the dialog can explain why.
+
+#include <vector>
+#include <string>
+#include "../../Models/Import/ImportedConnection.h"
+
+namespace DBModels { namespace TablePlusImporter {
+
+bool isInstalled();
+std::vector<ImportedConnection> importConnections();
+
+// Message for the import dialog when the user clicks TablePlus
+// but nothing can be parsed yet. Non-fatal — kept separate from
+// the generic ImportError path so the UI can show a friendly hint.
+std::wstring windowsSupportNote();
+
+}} // namespace