b=479733; stub out clipboard service on Windows CE, and reenable nsSound; r=dougt
authorVladimir Vukicevic <vladimir@pobox.com>
Tue, 14 Apr 2009 14:59:58 -0700
changeset 27335 0fa3d40dbeb7895e4eaaf7e8995cfaf30af96864
parent 27334 a55ed9d7328acc2a2c1c3feeed276c98b0c9993d
child 27336 2d9d7822862a2a5065511743ac3f0840588ffa02
push idunknown
push userunknown
push dateunknown
reviewersdougt
bugs479733
milestone1.9.2a1pre
b=479733; stub out clipboard service on Windows CE, and reenable nsSound; r=dougt
widget/src/build/nsWinWidgetFactory.cpp
widget/src/windows/Makefile.in
widget/src/windows/nsClipboardCE.cpp
widget/src/windows/nsClipboardCE.h
widget/src/windows/nsDataObj.cpp
widget/src/windows/nsSound.cpp
--- a/widget/src/build/nsWinWidgetFactory.cpp
+++ b/widget/src/build/nsWinWidgetFactory.cpp
@@ -51,20 +51,24 @@
 #include "nsLookAndFeel.h"
 #include "nsNativeThemeWin.h"
 #include "nsScreenManagerWin.h"
 #include "nsSound.h"
 #include "nsToolkit.h"
 #include "nsWindow.h"
 
 // Drag & Drop, Clipboard
-#ifndef WINCE
+
+#include "nsClipboardHelper.h"
+
+#ifdef WINCE
+#include "nsClipboardCE.h"
+#else
+#include "nsClipboard.h"
 #include "nsBidiKeyboard.h"
-#include "nsClipboard.h"
-#include "nsClipboardHelper.h"
 #include "nsDragService.h"
 #include "nsHTMLFormatConverter.h"
 #include "nsTransferable.h"
 #endif
 
 #ifdef NS_PRINTING
 #include "nsDeviceContextSpecWin.h"
 #include "nsPrintOptionsWin.h"
@@ -73,23 +77,23 @@
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
 NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerWin)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceWin)
-
-#ifndef WINCE
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
+
+#ifndef WINCE
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
 #endif
 
 #ifdef NS_PRINTING
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsWin, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorWin)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
@@ -130,30 +134,30 @@ static const nsModuleComponentInfo compo
     NS_THEMERENDERER_CID,
     "@mozilla.org/chrome/chrome-native-theme;1", 
     NS_NewNativeTheme
   },
   { "User Idle Service",
     NS_IDLE_SERVICE_CID,
     "@mozilla.org/widget/idleservice;1",
     nsIdleServiceWinConstructor },
-
-#ifndef WINCE
   { "Clipboard",
     NS_CLIPBOARD_CID,
     "@mozilla.org/widget/clipboard;1",
     nsClipboardConstructor },
   { "Clipboard Helper",
     NS_CLIPBOARDHELPER_CID,
     "@mozilla.org/widget/clipboardhelper;1",
     nsClipboardHelperConstructor },
   { "Sound",
     NS_SOUND_CID,
     "@mozilla.org/sound;1",
     nsSoundConstructor },
+
+#ifndef WINCE
   { "Drag Service",
     NS_DRAGSERVICE_CID,
     "@mozilla.org/widget/dragservice;1",
     nsDragServiceConstructor },
   { "Bidi Keyboard",
     NS_BIDIKEYBOARD_CID,
     "@mozilla.org/widget/bidikeyboard;1",
     nsBidiKeyboardConstructor },
--- a/widget/src/windows/Makefile.in
+++ b/widget/src/windows/Makefile.in
@@ -81,39 +81,43 @@ CPPSRCS		= \
 	nsFilePicker.cpp     \
 	nsScreenWin.cpp	\
 	nsScreenManagerWin.cpp \
 	nsLookAndFeel.cpp    \
 	nsUXThemeData.cpp \
 	nsNativeThemeWin.cpp \
 	nsWinGesture.cpp \
 	nsIdleServiceWin.cpp \
+	nsSound.cpp          \
 	$(NULL)
 
 ifdef NS_PRINTING
 CPPSRCS		+= \
 	nsPrintOptionsWin.cpp \
 	nsPrintSettingsWin.cpp \
 	nsDeviceContextSpecWin.cpp \
 	$(NULL)
 endif
 
-ifneq ($(OS_ARCH), WINCE)
+ifeq ($(OS_ARCH), WINCE)
+CPPSRCS += \
+	nsClipboardCE.cpp \
+	$(NULL)
+else
 CPPSRCS += \
 	nsKeyboardLayout.cpp \
 	IEnumFE.cpp  \
 	nsDataObj.cpp  \
 	nsDataObjCollection.cpp  \
 	nsNativeDragTarget.cpp  \
 	nsNativeDragSource.cpp  \
 	nsDragService.cpp  \
 	nsClipboard.cpp      \
 	nsImageClipboard.cpp \
 	nsBidiKeyboard.cpp   \
-	nsSound.cpp          \
 	nsTextStore.cpp \
 	$(NULL)
 endif
 
 
 DEFINES		+= -D_IMPL_NS_WIDGET -DMOZ_UNICODE 
 
 ifdef BUILD_STATIC_LIBS
