本文整理汇总了C++中nsIImportAddressBooks类的典型用法代码示例。如果您正苦于以下问题:C++ nsIImportAddressBooks类的具体用法?C++ nsIImportAddressBooks怎么用?C++ nsIImportAddressBooks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了nsIImportAddressBooks类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: NS_PRECONDITION
NS_IMETHODIMP nsImportGenericAddressBooks::SetData( const char *dataId, nsISupports *item)
{
NS_PRECONDITION(dataId != nsnull, "null ptr");
if (!dataId)
return NS_ERROR_NULL_POINTER;
if (!PL_strcasecmp( dataId, "addressInterface")) {
NS_IF_RELEASE( m_pInterface);
if (item)
item->QueryInterface( NS_GET_IID(nsIImportAddressBooks), (void **) &m_pInterface);
}
if (!PL_strcasecmp( dataId, "addressBooks")) {
NS_IF_RELEASE( m_pBooks);
if (item)
item->QueryInterface( NS_GET_IID(nsISupportsArray), (void **) &m_pBooks);
}
if (!PL_strcasecmp( dataId, "addressLocation")) {
m_pLocation = nsnull;
if (item) {
nsresult rv;
m_pLocation = do_QueryInterface(item, &rv);
NS_ENSURE_SUCCESS(rv,rv);
}
if (m_pInterface)
m_pInterface->SetSampleLocation(m_pLocation);
}
if (!PL_strcasecmp( dataId, "addressDestination")) {
if (item) {
nsCOMPtr<nsISupportsCString> abString;
item->QueryInterface( NS_GET_IID(nsISupportsCString), getter_AddRefs( abString));
if (abString) {
if (m_pDestinationUri)
NS_Free( m_pDestinationUri);
m_pDestinationUri = nsnull;
nsCAutoString tempUri;
abString->GetData(tempUri);
m_pDestinationUri = ToNewCString(tempUri);
}
}
}
if (!PL_strcasecmp( dataId, "fieldMap")) {
NS_IF_RELEASE( m_pFieldMap);
if (item)
item->QueryInterface( NS_GET_IID(nsIImportFieldMap), (void **) &m_pFieldMap);
}
return( NS_OK);
}
开发者ID:,项目名称:,代码行数:53,代码来源:
示例2: GetDefaultFieldMap
void nsImportGenericAddressBooks::GetDefaultFieldMap(void)
{
if (!m_pInterface || !m_pLocation)
return;
NS_IF_RELEASE(m_pFieldMap);
nsresult rv;
nsCOMPtr<nsIImportService> impSvc(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv));
if (NS_FAILED(rv)) {
IMPORT_LOG0("*** Unable to get nsIImportService.\n");
return;
}
rv = impSvc->CreateNewFieldMap(&m_pFieldMap);
if (NS_FAILED(rv))
return;
int32_t sz = 0;
rv = m_pFieldMap->GetNumMozFields(&sz);
if (NS_SUCCEEDED(rv))
rv = m_pFieldMap->DefaultFieldMap(sz);
if (NS_SUCCEEDED(rv))
rv = m_pInterface->InitFieldMap(m_pFieldMap);
if (NS_FAILED(rv)) {
IMPORT_LOG0("*** Error: Unable to initialize field map\n");
NS_IF_RELEASE(m_pFieldMap);
}
}
开发者ID:mxOBS,项目名称:deb-pkg_icedove,代码行数:29,代码来源:nsImportAddressBooks.cpp
示例3: GetProgress
NS_IMETHODIMP nsImportGenericAddressBooks::GetProgress(int32_t *_retval)
{
// This returns the progress from the the currently
// running import mail or import address book thread.
NS_PRECONDITION(_retval != nullptr, "null ptr");
if (!_retval)
return NS_ERROR_NULL_POINTER;
if (!m_pThreadData || !(m_pThreadData->threadAlive)) {
*_retval = 100;
return NS_OK;
}
uint32_t sz = 0;
if (m_pThreadData->currentSize && m_pInterface) {
if (NS_FAILED(m_pInterface->GetImportProgress(&sz)))
sz = 0;
}
if (m_totalSize)
*_retval = ((m_pThreadData->currentTotal + sz) * 100) / m_totalSize;
else
*_retval = 0;
// never return less than 5 so it looks like we are doing something!
if (*_retval < 5)
*_retval = 5;
// as long as the thread is alive don't return completely
// done.
if (*_retval > 99)
*_retval = 99;
return NS_OK;
}
开发者ID:mxOBS,项目名称:deb-pkg_icedove,代码行数:35,代码来源:nsImportAddressBooks.cpp
示例4: GetStatus
NS_IMETHODIMP nsImportGenericAddressBooks::GetStatus(const char *statusKind, int32_t *_retval)
{
NS_PRECONDITION(statusKind != nullptr, "null ptr");
NS_PRECONDITION(_retval != nullptr, "null ptr");
if (!statusKind || !_retval)
return NS_ERROR_NULL_POINTER;
*_retval = 0;
if (!PL_strcasecmp(statusKind, "isInstalled")) {
GetDefaultLocation();
*_retval = (int32_t) m_found;
}
if (!PL_strcasecmp(statusKind, "canUserSetLocation")) {
GetDefaultLocation();
*_retval = (int32_t) m_userVerify;
}
if (!PL_strcasecmp(statusKind, "autoFind")) {
GetDefaultLocation();
*_retval = (int32_t) m_autoFind;
}
if (!PL_strcasecmp(statusKind, "supportsMultiple")) {
bool multi = false;
if (m_pInterface)
m_pInterface->GetSupportsMultiple(&multi);
*_retval = (int32_t) multi;
}
if (!PL_strcasecmp(statusKind, "needsFieldMap")) {
bool needs = false;
if (m_pInterface && m_pLocation)
m_pInterface->GetNeedsFieldMap(m_pLocation, &needs);
*_retval = (int32_t) needs;
}
return NS_OK;
}
开发者ID:mxOBS,项目名称:deb-pkg_icedove,代码行数:40,代码来源:nsImportAddressBooks.cpp
示例5: GetDefaultBooks
void nsImportGenericAddressBooks::GetDefaultBooks(void)
{
if (!m_pInterface || m_Books)
return;
if (!m_pLocation && !m_autoFind)
return;
nsresult rv = m_pInterface->FindAddressBooks(m_pLocation, getter_AddRefs(m_Books));
if (NS_FAILED(rv)) {
IMPORT_LOG0("*** Error: FindAddressBooks failed\n");
}
}
开发者ID:mxOBS,项目名称:deb-pkg_icedove,代码行数:13,代码来源:nsImportAddressBooks.cpp
示例6: GetDefaultLocation
void nsImportGenericAddressBooks::GetDefaultLocation(void)
{
if (!m_pInterface)
return;
if ((m_pLocation && m_gotLocation) || m_autoFind)
return;
if (m_description)
NS_Free(m_description);
m_description = nullptr;
m_pInterface->GetAutoFind(&m_description, &m_autoFind);
m_gotLocation = true;
if (m_autoFind) {
m_found = true;
m_userVerify = false;
return;
}
nsCOMPtr <nsIFile> pLoc;
m_pInterface->GetDefaultLocation(getter_AddRefs(pLoc), &m_found, &m_userVerify);
if (!m_pLocation)
m_pLocation = pLoc;
}
开发者ID:mxOBS,项目名称:deb-pkg_icedove,代码行数:24,代码来源:nsImportAddressBooks.cpp
示例7: 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;
}
开发者ID:mxOBS,项目名称:deb-pkg_icedove,代码行数:95,代码来源:nsImportAddressBooks.cpp
示例8: 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;
}
开发者ID:mxOBS,项目名称:deb-pkg_icedove,代码行数:86,代码来源:nsImportAddressBooks.cpp
示例9: BeginImport
NS_IMETHODIMP nsImportGenericAddressBooks::BeginImport(nsISupportsString *successLog, nsISupportsString *errorLog, PRBool isAddrLocHome, PRBool *_retval)
{
NS_PRECONDITION(_retval != nsnull, "null ptr");
if (!_retval)
return NS_ERROR_NULL_POINTER;
nsString success;
nsString error;
if (!m_doImport) {
*_retval = PR_TRUE;
nsImportStringBundle::GetStringByID(IMPORT_NO_ADDRBOOKS, m_stringBundle,
success);
SetLogs( success, error, successLog, errorLog);
return( NS_OK);
}
if (!m_pInterface || !m_pBooks) {
nsImportStringBundle::GetStringByID(IMPORT_ERROR_AB_NOTINITIALIZED,
m_stringBundle, error);
SetLogs( success, error, successLog, errorLog);
*_retval = PR_FALSE;
return( NS_OK);
}
PRBool needsFieldMap = PR_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 = PR_FALSE;
return NS_OK;
}
if (m_pThreadData) {
m_pThreadData->DriverAbort();
m_pThreadData = nsnull;
}
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);
// kick off the thread to do the import!!!!
m_pThreadData = new AddressThreadData();
m_pThreadData->books = m_pBooks;
NS_ADDREF( m_pBooks);
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);
m_pThreadData->bAddrLocInput = isAddrLocHome ;
NS_IF_ADDREF(m_pThreadData->stringBundle = m_stringBundle);
nsresult rv;
nsCOMPtr<nsIAbLDIFService> ldifService(do_GetService(NS_ABLDIFSERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIProxyObjectManager> proxyObjectManager =
do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIAbLDIFService> proxyLDIFService;
rv = proxyObjectManager->GetProxyForObject(NS_PROXY_TO_CURRENT_THREAD,
NS_GET_IID(nsIAbLDIFService),
ldifService,
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
getter_AddRefs(proxyLDIFService));
NS_ENSURE_SUCCESS(rv, rv);
NS_IF_ADDREF(m_pThreadData->ldifService = proxyLDIFService);
PRThread *pThread = PR_CreateThread( PR_USER_THREAD, &ImportAddressThread, m_pThreadData,
PR_PRIORITY_NORMAL,
PR_LOCAL_THREAD,
PR_UNJOINABLE_THREAD,
0);
if (!pThread) {
m_pThreadData->ThreadDelete();
m_pThreadData->DriverDelete();
m_pThreadData = nsnull;
*_retval = PR_FALSE;
nsImportStringBundle::GetStringByID(IMPORT_ERROR_AB_NOTHREAD,
m_stringBundle, error);
SetLogs( success, error, successLog, errorLog);
}
else
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:
注:本文中的nsIImportAddressBooks类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论