Example #1
0
MCONTACT FacebookProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
{
	ptrA id(mir_t2a_cp(psr->id.t, CP_UTF8));
	ptrA name(mir_t2a_cp(psr->firstName.t, CP_UTF8));
	ptrA surname(mir_t2a_cp(psr->lastName.t, CP_UTF8));

	if (id == NULL)
		return NULL;

	facebook_user fbu;
	fbu.user_id = id;
	if (name != NULL)
		fbu.real_name = name;
	if (surname != NULL) {
		fbu.real_name += " ";
		fbu.real_name += surname;
	}

	if (fbu.user_id.find_first_not_of("0123456789") != std::string::npos) {
		MessageBox(0, TranslateT("Facebook ID must be numeric value."), m_tszUserName, MB_ICONERROR | MB_OK);
		return NULL;
	}

	bool add_temporarily = (flags & PALF_TEMPORARY);
	MCONTACT hContact = AddToContactList(&fbu, CONTACT_NONE, false, add_temporarily);

	// Reset NotOnList flag if present and we're adding this contact not temporarily
	if (hContact && !add_temporarily && db_get_b(hContact, "CList", "NotOnList", 0)) {
		db_unset(hContact, "CList", "Hidden");
		db_unset(hContact, "CList", "NotOnList");
	}

	return hContact;
}
Example #2
0
File: main.cpp Project: CCJY/coliru
int main( int, char** )
{
    std::string name = "John";
    auto ptr = Widget::create( name, "Smith", 99 );
    ptr = Widget::create( std::move( *ptr ) );
    std::cout << "Expected name: " << name << std::endl;
    std::cout << ptr->name() << std::endl;
    std::cout << ptr->surname() << std::endl;
    std::cout << ptr->catCount() << std::endl;
    
    return 0;
}
Example #3
0
MCONTACT FacebookProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
{
	ptrA id( mir_t2a_cp(psr->id, CP_UTF8));
	ptrA name( mir_t2a_cp(psr->firstName, CP_UTF8));
	ptrA surname( mir_t2a_cp(psr->lastName, CP_UTF8));

	if (id == NULL)
		return NULL;

	facebook_user fbu;
	fbu.user_id = id;
	if (name != NULL)
		fbu.real_name = name;
	if (surname != NULL) {
		fbu.real_name += " ";
		fbu.real_name += surname;
	}

	if (fbu.user_id.find_first_not_of("0123456789") != std::string::npos) {
		MessageBox(0, TranslateT("Facebook ID must be numeric value."), m_tszUserName, MB_ICONERROR | MB_OK);
		return NULL;
	}

	MCONTACT hContact = AddToContactList(&fbu, CONTACT_NONE);
	if (hContact) {
		if (flags & PALF_TEMPORARY) {
			db_set_b(hContact, "Clist", "Hidden", 1);
			db_set_b(hContact, "Clist", "NotOnList", 1);
		}
		else if (db_get_b(hContact, "CList", "NotOnList", 0)) {
			db_unset(hContact, "CList", "Hidden");
			db_unset(hContact, "CList", "NotOnList");
		}
	}

	return hContact;
}