当前位置: 首页>>代码示例>>C++>>正文


C++ Contact::AddPhoneNumber方法代码示例

本文整理汇总了C++中Contact::AddPhoneNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ Contact::AddPhoneNumber方法的具体用法?C++ Contact::AddPhoneNumber怎么用?C++ Contact::AddPhoneNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contact的用法示例。


在下文中一共展示了Contact::AddPhoneNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ContactPhoneNumberFound

void ContactList::ContactPhoneNumberFound(PhoneNumberType phoneType, std::string phoneNumber)
{
	//retrieve contact added last
	Contact *contact = m_contacts.back();
	contact->AddPhoneNumber(phoneType, phoneNumber);
}
开发者ID:BackupTheBerlios,项目名称:bme-svn,代码行数:6,代码来源:ContactList.cpp

示例2: AppLog

//TODO: Is it possible to set additional information?
v8::Handle<v8::Value> Contacts::add(const v8::Arguments& args) {
    AppLog("Entered Contacts::addContact (args length:%d)", args.Length());

//    if (args.Length() < 1 || Util::isArgumentNull(args[0])) {
    if (args.Length() < 1) {
        AppLog("Bad parameters");
        return v8::ThrowException(v8::String::New("Bad parameters"));
    }
    v8::HandleScope scope;

    String category;
	String name;
	String number;

	v8::Local<v8::Object> obj = args[0]->ToObject();
    if(args[0]->IsObject())
    {
		v8::Local<v8::Value> obj_category = obj->Get(v8::String::New("category"));
		if(obj_category->IsString())
		{
			category = UNWRAP_STRING(obj_category).c_str();
			AppLogTag("Contacts","Add Contacts: [Category:%ls]", category.GetPointer());
		}

		v8::Local<v8::Value> obj_name = obj->Get(v8::String::New("name"));
		if(obj_name->IsString())
		{
			name = UNWRAP_STRING(obj_name).c_str();
			AppLogTag("Contacts","Add Contacts: [Name:%ls]", name.GetPointer());
		}
	}

    if(category == null || name == null)
    {
    	AppLogTag("Contacts","Failed to add Contact");
    	return scope.Close(v8::Boolean::New(false));
    }

    //CREATE CONTACT
    Contact contact;
    contact.SetValue(CONTACT_PROPERTY_ID_FIRST_NAME, name);

    v8::Local<v8::Value> obj_number = obj->Get(v8::String::New("number"));

	if(!obj_number->IsNull() && obj_number->IsString())
	{
		number = UNWRAP_STRING(obj_number).c_str();
		AppLogTag("Contacts","Add Contacts: [Number:%ls]", number.GetPointer());
		PhoneNumber phoneNumber;
		phoneNumber.SetPhoneNumber(number);
		contact.AddPhoneNumber(phoneNumber);
	}

	AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
	Addressbook* pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID);

    //GET CATEGORIES TO ADD A CONTACT
	IList* pCategoryList = pAddressbook->GetAllCategoriesN();

	result r = GetLastResult();
	if (IsFailed(r)) {
		AppLogTag("Contacts", "Failed to get categories: %s", GetErrorMessage(r));
		return scope.Close(v8::Boolean::New(false));
	}

	if (pCategoryList != null && pCategoryList->GetCount() > 0) {
		IEnumerator* pCategoryEnum = pCategoryList->GetEnumeratorN();
		Category* pCategory = null;

		while (pCategoryEnum->MoveNext() == E_SUCCESS) {
			pCategory = static_cast<Category*>(pCategoryEnum->GetCurrent());
			if (pCategory->GetName().Equals(category)) {

				pAddressbook->AddContact(contact);
				pAddressbook->AddMemberToCategory(pCategory->GetRecordId(), contact.GetRecordId());

				if (IsFailed(GetLastResult())) {
					return scope.Close(v8::Boolean::New(false));
				} else {
					AppLogTag("Contacts", "%d", contact.GetRecordId());
					return scope.Close(v8::Boolean::New(true));
				}
			}
		}
	}

	AppLogTag("Contacts","No Categories");
	return scope.Close(v8::Boolean::New(false));
}
开发者ID:bylee,项目名称:cantata-jsbind,代码行数:90,代码来源:tizenair-contact.cpp


注:本文中的Contact::AddPhoneNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。