~ubuntu-branches/ubuntu/precise/p7zip/precise-updates

« back to all changes in this revision

Viewing changes to CPP/7zip/UI/FileManager/RegistryUtils.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mohammed Adnène Trojette
  • Date: 2009-02-14 20:12:27 UTC
  • mfrom: (1.1.11 upstream) (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090214201227-go63qxm9ozfdma60
Tags: 4.65~dfsg.1-1
* New upstream release.
* Remove wx2.8 Build-Depends added by mistakes (7zG is not yet
  intended to be built).
* Use dh_clean without -k.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// RegistryUtils.cpp
 
2
 
 
3
#include "StdAfx.h"
 
4
 
 
5
#include "RegistryUtils.h"
 
6
#include "Windows/Registry.h"
 
7
 
 
8
using namespace NWindows;
 
9
using namespace NRegistry;
 
10
 
 
11
#define REG_PATH_7Z TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP")
 
12
 
 
13
static const TCHAR *kCUBasePath = REG_PATH_7Z;
 
14
static const TCHAR *kCU_FMPath = REG_PATH_7Z TEXT(STRING_PATH_SEPARATOR) TEXT("FM");
 
15
// static const TCHAR *kLM_Path = REG_PATH_7Z TEXT(STRING_PATH_SEPARATOR) TEXT("FM");
 
16
 
 
17
static const WCHAR *kLangValueName = L"Lang";
 
18
static const WCHAR *kEditor = L"Editor";
 
19
static const TCHAR *kShowDots = TEXT("ShowDots");
 
20
static const TCHAR *kShowRealFileIcons = TEXT("ShowRealFileIcons");
 
21
static const TCHAR *kShowSystemMenu = TEXT("ShowSystemMenu");
 
22
 
 
23
static const TCHAR *kFullRow = TEXT("FullRow");
 
24
static const TCHAR *kShowGrid = TEXT("ShowGrid");
 
25
static const TCHAR *kAlternativeSelection = TEXT("AlternativeSelection");
 
26
// static const TCHAR *kLockMemoryAdd = TEXT("LockMemoryAdd");
 
27
static const TCHAR *kLargePagesEnable = TEXT("LargePages");
 
28
// static const TCHAR *kSingleClick = TEXT("SingleClick");
 
29
// static const TCHAR *kUnderline = TEXT("Underline");
 
30
 
 
31
void SaveRegLang(const UString &langFile)
 
32
{
 
33
  CKey key;
 
34
  key.Create(HKEY_CURRENT_USER, kCUBasePath);
 
35
  key.SetValue(kLangValueName, langFile);
 
36
}
 
37
 
 
38
void ReadRegLang(UString &langFile)
 
39
{
 
40
  langFile.Empty();
 
41
  CKey key;
 
42
  if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS)
 
43
    key.QueryValue(kLangValueName, langFile);
 
44
}
 
45
 
 
46
void SaveRegEditor(const UString &editorPath)
 
47
{
 
48
  CKey key;
 
49
  key.Create(HKEY_CURRENT_USER, kCU_FMPath);
 
50
  key.SetValue(kEditor, editorPath);
 
51
}
 
52
 
 
53
void ReadRegEditor(UString &editorPath)
 
54
{
 
55
  editorPath.Empty();
 
56
  CKey key;
 
57
  if (key.Open(HKEY_CURRENT_USER, kCU_FMPath, KEY_READ) == ERROR_SUCCESS)
 
58
    key.QueryValue(kEditor, editorPath);
 
59
}
 
60
 
 
61
static void Save7ZipOption(const TCHAR *value, bool enabled)
 
62
{
 
63
  CKey key;
 
64
  key.Create(HKEY_CURRENT_USER, kCUBasePath);
 
65
  key.SetValue(value, enabled);
 
66
}
 
67
 
 
68
static void SaveOption(const TCHAR *value, bool enabled)
 
