diff -Nru xdg-utils-1.1.0~rc1/debian/changelog xdg-utils-1.1.0~rc1/debian/changelog --- xdg-utils-1.1.0~rc1/debian/changelog 2011-03-30 14:11:28.000000000 +0100 +++ xdg-utils-1.1.0~rc1/debian/changelog 2011-04-08 02:03:28.000000000 +0100 @@ -1,3 +1,16 @@ +xdg-utils (1.1.0~rc1-2ubuntu2) natty; urgency=low + + * Fix LP: #670128 - gnome-open uses firefox while it's not the preferred + browser. Backport upstream changes to use the x-scheme-handler types + for checking/setting the default browser/mail client in xdg-settings + and xdg-email. In addition to this, we fix xdg-mime to get/set + default mimetype handlers using the users mimeapps.list, rather than + the defaults.list, which doesn't work anywhere + - add debian/patches/gnome-3.0.diff + - update debian/patches/series + + -- Chris Coulson Fri, 08 Apr 2011 02:00:05 +0100 + xdg-utils (1.1.0~rc1-2ubuntu1) natty; urgency=low [ Martin Pitt ] diff -Nru xdg-utils-1.1.0~rc1/debian/patches/gnome-3.0.diff xdg-utils-1.1.0~rc1/debian/patches/gnome-3.0.diff --- xdg-utils-1.1.0~rc1/debian/patches/gnome-3.0.diff 1970-01-01 01:00:00.000000000 +0100 +++ xdg-utils-1.1.0~rc1/debian/patches/gnome-3.0.diff 2011-04-08 01:59:54.000000000 +0100 @@ -0,0 +1,289 @@ +Description: Make the default mail client and browser settings work with the + x-scheme-handler method of registering URI handlers in gnome3. Note, this is loosely + based on http://cgit.freedesktop.org/xdg/xdg-utils/commit/?id=6f49c05ceb2a1935d07c49c2e100b5cf3cdf5f26, + however, we don't maintain separate methods for gnome and gnome3. The upstream gnome3 + detection doesn't work on Natty because we're not really using gnome3. In addition to this, + when we set the defaults we use both the new and old methods so that we preserve the + functionality of legacy apps using gnomevfs. + + This also contains additional changes to get/set default mimetype handlers from the users + mimeapps.list rather than defaults.list, which isn't used by anything + (see http://www.freedesktop.org/wiki/Specifications/mime-actions-spec) +Author: Bastien Nocera +Author: Chris Coulson +Bug-Ubuntu: https://launchpad.net/bugs/670128 + +--- a/scripts/xdg-email ++++ b/scripts/xdg-email +@@ -310,6 +310,24 @@ check_output_file() + fi + } + ++desktop_file_to_binary() ++{ ++ search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" ++ desktop="`basename "$1"`" ++ IFS=: ++ for dir in $search; do ++ unset IFS ++ [ "$dir" -a -d "$dir/applications" ] || continue ++ file="$dir/applications/$desktop" ++ [ -r "$file" ] || continue ++ # Remove any arguments (%F, %f, %U, %u, etc.). ++ command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`" ++ command="`which "$command"`" ++ readlink -f "$command" ++ return ++ done ++} ++ + #---------------------------------------- + # Checks for shared commands, e.g. --help + +@@ -479,7 +497,9 @@ open_kde() + open_gnome() + { + local client +- client=`gconftool-2 --get /desktop/gnome/url-handlers/mailto/command | cut -d ' ' -f 1` || "" ++ local desktop ++ desktop=`xdg-mime query default "x-scheme-handler/mailto"` ++ client=`desktop_file_to_binary "$browser"` + echo $client | grep thunderbird > /dev/null 2>&1 + if [ $? -eq 0 ] ; then + run_thunderbird "$client" "$1" +--- a/scripts/xdg-settings ++++ b/scripts/xdg-settings +@@ -418,21 +418,26 @@ desktop_file_to_binary() + # This function is hard-coded for text/html but it could be adapted if needed. + fix_local_desktop_file() + { ++ if test -z "$2" ; then ++ MIME="text/html" ++ else ++ MIME="$2" ++ fi + apps="${XDG_DATA_HOME:-$HOME/.local/share}/applications" + # No local desktop file? + [ ! -f "$apps/$1" ] && return +- MIME="`grep "^MimeType=" "$apps/$1" | cut -d= -f 2-`" +- case "$MIME" in +- text/html\;*|*\;text/html\;*|*\;text/html\;|*\;text/html) +- # Already has text/html? Great! ++ MIMETYPES="`grep "^MimeType=" "$apps/$1" | cut -d= -f 2-`" ++ case "$MIMETYPES" in ++ $MIME\;*|*\;$MIME\;*|*\;$MIME\;|*\;$MIME) ++ # Already has the mime-type? Great! + return 0 + ;; + esac + +- # Add text/html to the list ++ # Add the mime-type to the list + temp="`mktemp "$apps/$1.XXXXXX"`" || return + grep -v "^MimeType=" "$apps/$1" >> "$temp" +- echo "MimeType=text/html;$MIME" >> "$temp" ++ echo "MimeType=$MIME;$MIMETYPES" >> "$temp" + + oldlines="`wc -l < "$apps/$1"`" + newlines="`wc -l < "$temp"`" +@@ -466,22 +471,32 @@ xdg_mime_fixup() + + get_browser_mime() + { ++ if test -z "$1" ; then ++ MIME="text/html" ++ else ++ MIME="$1" ++ fi + xdg_mime_fixup +- xdg-mime query default text/html ++ xdg-mime query default "$MIME" + } + + set_browser_mime() + { + xdg_mime_fixup +- orig="`get_browser_mime`" ++ if test -z "$2" ; then ++ MIME="text/html" ++ else ++ MIME="$2" ++ fi ++ orig="`get_browser_mime $MIME`" + # Fixing the local desktop file can actually change the default browser all + # by itself, so we fix it only after querying to find the current default. +- fix_local_desktop_file "$1" || return ++ fix_local_desktop_file "$1" "$MIME" || return + mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/applications" +- xdg-mime default "$1" text/html || return +- if [ x"`get_browser_mime`" != x"$1" ]; then ++ xdg-mime default "$1" "$MIME" || return ++ if [ x"`get_browser_mime $MIME`" != x"$1" ]; then + # Put back the original value +- xdg-mime default "$orig" text/html ++ xdg-mime default "$orig" "$MIME" + exit_failure_operation_failed + fi + } +@@ -585,32 +600,32 @@ set_browser_kde() + + get_browser_gnome() + { +- binary="`gconftool-2 --get /desktop/gnome/applications/browser/exec | first_word`" +- if [ x"$binary" = x ]; then +- # No default browser; GNOME might use the MIME type text/html. +- get_browser_mime +- else +- # gconftool gives the binary (maybe with %s etc. afterward), +- # but we want the desktop file name, not the binary. So, we +- # have to find the desktop file to which it corresponds. +- desktop="`binary_to_desktop_file "$binary"`" +- basename "$desktop" +- fi ++ get_browser_mime "x-scheme-handler/http" + } + + check_browser_gnome() + { ++ desktop="$1" + check="`desktop_file_to_binary "$1"`" + if [ -z "$check" ]; then + echo no + exit_success + fi ++ # Check HTTP and HTTPS, but not about: and unknown:, using the GNOME 3 scheme. ++ for protocol in http https; do ++ browser="`get_browser_mime "x-scheme-handler/$protocol"`" ++ if [ x"$browser" != x"$desktop" ]; then ++ echo no ++ exit_success ++ fi ++ done ++ + binary="`gconftool-2 --get /desktop/gnome/applications/browser/exec | first_word`" + if [ x"$binary" != x"$check" ]; then + echo no + exit_success + fi +- # Check HTTP and HTTPS, but not about: and unknown:. ++ # Check HTTP and HTTPS, but not about: and unknown:, using the legacy GNOME scheme. + for protocol in http https; do + binary="`gconftool-2 --get /desktop/gnome/url-handlers/$protocol/command | first_word`" + if [ x"$binary" != x"$check" ]; then +@@ -634,7 +649,12 @@ set_browser_gnome() + [ "$binary" ] || exit_failure_file_missing + set_browser_mime "$1" || return + +- # Set the default browser. ++ # Set the default browser using the GNOME 3 scheme. ++ for protocol in http https about unknown; do ++ set_browser_mime "$1" "x-scheme-handler/$protocol" || return ++ done ++ ++ # Set the default browser using the legacy GNOME scheme. + gconftool-2 --type string --set /desktop/gnome/applications/browser/exec "$binary" + gconftool-2 --type bool --set /desktop/gnome/applications/browser/needs_term false + gconftool-2 --type bool --set /desktop/gnome/applications/browser/nremote true +--- a/scripts/xdg-mime ++++ b/scripts/xdg-mime +@@ -667,15 +667,57 @@ make_default_generic() + # Add $2=$1 to XDG_DATA_HOME/applications/defaults.list + xdg_user_dir="$XDG_DATA_HOME" + [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share" +- default_file="$xdg_user_dir/applications/defaults.list" ++ default_file="$xdg_user_dir/applications/mimeapps.list" + DEBUG 2 "make_default_generic $1 $2" + DEBUG 1 "Updating $default_file" +- grep -v "$2=" $default_file > ${default_file}.new 2> /dev/null +- if ! grep "[Default Applications]" ${default_file}.new > /dev/null; then +- echo "[Default Applications]" >> ${default_file}.new +- fi +- echo $2=$1 >> ${default_file}.new +- mv ${default_file}.new $default_file ++ awk -v mimetype="$2" -v application="$1" ' ++ BEGIN { ++ prefix=mimetype "=" ++ indefault=0 ++ added=0 ++ blanks=0 ++ found=0 ++ } ++ { ++ suppress=0 ++ if (index($0, "[Default Applications]") == 1) { ++ indefault=1 ++ found=1 ++ } else if (index($0, "[") == 1) { ++ if (!added && indefault) { ++ print prefix application ++ added=1 ++ } ++ indefault=0 ++ } else if ($0 == "") { ++ suppress=1 ++ blanks++ ++ } else if (indefault && !added && index($0, prefix) == 1) { ++ $0=prefix application ++ added=1 ++ } ++ if (!suppress) { ++ while (blanks > 0) { ++ print "" ++ blanks-- ++ } ++ print $0 ++ } ++ } ++ END { ++ if (!added) { ++ if (!found) { ++ print "" ++ print "[Default Applications]" ++ } ++ print prefix application ++ } ++ while (blanks > 0) { ++ print "" ++ blanks-- ++ } ++ } ++' $default_file > ${default_file}.new && mv ${default_file}.new $default_file + } + + defapp_generic() +@@ -687,7 +729,34 @@ defapp_generic() + 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 ++ for x in `echo "$xdg_user_dir" | sed 's/:/ /g'`; do ++ mimeapps_list="$x/applications/mimeapps.list" ++ if [ -f "$mimeapps_list" ] ; then ++ trader_result=`awk -v mimetype="$MIME" ' ++ BEGIN { ++ prefix=mimetype "=" ++ indefault=0 ++ found=0 ++ } ++ { ++ if (index($0, "[Default Applications]") == 1) { ++ indefault=1 ++ } else if (index($0, "[") == 1) { ++ indefault=0 ++ } else if (!found && indefault && index($0, prefix) == 1) { ++ print substr($0, length(prefix) +1, length) ++ found=1 ++ } ++ } ++' $mimeapps_list` ++ if [ -n "$trader_result" ] ; then ++ echo $trader_result ++ exit_success ++ fi ++ fi ++ done ++ ++ for x in `echo "$xdg_system_dirs" | sed 's/:/ /g'`; do + DEBUG 2 "Checking $x/applications/defaults.list" + trader_result=`grep "$MIME=" $x/applications/defaults.list 2> /dev/null | cut -d '=' -f 2 | cut -d ';' -f 1` + if [ -n "$trader_result" ] ; then diff -Nru xdg-utils-1.1.0~rc1/debian/patches/series xdg-utils-1.1.0~rc1/debian/patches/series --- xdg-utils-1.1.0~rc1/debian/patches/series 2011-03-30 14:11:33.000000000 +0100 +++ xdg-utils-1.1.0~rc1/debian/patches/series 2011-04-07 14:14:13.000000000 +0100 @@ -8,3 +8,4 @@ xdg-open-browser-multiword.diff xdg-open-printf.diff xdg-update-menu-caonicalize-defaults.list.diff +gnome-3.0.diff