LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (http://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   korganizer(3.5) alarm/reminder script argument problem (http://www.linuxquestions.org/questions/linux-desktop-74/korganizer-3-5-alarm-reminder-script-argument-problem-478597/)

mattsn 08-29-2006 08:19 PM

korganizer(3.5) alarm/reminder script argument problem
 
Hi all,

I'm using KDE 3.5.2, and korganizer 3.5, and have a simple problem.
In the advanced alarm configuration section for events and todos, there is a textbox where you can pass arguments to the script that the alarm will run. However, nothing entered in this textbox actually makes it to the script as an argument. I ran a sample bash script which indicates an argument list length of zero, no matter how many arguments were placed in this textbox, quoted or not.

Hope someone can help!
=)
Matt

mpdavig 12-05-2006 11:35 PM

Not implemented yet, patch included
 
This is not unlike the grayed out Email Reminder Type, the Program file: value is used however the Program arguments: value is ignored. The following patch adds support for this field and any number of arguments. It also allows you to use substitution characters as arguments as well:

%c - Categories
%d - Description
%D - Start date
%e - End date
%l - Location
%o - Organizer
%s - Summary

This patch is not mine, I just adapted it for korganizer 3.5.5, should work for all 3.5.x's though.

http://lists.kde.org/?l=kde-pim&m=112006762610911&w=2

--- begin patch text ---
Code:

diff -Naur kdepim-3.5.5/korganizer/korgac/alarmdialog.cpp kdepim-3.5.5.arg/korganizer/korgac/alarmdialog.cpp
--- kdepim-3.5.5/korganizer/korgac/alarmdialog.cpp    2005-09-10 04:24:44.000000000 -0400
+++ kdepim-3.5.5.arg/korganizer/korgac/alarmdialog.cpp    2006-12-05 16:45:39.000000000 -0500
@@ -38,11 +38,13 @@
 #include <kprocess.h>
 #include <kaudioplayer.h>
 #include <kdebug.h>
+#include <kmacroexpander.h>
 #include <kmessagebox.h>
 #include <knotifyclient.h>
 #include <kcombobox.h>
 #include <kwin.h>
 #include <klockfile.h>
+#include <kshell.h>
 
 #include <libkcal/event.h>
 
@@ -196,12 +198,54 @@
  Alarm::List::ConstIterator it;
  for ( it = alarms.begin(); it != alarms.end(); ++it ) {
    Alarm *alarm = *it;
+
+    // MPD 12/05/2006: Add Argument support for Alarm::Procedure
 // FIXME: Check whether this should be done for all multiple alarms
-    if (alarm->type() == Alarm::Procedure) {
+    if (alarm->type() == Alarm::Procedure && !alarm->programFile().isEmpty() ) {
 // FIXME: Add a message box asking whether the procedure should really be executed
-      kdDebug(5890) << "Starting program: '" << alarm->programFile() << "'" << endl;
      KProcess proc;
+      QString expanded;
      proc << QFile::encodeName(alarm->programFile());
+      kdDebug(5890) << "Program name: '" << alarm->programFile() << "'" << endl;
+      kdDebug(5890) << "Arguments: '" << alarm->programArguments() << "'" << endl;
+      //
+      // Arguments
+      if (!alarm->programArguments().isEmpty() ) {
+        QMap<QChar,QString> subst;
+        subst.insert( 'c', mIncidence->categoriesStr() );
+        subst.insert( 'd', mIncidence->description() );
+        subst.insert( 'D', mIncidence->dtStart().toString());
+        subst.insert( 'e', mIncidence->dtEnd().toString() );
+        subst.insert( 'l', mIncidence->location() );
+        subst.insert( 'o', mIncidence->organizer().fullName() );
+        subst.insert( 's', mIncidence->summary() );
+
+        //If the procedure failures on reading, no procedure is invoked
+        //(RFC2445 p.71)
+        expanded = KMacroExpander::expandMacrosShellQuote(
+            alarm->programArguments(), subst );
+
+        if ( expanded.isEmpty() ) {
+          kdDebug( 5890 ) << "error on expanding arguments: " << expanded << endl;
+          continue; //continue with the next alarms
+        }
+
+        kdDebug( 5890 ) << "Arguments expanded: " << expanded << endl;
+
+        int err;
+        proc << KShell::splitArgs( expanded, KShell::NoOptions, &err );
+
+        if ( err ) {
+          kdDebug( 5890 ) << "error on spliting arguments: " << expanded << endl;
+          continue; //continue with the next alarms
+        }
+
+      }
+
+      kdDebug(5890) << "Starting program: '" << alarm->programFile()
+        << " " << expanded << "'" << endl;
+      // MPD 12/05/2006: End of Argument support changes
+
      proc.start(KProcess::DontCare);
    }
    else if (alarm->type() == Alarm::Audio) {

--- endof patch text ---


All times are GMT -5. The time now is 04:11 AM.