Exemplo n.º 1
0
Settings::Settings(const char* filename) :
		settingsFileName(NULL),
		rootSettingsJSON(NULL),
		settingsJSON(NULL),
		variables()
{
	OpenOrCreate(filename);
}
Exemplo n.º 2
0
static INT_PTR CALLBACK
MainDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int id;

	try {

	switch (message) {
	case WM_INITDIALOG:
		Drives::Load();
		return TRUE;
	case SWM_TRAYMSG:
		switch (lParam) {
		case WM_LBUTTONDBLCLK:
			OpenOrCreate(hWnd);
			break;
		case WM_LBUTTONDOWN:
		case WM_RBUTTONDOWN:
		case WM_CONTEXTMENU:
			ShowContextMenu(hWnd);
		}
		break;
	case WM_COMMAND:
		id = LOWORD(wParam);
		switch (id) {
		case IDM_OPEN:
			OpenOrCreate(hWnd);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		case IDM_ABOUT:
			DialogBox(hInst, (LPCTSTR) IDD_ABOUTBOX, hWnd, (DLGPROC) AboutDlgProc);
			break;
		case IDM_PREFERENCES:
			Preferences(hWnd);
			break;
		default:
			if (id >= IDM_MOUNT_START && id < IDM_MOUNT_END) {
				boost::shared_ptr<Drive> drive = Drives::GetDrive(IDM_MOUNT_N(id));
				if (!drive)
					return 1;

				switch (IDM_MOUNT_TYPE(id)) {
				case IDM_TYPE_MOUNT:
					drive->Mount(hWnd);
					break;
				case IDM_TYPE_UMOUNT:
					drive->Umount(hWnd);
					break;
				case IDM_TYPE_SHOW:
					drive->Show(hWnd);
					break;
				}
			}
			break;
		}
		return 1;
	case WM_DESTROY:
		niData.uFlags = 0;
		Shell_NotifyIcon(NIM_DELETE, &niData);
		PostQuitMessage(0);
		break;
	default:
	    if (message == s_uTaskbarRestart)
		AddTaskbarIcon();
	}
	return 0;
	}
	catch (const truntime_error &err) {
		MessageBox(hWnd, err.what(), _T("EncFS"), MB_ICONERROR);
		return 1;
	}
}