[NEW_FEATURE] Settings on cloud - Google Drive.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1258 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2014-06-30 15:54:40 +00:00
parent 822693e106
commit e9ada08611
5 changed files with 62 additions and 29 deletions

View File

@ -1013,42 +1013,52 @@ generic_string NppParameters::getCloudSettingsPath(CloudChoice cloudChoice)
PathAppend(googleDriveInfoDB, TEXT("Google\\Drive\\sync_config.db")); PathAppend(googleDriveInfoDB, TEXT("Google\\Drive\\sync_config.db"));
generic_string settingsPath4GoogleDrive = TEXT(""); generic_string settingsPath4GoogleDrive = TEXT("");
/*
try {
sqlite3 *handle;
sqlite3_stmt *stmt;
// try to create the database. If it doesnt exist, it would be created if (::PathFileExists(googleDriveInfoDB.c_str()))
// pass a pointer to the pointer to sqlite3, in short sqlite3** {
int retval = sqlite3_open("sampledb.sqlite3", &handle); try {
// If connection failed, handle returns NULL sqlite3 *handle;
if (retval) sqlite3_stmt *stmt;
{
char query[] = "select * from data where entry_key='local_sync_root_path')";
retval = sqlite3_prepare_v2(handle, query, -1, &stmt, 0); //sqlite3_prepare_v2() interfaces use UTF-8 // try to create the database. If it doesnt exist, it would be created
if(retval) // 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 rows status char query[] = "select * from data where entry_key='local_sync_root_path'";
retval = sqlite3_step(stmt);
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; // fetch a rows status
const unsigned char * text; retval = sqlite3_step(stmt);
bytes = sqlite3_column_bytes(stmt, 0);
text = sqlite3_column_text (stmt, 0);
printf ("%d: %s\n", row, text);
}
}
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)) if (cloudChoice == dropbox && (_nppGUI._availableClouds & DROPBOX_AVAILABLE))
{ {

View File

@ -382,6 +382,7 @@ BEGIN
CONTROL "No Cloud",IDC_NOCLOUD_RADIO,"Button",BS_AUTORADIOBUTTON,125,57,92,10 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 "Dropbox",IDC_DROPBOX_RADIO,"Button",BS_AUTORADIOBUTTON,125,72,92,10
CONTROL "OneDrive",IDC_ONEDRIVE_RADIO,"Button",BS_AUTORADIOBUTTON,125,87,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 END

View File

@ -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); ::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); ::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; break;
@ -2852,6 +2854,16 @@ BOOL CALLBACK SettingsOnCloudDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARA
} }
break; 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 : default :
return FALSE; return FALSE;

View File

@ -129,6 +129,7 @@
#define IDC_NOCLOUD_RADIO (IDD_PREFERENCE_SETTINGSONCLOUD_BOX + 3) #define IDC_NOCLOUD_RADIO (IDD_PREFERENCE_SETTINGSONCLOUD_BOX + 3)
#define IDC_DROPBOX_RADIO (IDD_PREFERENCE_SETTINGSONCLOUD_BOX + 4) #define IDC_DROPBOX_RADIO (IDD_PREFERENCE_SETTINGSONCLOUD_BOX + 4)
#define IDC_ONEDRIVE_RADIO (IDD_PREFERENCE_SETTINGSONCLOUD_BOX + 5) #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) #define IDD_PREFERENCE_SETTING_BOX 6300 //(IDD_PREFERENCE_BOX + 300)

View File

@ -548,6 +548,15 @@
<File <File
RelativePath="..\src\sqlite\sqlite3.c" RelativePath="..\src\sqlite\sqlite3.c"
> >
<FileConfiguration
Name="Unicode Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
WarningLevel="0"
/>
</FileConfiguration>
<FileConfiguration <FileConfiguration
Name="Unicode Release|Win32" Name="Unicode Release|Win32"
> >