-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebprefs.cpp
107 lines (80 loc) · 3.02 KB
/
webprefs.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
///////////////////////////////////////////////////////////////////////////////
// Name: webprefs.cpp
// Purpose: wxwebconnect: embedded web browser control library
// Author: Benjamin I. Williams
// Modified by:
// Created: 2007-04-23
// RCS-ID:
// Copyright: (C) Copyright 2006-2010, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
#include <wx/wx.h>
#include "webframe.h"
#include "webcontrol.h"
#include "nsinclude.h"
///////////////////////////////////////////////////////////////////////////////
// wxWebPreferences class implementation
///////////////////////////////////////////////////////////////////////////////
wxWebPreferences::wxWebPreferences()
{
}
bool wxWebPreferences::GetBoolPref(const wxString& branch_name, const wxString& name)
{
ns_smartptr<nsIPrefBranch> prefs = nsGetPrefBranch(branch_name);
wxASSERT(!prefs.empty());
if (prefs.empty())
return false;
PRBool val;
if (NS_FAILED(prefs->GetBoolPref((const char*)name.mbc_str(), &val)))
return false;
return (val == PR_TRUE ? true : false);
}
wxString wxWebPreferences::GetStringPref(const wxString& branch_name, const wxString& name)
{
wxString val;
ns_smartptr<nsIPrefBranch> prefs = nsGetPrefBranch(branch_name);
wxASSERT(!prefs.empty());
if (prefs.empty())
return val;
char* cstr = NULL;
if (NS_FAILED(prefs->GetCharPref((const char*)name.mbc_str(), &cstr)))
return val;
if (cstr)
{
val = wxString::FromAscii(cstr);
NS_Free(cstr);
}
return val;
}
int wxWebPreferences::GetIntPref(const wxString& branch_name, const wxString& name)
{
ns_smartptr<nsIPrefBranch> prefs = nsGetPrefBranch(branch_name);
wxASSERT(!prefs.empty());
if (prefs.empty())
return 0;
int val = 0;
if (NS_FAILED(prefs->GetIntPref((const char*)name.mbc_str(), &val)))
return 0;
return val;
}
void wxWebPreferences::SetIntPref(const wxString& branch_name, const wxString& name, int value)
{
ns_smartptr<nsIPrefBranch> prefs = nsGetPrefBranch(branch_name);
if (prefs.empty())
return;
prefs->SetIntPref((const char*)name.mbc_str(), value);
}
void wxWebPreferences::SetStringPref(const wxString& branch_name, const wxString& name, const wxString& value)
{
ns_smartptr<nsIPrefBranch> prefs = nsGetPrefBranch(branch_name);
if (prefs.empty())
return;
prefs->SetCharPref((const char*)name.mbc_str(), (const char*)value.mbc_str());
}
void wxWebPreferences::SetBoolPref(const wxString& branch_name, const wxString& name, bool value)
{
ns_smartptr<nsIPrefBranch> prefs = nsGetPrefBranch(branch_name);
if (prefs.empty())
return;
prefs->SetBoolPref((const char*)name.mbc_str(), value ? PR_TRUE : PR_FALSE);
}