This commit is contained in:
morse%netscape.com 1998-11-18 04:38:13 +00:00
Родитель b9bbbccca0
Коммит 18d1bc714d
6 изменённых файлов: 195 добавлений и 7 удалений

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

@ -40,6 +40,16 @@
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMHTMLTextAreaElement.h"
#ifdef SingleSignon
#include "nsIDocument.h"
#include "prmem.h"
#include "nsIURL.h"
#include "nsINetService.h"
#include "nsIServiceManager.h"
static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
#endif
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
static NS_DEFINE_IID(kTextCID, NS_TEXTFIELD_CID);
static NS_DEFINE_IID(kTextAreaCID, NS_TEXTAREA_CID);
@ -331,13 +341,49 @@ nsTextControlFrame::PostCreateWidget(nsIPresContext* aPresContext,
SetColors(*aPresContext);
PRUint32 ignore;
nsAutoString value;
GetText(&value);
nsITextAreaWidget* textArea = nsnull;
nsITextWidget* text = nsnull;
if (NS_OK == mWidget->QueryInterface(kITextWidgetIID,(void**)&text)) {
#ifdef SingleSignon
/* get name of text */
nsAutoString name;
GetName(&name);
/* get url name */
char *URLName;
nsIURL* docURL = nsnull;
nsIDocument* doc = nsnull;
mContent->GetDocument(doc);
if (nsnull != doc) {
docURL = doc->GetDocumentURL();
NS_RELEASE(doc);
URLName = (char*)PR_Malloc(PL_strlen(docURL->GetSpec())+1);
PL_strcpy(URLName, docURL->GetSpec());
}
/* invoke single-signon to get previously-used value of text */
nsINetService *service;
nsresult res = nsServiceManager::GetService(kNetServiceCID,
kINetServiceIID,
(nsISupports **)&service);
if ((NS_OK == res) && (nsnull != service)) {
char* valueString = NULL;
res = service->SI_RestoreSignonData(URLName, name.ToNewCString(), &valueString);
NS_RELEASE(service);
if (valueString && *valueString) {
value = nsAutoString(valueString);
} else {
GetText(&value);
}
}
#else
GetText(&value);
#endif
text->SetText(value, ignore);
PRInt32 maxLength;
nsresult result = GetMaxLength(&maxLength);

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

@ -56,6 +56,13 @@
#include "prmem.h"
#include "prenv.h"
#ifdef SingleSignon
#include "proto.h"
#include "nsINetService.h"
#include "nsIServiceManager.h"
static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
#endif
//----------------------------------------------------------------------
static NS_DEFINE_IID(kIFormManagerIID, NS_IFORMMANAGER_IID);
@ -514,12 +521,37 @@ void nsFormFrame::ProcessAsURLEncoded(PRBool isPost, nsString& aData, nsIFormCon
{
nsString buf;
PRBool firstTime = PR_TRUE;
PRUint32 numChildren = mFormControls.Count();
#ifdef SingleSignon
#define MAX_ARRAY_SIZE 50
char* name_array[MAX_ARRAY_SIZE];
char* value_array[MAX_ARRAY_SIZE];
uint8 type_array[MAX_ARRAY_SIZE];
LO_FormSubmitData submit;
submit.value_cnt = 0;
submit.type_array = (PA_Block)type_array;
submit.name_array = (PA_Block)name_array;
submit.value_array = (PA_Block)value_array;
/* get url name as ascii string */
char *URLName;
nsIURL* docURL = nsnull;
nsIDocument* doc = nsnull;
mContent->GetDocument(doc);
if (nsnull != doc) {
docURL = doc->GetDocumentURL();
NS_RELEASE(doc);
URLName = (char*)PR_Malloc(PL_strlen(docURL->GetSpec())+1);
PL_strcpy(URLName, docURL->GetSpec());
}
#endif
// collect and encode the data from the children controls
for (PRUint32 childX = 0; childX < numChildren; childX++) {
nsIFormControlFrame* child = (nsIFormControlFrame*) mFormControls.ElementAt(childX);
if (child && child->IsSuccessful(aFrame)) {
nsIFormControlFrame* child = (nsIFormControlFrame*) mFormControls.ElementAt(childX);
if (child && child->IsSuccessful(aFrame)) {
PRInt32 numValues = 0;
PRInt32 maxNumValues = child->GetMaxNumValues();
if (maxNumValues <= 0) {
@ -528,6 +560,20 @@ void nsFormFrame::ProcessAsURLEncoded(PRBool isPost, nsString& aData, nsIFormCon
nsString* names = new nsString[maxNumValues];
nsString* values = new nsString[maxNumValues];
if (PR_TRUE == child->GetNamesValues(maxNumValues, numValues, values, names)) {
#ifdef SingleSignon
PRInt32 type;
child->GetType(&type);
if (type == NS_FORM_INPUT_PASSWORD) {
type_array[submit.value_cnt] = FORM_TYPE_PASSWORD;
} else {
type_array[submit.value_cnt] = FORM_TYPE_TEXT;
}
value_array[submit.value_cnt] =
values[0].ToNewCString();
name_array[submit.value_cnt] =
names[0].ToNewCString();
submit.value_cnt++;
#endif
for (int valueX = 0; valueX < numValues; valueX++) {
if (PR_TRUE == firstTime) {
firstTime = PR_FALSE;
@ -548,6 +594,22 @@ void nsFormFrame::ProcessAsURLEncoded(PRBool isPost, nsString& aData, nsIFormCon
}
}
#ifdef SingleSignon
nsINetService *service;
nsresult res = nsServiceManager::GetService(kNetServiceCID,
kINetServiceIID,
(nsISupports **)&service);
if ((NS_OK == res) && (nsnull != service)) {
res = service->SI_RememberSignonData(URLName, &submit);
NS_RELEASE(service);
}
PR_FREEIF(URLName);
while (submit.value_cnt--) {
PR_FREEIF(name_array[submit.value_cnt]);
PR_FREEIF(value_array[submit.value_cnt]);
}
#endif
aData.SetLength(0);
if (isPost) {
char size[16];

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

@ -40,6 +40,16 @@
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMHTMLTextAreaElement.h"
#ifdef SingleSignon
#include "nsIDocument.h"
#include "prmem.h"
#include "nsIURL.h"
#include "nsINetService.h"
#include "nsIServiceManager.h"
static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
#endif
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
static NS_DEFINE_IID(kTextCID, NS_TEXTFIELD_CID);
static NS_DEFINE_IID(kTextAreaCID, NS_TEXTAREA_CID);
@ -331,13 +341,49 @@ nsTextControlFrame::PostCreateWidget(nsIPresContext* aPresContext,
SetColors(*aPresContext);
PRUint32 ignore;
nsAutoString value;
GetText(&value);
nsITextAreaWidget* textArea = nsnull;
nsITextWidget* text = nsnull;
if (NS_OK == mWidget->QueryInterface(kITextWidgetIID,(void**)&text)) {
#ifdef SingleSignon
/* get name of text */
nsAutoString name;
GetName(&name);
/* get url name */
char *URLName;
nsIURL* docURL = nsnull;
nsIDocument* doc = nsnull;
mContent->GetDocument(doc);
if (nsnull != doc) {
docURL = doc->GetDocumentURL();
NS_RELEASE(doc);
URLName = (char*)PR_Malloc(PL_strlen(docURL->GetSpec())+1);
PL_strcpy(URLName, docURL->GetSpec());
}
/* invoke single-signon to get previously-used value of text */
nsINetService *service;
nsresult res = nsServiceManager::GetService(kNetServiceCID,
kINetServiceIID,
(nsISupports **)&service);
if ((NS_OK == res) && (nsnull != service)) {
char* valueString = NULL;
res = service->SI_RestoreSignonData(URLName, name.ToNewCString(), &valueString);
NS_RELEASE(service);
if (valueString && *valueString) {
value = nsAutoString(valueString);
} else {
GetText(&value);
}
}
#else
GetText(&value);
#endif
text->SetText(value, ignore);
PRInt32 maxLength;
nsresult result = GetMaxLength(&maxLength);

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

@ -24,6 +24,10 @@
#include "nsIURL.h"
#include "nsIStreamListener.h"
#ifdef SingleSignon
#include "lo_ele.h"
#endif
/* XXX: This should be moved to ns/xpcom/src/nserror.h */
#define NS_OK 0
#define NS_FALSE 1
@ -99,6 +103,13 @@ struct nsINetService : public nsISupports
*/
NS_IMETHOD SetCookieString(nsIURL *aURL, const nsString& aCookie)=0;
#ifdef SingleSignon
NS_IMETHOD SI_RememberSignonData
(char* URLName, LO_FormSubmitData *submit)=0;
NS_IMETHOD SI_RestoreSignonData
(char* URLNAME, char* name, char** value)=0;
#endif
/**
* Get the http proxy used for http transactions.
*

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

@ -582,6 +582,22 @@ nsNetlibService::SetCookieString(nsIURL *aURL, const nsString& aCookie)
return NS_OK;
}
#ifdef SingleSignon
NS_IMETHODIMP
nsNetlibService::SI_RememberSignonData
(char* URLName, LO_FormSubmitData *submit) {
::SI_RememberSignonData(URLName, submit);
return NS_OK;
}
NS_IMETHODIMP
nsNetlibService::SI_RestoreSignonData
(char* URLName, char* name, char** value) {
::SI_RestoreSignonData(URLName, name, value);
return NS_OK;
}
#endif
NS_IMETHODIMP
nsNetlibService::GetProxyHTTP(nsString& aProxyHTTP) {

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

@ -47,6 +47,13 @@ public:
NS_IMETHOD GetCookieString(nsIURL *aURL, nsString& aCookie);
NS_IMETHOD SetCookieString(nsIURL *aURL, const nsString& aCookie);
#ifdef SingleSignon
NS_IMETHOD SI_RememberSignonData
(char* URLName, LO_FormSubmitData *submit);
NS_IMETHOD SI_RestoreSignonData
(char* URLNAME, char* name, char** value);
#endif
NS_IMETHOD GetProxyHTTP(nsString& aProxyHTTP);
NS_IMETHOD SetProxyHTTP(nsString& aProxyHTTP);
NS_IMETHOD GetHTTPOneOne(PRBool& aOneOne);