1
0
mirror of https://github.com/KDE/krfb synced 2026-07-01 07:41:17 -07:00

set RFB desktop name

svn path=/trunk/kdenetwork/krfb/; revision=191529
This commit is contained in:
Tim Jansen
2002-12-01 23:36:16 +00:00
parent 38f4d170f5
commit 4015cb8b89
5 changed files with 73 additions and 9 deletions

7
TODO
View File

@@ -1,10 +1,7 @@
For 3.1:
- write SLP service template for remote desktop protocols
(documentation)
For 3.2: For 3.2:
- set desktop name (username@hostname) - write SLP service template for remote desktop protocols
- apply multi-desktop patch (documentation)
- trayicon mouse-over text - trayicon mouse-over text
- when krfb is started with URL arguments and without connection - when krfb is started with URL arguments and without connection
quality, add some kind of smart algorithm to determine whether the quality, add some kind of smart algorithm to determine whether the

View File

@@ -24,6 +24,7 @@
*/ */
#include "rfbcontroller.h" #include "rfbcontroller.h"
#include "kuser.h"
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <netinet/in.h> #include <netinet/in.h>
@@ -324,6 +325,11 @@ RFBController::RFBController(Configuration *c) :
asyncQueue.setAutoDelete(true); asyncQueue.setAutoDelete(true);
KeyboardEvent::initKeycodes(); KeyboardEvent::initKeycodes();
char hostname[256];
if (gethostname(hostname, 256))
hostname[0] = 0;
desktopName = QString(i18n("%1@%2 (shared desktop)")).arg(KUser().loginName()).arg(hostname);
} }
RFBController::~RFBController() RFBController::~RFBController()
@@ -395,6 +401,8 @@ void RFBController::startServer(int inetdFd, bool xtestGrab)
server->newClientHook = newClientHook; server->newClientHook = newClientHook;
server->passwordCheck = passwordCheck; server->passwordCheck = passwordCheck;
server->desktopName = desktopName.latin1();
if (!myCursor) if (!myCursor)
myCursor = rfbMakeXCursor(19, 19, (char*) cur, (char*) mask); myCursor = rfbMakeXCursor(19, 19, (char*) cur, (char*) mask);
server->cursor = myCursor; server->cursor = myCursor;

View File

@@ -169,6 +169,8 @@ private:
XUpdateScanner *scanner; XUpdateScanner *scanner;
ConnectionDialog dialog; ConnectionDialog dialog;
QString desktopName;
rfbScreenInfoPtr server; rfbScreenInfoPtr server;
XImage *framebufferImage; XImage *framebufferImage;

View File

@@ -49,8 +49,8 @@ public:
}; };
KUser::KUser() { KUser::KUser(bool effective) {
fillPasswd(getpwuid(getuid())); fillPasswd(getpwuid(effective ? geteuid() : getuid()));
} }
KUser::KUser(long uid) { KUser::KUser(long uid) {
@@ -61,6 +61,28 @@ KUser::KUser(const QString& name) {
fillPasswd(getpwnam(name.latin1())); fillPasswd(getpwnam(name.latin1()));
} }
KUser::KUser(const KUser &user) {
d = new KUserPrivate(user.uid(),
user.loginName(),
user.fullName());
}
KUser& KUser::operator =(const KUser& user) {
delete d;
d = new KUserPrivate(user.uid(),
user.loginName(),
user.fullName());
}
bool KUser::operator ==(const KUser& user) {
if (isValid() != user.isValid())
return false;
if (isValid())
return uid() == user.uid();
else
return true;
}
void KUser::fillPasswd(struct passwd *p) { void KUser::fillPasswd(struct passwd *p) {
if (p) { if (p) {
QString fn(p->pw_gecos); QString fn(p->pw_gecos);
@@ -87,6 +109,10 @@ long KUser::uid() const {
return -1; return -1;
} }
bool KUser::isSuperUser() const {
return uid() == 0;
}
QString KUser::loginName() const { QString KUser::loginName() const {
if (d->valid) if (d->valid)
return d->loginName; return d->loginName;

View File

@@ -36,15 +36,22 @@ struct passwd;
* *
* @author Tim Jansen <tim@tjansen.de> * @author Tim Jansen <tim@tjansen.de>
* @short Represents a user on your system * @short Represents a user on your system
* @since 3.2
*/ */
class KUser { class KUser {
public: public:
/** /**
* Creates an object that contains information about the current user. * Creates an object that contains information about the current user.
* (As returned by getuid(2)). * (as returned by getuid(2) or geteuid(2)).
* @param effective if true, returns the effective user. If false, the
* real user will be returned. The difference is that when the
* user uses a command like "su", this will change the effective
* user, but not the real user. Use the effective user when
* checking permissions, and the real user for displaying
* information about the user
*/ */
KUser(); KUser(bool effective = false);
/** /**
* Creates an object for the user with the given user id. * Creates an object for the user with the given user id.
@@ -61,6 +68,24 @@ public:
*/ */
KUser(const QString& name); KUser(const QString& name);
/**
* Copy constructor.
* Makes a deep copy.
*/
KUser(const KUser &user);
/**
* Assignment operator.
* Makes a deep copy.
*/
KUser& operator =(const KUser& user);
/**
* Two KUser objects are equal if @ref isValid() and the uid() are
* identical.
*/
bool operator ==(const KUser& user);
/** /**
* Returns true if the user is valid. A KUser object can be invalid if * Returns true if the user is valid. A KUser object can be invalid if
* you created it with an non-existing uid or name. * you created it with an non-existing uid or name.
@@ -74,6 +99,12 @@ public:
*/ */
long uid() const; long uid() const;
/**
* Checks whether the user it the super user (root).
* @return true if the user is root
*/
bool isSuperUser() const;
/** /**
* The login name of the user. * The login name of the user.
* @the login name of the user or QString::null if user is invalid * @the login name of the user or QString::null if user is invalid