george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame^] | 1 | /* Copyright (C) 2004 TightVNC Team. All Rights Reserved. |
| 2 | * |
| 3 | * This is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This software is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this software; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 16 | * USA. |
| 17 | */ |
| 18 | |
| 19 | // -=- PlayerOptions class |
| 20 | |
| 21 | #include <rfbplayer/PlayerOptions.h> |
| 22 | |
| 23 | using namespace rfb::win32; |
| 24 | |
| 25 | PlayerOptions::PlayerOptions() { |
| 26 | writeDefaults(); |
| 27 | }; |
| 28 | |
| 29 | void PlayerOptions::readFromRegistry() { |
| 30 | try { |
| 31 | RegKey regKey; |
| 32 | regKey.createKey(HKEY_CURRENT_USER, _T("Software\\TightVnc\\RfbPlayer")); |
| 33 | autoPlay = regKey.getBool(_T("AutoPlay"), DEFAULT_AUTOPLAY); |
| 34 | pixelFormat = regKey.getInt(_T("PixelFormat"), DEFAULT_PF); |
| 35 | acceptBell = regKey.getBool(_T("AcceptBell"), DEFAULT_ACCEPT_BELL); |
| 36 | acceptCutText = regKey.getBool(_T("AcceptCutText"), DEFAULT_ACCEPT_CUT_TEXT); |
| 37 | autoStoreSettings = regKey.getBool(_T("AutoStoreSettings"), DEFAULT_STORE_SETTINGS); |
| 38 | autoPlay = regKey.getBool(_T("AutoPlay"), DEFAULT_AUTOPLAY); |
| 39 | loopPlayback = regKey.getBool(_T("LoopPlayback"), DEFAULT_LOOP_PLAYBACK); |
| 40 | askPixelFormat = regKey.getBool(_T("AskPixelFormat"), DEFAULT_ASK_PF); |
| 41 | } catch (rdr::Exception e) { |
| 42 | MessageBox(0, e.str(), e.type(), MB_OK | MB_ICONERROR); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | void PlayerOptions::writeToRegistry() { |
| 47 | try { |
| 48 | RegKey regKey; |
| 49 | regKey.createKey(HKEY_CURRENT_USER, _T("Software\\TightVnc\\RfbPlayer")); |
| 50 | regKey.setBool(_T("AutoPlay"), autoPlay); |
| 51 | regKey.setInt(_T("PixelFormat"), pixelFormat); |
| 52 | regKey.setBool(_T("AcceptBell"), acceptBell); |
| 53 | regKey.setBool(_T("AcceptCutText"), acceptCutText); |
| 54 | regKey.setBool(_T("AutoStoreSettings"), autoStoreSettings); |
| 55 | regKey.setBool(_T("AutoPlay"), autoPlay); |
| 56 | regKey.setBool(_T("LoopPlayback"), loopPlayback); |
| 57 | regKey.setBool(_T("AskPixelFormat"), askPixelFormat); |
| 58 | } catch (rdr::Exception e) { |
| 59 | MessageBox(0, e.str(), e.type(), MB_OK | MB_ICONERROR); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | void PlayerOptions::writeDefaults() { |
| 64 | initTime = DEFAULT_INIT_TIME; |
| 65 | playbackSpeed = DEFAULT_SPEED; |
| 66 | pixelFormat = PF_AUTO; |
| 67 | frameScale = DEFAULT_FRAME_SCALE; |
| 68 | autoPlay = DEFAULT_AUTOPLAY; |
| 69 | fullScreen = DEFAULT_FULL_SCREEN; |
| 70 | acceptBell = DEFAULT_ACCEPT_BELL; |
| 71 | acceptCutText = DEFAULT_ACCEPT_CUT_TEXT; |
| 72 | loopPlayback = DEFAULT_LOOP_PLAYBACK; |
| 73 | askPixelFormat = DEFAULT_ASK_PF; |
| 74 | autoStoreSettings = DEFAULT_STORE_SETTINGS; |
| 75 | } |