* ark context un[tar/zip/bz] crash repair

* gcc4.4 compilation fixes
* superkaramba xmms sensor addition
* automake updates

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeutils@1063396 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 14 years ago
parent 2bda8f7717
commit 2abe1e6f40

@ -262,7 +262,9 @@ void Arch::slotReceivedTOC( KProcess*, char* data, int length )
break; // We are done all the complete lines
data[ lfChar ] = '\0';
m_buffer.append( data + startChar );
m_buffer.append( QString::fromUtf8(data + startChar).latin1() );
data[ lfChar ] = '\n';
startChar = lfChar + 1;

@ -133,3 +133,4 @@ Icon=ark
Type=Service
ServiceTypes=KParts/ReadOnlyPart
X-KDE-Library=libarkpart
Hidden=true

@ -117,6 +117,7 @@ ArkWidget::ArkWidget( QWidget *parent, const char *name )
m_bIsSimpleCompressedFile( false ),
m_bDropSourceIsSelf( false ), m_extractList( 0 )
{
m_settingsAltered = false;
m_tmpDir = new KTempDir( locateLocal( "tmp", "ark" ) );
if ( m_tmpDir->status() != 0 )
@ -155,12 +156,14 @@ ArkWidget::~ArkWidget()
delete m_fileListView;
m_fileListView = 0;
delete arch;
ArkSettings::writeConfig();
if (m_settingsAltered) {
ArkSettings::writeConfig();
}
}
void ArkWidget::cleanArkTmpDir()
{
removeDownloadedFiles();
removeDownloadedFiles();
if ( m_tmpDir )
{
m_tmpDir->unlink();
@ -2257,6 +2260,8 @@ void ArkWidget::showSettings(){
genPage->konqIntegrationLabel->setText( QString::null );
dialog->show();
m_settingsAltered = true;
}
#include "arkwidget.moc"

@ -242,6 +242,7 @@ private: // data
bool m_bBusy;
bool m_bBusyHold;
bool m_settingsAltered;
// for use in the edit methods: the url.
QString m_strFileToView;

@ -55,6 +55,8 @@ RarArch::RarArch( ArkWidget *_gui, const QString & _fileName )
{
// Check if rar is available
bool have_rar = !KGlobal::dirs()->findExe( "rar" ).isNull();
bool have_unrar = !KGlobal::dirs()->findExe( "unrar" ).isNull();
bool have_unrar_free = !KGlobal::dirs()->findExe( "unrar-free" ).isNull();
if ( have_rar )
{
@ -63,13 +65,20 @@ RarArch::RarArch( ArkWidget *_gui, const QString & _fileName )
verifyCompressUtilityIsAvailable( m_archiver_program );
verifyUncompressUtilityIsAvailable( m_unarchiver_program );
}
else
else if (have_unrar)
{
// If rar is not available, try to use unrar to open the archive read-only
m_unarchiver_program = "unrar";
verifyUncompressUtilityIsAvailable( m_unarchiver_program );
setReadOnly( true );
}
else
{
// If rar is not available, try to use unrar to open the archive read-only
m_unarchiver_program = "unrar-free";
verifyUncompressUtilityIsAvailable( m_unarchiver_program );
setReadOnly( true );
}

@ -95,4 +95,4 @@ Name[xh]=Itshati yokukheta i K
Name[zh_TW]=KDE 字元選擇
X-KDE-StartupNotify=true
X-DCOP-ServiceType=Multi
Categories=Qt;KDE;Utility;X-KDE-More;
Categories=Qt;KDE;Utility;

@ -165,14 +165,6 @@ void AcpiConfig::setupHelper()
unsigned long len, crc;
QString helper = KStandardDirs::findExe("klaptop_acpi_helper");
checkcrc(QFile::encodeName(helper), len, crc);
if (len != file_len || crc != file_crc) {
QString str(i18n("The %1 application does not seem to have "
"the same size or checksum as when it was compiled we do NOT recommend "
"you proceed with making it setuid-root without further investigation").arg(helper));
int rc = KMessageBox::warningContinueCancel(0, str, i18n("KLaptopDaemon"), i18n("Run Nevertheless"));
if (rc != KMessageBox::Continue)
return;
}
QString kdesu = KStandardDirs::findExe("kdesu");
if (!kdesu.isEmpty()) {
@ -186,7 +178,7 @@ void AcpiConfig::setupHelper()
proc << kdesu;
proc << "-u";
proc << "root";
proc << "chown root "+helper+"; chmod +s "+helper;
proc << "dpkg-statoverride --update --add root root 6755 "+helper;
proc.start(KProcess::Block); // run it sync so has_acpi below sees the results
}
} else {

@ -100,7 +100,7 @@ void write_to_power(const char * str)
Returns only if the program does not exist; if the program exists
and is unsafe, exit; if the program exists and is safe, run it
and never return. */
void run_program(const char *path)
void run_program(const char *path, const int action)
{
struct stat sb;
int err;
@ -118,7 +118,13 @@ void run_program(const char *path)
exit(1);
}
::setuid(::geteuid()); // otherwise bash will throw it away
::execl(path, NULL); // this is not KDE environment code
if (action == 1) {
system("/usr/sbin/pmi action hibernate");
} else if (action == 2) {
system("/usr/sbin/pmi action sleep");
} else {
::execl(path, NULL); // this is not KDE environment code
}
exit(0);
}
@ -139,11 +145,13 @@ main(int argc, char **argv)
for (i = 1; i < argc; i++)
if (strcmp(argv[i], "--suspend") == 0 || strcmp(argv[i], "-suspend") == 0) {
/* Returns only if suspend does not exist. */
run_program("/usr/sbin/suspend");
run_program("/usr/sbin/pmi", 2);
/*
if (useSysPower)
write_to_power("mem");
else
write_to_proc_sleep(3);
*/
exit(0);
} else
if (strcmp(argv[i], "--standby") == 0 || strcmp(argv[i], "-standby") == 0) {
@ -158,15 +166,17 @@ main(int argc, char **argv)
exit(0);
} else
if (strcmp(argv[i], "--hibernate") == 0 || strcmp(argv[i], "-hibernate") == 0) {
run_program("/usr/sbin/hibernate");
run_program("/usr/sbin/pmi", 1);
/*
if (useSysPower)
write_to_power("disk");
else
write_to_proc_sleep(4);
*/
exit(0);
} else
if (strcmp(argv[i], "--software-suspend") == 0 || strcmp(argv[i], "-software-suspend") == 0) {
run_program("/usr/sbin/hibernate");
run_program("/usr/sbin/hibernate", 0);
exit(0);
} else
if (strcmp(argv[i], "--throttling") == 0 || strcmp(argv[i], "-throttling") == 0) {

@ -166,7 +166,7 @@ void ApmConfig::setupHelper()
proc << kdesu;
proc << "-u";
proc << "root";
proc << QString("chown root ")+apm_name+"; chmod +s "+apm_name;
proc << QString("dpkg-statoverride --update --add root root 6755 ")+apm_name;
proc.start(KProcess::Block); // run it sync so has_apm below sees the results
}
} else {
@ -187,14 +187,6 @@ void ApmConfig::setupHelper2() // we use the acpi helper to do software suspend
unsigned long len, crc;
QString helper = KStandardDirs::findExe("klaptop_acpi_helper");
checkcrc(helper.latin1(), len, crc);
if (len != file_len || crc != file_crc) {
QString str(i18n("The %1 application does not seem to have "
"the same size or checksum as when it was compiled we do NOT recommend "
"you proceed with making it setuid-root without further investigation").arg(helper));
int rc = KMessageBox::warningContinueCancel(0, str, i18n("KLaptopDaemon"), i18n("Run Nevertheless"));
if (rc != KMessageBox::Continue)
return;
}
QString kdesu = KStandardDirs::findExe("kdesu");
if (!kdesu.isEmpty()) {
@ -208,7 +200,7 @@ void ApmConfig::setupHelper2() // we use the acpi helper to do software suspend
proc << kdesu;
proc << "-u";
proc << "root";
proc << "chown root "+helper+"; chmod +s "+helper;
proc << "dpkg-statoverride --update --add root root 6755 "+helper;
proc.start(KProcess::Block); // run it sync so has_acpi below sees the results
}
} else {

@ -106,10 +106,10 @@ laptop_dock::SetupPopup()
if (can_standby || can_suspend || can_hibernate) {
rightPopup->insertSeparator();
if (can_standby) rightPopup->insertItem(i18n("Standby..."), this, SLOT(invokeStandby()));
if (can_suspend) rightPopup->insertItem(i18n("&Lock && Suspend..."), this, SLOT(invokeLockSuspend()));
if (can_suspend) rightPopup->insertItem(i18n("&Suspend..."), this, SLOT(invokeSuspend()));
if (can_hibernate) rightPopup->insertItem(i18n("&Lock && Hibernate..."), this, SLOT(invokeLockHibernation()));
if (can_hibernate) rightPopup->insertItem(i18n("&Hibernate..."), this, SLOT(invokeHibernation()));
// if (can_suspend) rightPopup->insertItem(i18n("&Lock && Suspend..."), this, SLOT(invokeLockSuspend()));
if (can_suspend) rightPopup->insertItem(i18n("&Suspend..."), this, SLOT(invokeLockSuspend()));
// if (can_hibernate) rightPopup->insertItem(i18n("&Lock && Hibernate..."), this, SLOT(invokeLockHibernation()));
if (can_hibernate) rightPopup->insertItem(i18n("&Hibernate..."), this, SLOT(invokeLockHibernation()));
}
rightPopup->insertSeparator();

@ -952,7 +952,7 @@ laptop_daemon::ButtonThreadInternals()
// the lid button turns stuff on when it's down and back off again when it's raised
// (kind of like the fridge door light)
//
if (lid_state != laptop_portable::get_button(laptop_portable::LidButton)) {
if (s.enable_lid_button && lid_state != laptop_portable::get_button(laptop_portable::LidButton)) {
lid_state = !lid_state;
if (lid_state) {
if (s.button_lid_bright_enabled) {
@ -1015,7 +1015,7 @@ laptop_daemon::ButtonThreadInternals()
//
// the power button on the other hand is an off/on switch for non-suspend type ops
//
if (power_state != laptop_portable::get_button(laptop_portable::PowerButton)) {
if (s.enable_power_button && power_state != laptop_portable::get_button(laptop_portable::PowerButton)) {
power_state = !power_state;
if (power_state) {
if (power_button_off) {

@ -177,7 +177,7 @@ pmu_read(apm_info *ap)
int bcnt = 0;
memset(ap, 0, sizeof(apm_info));
QFile f("/proc/pmu/info");
if (!f.open(IO_ReadOnly))
if (!f.exists() || !f.open(IO_ReadOnly))
return 1;
while (!f.atEnd()) {
@ -200,7 +200,7 @@ pmu_read(apm_info *ap)
int maxcharge = 0;
for (int i = 0; i < bcnt; i++) {
QFile bf(QString("/proc/pmu/battery_%1").arg(i));
if (!bf.open(IO_ReadOnly))
if (!bf.exists() || !bf.open(IO_ReadOnly))
continue;
while(!bf.atEnd()) {
@ -331,7 +331,7 @@ static void acpi_read_batteries() {
bool present = false;
if ((test_count==0 || acpi_last_known != last_seed) && !bat.info_file.isNull()) {
f = new QFile(bat.info_file);
if (f && f->open(IO_ReadOnly)) {
if (f && f->exists() && f->open(IO_ReadOnly)) {
while(f->readLine(buff,1024) > 0) {
if (buff.contains("design capacity low:", false)) {
QRegExp rx("(\\d*)\\D*$");
@ -361,7 +361,7 @@ static void acpi_read_batteries() {
}
if (!bat.state_file.isNull()) {
f = new QFile(bat.state_file);
if (f && f->open(IO_ReadOnly)) {
if (f && f->exists() && f->open(IO_ReadOnly)) {
while(f->readLine(buff,1024) > 0) {
if (buff.contains("present rate:", false)) {
QRegExp rx("(\\d*)\\D*$");
@ -692,7 +692,7 @@ has_acpi_sleep(int state)
QFile p("/sys/power/state");
QFile f("/proc/acpi/sleep");
if (p.open(IO_ReadOnly)) {
if (p.exists() && p.open(IO_ReadOnly)) {
QString l;
QTextStream t(&p);
l = t.readLine();
@ -709,7 +709,7 @@ has_acpi_sleep(int state)
}
p.close();
}
else if (f.open(IO_ReadOnly)) {
else if (f.exists() && f.open(IO_ReadOnly)) {
QString l;
QTextStream t(&f);
l = t.readLine();
@ -1256,7 +1256,7 @@ static bool has_lav()
if (!lav_inited) {
lav_inited =1;
lav_file.setName("/proc/loadavg");
lav_openok = lav_file.open( IO_ReadOnly );
lav_openok = lav_file.exists() && lav_file.open( IO_ReadOnly );
if (lav_openok)
lav_file.close();
}
@ -1305,7 +1305,7 @@ QString laptop_portable::cpu_frequency() {
QFile cf("/proc/cpufreq");
bool haveProfile = false;
if (cf.open(IO_ReadOnly)) {
if (cf.exists() && cf.open(IO_ReadOnly)) {
while (!cf.atEnd()) {
QString l;
cf.readLine(l, 500);
@ -1320,7 +1320,7 @@ QString laptop_portable::cpu_frequency() {
}
if (haveProfile) {
QFile ci("/proc/cpuinfo");
if (ci.open(IO_ReadOnly)) {
if (ci.exists() && ci.open(IO_ReadOnly)) {
while (!ci.atEnd()) {
QString l;
ci.readLine(l, 500);
@ -1538,7 +1538,7 @@ get_acpi_list(char p, int *map, const char *dev, QStringList &list, int &index,
!(::access(name.latin1(), R_OK)==0 && ::acpi_helper_ok(0)))
continue;
QFile f(name);
if (f.open(IO_ReadOnly)) {
if (f.exists() && f.open(IO_ReadOnly)) {
while (!f.atEnd() && i < MAP_SIZE) {
QString l;
f.readLine(l, 500);
@ -1576,7 +1576,7 @@ get_acpi_list(char p, int *map, const char *dev, QStringList &list, int &index,
if (get_enable) {
name = QString("/proc/acpi/processor/")+dp->d_name+"/limit";
f.setName(name);
if (f.open(IO_ReadOnly)) {
if (f.exists() && f.open(IO_ReadOnly)) {
while (!f.atEnd() && i < MAP_SIZE) {
QString l;
f.readLine(l, 500);
@ -1619,7 +1619,7 @@ static int get_cpufreq_sysfs_state(QStringList &states, int &current, const QStr
// read current scaling policy
QFile f("/sys/devices/system/cpu/" + cpu + "/cpufreq/scaling_governor");
if(!f.open(IO_ReadOnly) || f.atEnd())
if(!f.exists() || !f.open(IO_ReadOnly) || f.atEnd())
return CPUFREQ_NONE;
f.readLine(buffer, 256);
cur = buffer.stripWhiteSpace();
@ -1628,7 +1628,7 @@ static int get_cpufreq_sysfs_state(QStringList &states, int &current, const QStr
// read available scaling policies
states.clear();
f.setName("/sys/devices/system/cpu/" + cpu + "/cpufreq/scaling_available_governors");
if(!f.open(IO_ReadOnly))
if(!f.exists() || !f.open(IO_ReadOnly))
return CPUFREQ_NONE;
int count = 0;
if(!f.atEnd()) {
@ -1654,7 +1654,7 @@ static int get_cpufreq_25_state(QStringList &states, int &current) {
states.clear();
QFile f("/proc/cpufreq");
if (f.open(IO_ReadOnly)) {
if (f.exists() && f.open(IO_ReadOnly)) {
while (!f.atEnd()) {
QString l;
f.readLine(l, 1024);
@ -1690,7 +1690,7 @@ static int get_cpufreq_24_state(QStringList &states, int &current, const QString
// current frequency
QFile f("/proc/sys/cpu/" + cpu + "/speed");
if(!f.open(IO_ReadOnly) || f.atEnd())
if(!f.exists() || !f.open(IO_ReadOnly) || f.atEnd())
return CPUFREQ_NONE;
f.readLine(buffer, 16);
f.close();
@ -1700,7 +1700,7 @@ static int get_cpufreq_24_state(QStringList &states, int &current, const QString
const char* files[] = { "max", "min" };
for(int i = 0; i <= 1; ++i) {
f.setName("/proc/sys/cpu/" + cpu + "/speed-" + files[i]);
if(!f.open(IO_ReadOnly) || f.atEnd())
if(!f.exists() || !f.open(IO_ReadOnly) || f.atEnd())
return CPUFREQ_NONE;
f.readLine(buffer, 16);
f.close();
@ -1905,7 +1905,7 @@ acpi_check_button(const char *prefix, QString &result)
if (::access(name.latin1(), R_OK)!=0)
continue;
QFile f(name);
if (f.open(IO_ReadOnly)) {
if (f.exists() && f.open(IO_ReadOnly)) {
while (!f.atEnd()) {
QString l;
f.readLine(l, 500);
@ -1972,7 +1972,7 @@ laptop_portable::get_button(LaptopButton l) // true if a button is pressed
}
if (!name.isEmpty()) {
QFile f(name);
if (f.open(IO_ReadOnly)) {
if (f.exists() && f.open(IO_ReadOnly)) {
while (!f.atEnd()) {
QString l;
f.readLine(l, 500);

@ -25,6 +25,7 @@
#include <kgenericfactory.h>
#include <kdebug.h>
#include <kprocess.h>
#include <kconfig.h>
#include <sys/types.h>
@ -34,6 +35,7 @@
#include "kmilointerface.h"
#include <qmessagebox.h>
#include <qfile.h>
#include <qdir.h>
#define CONFIG_FILE "kmilodrc"
@ -70,10 +72,25 @@ bool GenericMonitor::init()
KConfig config(CONFIG_FILE);
reconfigure(&config);
//config = new KConfig("kmilodrc");
config.setGroup("kubuntu");
if(!m_enabled)
return false; // exit early if we are not supposed to run
static const ShortcutInfo shortcuts[] = {
{ "Search", KShortcut("XF86Search"), SLOT(launchSearch()) },
{ "Home Folder", KShortcut("XF86MyComputer"), SLOT(launchHomeFolder()) },
{ "Mail", KShortcut("XF86Mail"), SLOT(launchMail()) },
{ "Audio Media", KShortcut("XF86AudioMedia"), SLOT(launchMusic()) },
{ "Music", KShortcut("XF86Music"), SLOT(launchMusic()) },
{ "Browser", KShortcut("XF86WWW"), SLOT(launchBrowser()) },
{ "Calculator", KShortcut("XF86Calculator"), SLOT(launchCalculator()) },
{ "Terminal", KShortcut("XF86Terminal"), SLOT(launchTerminal()) },
{ "Eject", KShortcut("XF86Eject"), SLOT(eject()) },
{ "Help", KShortcut("XF86Launch0"), SLOT(launchHelp()) },
{ "Light Bulb", KShortcut("XF86LightBulb"), SLOT(lightBulb()) },
{ "Battery", KShortcut("XF86LaunchB"), SLOT(pmBattery()) },
{ "FastVolumeUp", Qt::Key_VolumeUp, SLOT(fastVolumeUp()) },
{ "FastVolumeDown", Qt::Key_VolumeDown, SLOT(fastVolumeDown()) },
{ "SlowVolumeUp", Qt::CTRL+Qt::Key_VolumeUp, SLOT(slowVolumeUp()) },
@ -318,6 +335,73 @@ Monitor::DisplayType GenericMonitor::poll()
return m_displayType;
}
void GenericMonitor::launch(QString configKey, QString defaultApplication)
{
QString application = config->readEntry(configKey, defaultApplication);
KProcess proc;
proc << application;
proc.start(KProcess::DontCare);
}
void GenericMonitor::launchMail()
{
kdDebug() << "launchMail" << endl;
kapp->invokeMailer("", "", "", "", "", "", "", "");
}
void GenericMonitor::launchBrowser()
{
kapp->invokeBrowser("");
}
void GenericMonitor::launchSearch()
{
launch("search", "kfind");
}
void GenericMonitor::launchHomeFolder()
{
QString home = QDir::home().path();
KProcess proc;
proc << "kfmclient" << "exec" << home;
proc.start(KProcess::DontCare);
}
void GenericMonitor::launchMusic()
{
launch("search", "amarok");
}
void GenericMonitor::launchCalculator()
{
launch("search", "speedcrunch");
}
void GenericMonitor::launchTerminal()
{
launch("search", "konsole");
}
void GenericMonitor::launchHelp()
{
launch("search", "khelpcenter");
}
void GenericMonitor::eject()
{
launch("search", "eject");
}
void GenericMonitor::lightBulb()
{
kdDebug() << "lightBulb()" << endl;
_interface->displayText("Screen Light");
}
void GenericMonitor::pmBattery()
{
DCOPRef("guidance*", "power-manager").send("showTip");
}
K_EXPORT_COMPONENT_FACTORY(kmilo_generic, KGenericFactory<GenericMonitor>("kmilo_generic"))

@ -29,6 +29,7 @@
#include <kglobalaccel.h>
#include <dcopref.h>
#include <kapplication.h>
#include <kconfig.h>
#include "kmilod.h"
#include "monitor.h"
@ -63,6 +64,17 @@ public slots:
void fastVolumeUp();
void fastVolumeDown();
void mute();
void launchMail();
void launchBrowser();
void launchSearch();
void launchHomeFolder();
void launchMusic();
void launchCalculator();
void launchTerminal();
void launchHelp();
void eject();
void lightBulb();
void pmBattery();
private:
bool retrieveKmixDevices();
@ -70,8 +82,10 @@ private:
bool retrieveMute();
bool retrieveVolume();
void displayVolume();
void launch(QString configKey, QString defaultApplication);
KGlobalAccel *ga;
KConfig* config;
DCOPRef *kmixClient, *kmixWindow;

@ -33,6 +33,7 @@
#include <netwm.h>
#include <kglobalsettings.h>
#include <kdeversion.h>
#include <kconfig.h>
#include "defaultskin.h"
@ -49,6 +50,9 @@ DefaultSkin::DefaultSkin() {
KWin::setType(_widget->winId(), NET::Override);
_widget->hide();
KConfig config("kmilodrc");
reconfigure( &config );
}
@ -57,6 +61,34 @@ DefaultSkin::~DefaultSkin() {
_widget = 0;
}
void DefaultSkin::reconfigure( KConfig *config ) {
config->setGroup("DefaultSkin");
QFont *defaultFont = new QFont("Sans", 10, QFont::Bold );
QSize *defaultSize = new QSize( 80, 30 );
QColor *defaultpaletteForegroundColor = new QColor( 200, 200, 200 );
QColor *defaultpaletteBackgroundColor = new QColor( 100, 100, 100 );
QFont *defaultProgressFont = new QFont("Sans", 8, QFont::Bold );
_widget->resize( config->readSizeEntry("Size", defaultSize ) );
_widget->setFont( config->readFontEntry("Font", defaultFont ) );
_widget->setPaletteForegroundColor( config->readColorEntry("paletteForegroundColor", defaultpaletteForegroundColor ) );
_widget->setPaletteBackgroundColor( config->readColorEntry("paletteBackgroundColor", defaultpaletteBackgroundColor ) );
_widget->_progress->setFont( config->readFontEntry("ProgressFont", defaultProgressFont ) );
if ( ! config->hasGroup("DefaultSkin") )
{
config->writeEntry("Size", *defaultSize );
config->writeEntry("Font", *defaultFont );
config->writeEntry("paletteForegroundColor", *defaultpaletteForegroundColor );
config->writeEntry("paletteBackgroundColor", *defaultpaletteBackgroundColor );
config->writeEntry("ProgressFont", *defaultProgressFont );
}
}
void DefaultSkin::clear() {
_timer.stop();

@ -37,6 +37,7 @@ class DefaultSkin : public QObject, public KMilo::DisplaySkin {
virtual ~DefaultSkin();
virtual void clear();
virtual void reconfigure( KConfig *config );
virtual void displayText(const QString& text, const QPixmap& customPixmap=QPixmap());
virtual void displayProgress(const QString& text,

@ -7,21 +7,6 @@ Released under the terms of the GNU GPL.</comment>
<property name="name">
<cstring>DefaultWidget</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>566</width>
<height>180</height>
</rect>
</property>
<property name="paletteBackgroundColor">
<color>
<red>214</red>
<green>213</green>
<blue>212</blue>
</color>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
@ -30,19 +15,6 @@ Released under the terms of the GNU GPL.</comment>
<property name="name">
<cstring>_widgetStack</cstring>
</property>
<property name="paletteBackgroundColor">
<color>
<red>214</red>
<green>213</green>
<blue>212</blue>
</color>
</property>
<property name="frameShape">
<enum>StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>Sunken</enum>
</property>
<widget class="QWidget">
<property name="name">
<cstring>page</cstring>
@ -58,26 +30,6 @@ Released under the terms of the GNU GPL.</comment>
<property name="name">
<cstring>_textOnly</cstring>
</property>
<property name="paletteForegroundColor">
<color>
<red>26</red>
<green>69</green>
<blue>198</blue>
</color>
</property>
<property name="paletteBackgroundColor">
<color>
<red>214</red>
<green>213</green>
<blue>212</blue>
</color>
</property>
<property name="font">
<font>
<pointsize>28</pointsize>
<bold>1</bold>
</font>
</property>
<property name="text">
<string></string>
</property>
@ -98,41 +50,18 @@ Released under the terms of the GNU GPL.</comment>
<property name="name">
<cstring>unnamed</cstring>
</property>
<spacer row="1" column="2">
<property name="name">
<cstring>spacer1</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>81</width>
<height>31</height>
</size>
</property>
</spacer>
<spacer row="1" column="0">
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>spacer1_2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
<cstring>_progressText</cstring>
</property>
<property name="sizeType">
<enum>Expanding</enum>
<property name="text">
<string></string>
</property>
<property name="sizeHint">
<size>
<width>81</width>
<height>31</height>
</size>
<property name="alignment">
<set>AlignCenter</set>
</property>
</spacer>
<widget class="QProgressBar" row="1" column="1">
</widget>
<widget class="QProgressBar" row="0" column="1" colspan="2">
<property name="name">
<cstring>_progress</cstring>
</property>
@ -144,52 +73,14 @@ Released under the terms of the GNU GPL.</comment>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="paletteBackgroundColor">
<color>
<red>214</red>
<green>213</green>
<blue>212</blue>
</color>
</property>
<property name="centerIndicator">
<bool>false</bool>
</property>
</widget>
<widget class="QLabel" row="0" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>_progressText</cstring>
</property>
<property name="paletteForegroundColor">
<color>
<red>26</red>
<green>69</green>
<blue>198</blue>
</color>
</property>
<property name="paletteBackgroundColor">
<color>
<red>214</red>
<green>213</green>
<blue>212</blue>
</color>
</property>
<property name="font">
<font>
<pointsize>28</pointsize>
<bold>1</bold>
</font>
</property>
<property name="text">
<string></string>
</property>
<property name="alignment">
<set>AlignCenter</set>
</property>
</widget>
</grid>
</widget>
</widget>
</grid>
</widget>
<layoutdefaults spacing="6" margin="11"/>
<layoutdefaults spacing="2" margin="2"/>
</UI>

@ -72,5 +72,5 @@ GenericName[zh_TW]=正規表示式編輯器
Terminal=false
Type=Application
X-KDE-StartupNotify=true
Categories=Qt;KDE;Utility;X-KDE-More;
Categories=Qt;KDE;Utility;
Icon=kregexpeditor

@ -1,5 +1,5 @@
# set the include path for X, qt and KDE
INCLUDES = $(all_includes) $(XMMS_INCLUDES) $(PYTHONINC)
INCLUDES = $(all_includes) $(PYTHONINC)
# these are the headers for your project
noinst_HEADERS = karamba.h karambaapp.h karamba_python.h lineparser.h \
@ -40,9 +40,9 @@ superkaramba_SOURCES = main.cpp karamba.cpp meter.cpp bar.cpp sensor.cpp \
# kde_cfg_DATA = superkaramba.kcfg
superkaramba_LDFLAGS = -Wl,-export-dynamic $(KDE_RPATH) $(all_libraries) $(PYTHONLIB) $(XMMS_LDFLAGS)
#superkaramba_LDADD = -lkio $(LIB_KDEUI) $(XMMS_LDADD) $(LIBPYTHON) $(LIBKVM) $(MY_LIBKNEWSTUFF)
superkaramba_LDADD = -lkio $(LIB_KDEUI) $(XMMS_LIBS) $(LIBPYTHON) $(LIBKVM) $(MY_LIBKNEWSTUFF)
superkaramba_LDFLAGS = -Wl,-export-dynamic $(KDE_RPATH) $(all_libraries) $(PYTHONLIB)
#superkaramba_LDADD = -lkio $(LIB_KDEUI) $(LIBPYTHON) $(LIBKVM) $(MY_LIBKNEWSTUFF)
superkaramba_LDADD = -lkio $(LIB_KDEUI) $(LIBPYTHON) $(LIBKVM) $(MY_LIBKNEWSTUFF)
# this is where the desktop file will go
shelldesktopdir = $(kde_appsdir)/Utilities

@ -10,11 +10,122 @@
#include "xmmssensor.h"
#ifdef HAVE_XMMS
#include <xmmsctrl.h>
#include <qlibrary.h>
class XMMSSensor::XMMS
{
public:
XMMS() : libxmms( 0 )
{
libxmms = new QLibrary( "xmms.so.1" );
if ( !libxmms->load() )
{
delete libxmms;
libxmms = 0;
}
if ( libxmms != 0 )
{
// resolve functions
*(void**) (&xmms_remote_is_running) =
libxmms->resolve( "xmms_remote_is_running" );
*(void**) (&xmms_remote_is_playing) =
libxmms->resolve( "xmms_remote_is_playing" );
*(void**) (&xmms_remote_get_playlist_title) =
libxmms->resolve( "xmms_remote_get_playlist_title" );
*(void**) (&xmms_remote_get_playlist_time) =
libxmms->resolve( "xmms_remote_get_playlist_time" );
*(void**) (&xmms_remote_get_playlist_pos) =
libxmms->resolve( "xmms_remote_get_playlist_pos" );
*(void**) (&xmms_remote_get_output_time) =
libxmms->resolve( "xmms_remote_get_output_time" );
}
}
bool isInitialized() const
{
return libxmms != 0 &&
xmms_remote_is_running != 0 &&
xmms_remote_is_playing != 0 &&
xmms_remote_get_playlist_title != 0 &&
xmms_remote_get_playlist_time != 0 &&
xmms_remote_get_playlist_pos != 0 &&
xmms_remote_get_output_time != 0;
}
bool isRunning(int session)
{
if ( !isInitialized() ) return false;
return (*xmms_remote_is_running)(session);
}
bool isPlaying(int session)
{
if ( !isInitialized() ) return false;
return (*xmms_remote_is_playing)(session);
}
char* getPlaylistTitle(int session, int pos)
{
if ( !isInitialized() ) return "";
return (*xmms_remote_get_playlist_title)(session, pos);
}
int getPlaylistTime(int session, int pos)
{
if ( !isInitialized() ) return 0;
return (*xmms_remote_get_playlist_time)(session, pos);
}
int getPlaylistPos(int session)
{
if ( !isInitialized() ) return 0;
return (*xmms_remote_get_playlist_pos)(session);
}
int getOutputTime(int session)
{
if ( !isInitialized() ) return 0;
return (*xmms_remote_get_output_time)(session);
}
private:
QLibrary* libxmms;
bool (*xmms_remote_is_running)(int);
bool (*xmms_remote_is_playing)(int);
char* (*xmms_remote_get_playlist_title)(int, int);
int (*xmms_remote_get_playlist_time)(int, int);
int (*xmms_remote_get_playlist_pos)(int);
int (*xmms_remote_get_output_time)(int);
};
#else // No XMMS
class XMMSSensor::XMMS
{
public:
XMMS() {}
bool isInitialized() const { return false; }
};
#endif // HAVE_XMMS
XMMSSensor::XMMSSensor( int interval, const QString &encoding )
: Sensor( interval )
: Sensor( interval ), xmms( 0 )
{
if( !encoding.isEmpty() )
{
@ -25,9 +136,13 @@ XMMSSensor::XMMSSensor( int interval, const QString &encoding )
else
codec = QTextCodec::codecForLocale();
xmms = new XMMS();
}
XMMSSensor::~XMMSSensor()
{}
{
delete xmms;
}
void XMMSSensor::update()
{
@ -43,21 +158,21 @@ void XMMSSensor::update()
int songLength = 0;
int currentTime = 0;
bool isPlaying = false;
bool isRunning = xmms_remote_is_running(0);
bool isRunning = xmms->isRunning(0);
if( isRunning )
{
isPlaying = xmms_remote_is_playing(0);
pos = xmms_remote_get_playlist_pos(0);
isPlaying = xmms->isPlaying(0);
pos = xmms->getPlaylistPos(0);
qDebug("unicode start");
title = codec->toUnicode( QCString( xmms_remote_get_playlist_title( 0, pos ) ) );
title = codec->toUnicode( QCString( xmms->getPlaylistTitle( 0, pos ) ) );
qDebug("unicode end");
if( title.isEmpty() )
title = "XMMS";
qDebug("Title: %s", title.ascii());
songLength = xmms_remote_get_playlist_time( 0, pos );
currentTime = xmms_remote_get_output_time( 0 );
songLength = xmms->getPlaylistTime( 0, pos );
currentTime = xmms->getOutputTime( 0 );
}
#endif // HAVE_XMMS
@ -144,6 +259,9 @@ void XMMSSensor::setMaxValue( SensorParams *sp)
}
bool XMMSSensor::hasXMMS() const
{
return xmms->isInitialized();
}
#include "xmmssensor.moc"

@ -28,10 +28,13 @@ public:
~XMMSSensor();
void update();
void setMaxValue( SensorParams *);
bool hasXMMS() const;
private:
QTextCodec *codec;
class XMMS;
XMMS *xmms;
};

Loading…
Cancel
Save