зеркало из https://github.com/mozilla/pjs.git
first pass at form fill
This commit is contained in:
Родитель
ba1706f3f2
Коммит
b9745a0808
|
@ -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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
//
|
||||
// PhoneNumber
|
||||
//
|
||||
// A helper class for parsing a phone number into its respective parts. If
|
||||
// initialization fails, the getters will return nil strings.
|
||||
//
|
||||
|
||||
@interface PhoneNumber : NSObject
|
||||
{
|
||||
@private
|
||||
NSString* remainderString; // XXX(111)111-1111
|
||||
NSString* areaCodeString; // (XXX)111-1111
|
||||
NSString* prefixString; // (111)XXX-1111
|
||||
NSString* suffixString; // (111)111-XXXX
|
||||
}
|
||||
|
||||
-(id)initWithPhoneNumberString:(NSString*)phoneString;
|
||||
-(NSString*)remainderString;
|
||||
-(NSString*)areaCodeString;
|
||||
-(NSString*)prefixString;
|
||||
-(NSString*)suffixString;
|
||||
|
||||
@end
|
|
@ -0,0 +1,124 @@
|
|||
/* -*- 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
/*
|
||||
We index digits from right to left, such that the rightmost digit is digit 0.
|
||||
|
||||
We take digits 0-3 as suffix. We take digits 4-6 as prefix. We take digits 7-9
|
||||
as area code. If there are only 11 digits and digit 10 is a 1, then throw it away
|
||||
and stop. If there are more than 10 digits and its not just a single 1 after the
|
||||
digit at index 9, we put all digits after index 9 into remainderString.
|
||||
|
||||
Fail if we don't have 7 or more than 9 digits.
|
||||
*/
|
||||
|
||||
#import "PhoneNumber.h"
|
||||
|
||||
@implementation PhoneNumber
|
||||
|
||||
// init will never fail - if it gets a bad phoneString, all member variables will be nil
|
||||
-(id)initWithPhoneNumberString:(NSString*)phoneString
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
remainderString = nil;
|
||||
areaCodeString = nil;
|
||||
prefixString = nil;
|
||||
suffixString = nil;
|
||||
if (phoneString) {
|
||||
// get phone number into just a string of digits
|
||||
NSCharacterSet *digitCharSet = [NSCharacterSet decimalDigitCharacterSet];
|
||||
NSMutableString *tmpString = [NSMutableString stringWithCapacity:[phoneString length]];
|
||||
[tmpString appendString:phoneString];
|
||||
// remove non-digit characters
|
||||
for (int i = [tmpString length] - 1; i >= 0; i--) {
|
||||
if (![digitCharSet characterIsMember:[tmpString characterAtIndex:i]])
|
||||
[tmpString deleteCharactersInRange:NSMakeRange(i, 1)];
|
||||
}
|
||||
|
||||
// only fill in some values if we have an acceptable number of digits in total
|
||||
int digitCount = [tmpString length];
|
||||
if ((digitCount == 7) || (digitCount > 9)) {
|
||||
// if we got to this point, we must have prefix and suffix strings
|
||||
prefixString = [[tmpString substringWithRange:NSMakeRange(digitCount - 7, 3)] retain];
|
||||
suffixString = [[tmpString substringWithRange:NSMakeRange(digitCount - 4, 4)] retain];
|
||||
|
||||
// now fill in area code and remainder (if they exist)
|
||||
if (digitCount > 9) {
|
||||
// grab the area code
|
||||
areaCodeString = [[tmpString substringWithRange:NSMakeRange(digitCount - 10, 3)] retain];
|
||||
// ignore everything else if there is only one more digit and its a 1
|
||||
if (!((digitCount == 10) && ([[tmpString substringWithRange:NSMakeRange(9,1)] isEqualToString:@"1"]))) {
|
||||
remainderString = [[tmpString substringWithRange:NSMakeRange(0, digitCount - 9)] retain];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(void)dealloc
|
||||
{
|
||||
[remainderString release];
|
||||
[areaCodeString release];
|
||||
[prefixString release];
|
||||
[suffixString release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(NSString*)remainderString
|
||||
{
|
||||
return remainderString;
|
||||
}
|
||||
|
||||
-(NSString*)areaCodeString
|
||||
{
|
||||
return areaCodeString;
|
||||
}
|
||||
|
||||
-(NSString*)prefixString
|
||||
{
|
||||
return prefixString;
|
||||
}
|
||||
|
||||
-(NSString*)suffixString
|
||||
{
|
||||
return suffixString;
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,182 @@
|
|||
/* -*- Mode: C; tab-width: 4; 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
//
|
||||
// Portions of this extension have been rewritten from the original version in
|
||||
// order to shim in reading from the Apple address book instead of a saved data file. No
|
||||
// user data is stored in the profile, we only read from the address book.
|
||||
//
|
||||
// The majority of the code has been left as-is but commented out so that if additional
|
||||
// features want to be brought back in (such as saving form values) that should be
|
||||
// a bit easier.
|
||||
//
|
||||
|
||||
/*
|
||||
wallet.h --- prototypes for wallet functions.
|
||||
*/
|
||||
|
||||
#ifndef _WALLET_H
|
||||
#define _WALLET_H
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIPrompt.h"
|
||||
|
||||
class nsIDOMWindowInternal;
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
#define HEADER_VERSION "#2c"
|
||||
|
||||
// The only public API we expose from wallet. Prefills the given presShell with values
|
||||
// from the Apple Address Book's "me" card. This will initialize wallet if nothing else has
|
||||
// already done so so no additional intialzation routine is necessary.
|
||||
extern nsresult
|
||||
Wallet_Prefill(nsIDOMWindowInternal* win);
|
||||
|
||||
// Tell wallet to clean itself up.
|
||||
extern void
|
||||
Wallet_ReleaseAllLists();
|
||||
|
||||
//
|
||||
// Everything below here is kept as-is for posterity, in case anybody is crazy enough
|
||||
// to use it....
|
||||
//
|
||||
|
||||
#if UNUSED
|
||||
|
||||
#define YES_BUTTON 0
|
||||
#define NO_BUTTON 1
|
||||
#define NEVER_BUTTON 2
|
||||
|
||||
#define pref_Crypto "wallet.crypto"
|
||||
#define pref_AutoCompleteOverride "wallet.crypto.autocompleteoverride"
|
||||
|
||||
class nsIInputStream;
|
||||
class nsIOutputStream;
|
||||
class nsIFile;
|
||||
class nsIDOMNode;
|
||||
|
||||
extern void
|
||||
WLLT_ChangePassword(PRBool* status);
|
||||
|
||||
extern void
|
||||
WLLT_DeleteAll();
|
||||
|
||||
extern void
|
||||
WLLT_ClearUserData();
|
||||
|
||||
extern void
|
||||
WLLT_DeletePersistentUserData();
|
||||
|
||||
extern void
|
||||
WLLT_PreEdit(nsAString& walletList);
|
||||
|
||||
extern void
|
||||
WLLT_PostEdit(const nsAString& walletList);
|
||||
|
||||
extern void
|
||||
WLLT_PrefillReturn(const nsAString& results);
|
||||
|
||||
extern void
|
||||
WLLT_RequestToCapture(nsIPresShell* shell, nsIDOMWindowInternal * win, PRUint32* status);
|
||||
|
||||
extern nsresult
|
||||
WLLT_PrefillOneElement
|
||||
(nsIDOMWindowInternal* win, nsIDOMNode* elementNode, nsAString& compositeValue);
|
||||
|
||||
extern void
|
||||
WLLT_GetNopreviewListForViewer(nsAString& aNopreviewList);
|
||||
|
||||
extern void
|
||||
WLLT_GetNocaptureListForViewer(nsAString& aNocaptureList);
|
||||
|
||||
extern void
|
||||
WLLT_GetPrefillListForViewer(nsAString& aPrefillList);
|
||||
|
||||
extern void
|
||||
WLLT_OnSubmit(nsIContent* formNode, nsIDOMWindowInternal* window);
|
||||
|
||||
extern void
|
||||
WLLT_ExpirePassword(PRBool* status);
|
||||
|
||||
extern void
|
||||
WLLT_ExpirePasswordOnly(PRBool* status);
|
||||
|
||||
extern void
|
||||
WLLT_InitReencryptCallback(nsIDOMWindowInternal* window);
|
||||
|
||||
extern nsresult
|
||||
Wallet_Encrypt(const nsAString& text, nsAString& crypt);
|
||||
|
||||
extern nsresult
|
||||
Wallet_Decrypt(const nsAString& crypt, nsAString& text);
|
||||
|
||||
extern nsresult
|
||||
wallet_GetLine(nsIInputStream* strm, nsACString& line);
|
||||
|
||||
/**
|
||||
* Writes a line to a stream, including a newline character.
|
||||
* parameter should not include '\n'
|
||||
*/
|
||||
extern void
|
||||
wallet_PutLine(nsIOutputStream* strm, const char* line);
|
||||
|
||||
/**
|
||||
* Gets the current profile directory
|
||||
*/
|
||||
extern nsresult Wallet_ProfileDirectory(nsIFile** aFile);
|
||||
|
||||
extern PRUnichar * Wallet_Localize(const char * genericString);
|
||||
|
||||
extern char* Wallet_RandomName(char* suffix);
|
||||
|
||||
extern PRBool Wallet_ConfirmYN(PRUnichar * szMessage, nsIDOMWindowInternal* window);
|
||||
|
||||
extern PRInt32 Wallet_3ButtonConfirm(PRUnichar * szMessage, nsIDOMWindowInternal* window);
|
||||
|
||||
extern void Wallet_GiveCaveat(nsIDOMWindowInternal* window, nsIPrompt* dialog);
|
||||
|
||||
extern void
|
||||
Wallet_SignonViewerReturn(const nsAString& results);
|
||||
#endif
|
||||
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* !_WALLET_H */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче