| Summary: | [Hob] "View files" does not work on my 32bit Ubuntu 11.04 | ||
|---|---|---|---|
| Product: | [Build System, Metadata & Runtime] Hob | Reporter: | Jiajun Xu <jiajun.xu> |
| Component: | hob | Assignee: | Shane Wang <shane.wang> |
| Status: | VERIFIED WORKSFORME | QA Contact: | |
| Severity: | minor | ||
| Priority: | Low | CC: | andreea.b.proca, dongxiao.xu, jessica.zhang, jiajun.xu, poky.bs.watcher, poky.watcher |
| Version: | unspecified | ||
| Target Milestone: | 1.2 M4 | ||
| Hardware: | x86 | ||
| OS: | Multiple | ||
| Whiteboard: | |||
| OS type for building Yocto: | --- | Type of Regression: | --- |
| Verified: | Documentation change: | No (bug/feature does not impact docs) | |
|
Description
Jiajun Xu
2012-04-18 08:51:06 UTC
That is a bug for xdg-open. Jiajun is using xdg-open 1.0.1. On my Ubuntu 10.10 x86_64, the version of xdg-open is 1.0.2 and I don't have that issue. Here is the diff between two xdg-opens.
--- /usr/bin/xdg-open.orig 2010-03-11 23:54:02.000000000 -0800
+++ /usr/bin/xdg-open 2012-04-18 20:42:18.341913133 -0700
@@ -200,7 +200,7 @@
}
#------------------------------------------------------------
-# Exit script on insufficient permission to read a specified file
+# Exit script on insufficient permission to write a specified file
exit_failure_file_permission_write()
{
@@ -277,7 +277,7 @@
;;
--version)
- echo "xdg-open 1.0.1"
+ echo "xdg-open 1.0.2"
exit_success
;;
esac
@@ -303,7 +303,8 @@
{
if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
- elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+ elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=gnome;
+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
fi
}
@@ -314,7 +315,7 @@
kfmclient_fix_exit_code()
{
- version=`kde-config --version 2>/dev/null | grep KDE`
+ version=`kde${KDE_SESSION_VERSION}-config --version 2>/dev/null | grep KDE`
major=`echo $version | sed 's/KDE: \([0-9]\).*/\1/'`
minor=`echo $version | sed 's/KDE: [0-9]*\.\([0-9]\).*/\1/'`
release=`echo $version | sed 's/KDE: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
@@ -324,12 +325,25 @@
return 0
}
-open_kde()
+# This handles backslashes but not quote marks.
+first_word()
{
- which kfmclient >/dev/null || open_generic "$1"
+ read first rest
+ echo "$first"
+}
- kfmclient exec "$1"
- kfmclient_fix_exit_code $?
+open_kde()
+{
+ if kde-open -v 2>/dev/null 1>&2; then
+ kde-open "$1"
+ else
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ kfmclient openURL "$1"
+ else
+ kfmclient exec "$1"
+ kfmclient_fix_exit_code $?
+ fi
+ fi
if [ $? -eq 0 ]; then
exit_success
@@ -340,7 +354,11 @@
open_gnome()
{
- gnome-open "$1"
+ if gvfs-open --help 2>/dev/null 1>&2; then
+ gvfs-open "$1"
+ else
+ gnome-open "$1"
+ fi
if [ $? -eq 0 ]; then
exit_success
@@ -360,38 +378,73 @@
fi
}
+open_generic_xdg_mime()
+{
+ filetype=`xdg-mime query filetype "$1" | sed "s/;.*//"`
+ default=`xdg-mime query default "$filetype"`
+ if [ -n "$default" ] ; then
+ xdg_user_dir="$XDG_DATA_HOME"
+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+
+ xdg_system_dirs="$XDG_DATA_DIRS"
+ [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
+
+ for x in `echo "$xdg_user_dir:$xdg_system_dirs" | sed 's/:/ /g'`; do
+ file="$x/applications/$default"
+ if [ -r "$file" ] ; then
+ command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
+ command_exec=`which $command 2>/dev/null`
+ if [ -x "$command_exec" ] ; then
+ $command_exec "$1"
+ if [ $? -eq 0 ]; then
+ exit_success
+ fi
+ fi
+ fi
+ done
+ fi
+}
+
open_generic()
{
- # If it's a path or a file:/// URL, we can open it with run-mailcap
- if which run-mailcap >/dev/null &&
- (echo "$1" | grep -q '^file:///' ||
- ! echo "$1" | egrep -q '^[a-zA-Z+\.\-]+:'); then
-
- local file
- file="$1"
-
- # Decode URLs
- if echo "$file" | grep -q '^file:///'; then
- file=${file#file://}
- file=$(echo "$file" | perl -pe 's/%(..)/pack("c", hex($1))/eg')
- fi
-
- run-mailcap --action=view "$file"
-
- if [ $? -eq 0 ]; then
- exit_success
- else
- exit_failure_operation_failed
- fi
+ # Paths or file:// URLs
+ if (echo "$1" | grep -q '^file://' ||
+ ! echo "$1" | egrep -q '^[a-zA-Z+\.\-]+:'); then
+
+ local file="$1"
+
+ # Decode URLs
+ if echo "$file" | grep -q '^file:///'; then
+ file=${file#file://}
+ file=$(echo "$file" | perl -pe 's/%(..)/pack("c", hex($1))/eg')
+ fi
+
+ check_input_file "$file"
+
+ open_generic_xdg_mime "$file"
+
+ if [ -f /etc/debian_version ] &&
+ which run-mailcap 2>/dev/null 1>&2; then
+ run-mailcap --action=view "$file"
+ if [ $? -eq 0 ]; then
+ exit_success
+ fi
+ fi
+
+ if mimeopen -v 2>/dev/null 1>&2; then
+ mimeopen -n "$file"
+ if [ $? -eq 0 ]; then
+ exit_success
+ fi
+ fi
fi
sensible-browser "$1"
-
if [ $? -eq 0 ]; then
exit_success
- else
- exit_failure_operation_failed
fi
+
+ exit_failure_operation_impossible "no method available for opening '$1'"
}
[ x"$1" != x"" ] || exit_failure_syntax
Please upgrade to the latest xdg-open, and I will mark it "work for me" By the way, I copy my xdg-open to Jiajun's machine, it works. Verified in master:a02280f99f05b1c21de2a78de9222a2f62a0dabc. |