3 This is a standalone application that executes Netscape plugins.
6 Copyright (c) 2000 Matthias Hoelzer-Kluepfel <mhk@caldera.de>
7 Stefan Schimanski <1Stein@gmx.de>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #include <config-apps.h>
28 #include <kapplication.h>
31 #include <kcmdlineargs.h>
32 #include <kaboutdata.h>
33 #include <kconfiggroup.h>
37 #include <kmessagebox.h>
38 #include <QSocketNotifier>
41 #include <sys/resource.h>
52 #include "glibevents.h"
53 #include <QtDBus/QtDBus>
56 * Use RLIMIT_DATA on systems that don't define RLIMIT_AS,
57 * such as FreeBSD 4, NetBSD and OpenBSD.
61 #define RLIMIT_AS RLIMIT_DATA
65 * As the plugin viewer needs to be a motif application, I give in to
66 * the "old style" and keep lot's of global vars. :-)
69 static QString g_dbusServiceName
;
72 * parseCommandLine - get command line parameters
75 void parseCommandLine(int argc
, char *argv
[])
77 for (int i
=0; i
<argc
; i
++)
79 if (!strcmp(argv
[i
], "-dbusservice") && (i
+1 < argc
))
81 g_dbusServiceName
= argv
[i
+1];
87 int main(int argc
, char** argv
)
89 // nspluginviewer is a helper app, it shouldn't do session management at all
90 setenv( "SESSION_MANAGER", "", 1 );
92 setvbuf( stderr
, NULL
, _IONBF
, 0 );
94 kDebug(1430) << "2 - parseCommandLine";
95 parseCommandLine(argc
, argv
);
97 parseCommandLine(argc
, argv
);
99 kDebug(1430) << "3 - create KApplication";
101 // Skip the args.. This is internal, anyway.
102 KCmdLineArgs::init(1, argv
, "nspluginviewer", "nsplugin", ki18n("nspluginviewer"), "");
106 kDebug(1430) << "4 - create XtEvents and GlibEvents";
109 GlibEvents glibevents
;
112 KConfig
_cfg( "kcmnspluginrc" );
113 KConfigGroup
cfg(&_cfg
, "Misc");
114 int v
= qBound(0, cfg
.readEntry("Nice Level", 0), 19);
118 v
= cfg
.readEntry("Max Memory", 0);
121 memset(&rl
, 0, sizeof(rl
));
122 if (0 == getrlimit(RLIMIT_AS
, &rl
)) {
123 rl
.rlim_cur
= qMin(v
, int(rl
.rlim_max
));
124 setrlimit(RLIMIT_AS
, &rl
);
129 kDebug(1430) << "5 - dbus requestName";
130 if (!g_dbusServiceName
.isEmpty()) {
131 QDBusConnectionInterface
* bus
= QDBusConnection::sessionBus().interface(); // already null-checked by KApplication
132 if ( bus
->registerService(g_dbusServiceName
, QDBusConnectionInterface::DontQueueService
) == QDBusConnectionInterface::ServiceNotRegistered
) {
133 kError(101) << "Couldn't register name '" << g_dbusServiceName
<< "' with DBUS - another process owns it already!" << endl
;
138 // create dcop interface
139 kDebug(1430) << "6 - new NSPluginViewer";
140 NSPluginViewer
*viewer
= new NSPluginViewer( 0 );
143 kDebug(1430) << "7 - app.exec()";