⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nqcontactengine.cpp

📁 本例是SYMBIAN C++一个创建短信的例子
💻 CPP
字号:
/*
 * CNqContactEngine class
 * Contact Engine for NetQin
 * Date: 2008.06.11
 * Author: Tomken
 */

#include "NqContactEngine.h"
#include <cpbkcontactengine.h> 
#include <cpbkcontactchangenotifier.h>
#include <cpbkcontactiter.h>
#include <cpbkcontactitem.h> 
#include <cntdef.h>

CNqContactEngine* CNqContactEngine::NewL()
{
	CNqContactEngine* self = new (ELeave) CNqContactEngine();
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop(self);
	return self;
}

CNqContactEngine::CNqContactEngine()
{
	iLastOpCnItem = NULL;
	iLastOpCnId = -1;
}

CNqContactEngine::~CNqContactEngine()
{
	delete iLastOpCnItem;
	delete iNotifier;
	
	iPbkEngine->CompressL();
	delete iPbkEngine;
	
	iContactsArray->Reset();
	delete iContactsArray;
}

void CNqContactEngine::ConstructL()
{
	iPbkEngine = CPbkContactEngine::NewL();
	iNotifier = iPbkEngine->CreateContactChangeNotifierL(this); 
	iContactsArray = CContactIdArray::NewL();
}

void CNqContactEngine::HandleDatabaseEventL(TContactDbObserverEvent aEvent)
{
	if(aEvent.iType == EContactDbObserverEventContactAdded)
	{
	}
}

void CNqContactEngine::SynchContactListL()
{
	CPbkContactItem *item=0;
	iContactsArray->Reset();
	
	CPbkContactIter * iter = iPbkEngine->CreateContactIteratorLC(ETrue);
	for (iter->FirstL(); (item=iter->CurrentL()); iter->NextL()) 
	{
		if(item->Type() != KUidContactGroup)
		{
			iContactsArray->AddL(item->Id());
		}
	}
	
	CleanupStack::PopAndDestroy(iter); // iter
}

TInt CNqContactEngine::ContactsCount()
{
	return iContactsArray->Count();
}

TContactItemId CNqContactEngine::ContactItemId(TInt aIndex)
{
	if(aIndex >= 0 && aIndex < iContactsArray->Count())
		return (*iContactsArray)[aIndex];
	else
		return -1;
}

void CNqContactEngine::MakeLastCnItemL(TContactItemId aCnId)
{
	if(aCnId != iLastOpCnId || !iLastOpCnItem)
	{
		delete iLastOpCnItem;
		iLastOpCnItem = iPbkEngine->ReadContactL(aCnId);
		iLastOpCnId = aCnId;
	}
}

void CNqContactEngine::ContactItemTextInfoL(TContactItemId aCnId, TPbkFieldId aType, TDes& aBuf)
{
	MakeLastCnItemL(aCnId);

	TPbkContactItemField* itemField = iLastOpCnItem->FindField(aType);
	if(itemField && itemField->StorageType() == KStorageTypeText)
	{
		TPtrC ptrc = itemField->Text();
		aBuf.Copy(ptrc.Left(aBuf.MaxLength()));
	}
}

TStorageType CNqContactEngine::ContactItemStorageType(TContactItemId aCnId, TPbkFieldId aType)
{
	TStorageType tst = -1;
	MakeLastCnItemL(aCnId);
	
	TPbkContactItemField* itemField = iLastOpCnItem->FindField(aType);
	if(itemField && !itemField->IsEmpty())
		tst = itemField->StorageType();

	return tst;
}

HBufC8* CNqContactEngine::ContactItemThumbnailImageDataL(TContactItemId aCnId)
{
	MakeLastCnItemL(aCnId);
	
	TPbkContactItemField* itemField = iLastOpCnItem->FindField(EPbkFieldIdThumbnailImage);
	if(itemField && itemField->StorageType() == KStorageTypeStore)
	{
		CContactStoreField* csf = itemField->ItemField().StoreStorage();
		
		if(csf && csf->IsFull())
		{
			return csf->Thing();
		}
	}
	return NULL;
}

// end of file

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -