Mercurial > projects > dwt-linux
diff dwt/browser/PromptService2.d @ 346:2e591eb01162
Browser Package now compiles (phase 2 complete)
author | John Reimer <terminal.node@gmail.com> |
---|---|
date | Wed, 29 Oct 2008 20:06:08 -0700 |
parents | 942da4b6558a |
children | 9a4d7706df52 |
line wrap: on
line diff
--- a/dwt/browser/PromptService2.d Tue Oct 28 22:07:01 2008 -0700 +++ b/dwt/browser/PromptService2.d Wed Oct 29 20:06:08 2008 -0700 @@ -13,14 +13,16 @@ module dwt.browser.PromptService2; import tango.stdc.stdlib; +import tango.text.convert.Format; import dwt.dwthelper.utils; import dwt.DWT; -//import dwt.internal.C; + import dwt.internal.Compatibility; + import XPCOM = dwt.internal.mozilla.XPCOM; -//import dwt.internal.mozilla.XPCOMObject; + import dwt.internal.mozilla.Common; import dwt.internal.mozilla.nsEmbedString; import dwt.internal.mozilla.nsIAuthInformation; @@ -38,9 +40,14 @@ import dwt.internal.mozilla.nsIWindowWatcher; import dwt.internal.mozilla.nsIAuthPromptCallback; import dwt.internal.mozilla.nsICancelable; +import dwt.internal.mozilla.nsStringAPI; + import dwt.widgets.MessageBox; import dwt.widgets.Shell; + import dwt.browser.Browser; +import dwt.browser.Mozilla; +import dwt.browser.PromptDialog; class PromptService2 : nsIPromptService2 { int refCount = 0; @@ -95,7 +102,7 @@ //result[0] = 0; //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WINDOWWATCHER_CONTRACTID, true); nsIWindowWatcher windowWatcher; - rc = serviceManager.GetServiceByContractID (XPCOM.NS_WINDOWWATCHER_CONTRACTID, &nsIWindowWatcher.IID, cast(void**)&windowWatcher); + rc = serviceManager.GetServiceByContractID (XPCOM.NS_WINDOWWATCHER_CONTRACTID.ptr, &nsIWindowWatcher.IID, cast(void**)&windowWatcher); if (rc !is XPCOM.NS_OK) Mozilla.error(rc); if (windowWatcher is null) Mozilla.error (XPCOM.NS_NOINTERFACE); serviceManager.Release (); @@ -119,7 +126,7 @@ //nsIWebBrowserChrome webBrowserChrome = new nsIWebBrowserChrome (result[0]); //result[0] = 0; nsIEmbeddingSiteWindow embeddingSiteWindow; - rc = webBrowserChrome.QueryInterface (nsIEmbeddingSiteWindow.IID, cast(void**)&embeddingSiteWindow); + rc = webBrowserChrome.QueryInterface (&nsIEmbeddingSiteWindow.IID, cast(void**)&embeddingSiteWindow); if (rc !is XPCOM.NS_OK) Mozilla.error (rc); if (embeddingSiteWindow is null) Mozilla.error (XPCOM.NS_NOINTERFACE); webBrowserChrome.Release (); @@ -150,7 +157,7 @@ auto span = XPCOM.strlen_PRUnichar (buttonTitle); //char[] dest = new char[length]; //XPCOM.memmove (dest, buttonTitle, length * 2); - label = UTf.toString (buttonTitle[0 .. span]); + label = Utf.toString (buttonTitle[0 .. span]); } } return label; @@ -353,7 +360,7 @@ //result2[0] = 0; nsIMemory memory; //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true); - rc = serviceManager.GetServiceByContractID (XPCOM.NS_MEMORY_CONTRACTID, &nsIMemory.IID, cast(void**)&memory); + rc = serviceManager.GetServiceByContractID (XPCOM.NS_MEMORY_CONTRACTID.ptr, &nsIMemory.IID, cast(void**)&memory); if (rc !is XPCOM.NS_OK) DWT.error (rc); if (memory is null) DWT.error (XPCOM.NS_NOINTERFACE); serviceManager.Release (); @@ -380,10 +387,10 @@ String title = "Authentication Required"; if (checkboxLabel !is null && checkboxValue !is null) { - int span = XPCOM.strlen_PRUnichar (checkboxLabel); + //int span = XPCOM.strlen_PRUnichar (checkboxLabel); //char[] dest = new char[length]; //XPCOM.memmove (dest, checkboxLabel, length * 2); - checkLabel = Utf.toString (checkboxLabel[0 .. span]); + checkLabel = Utf.toString (fromString16z(checkboxLabel)); checkValue = *checkboxValue; /* PRBool */ } @@ -402,7 +409,7 @@ //XPCOM.nsEmbedString_delete (ptr); scope auto ptr2 = new nsEmbedString; - rc = authInfo.GetPassword (ptr2); + rc = authInfo.GetPassword (cast(nsAString*)ptr2); if (rc !is XPCOM.NS_OK) DWT.error (rc); //length = XPCOM.nsEmbedString_Length (ptr); //buffer = XPCOM.nsEmbedString_get (ptr); @@ -425,7 +432,7 @@ //nsIChannel channel = new nsIChannel (aChannel); nsIURI uri; - rc = channel.GetURI (&uri); + rc = aChannel.GetURI (&uri); if (rc !is XPCOM.NS_OK) DWT.error (rc); if (uri is null) Mozilla.error (XPCOM.NS_NOINTERFACE); @@ -458,12 +465,12 @@ //XPCOM.memmove (_retval, result, 4); /* PRBool */ *_retval = result; if (result is 1) { /* User selected OK */ - scope auto string1 = new nsEmbedString (userLabel); + scope auto string1 = new nsEmbedString (toString16(userLabel)); rc = authInfo.SetUsername(cast(nsAString*)string1); if (rc !is XPCOM.NS_OK) DWT.error (rc); //string.dispose (); - scope auto string2 = new nsEmbedString (passLabel); + scope auto string2 = new nsEmbedString (toString16(passLabel)); rc = authInfo.SetPassword(cast(nsAString*)string2); if (rc !is XPCOM.NS_OK) DWT.error (rc); //string.dispose (); @@ -480,54 +487,54 @@ char[] dest; int span; if (aDialogTitle !is null) { - span = XPCOM.strlen_PRUnichar (aDialogTitle); + //span = XPCOM.strlen_PRUnichar (aDialogTitle); //dest = new char[length]; //XPCOM.memmove (dest, aDialogTitle, length * 2); - titleLabel = Utf.toString (aDialogTitle[0 .. span]); + titleLabel = Utf.toString (fromString16z(aDialogTitle)); } else { //titleLabel = DWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$ titleLabel = "Authentication Required"; } - span = XPCOM.strlen_PRUnichar (aText); + //span = XPCOM.strlen_PRUnichar (aText); //dest = new char[length]; //XPCOM.memmove (dest, aText, length * 2); - textLabel = Utf.toString (aText[0 .. span]); + textLabel = Utf.toString (fromString16z(aText)); //int /*long*/[] userAddr = new int /*long*/[1]; //XPCOM.memmove (userAddr, aUsername, C.PTR_SIZEOF); - auto userAddr = aUsername; - if (userAddr[0] !is null) { - span = XPCOM.strlen_PRUnichar (userAddr[0]); + auto userAddr = *aUsername; + if (*aUsername !is null) { + //span = XPCOM.strlen_PRUnichar (userAddr[0]); //dest = new char[length]; //XPCOM.memmove (dest, userAddr[0], length * 2); - userLabel = Utf.toString((userAddr[0])[0 .. span]); + userLabel = Utf.toString(fromString16z(*aUsername)); } //int /*long*/[] passAddr = new int /*long*/[1]; //XPCOM.memmove (passAddr, aPassword, C.PTR_SIZEOF); - auto passAddr = aPassword; - if (passAddr[0] !is null) { - span = XPCOM.strlen_PRUnichar (passAddr[0]); + auto passAddr = *aPassword; + if (*aPassword !is null) { + //span = XPCOM.strlen_PRUnichar (passAddr[0]); //dest = new char[length]; //XPCOM.memmove (dest, passAddr[0], length * 2); - passLabel = Utf.toString((passAddr[0])[0 .. span]); + passLabel = Utf.toString(fromString16z(*aPassword)); } if (aCheckMsg !is null) { - span = XPCOM.strlen_PRUnichar (aCheckMsg); - if (span > 0) { + //span = XPCOM.strlen_PRUnichar (aCheckMsg); + //if (span > 0) { //dest = new char[length]; //XPCOM.memmove (dest, aCheckMsg, length * 2); - checkLabel = Utf.toString (aCheckMsg[0 .. span]); - } + checkLabel = Utf.toString (fromString16z(aCheckMsg)); + //} } Shell shell = browser is null ? new Shell () : browser.getShell (); PromptDialog dialog = new PromptDialog (shell); int check, result; if (aCheckState !is null) check = *aCheckState; /* PRBool */ - dialog.promptUsernameAndPassword (titleLabel, textLabel, checkLabel, userLabel, passLabel, check, result); + dialog.promptUsernameAndPassword (titleLabel, textLabel, checkLabel, /*ref*/ userLabel, /*ref*/ passLabel, check, result); *_retval = result; /* PRBool */ if (result is 1) { @@ -542,17 +549,17 @@ if (userLabel !is null) { //cnt = userLabel[0].length (); //buffer = new char[cnt + 1]; - buffer = Utf.toString16(userLabel); + //buffer = Utf.toString16(userLabel); //userLabel[0].getChars (0, cnt, buffer, 0); - size = buffer.length * 2; - ptr = tango.stdc.stdlib.malloc (size); - (cast(wchar*)ptr)[0 .. buffer.length] = buffer[0 .. $]; + //size = buffer.length * 2; + //ptr = tango.stdc.stdlib.malloc (size); + //(cast(wchar*)ptr)[0 .. buffer.length] = buffer[0 .. $]; //XPCOM.memmove (ptr, buffer, size); - *aUsername = cast(PRUnichar*)ptr; + *aUsername = toString16z(Utf.toString16(userLabel)); //XPCOM.memmove (aUsername, new int /*long*/[] {ptr}, C.PTR_SIZEOF); nsIServiceManager serviceManager; - if (userAddr[0] !is null) { + if (userAddr !is null) { int rc = XPCOM.NS_GetServiceManager (&serviceManager); if (rc !is XPCOM.NS_OK) DWT.error (rc); if (serviceManager is null) DWT.error (XPCOM.NS_NOINTERFACE); @@ -561,30 +568,31 @@ //result2[0] = 0; //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true); nsIMemory memory; - rc = serviceManager.GetServiceByContractID (XPCOM.NS_MEMORY_CONTRACTID, nsIMemory.IID, cast(void**)&memory); + rc = serviceManager.GetServiceByContractID (XPCOM.NS_MEMORY_CONTRACTID.ptr, &nsIMemory.IID, cast(void**)&memory); if (rc !is XPCOM.NS_OK) DWT.error (rc); if (memory is null) DWT.error (XPCOM.NS_NOINTERFACE); serviceManager.Release (); //nsIMemory memory = new nsIMemory (result2[0]); //result2[0] = 0; - memory.Free (userAddr[0]); + memory.Free (userAddr); memory.Release (); } } if (passLabel !is null) { //cnt = passLabel[0].length (); //buffer = new char[cnt + 1]; - buffer = Utf.toString16( passLabel ); + //buffer = Utf.toString16( passLabel ); //passLabel[0].getChars (0, cnt, buffer, 0); - size = buffer.length * 2; - ptr = tango.stdc.stdlib.malloc (size); - (cast(wchar*)ptr)[0 .. buffer.length] = buffer[0 .. $]; + //size = buffer.length * 2; + //ptr = tango.stdc.stdlib.malloc (size); + //(cast(wchar*)ptr)[0 .. buffer.length] = buffer[0 .. $]; //XPCOM.memmove (ptr, buffer, size); - *aPassword = cast(PRUnichar*)ptr; + *aPassword = toString16z(Utf.toString16(passLabel)); //XPCOM.memmove (aPassword, new int /*long*/[] {ptr}, C.PTR_SIZEOF); - if (passAddr[0] !is null) { + nsIServiceManager serviceManager; + if (passAddr !is null) { int rc = XPCOM.NS_GetServiceManager (&serviceManager); if (rc !is XPCOM.NS_OK) DWT.error (rc); if (serviceManager is null) DWT.error (XPCOM.NS_NOINTERFACE); @@ -593,14 +601,14 @@ //result2[0] = 0; //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true); nsIMemory memory; - rc = serviceManager.GetServiceByContractID (XPCOM.NS_MEMORY_CONTRACTID, nsIMemory.IID, cast(void**)&memory); + rc = serviceManager.GetServiceByContractID (XPCOM.NS_MEMORY_CONTRACTID.ptr, &nsIMemory.IID, cast(void**)&memory); if (rc !is XPCOM.NS_OK) DWT.error (rc); if (memory is null) DWT.error (XPCOM.NS_NOINTERFACE); serviceManager.Release (); //nsIMemory memory = new nsIMemory (result2[0]); //result2[0] = 0; - memory.Free (passAddr[0]); + memory.Free (passAddr); memory.Release (); } }