mirror of
https://invent.kde.org/network/krfb
synced 2024-07-05 17:38:38 +00:00
-include cleanups
-invitationmanager now really manages invitations -invitation dialog displays invitations too -start porting the real server code svn path=/trunk/KDE/kdenetwork/krfb/; revision=649569
This commit is contained in:
parent
171ffcfc95
commit
cecfaa69b6
|
@ -19,11 +19,11 @@
|
|||
|
||||
#include "connectiondialog.h"
|
||||
|
||||
#include <qcheckbox.h>
|
||||
#include <qlabel.h>
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
|
||||
#include <kiconloader.h>
|
||||
#include <klocale.h>
|
||||
#include <KIconLoader>
|
||||
#include <KLocale>
|
||||
#include <KStandardGuiItem>
|
||||
|
||||
ConnectionDialog::ConnectionDialog( QWidget *parent )
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
***************************************************************************/
|
||||
|
||||
#include "invitation.h"
|
||||
#include <krandom.h>
|
||||
#include <KRandom>
|
||||
/*
|
||||
* Function for (en/de)crypting strings for config file, taken from KMail
|
||||
* Author: Stefan Taferner <taferner@alpin.or.at>
|
||||
|
|
10
invitation.h
10
invitation.h
|
@ -18,11 +18,11 @@
|
|||
#ifndef INVITATION_H
|
||||
#define INVITATION_H
|
||||
|
||||
#include <kapplication.h>
|
||||
#include <kconfig.h>
|
||||
#include <qobject.h>
|
||||
#include <qstring.h>
|
||||
#include <qdatetime.h>
|
||||
#include <KApplication>
|
||||
#include <KConfig>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
const int INVITATION_DURATION = 60*60;
|
||||
|
|
|
@ -46,6 +46,7 @@ void InvitationManager::invalidateOldInvitations() {
|
|||
invitationList.removeAt(invNum);
|
||||
}
|
||||
}
|
||||
saveInvitations();
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,7 +64,6 @@ void InvitationManager::loadInvitations()
|
|||
}
|
||||
|
||||
invalidateOldInvitations();
|
||||
|
||||
if (numInv != invNum) {
|
||||
emit invitationNumChanged(invitationList.size());
|
||||
}
|
||||
|
@ -75,9 +75,28 @@ Invitation InvitationManager::addInvitation()
|
|||
Invitation i;
|
||||
invitationList.append(i);
|
||||
emit invitationNumChanged(invitationList.size());
|
||||
saveInvitations();
|
||||
return i;
|
||||
}
|
||||
|
||||
const QList< Invitation > & InvitationManager::invitations()
|
||||
{
|
||||
return invitationList;
|
||||
}
|
||||
|
||||
void InvitationManager::saveInvitations()
|
||||
{
|
||||
KSharedConfigPtr conf = KGlobal::config();
|
||||
KConfigGroup invitationConfig(conf, "Invitations");
|
||||
int invNum = invitationList.size();
|
||||
invitationConfig.writeEntry("invitation_num",invNum);
|
||||
for (int i = 0; i < invNum; i++) {
|
||||
KConfigGroup ic(conf, QString("Invitation_%1").arg(i));
|
||||
invitationList[i].save(ic);
|
||||
}
|
||||
conf->sync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -28,12 +28,15 @@ public:
|
|||
|
||||
Invitation addInvitation();
|
||||
|
||||
const QList<Invitation> &invitations();
|
||||
|
||||
signals:
|
||||
void invitationNumChanged(int);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
void loadInvitations();
|
||||
void saveInvitations();
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include <KStandardDirs>
|
||||
#include <KStandardGuiItem>
|
||||
|
||||
#include <qlabel.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QToolTip>
|
||||
#include <QCursor>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2007 Alessandro Praduroux <pradu@pradu.it>
|
||||
(C) 2001-2003 by Tim Jansen <tim@tjansen.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
|
@ -16,9 +17,21 @@
|
|||
#include <QTcpServer>
|
||||
#include <QTcpSocket>
|
||||
#include <QTimer>
|
||||
#include <QHostInfo>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
#include <KConfig>
|
||||
#include <KGlobal>
|
||||
#include <KUser>
|
||||
#include <KLocale>
|
||||
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/extensions/XTest.h>
|
||||
#include <QX11Info>
|
||||
|
||||
#include <rfb/rfb.h>
|
||||
|
||||
|
||||
const int DEFAULT_TCP_PORT = 5900;
|
||||
|
||||
|
@ -64,9 +77,8 @@ void KrfbServer::newConnection()
|
|||
connect (conn, SIGNAL(disconnected()), SIGNAL(sessionFinished()));
|
||||
|
||||
fdNum = conn->socketDescriptor();
|
||||
conn->close();
|
||||
// TODO: start the actual sharing implementation
|
||||
//_controller->startServer(fdNum);
|
||||
startServer(fdNum);
|
||||
}
|
||||
|
||||
void KrfbServer::enableDesktopControl(bool enable)
|
||||
|
@ -81,4 +93,45 @@ void KrfbServer::disconnectAndQuit()
|
|||
emit quitApp();
|
||||
}
|
||||
|
||||
void KrfbServer::startServer(int fd)
|
||||
{
|
||||
rfbScreenInfoPtr server;
|
||||
XImage *framebufferImage;
|
||||
|
||||
framebufferImage = XGetImage(QX11Info::display(),
|
||||
QApplication::desktop()->winId(),
|
||||
0,
|
||||
0,
|
||||
QApplication::desktop()->width(),
|
||||
QApplication::desktop()->height(),
|
||||
AllPlanes,
|
||||
ZPixmap);
|
||||
|
||||
int w = framebufferImage->width;
|
||||
int h = framebufferImage->height;
|
||||
char *fb = framebufferImage->data;
|
||||
|
||||
rfbLogEnable(0);
|
||||
server = rfbGetScreen(0, 0, w, h,
|
||||
framebufferImage->bits_per_pixel,
|
||||
8,
|
||||
framebufferImage->bits_per_pixel/8);
|
||||
|
||||
server->paddedWidthInBytes = framebufferImage->bytes_per_line;
|
||||
server->frameBuffer = fb;
|
||||
server->autoPort = TRUE;
|
||||
server->inetdSock = fd;
|
||||
|
||||
server->desktopName = i18n("%1@%2 (shared desktop)", KUser().loginName(), QHostInfo::localHostName()).toLatin1();
|
||||
|
||||
// if (!myCursor)
|
||||
// myCursor = rfbMakeXCursor(19, 19, (char*) cur, (char*) mask);
|
||||
// server->cursor = myCursor;
|
||||
|
||||
rfbInitServer(server);
|
||||
|
||||
rfbRunEventLoop(server, -1, TRUE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@ public Q_SLOTS:
|
|||
void disconnectAndQuit();
|
||||
|
||||
private:
|
||||
void startServer(int fd);
|
||||
|
||||
RFBController *_controller;
|
||||
QTcpServer *_server;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item rowspan="5" row="2" column="1" >
|
||||
<widget class="QTreeWidget" name="treeWidget" >
|
||||
<widget class="QTreeWidget" name="invitationWidget" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
|
@ -64,6 +64,15 @@
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="alternatingRowColors" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="rootIsDecorated" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="allColumnsShowFocus" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Created</string>
|
||||
|
|
|
@ -16,10 +16,13 @@
|
|||
#include <QWidget>
|
||||
#include <QToolTip>
|
||||
#include <QCursor>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <KStandardDirs>
|
||||
#include <KStandardGuiItem>
|
||||
#include <KIconLoader>
|
||||
#include <KLocale>
|
||||
#include <KGlobal>
|
||||
|
||||
|
||||
ManageInvitationsDialog::ManageInvitationsDialog(QWidget *parent)
|
||||
|
@ -43,7 +46,10 @@ ManageInvitationsDialog::ManageInvitationsDialog(QWidget *parent)
|
|||
SLOT( inviteManually() ));
|
||||
connect( newEmailInvitationButton, SIGNAL( clicked() ),
|
||||
SLOT( inviteByMail() ));
|
||||
connect( InvitationManager::self(), SIGNAL( invitationNumChanged( int )),
|
||||
SLOT( reloadInvitations() ));
|
||||
|
||||
reloadInvitations();
|
||||
}
|
||||
|
||||
ManageInvitationsDialog::~ManageInvitationsDialog()
|
||||
|
@ -76,3 +82,16 @@ void ManageInvitationsDialog::inviteByMail()
|
|||
{
|
||||
}
|
||||
|
||||
void ManageInvitationsDialog::reloadInvitations()
|
||||
{
|
||||
invitationWidget->clear();
|
||||
KLocale *loc = KGlobal::locale();
|
||||
foreach(Invitation inv, InvitationManager::self()->invitations()) {
|
||||
QStringList strs;
|
||||
strs << loc->formatDateTime(inv.creationTime()) << loc->formatDateTime(inv.expirationTime());
|
||||
QTreeWidgetItem *it = new QTreeWidgetItem(strs);
|
||||
invitationWidget->addTopLevelItem(it);
|
||||
}
|
||||
invitationWidget->resizeColumnToContents(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ public Q_SLOTS:
|
|||
void showWhatsthis();
|
||||
void inviteManually();
|
||||
void inviteByMail();
|
||||
void reloadInvitations();
|
||||
|
||||
private:
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user