Blob Blame History Raw
From 345ef333025ba386494a7ca0bc1ccd91f319f926 Mon Sep 17 00:00:00 2001
From: Rex Dieter <rdieter@math.unl.edu>
Date: Mon, 22 Sep 2014 15:29:40 -0500
Subject: [PATCH 25/25] more plasma5: ktraderclient5, kreadconfig5,
 kwriteconfig5

---
 scripts/xdg-email.in    |  9 +++++++--
 scripts/xdg-mime.in     | 18 ++++++++++++++----
 scripts/xdg-settings.in | 20 +++++++++++++++++---
 3 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/scripts/xdg-email.in b/scripts/xdg-email.in
index e68425c..c8909d0 100644
--- a/scripts/xdg-email.in
+++ b/scripts/xdg-email.in
@@ -85,8 +85,13 @@ run_thunderbird()
 open_kde()
 {
     local client kde_email_profile_name
-    kde_email_profile_name=`kreadconfig --file emaildefaults --group Defaults --key Profile`
-    client=`kreadconfig --file emaildefaults --group PROFILE_"$kde_email_profile_name" --key EmailClient | cut -d ' ' -f 1`
+    if [ x"${KDE_SESSION_VERSION}" = x"5" ]; then
+        kde_email_profile_name=`kreadconfig5 --file emaildefaults --group Defaults --key Profile`
+        client=`kreadconfig5 --file emaildefaults --group PROFILE_"$kde_email_profile_name" --key EmailClient | cut -d ' ' -f 1`
+    else
+        kde_email_profile_name=`kreadconfig --file emaildefaults --group Defaults --key Profile`
+        client=`kreadconfig --file emaildefaults --group PROFILE_"$kde_email_profile_name" --key EmailClient | cut -d ' ' -f 1`
+    fi
     echo $client | grep thunderbird > /dev/null 2>&1
     if [ $? -eq 0 ] ; then
         run_thunderbird "$client" "$1"
diff --git a/scripts/xdg-mime.in b/scripts/xdg-mime.in
index b324be9..0290d77 100644
--- a/scripts/xdg-mime.in
+++ b/scripts/xdg-mime.in
@@ -398,10 +398,20 @@ defapp_generic()
 defapp_kde()
 {
     MIME="$1"
-    if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
-        KTRADER=`which ktraderclient 2> /dev/null`
-        MIMETYPE="--mimetype"
-        SERVICETYPE="--servicetype"
+
+    if [ -n "${KDE_SESSION_VERSION}" ]; then
+      case "${KDE_SESSION_VERSION}" in
+        4)
+          KTRADER=`which ktraderclient 2> /dev/null`
+          MIMETYPE="--mimetype"
+          SERVICETYPE="--servicetype"
+        ;;
+        5)
+          KTRADER=`which ktraderclient${KDE_SESSION_VERSION} 2> /dev/null`
+          MIMETYPE="--mimetype"
+          SERVICETYPE="--servicetype"
+        ;;
+      esac
     else
         KTRADER=`which ktradertest 2> /dev/null`
     fi
diff --git a/scripts/xdg-settings.in b/scripts/xdg-settings.in
index 460ffc9..20a9f94 100644
--- a/scripts/xdg-settings.in
+++ b/scripts/xdg-settings.in
@@ -146,10 +146,15 @@ read_kde_config()
     configfile="$1"
     configsection="$2"
     configkey="$3"
-    application="`kreadconfig --file $configfile --group $configsection --key $configkey`"
+    if [ x"${KDE_SESSION_VERSION}" = x"5" ]; then
+        application="`kreadconfig5 --file $configfile --group $configsection --key $configkey`"
+    else
+        application="`kreadconfig --file $configfile --group $configsection --key $configkey`"
+    fi
     if [ x"$application" != x ]; then
         echo "$application"
     else
+      if [ x"${KDE_SESSION_VERSION}" = x"4" ]; then
         # kreadconfig in KDE 4 may not notice Key[$*]=... localized settings, so
         # check by hand if it didn't find anything (oddly kwriteconfig works
         # fine though).
@@ -158,6 +163,7 @@ read_kde_config()
         [ ! -f "$configfile_path" ] && return
         # This will only take the first value if there is more than one.
         grep "^$configkey"'\[$[^]=]*\]=' "$configfile_path" | head -n 1 | cut -d= -f 2-
+      fi
     fi
 }
 
@@ -239,7 +245,11 @@ check_browser_kde()
 set_browser_kde()
 {
     set_browser_mime "$1" || return
-    kwriteconfig --file kdeglobals --group General --key BrowserApplication "$1"
+    if [ x"${KDE_SESSION_VERSION}" = x"5" ]; then
+        kwriteconfig5 --file kdeglobals --group General --key BrowserApplication "$1"
+    else
+        kwriteconfig --file kdeglobals --group General --key BrowserApplication "$1"
+    fi
 }
 
 # }}} KDE
@@ -516,7 +526,11 @@ set_url_scheme_handler_kde()
     set_browser_mime "$2" "x-scheme-handler/$1" || return
     if [ "$1" = "mailto" ]; then
         binary="`desktop_file_to_binary "$2"`"
-        kwriteconfig --file emaildefaults --group PROFILE_Default --key EmailClient "$binary"
+        if [ x"${KDE_SESSION_VERSION}" = x"5" ]; then
+            kwriteconfig5 --file emaildefaults --group PROFILE_Default --key EmailClient "$binary"
+        else
+            kwriteconfig --file emaildefaults --group PROFILE_Default --key EmailClient "$binary"
+        fi
     fi
 }
 
-- 
1.9.3