summaryrefslogtreecommitdiffstats
path: root/kcontrol/konqhtml/main.cpp
blob: 0794b390b6875122d03b5b297a646d3be19e73bf (plain)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
 * main.cpp
 *
 * Copyright (c) 1999 Matthias Hoelzer-Kluepfel <[email protected]>
 * Copyright (c) 2000 Daniel Molkentin <[email protected]>
 *
 * Requires the Qt widget libraries, available at no cost at
 * http://www.troll.no/
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */


#include <unistd.h>

#include <tdeapplication.h>
#include <dcopclient.h>
#include <tqtabwidget.h>
#include <tqlayout.h>

#include "jsopts.h"
#include "javaopts.h"
#include "pluginopts.h"
#include "appearance.h"
#include "htmlopts.h"
#include "filteropts.h"
#include "userInterConfig.h"

#include "main.h"
#include <tdeaboutdata.h>
#include "main.moc"

extern "C"
{
	KDE_EXPORT TDECModule *create_tdehtml_behavior(TQWidget *parent, const char *name)
	{
		TDEConfig *c = new TDEConfig( "konquerorrc", false, false );
		return new KMiscHTMLOptions(c, "HTML Settings", parent, name);
	}

	KDE_EXPORT TDECModule *create_tdehtml_fonts(TQWidget *parent, const char *name)
	{
		TDEConfig *c = new TDEConfig( "konquerorrc", false, false );
		return new KAppearanceOptions(c, "HTML Settings", parent, name);
	}

	KDE_EXPORT TDECModule *create_tdehtml_java_js(TQWidget *parent, const char* /*name*/)
	{
		TDEConfig *c = new TDEConfig( "konquerorrc", false, false );
		return new KJSParts(c, parent, "kcmkonqhtml");
	}

	KDE_EXPORT TDECModule *create_tdehtml_plugins(TQWidget *parent, const char *name)
	{
		TDEConfig *c = new TDEConfig( "konquerorrc", false, false );
		return new KPluginOptions(c, "Java/JavaScript Settings", parent, name);
	}

  KDE_EXPORT TDECModule *create_tdehtml_filter(TQWidget *parent, const char *name )
  {
    TDEConfig *c = new TDEConfig( "tdehtmlrc", false, false );
    return new KCMFilter(c, "Filter Settings", parent, name);
  }

  KDE_EXPORT TDECModule *create_tdehtml_userinterface(TQWidget *parent, const char *name )
  {
    TDEConfig *c = new TDEConfig( "konquerorrc", false, false );
    return new userInterConfig(c, "FMSettings", parent, name);
  }
}


KJSParts::KJSParts(TDEConfig *config, TQWidget *parent, const char *name)
	: TDECModule(parent, name), mConfig(config)
{
  TDEAboutData *about =
  new TDEAboutData(I18N_NOOP("kcmkonqhtml"), I18N_NOOP("Konqueror Browsing Control Module"),
                0, 0, TDEAboutData::License_GPL,
                I18N_NOOP("(c) 1999 - 2001 The Konqueror Developers"));

  about->addAuthor("Waldo Bastian",0,"[email protected]");
  about->addAuthor("David Faure",0,"[email protected]");
  about->addAuthor("Matthias Kalle Dalheimer",0,"[email protected]");
  about->addAuthor("Lars Knoll",0,"[email protected]");
  about->addAuthor("Dirk Mueller",0,"[email protected]");
  about->addAuthor("Daniel Molkentin",0,"[email protected]");
  about->addAuthor("Wynn Wilkes",0,"[email protected]");
  
  about->addCredit("Leo Savernik",I18N_NOOP("JavaScript access controls\n"
    			"Per-domain policies extensions"),
			"[email protected]");

  setAboutData( about );

  TQVBoxLayout *layout = new TQVBoxLayout(this);
  tab = new TQTabWidget(this);
  layout->addWidget(tab);

  // ### the groupname is duplicated in KJSParts::save
  java = new KJavaOptions( config, "Java/JavaScript Settings", this, name );
  tab->addTab( java, i18n( "&Java" ) );
  connect( java, TQ_SIGNAL( changed( bool ) ), TQ_SIGNAL( changed( bool ) ) );

  javascript = new KJavaScriptOptions( config, "Java/JavaScript Settings", this, name );
  tab->addTab( javascript, i18n( "Java&Script" ) );
  connect( javascript, TQ_SIGNAL( changed( bool ) ), TQ_SIGNAL( changed( bool ) ) );
}

KJSParts::~KJSParts()
{
  delete mConfig;
}

void KJSParts::load()
{
  javascript->load();
  java->load();
}


void KJSParts::save()
{
  javascript->save();
  java->save();
  
  // delete old keys after they have been migrated
  if (javascript->_removeJavaScriptDomainAdvice
      || java->_removeJavaScriptDomainAdvice) {
    mConfig->setGroup("Java/JavaScript Settings");
    mConfig->deleteEntry("JavaScriptDomainAdvice");
    javascript->_removeJavaScriptDomainAdvice = false;
    java->_removeJavaScriptDomainAdvice = false;
  }
  
  mConfig->sync();

  // Send signal to konqueror
  // Warning. In case something is added/changed here, keep kfmclient in sync
  TQByteArray data;
  if ( !kapp->dcopClient()->isAttached() )
    kapp->dcopClient()->attach();
  kapp->dcopClient()->send( "konqueror*", "KonquerorIface", "reparseConfiguration()", data );
}


void KJSParts::defaults()
{
  javascript->defaults();
  java->defaults();
}

TQString KJSParts::quickHelp() const
{
  return i18n("<h2>JavaScript</h2>On this page, you can configure "
              "whether JavaScript programs embedded in web pages should "
              "be allowed to be executed by Konqueror."
              "<h2>Java</h2>On this page, you can configure "
              "whether Java applets embedded in web pages should "
              "be allowed to be executed by Konqueror."
              "<br><br><b>Note:</b> Active content is always a "
              "security risk, which is why Konqueror allows you to specify very "
              "fine-grained from which hosts you want to execute Java and/or "
              "JavaScript programs." );
}

TQString KJSParts::handbookSection() const
{
	int index = tab->currentPageIndex();
	if (index == 0) {
		return "kbrowse-java";
	}
	else if (index == 1) {
		return "kbrowse-javascript";
	}
	else {
		return TQString::null;
	}
}