Bug 315563 - Convert the activex code to use the frozen string API, r=darin

This commit is contained in:
bsmedberg%covad.net 2005-11-18 15:58:53 +00:00
Родитель 6983632d9f
Коммит 2bccd4ab67
16 изменённых файлов: 58 добавлений и 55 удалений

Просмотреть файл

@ -40,7 +40,6 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
#include "nsString.h"
#include "IEHtmlElement.h" #include "IEHtmlElement.h"
#include "IEHtmlElementCollection.h" #include "IEHtmlElementCollection.h"

Просмотреть файл

@ -43,8 +43,6 @@
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsIDOMHtmlElement.h" #include "nsIDOMHtmlElement.h"
#include "nsString.h"
#include "IEHtmlElement.h" #include "IEHtmlElement.h"
#include "IEHtmlElementCollection.h" #include "IEHtmlElementCollection.h"

Просмотреть файл

@ -48,8 +48,10 @@
#include "nsIBaseWindow.h" #include "nsIBaseWindow.h"
#include "nsIWindowWatcher.h" #include "nsIWindowWatcher.h"
#include "nsIInputStream.h" #include "nsIInputStream.h"
#include "nsIByteArrayInputStream.h" #include "nsIStringStream.h"
#include "nsIURI.h" #include "nsIURI.h"
#include "nsComponentManagerUtils.h"
#include "nsServiceManagerUtils.h"
#include "PropertyList.h" #include "PropertyList.h"
@ -184,7 +186,7 @@ public:
if (homePage) if (homePage)
{ {
nsXPIDLString homePageString; nsString homePageString;
nsresult rv = homePage->ToString(getter_Copies(homePageString)); nsresult rv = homePage->ToString(getter_Copies(homePageString));
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
@ -226,6 +228,8 @@ public:
ATLTRACE(_T("IWebBrowserImpl::Navigate()\n")); ATLTRACE(_T("IWebBrowserImpl::Navigate()\n"));
ENSURE_BROWSER_IS_VALID(); ENSURE_BROWSER_IS_VALID();
nsresult rv;
// Extract the URL parameter // Extract the URL parameter
if (URL == NULL) if (URL == NULL)
{ {
@ -368,9 +372,9 @@ public:
SafeArrayUnlock(PostData->parray); SafeArrayUnlock(PostData->parray);
// Create a byte array input stream object. // Create a byte array input stream object.
nsCOMPtr<nsIByteArrayInputStream> stream; nsCOMPtr<nsIStringInputStream> stream
nsresult rv = NS_NewByteArrayInputStream( (do_CreateInstance("@mozilla.org/io/string-input-stream;1"));
getter_AddRefs(stream), tmp, nSize); rv = stream->AdoptData(tmp, nSize);
if (NS_FAILED(rv) || !stream) if (NS_FAILED(rv) || !stream)
{ {
NS_ASSERTION(0, "cannot create byte stream"); NS_ASSERTION(0, "cannot create byte stream");
@ -384,7 +388,7 @@ public:
} }
// Extract the headers parameter // Extract the headers parameter
nsCOMPtr<nsIByteArrayInputStream> headersStream; nsCOMPtr<nsIStringInputStream> headersStream;
if (Headers && if (Headers &&
Headers->vt == VT_BSTR && Headers->vt == VT_BSTR &&
Headers->bstrVal) Headers->bstrVal)
@ -403,15 +407,15 @@ public:
tmp[nSize - 1] = '\0'; tmp[nSize - 1] = '\0';
// Create a byte array input stream object which will own the buffer // Create a byte array input stream object which will own the buffer
nsCOMPtr<nsIByteArrayInputStream> stream; headersStream = do_CreateInstance("@mozilla.org/io/string-input-stream;1");
nsresult rv = if (headersStream)
NS_NewByteArrayInputStream(getter_AddRefs(stream), tmp, nSize); rv = headersStream->AdoptData(tmp, nSize);
if (NS_FAILED(rv) || !stream)
if (NS_FAILED(rv) || !headersStream)
{ {
NS_ASSERTION(0, "cannot create byte stream"); NS_ASSERTION(0, "cannot create byte stream");
nsMemory::Free(tmp); nsMemory::Free(tmp);
} }
headersStream = do_QueryInterface(stream);
} }
} }
} }
@ -428,7 +432,7 @@ public:
} }
// Load the URL // Load the URL
nsresult rv = NS_ERROR_FAILURE; rv = NS_ERROR_FAILURE;
if (webNavToUse) if (webNavToUse)
{ {
rv = webNavToUse->LoadURI(URL, rv = webNavToUse->LoadURI(URL,
@ -664,18 +668,18 @@ public:
return SetErrorInfo(E_INVALIDARG); return SetErrorInfo(E_INVALIDARG);
} }
// Get the url from the web shell // Get the url from the web shell
nsXPIDLString szLocationName; nsString szLocationName;
ENSURE_GET_WEBNAV(); ENSURE_GET_WEBNAV();
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(webNav); nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(webNav);
baseWindow->GetTitle(getter_Copies(szLocationName)); baseWindow->GetTitle(getter_Copies(szLocationName));
if (nsnull == (const PRUnichar *) szLocationName) if (!szLocationName.get())
{ {
return SetErrorInfo(E_UNEXPECTED); return SetErrorInfo(E_UNEXPECTED);
} }
// Convert the string to a BSTR // Convert the string to a BSTR
USES_CONVERSION; USES_CONVERSION;
LPCOLESTR pszConvertedLocationName = W2COLE((const PRUnichar *) szLocationName); LPCOLESTR pszConvertedLocationName = W2COLE(szLocationName.get());
*LocationName = SysAllocString(pszConvertedLocationName); *LocationName = SysAllocString(pszConvertedLocationName);
return S_OK; return S_OK;

Просмотреть файл

@ -46,7 +46,6 @@ include $(DEPTH)/config/autoconf.mk
MODULE = ax_common MODULE = ax_common
LIBRARY_NAME = ax_common_s LIBRARY_NAME = ax_common_s
XPIDL_MODULE = ax_common XPIDL_MODULE = ax_common
MOZILLA_INTERNAL_API = 1
REQUIRES = \ REQUIRES = \
xpcom \ xpcom \

Просмотреть файл

@ -65,14 +65,14 @@
#include "nsIComponentManager.h" #include "nsIComponentManager.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsIEventQueueService.h" #include "nsIEventQueueService.h"
#include "nsString.h" #include "nsStringAPI.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsXPIDLString.h" #include "nsComponentManagerUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIDocumentObserver.h" #include "nsIDocumentObserver.h"
#include "nsVoidArray.h" #include "nsVoidArray.h"
#include "nsCRT.h"
#include "nsIDOMNode.h" #include "nsIDOMNode.h"
#include "nsIDOMNodeList.h" #include "nsIDOMNodeList.h"

Просмотреть файл

@ -49,7 +49,6 @@ DEFFILE = L_mozctl.def
EXPORT_LIBRARY = 1 EXPORT_LIBRARY = 1
FORCE_SHARED_LIB= 1 FORCE_SHARED_LIB= 1
GRE_MODULE = 1 GRE_MODULE = 1
MOZILLA_INTERNAL_API = 1
REQUIRES = \ REQUIRES = \
xpcom \ xpcom \

Просмотреть файл

@ -186,7 +186,7 @@ CMozillaBrowser::CMozillaBrowser()
mBrowserHelperListCount = 0; mBrowserHelperListCount = 0;
// Name of the default profile to use // Name of the default profile to use
mProfileName.AssignLiteral("MozillaControl"); mProfileName.Assign(NS_LITERAL_STRING("MozillaControl"));
// Initialise the web browser // Initialise the web browser
Initialize(); Initialize();
@ -448,7 +448,7 @@ LRESULT CMozillaBrowser::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
ios->GetProtocolHandler(kDesignModeScheme, getter_AddRefs(ph)); ios->GetProtocolHandler(kDesignModeScheme, getter_AddRefs(ph));
if (ph && if (ph &&
NS_SUCCEEDED(ph->GetScheme(phScheme)) && NS_SUCCEEDED(ph->GetScheme(phScheme)) &&
phScheme.LowerCaseEqualsASCII(kDesignModeScheme)) phScheme.Equals(NS_LITERAL_CSTRING(kDesignModeScheme)))
{ {
Navigate(const_cast<BSTR>(kDesignModeURL), NULL, NULL, NULL, NULL); Navigate(const_cast<BSTR>(kDesignModeURL), NULL, NULL, NULL, NULL);
} }
@ -786,8 +786,8 @@ LRESULT CMozillaBrowser::OnViewSource(WORD wNotifyCode, WORD wID, HWND hWndCtl,
nsCAutoString aURI; nsCAutoString aURI;
uri->GetSpec(aURI); uri->GetSpec(aURI);
nsAutoString strURI(NS_LITERAL_STRING("view-source:")); NS_ConvertUTF8toUTF16 strURI(aURI);
AppendUTF8toUTF16(aURI, strURI); strURI.Insert(NS_LITERAL_STRING("view-source:"), 0);
// Ask the client to create a window to view the source in // Ask the client to create a window to view the source in
CIPtr(IDispatch) spDispNew; CIPtr(IDispatch) spDispNew;
@ -932,18 +932,27 @@ LRESULT CMozillaBrowser::OnLinkCopyShortcut(WORD wNotifyCode, WORD wID, HWND hWn
{ {
EmptyClipboard(); EmptyClipboard();
NS_ConvertUTF16toUTF8 curi(uri);
const char *stringText;
PRUint32 stringLen = NS_CStringGetData(curi,
&stringText);
// CF_TEXT // CF_TEXT
HGLOBAL hmemText = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, uri.Length() + 1); HGLOBAL hmemText = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT,
stringLen + 1);
char *pszText = (char *) GlobalLock(hmemText); char *pszText = (char *) GlobalLock(hmemText);
uri.ToCString(pszText, uri.Length() + 1); strncpy(pszText, stringText, stringLen);
pszText[stringLen] = '\0';
GlobalUnlock(hmemText); GlobalUnlock(hmemText);
SetClipboardData(CF_TEXT, hmemText); SetClipboardData(CF_TEXT, hmemText);
// UniformResourceLocator - CFSTR_SHELLURL // UniformResourceLocator - CFSTR_SHELLURL
const UINT cfShellURL = RegisterClipboardFormat(CFSTR_SHELLURL); const UINT cfShellURL = RegisterClipboardFormat(CFSTR_SHELLURL);
HGLOBAL hmemURL = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, uri.Length() + 1); HGLOBAL hmemURL = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT,
stringLen + 1);
char *pszURL = (char *) GlobalLock(hmemURL); char *pszURL = (char *) GlobalLock(hmemURL);
uri.ToCString(pszURL, uri.Length() + 1); strncpy(pszText, stringText, stringLen);
pszText[stringLen] = '\0';
GlobalUnlock(hmemURL); GlobalUnlock(hmemURL);
SetClipboardData(cfShellURL, hmemURL); SetClipboardData(cfShellURL, hmemURL);

Просмотреть файл

@ -46,7 +46,6 @@
#include "nsIPromptService.h" #include "nsIPromptService.h"
#include "nsIFactory.h" #include "nsIFactory.h"
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsReadableUtils.h"
class PromptDlg class PromptDlg
{ {

Просмотреть файл

@ -67,9 +67,8 @@
#include "nsWidgetsCID.h" #include "nsWidgetsCID.h"
#include "nsGfxCIID.h" #include "nsGfxCIID.h"
#include "nsViewsCID.h" #include "nsViewsCID.h"
#include "nsString.h" #include "nsStringAPI.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsIHTTPChannel.h" #include "nsIHTTPChannel.h"
@ -95,7 +94,6 @@
#include "nsIPresShell.h" #include "nsIPresShell.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsISelection.h" #include "nsISelection.h"
#include "nsPresContext.h"
#include "nsIPrompt.h" #include "nsIPrompt.h"
#include "nsIEditor.h" #include "nsIEditor.h"
#include "nsIEditingSession.h" #include "nsIEditingSession.h"
@ -106,7 +104,6 @@
#include "nsIStreamListener.h" #include "nsIStreamListener.h"
#include "nsUnitConversion.h" #include "nsUnitConversion.h"
#include "nsVoidArray.h" #include "nsVoidArray.h"
#include "nsCRT.h"
#include "nsIDocumentViewer.h" #include "nsIDocumentViewer.h"
#include "nsIDOMNode.h" #include "nsIDOMNode.h"

Просмотреть файл

@ -43,8 +43,6 @@
#include "WebBrowserContainer.h" #include "WebBrowserContainer.h"
#include "nsReadableUtils.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "nsIWebNavigationInfo.h" #include "nsIWebNavigationInfo.h"
@ -284,7 +282,7 @@ NS_IMETHODIMP CWebBrowserContainer::OnLocationChange(nsIWebProgress* aWebProgres
nsIRequest* aRequest, nsIRequest* aRequest,
nsIURI *location) nsIURI *location)
{ {
// nsXPIDLCString aPath; // nsCString aPath;
// location->GetPath(getter_Copies(aPath)); // location->GetPath(getter_Copies(aPath));
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -54,7 +54,7 @@
#ifdef XPC_IDISPATCH_SUPPORT #ifdef XPC_IDISPATCH_SUPPORT
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsString.h" #include "nsStringAPI.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"

Просмотреть файл

@ -50,7 +50,6 @@ LIBRARY_NAME = npmozax
RESFILE = MozActiveX.res RESFILE = MozActiveX.res
DEFFILE = npmozax.def DEFFILE = npmozax.def
GRE_MODULE = 1 GRE_MODULE = 1
MOZILLA_INTERNAL_API = 1
REQUIRES = \ REQUIRES = \
xpcom \ xpcom \
@ -198,6 +197,7 @@ DEFINES += -DXPC_IDISPATCH_SUPPORT
endif endif
EXTRA_DSO_LDOPTS = \ EXTRA_DSO_LDOPTS = \
$(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
$(MOZ_COMPONENT_LIBS) \ $(MOZ_COMPONENT_LIBS) \
$(NSPR_LIBS) \ $(NSPR_LIBS) \
$(NULL) $(NULL)

Просмотреть файл

@ -46,8 +46,7 @@
#include "nsIPrefBranch2.h" #include "nsIPrefBranch2.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsCRT.h" #include "nsStringAPI.h"
#include "nsString.h"
#include "XPConnect.h" #include "XPConnect.h"
@ -116,7 +115,7 @@ NS_INTERFACE_MAP_END
/* void observe (in nsISupports aSubject, in string aTopic, in wstring aData); */ /* void observe (in nsISupports aSubject, in string aTopic, in wstring aData); */
NS_IMETHODIMP PrefObserver::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData) NS_IMETHODIMP PrefObserver::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
{ {
if (nsCRT::strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic) != 0) if (strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic) != 0)
{ {
return S_OK; return S_OK;
} }
@ -127,9 +126,9 @@ NS_IMETHODIMP PrefObserver::Observe(nsISupports *aSubject, const char *aTopic, c
return rv; return rv;
NS_ConvertUTF16toUTF8 pref(aData); NS_ConvertUTF16toUTF8 pref(aData);
if (nsCRT::strcmp(kActiveXHostingFlags, pref.get()) == 0 || if (strcmp(kActiveXHostingFlags, pref.get()) == 0 ||
nsCRT::strcmp(kUserAgentPref, pref.get()) == 0 || strcmp(kUserAgentPref, pref.get()) == 0 ||
nsCRT::strcmp(kProxyPref, pref.get()) == 0) strcmp(kProxyPref, pref.get()) == 0)
{ {
Sync(prefBranch); Sync(prefBranch);
} }

Просмотреть файл

@ -43,9 +43,10 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIInterfaceRequestorUtils.h" #include "nsIInterfaceRequestorUtils.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "nsString.h" #include "nsStringAPI.h"
#include "nsIPrefBranch.h" #include "nsIPrefBranch.h"
#include "nsIPrefService.h" #include "nsIPrefService.h"
#include "nsMemory.h"
#include "XPCBrowser.h" #include "XPCBrowser.h"

Просмотреть файл

@ -109,7 +109,7 @@ public:
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIInterfaceRequestorUtils.h" #include "nsIInterfaceRequestorUtils.h"
#include "nsString.h" #include "nsStringAPI.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsIContent.h" #include "nsIContent.h"

Просмотреть файл

@ -42,6 +42,7 @@
#endif #endif
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIComponentManager.h"
#include "nsComponentManagerUtils.h" #include "nsComponentManagerUtils.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
@ -50,8 +51,6 @@
#include "nsIVariant.h" #include "nsIVariant.h"
#include "nsMemory.h" #include "nsMemory.h"
#include "nsIAtom.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsIDOMNode.h" #include "nsIDOMNode.h"
#include "nsIDOMNodeList.h" #include "nsIDOMNodeList.h"
@ -281,9 +280,10 @@ nsScriptablePeer::ConvertVariants(nsIVariant *aIn, VARIANT *aOut)
case nsIDataType::VTYPE_STRING_SIZE_IS: case nsIDataType::VTYPE_STRING_SIZE_IS:
case nsIDataType::VTYPE_CHAR_STR: case nsIDataType::VTYPE_CHAR_STR:
{ {
nsXPIDLCString value; nsCString value;
aIn->GetAsString(getter_Copies(value)); aIn->GetAsString(getter_Copies(value));
nsAutoString valueWide; valueWide.AssignWithConversion(value); nsString valueWide;
NS_CStringToUTF16(value, NS_CSTRING_ENCODING_ASCII, valueWide);
aOut->vt = VT_BSTR; aOut->vt = VT_BSTR;
aOut->bstrVal = SysAllocString(valueWide.get()); aOut->bstrVal = SysAllocString(valueWide.get());
} }
@ -291,7 +291,7 @@ nsScriptablePeer::ConvertVariants(nsIVariant *aIn, VARIANT *aOut)
case nsIDataType::VTYPE_WSTRING_SIZE_IS: case nsIDataType::VTYPE_WSTRING_SIZE_IS:
case nsIDataType::VTYPE_WCHAR_STR: case nsIDataType::VTYPE_WCHAR_STR:
{ {
nsXPIDLString value; nsString value;
aIn->GetAsWString(getter_Copies(value)); aIn->GetAsWString(getter_Copies(value));
aOut->vt = VT_BSTR; aOut->vt = VT_BSTR;
aOut->bstrVal = SysAllocString(value.get()); aOut->bstrVal = SysAllocString(value.get());
@ -320,7 +320,8 @@ nsScriptablePeer::ConvertVariants(nsIVariant *aIn, VARIANT *aOut)
{ {
nsCAutoString value; nsCAutoString value;
aIn->GetAsACString(value); aIn->GetAsACString(value);
nsAutoString valueWide; valueWide.AssignWithConversion(value.get()); nsAutoString valueWide;
NS_CStringToUTF16(value, NS_CSTRING_ENCODING_ASCII, valueWide);
aOut->vt = VT_BSTR; aOut->vt = VT_BSTR;
aOut->bstrVal = SysAllocString(valueWide.get()); aOut->bstrVal = SysAllocString(valueWide.get());
} }