Extends krandrtray, adds iccconfig kcontrol module, adds run dialog autocomplete and lots of bugfixes Will need to check for commit warnings and repair as encountered Also needs full compile test git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1061475 283d02a7-25f6-0310-bc7c-ecb5cbfe19dav3.5.13-sru
parent
4aed2c8219
commit
10e4114459
@ -0,0 +1,17 @@
|
||||
AM_CPPFLAGS = $(all_includes)
|
||||
kde_module_LTLIBRARIES = kcm_iccconfig.la
|
||||
|
||||
kcm_iccconfig_la_SOURCES = iccconfig.cpp iccconfigbase.ui iccconfig.skel
|
||||
|
||||
kcm_iccconfig_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined
|
||||
|
||||
kcm_iccconfig_la_LIBADD = -lkdeui $(LIB_KIO)
|
||||
|
||||
METASOURCES = AUTO
|
||||
|
||||
noinst_HEADERS = iccconfig.h
|
||||
|
||||
messages: rc.cpp
|
||||
$(XGETTEXT) *.cpp -o $(podir)/kcmiccconfig.pot
|
||||
|
||||
xdg_apps_DATA = iccconfig.desktop
|
@ -0,0 +1,7 @@
|
||||
case "$host" in
|
||||
*-*-linux*)
|
||||
FOUND_LINUX=yes
|
||||
;;
|
||||
esac
|
||||
|
||||
AM_CONDITIONAL(include_kcontrol_iccconfig, test "$FOUND_LINUX" = "yes")
|
@ -0,0 +1,166 @@
|
||||
/**
|
||||
* smartcard.cpp
|
||||
*
|
||||
* Copyright (c) 2001 George Staikos <staikos@kde.org>
|
||||
* Copyright (c) 2001 Fernando Llobregat <fernando.llobregat@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "iccconfig.h"
|
||||
|
||||
#include <qcheckbox.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlayout.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include <dcopclient.h>
|
||||
|
||||
#include <kaboutdata.h>
|
||||
#include <kapplication.h>
|
||||
#include <kconfig.h>
|
||||
#include <kdebug.h>
|
||||
#include <kdialog.h>
|
||||
#include <kglobal.h>
|
||||
#include <klistview.h>
|
||||
#include <klocale.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <kpopupmenu.h>
|
||||
#include <kurlrequester.h>
|
||||
#include <kgenericfactory.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <ksimpleconfig.h>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <qstring.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**** DLL Interface ****/
|
||||
typedef KGenericFactory<KICCConfig, QWidget> KICCCFactory;
|
||||
K_EXPORT_COMPONENT_FACTORY( kcm_iccconfig, KICCCFactory("kcmiccconfig") )
|
||||
|
||||
KSimpleConfig *config;
|
||||
|
||||
/**** KICCConfig ****/
|
||||
|
||||
KICCConfig::KICCConfig(QWidget *parent, const char *name, const QStringList &)
|
||||
: KCModule(KICCCFactory::instance(), parent, name)
|
||||
{
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
|
||||
config = new KSimpleConfig( QString::fromLatin1( KDE_CONFDIR "/kicc/kiccconfigrc" ));
|
||||
|
||||
KAboutData *about =
|
||||
new KAboutData(I18N_NOOP("kcmiccconfig"), I18N_NOOP("KDE ICC Profile Control Module"),
|
||||
0, 0, KAboutData::License_GPL,
|
||||
I18N_NOOP("(c) 2009 Timothy Pearson"));
|
||||
|
||||
about->addAuthor("Timothy Pearson", 0, "kb9vqf@pearsoncomputing.net");
|
||||
setAboutData( about );
|
||||
|
||||
base = new ICCConfigBase(this);
|
||||
layout->add(base);
|
||||
|
||||
setRootOnlyMsg(i18n("<b>The ICC color profile is a system wide setting, and requires administrator access</b><br>To alter the system's ICC profile, click on the \"Administrator Mode\" button below."));
|
||||
setUseRootOnlyMsg(true);
|
||||
|
||||
connect(base->enableSupport, SIGNAL(clicked()), SLOT(changed()));
|
||||
connect(base->enableSupport, SIGNAL(toggled(bool)), base->iccFile, SLOT(setEnabled(bool)));
|
||||
|
||||
connect(base->iccFile, SIGNAL(textChanged(const QString&)), SLOT(changed()));
|
||||
|
||||
load();
|
||||
|
||||
if (getuid() != 0 || !config->checkConfigFilesWritable( true )) {
|
||||
base->enableSupport->setEnabled(false);
|
||||
base->iccFile->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
KICCConfig::~KICCConfig()
|
||||
{
|
||||
delete config;
|
||||
}
|
||||
|
||||
void KICCConfig::load()
|
||||
{
|
||||
load( false );
|
||||
}
|
||||
|
||||
void KICCConfig::load(bool useDefaults )
|
||||
{
|
||||
//Update the toggle buttons with the current configuration
|
||||
|
||||
config->setReadDefaults( useDefaults );
|
||||
|
||||
base->enableSupport->setChecked(config->readBoolEntry("EnableICC", false));
|
||||
base->iccFile->setEnabled(config->readBoolEntry("EnableICC", false));
|
||||
base->iccFile->setURL(config->readEntry("ICCFile"));
|
||||
|
||||
emit changed(useDefaults);
|
||||
}
|
||||
|
||||
void KICCConfig::save()
|
||||
{
|
||||
config->writeEntry("EnableICC", base->enableSupport->isChecked());
|
||||
config->writeEntry("ICCFile", base->iccFile->url());
|
||||
|
||||
if (base->enableSupport->isChecked()) {
|
||||
// Apply ICC settings with XCalib
|
||||
string icc_command="/usr/bin/xcalib ";
|
||||
FILE *pipe_xcalib;
|
||||
char xcalib_result[2048];
|
||||
int i;
|
||||
xcalib_result[0]=0;
|
||||
|
||||
icc_command.append(base->iccFile->url().ascii());
|
||||
if ((pipe_xcalib = popen(icc_command.c_str(), "r")) == NULL)
|
||||
{
|
||||
printf("Xcalib pipe error\n\r");
|
||||
}
|
||||
else {
|
||||
fgets(xcalib_result, 2048, pipe_xcalib);
|
||||
pclose(pipe_xcalib);
|
||||
for (i=1;i<2048;i++) {
|
||||
if (xcalib_result[i] == 0) {
|
||||
xcalib_result[i-1]=0;
|
||||
i=2048;
|
||||
}
|
||||
}
|
||||
if (strlen(xcalib_result) > 2) {
|
||||
KMessageBox::error(this, QString("Unable to apply ICC configuration:\n\r%1").arg(xcalib_result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
void KICCConfig::defaults()
|
||||
{
|
||||
load( true );
|
||||
}
|
||||
|
||||
QString KICCConfig::quickHelp() const
|
||||
{
|
||||
return i18n("<h1>ICC Profile Configuration</h1> This module allows you to configure KDE support"
|
||||
" for ICC profiles. This allows you to easily color correct your monitor"
|
||||
" for a more lifelike and vibrant image.");
|
||||
}
|
||||
|
||||
#include "iccconfig.moc"
|
@ -0,0 +1,21 @@
|
||||
[Desktop Entry]
|
||||
Exec=kcmshell iccconfig
|
||||
Icon=kcoloredit
|
||||
Type=Application
|
||||
DocPath=kcontrol/iccconfig/index.html
|
||||
|
||||
X-KDE-Library=iccconfig
|
||||
X-KDE-ParentApp=kcontrol
|
||||
X-KDE-RootOnly=true
|
||||
X-KDE-SubstituteUID=true
|
||||
|
||||
Categories=Qt;KDE;X-KDE-settings-peripherals;
|
||||
Comment=Configure display ICC profile
|
||||
Comment[en_US]=Configure display ICC profile
|
||||
DocPath=kcontrol/iccconfig.html
|
||||
GenericName=
|
||||
GenericName[en_US]=
|
||||
Keywords=ICC,display,color,profile
|
||||
MimeType=
|
||||
Name=ICC Color Profile
|
||||
Name[en_US]=ICC Color Profile
|
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* iccconfig.h
|
||||
*
|
||||
* Copyright (c) 2009 Timothy Pearson <kb9vqf@pearsoncomputing.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _KCM_ICCCONFIG_H
|
||||
#define _KCM_ICCCONFIG_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <dcopobject.h>
|
||||
|
||||
#include <kcmodule.h>
|
||||
|
||||
#include "iccconfigbase.h"
|
||||
|
||||
class KConfig;
|
||||
class KPopupMenu;
|
||||
class KListViewItem;
|
||||
|
||||
class KICCConfig : public KCModule, public DCOPObject
|
||||
{
|
||||
K_DCOP
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
//KICCConfig(QWidget *parent = 0L, const char *name = 0L);
|
||||
KICCConfig(QWidget *parent, const char *name, const QStringList &);
|
||||
virtual ~KICCConfig();
|
||||
|
||||
ICCConfigBase *base;
|
||||
|
||||
void load();
|
||||
void load( bool useDefaults);
|
||||
void save();
|
||||
void defaults();
|
||||
|
||||
int buttons();
|
||||
QString quickHelp() const;
|
||||
|
||||
k_dcop:
|
||||
|
||||
private:
|
||||
|
||||
KConfig *config;
|
||||
bool _ok;
|
||||
KPopupMenu * _popUpKardChooser;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,102 @@
|
||||
<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
|
||||
<class>ICCConfigBase</class>
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>ICCConfigBase</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>519</width>
|
||||
<height>356</height>
|
||||
</rect>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QTabWidget" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>TabWidget2</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>tab</cstring>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>ICC Color Profile Configuration</string>
|
||||
</attribute>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QCheckBox" row="0" column="0" colspan="2">
|
||||
<property name="name">
|
||||
<cstring>enableSupport</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Enable global ICC color profile support</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KURLRequester" row="1" column="1">
|
||||
<property name="name">
|
||||
<cstring>iccFile</cstring>
|
||||
</property>
|
||||
<property name="filter">
|
||||
<string>*.icc</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel2_2</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ICC File</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer row="2" column="0">
|
||||
<property name="name" stdset="0">
|
||||
<cstring>Spacer4</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</grid>
|
||||
</widget>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>enableSupport</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>ICCConfigBase</receiver>
|
||||
<slot>enableSupport_toggled(bool)</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<includes>
|
||||
<include location="local" impldecl="in implementation">ICCConfigBase.ui.h</include>
|
||||
</includes>
|
||||
<slots>
|
||||
<slot>enableSupport_toggled(bool)</slot>
|
||||
</slots>
|
||||
<includes>
|
||||
<include location="local" impldecl="in implementation">kdialog.h</include>
|
||||
</includes>
|
||||
<layoutdefaults spacing="3" margin="6"/>
|
||||
<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
|
||||
</UI>
|
@ -0,0 +1,104 @@
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>ICCConfigBase</class>
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>ICCConfigBase</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>519</width>
|
||||
<height>356</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>ICCConfigBase</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QTabWidget" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>TabWidget2</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>tab</cstring>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>ICC Color Profile Configuration</string>
|
||||
</attribute>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="2">
|
||||
<property name="name">
|
||||
<cstring>enableSupport</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Enable ICC color profile support</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KURLRequester" row="1" column="1">
|
||||
<property name="name">
|
||||
<cstring>editPCF</cstring>
|
||||
</property>
|
||||
<property name="filter">
|
||||
<string>.icc</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel2_2</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ICC File</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer row="2" column="0">
|
||||
<property name="name">
|
||||
<cstring>Spacer4</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</grid>
|
||||
</widget>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>enableSupport</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>ICCConfigBase</receiver>
|
||||
<slot>enableSupport_toggled(bool)</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>enableSupport_toggled(bool)</slot>
|
||||
</slots>
|
||||
<layoutdefaults spacing="3" margin="6"/>
|
||||
<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
|
||||
<includehints>
|
||||
<includehint>kurlrequester.h</includehint>
|
||||
<includehint>klineedit.h</includehint>
|
||||
<includehint>kpushbutton.h</includehint>
|
||||
</includehints>
|
||||
</UI>
|
@ -1,42 +1,16 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# /etc/hotplug/usb/consoleUserPerms
|
||||
#
|
||||
# Sets up newly plugged in USB device so that the user who owns
|
||||
# the console according to pam_console can access it from user space
|
||||
#
|
||||
# Note that for this script to work, you'll need all of the following:
|
||||
# a) a line in the file /etc/hotplug/usb.usermap or another usermap file
|
||||
# in /etc/hotplug/usb/ that corresponds to the device you are using.
|
||||
# b) a setup using pam_console creates the respective lock files
|
||||
# containing the name of the respective user. You can check for that
|
||||
# by executing "echo `cat /var/{run,lock}/console.lock`" and
|
||||
# verifying the appropriate user is mentioned somewhere there.
|
||||
# c) a Linux kernel supporting hotplug and usbdevfs
|
||||
# d) the hotplug package (http://linux-hotplug.sourceforge.net/)
|
||||
#
|
||||
# In the usermap file, the first field "usb module" should be named
|
||||
# "consoleUserPerms" to invoke this script.
|
||||
#
|
||||
#!/bin/sh
|
||||
|
||||
if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
|
||||
GROUP=plugdev
|
||||
|
||||
if [ "${ACTION}" = "add" ]
|
||||
then
|
||||
# New code, using lock files instead of copying /dev/console permissions
|
||||
# This also works with non-kdm logins (e.g. on a virtual terminal)
|
||||
# Idea and code from Nalin Dahyabhai <nalin@redhat.com>
|
||||
if [ -f /var/run/console.lock ]
|
||||
then
|
||||
CONSOLEOWNER=`cat /var/run/console.lock`
|
||||
elif [ -f /var/lock/console.lock ]
|
||||
then
|
||||
CONSOLEOWNER=`cat /var/lock/console.lock`
|
||||
else
|
||||
CONSOLEOWNER=
|
||||
fi
|
||||
if [ -n "$CONSOLEOWNER" ]
|
||||
then
|
||||
chmod 0000 "${DEVICE}"
|
||||
chown "$CONSOLEOWNER" "${DEVICE}"
|
||||
chmod 0600 "${DEVICE}"
|
||||
if getent group $GROUP > /dev/null; then
|
||||
N=0
|
||||
while [ ! -e $DEVICE ] && [ $N -lt 25 ]; do
|
||||
sleep 1
|
||||
N=$(expr $N + 1)
|
||||
done
|
||||
chmod 660 "${DEVICE}"
|
||||
chown root:$GROUP "${DEVICE}"
|
||||
fi
|
||||
fi
|
||||
|
@ -0,0 +1,87 @@
|
||||
// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*-
|
||||
/* This file is part of the KDE project
|
||||
Copyright (C) 2000 by Carsten Pfeiffer <pfeiffer@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include <qlabel.h>
|
||||
#include <qlayout.h>
|
||||
#include <qlistview.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qtooltip.h>
|
||||
#include <qwhatsthis.h>
|
||||
#include <qvbuttongroup.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <kiconloader.h>
|
||||
#include <klocale.h>
|
||||
#include <kpopupmenu.h>
|
||||
#include <kwinmodule.h>
|
||||
#include <kregexpeditorinterface.h>
|
||||
#include <kparts/componentfactory.h>
|
||||
|
||||
#include "configdialog.h"
|
||||
|
||||
ConfigDialog::ConfigDialog(KGlobalAccel *accel,
|
||||
bool isApplet )
|
||||
: KDialogBase( Tabbed, i18n("Configure"),
|
||||
Ok | Cancel | Help,
|
||||
Ok, 0L, "config dialog" )
|
||||
{
|
||||
if ( isApplet )
|
||||
setHelp( QString::null, "krandrtray" );
|
||||
|
||||
QFrame *w = 0L; // the parent for the widgets
|
||||
|
||||
w = addVBoxPage( i18n("Global &Shortcuts") );
|
||||
keysWidget = new KKeyChooser( accel, w );
|
||||
}
|
||||
|
||||
|
||||
ConfigDialog::~ConfigDialog()
|
||||
{
|
||||
}
|
||||
|
||||
// prevent huge size due to long regexps in the action-widget
|
||||
void ConfigDialog::show()
|
||||
{
|
||||
if ( !isVisible() ) {
|
||||
KWinModule module(0, KWinModule::INFO_DESKTOP);
|
||||
QSize s1 = sizeHint();
|
||||
QSize s2 = module.workArea().size();
|
||||
int w = s1.width();
|
||||
int h = s1.height();
|
||||
|
||||
if ( s1.width() >= s2.width() )
|
||||
w = s2.width();
|
||||
if ( s1.height() >= s2.height() )
|
||||
h = s2.height();
|
||||
|
||||
resize( w, h );
|
||||
}
|
||||
|
||||
KDialogBase::show();
|
||||
}
|
||||
|
||||
void ConfigDialog::commitShortcuts()
|
||||
{
|
||||
keysWidget->commitChanges();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////
|
||||
////
|
||||
|
||||
#include "configdialog.moc"
|
@ -0,0 +1,88 @@
|
||||
// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*-
|
||||
/* This file is part of the KDE project
|
||||
Copyright (C) 2000 by Carsten Pfeiffer <pfeiffer@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef CONFIGDIALOG_H
|
||||
#define CONFIGDIALOG_H
|
||||
|
||||
#include <qcheckbox.h>
|
||||
#include <qevent.h>
|
||||
#include <qgroupbox.h>
|
||||
#include <qheader.h>
|
||||
#include <qradiobutton.h>
|
||||
#include <qvbox.h>
|
||||
|
||||
#include <kdialogbase.h>
|
||||
#include <keditlistbox.h>
|
||||
#include <kkeydialog.h>
|
||||
#include <klistview.h>
|
||||
#include <knuminput.h>
|
||||
|
||||
class KGlobalAccel;
|
||||
class KKeyChooser;
|
||||
class KListView;
|
||||
class QPushButton;
|
||||
class QDialog;
|
||||
class ConfigDialog;
|
||||
|
||||
class ConfigDialog : public KDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConfigDialog(KGlobalAccel *accel, bool isApplet );
|
||||
~ConfigDialog();
|
||||
|
||||
virtual void show();
|
||||
void commitShortcuts();
|
||||
|
||||
private:
|
||||
KKeyChooser *keysWidget;
|
||||
|
||||
};
|
||||
|
||||
class ListView : public KListView
|
||||
{
|
||||
public:
|
||||
ListView( ConfigDialog* configWidget, QWidget *parent, const char *name )
|
||||
: KListView( parent, name ), _configWidget( configWidget ),
|
||||
_regExpEditor(0L) {}
|
||||
// QListView has a weird idea of a sizeHint...
|
||||
virtual QSize sizeHint () const {
|
||||
int w = minimumSizeHint().width();
|
||||
int h = header()->height();
|
||||
h += viewport()->sizeHint().height();
|
||||
h += horizontalScrollBar()->height();
|
||||
|
||||
QListViewItem *item = firstChild();
|
||||
while ( item ) {
|
||||
h += item->totalHeight();
|
||||
item = item->nextSibling();
|
||||
}
|
||||
|
||||
return QSize( w, h );
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void rename( QListViewItem* item, int c );
|
||||
private:
|
||||
ConfigDialog* _configWidget;
|
||||
QDialog* _regExpEditor;
|
||||
};
|
||||
|
||||
#endif // CONFIGDIALOG_H
|
@ -0,0 +1,34 @@
|
||||
// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*-
|
||||
/* This file is part of the KDE project
|
||||
Copyright (C) by Andrew Stanley-Jones
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef NOSLOTS
|
||||
# define DEF( name, key3, key4, fnSlot ) \
|
||||
keys->insert( name, i18n(name), QString::null, key3, key4, this, SLOT(fnSlot) )
|
||||
#else
|
||||
# define DEF( name, key3, key4, fnSlot ) \
|
||||
keys->insert( name, i18n(name), QString::null, key3, key4 )
|
||||
#endif
|
||||
#define WIN KKey::QtWIN
|
||||
|
||||
keys->insert( "Program:krandrtray", i18n("Display Control") );
|
||||
|
||||
DEF( I18N_NOOP("Switch Displays"), KShortcut::KShortcut(QString("XF86Display")), KShortcut::KShortcut(QString("XF86Display")), slotCycleDisplays() );
|
||||
|
||||
#undef DEF
|
||||
#undef WIN
|
@ -0,0 +1,700 @@
|
||||
/*
|
||||
* Copyright © 2007 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#include "lowlevel_randr.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
Status crtc_disable (struct CrtcInfo *crtc);
|
||||
|
||||
char * get_output_name (struct ScreenInfo *screen_info, RROutput id)
|
||||
{
|
||||
char *output_name = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < screen_info->n_output; i++) {
|
||||
if (id == screen_info->outputs[i]->id) {
|
||||
output_name = screen_info->outputs[i]->info->name;
|
||||
}
|
||||
}
|
||||
|
||||
if (!output_name) {
|
||||
output_name = "Unknown";
|
||||
}
|
||||
|
||||
return output_name;
|
||||
}
|
||||
|
||||
XRRModeInfo * find_mode_by_xid (struct ScreenInfo *screen_info, RRMode mode_id)
|
||||
{
|
||||
XRRModeInfo *mode_info = NULL;
|
||||
XRRScreenResources *res;
|
||||
int i;
|
||||
|
||||
res = screen_info->res;
|
||||
for (i = 0; i < res->nmode; i++) {
|
||||
if (mode_id == res->modes[i].id) {
|
||||
mode_info = &res->modes[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return mode_info;
|
||||
}
|
||||
|
||||
static XRRCrtcInfo * find_crtc_by_xid (struct ScreenInfo *screen_info, RRCrtc crtc_id)
|
||||
{
|
||||
XRRCrtcInfo *crtc_info;
|
||||
Display *dpy;
|
||||
XRRScreenResources *res;
|
||||
|
||||
dpy = screen_info->dpy;
|
||||
res = screen_info->res;
|
||||
|
||||
crtc_info = XRRGetCrtcInfo (dpy, res, crtc_id);
|
||||
|
||||
return crtc_info;
|
||||
}
|
||||
|
||||
int get_width_by_output_id (struct ScreenInfo *screen_info, RROutput output_id)
|
||||
{
|
||||
struct OutputInfo *output_info;
|
||||
struct CrtcInfo *crtc_info;
|
||||
RRMode mode_id;
|
||||
XRRModeInfo *mode_info;
|
||||
int i;
|
||||
int width = -1;
|
||||
|
||||
for (i = 0; i < screen_info->n_output; i++) {
|
||||
if (output_id == screen_info->outputs[i]->id) {
|
||||
crtc_info = screen_info->outputs[i]->cur_crtc;
|
||||
if (!crtc_info) {
|
||||
width = 0;
|
||||
break;
|
||||
}
|
||||
mode_id = crtc_info->cur_mode_id;
|
||||
mode_info = find_mode_by_xid (screen_info, mode_id);
|
||||
|
||||
width = mode_width (mode_info, crtc_info->cur_rotation);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
int get_height_by_output_id (struct ScreenInfo *screen_info, RROutput output_id)
|
||||
{
|
||||
struct OutputInfo *output_info;
|
||||
struct CrtcInfo *crtc_info;
|
||||
RRMode mode_id;
|
||||
XRRModeInfo *mode_info;
|
||||
int i;
|
||||
int height = -1;
|
||||
|
||||
for (i = 0; i < screen_info->n_output; i++) {
|
||||
if (output_id == screen_info->outputs[i]->id) {
|
||||
crtc_info = screen_info->outputs[i]->cur_crtc;
|
||||
if (!crtc_info) {
|
||||
height = 0;
|
||||
break;
|
||||
}
|
||||
mode_id = crtc_info->cur_mode_id;
|
||||
mode_info = find_mode_by_xid (screen_info, mode_id);
|
||||
|
||||
height = mode_height (mode_info, crtc_info->cur_rotation);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
int mode_height (XRRModeInfo *mode_info, Rotation rotation)
|
||||
{
|
||||
switch (rotation & 0xf) {
|
||||
case RR_Rotate_0:
|
||||
case RR_Rotate_180:
|
||||
return mode_info->height;
|
||||
case RR_Rotate_90:
|
||||
case RR_Rotate_270:
|
||||
return mode_info->width;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int mode_width (XRRModeInfo *mode_info, Rotation rotation)
|
||||
{
|
||||
switch (rotation & 0xf) {
|
||||
case RR_Rotate_0:
|
||||
case RR_Rotate_180:
|
||||
return mode_info->width;
|
||||
case RR_Rotate_90:
|
||||
case RR_Rotate_270:
|
||||
return mode_info->height;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static struct CrtcInfo * find_crtc (struct ScreenInfo *screen_info, XRROutputInfo *output)
|
||||
{
|
||||
struct CrtcInfo *crtc_info = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < screen_info->n_crtc; i++) {
|
||||
if (screen_info->crtcs[i]->id == output->crtc) {
|
||||
crtc_info = screen_info->crtcs[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return crtc_info;
|
||||
}
|
||||
|
||||
struct CrtcInfo * auto_find_crtc (struct ScreenInfo *screen_info, struct OutputInfo *output_info)
|
||||
{
|
||||
struct CrtcInfo *crtc_info = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < screen_info->n_crtc; i++) {
|
||||
if (0 == screen_info->crtcs[i]->cur_noutput) {
|
||||
crtc_info = screen_info->crtcs[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == crtc_info) {
|
||||
crtc_info = screen_info->crtcs[0];
|
||||
}
|
||||
|
||||
return crtc_info;
|
||||
}
|
||||
|
||||
int set_screen_size (struct ScreenInfo *screen_info)
|
||||
{
|
||||
Display *dpy;
|
||||
int screen;
|
||||
struct CrtcInfo *crtc;
|
||||
XRRModeInfo *mode_info;
|
||||
int cur_x = 0, cur_y = 0;
|
||||
int w = 0, h = 0;
|
||||
int mmW, mmH;
|
||||
int max_width = 0, max_height = 0;
|
||||
int i;
|
||||
|
||||
dpy = screen_info->dpy;
|
||||
screen = DefaultScreen (dpy);
|
||||
|
||||
for (i = 0; i < screen_info->n_crtc; i++) {
|
||||
crtc = screen_info->crtcs[i];
|
||||
if (!crtc->cur_mode_id) {
|
||||
continue;
|
||||
}
|
||||
mode_info = find_mode_by_xid (screen_info, crtc->cur_mode_id);
|
||||
cur_x = crtc->cur_x;
|
||||
cur_y = crtc->cur_y;
|
||||
|
||||
w = mode_width (mode_info, crtc->cur_rotation);
|
||||
h = mode_height (mode_info, crtc->cur_rotation);
|
||||
|
||||
if (cur_x + w > max_width) {
|
||||
max_width = cur_x + w;
|
||||
}
|
||||
if (cur_y + h > max_height) {
|
||||
max_height = cur_y + h;
|
||||
}
|
||||
}
|
||||
|
||||
if (max_width > screen_info->max_width) {
|
||||
#if RANDR_GUI_DEBUG
|
||||
fprintf (stderr, "user set screen width %d, larger than max width %d, set to max width\n",
|
||||
cur_x + w, screen_info->max_width);
|
||||
#endif
|
||||
return 0;
|
||||
} else if (max_width < screen_info->min_width) {
|
||||
screen_info->cur_width = screen_info->min_width;
|
||||
} else {
|
||||
screen_info->cur_width = max_width;
|
||||
}
|
||||
|
||||
if (max_height > screen_info->max_height) {
|
||||
#if RANDR_GUI_DEBUG
|
||||
fprintf (stderr, "user set screen height %d, larger than max height %d, set to max height\n",
|
||||
cur_y + h, screen_info->max_height);
|
||||
#endif
|
||||
return 0;
|
||||
} else if (max_height < screen_info->min_height) {
|
||||
screen_info->cur_height = screen_info->min_height;
|
||||
} else {
|
||||
screen_info->cur_height = max_height;
|
||||
}
|
||||
|
||||
/* calculate mmWidth, mmHeight */
|
||||
if (screen_info->cur_width != DisplayWidth (dpy, screen) ||
|
||||
screen_info->cur_height != DisplayHeight (dpy, screen) ) {
|
||||
double dpi;
|
||||
|
||||
dpi = (25.4 * DisplayHeight (dpy, screen)) / DisplayHeightMM(dpy, screen);
|
||||
mmW = (25.4 * screen_info->cur_width) / dpi;
|
||||
mmH = (25.4 * screen_info->cur_height) / dpi;
|
||||
} else {
|
||||
mmW = DisplayWidthMM (dpy, screen);
|
||||
mmH = DisplayHeightMM (dpy, screen);
|
||||
}
|
||||
|
||||
screen_info->cur_mmWidth = mmW;
|
||||
screen_info->cur_mmHeight = mmH;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void screen_apply (struct ScreenInfo *screen_info)
|
||||
{
|
||||
int width, height;
|
||||
int mmWidth, mmHeight;
|
||||
Display *dpy, *cur_dpy;
|
||||
Window window;
|
||||
int screen;
|
||||
static int first = 1;
|
||||
|
||||
width = screen_info->cur_width;
|
||||
height = screen_info->cur_height;
|
||||
mmWidth = screen_info->cur_mmWidth;
|
||||
mmHeight = screen_info->cur_mmHeight;
|
||||
dpy = screen_info->dpy;
|
||||
window = screen_info->window;
|
||||
screen = DefaultScreen (dpy);
|
||||
|
||||
cur_dpy = XOpenDisplay (NULL);
|
||||
|
||||
if (width == DisplayWidth (cur_dpy, screen) &&
|
||||
height == DisplayHeight (cur_dpy, screen) &&
|
||||
mmWidth == DisplayWidthMM (cur_dpy, screen) &&
|
||||
mmHeight == DisplayHeightMM (cur_dpy, screen) ) {
|
||||
return;
|
||||
} else {
|
||||
XRRSetScreenSize (dpy, window, width, height, mmWidth, mmHeight);
|
||||
}
|
||||
}
|
||||
|
||||
Status crtc_apply (struct CrtcInfo *crtc_info)
|
||||
{
|
||||
struct ScreenInfo *screen_info;
|
||||
XRRCrtcInfo *rr_crtc_info;
|
||||
Display *dpy;
|
||||
XRRScreenResources *res;
|
||||
RRCrtc crtc_id;
|
||||
int x, y;
|
||||
RRMode mode_id;
|
||||
Rotation rotation;
|
||||
RROutput *outputs;
|
||||
int noutput;
|
||||
Status s;
|
||||
int i;
|
||||
|
||||
/*if (!crtc_info->changed) {
|
||||
return RRSetConfigSuccess;
|
||||
}*/
|
||||
|
||||
screen_info = crtc_info->screen_info;
|
||||
dpy = screen_info->dpy;
|
||||
res = screen_info->res;
|
||||
crtc_id = crtc_info->id;
|
||||
x = crtc_info->cur_x;
|
||||
y = crtc_info->cur_y;
|
||||
|
||||
mode_id = crtc_info->cur_mode_id;
|
||||
rotation = crtc_info->cur_rotation;
|
||||
|
||||
noutput = crtc_info->cur_noutput;
|
||||
|
||||
if (0 == noutput) {
|
||||
return crtc_disable (crtc_info);
|
||||
}
|
||||
|
||||
outputs = malloc (sizeof (RROutput) * noutput);
|
||||
noutput = 0;
|
||||
for (i = 0; i < screen_info->n_output; i++) {
|
||||
struct OutputInfo *output_info = screen_info->outputs[i];
|
||||
|
||||
if (output_info->cur_crtc && crtc_id == output_info->cur_crtc->id) {
|
||||
outputs[noutput++] = output_info->id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
s = XRRSetCrtcConfig (dpy, res, crtc_id, CurrentTime,
|
||||
x, y, mode_id, rotation,
|
||||
outputs, noutput);
|
||||
|
||||
if (RRSetConfigSuccess == s) {
|
||||
crtc_info->changed = 0;
|
||||
}
|
||||
|
||||
free (outputs);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
Status crtc_disable (struct CrtcInfo *crtc)
|
||||
{
|
||||
struct ScreenInfo *screen_info;
|
||||
|
||||
screen_info = crtc->screen_info;
|
||||
|
||||
return XRRSetCrtcConfig (screen_info->dpy, screen_info->res, crtc->id, CurrentTime,
|
||||
0, 0, None, RR_Rotate_0, NULL, 0);
|
||||
}
|
||||
|
||||
struct ScreenInfo* read_screen_info (Display *display)
|
||||
{
|
||||
struct ScreenInfo *screen_info;
|
||||
int screen_num;
|
||||
Window root_window;
|
||||
XRRScreenResources *sr;
|
||||
int i;
|
||||
|
||||
screen_num = DefaultScreen (display);
|
||||
root_window = RootWindow (display, screen_num);
|
||||
|
||||
sr = XRRGetScreenResources (display, root_window);
|
||||
|
||||
screen_info = malloc (sizeof (struct ScreenInfo));
|
||||
screen_info->dpy = display;
|
||||
screen_info->window = root_window;
|
||||
screen_info->res = sr;
|
||||
screen_info->cur_width = DisplayWidth (display, screen_num);
|
||||
screen_info->cur_height = DisplayHeight (display, screen_num);
|
||||
screen_info->cur_mmWidth = DisplayWidthMM (display, screen_num);
|
||||
screen_info->cur_mmHeight = DisplayHeightMM (display, screen_num);
|
||||
screen_info->n_output = sr->noutput;
|
||||
screen_info->n_crtc = sr->ncrtc;
|
||||
screen_info->outputs = malloc (sizeof (struct OutputInfo *) * sr->noutput);
|
||||
screen_info->crtcs = malloc (sizeof (struct CrtcInfo *) * sr->ncrtc);
|
||||
screen_info->clone = 0;
|
||||
|
||||
XRRGetScreenSizeRange (display, root_window, &screen_info->min_width, &screen_info->min_height, &screen_info->max_width, &screen_info->max_height);
|
||||
|
||||
/* get crtc */
|
||||
for (i = 0; i < sr->ncrtc; i++) {
|
||||
struct CrtcInfo *crtc_info;
|
||||
screen_info->crtcs[i] = malloc (sizeof (struct CrtcInfo));
|
||||
crtc_info = screen_info->crtcs[i];
|
||||
XRRCrtcInfo *xrr_crtc_info = XRRGetCrtcInfo (display, sr, sr->crtcs[i]);
|
||||
|
||||
crtc_info->id = sr->crtcs[i];
|
||||
crtc_info->info = xrr_crtc_info;
|
||||
crtc_info->cur_x = xrr_crtc_info->x;
|
||||
crtc_info->cur_y = xrr_crtc_info->y;
|
||||
crtc_info->cur_mode_id = xrr_crtc_info->mode;
|
||||
crtc_info->cur_rotation = xrr_crtc_info->rotation;
|
||||
crtc_info->rotations = xrr_crtc_info->rotations;
|
||||
crtc_info->cur_noutput = xrr_crtc_info->noutput;
|
||||
|
||||
crtc_info->changed = 0;
|
||||
crtc_info->screen_info = screen_info;
|
||||
}
|
||||
|
||||
|
||||
/* get output */
|
||||
for (i = 0; i < sr->noutput; i++) {
|
||||
struct OutputInfo *output;
|
||||
screen_info->outputs[i] = malloc (sizeof (struct OutputInfo));
|
||||
output = screen_info->outputs[i];
|
||||
|
||||
output->id = sr->outputs[i];
|
||||
output->info = XRRGetOutputInfo (display, sr, sr->outputs[i]);
|
||||
output->cur_crtc = find_crtc (screen_info, output->info);
|
||||
output->auto_set = 0;
|
||||
if (output->cur_crtc) {
|
||||
output->off_set = 0;
|
||||
} else {
|
||||
output->off_set = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* set current crtc */
|
||||
screen_info->cur_crtc = screen_info->outputs[0]->cur_crtc;
|
||||
screen_info->primary_crtc = screen_info->cur_crtc;
|
||||
screen_info->cur_output = screen_info->outputs[0];
|
||||
|
||||
return screen_info;
|
||||
}
|
||||
|
||||
void free_screen_info (struct ScreenInfo *screen_info)
|
||||
{
|
||||
free (screen_info->outputs);
|
||||
free (screen_info->crtcs);
|
||||
free (screen_info);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static char * get_mode_name (struct ScreenInfo *screen_info, RRMode mode_id)
|
||||
{
|
||||
XRRScreenResources *sr;
|
||||
char *mode_name = NULL;
|
||||
int i;
|
||||
|
||||
sr = screen_info->res;
|
||||
|
||||
for (i = 0; i < sr->nmode; i++) {
|
||||
if (sr->modes[i].id == mode_id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == sr->nmode) {
|
||||
mode_name = g_strdup ("Unknown mode");
|
||||
} else {
|
||||
double rate;
|
||||
if (sr->modes[i].hTotal && sr->modes[i].vTotal) {
|
||||
rate = ((double) sr->modes[i].dotClock /
|
||||
((double) sr->modes[i].hTotal * (double) sr->modes[i].vTotal));
|
||||
} else {
|
||||
rate = 0;
|
||||
}
|
||||
mode_name = g_strdup_printf ("%s%6.1fHz", sr->modes[i].name, rate);
|
||||
}
|
||||
|
||||
return mode_name;
|
||||
}
|
||||
|
||||
/*check if other outputs that connected to the same crtc support this mode*/
|
||||
static int check_mode (struct ScreenInfo *screen_info, struct OutputInfo *output, RRMode mode_id)
|
||||
{
|
||||
XRRCrtcInfo *crtc_info;
|
||||
/* XRR */
|
||||
int i, j;
|
||||
int mode_ok = 1;
|
||||
|
||||
if (!output->cur_crtc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
crtc_info = output->cur_crtc->info;
|
||||
for (i = 0; i < crtc_info->noutput; i++) {
|
||||
XRROutputInfo *output_info;
|
||||
int nmode;
|
||||
|
||||
if (output->id == crtc_info->outputs[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mode_ok = 0;
|
||||
output_info = XRRGetOutputInfo (screen_info->dpy, screen_info->res, crtc_info->outputs[i]);
|
||||
nmode = output_info->nmode;
|
||||
for (j = 0; j < nmode; j++) {
|
||||
if (mode_id == output_info->modes[j]) {
|
||||
mode_ok = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!mode_ok) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return mode_ok;
|
||||
}
|
||||
|
||||
static RRCrtc get_crtc_id_by_output_id (struct ScreenInfo *screen_info, RROutput output_id)
|
||||
{
|
||||
int i;
|
||||
RRCrtc crtc_id = -1;
|
||||
|
||||
for (i = 0; i < screen_info->n_output; i++) {
|
||||
if (output_id == screen_info->outputs[i]->id) {
|
||||
if (screen_info->outputs[i]->cur_crtc) {
|
||||
crtc_id = screen_info->outputs[i]->cur_crtc->id;
|
||||
} else {
|
||||
crtc_id = 0; /* this output is off */
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return crtc_id;
|
||||
}
|
||||
|
||||
static struct CrtcInfo *
|
||||
get_crtc_info_by_xid (struct ScreenInfo *screen_info, RRCrtc crtc_id)
|
||||
{
|
||||
struct CrtcInfo *crtc_info = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < screen_info->n_crtc; i++) {
|
||||
if (crtc_id == screen_info->crtcs[i]->id) {
|
||||
crtc_info = screen_info->crtcs[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return crtc_info;
|
||||
}
|
||||
|
||||
static XRRModeInfo *
|
||||
preferred_mode (struct ScreenInfo *screen_info, struct OutputInfo *output)
|
||||
{
|
||||
XRROutputInfo *output_info = output->info;
|
||||
Display *dpy;
|
||||
int screen;
|
||||
int m;
|
||||
XRRModeInfo *best;
|
||||
int bestDist;
|
||||
|
||||
dpy = screen_info->dpy;
|
||||
screen = DefaultScreen (dpy);
|
||||
best = NULL;
|
||||
bestDist = 0;
|
||||
for (m = 0; m < output_info->nmode; m++) {
|
||||
XRRModeInfo *mode_info = find_mode_by_xid (screen_info, output_info->modes[m]);
|
||||
int dist;
|
||||
|
||||
if (m < output_info->npreferred)
|
||||
dist = 0;
|
||||
else if (output_info->mm_height)
|
||||
dist = (1000 * DisplayHeight(dpy, screen) / DisplayHeightMM(dpy, screen) -
|
||||
1000 * mode_info->height / output_info->mm_height);
|
||||
else
|
||||
dist = DisplayHeight(dpy, screen) - mode_info->height;
|
||||
|
||||
if (dist < 0) dist = -dist;
|
||||
if (!best || dist < bestDist) {
|
||||
best = mode_info;
|
||||
bestDist = dist;
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
int main_low_apply (struct ScreenInfo *screen_info)
|
||||
{
|
||||
int i;
|
||||
struct CrtcInfo *crtc_info;
|
||||
|
||||
/* set_positions (screen_info); */
|
||||
|
||||
if (!set_screen_size (screen_info)) {
|
||||
printf("Screen Size FAILURE\n\r");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < screen_info->n_crtc; i++) {
|
||||
int old_x, old_y, old_w, old_h;
|
||||
|
||||
XRRCrtcInfo *crtc_info = XRRGetCrtcInfo (screen_info->dpy, screen_info->res, screen_info->crtcs[i]->id);
|
||||
XRRModeInfo *old_mode = find_mode_by_xid (screen_info, crtc_info->mode);
|
||||
|
||||
if (crtc_info->mode == None) {
|
||||
continue;
|
||||
}
|
||||
|
||||
old_x = crtc_info->x;
|
||||
old_y = crtc_info->y;
|
||||
old_w = mode_width (old_mode, crtc_info->rotation);
|
||||
old_h = mode_height (old_mode, crtc_info->rotation);
|
||||
|
||||
if (old_x + old_w <= screen_info->cur_width &&
|
||||
old_y + old_h <= screen_info->cur_height ) {
|
||||
continue;
|
||||
} else {
|
||||
crtc_disable (screen_info->crtcs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
screen_apply (screen_info);
|
||||
|
||||
for (i = 0; i < screen_info->n_crtc; i++) {
|
||||
Status s;
|
||||
crtc_info = screen_info->crtcs[i];
|
||||
|
||||
s = crtc_apply (crtc_info);
|
||||
if (RRSetConfigSuccess != s) {
|
||||
fprintf (stderr, "crtc apply error\n");
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void output_auto (struct ScreenInfo *screen_info, struct OutputInfo *output_info)
|
||||
{
|
||||
XRRModeInfo *mode_info;
|
||||
RRMode mode_id;
|
||||
struct CrtcInfo *crtc_info;
|
||||
XRROutputInfo *probe_output_info;
|
||||
|
||||
if (RR_Disconnected == output_info->info->connection) {
|
||||
XRRScreenResources *cur_res;
|
||||
|
||||
cur_res = XRRGetScreenResources (screen_info->dpy, screen_info->window);
|
||||
probe_output_info = XRRGetOutputInfo (screen_info->dpy, cur_res, output_info->id);
|
||||
if (RR_Disconnected != probe_output_info->connection) {
|
||||
output_info->info = probe_output_info;
|
||||
output_info->cur_crtc = auto_find_crtc (screen_info, output_info);
|
||||
}
|
||||
}
|
||||
|
||||
mode_info = preferred_mode (screen_info, output_info);
|
||||
if (!mode_info) {
|
||||
return;
|
||||
}
|
||||
mode_id = mode_info->id;
|
||||
|
||||
crtc_info = output_info->cur_crtc;
|
||||
if (crtc_info) {
|
||||
crtc_info->cur_mode_id = mode_id;
|
||||
} else {
|
||||
crtc_info = auto_find_crtc (screen_info, output_info);
|
||||
if (!crtc_info) {
|
||||
#if RANDR_GUI_DEBUG
|
||||
fprintf (stderr, "Can not find usable CRTC\n");
|
||||
#endif
|
||||
return;
|
||||
} else {
|
||||
screen_info->cur_output->cur_crtc = crtc_info;
|
||||
screen_info->cur_crtc = crtc_info;
|
||||
screen_info->cur_crtc->cur_noutput++;
|
||||
fprintf (stderr, "n output: %d\n", screen_info->cur_crtc->cur_noutput);
|
||||
screen_info->cur_crtc->cur_mode_id = mode_id;
|
||||
screen_info->cur_crtc->changed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void output_off (struct ScreenInfo *screen_info, struct OutputInfo *output)
|
||||
{
|
||||
if (output->cur_crtc) {
|
||||
output->cur_crtc->cur_noutput--;
|
||||
}
|
||||
output->cur_crtc = NULL;
|
||||
screen_info->cur_crtc = NULL;
|
||||
output->off_set = 1;
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright © 2007 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
|
||||
struct ScreenInfo;
|
||||
|
||||
struct CrtcInfo {
|
||||
RRCrtc id;
|
||||
XRRCrtcInfo *info;
|
||||
int cur_x;
|
||||
int cur_y;
|
||||
RRMode cur_mode_id;
|
||||
Rotation cur_rotation;
|
||||
Rotation rotations;
|
||||
int cur_noutput;
|
||||
|
||||
int changed;
|
||||
|
||||
struct ScreenInfo *screen_info;
|
||||
};
|
||||
|
||||
struct OutputInfo {
|
||||
RROutput id;
|
||||
XRROutputInfo *info;
|
||||
struct CrtcInfo *cur_crtc;
|
||||
|
||||
int auto_set;
|
||||
int off_set;
|
||||
};
|
||||
|
||||
struct ScreenInfo {
|
||||
Display *dpy;
|
||||
Window window;
|
||||
XRRScreenResources *res;
|
||||
int min_width, min_height;
|
||||
int max_width, max_height;
|
||||
int cur_width;
|
||||
int cur_height;
|
||||
int cur_mmWidth;
|
||||
int cur_mmHeight;
|
||||
|
||||
int n_output;
|
||||
int n_crtc;
|
||||
struct OutputInfo **outputs;
|
||||
struct CrtcInfo **crtcs;
|
||||
|
||||
int clone;
|
||||
struct CrtcInfo *primary_crtc;
|
||||
|
||||
struct CrtcInfo *cur_crtc;
|
||||
struct OutputInfo *cur_output;
|
||||
};
|
||||
|
||||
extern struct ScreenInfo *screen_info;
|
||||
extern const uint big_pixbuf[], small_pixbuf[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void free_screen_info (struct ScreenInfo *screen_info);
|
||||
|
||||
struct ScreenInfo* read_screen_info (Display *);
|
||||
|
||||
int set_screen_size (struct ScreenInfo *screen_info);
|
||||
void output_auto (struct ScreenInfo *screen_info, struct OutputInfo *output_info);
|
||||
void output_off (struct ScreenInfo *screen_info, struct OutputInfo *output);
|
||||
struct CrtcInfo* auto_find_crtc (struct ScreenInfo *screen_info, struct OutputInfo *output_info);
|
||||
|
||||
XRRModeInfo *find_mode_by_xid (struct ScreenInfo *screen_info, RRMode mode_id);
|
||||
int mode_height (XRRModeInfo *mode_info, Rotation rotation);
|
||||
int mode_width (XRRModeInfo *mode_info, Rotation rotation);
|
||||
int get_width_by_output_id (struct ScreenInfo *screen_info, RROutput output_id);
|
||||
int get_height_by_output_id (struct ScreenInfo *screen_info, RROutput output_id);
|
||||
char *get_output_name (struct ScreenInfo *screen_info, RROutput id);
|
||||
Status crtc_apply (struct CrtcInfo *crtc_info);
|
||||
Status crtc_disable (struct CrtcInfo *crtc);
|
||||
int main_low_apply (struct ScreenInfo *screen_info);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,557 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
*
|
||||
* Copyright (C) 2006-2007 William Jon McCann <mccann@jhu.edu>
|
||||
* Copyright (C) 2007 Kevin Kofler <Kevin@tigcc.ticalc.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "dm.h"
|
||||
#include "dm_auth.h"
|
||||
#include "dm_error.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#define DBUS_API_SUBJECT_TO_CHANGE
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#include "consolekit.h"
|
||||
|
||||
|
||||
#define CK_NAME "org.freedesktop.ConsoleKit"
|
||||
#define CK_PATH "/org/freedesktop/ConsoleKit"
|
||||
#define CK_INTERFACE "org.freedesktop.ConsoleKit"
|
||||
#define CK_MANAGER_PATH "/org/freedesktop/ConsoleKit/Manager"
|
||||
#define CK_MANAGER_INTERFACE "org.freedesktop.ConsoleKit.Manager"
|
||||
#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
|
||||
|
||||
static DBusConnection *private_connection = NULL;
|
||||
|
||||
static void
|
||||
add_param_int (DBusMessageIter *iter_struct,
|
||||
const char *key,
|
||||
int value)
|
||||
{
|
||||
DBusMessageIter iter_struct_entry;
|
||||
DBusMessageIter iter_var;
|
||||
|
||||
dbus_message_iter_open_container (iter_struct,
|
||||
DBUS_TYPE_STRUCT,
|
||||
NULL,
|
||||
&iter_struct_entry);
|
||||
|
||||
dbus_message_iter_append_basic (&iter_struct_entry,
|
||||
DBUS_TYPE_STRING,
|
||||
&key);
|
||||
|
||||
dbus_message_iter_open_container (&iter_struct_entry,
|
||||
DBUS_TYPE_VARIANT,
|
||||
DBUS_TYPE_INT32_AS_STRING,
|
||||
&iter_var);
|
||||
|
||||
dbus_message_iter_append_basic (&iter_var,
|
||||
DBUS_TYPE_INT32,
|
||||
&value);
|
||||
|
||||
dbus_message_iter_close_container (&iter_struct_entry,
|
||||
&iter_var);
|
||||
|
||||
dbus_message_iter_close_container (iter_struct, &iter_struct_entry);
|
||||
}
|
||||
|
||||
static void
|
||||
add_param_boolean (DBusMessageIter *iter_struct,
|
||||
const char *key,
|
||||
int value)
|
||||
{
|
||||
DBusMessageIter iter_struct_entry;
|
||||
DBusMessageIter iter_var;
|
||||
|
||||
dbus_message_iter_open_container (iter_struct,
|
||||
DBUS_TYPE_STRUCT,
|
||||
NULL,
|
||||
&iter_struct_entry);
|
||||
|
||||
dbus_message_iter_append_basic (&iter_struct_entry,
|
||||
DBUS_TYPE_STRING,
|
||||
&key);
|
||||
|
||||
dbus_message_iter_open_container (&iter_struct_entry,
|
||||
DBUS_TYPE_VARIANT,
|
||||
DBUS_TYPE_BOOLEAN_AS_STRING,
|
||||
&iter_var);
|
||||
|
||||
dbus_message_iter_append_basic (&iter_var,
|
||||
DBUS_TYPE_BOOLEAN,
|
||||
&value);
|
||||
|
||||
dbus_message_iter_close_container (&iter_struct_entry,
|
||||
&iter_var);
|
||||
|
||||
dbus_message_iter_close_container (iter_struct, &iter_struct_entry);
|
||||
}
|
||||
|
||||
static void
|
||||
add_param_string (DBusMessageIter *iter_struct,
|
||||
const char *key,
|
||||
const char *value)
|
||||
{
|
||||
DBusMessageIter iter_struct_entry;
|
||||
DBusMessageIter iter_var;
|
||||
|
||||
dbus_message_iter_open_container (iter_struct,
|
||||
DBUS_TYPE_STRUCT,
|
||||
NULL,
|
||||
&iter_struct_entry);
|
||||
|
||||
dbus_message_iter_append_basic (&iter_struct_entry,
|
||||
DBUS_TYPE_STRING,
|
||||
&key);
|
||||
|
||||
dbus_message_iter_open_container (&iter_struct_entry,
|
||||
DBUS_TYPE_VARIANT,
|
||||
DBUS_TYPE_STRING_AS_STRING,
|
||||
&iter_var);
|
||||
|
||||
dbus_message_iter_append_basic (&iter_var,
|
||||
DBUS_TYPE_STRING,
|
||||
&value);
|
||||
|
||||
dbus_message_iter_close_container (&iter_struct_entry,
|
||||
&iter_var);
|
||||
|
||||
dbus_message_iter_close_container (iter_struct, &iter_struct_entry);
|
||||
}
|
||||
|
||||
static int
|
||||
session_get_x11_display (DBusConnection *connection,
|
||||
const char *ssid,
|
||||
char **str)
|
||||
{
|
||||
DBusError error;
|
||||
DBusMessage *message;
|
||||
DBusMessage *reply;
|
||||
DBusMessageIter iter;
|
||||
const char *value;
|
||||
|
||||
if (str != NULL) {
|
||||
*str = NULL;
|
||||
}
|
||||
|
||||
message = dbus_message_new_method_call (CK_NAME,
|
||||
ssid,
|
||||
CK_SESSION_INTERFACE,
|
||||
"GetX11Display");
|
||||
if (message == NULL) {
|
||||
Debug ("ConsoleKit: Couldn't allocate the D-Bus message");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
dbus_error_init (&error);
|
||||
reply = dbus_connection_send_with_reply_and_block (connection,
|
||||
message,
|
||||
-1, &error);
|
||||
if (dbus_error_is_set (&error)) {
|
||||
Debug ("ConsoleKit: %s raised:\n %s\n\n", error.name, error.message);
|
||||
reply = NULL;
|
||||
}
|
||||
|
||||
dbus_connection_flush (connection);
|
||||
dbus_message_unref (message);
|
||||
|
||||
if (reply == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
dbus_message_iter_init (reply, &iter);
|
||||
dbus_message_iter_get_basic (&iter, &value);
|
||||
if (str != NULL) {
|
||||
*str = strdup (value);
|
||||
}
|
||||
dbus_message_unref (reply);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
session_unlock (DBusConnection *connection,
|
||||
const char *ssid)
|
||||
{
|
||||
DBusError error;
|
||||
DBusMessage *message;
|
||||
DBusMessage *reply;
|
||||
|
||||
Debug ("ConsoleKit: Unlocking session %s", ssid);
|
||||
message = dbus_message_new_method_call (CK_NAME,
|
||||
ssid,
|
||||
CK_SESSION_INTERFACE,
|
||||
"Unlock");
|
||||
if (message == NULL) {
|
||||
Debug ("ConsoleKit: Couldn't allocate the D-Bus message");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
dbus_error_init (&error);
|
||||
reply = dbus_connection_send_with_reply_and_block (connection,
|
||||
message,
|
||||
-1, &error);
|
||||
dbus_message_unref (message);
|
||||
dbus_message_unref (reply);
|
||||
dbus_connection_flush (connection);
|
||||
|
||||
if (dbus_error_is_set (&error)) {
|
||||
Debug ("ConsoleKit: %s raised:\n %s\n\n", error.name, error.message);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* from libhal */
|
||||
static char **
|
||||
get_path_array_from_iter (DBusMessageIter *iter,
|
||||
int *num_elements)
|
||||
{
|
||||
int count;
|
||||
char **buffer;
|
||||
|
||||
count = 0;
|
||||
buffer = (char **)malloc (sizeof (char *) * 8);
|
||||
|
||||
if (buffer == NULL)
|
||||
goto oom;
|
||||
|
||||
buffer[0] = NULL;
|
||||
while (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_OBJECT_PATH) {
|
||||
const char *value;
|
||||
char *str;
|
||||
|
||||
if ((count % 8) == 0 && count != 0) {
|
||||
buffer = realloc (buffer, sizeof (char *) * (count + 8));
|
||||
if (buffer == NULL)
|
||||
goto oom;
|
||||
}
|
||||
|
||||
dbus_message_iter_get_basic (iter, &value);
|
||||
str = strdup (value);
|
||||
if (str == NULL)
|
||||
goto oom;
|
||||
|
||||
buffer[count] = str;
|
||||
|
||||
dbus_message_iter_next (iter);
|
||||
count++;
|
||||
}
|
||||
|
||||
if ((count % 8) == 0) {
|
||||
buffer = realloc (buffer, sizeof (char *) * (count + 1));
|
||||
if (buffer == NULL)
|
||||
goto oom;
|
||||
}
|
||||
|
||||
buffer[count] = NULL;
|
||||
if (num_elements != NULL)
|
||||
*num_elements = count;
|
||||
return buffer;
|
||||
|
||||
oom:
|
||||
LogWarn ("%s %d : error allocating memory\n", __FILE__, __LINE__);
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
static char **
|
||||
get_sessions_for_user (DBusConnection *connection,
|
||||
const char *user,
|
||||
const char *x11_display)
|
||||
{
|
||||
DBusError error;
|
||||
DBusMessage *message;
|
||||
DBusMessage *reply;
|
||||
DBusMessageIter iter;
|
||||
DBusMessageIter iter_reply;
|
||||
DBusMessageIter iter_array;
|
||||
struct passwd *pwent;
|
||||
char **sessions;
|
||||
|
||||
sessions = NULL;
|
||||
message = NULL;
|
||||
reply = NULL;
|
||||
|
||||
pwent = getpwnam (user);
|
||||
|
||||
dbus_error_init (&error);
|
||||
message = dbus_message_new_method_call (CK_NAME,
|
||||
CK_MANAGER_PATH,
|
||||
CK_MANAGER_INTERFACE,
|
||||
"GetSessionsForUser");
|
||||
if (message == NULL) {
|
||||
Debug ("ConsoleKit: Couldn't allocate the D-Bus message");
|
||||
goto out;
|
||||
}
|
||||
|
||||
dbus_message_iter_init_append (message, &iter);
|
||||
dbus_message_iter_append_basic (&iter,
|
||||
DBUS_TYPE_UINT32,
|
||||
&pwent->pw_uid);
|
||||
|
||||
dbus_error_init (&error);
|
||||
reply = dbus_connection_send_with_reply_and_block (connection,
|
||||
message,
|
||||
-1, &error);
|
||||
dbus_connection_flush (connection);
|
||||
|
||||
if (dbus_error_is_set (&error)) {
|
||||
Debug ("ConsoleKit: %s raised:\n %s\n\n", error.name, error.message);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (reply == NULL) {
|
||||
Debug ("ConsoleKit: No reply for GetSessionsForUser");
|
||||
goto out;
|
||||
}
|
||||
|
||||
dbus_message_iter_init (reply, &iter_reply);
|
||||
if (dbus_message_iter_get_arg_type (&iter_reply) != DBUS_TYPE_ARRAY) {
|
||||
Debug ("ConsoleKit: Wrong reply for GetSessionsForUser - expecting an array.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
dbus_message_iter_recurse (&iter_reply, &iter_array);
|
||||
sessions = get_path_array_from_iter (&iter_array, NULL);
|
||||
|
||||
out:
|
||||
if (message != NULL) {
|
||||
dbus_message_unref (message);
|
||||
}
|
||||
if (reply != NULL) {
|
||||
dbus_message_unref (reply);
|
||||
}
|
||||
|
||||
return sessions;
|
||||
}
|
||||
|
||||
void
|
||||
unlock_ck_session (const char *user,
|
||||
const char *x11_display)
|
||||
{
|
||||
DBusError error;
|
||||
DBusConnection *connection;
|
||||
char **sessions;
|
||||
int i;
|
||||
|
||||
Debug ("ConsoleKit: Unlocking session for %s on %s", user, x11_display);
|
||||
|
||||
dbus_error_init (&error);
|
||||
connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
|
||||
if (connection == NULL) {
|
||||
Debug ("ConsoleKit: Failed to connect to the D-Bus daemon: %s", error.message);
|
||||
dbus_error_free (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
sessions = get_sessions_for_user (connection, user, x11_display);
|
||||
if (sessions == NULL || sessions[0] == NULL) {
|
||||
Debug ("ConsoleKit: no sessions found");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; sessions[i] != NULL; i++) {
|
||||
char *ssid;
|
||||
char *xdisplay;
|
||||
|
||||
ssid = sessions[i];
|
||||
session_get_x11_display (connection, ssid, &xdisplay);
|
||||
Debug ("ConsoleKit: session %s has DISPLAY %s", ssid, xdisplay);
|
||||
|
||||
if (xdisplay != NULL
|
||||
&& x11_display != NULL
|
||||
&& strcmp (xdisplay, x11_display) == 0) {
|
||||
int res;
|
||||
|
||||
res = session_unlock (connection, ssid);
|
||||
if (! res) {
|
||||
LogError ("ConsoleKit: Unable to unlock %s", ssid);
|
||||
}
|
||||
}
|
||||
|
||||
free (xdisplay);
|
||||
}
|
||||
|
||||
freeStrArr (sessions);
|
||||
}
|
||||
|
||||
char *
|
||||
open_ck_session (struct passwd *pwent,
|
||||
struct display *d)
|
||||
{
|
||||
DBusConnection *connection;
|
||||
DBusError error;
|
||||
DBusMessage *message;
|
||||
DBusMessage *reply;
|
||||
DBusMessageIter iter;
|
||||
DBusMessageIter iter_struct;
|
||||
char *cookie;
|
||||
|
||||
cookie = NULL;
|
||||
|
||||
if (pwent == NULL) {
|
||||
Debug ("ConsoleKit: NULL user passed as parameter");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Debug ("ConsoleKit: Opening session for %s", pwent->pw_name);
|
||||
|
||||
dbus_error_init (&error);
|
||||
connection = dbus_bus_get_private (DBUS_BUS_SYSTEM, &error);
|
||||
private_connection = connection;
|
||||
|
||||
if (connection == NULL) {
|
||||
Debug ("ConsoleKit: Failed to connect to the D-Bus daemon: %s", error.message);
|
||||
dbus_error_free (&error);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dbus_connection_set_exit_on_disconnect (connection, FALSE);
|
||||
/* FIXME: What to do about these?
|
||||
dbus_connection_set_watch_functions( connection,
|
||||
dbusAddWatch,
|
||||
dbusRemoveWatch,
|
||||
dbusToggleWatch,
|
||||
data, 0 );
|
||||
dbus_connection_set_timeout_functions( connection,
|
||||
dbusAddTimeout,
|
||||
dbusRemoveTimeout,
|
||||
dbusToggleTimeout,
|
||||
data, 0 );
|
||||
dbus_connection_set_wakeup_main_function( connection,
|
||||
dbusWakeupMain,
|
||||
data, 0 ); */
|
||||
|
||||
dbus_error_init (&error);
|
||||
message = dbus_message_new_method_call (CK_NAME,
|
||||
CK_MANAGER_PATH,
|
||||
CK_MANAGER_INTERFACE,
|
||||
"OpenSessionWithParameters");
|
||||
if (message == NULL) {
|
||||
Debug ("ConsoleKit: Couldn't allocate the D-Bus message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dbus_message_iter_init_append (message, &iter);
|
||||
dbus_message_iter_open_container (&iter,
|
||||
DBUS_TYPE_ARRAY,
|
||||
DBUS_STRUCT_BEGIN_CHAR_AS_STRING
|
||||
DBUS_TYPE_STRING_AS_STRING
|
||||
DBUS_TYPE_VARIANT_AS_STRING
|
||||
DBUS_STRUCT_END_CHAR_AS_STRING,
|
||||
&iter_struct);
|
||||
|
||||
add_param_int (&iter_struct, "user", pwent->pw_uid);
|
||||
add_param_string (&iter_struct, "x11-display", d->name);
|
||||
add_param_boolean (&iter_struct, "is-local", ((d->displayType & d_location) == dLocal));
|
||||
#ifdef XDMCP
|
||||
if ((d->displayType & d_location) != dLocal) {
|
||||
add_param_string (&iter_struct, "remote-host-name", d->remoteHost);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_VTS
|
||||
if (d->serverVT > 0) {
|
||||
char device[20];
|
||||
|
||||
/* FIXME: how does xorg construct this */
|
||||
sprintf(device, "/dev/tty%d", d->serverVT);
|
||||
add_param_string (&iter_struct, "x11-display-device", device);
|
||||
}
|
||||
#endif
|
||||
|
||||
dbus_message_iter_close_container (&iter, &iter_struct);
|
||||
|
||||
reply = dbus_connection_send_with_reply_and_block (connection,
|
||||
message,
|
||||
-1, &error);
|
||||
if (dbus_error_is_set (&error)) {
|
||||
Debug ("ConsoleKit: %s raised:\n %s\n\n", error.name, error.message);
|
||||
reply = NULL;
|
||||
}
|
||||
|
||||
dbus_connection_flush (connection);
|
||||
|
||||
dbus_message_unref (message);
|
||||
dbus_error_free (&error);
|
||||
|
||||
if (reply != NULL) {
|
||||
const char *value;
|
||||
|
||||
dbus_message_iter_init (reply, &iter);
|
||||
dbus_message_iter_get_basic (&iter, &value);
|
||||
cookie = strdup (value);
|
||||
dbus_message_unref (reply);
|
||||
}
|
||||
|
||||
return cookie;
|
||||
}
|
||||
|
||||
void
|
||||
close_ck_session (const char *cookie)
|
||||
{
|
||||
DBusError error;
|
||||
DBusMessage *message;
|
||||
DBusMessage *reply;
|
||||
DBusMessageIter iter;
|
||||
|
||||
if (cookie == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (private_connection == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
dbus_error_init (&error);
|
||||
message = dbus_message_new_method_call (CK_NAME,
|
||||
CK_MANAGER_PATH,
|
||||
CK_MANAGER_INTERFACE,
|
||||
"CloseSession");
|
||||
if (message == NULL) {
|
||||
Debug ("ConsoleKit: Couldn't allocate the D-Bus message");
|
||||
return;
|
||||
}
|
||||
|
||||
dbus_message_iter_init_append (message, &iter);
|
||||
dbus_message_iter_append_basic (&iter,
|
||||
DBUS_TYPE_STRING,
|
||||
&cookie);
|
||||
|
||||
reply = dbus_connection_send_with_reply_and_block (private_connection,
|
||||
message,
|
||||
-1, &error);
|
||||
if (dbus_error_is_set (&error)) {
|
||||
Debug ("ConsoleKit: %s raised:\n %s\n\n", error.name, error.message);
|
||||
reply = NULL;
|
||||
}
|
||||
|
||||
dbus_connection_flush (private_connection);
|
||||
|
||||
dbus_message_unref (message);
|
||||
dbus_error_free (&error);
|
||||
|
||||
dbus_connection_close (private_connection);
|
||||
private_connection = NULL;
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
*
|
||||
* Copyright (C) 2006 William Jon McCann <mccann@jhu.edu>
|
||||
* Copyright (C) 2007 Kevin Kofler <Kevin@tigcc.ticalc.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __CONSOLE_KIT_H
|
||||
#define __CONSOLE_KIT_H
|
||||
|
||||
#include <pwd.h>
|
||||
|
||||
struct display;
|
||||
|
||||
char * open_ck_session (struct passwd *pwent,
|
||||
struct display *display);
|
||||
void close_ck_session (const char *cookie);
|
||||
void unlock_ck_session (const char *user,
|
||||
const char *x11_display);
|
||||
|
||||
#endif /* __CONSOLE_KIT_H */
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Icon=cdrom_mount_decrypt
|
||||
Type=MimeType
|
||||
MimeType=media/cdrom_mounted_decrypted
|
||||
Comment=Mounted Decrypted CD-ROM
|
||||
Comment[de]=Eingebundene, entschlüsselte CD-ROM
|
||||
Patterns=
|
||||
|
||||
X-KDE-AutoEmbed=true
|
||||
X-KDE-IsAlso=inode/directory
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Icon=cdrom_unmount_decrypt
|
||||
Type=MimeType
|
||||
MimeType=media/cdrom_unmounted_decrypted
|
||||
Comment=Unmounted Decrypted CD-ROM
|
||||
Comment[de]=Nicht eingebundene, entschlüsselte CD-ROM
|
||||
Patterns=
|
||||
|
||||
X-KDE-AutoEmbed=true
|
||||
X-KDE-IsAlso=inode/directory
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Icon=cdrom_unmount_encrypt
|
||||
Type=MimeType
|
||||
MimeType=media/cdrom_unmounted_encrypted
|
||||
Comment=Unmounted Encrypted CD-ROM
|
||||
Comment[de]=Nicht eingebundene, verschlüsselte CD-ROM
|
||||
Patterns=
|
||||
|
||||
X-KDE-AutoEmbed=true
|
||||
X-KDE-IsAlso=inode/directory
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Icon=cdwriter_mount_decrypt
|
||||
Type=MimeType
|
||||
MimeType=media/cdwriter_mounted_decrypted
|
||||
Comment=Mounted Decrypted CD Writer
|
||||
Comment[de]=Eingebundener, entschlüsselter CD-Brenner
|
||||
Patterns=
|
||||
|
||||
X-KDE-AutoEmbed=true
|
||||
X-KDE-IsAlso=inode/directory
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Icon=cdwriter_unmount_decrypt
|
||||
Type=MimeType
|
||||
MimeType=media/cdwriter_unmounted_decrypted
|
||||
Comment=Unmounted Decrypted CD Writer
|
||||
Comment[de]=Nicht eingebundener, entschlüsselter CD-Brenner
|
||||
Patterns=
|
||||
|
||||
X-KDE-AutoEmbed=true
|
||||
X-KDE-IsAlso=inode/directory
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Icon=cdwriter_unmount_encrypt
|
||||
Type=MimeType
|
||||
MimeType=media/cdwriter_unmounted_encrypted
|
||||
Comment=Unmounted Encrypted CD Writer
|
||||
Comment[de]=Nicht eingebundener, entschlüsselter CD-Brenner
|
||||
Patterns=
|
||||
|
||||
X-KDE-AutoEmbed=true
|
||||
X-KDE-IsAlso=inode/directory
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Icon=dvd_mount_decrypt
|
||||
Type=MimeType
|
||||
MimeType=media/dvd_mounted_decrypted
|
||||
Comment=Mounted Decrypted DVD
|
||||
Comment[de]=Eingebundene, entschlüsselte DVD
|
||||
Patterns=
|
||||
|
||||
X-KDE-AutoEmbed=true
|
||||
X-KDE-IsAlso=inode/directory
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Icon=dvd_unmount_decrypt
|
||||
Type=MimeType
|
||||
MimeType=media/dvd_unmounted_decrypted
|
||||
Comment=Unmounted Decrypted DVD
|
||||
Comment[de]=Nicht eingebundene, entschlüsselte DVD
|
||||
Patterns=
|
||||
|
||||
X-KDE-AutoEmbed=true
|
||||
X-KDE-IsAlso=inode/directory
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Icon=dvd_unmount_encrypt
|
||||
Type=MimeType
|
||||
MimeType=media/dvd_unmounted_encrypted
|
||||
Comment=Unmounted Encrypted DVD
|
||||
Comment[de]=Nicht eingebundene, verschlüsselte DVD
|
||||
Patterns=
|
||||
|
||||
X-KDE-AutoEmbed=true
|
||||
X-KDE-IsAlso=inode/directory
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Icon=hdd_mount_decrypt
|
||||
Type=MimeType
|
||||
MimeType=media/hdd_mounted_decrypted
|
||||
Comment=Mounted Decrypted Hard Disk Volume
|
||||
Comment[de]=Eingebundene, entschlüsselte Festplattenpartition
|
||||
Patterns=
|
||||
|
||||
X-KDE-AutoEmbed=true
|
||||
X-KDE-IsAlso=inode/directory
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Icon=hdd_unmount_decrypt
|
||||
Type=MimeType
|
||||
MimeType=media/hdd_unmounted_decrypted
|
||||
Comment=Unmounted Decrypted Hard Disk Volume
|
||||
Comment[de]=Nicht eingebundene, entschlüsselte Festplattenpartition
|
||||
Patterns=
|
||||
|
||||
X-KDE-AutoEmbed=true
|
||||
X-KDE-IsAlso=inode/directory
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Icon=hdd_unmount_encrypt
|
||||
Type=MimeType
|
||||
MimeType=media/hdd_unmounted_encrypted
|
||||
Comment=Unmounted Encrypted Hard Disk Volume
|
||||
Comment[de]=Nicht eingebundene, verschlüsselte Festplattenpartition
|
||||
Patterns=
|
||||
|
||||
X-KDE-AutoEmbed=true
|
||||
X-KDE-IsAlso=inode/directory
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Icon=usbpendrive_mount_decrypt
|
||||
Type=MimeType
|
||||
MimeType=media/removable_mounted_decrypted
|
||||
Comment=Mounted Decrypted Removable Medium
|
||||
Comment[de]=Eingebundenes, entschlüsseltes Wechsellaufwerk
|
||||
Patterns=
|
||||
|
||||
X-KDE-AutoEmbed=true
|
||||
X-KDE-IsAlso=inode/directory
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Icon=usbpendrive_unmount_decrypt
|
||||
Type=MimeType
|
||||
MimeType=media/removable_unmounted_decrypted
|
||||
Comment=Unmounted Decrypted Removable Medium
|
||||
Comment[de]=Nicht eingebundenes, entschlüsseltes Wechsellaufwerk
|
||||
Patterns=
|
||||
|
||||
X-KDE-AutoEmbed=true
|
||||
X-KDE-IsAlso=inode/directory
|
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Icon=usbpendrive_unmount_encrypt
|
||||
Type=MimeType
|
||||
MimeType=media/removable_unmounted_encrypted
|
||||
Comment=Unmounted Encrypted Removable Medium
|
||||
Comment[de]=Nicht eingebundenes, verschlüsseltes Wechsellaufwerk
|
||||
Patterns=
|
||||
|
||||
X-KDE-AutoEmbed=true
|
||||
X-KDE-IsAlso=inode/directory
|
@ -0,0 +1,201 @@
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>DecryptDialog</class>
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>DecryptDialog</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>207</width>
|
||||
<height>172</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>3</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>Decrypting Storage Device</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLayoutWidget" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>layout5</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout4</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>encryptedIcon</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
<property name="name">
|
||||
<cstring>spacer2_2</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>31</width>
|
||||
<height>41</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>descLabel</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>3</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><p><b>%1</b> is an encrypted storage device.</p>
|
||||
<p>Please enter the password to decrypt the storage device.</p></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>WordBreak|AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>layout4</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel1</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Password:</string>
|
||||
</property>
|
||||
<property name="buddy" stdset="0">
|
||||
<cstring>passwordEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit">
|
||||
<property name="name">
|
||||
<cstring>passwordEdit</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
<widget class="QGroupBox" row="2" column="0">
|
||||
<property name="name">
|
||||
<cstring>errorBox</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>3</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Error</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>errorLabel</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>3</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>WordBreak|AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
</UI>
|
@ -0,0 +1,68 @@
|
||||
/* This file is part of the KDE project
|
||||
* Copyright (C) 2007 Jan Klötzke <jan kloetzke at freenet de>
|
||||
*
|
||||
* Based on kryptomedia- Another KDE cryto media application.
|
||||
* Copyright (C) 2006 Daniel Gollub <dgollub@suse.de>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "dialog.h"
|
||||
|
||||
Dialog::Dialog(QString url, QString iconName) :
|
||||
KDialogBase(NULL, "Dialog", true, "Decrypt Storage Device", (Cancel|User1), User1, false, KGuiItem(i18n("Decrypt"), "decrypted" ))
|
||||
{
|
||||
decryptDialog = new DecryptDialog(this);
|
||||
|
||||
decryptDialog->errorBox->hide();
|
||||
decryptDialog->descLabel->setText(decryptDialog->descLabel->text().arg(url));
|
||||
decryptDialog->descLabel->adjustSize();
|
||||
decryptDialog->adjustSize();
|
||||
|
||||
enableButton( User1, false );
|
||||
|
||||
QPixmap pixmap = KGlobal::iconLoader()->loadIcon(iconName, KIcon::NoGroup, KIcon::SizeLarge);
|
||||
decryptDialog->encryptedIcon->setPixmap( pixmap );
|
||||
|
||||
connect(decryptDialog->passwordEdit, SIGNAL (textChanged(const QString &)), this, SLOT (slotPasswordChanged(const QString &)));
|
||||
|
||||
setMainWidget(decryptDialog);
|
||||
}
|
||||
|
||||
Dialog::~Dialog()
|
||||
{
|
||||
delete decryptDialog;
|
||||
}
|
||||
|
||||
QString Dialog::getPassword()
|
||||
{
|
||||
return decryptDialog->passwordEdit->text();
|
||||
}
|
||||
|
||||
void Dialog::slotDialogError(QString errorMsg)
|
||||
{
|
||||
kdDebug() << __func__ << "(" << errorMsg << " )" << endl;
|
||||
|
||||
decryptDialog->errorLabel->setText(QString("<b>%1</b>").arg(errorMsg));
|
||||
decryptDialog->errorBox->show();
|
||||
}
|
||||
|
||||
void Dialog::slotPasswordChanged(const QString &text)
|
||||
{
|
||||
enableButton( User1, !text.isEmpty() );
|
||||
}
|
||||
|
||||
#include "dialog.moc"
|
@ -0,0 +1,61 @@
|
||||
/* This file is part of the KDE project
|
||||
* Copyright (C) 2007 Jan Klötzke <jan kloetzke at freenet de>
|
||||
*
|
||||
* Based on kryptomedia- Another KDE cryto media application.
|
||||
* Copyright (C) 2006 Daniel Gollub <dgollub@suse.de>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef DIALOG_H_
|
||||
#define DIALOG_H_
|
||||
|
||||
#include <kmessagebox.h>
|
||||
#include <klocale.h>
|
||||
#include <kconfig.h>
|
||||
#include <kdebug.h>
|
||||
#include <kdialogbase.h>
|
||||
#include <kiconloader.h>
|
||||
|
||||
#include <qlineedit.h>
|
||||
#include <qlabel.h>
|
||||
#include <qgroupbox.h>
|
||||
|
||||
#include "decryptdialog.h"
|
||||
|
||||
class KryptoMedia;
|
||||
|
||||
class Dialog : public KDialogBase
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Dialog(QString url, QString iconName);
|
||||
~Dialog();
|
||||
|
||||
QString getPassword();
|
||||
|
||||
public slots:
|
||||
void slotDialogError(QString errorMsg);
|
||||
void slotPasswordChanged(const QString &text);
|
||||
|
||||
private:
|
||||
DecryptDialog *decryptDialog;
|
||||
};
|
||||
|
||||
#endif // DIALOG_H_
|
||||
|
@ -1,3 +1,3 @@
|
||||
servicesdir = $(kde_datadir)/konqueror/servicemenus
|
||||
services_DATA = media_mount.desktop media_unmount.desktop media_eject.desktop media_safelyremove.desktop
|
||||
services_DATA = media_decrypt.desktop media_mount.desktop media_unmount.desktop media_eject.desktop media_safelyremove.desktop
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
[Desktop Action Decrypt]
|
||||
Exec=kio_media_mounthelper -d %u
|
||||
Icon=decrypted
|
||||
Name=Decrypt
|
||||
Name[de]=Entschlüsseln
|
||||
|
||||
[Desktop Entry]
|
||||
Actions=Decrypt
|
||||
ServiceTypes=media/removable_unmounted_encrypted,media/hdd_unmounted_encrypted,media/cdrom_unmounted_encrypted,media/cdwriter_unmounted_encrypted,media/dvd_unmounted_encrypted
|
Loading…
Reference in new issue