69
{
 
70
  CKey key;
 
71
  key.Create(HKEY_CURRENT_USER, kCU_FMPath);
 
72
  key.SetValue(value, enabled);
 
73
}
 
74
 
 
75
static bool Read7ZipOption(const TCHAR *value, bool defaultValue)
 
76
{
 
77
  CKey key;
 
78
  if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS)
 
79
  {
 
80
    bool enabled;
 
81
    if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
 
82
      return enabled;
 
83
  }
 
84
  return defaultValue;
 
85
}
 
86
 
 
87
static bool ReadOption(const TCHAR *value, bool defaultValue)
 
88
{
 
89
  CKey key;
 
90
  if (key.Open(HKEY_CURRENT_USER, kCU_FMPath, KEY_READ) == ERROR_SUCCESS)
 
91
  {
 
92
    bool enabled;
 
93
    if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
 
94
      return enabled;
 
95
  }
 
96
  return defaultValue;
 
97
}
 
98
 
 
99
/*
 
100
static void SaveLmOption(const TCHAR *value, bool enabled)
 
101
{
 
102
  CKey key;
 
103
  key.Create(HKEY_LOCAL_MACHINE, kLM_Path);
 
104
  key.SetValue(value, enabled);
 
105
}
 
106
 
 
107
static bool ReadLmOption(const TCHAR *value, bool defaultValue)
 
108
{
 
109
  CKey key;
 
110
  if (key.Open(HKEY_LOCAL_MACHINE, kLM_Path, KEY_READ) == ERROR_SUCCESS)
 
111
  {
 
112
    bool enabled;
 
113
    if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
 
114
      return enabled;
 
115
  }
 
116
  return defaultValue;
 
117
}
 
118
*/
 
119
 
 
120
void SaveShowDots(bool showDots) { SaveOption(kShowDots, showDots); }
 
121
bool ReadShowDots() { return ReadOption(kShowDots, false); }
 
122
 
 
123
void SaveShowRealFileIcons(bool show)  { SaveOption(kShowRealFileIcons, show); }
 
124
bool ReadShowRealFileIcons() { return ReadOption(kShowRealFileIcons, false); }
 
125
 
 
126
void SaveShowSystemMenu(bool show) { SaveOption(kShowSystemMenu, show); }
 
127
bool ReadShowSystemMenu(){ return ReadOption(kShowSystemMenu, false); }
 
128
 
 
129
void SaveFullRow(bool enable) { SaveOption(kFullRow, enable); }
 
130
bool ReadFullRow() { return ReadOption(kFullRow, false); }
 
131
 
 
132
void SaveShowGrid(bool enable) { SaveOption(kShowGrid, enable); }
 
133
bool ReadShowGrid(){ return ReadOption(kShowGrid, false); }
 
134
 
 
135
void SaveAlternativeSelection(bool enable) { SaveOption(kAlternativeSelection, enable); }
 
136
bool ReadAlternativeSelection(){ return ReadOption(kAlternativeSelection, false); }
 
137
 
 
138
/*
 
139
void SaveSingleClick(bool enable) { SaveOption(kSingleClick, enable); }
 
140
bool ReadSingleClick(){ return ReadOption(kSingleClick, false); }
 
141
 
 
142
void SaveUnderline(bool enable) { SaveOption(kUnderline, enable); }
 
143
bool ReadUnderline(){ return ReadOption(kUnderline, false); }
 
144
*/
 
145
 
 
146
// void SaveLockMemoryAdd(bool enable) { SaveLmOption(kLockMemoryAdd, enable); }
 
147
// bool ReadLockMemoryAdd() { return ReadLmOption(kLockMemoryAdd, true); }
 
148
 
 
149
void SaveLockMemoryEnable(bool enable) { Save7ZipOption(kLargePagesEnable, enable); }
 
150
bool ReadLockMemoryEnable() { return Read7ZipOption(kLargePagesEnable, false); }
 
151
 
 
152