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 "nsIDOMElement.h"
#include "nsString.h"
#include "IEHtmlElement.h"
#include "IEHtmlElementCollection.h"

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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