diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index de4c936e..dc927df0 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -1013,42 +1013,52 @@ generic_string NppParameters::getCloudSettingsPath(CloudChoice cloudChoice) PathAppend(googleDriveInfoDB, TEXT("Google\\Drive\\sync_config.db")); generic_string settingsPath4GoogleDrive = TEXT(""); -/* - try { - sqlite3 *handle; - sqlite3_stmt *stmt; - // try to create the database. If it doesnt exist, it would be created - // pass a pointer to the pointer to sqlite3, in short sqlite3** - int retval = sqlite3_open("sampledb.sqlite3", &handle); - // If connection failed, handle returns NULL - if (retval) - { - char query[] = "select * from data where entry_key='local_sync_root_path')"; + if (::PathFileExists(googleDriveInfoDB.c_str())) + { + try { + sqlite3 *handle; + sqlite3_stmt *stmt; - retval = sqlite3_prepare_v2(handle, query, -1, &stmt, 0); //sqlite3_prepare_v2() interfaces use UTF-8 - if(retval) + // try to create the database. If it doesnt exist, it would be created + // pass a pointer to the pointer to sqlite3, in short sqlite3** + char dest[MAX_PATH]; + wcstombs(dest, googleDriveInfoDB.c_str(), sizeof(dest)); + int retval = sqlite3_open(dest, &handle); + + // If connection failed, handle returns NULL + if (retval == SQLITE_OK) { - // fetch a row’s status - retval = sqlite3_step(stmt); + char query[] = "select * from data where entry_key='local_sync_root_path'"; - if (retval == SQLITE_ROW) + retval = sqlite3_prepare_v2(handle, query, -1, &stmt, 0); //sqlite3_prepare_v2() interfaces use UTF-8 + if (retval == SQLITE_OK) { - int bytes; - const unsigned char * text; - bytes = sqlite3_column_bytes(stmt, 0); - text = sqlite3_column_text (stmt, 0); - printf ("%d: %s\n", row, text); - } - } + // fetch a row’s status + retval = sqlite3_step(stmt); - sqlite3_close(handle); + if (retval == SQLITE_ROW) + { + const unsigned char *text; + text = sqlite3_column_text(stmt, 2); + + const size_t maxLen = 2048; + wchar_t googleFolder[maxLen]; + mbstowcs(googleFolder, (char *)(text + 4), maxLen); + if (::PathFileExists(googleFolder)) + { + settingsPath4GoogleDrive = googleFolder; + _nppGUI._availableClouds |= GOOGLEDRIVE_AVAILABLE; + } + } + } + sqlite3_close(handle); + } + + } catch(...) { + // Do nothing } - - } catch(...) { - // Do nothing } -*/ if (cloudChoice == dropbox && (_nppGUI._availableClouds & DROPBOX_AVAILABLE)) { diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index 4bd21164..3b1065cb 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -382,6 +382,7 @@ BEGIN CONTROL "No Cloud",IDC_NOCLOUD_RADIO,"Button",BS_AUTORADIOBUTTON,125,57,92,10 CONTROL "Dropbox",IDC_DROPBOX_RADIO,"Button",BS_AUTORADIOBUTTON,125,72,92,10 CONTROL "OneDrive",IDC_ONEDRIVE_RADIO,"Button",BS_AUTORADIOBUTTON,125,87,92,10 - LTEXT "",IDC_SETTINGSONCLOUD_WARNING_STATIC,131,106,135,8 + CONTROL "Google Drive",IDC_GOOGLEDRIVE_RADIO,"Button",BS_AUTORADIOBUTTON,125,102,92,10 + LTEXT "",IDC_SETTINGSONCLOUD_WARNING_STATIC,131,117,135,8 END diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 74a2e000..36be1990 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -2814,6 +2814,8 @@ BOOL CALLBACK SettingsOnCloudDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARA ::SendDlgItemMessage(_hSelf, IDC_ONEDRIVE_RADIO, BM_SETCHECK, cloudChoice == oneDrive?BST_CHECKED:BST_UNCHECKED, 0); ::EnableWindow(::GetDlgItem(_hSelf, IDC_ONEDRIVE_RADIO), (nppGUI._availableClouds & ONEDRIVE_AVAILABLE) != 0); + ::SendDlgItemMessage(_hSelf, IDC_GOOGLEDRIVE_RADIO, BM_SETCHECK, cloudChoice == googleDrive?BST_CHECKED:BST_UNCHECKED, 0); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_GOOGLEDRIVE_RADIO), (nppGUI._availableClouds & GOOGLEDRIVE_AVAILABLE) != 0); } break; @@ -2852,6 +2854,16 @@ BOOL CALLBACK SettingsOnCloudDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARA } break; + case IDC_GOOGLEDRIVE_RADIO : + { + nppGUI._cloudChoice = googleDrive; + setCloudChoice("googleDrive"); + + generic_string message = _initialCloudChoice != nppGUI._cloudChoice?TEXT("Please restart Notepad++ to take effect."):TEXT(""); + ::SetDlgItemText(_hSelf, IDC_SETTINGSONCLOUD_WARNING_STATIC, message.c_str()); + } + break; + default : return FALSE; diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index f1fa476d..6fc75081 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -129,6 +129,7 @@ #define IDC_NOCLOUD_RADIO (IDD_PREFERENCE_SETTINGSONCLOUD_BOX + 3) #define IDC_DROPBOX_RADIO (IDD_PREFERENCE_SETTINGSONCLOUD_BOX + 4) #define IDC_ONEDRIVE_RADIO (IDD_PREFERENCE_SETTINGSONCLOUD_BOX + 5) + #define IDC_GOOGLEDRIVE_RADIO (IDD_PREFERENCE_SETTINGSONCLOUD_BOX + 6) #define IDD_PREFERENCE_SETTING_BOX 6300 //(IDD_PREFERENCE_BOX + 300) diff --git a/PowerEditor/visual.net/notepadPlus.vcproj b/PowerEditor/visual.net/notepadPlus.vcproj index 77138e44..bb0e6428 100644 --- a/PowerEditor/visual.net/notepadPlus.vcproj +++ b/PowerEditor/visual.net/notepadPlus.vcproj @@ -548,6 +548,15 @@ + + +