本文整理汇总了C++中nsIImportAddressBooks::GetSampleData方法的典型用法代码示例。如果您正苦于以下问题:C++ nsIImportAddressBooks::GetSampleData方法的具体用法?C++ nsIImportAddressBooks::GetSampleData怎么用?C++ nsIImportAddressBooks::GetSampleData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsIImportAddressBooks
的用法示例。
在下文中一共展示了nsIImportAddressBooks::GetSampleData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetData
NS_IMETHODIMP nsImportGenericAddressBooks::GetData(const char *dataId, nsISupports **_retval)
{
NS_PRECONDITION(_retval != nullptr, "null ptr");
if (!_retval)
return NS_ERROR_NULL_POINTER;
nsresult rv;
*_retval = nullptr;
if (!PL_strcasecmp(dataId, "addressInterface")) {
*_retval = m_pInterface;
NS_IF_ADDREF(m_pInterface);
}
if (!PL_strcasecmp(dataId, "addressLocation")) {
if (!m_pLocation)
GetDefaultLocation();
NS_IF_ADDREF(*_retval = m_pLocation);
}
if (!PL_strcasecmp(dataId, "addressBooks")) {
if (!m_pLocation)
GetDefaultLocation();
if (!m_Books)
GetDefaultBooks();
*_retval = m_Books;
}
if (!PL_strcasecmp(dataId, "addressDestination")) {
if (m_pDestinationUri) {
nsCOMPtr<nsISupportsCString> abString = do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
abString->SetData(nsDependentCString(m_pDestinationUri));
NS_IF_ADDREF(*_retval = abString);
}
}
if (!PL_strcasecmp(dataId, "fieldMap")) {
if (m_pFieldMap) {
*_retval = m_pFieldMap;
m_pFieldMap->AddRef();
}
else {
if (m_pInterface && m_pLocation) {
bool needsIt = false;
m_pInterface->GetNeedsFieldMap(m_pLocation, &needsIt);
if (needsIt) {
GetDefaultFieldMap();
if (m_pFieldMap) {
*_retval = m_pFieldMap;
m_pFieldMap->AddRef();
}
}
}
}
}
if (!PL_strncasecmp(dataId, "sampleData-", 11)) {
// extra the record number
const char *pNum = dataId + 11;
int32_t rNum = 0;
while (*pNum) {
rNum *= 10;
rNum += (*pNum - '0');
pNum++;
}
IMPORT_LOG1("Requesting sample data #: %ld\n", (long)rNum);
if (m_pInterface) {
nsCOMPtr<nsISupportsString> data = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
char16_t * pData = nullptr;
bool found = false;
rv = m_pInterface->GetSampleData(rNum, &found, &pData);
if (NS_FAILED(rv))
return rv;
if (found) {
data->SetData(nsDependentString(pData));
*_retval = data;
NS_ADDREF(*_retval);
}
NS_Free(pData);
}
}
return NS_OK;
}