mirror of
https://github.com/KDE/krfb
synced 2026-07-01 07:41:17 -07:00
- finished invitation dialog (delete and deleteall now work)
- some cleanup on the trayicon code - fixed crash on exit - dnssd support svn path=/trunk/KDE/kdenetwork/krfb/; revision=655612
This commit is contained in:
@@ -43,7 +43,7 @@ kde4_add_ui_files(krfb_SRCS connectionwidget.ui
|
||||
|
||||
kde4_add_executable(krfb ${krfb_SRCS})
|
||||
|
||||
target_link_libraries(krfb ${KDE4_KIO_LIBS} ${JPEG_LIBRARIES} ${SLP_LIBRARIES} ${LIBVNCSERVER_LIBRARIES} ${X11_Xdamage_LIB})
|
||||
target_link_libraries(krfb ${KDE4_KIO_LIBS} ${JPEG_LIBRARIES} ${SLP_LIBRARIES} ${LIBVNCSERVER_LIBRARIES} ${X11_Xdamage_LIB} ${KDE4_KDNSSD_LIBRARY})
|
||||
|
||||
install(TARGETS krfb DESTINATION ${BIN_INSTALL_DIR})
|
||||
|
||||
|
||||
31
configtcp.ui
31
configtcp.ui
@@ -13,6 +13,22 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_publishService" >
|
||||
<property name="text" >
|
||||
<string>Announce the service on the local network</string>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_useDefaultPort" >
|
||||
<property name="text" >
|
||||
@@ -25,21 +41,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
|
||||
@@ -13,18 +13,9 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "invitation.h"
|
||||
|
||||
#include <KRandom>
|
||||
/*
|
||||
* Function for (en/de)crypting strings for config file, taken from KMail
|
||||
* Author: Stefan Taferner <taferner@alpin.or.at>
|
||||
*/
|
||||
static QString cryptStr(const QString &aStr) {
|
||||
QString result;
|
||||
for ( int i = 0; i < aStr.length(); i++)
|
||||
result += (aStr[i].unicode() < 0x20) ? aStr[i] :
|
||||
QChar(0x1001F - aStr[i].unicode());
|
||||
return result;
|
||||
}
|
||||
#include <KStringHandler>
|
||||
|
||||
// a random string that doesn't contain i, I, o, O, 1, 0
|
||||
// based on KRandom::randomString()
|
||||
@@ -65,7 +56,8 @@ Invitation::Invitation(const Invitation &x)
|
||||
}
|
||||
|
||||
Invitation::Invitation(const KConfigGroup &config) {
|
||||
m_password = cryptStr(config.readEntry("password", QString()));
|
||||
m_password = KStringHandler::obscure(config.readEntry("password", QString()));
|
||||
kDebug() << "read: " << config.readEntry("password", QString()) << " = " << m_password << endl;
|
||||
m_creationTime = config.readEntry("creation", QDateTime());
|
||||
m_expirationTime = config.readEntry("expiration", QDateTime());
|
||||
}
|
||||
@@ -81,7 +73,8 @@ Invitation &Invitation::operator= (const Invitation&x) {
|
||||
}
|
||||
|
||||
void Invitation::save(KConfigGroup &config) const {
|
||||
config.writeEntry("password", cryptStr(m_password));
|
||||
kDebug() << "write: " << m_password << ": " << KStringHandler::obscure(m_password) << endl;
|
||||
config.writeEntry("password", KStringHandler::obscure(m_password));
|
||||
config.writeEntry("creation", m_creationTime);
|
||||
config.writeEntry("expiration", m_expirationTime);
|
||||
}
|
||||
|
||||
@@ -107,5 +107,13 @@ int InvitationManager::activeInvitations()
|
||||
void InvitationManager::removeInvitation(const Invitation & inv)
|
||||
{
|
||||
invitationList.removeAll(inv);
|
||||
saveInvitations();
|
||||
emit invitationNumChanged(invitationList.size());
|
||||
}
|
||||
|
||||
void InvitationManager::removeAllInvitations()
|
||||
{
|
||||
invitationList.clear();
|
||||
saveInvitations();
|
||||
emit invitationNumChanged(invitationList.size());
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
int activeInvitations();
|
||||
|
||||
void removeInvitation(const Invitation &inv);
|
||||
void removeAllInvitations();
|
||||
|
||||
const QList<Invitation> &invitations();
|
||||
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
<label>This is the port on wich krfb will listen.</label>
|
||||
<default>5900</default>
|
||||
</entry>
|
||||
<entry name="publishService" type="Bool">
|
||||
<label>Announce the service on the local network</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
</group>
|
||||
<group name="Security">
|
||||
<entry name="allowDesktopControl" type="Bool">
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <KLocale>
|
||||
#include <KStaticDeleter>
|
||||
#include <KMessageBox>
|
||||
#include <dnssd/publicservice.h>
|
||||
|
||||
#include "connectioncontroller.h"
|
||||
#include "framebuffer.h"
|
||||
@@ -197,6 +198,11 @@ void KrfbServer::startListening()
|
||||
disconnectAndQuit();
|
||||
};
|
||||
|
||||
if (KrfbConfig::publishService()) {
|
||||
DNSSD::PublicService *service = new DNSSD::PublicService(i18n("%1@%2 (shared desktop)", KUser().loginName(), QHostInfo::localHostName()),"_rfb._tcp",port);
|
||||
service->publishAsync();
|
||||
}
|
||||
|
||||
while (d->running) {
|
||||
foreach(QRect r, d->fb->modifiedTiles()) {
|
||||
rfbMarkRectAsModified(screen, r.x(), r.y(), r.right(), r.bottom());
|
||||
@@ -205,6 +211,7 @@ void KrfbServer::startListening()
|
||||
qApp->processEvents();
|
||||
}
|
||||
rfbShutdownServer(screen, true);
|
||||
emit quitApp();
|
||||
}
|
||||
|
||||
|
||||
@@ -220,7 +227,6 @@ void KrfbServer::enableDesktopControl(bool enable)
|
||||
void KrfbServer::disconnectAndQuit()
|
||||
{
|
||||
d->running = false;
|
||||
emit quitApp();
|
||||
}
|
||||
|
||||
enum rfbNewClientAction KrfbServer::handleNewClient(struct _rfbClientRec * cl)
|
||||
|
||||
7
main.cpp
7
main.cpp
@@ -83,11 +83,6 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
QObject::connect(&app, SIGNAL(lastWindowClosed()), // do not show passivepopup
|
||||
&trayicon, SLOT(prepareQuit()));
|
||||
QObject::connect(&app, SIGNAL(lastWindowClosed()),
|
||||
server, SLOT(disconnectAndQuit()));
|
||||
|
||||
QObject::connect(&trayicon, SIGNAL(enableDesktopControl(bool)),
|
||||
server, SLOT(enableDesktopControl(bool)));
|
||||
QObject::connect(server, SIGNAL(sessionEstablished(QString)),
|
||||
@@ -96,7 +91,7 @@ int main(int argc, char *argv[])
|
||||
&trayicon, SLOT(showDisconnectedMessage()));
|
||||
QObject::connect(server, SIGNAL(desktopControlSettingChanged(bool)),
|
||||
&trayicon, SLOT(setDesktopControlSetting(bool)));
|
||||
QObject::connect(&trayicon, SIGNAL(quitApp()),
|
||||
QObject::connect(&trayicon, SIGNAL(quitSelected()),
|
||||
server, SLOT(disconnectAndQuit()));
|
||||
QObject::connect(server, SIGNAL(quitApp()),
|
||||
&app, SLOT(quit()));
|
||||
|
||||
@@ -207,6 +207,13 @@ p, li { white-space: pre-wrap; }
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11" />
|
||||
<tabstops>
|
||||
<tabstop>invitationWidget</tabstop>
|
||||
<tabstop>newPersonalInvitationButton</tabstop>
|
||||
<tabstop>newEmailInvitationButton</tabstop>
|
||||
<tabstop>deleteAllButton</tabstop>
|
||||
<tabstop>deleteOneButton</tabstop>
|
||||
</tabstops>
|
||||
<includes>
|
||||
<include location="global" >k3listview.h</include>
|
||||
<include location="local" >k3listview.h</include>
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <KLocale>
|
||||
#include <KGlobal>
|
||||
#include <KConfigDialog>
|
||||
#include <KMessageBox>
|
||||
|
||||
// settings dialog
|
||||
#include "ui_configtcp.h"
|
||||
@@ -72,6 +73,12 @@ ManageInvitationsDialog::ManageInvitationsDialog(QWidget *parent)
|
||||
connect( InvitationManager::self(), SIGNAL( invitationNumChanged( int )),
|
||||
SLOT( reloadInvitations() ));
|
||||
connect( this, SIGNAL(user1Clicked()),SLOT(showConfiguration()));
|
||||
connect( deleteAllButton, SIGNAL( clicked() ),
|
||||
SLOT( deleteAll() ));
|
||||
connect( deleteOneButton, SIGNAL( clicked() ),
|
||||
SLOT( deleteCurrent() ));
|
||||
connect( invitationWidget, SIGNAL(itemSelectionChanged ()),
|
||||
SLOT( selectionChanged() ));
|
||||
|
||||
reloadInvitations();
|
||||
}
|
||||
@@ -115,8 +122,10 @@ void ManageInvitationsDialog::reloadInvitations()
|
||||
strs << loc->formatDateTime(inv.creationTime()) << loc->formatDateTime(inv.expirationTime());
|
||||
QTreeWidgetItem *it = new QTreeWidgetItem(strs);
|
||||
invitationWidget->addTopLevelItem(it);
|
||||
it->setData(0,Qt::UserRole+1, inv.creationTime());
|
||||
}
|
||||
invitationWidget->resizeColumnToContents(0);
|
||||
deleteAllButton->setEnabled(InvitationManager::self()->activeInvitations() > 0);
|
||||
}
|
||||
|
||||
void ManageInvitationsDialog::showConfiguration()
|
||||
@@ -131,3 +140,47 @@ void ManageInvitationsDialog::showConfiguration()
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
void ManageInvitationsDialog::deleteAll()
|
||||
{
|
||||
if (KMessageBox::warningContinueCancel(this,
|
||||
i18n("<qt>Are you sure you want to delete all invitations?</qt>"),
|
||||
i18n("Confirm delete Invitations"),
|
||||
KStandardGuiItem::ok(),
|
||||
KStandardGuiItem::cancel(),
|
||||
QString("krfbdeleteallinv")) !=
|
||||
KMessageBox::Continue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
InvitationManager::self()->removeAllInvitations();
|
||||
}
|
||||
|
||||
void ManageInvitationsDialog::deleteCurrent()
|
||||
{
|
||||
if (KMessageBox::warningContinueCancel(this,
|
||||
i18n("<qt>Are you sure you want to delete this invitation?</qt>"),
|
||||
i18n("Confirm delete Invitations"),
|
||||
KStandardGuiItem::ok(),
|
||||
KStandardGuiItem::cancel(),
|
||||
QString("krfbdeleteoneinv")) !=
|
||||
KMessageBox::Continue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
QList<QTreeWidgetItem *> itl = invitationWidget->selectedItems();
|
||||
foreach(QTreeWidgetItem *itm, itl) {
|
||||
foreach(Invitation inv, InvitationManager::self()->invitations()) {
|
||||
if (inv.creationTime() == itm->data(0,Qt::UserRole+1)) {
|
||||
InvitationManager::self()->removeInvitation(inv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ManageInvitationsDialog::selectionChanged()
|
||||
{
|
||||
deleteOneButton->setEnabled(invitationWidget->selectedItems().size() > 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,9 @@ public Q_SLOTS:
|
||||
void inviteByMail();
|
||||
void reloadInvitations();
|
||||
void showConfiguration();
|
||||
void deleteAll();
|
||||
void deleteCurrent();
|
||||
void selectionChanged();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
23
trayicon.cpp
23
trayicon.cpp
@@ -22,6 +22,7 @@
|
||||
#include <kdialog.h>
|
||||
#include <kmenu.h>
|
||||
#include <kglobal.h>
|
||||
#include <kactioncollection.h>
|
||||
#include <kaboutapplicationdialog.h>
|
||||
|
||||
#include "manageinvitationsdialog.h"
|
||||
@@ -30,7 +31,6 @@
|
||||
|
||||
TrayIcon::TrayIcon(KDialog *d) :
|
||||
KSystemTrayIcon(d),
|
||||
actionCollection(this),
|
||||
quitting(false)
|
||||
{
|
||||
setIcon(KIcon("eyes-closed24"));
|
||||
@@ -44,18 +44,15 @@ TrayIcon::TrayIcon(KDialog *d) :
|
||||
|
||||
// contextMenu()->addSeparator();
|
||||
|
||||
enableControlAction = new KToggleAction(i18n("Enable Remote Control"), &actionCollection);
|
||||
enableControlAction = new KToggleAction(i18n("Enable Remote Control"), actionCollection());
|
||||
enableControlAction->setCheckedState(KGuiItem(i18n("Disable Remote Control")));
|
||||
enableControlAction->setEnabled(false);
|
||||
actionCollection.addAction("enable_control", enableControlAction);
|
||||
actionCollection()->addAction("enable_control", enableControlAction);
|
||||
connect(enableControlAction, SIGNAL(toggled(bool)), SIGNAL(enableDesktopControl(bool)));
|
||||
contextMenu()->addAction(actionCollection.action("enable_control"));
|
||||
contextMenu()->addAction(actionCollection()->action("enable_control"));
|
||||
|
||||
contextMenu()->addSeparator();
|
||||
|
||||
aboutAction = KStandardAction::aboutApp(this, SLOT(showAbout()), &actionCollection);
|
||||
actionCollection.addAction("about", aboutAction);
|
||||
contextMenu()->addAction(actionCollection.action("about"));
|
||||
contextMenu()->addAction(KStandardAction::aboutApp(this, SLOT(showAbout()), actionCollection()));
|
||||
|
||||
show();
|
||||
}
|
||||
@@ -99,16 +96,6 @@ void TrayIcon::setDesktopControlSetting(bool b) {
|
||||
enableControlAction->setChecked(b);
|
||||
}
|
||||
|
||||
void TrayIcon::activated(QSystemTrayIcon::ActivationReason reason)
|
||||
{
|
||||
if (reason == QSystemTrayIcon::Trigger)
|
||||
{
|
||||
contextMenu()->popup(QCursor::pos());
|
||||
}
|
||||
else
|
||||
KSystemTrayIcon::activated(reason);
|
||||
}
|
||||
|
||||
void TrayIcon::showManageInvitations()
|
||||
{
|
||||
ManageInvitationsDialog invMngDlg(0);
|
||||
|
||||
@@ -50,11 +50,7 @@ public Q_SLOTS:
|
||||
void showManageInvitations();
|
||||
void showAbout();
|
||||
|
||||
protected:
|
||||
void activated(QSystemTrayIcon::ActivationReason reason);
|
||||
|
||||
private:
|
||||
KActionCollection actionCollection;
|
||||
KAction* manageInvitationsAction;
|
||||
KAction* aboutAction;
|
||||
KToggleAction* enableControlAction;
|
||||
|
||||
@@ -117,6 +117,7 @@ X11FrameBuffer::~X11FrameBuffer()
|
||||
shmctl(d->shminfo.shmid, IPC_RMID, 0);
|
||||
#endif
|
||||
delete d;
|
||||
fb = 0; // already deleted by XDestroyImage
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user