本文整理汇总了C++中nsCOMPtr::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCOMPtr::GetLength方法的具体用法?C++ nsCOMPtr::GetLength怎么用?C++ nsCOMPtr::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCOMPtr
的用法示例。
在下文中一共展示了nsCOMPtr::GetLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
NS_IMETHODIMP
nsSimpleArrayEnumerator::HasMoreElements(bool* aResult)
{
NS_PRECONDITION(aResult != 0, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
if (!mValueArray) {
*aResult = false;
return NS_OK;
}
PRUint32 cnt;
nsresult rv = mValueArray->GetLength(&cnt);
if (NS_FAILED(rv)) return rv;
*aResult = (mIndex < cnt);
return NS_OK;
}
示例2: WantsProgress
NS_IMETHODIMP nsImportGenericAddressBooks::WantsProgress(bool *_retval)
{
NS_PRECONDITION(_retval != nullptr, "null ptr");
NS_ENSURE_ARG_POINTER(_retval);
GetDefaultLocation();
GetDefaultBooks();
bool result = false;
if (m_Books) {
uint32_t count = 0;
uint32_t i;
bool import;
uint32_t size;
uint32_t totalSize = 0;
m_Books->GetLength(&count);
for (i = 0; i < count; i++) {
nsCOMPtr<nsIImportABDescriptor> book = do_QueryElementAt(m_Books, i);
if (book) {
import = false;
size = 0;
nsresult rv = book->GetImport(&import);
if (NS_SUCCEEDED(rv) && import) {
(void) book->GetSize(&size);
result = true;
}
totalSize += size;
}
}
m_totalSize = totalSize;
}
m_doImport = result;
*_retval = result;
return NS_OK;
}
示例3: BeginImport
NS_IMETHODIMP nsImportGenericAddressBooks::BeginImport(nsISupportsString *successLog, nsISupportsString *errorLog, bool *_retval)
{
NS_PRECONDITION(_retval != nullptr, "null ptr");
if (!_retval)
return NS_ERROR_NULL_POINTER;
nsString success;
nsString error;
if (!m_doImport) {
*_retval = true;
nsImportStringBundle::GetStringByID(IMPORT_NO_ADDRBOOKS, m_stringBundle,
success);
SetLogs(success, error, successLog, errorLog);
return NS_OK;
}
if (!m_pInterface || !m_Books) {
nsImportStringBundle::GetStringByID(IMPORT_ERROR_AB_NOTINITIALIZED,
m_stringBundle, error);
SetLogs(success, error, successLog, errorLog);
*_retval = false;
return NS_OK;
}
bool needsFieldMap = false;
if (NS_FAILED(m_pInterface->GetNeedsFieldMap(m_pLocation, &needsFieldMap)) ||
(needsFieldMap && !m_pFieldMap)) {
nsImportStringBundle::GetStringByID(IMPORT_ERROR_AB_NOTINITIALIZED,
m_stringBundle, error);
SetLogs(success, error, successLog, errorLog);
*_retval = false;
return NS_OK;
}
NS_IF_RELEASE(m_pSuccessLog);
NS_IF_RELEASE(m_pErrorLog);
m_pSuccessLog = successLog;
m_pErrorLog = errorLog;
NS_IF_ADDREF(m_pSuccessLog);
NS_IF_ADDREF(m_pErrorLog);
// create the info need to drive address book import. We're
// not going to create a new thread for this since address books
// don't tend to be large, and import is rare.
m_pThreadData = new AddressThreadData();
m_pThreadData->books = m_Books;
NS_ADDREF(m_Books);
m_pThreadData->addressImport = m_pInterface;
NS_ADDREF(m_pInterface);
m_pThreadData->fieldMap = m_pFieldMap;
NS_IF_ADDREF(m_pFieldMap);
m_pThreadData->errorLog = m_pErrorLog;
NS_IF_ADDREF(m_pErrorLog);
m_pThreadData->successLog = m_pSuccessLog;
NS_IF_ADDREF(m_pSuccessLog);
if (m_pDestinationUri)
m_pThreadData->pDestinationUri = strdup(m_pDestinationUri);
uint32_t count = 0;
m_Books->GetLength(&count);
// Create/obtain any address books that we need here, so that we don't need
// to do so inside the import thread which would just proxy the create
// operations back to the main thread anyway.
nsCOMPtr<nsIAddrDatabase> db = GetAddressBookFromUri(m_pDestinationUri);
for (uint32_t i = 0; i < count; ++i)
{
nsCOMPtr<nsIImportABDescriptor> book = do_QueryElementAt(m_Books, i);
if (book)
{
if (!db)
{
nsString name;
book->GetPreferredName(name);
db = GetAddressBook(name.get(), true);
}
m_DBs.AppendObject(db);
}
}
m_pThreadData->dBs = &m_DBs;
NS_IF_ADDREF(m_pThreadData->stringBundle = m_stringBundle);
nsresult rv;
m_pThreadData->ldifService = do_GetService(NS_ABLDIFSERVICE_CONTRACTID, &rv);
ImportAddressThread(m_pThreadData);
delete m_pThreadData;
m_pThreadData = nullptr;
*_retval = true;
return NS_OK;
}