Bug 2325 - [Hob] "View files" does not work on my 32bit Ubuntu 11.04
Summary: [Hob] "View files" does not work on my 32bit Ubuntu 11.04
Status: VERIFIED WORKSFORME
Alias: None
Product: Hob
Classification: Build System, Metadata & Runtime
Component: hob (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Low minor
Target Milestone: 1.2 M4
Assignee: Shane Wang
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2012-04-18 08:51 UTC by Jiajun Xu
Modified: 2013-10-03 13:56 UTC (History)
6 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jiajun Xu 2012-04-18 08:51:06 UTC
tree/branch: poky/master
commit: 720fe9e371eef16da19df0885188aa0341ad2090

On my 32bit Ubuntu 11.04, I find that if an image is build finished or I open an image with icon "Images" and open it, the "View files" icon does not work. No window pop up with following error. The issue does not happen on Ubuntu 11.10 and Fedora 16.

######
Warning: unknown mime-type for "//home/jxu49/osel/poky/hob2/tmp/deploy/images" -- using "application/octet-stream"
Error: no "view" mailcap rules found for type "application/octet-stream"
######
Comment 1 Shane Wang 2012-04-18 13:36:22 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.
Comment 2 Shane Wang 2012-04-18 13:38:19 UTC
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
Comment 3 Shane Wang 2012-04-18 13:39:11 UTC
Please upgrade to the latest xdg-open, and I will mark it "work for me"
Comment 4 Shane Wang 2012-04-18 13:41:41 UTC
By the way, I copy my xdg-open to Jiajun's machine, it works.
Comment 5 Andreea Brandusa Proca 2013-10-03 13:56:14 UTC
Verified in master:a02280f99f05b1c21de2a78de9222a2f62a0dabc.