new file mode 100644
--- /dev/null
+++ b/widget/src/windows/nsClipboardCE.cpp
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ *   Mozilla Corporation
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *    Vladimir Vukicevic <vladimir@pobox.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * 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 ***** */
+
+#include "nsClipboardCE.h"
+
+#include <winuserm.h>
+
+nsClipboard::nsClipboard()
+{
+}
+
+nsClipboard::~nsClipboard()
+{
+}
+
+NS_IMETHODIMP
+nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard)
+{
+  return NS_ERROR_FAILURE;
+}
+
+NS_IMETHODIMP
+nsClipboard::GetNativeClipboardData(nsITransferable *aTransferable,
+				    PRInt32 aWhichClipboard)
+{
+  return NS_ERROR_FAILURE;
+}
new file mode 100644
--- /dev/null
+++ b/widget/src/windows/nsClipboardCE.h
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ *   Mozilla Corporation
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *    Vladimir Vukicevic <vladimir@pobox.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * 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 ***** */
+
+#ifndef nsClipboardCE_h__
+#define nsClipboardCE_h__
+
+#include "nsBaseClipboard.h"
+
+#include <windows.h>
+
+/*
+ * Windows CE clipboard wrapper
+ */
+
+class nsClipboard :
+  public nsBaseClipboard
+{
+public:
+  nsClipboard();
+  virtual ~nsClipboard();
+
+protected:
+  NS_IMETHOD SetNativeClipboardData (PRInt32 aWhichClipboard);
+  NS_IMETHOD GetNativeClipboardData (nsITransferable * aTransferable, PRInt32 aWhichClipboard);
+};
+
+#endif
--- a/widget/src/windows/nsDataObj.cpp
+++ b/widget/src/windows/nsDataObj.cpp
@@ -924,17 +924,16 @@ nsDataObj :: GetFileDescriptor ( FORMATE
       res = GetFileDescriptorInternetShortcutW ( aFE, aSTG );
     else
       res = GetFileDescriptorInternetShortcutA ( aFE, aSTG );
   }
   else
     NS_WARNING ( "Not yet implemented\n" );
   
 	return res;
-	
 } // GetFileDescriptor
 
 
 //
 HRESULT 
 nsDataObj :: GetFileContents ( FORMATETC& aFE, STGMEDIUM& aSTG )
 {
   HRESULT res = S_OK;
@@ -1069,17 +1068,16 @@ GetLocalizedString(const PRUnichar * aNa
 // GetFileDescriptorInternetShortcut
 //
 // Create the special format for an internet shortcut and build up the data
 // structures the shell is expecting.
 //
 HRESULT
 nsDataObj :: GetFileDescriptorInternetShortcutA ( FORMATETC& aFE, STGMEDIUM& aSTG )
 {
-
   // get the title of the shortcut
   nsAutoString title;
   if ( NS_FAILED(ExtractShortcutTitle(title)) )
     return E_OUTOFMEMORY;
 
   HGLOBAL fileGroupDescHandle = ::GlobalAlloc(GMEM_ZEROINIT|GMEM_SHARE,sizeof(FILEGROUPDESCRIPTORA));
   if (!fileGroupDescHandle)
     return E_OUTOFMEMORY;
--- a/widget/src/windows/nsSound.cpp
+++ b/widget/src/windows/nsSound.cpp
@@ -48,33 +48,39 @@
 
 #include "nsSound.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
 #include "nsCRT.h"
 
 #include "nsNativeCharsetUtils.h"
 
+#ifndef SND_PURGE
+// Not available on Windows CE, and according to MSDN
+// doesn't do anything on recent windows either.
+#define SND_PURGE 0
+#endif
+
 NS_IMPL_ISUPPORTS2(nsSound, nsISound, nsIStreamLoaderObserver)
 
 
 nsSound::nsSound()
 {
   mLastSound = nsnull;
 }
 
 nsSound::~nsSound()
 {
   PurgeLastSound();
 }
 
 void nsSound::PurgeLastSound() {
   if (mLastSound) {
-    // Purge the current sound buffer.
-    ::PlaySound(nsnull, nsnull, SND_PURGE); // This call halts the sound if it was still playing.
+    // Halt any currently playing sound.
+    ::PlaySound(nsnull, nsnull, SND_PURGE);
 
     // Now delete the buffer.
     free(mLastSound);
     mLastSound = nsnull;
   }
 }
 
 NS_IMETHODIMP nsSound::Beep()
@@ -149,17 +155,17 @@ NS_IMETHODIMP nsSound::Play(nsIURL *aURL
 
 NS_IMETHODIMP nsSound::Init()
 {
   // This call halts a sound if it was still playing.
   // We have to use the sound library for something to make sure
   // it is initialized.
   // If we wait until the first sound is played, there will
   // be a time lag as the library gets loaded.
-  ::PlaySound(nsnull, nsnull, SND_PURGE); 
+  ::PlaySound(nsnull, nsnull, SND_PURGE);
 
   return NS_OK;
 }
 
 
 NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
 {
   PurgeLastSound();