Added the concept of a replaceable entry. This is an entry which when a new item is added will get overwritten rather than adding the entry to the end of the list.

This commit is contained in:
tbogard%aol.net 2000-03-28 00:19:05 +00:00
Родитель 943ee880f3
Коммит b5fb426956
5 изменённых файлов: 64 добавлений и 31 удалений

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

@ -36,7 +36,7 @@ interface nsISHTransaction : nsISupports
/**
* The nsISHEntry for the current transaction
*/
readonly attribute nsISHEntry sHEntry;
attribute nsISHEntry sHEntry;
/**
* The parent of this transaction
@ -53,6 +53,12 @@ interface nsISHTransaction : nsISupports
*/
readonly attribute nsISHTransaction lrvList;
/**
* Specifies if this transaction should persist. If not it will be replaced
* by new additions to the list.
*/
attribute boolean persist;
/**
* Create a transaction with parent and History Entry
*/

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

@ -38,8 +38,12 @@ interface nsISHistory: nsISupports
{
/**
* Add a new Entry to the History List
* @param aEntry - The entry to add
* @param aPersist - If true this specifies that the entry should persist
* in the list. If false, this means that when new entries are added
* this element will not appear in the session history list.
*/
void addEntry(in nsISHEntry aEntry);
void addEntry(in nsISHEntry aEntry, in boolean aPersist);
/**
* Get the size of the History list

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

@ -40,7 +40,8 @@
NS_IMPL_ISUPPORTS1(nsSHTransaction, nsISHTransaction)
nsSHTransaction::nsSHTransaction() : mParent(nsnull), mChild(nsnull),mLRVList(nsnull), mSHEntry(nsnull)
nsSHTransaction::nsSHTransaction() : mPersist(PR_TRUE), mParent(nsnull),
mChild(nsnull), mLRVList(nsnull), mSHEntry(nsnull)
{
NS_INIT_REFCNT();
}
@ -157,6 +158,22 @@ nsSHTransaction::GetLrvList(nsISHTransaction ** aResult)
return NS_OK;
}
NS_IMETHODIMP
nsSHTransaction::SetPersist(PRBool aPersist)
{
mPersist = aPersist;
return NS_OK;
}
NS_IMETHODIMP
nsSHTransaction::GetPersist(PRBool* aPersist)
{
NS_ENSURE_ARG_POINTER(aPersist);
*aPersist = mPersist;
return NS_OK;
}
NS_IMETHODIMP
NS_NewSHTransaction(nsISupports* aOuter, REFNSIID aIID, void** aResult)

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

@ -43,9 +43,11 @@ private:
NS_NewSHTransaction(nsISupports * aOuter, REFNSIID aIID, void** aResult);
nsresult SetChild(nsISHTransaction * aChild);
nsresult SetParent(nsISHTransaction * aParent);
nsresult SetSHEntry(nsISHEntry * aSHEntry);
//nsresult SetSHEntry(nsISHEntry * aSHEntry);
//nsresult SetLRVList(nsISHTransaction * aLRVList);
PRBool mPersist;
/* Weak reference to parent */
nsISHTransaction * mParent;
nsISHTransaction * mChild;

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

@ -57,37 +57,41 @@ nsSHistory::~nsSHistory()
* increment the index to point to the new entry
*/
NS_IMETHODIMP
nsSHistory::AddEntry(nsISHEntry * aSHEntry)
nsSHistory::AddEntry(nsISHEntry * aSHEntry, PRBool aPersist)
{
nsresult rv;
NS_ENSURE_ARG(aSHEntry);
NS_PRECONDITION(aSHEntry != nsnull, "null ptr");
if (! aSHEntry)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsISHTransaction> currentTxn;
nsCOMPtr<nsISHTransaction> txn;
rv = nsComponentManager::CreateInstance(NS_SHTRANSACTION_PROGID,
nsnull,
NS_GET_IID(nsISHTransaction),
getter_AddRefs(txn));
nsCOMPtr<nsISHTransaction> parent;
if(mListRoot)
GetTransactionAtIndex(mIndex, getter_AddRefs(currentTxn));
PRBool currentPersist = PR_TRUE;
if(currentTxn)
currentTxn->GetPersist(&currentPersist);
if(!currentPersist)
{
NS_ENSURE_SUCCESS(currentTxn->SetSHEntry(aSHEntry),
NS_ERROR_FAILURE);
return NS_OK;
}
nsCOMPtr<nsISHTransaction> txn(do_CreateInstance(NS_SHTRANSACTION_PROGID));
NS_ENSURE_TRUE(txn, NS_ERROR_FAILURE);
// Set the ShEntry and parent for the transaction. setting the
// parent will properly set the parent child relationship
txn->SetPersist(aPersist);
NS_ENSURE_SUCCESS(txn->Create(aSHEntry, currentTxn), NS_ERROR_FAILURE);
mLength++;
mIndex++;
// If this is the very first transaction, initialize the list
if(!mListRoot)
mListRoot = txn;
PrintHistory();
if (NS_SUCCEEDED(rv) && txn) {
if (mListRoot) {
GetTransactionAtIndex(mIndex, getter_AddRefs(parent));
}
// Set the ShEntry and parent for the transaction. setting the
// parent will properly set the parent child relationship
rv = txn->Create(aSHEntry, parent);
if (NS_SUCCEEDED(rv)) {
mLength++;
mIndex++;
// If this is the very first transaction, initialize the list
if (!mListRoot)
mListRoot = txn;
PrintHistory();
}
}
return NS_OK;
}