From 4ffce7bb907da506241abd687dcd8a641f403f55 Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Thu, 4 Mar 2021 14:46:45 +0200 Subject: [PATCH] Scheduler scipt: store path to ICEauthority file in script. This hopefully resolves issue #21. Signed-off-by: Mavridis Philippe --- src/schedule.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++--- src/schedule.h | 8 +++++++ 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/src/schedule.cpp b/src/schedule.cpp index 75e18b9..c0250ed 100644 --- a/src/schedule.cpp +++ b/src/schedule.cpp @@ -21,6 +21,8 @@ #include #include +/* Finding out ICEauthority path */ +#include Schedule::Schedule( TQWidget* parent, TQStringList filepattern, const char* name, bool modal, WFlags fl ) : TQDialog( parent, name, modal, fl ) @@ -33,17 +35,19 @@ Schedule::Schedule( TQWidget* parent, TQStringList filepattern, const char* name // for each user // CTCronIterator i = const_cast(cth).cron.begin(); -// CTCron* ctcron((CTCron*)*i); +// CTCron* ctcron((CTCron*)*i); + /* Figure out where the ICEauthority file is located */ + getICEauth(); _filepattern = filepattern; //bool isRTL = TQApplication::reverseLayout(); TQVBoxLayout *vbox = new TQVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint(), "vbox"); - + TQGroupBox *group = new TQGroupBox("Schedule Scan of Selected Folders", this); vbox->addWidget(group); - + TQGridLayout *layout = new TQGridLayout( group, 6, 6, KDialog::spacingHint(), @@ -371,6 +375,8 @@ TQString Schedule::createScanScript() ts << " done" << "\n"; ts << "fi" << "\n"; ts << "export DCOPSERVER=`cat ${HOME}/.DCOPserver_${HOSTNAME}_${DISPLAY} | grep local`" << "\n"; + /* This path is always the same for the current user */ + ts << TQString("export ICEAUTHORITY=%1 # issue 21").arg(iceauth) << "\n"; ts << "# Execution starts here" << "\n"; ts << "if [ \"$1\" = \"\" ]; then" << "\n"; ts << " exit 1" << "\n"; @@ -468,6 +474,50 @@ TQString Schedule::createStartupScript() } +void Schedule::getICEauth() +{ + /* Code taken from freshklam.cpp */ + TQString command=TQString("iceauth -v exit"); + + iceproc = new KProcIO(); + iceproc->setUseShell(TRUE); + iceproc->setUsePty(KProcIO::Stdout,TRUE); + + *iceproc<start(KProcIO::NotifyOnExit); + iceproc->closeWhenDone(); +} + + +void Schedule::slotICEexited() +{ + delete iceproc; +} + +void Schedule::slotICEoutput(KProcIO *) +{ + TQString lineout = ""; + int pos; + + if ((pos = (iceproc->readln(lineout))) != -1) { + if ((pos = (lineout.find("Using authority file"))) != -1){ + lineout = lineout.stripWhiteSpace(); + int StartPoint = (lineout.find("Using authority file") + 20); + iceauth = lineout.mid(StartPoint).stripWhiteSpace(); + // kdDebug() << "iceauth file: " << iceauth << endl; + } + } + + iceproc->ackRead(); + lineout = ""; +} + HMSTimeWidget::HMSTimeWidget(TQWidget *parent, const char *name) : diff --git a/src/schedule.h b/src/schedule.h index d3725fd..486019a 100644 --- a/src/schedule.h +++ b/src/schedule.h @@ -43,6 +43,7 @@ class KURLRequester; class CollectionSetup; class TQToolButton; class TQHBoxLayout; +class KProcIO; class HMSTimeWidget : public KIntSpinBox { @@ -123,11 +124,17 @@ private slots: void slotDelete(); void slotOK(); void slotCancel(); + + void slotICEoutput(KProcIO *); + void slotICEexited(); private: void setupAccel(); void setupActions(); TQString createScanScript(); TQString createStartupScript(); + + TQString iceauth; + void getICEauth(); private: signals: @@ -163,6 +170,7 @@ private: CTHost* cthost; CTTask* cttask; CTCron* ctcron; + KProcIO *iceproc; };