mirror of
https://invent.kde.org/network/krfb
synced 2024-07-08 12:05:49 +00:00
stuff
svn path=/trunk/kdenetwork/krfb/; revision=142285
This commit is contained in:
parent
788b31b6c6
commit
789a9a1010
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
* added multithreaded inetd capabilities to libvncserver
|
* added multithreaded inetd capabilities to libvncserver
|
||||||
|
|
||||||
|
* main.c: implemented the 4 modes of krfb
|
||||||
|
|
||||||
2002-03-02 Tim Jansen <tjansen@tjansen.de>
|
2002-03-02 Tim Jansen <tjansen@tjansen.de>
|
||||||
|
|
||||||
* added kinetd
|
* added kinetd
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
/*
|
/*
|
||||||
* TODOs:
|
* TODOs:
|
||||||
* - get notified of changes in services
|
* - get notified of changes in services
|
||||||
|
* - replace debug messages with knotify
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "kinetd.h"
|
#include "kinetd.h"
|
||||||
|
@ -109,7 +110,7 @@ void PortListener::accepted(KSocket *sock) {
|
||||||
|
|
||||||
process.clearArguments();
|
process.clearArguments();
|
||||||
process << argument << sock->socket();
|
process << argument << sock->socket();
|
||||||
if (!process.start(KProcess::DontCare) {
|
if (!process.start(KProcess::DontCare)) {
|
||||||
kdDebug() << "kinetd: Calling process failed" << endl;
|
kdDebug() << "kinetd: Calling process failed" << endl;
|
||||||
}
|
}
|
||||||
delete sock;
|
delete sock;
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
#include <kmessagebox.h>
|
#include <kmessagebox.h>
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qwindowdefs.h>
|
#include <qwindowdefs.h>
|
||||||
|
#include <qcstring.h>
|
||||||
|
#include <qdatastream.h>
|
||||||
|
#include <dcopclient.h>
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
@ -43,6 +46,9 @@ static const char *description = I18N_NOOP("VNC-compatible server to share "
|
||||||
#define ARG_PASSWORD "password"
|
#define ARG_PASSWORD "password"
|
||||||
#define ARG_DONT_CONFIRM_CONNECT "dont-confirm-connect"
|
#define ARG_DONT_CONFIRM_CONNECT "dont-confirm-connect"
|
||||||
#define ARG_REMOTE_CONTROL "remote-control"
|
#define ARG_REMOTE_CONTROL "remote-control"
|
||||||
|
#define ARG_STAND_ALONE "stand-alone"
|
||||||
|
#define ARG_KINETD "kinetd "
|
||||||
|
|
||||||
|
|
||||||
static KCmdLineOptions options[] =
|
static KCmdLineOptions options[] =
|
||||||
{
|
{
|
||||||
|
@ -54,12 +60,69 @@ static KCmdLineOptions options[] =
|
||||||
{ ARG_DONT_CONFIRM_CONNECT, I18N_NOOP("Allow connections without asking the user."), 0},
|
{ ARG_DONT_CONFIRM_CONNECT, I18N_NOOP("Allow connections without asking the user."), 0},
|
||||||
{ "c", 0, 0},
|
{ "c", 0, 0},
|
||||||
{ ARG_REMOTE_CONTROL, I18N_NOOP("Allow remote side to control this computer."), 0},
|
{ ARG_REMOTE_CONTROL, I18N_NOOP("Allow remote side to control this computer."), 0},
|
||||||
|
{ "s", 0, 0},
|
||||||
|
{ ARG_STAND_ALONE, I18N_NOOP("Stand-alone mode, do not use daemon."), 0},
|
||||||
|
{ ARG_KINETD, I18N_NOOP("Used for calling from kinetd."), 0},
|
||||||
{ 0, 0, 0 }
|
{ 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* KRfb can run in 4 different modes:
|
||||||
|
* - stand-alone
|
||||||
|
* + To get there call KRfb with kinetd disabled or not running
|
||||||
|
* + traditional mode like <0.7 versions
|
||||||
|
* + uses non-kcm configuration dialog
|
||||||
|
* + invitation on start-up can be disabled
|
||||||
|
* - stand-alone with command line args
|
||||||
|
* + to get there call krfb any cmd line args (except --kinetd)
|
||||||
|
* + behaves like stand-alone, but without configuration
|
||||||
|
* - kinetd mode
|
||||||
|
* + started using the --kinetd argument
|
||||||
|
* + used for starting from kinetd
|
||||||
|
* + takes socket fd from cmd args
|
||||||
|
* + exits after connection is finished
|
||||||
|
* + config option calls kcontrol module
|
||||||
|
* - invitation mode
|
||||||
|
* + started when krfb is called while kinetd is enabled and no cmd line arg is given
|
||||||
|
* + displays only invitation dialog and finished then
|
||||||
|
* + does not accept connections, no tray icons
|
||||||
|
*
|
||||||
|
* TODO:
|
||||||
|
* - invitations
|
||||||
|
* - kcontrol config for kinetd mode
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum krfb_mode {
|
||||||
|
KRFB_UNKNOWN_MODE = 0,
|
||||||
|
KRFB_STAND_ALONE,
|
||||||
|
KRFB_STAND_ALONE_CMDARG,
|
||||||
|
KRFB_KINETD_MODE,
|
||||||
|
KRFB_INVITATION_MODE
|
||||||
|
};
|
||||||
|
|
||||||
|
bool checkKInetd() {
|
||||||
|
bool enabled;
|
||||||
|
DCOPClient *d = KApplication::dcopClient();
|
||||||
|
|
||||||
|
QByteArray sdata, rdata;
|
||||||
|
QCString replyType;
|
||||||
|
QDataStream arg(sdata, IO_WriteOnly);
|
||||||
|
arg << QString("krfb");
|
||||||
|
if (!d->call ("kded", "kinetd", "isEnabled(QString)", sdata, replyType, rdata))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (replyType != "bool")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QDataStream answer(rdata, IO_ReadOnly);
|
||||||
|
answer >> enabled;
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
enum krfb_mode mode = KRFB_UNKNOWN_MODE;
|
||||||
|
|
||||||
KAboutData aboutData( "krfb", I18N_NOOP("Desktop Sharing"),
|
KAboutData aboutData( "krfb", I18N_NOOP("Desktop Sharing"),
|
||||||
VERSION, description, KAboutData::License_GPL,
|
VERSION, description, KAboutData::License_GPL,
|
||||||
"(c) 2001-2002, Tim Jansen\n"
|
"(c) 2001-2002, Tim Jansen\n"
|
||||||
|
@ -90,11 +153,10 @@ int main(int argc, char *argv[])
|
||||||
KCmdLineArgs::addCmdLineOptions(options);
|
KCmdLineArgs::addCmdLineOptions(options);
|
||||||
|
|
||||||
KApplication app;
|
KApplication app;
|
||||||
if (!RFBController::checkX11Capabilities())
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
Configuration *config;
|
Configuration *config;
|
||||||
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
|
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
|
||||||
|
QString fdString;
|
||||||
if (args->isSet(ARG_ONE_SESSION) ||
|
if (args->isSet(ARG_ONE_SESSION) ||
|
||||||
args->isSet(ARG_PASSWORD) ||
|
args->isSet(ARG_PASSWORD) ||
|
||||||
args->isSet(ARG_REMOTE_CONTROL) ||
|
args->isSet(ARG_REMOTE_CONTROL) ||
|
||||||
|
@ -106,11 +168,30 @@ int main(int argc, char *argv[])
|
||||||
QString password = args->getOption(ARG_PASSWORD);
|
QString password = args->getOption(ARG_PASSWORD);
|
||||||
config = new Configuration(oneConnection, askOnConnect,
|
config = new Configuration(oneConnection, askOnConnect,
|
||||||
allowDesktopControl, password);
|
allowDesktopControl, password);
|
||||||
|
mode = KRFB_STAND_ALONE_CMDARG;
|
||||||
|
}
|
||||||
|
else if (args->isSet(ARG_STAND_ALONE)) {
|
||||||
|
mode = KRFB_STAND_ALONE;
|
||||||
|
}
|
||||||
|
else if (args->isSet(ARG_KINETD)) {
|
||||||
|
fdString = args->getOption(ARG_KINETD);
|
||||||
|
mode = KRFB_KINETD_MODE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
config = new Configuration();
|
config = new Configuration();
|
||||||
args->clear();
|
args->clear();
|
||||||
|
|
||||||
|
if (mode == KRFB_UNKNOWN_MODE)
|
||||||
|
mode = checkKInetd() ? KRFB_INVITATION_MODE : KRFB_STAND_ALONE;
|
||||||
|
|
||||||
|
if (mode == KRFB_INVITATION_MODE) {
|
||||||
|
// TODO: display invitation
|
||||||
|
return app.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RFBController::checkX11Capabilities())
|
||||||
|
return 1;
|
||||||
|
|
||||||
TrayIcon trayicon(new KAboutApplication(&aboutData),
|
TrayIcon trayicon(new KAboutApplication(&aboutData),
|
||||||
config);
|
config);
|
||||||
KRfbIfaceImpl dcopiface(config);
|
KRfbIfaceImpl dcopiface(config);
|
||||||
|
@ -124,7 +205,6 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
QObject::connect(&trayicon, SIGNAL(connectionClosed()),
|
QObject::connect(&trayicon, SIGNAL(connectionClosed()),
|
||||||
&controller, SLOT(closeConnection()));
|
&controller, SLOT(closeConnection()));
|
||||||
|
|
||||||
QObject::connect(&trayicon, SIGNAL(showConfigure()),
|
QObject::connect(&trayicon, SIGNAL(showConfigure()),
|
||||||
config, SLOT(showDialog()));
|
config, SLOT(showDialog()));
|
||||||
|
|
||||||
|
@ -143,7 +223,7 @@ int main(int argc, char *argv[])
|
||||||
QObject::connect(&controller, SIGNAL(sessionEstablished()),
|
QObject::connect(&controller, SIGNAL(sessionEstablished()),
|
||||||
&trayicon, SLOT(openConnection()));
|
&trayicon, SLOT(openConnection()));
|
||||||
|
|
||||||
if (config->oneConnection()) {
|
if (config->oneConnection() || (mode == KRFB_KINETD_MODE)) {
|
||||||
QObject::connect(&controller, SIGNAL(sessionRefused()),
|
QObject::connect(&controller, SIGNAL(sessionRefused()),
|
||||||
&app, SLOT(quit()));
|
&app, SLOT(quit()));
|
||||||
QObject::connect(&controller, SIGNAL(sessionFinished()),
|
QObject::connect(&controller, SIGNAL(sessionFinished()),
|
||||||
|
@ -158,6 +238,16 @@ int main(int argc, char *argv[])
|
||||||
sigaddset(&sigs, SIGPIPE);
|
sigaddset(&sigs, SIGPIPE);
|
||||||
sigprocmask(SIG_BLOCK, &sigs, 0);
|
sigprocmask(SIG_BLOCK, &sigs, 0);
|
||||||
|
|
||||||
|
if (mode == KRFB_KINETD_MODE) {
|
||||||
|
bool ok;
|
||||||
|
int fdNum = fdString.toInt(&ok);
|
||||||
|
if (!ok) {
|
||||||
|
kdError() << "kinetd fd was not numeric." << endl;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
controller.startServer(fdNum);
|
||||||
|
}
|
||||||
|
else
|
||||||
controller.startServer();
|
controller.startServer();
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|
|
@ -258,7 +258,7 @@ RFBController::~RFBController()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void RFBController::startServer(bool xtestGrab)
|
void RFBController::startServer(int inetdFd, bool xtestGrab)
|
||||||
{
|
{
|
||||||
framebufferImage = XGetImage(qt_xdisplay(),
|
framebufferImage = XGetImage(qt_xdisplay(),
|
||||||
QApplication::desktop()->winId(),
|
QApplication::desktop()->winId(),
|
||||||
|
@ -313,6 +313,9 @@ void RFBController::startServer(bool xtestGrab)
|
||||||
server->frameBuffer = fb;
|
server->frameBuffer = fb;
|
||||||
server->autoPort = TRUE;
|
server->autoPort = TRUE;
|
||||||
|
|
||||||
|
if (inetdFd >= 0)
|
||||||
|
server->inetdSock = inetdFd;
|
||||||
|
|
||||||
server->kbdAddEvent = keyboardHook;
|
server->kbdAddEvent = keyboardHook;
|
||||||
server->ptrAddEvent = pointerHook;
|
server->ptrAddEvent = pointerHook;
|
||||||
server->newClientHook = newClientHook;
|
server->newClientHook = newClientHook;
|
||||||
|
@ -356,7 +359,7 @@ void RFBController::stopServer(bool xtestUngrab)
|
||||||
void RFBController::rebind()
|
void RFBController::rebind()
|
||||||
{
|
{
|
||||||
stopServer(false);
|
stopServer(false);
|
||||||
startServer(false);
|
startServer(-1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RFBController::connectionAccepted(bool aRC)
|
void RFBController::connectionAccepted(bool aRC)
|
||||||
|
|
|
@ -121,7 +121,7 @@ public:
|
||||||
enum rfbNewClientAction handleNewClient(rfbClientPtr cl);
|
enum rfbNewClientAction handleNewClient(rfbClientPtr cl);
|
||||||
void handleClientGone();
|
void handleClientGone();
|
||||||
int getPort();
|
int getPort();
|
||||||
void startServer(bool xtestGrab = true);
|
void startServer(int inetdFd = -1, bool xtestGrab = true);
|
||||||
|
|
||||||
static bool checkX11Capabilities();
|
static bool checkX11Capabilities();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user