Bug 652029 - Remove WinCE code from mobile/components/build/ & prune now unused nsIPhoneSupport methods; r=mfinkle
authorEd Morley <bmo@edmorley.co.uk>
Sun, 24 Apr 2011 08:58:51 +0200
changeset 68480 8a822b2befc3faaeee2f9b9dbc6d7fb8e2a97b9f
parent 68479 7b7a77e74c7874f215a1020cf434dd6059be3a5f
child 68481 582c92878440d956e227341c66603de34d2e3b8e
push id19659
push userMs2ger@gmail.com
push dateSun, 24 Apr 2011 12:11:38 +0000
treeherdermozilla-central@8a822b2befc3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs652029
milestone6.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 652029 - Remove WinCE code from mobile/components/build/ & prune now unused nsIPhoneSupport methods; r=mfinkle
mobile/components/build/Makefile.in
mobile/components/build/nsIPhoneSupport.idl
mobile/components/build/nsPhoneSupport.cpp
--- a/mobile/components/build/Makefile.in
+++ b/mobile/components/build/Makefile.in
@@ -80,14 +80,10 @@ LOCAL_INCLUDES   += $(MOZ_DBUS_GLIB_CFLA
 EXTRA_DSO_LDOPTS += $(MOZ_DBUS_GLIB_LIBS)
 endif
 
 ifneq (,$(filter $(MOZ_WIDGET_TOOLKIT),qt))
 LOCAL_INCLUDES += $(MOZ_QT_CFLAGS)
 EXTRA_DSO_LDOPTS += $(MOZ_QT_LIBS)
 endif
 
-ifdef WINCE
-OS_LIBS += $(call EXPAND_LIBNAME, aygshell cellcore)
-endif
-
 include $(topsrcdir)/config/rules.mk
 
--- a/mobile/components/build/nsIPhoneSupport.idl
+++ b/mobile/components/build/nsIPhoneSupport.idl
@@ -35,43 +35,16 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 
-[scriptable, uuid(c75982d6-811b-4321-980d-46490e1a6703)]
+[scriptable, uuid(c893eb89-8650-49d2-aed7-0ef809a2b940)]
 interface nsIPhoneSupport : nsISupports
 {
   /**
-   * This method attempts to make a telephone call.
-   *
-   * @param telephoneNumber this is the telephone to dial.
-   * @param telephoneDescription this is an optional
-   * description of the telephone number.
-   * @param aPrompt this indicates whether to display the confirm call dialog
-   * before dialing   
-   */
-  void makeCall(in wstring telephoneNumber, in wstring telephoneDescription, in boolean aPrompt);
-  
-  /**
    * This method displays a UI to switch to (or launch) a different task
    */
   void switchTask();
-
-  /**
-   * Determines whether or not Fennec is the "Default Browser".
-   * This is simply whether or not Fennec is registered to handle http links.
-   */
-  boolean isDefaultBrowser();
-
-  /**
-   * Registers Fennec as the "Default Browser".
-   */
-  void setDefaultBrowser();
-
-  /**
-   * Restores previous "Default Browser".
-   */
-  void restoreDefaultBrowser();
 };
--- a/mobile/components/build/nsPhoneSupport.cpp
+++ b/mobile/components/build/nsPhoneSupport.cpp
@@ -34,65 +34,31 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifdef WINCE_WINDOWS_MOBILE
-#include <windows.h>
-#include <phone.h>
-#endif
-
 #if (MOZ_PLATFORM_MAEMO == 5)
 #include <dbus/dbus.h>
 #endif
 
 #ifdef MOZ_WIDGET_QT
 #include <QtGui/QApplication>
 #include <QtGui/QWidget>
 #endif
 
 #include "nsPhoneSupport.h"
 #include "nsString.h"
 
 NS_IMPL_ISUPPORTS1(nsPhoneSupport, nsIPhoneSupport)
 
 NS_IMETHODIMP
-nsPhoneSupport::MakeCall(const PRUnichar *telephoneNumber, const PRUnichar *telephoneDescription, PRBool aPrompt)
-{
-  long result = -1;
-
-#ifdef WINCE_WINDOWS_MOBILE
-  typedef LONG (*__PhoneMakeCall)(PHONEMAKECALLINFO *ppmci);
-
-  HMODULE hPhoneDLL = LoadLibraryW(L"phone.dll");
-  if (hPhoneDLL) {
-    __PhoneMakeCall MakeCall = (__PhoneMakeCall) GetProcAddress(hPhoneDLL,
-                                                                "PhoneMakeCall");
-    if (MakeCall) {
-      PHONEMAKECALLINFO callInfo;
-      callInfo.cbSize          = sizeof(PHONEMAKECALLINFO);
-      callInfo.dwFlags         = aPrompt ? PMCF_PROMPTBEFORECALLING : PMCF_DEFAULT;
-      callInfo.pszDestAddress  = telephoneNumber;
-      callInfo.pszAppName      = nsnull;
-      callInfo.pszCalledParty  = telephoneDescription;
-      callInfo.pszComment      = nsnull;
-      result = MakeCall(&callInfo);
-    }
-    FreeLibrary(hPhoneDLL);
-  }
-#endif
-
-  return (result == 0) ? NS_OK : NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP
 nsPhoneSupport::SwitchTask()
 {
 #if (MOZ_PLATFORM_MAEMO == 5)
   DBusError error;
   dbus_error_init(&error);
 
   DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, &error);
 
@@ -110,309 +76,8 @@ nsPhoneSupport::SwitchTask()
   QWidget * window = QApplication::activeWindow();
   if (window)
       window->showMinimized();
   return NS_OK;
 #else
   return NS_ERROR_NOT_IMPLEMENTED;
 #endif
 }
-
-#ifdef WINCE
-
-///////////////////////////////////////////////////////////////////////////////
-// Default Browser Registry Settings
-// Based on the browser\components\shell\src\nsWindowsShellService.cpp
-//
-// The following keys have to be changed for Windows Mobile:
-//
-// [HKEY_LOCAL_MACHINE\Software\Microsoft\Shell\Rai\:DEFBROWSER]
-// 0=Pocket IE
-// 1=:MSPIE
-// 
-// [HKEY_CLASSES_ROOT\file\Shell\Open\Command]
-// [HKEY_CLASSES_ROOT\ftp\Shell\Open\Command]
-// [HKEY_CLASSES_ROOT\http\Shell\Open\Command]
-// [HKEY_CLASSES_ROOT\https\Shell\Open\Command]
-// (Default)=iexplore.exe %1
-// 
-// --- Optional: ---
-// 
-// [HKEY_CLASSES_ROOT\htmlfile\Shell\Open\Command]
-// [HKEY_CLASSES_ROOT\xhtmlfile\Shell\Open\Command]
-// [HKEY_CLASSES_ROOT\xmlfile\Shell\Open\Command]
-// [HKEY_CLASSES_ROOT\xslfile\Shell\Open\Command]
-// (Default)=iexplore.exe file:%1
-// 
-///////////////////////////////////////////////////////////////////////////////
-
-#define MAX_BUF 1024
-
-#define REG_SUCCEEDED(val) \
-  (val == ERROR_SUCCESS)
-
-#define REG_FAILED(val) \
-  (val != ERROR_SUCCESS)
-
-typedef struct {
-  HKEY keyRoot;
-  char* keyName;
-  char* valueName;
-  char* valueData;
-  char* backupValueName;
-} SETTING;
-
-#define APP_REG_NAME "Fennec"
-#define BACKUP_KEY_ROOT HKEY_LOCAL_MACHINE
-#define BACKUP_KEY "Software\\Mozilla\\Fennec\\DefaultBrowserBackup"
-#define DEFBROWSERREG "Software\\Microsoft\\Shell\\Rai\\:DEFBROWSER"
-#define VAL_OPEN "\"%APPPATH%\" \"%1\""
-#define SHELL_OPEN "\\Shell\\Open\\Command"
-
-static SETTING gSettings[] = {
-  { HKEY_LOCAL_MACHINE, DEFBROWSERREG,         "0", APP_REG_NAME,    "Rai_DEFBROWSER_0" },
-  { HKEY_LOCAL_MACHINE, DEFBROWSERREG,         "1", "\"%APPPATH%\"", "Rai_DEFBROWSER_1" },
-  { HKEY_CLASSES_ROOT, "http" SHELL_OPEN,      "",  VAL_OPEN,        "http" },
-  { HKEY_CLASSES_ROOT, "https" SHELL_OPEN,     "",  VAL_OPEN,        "https" },
-  // Optional in Firefox
-  { HKEY_CLASSES_ROOT, "file" SHELL_OPEN,      "",  VAL_OPEN,        "file" },
-  { HKEY_CLASSES_ROOT, "ftp" SHELL_OPEN,       "",  VAL_OPEN,        "ftp" },
-  { HKEY_CLASSES_ROOT, "htmlfile" SHELL_OPEN,  "",  VAL_OPEN,        "htmlfile" },
-  { HKEY_CLASSES_ROOT, "xhtmlfile" SHELL_OPEN, "",  VAL_OPEN,        "xhtmlfile" },
-  { HKEY_CLASSES_ROOT, "xmlfile" SHELL_OPEN,   "",  VAL_OPEN,        "xmlfile" },
-  { HKEY_CLASSES_ROOT, "xslfile" SHELL_OPEN,   "",  VAL_OPEN,        "xslfile" },
-  // Opera changes these as well
-  { HKEY_CLASSES_ROOT, ".htm",                 "",  "htmlfile",      ".htm" },
-  { HKEY_CLASSES_ROOT, ".html",                "",  "htmlfile",      ".html" },
-  { HKEY_CLASSES_ROOT, ".xml",                 "",  "xmlfile",       ".xml" },
-  { HKEY_CLASSES_ROOT, ".xsl",                 "",  "xslfile",       ".xsl" },
-};
-
-const PRInt32 gSettingsCount = sizeof(gSettings)/sizeof(SETTING);
-
-static nsresult
-OpenKeyForReading(HKEY aKeyRoot, const nsAString& aKeyName, HKEY* aKey)
-{
-  const nsString &flatName = PromiseFlatString(aKeyName);
-
-  DWORD res = ::RegOpenKeyExW(aKeyRoot, flatName.get(), 0, KEY_READ, aKey);
-  switch (res) {
-  case ERROR_ACCESS_DENIED:
-    return NS_ERROR_FILE_ACCESS_DENIED;
-  case ERROR_FILE_NOT_FOUND:
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  return NS_OK;
-}
-
-static nsresult
-OpenKeyForWriting(HKEY aStartKey, const nsAString& aKeyName, HKEY* aKey)
-{
-  const nsString &flatName = PromiseFlatString(aKeyName);
-
-  DWORD dwDisp = 0;
-  DWORD res = ::RegCreateKeyExW(aStartKey, flatName.get(), 0, NULL,
-                                0, KEY_READ | KEY_WRITE, NULL, aKey,
-                                &dwDisp);
-  switch (res) {
-  case ERROR_ACCESS_DENIED:
-    return NS_ERROR_FILE_ACCESS_DENIED;
-  case ERROR_FILE_NOT_FOUND:
-    res = ::RegCreateKeyExW(aStartKey, flatName.get(), 0, NULL,
-                            0, KEY_READ | KEY_WRITE, NULL, aKey,
-                            NULL);
-    if (res != ERROR_SUCCESS)
-      return NS_ERROR_FILE_ACCESS_DENIED;
-  }
-
-  return NS_OK;
-}
-
-void
-SetRegValue(HKEY aKeyRoot, const nsString& aKeyName, const nsString& aValueName, const nsString& aValue)
-{
-  PRUnichar buf[MAX_BUF];
-  DWORD len = sizeof buf;
-
-  HKEY theKey;
-  nsresult rv = OpenKeyForWriting(aKeyRoot, aKeyName, &theKey);
-  if (NS_FAILED(rv))
-    return;
-
-  // Get the current value.
-  DWORD res = ::RegQueryValueExW(theKey, PromiseFlatString(aValueName).get(),
-                                 NULL, NULL, (LPBYTE)buf, &len);
-
-  // Set the new value if it doesn't exist or it is different than the current
-  // value.
-  nsAutoString current(buf);
-  if (REG_FAILED(res) || !current.Equals(aValue)) {
-    const nsString &flatValue = PromiseFlatString(aValue);
-
-    ::RegSetValueExW(theKey, PromiseFlatString(aValueName).get(),
-                     0, REG_SZ, (const BYTE *)flatValue.get(),
-                     (flatValue.Length() + 1) * sizeof(PRUnichar));
-  }
-
-  // Close the key we opened.
-  ::RegCloseKey(theKey);
-}
-
-DWORD
-GetRegValue(HKEY aKeyRoot, const nsString& aKeyName, const nsString& aValueName, nsString& aValue)
-{
-  aValue = L"";
-  PRUnichar currValue[MAX_BUF];
-  ::ZeroMemory(currValue, sizeof(currValue));
-  HKEY theKey;
-  DWORD res = OpenKeyForReading(aKeyRoot, aKeyName, &theKey);
-  if (REG_FAILED(res))
-    return res;
-
-  DWORD len = sizeof currValue;
-  res = ::RegQueryValueExW(theKey, PromiseFlatString(aValueName).get(),
-                                 NULL, NULL, (LPBYTE)currValue, &len);
-  // Close the key we opened.
-  ::RegCloseKey(theKey);
-
-  if (REG_SUCCEEDED(res))
-    aValue = currValue;
-
-  return res;
-}
-#endif // WINCE
-
-NS_IMETHODIMP
-nsPhoneSupport::IsDefaultBrowser(PRBool* aIsDefaultBrowser)
-{
-#ifdef WINCE
-  *aIsDefaultBrowser = PR_TRUE;
-
-  SETTING* settings;
-  SETTING* end = gSettings + gSettingsCount;
-
-  PRUnichar exePath[MAX_BUF];
-  if (!::GetModuleFileNameW(0, exePath, MAX_BUF))
-    return NS_ERROR_FAILURE;
-
-  nsAutoString appPath(exePath);
-
-  nsresult rv;
-  PRUnichar currValue[MAX_BUF];
-  for (settings = gSettings; settings < end; ++settings) {
-    NS_ConvertUTF8toUTF16 dataPath(settings->valueData);
-    NS_ConvertUTF8toUTF16 key(settings->keyName);
-    NS_ConvertUTF8toUTF16 value(settings->valueName);
-    PRInt32 offset = dataPath.Find("%APPPATH%");
-    if (offset >= 0)
-      dataPath.Replace(offset, 9, appPath);
-
-    ::ZeroMemory(currValue, sizeof(currValue));
-    HKEY theKey;
-    rv = OpenKeyForReading(settings->keyRoot, key, &theKey);
-    if (NS_FAILED(rv)) {
-      *aIsDefaultBrowser = PR_FALSE;
-      return NS_OK;
-    }
-
-    DWORD len = sizeof currValue;
-    DWORD res = ::RegQueryValueExW(theKey, PromiseFlatString(value).get(),
-                                   NULL, NULL, (LPBYTE)currValue, &len);
-    // Close the key we opened.
-    ::RegCloseKey(theKey);
-    if (REG_FAILED(res) ||
-        !dataPath.Equals(currValue)) {
-      // Key wasn't set, or was set to something other than our registry entry
-      *aIsDefaultBrowser = PR_FALSE;
-      return NS_OK;
-    }
-  }
-
-  return NS_OK;
-#else
-  return NS_ERROR_NOT_IMPLEMENTED;
-#endif
-}
-
-NS_IMETHODIMP
-nsPhoneSupport::SetDefaultBrowser()
-{
-#ifdef WINCE
-  PRBool defaultBrowser = PR_FALSE;
-  nsresult result = IsDefaultBrowser(&defaultBrowser);
-  if (defaultBrowser || result != NS_OK)
-  {
-    // Already set as default browser
-    return result;
-  }
-
-  SETTING* settings;
-  SETTING* end = gSettings + gSettingsCount;
-
-  PRUnichar exePath[MAX_BUF];
-  if (!::GetModuleFileNameW(0, exePath, MAX_BUF))
-    return NS_ERROR_FAILURE;
-
-  nsAutoString appPath(exePath);
-
-  for (settings = gSettings; settings < end; ++settings) {
-    NS_ConvertUTF8toUTF16 dataPath(settings->valueData);
-    NS_ConvertUTF8toUTF16 key(settings->keyName);
-    NS_ConvertUTF8toUTF16 value(settings->valueName);
-    NS_ConvertUTF8toUTF16 backupKey(BACKUP_KEY);
-    NS_ConvertUTF8toUTF16 backupValue(settings->backupValueName);
-    PRInt32 offset = dataPath.Find("%APPPATH%");
-    if (offset >= 0)
-      dataPath.Replace(offset, 9, appPath);
-
-    nsString dataOld;
-    if (REG_SUCCEEDED(GetRegValue(settings->keyRoot, key, value, dataOld))) {
-      SetRegValue(BACKUP_KEY_ROOT, backupKey, backupValue, dataOld);
-      SetRegValue(settings->keyRoot, key, value, dataPath);
-    }
-  }
-  // On Windows CE RegFlushKey can negatively impact performance if there are a
-  // lot of pending writes to the HKEY_CLASSES_ROOT registry hive but it is
-  // necessary to save the values in the case where the user performs a hard
-  // power off of the device.
-  ::RegFlushKey(HKEY_CLASSES_ROOT);
-  ::RegFlushKey(HKEY_LOCAL_MACHINE);
-
-  return NS_OK;
-#else
-  return NS_ERROR_NOT_IMPLEMENTED;
-#endif
-}
-
-NS_IMETHODIMP
-nsPhoneSupport::RestoreDefaultBrowser()
-{
-#ifdef WINCE
-  PRBool defaultBrowser = PR_FALSE;
-  nsresult result = IsDefaultBrowser(&defaultBrowser);
-  if (!defaultBrowser || result != NS_OK)
-  {
-    // Not default browser - nothing to restore
-    return result;
-  }
-
-  SETTING* settings;
-  SETTING* end = gSettings + gSettingsCount;
-
-  for (settings = gSettings; settings < end; ++settings) {
-    NS_ConvertUTF8toUTF16 key(settings->keyName);
-    NS_ConvertUTF8toUTF16 value(settings->valueName);
-    NS_ConvertUTF8toUTF16 backupKey(BACKUP_KEY);
-    NS_ConvertUTF8toUTF16 backupValue(settings->backupValueName);
-
-    nsString dataOld;
-    if (REG_SUCCEEDED(GetRegValue(BACKUP_KEY_ROOT, backupKey, backupValue, dataOld)))
-      SetRegValue(settings->keyRoot, key, value, dataOld);
-  }
-  ::RegFlushKey(HKEY_CLASSES_ROOT);
-  ::RegFlushKey(HKEY_LOCAL_MACHINE);
-
-  return NS_OK;
-#else
-  return NS_ERROR_NOT_IMPLEMENTED;
-#endif
-}