View | Details | Raw Unified | Return to bug 21678
Collapse All | Expand All

(-)a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp (-5 / +19 lines)
Lines 41-56 Link Here
41
#include <glib.h>
41
#include <glib.h>
42
#include <hildon-uri.h>
42
#include <hildon-uri.h>
43
#endif
43
#endif
44
44
45
45
46
#include "nsMIMEInfoUnix.h"
46
#include "nsMIMEInfoUnix.h"
47
#include "nsGNOMERegistry.h"
47
#include "nsGNOMERegistry.h"
48
#include "nsIGnomeVFSService.h"
48
#include "nsIGnomeVFSService.h"
49
#include "nsAutoPtr.h"
49
#ifdef MOZ_ENABLE_DBUS
50
#ifdef MOZ_ENABLE_DBUS
50
#include "nsDBusHandlerApp.h"
51
#include "nsDBusHandlerApp.h"
51
#endif
52
#endif
52
53
53
54
54
nsresult
55
nsresult
55
nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI)
56
nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI)
56
{ 
57
{ 
Lines 69-91 nsMIMEInfoUnix::LoadUriInternal(nsIURI * Link Here
69
#endif
70
#endif
70
  return rv;
71
  return rv;
71
}
72
}
72
73
73
NS_IMETHODIMP
74
NS_IMETHODIMP
74
nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval)
75
nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval)
75
{
76
{
76
  *_retval = PR_FALSE;
77
  *_retval = PR_FALSE;
77
  nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
78
  nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromType(mType);
78
  if (vfs) {
79
  if (!mimeInfo) {
79
    nsCOMPtr<nsIGnomeVFSMimeApp> app;
80
    nsCAutoString ext;
80
    if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app)
81
    GetPrimaryExtension(ext);
81
      *_retval = PR_TRUE;
82
    mimeInfo = nsGNOMERegistry::GetFromExtension(ext);
82
  }
83
  }
83
84
85
  if (mimeInfo)
86
    *_retval = PR_TRUE;
87
84
  if (*_retval)
88
  if (*_retval)
85
    return NS_OK;
89
    return NS_OK;
86
90
87
#ifdef MOZ_PLATFORM_HILDON
91
#ifdef MOZ_PLATFORM_HILDON
88
  HildonURIAction *action = hildon_uri_get_default_action(mType.get(), nsnull);
92
  HildonURIAction *action = hildon_uri_get_default_action(mType.get(), nsnull);
89
  if (action) {
93
  if (action) {
90
    *_retval = PR_TRUE;
94
    *_retval = PR_TRUE;
91
    hildon_uri_action_unref(action);
95
    hildon_uri_action_unref(action);
Lines 104-119 nsMIMEInfoUnix::LaunchDefaultWithFile(ns Link Here
104
  aFile->GetNativePath(nativePath);
108
  aFile->GetNativePath(nativePath);
105
109
106
  nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
110
  nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
107
111
108
  if (vfs) {
112
  if (vfs) {
109
    nsCOMPtr<nsIGnomeVFSMimeApp> app;
113
    nsCOMPtr<nsIGnomeVFSMimeApp> app;
110
    if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app)
114
    if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app)
111
      return app->Launch(nativePath);
115
      return app->Launch(nativePath);
116
117
    // If we haven't got an app we try to get a valid one by searching for the
118
    // extension mapped type
119
    nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromExtension(nativePath);
120
    if (mimeInfo) {
121
      nsCAutoString type;
122
      mimeInfo->GetType(type);
123
      if (NS_SUCCEEDED(vfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
124
        return app->Launch(nativePath);
125
    }
112
  }
126
  }
113
127
114
  if (!mDefaultApplication)
128
  if (!mDefaultApplication)
115
    return NS_ERROR_FILE_NOT_FOUND;
129
    return NS_ERROR_FILE_NOT_FOUND;
116
130
117
  return LaunchWithIProcess(mDefaultApplication, nativePath);
131
  return LaunchWithIProcess(mDefaultApplication, nativePath);
118
}
132
}
119
133
(-)a/uriloader/exthandler/unix/nsOSHelperAppService.cpp (-1 / +9 lines)
Lines 1641-1658 nsOSHelperAppService::GetMIMEInfoFromOS( Link Here
1641
        NS_ADDREF(retval);
1641
        NS_ADDREF(retval);
1642
        if (!aFileExt.IsEmpty())
1642
        if (!aFileExt.IsEmpty())
1643
          retval->AppendExtension(aFileExt);
1643
          retval->AppendExtension(aFileExt);
1644
      }
1644
      }
1645
      
1645
      
1646
      return retval;
1646
      return retval;
1647
    }
1647
    }
1648
1648
1649
    // Copy the attributes of retval onto miByExt, to return it
1649
    // Copy the attributes of retval onto miByExt, to return it but keep
1650
    // just collected mDefaultAppDescription
1651
    nsAutoString byExtDefault;
1652
    miByExt->GetDefaultDescription(byExtDefault);
1653
    retval->SetDefaultDescription(byExtDefault);
1650
    retval->CopyBasicDataTo(miByExt);
1654
    retval->CopyBasicDataTo(miByExt);
1655
    // But set the extensions primary since CopyBasicDataTo overwrites the
1656
    // list
1657
    if (!aFileExt.IsEmpty())
1658
      miByExt->SetPrimaryExtension(aFileExt);
1651
1659
1652
    miByExt.swap(retval);
1660
    miByExt.swap(retval);
1653
  }
1661
  }
1654
  return retval;
1662
  return retval;
1655
}
1663
}
1656
1664
1657
NS_IMETHODIMP
1665
NS_IMETHODIMP
1658
nsOSHelperAppService::GetProtocolHandlerInfoFromOS(const nsACString &aScheme,
1666
nsOSHelperAppService::GetProtocolHandlerInfoFromOS(const nsACString &aScheme,

Return to bug 21678