// Set the currently entered password, may be NULL void CSecureEditEx::SetPassword(LPCTSTR lpPassword) { _DeleteAll(); if(m_bSecMode == FALSE) { if(lpPassword != NULL) SetWindowText(lpPassword); else SetWindowText(_T("")); return; } if(lpPassword != NULL) { unsigned int uLen = (unsigned int)_tcslen(lpPassword); if(uLen != 0) _InsertCharacters(0, lpPassword, uLen); size_t sizeTempBuffer = uLen + 1; LPTSTR tszBuf = new TCHAR[sizeTempBuffer]; ASSERT(tszBuf != NULL); if(tszBuf != NULL) { _tcscpy_s(tszBuf, sizeTempBuffer, lpPassword); _tcsset_s(tszBuf, sizeTempBuffer, TCH_STDPWCHAR); m_nOldLen = (int)_tcslen(tszBuf); ASSERT(m_nOldLen == (int)uLen); SetWindowText(tszBuf); delete []tszBuf; tszBuf = NULL; } else SetWindowText(_T("")); } else SetWindowText(_T("")); }
// Enable or disable the secure mode, default is enabled void CSecureEditEx::EnableSecureMode(BOOL bEnable) { if(m_bSecMode == bEnable) return; // Nothing to do LPTSTR lpSource = GetPassword(); ASSERT(lpSource != NULL); ASSERT((int)_tcslen(lpSource) == m_nOldLen); const int iPos = static_cast<int>(GetSel() & 0xFFFF); _DeleteAll(); m_bSecMode = bEnable; if(lpSource != NULL) { m_nOldLen = (int)_tcslen(lpSource); if(bEnable == FALSE) SetWindowText(lpSource); else { if(m_nOldLen != 0) { _InsertCharacters(0, lpSource, (unsigned int)m_nOldLen); _tcsset_s(lpSource, m_nOldLen + 1, TCH_STDPWCHAR); } SetWindowText(lpSource); } if((iPos >= 0) && (iPos <= m_nOldLen)) SetSel(iPos, iPos, FALSE); else { ASSERT(FALSE); } } DeletePassword(lpSource); lpSource = NULL; }
void DwMailboxList::Parse() { mIsModified = 0; // Mailboxes are separated by commas. Commas may also occur in a route. // (See RFC822 p. 27) if (mFirstMailbox) _DeleteAll(); DwMailboxListParser parser(mString); DwMailbox* mailbox; while (1) { switch (parser.MbType()) { case DwMailboxListParser::eMbError: case DwMailboxListParser::eMbEnd: goto LOOP_EXIT; case DwMailboxListParser::eMbMailbox: mailbox = DwMailbox::NewMailbox(parser.MbString(), this); mailbox->Parse(); if (mailbox->IsValid()) { _AddMailbox(mailbox); } else { delete mailbox; } break; case DwMailboxListParser::eMbNull: break; } ++parser; } LOOP_EXIT: return; }
CSecureEditEx::~CSecureEditEx() { if(m_pSecDrop != NULL) { m_pSecDrop->Revoke(); delete m_pSecDrop; m_pSecDrop = NULL; } _DeleteAll(); SetMemoryEx(m_pXorPad, 0, SE_XORPAD_SIZE * sizeof(TCHAR)); DeleteTPtr(m_pXorPad, TRUE, FALSE); m_pXorPad = NULL; }
const DwMailboxList& DwMailboxList::operator = (const DwMailboxList& aList) { if (this == &aList) return *this; DwFieldBody::operator = (aList); if (mFirstMailbox) { _DeleteAll(); } const DwMailbox* firstMailbox = aList.mFirstMailbox; if (firstMailbox) { CopyList(firstMailbox); } if (mParent && mIsModified) { mParent->SetModified(); } return *this; }
void CSecureEditEx::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { if(m_bSecMode == TRUE) { if((nChar == VK_HOME) || (nChar == VK_END)) { SHORT shShift = GetKeyState(VK_SHIFT); shShift |= GetKeyState(VK_LSHIFT); shShift |= GetKeyState(VK_RSHIFT); if((shShift & 0x8000) != 0) { _DeleteAll(); SetWindowText(_T("")); SetSel(0, 0, FALSE); } } } CEdit::OnKeyDown(nChar, nRepCnt, nFlags); _ClearSelection(); }
DwMailboxList::~DwMailboxList() { if (mFirstMailbox) { _DeleteAll(); } }
void DwMailboxList::DeleteAll() { _DeleteAll(); SetModified(); }