");
std::string::size_type pos = 0;
std::string::size_type pos2 = 0;
bool last = false;
while (!last && !reqs.empty()) {
std::string req;
if ((pos2 = reqs.find("
");
std::string time = utils::text::source_get_value2(&get, "seenrequesttime=", "&\"");
facebook_user *fbu = new facebook_user();
fbu->real_name = utils::text::source_get_value(&req, 2, "class=\"actor\">", "");
fbu->user_id = utils::text::source_get_value(&get, 2, "id=", "&");
if (fbu->user_id.length() && fbu->real_name.length())
{
HANDLE hContact = AddToContactList(fbu, FACEBOOK_CONTACT_APPROVE, false, fbu->real_name.c_str());
DBWriteContactSettingByte(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_APPROVE);
bool seen = false;
DBVARIANT dbv;
if (!DBGetContactSettingString(hContact, m_szModuleName, "RequestTime", &dbv)) {
seen = !strcmp(dbv.pszVal, time.c_str());
DBFreeVariant(&dbv);
}
if (!seen) {
// This is new request
DBWriteContactSettingString(hContact, m_szModuleName, "RequestTime", time.c_str());
//blob is: uin( DWORD ), hContact( HANDLE ), nick( ASCIIZ ), first( ASCIIZ ), last( ASCIIZ ), email( ASCIIZ ), reason( ASCIIZ )
//blob is: 0( DWORD ), hContact( HANDLE ), nick( ASCIIZ ), ""( ASCIIZ ), ""( ASCIIZ ), ""( ASCIIZ ), ""( ASCIIZ )
DBEVENTINFO dbei = {0};
dbei.cbSize = sizeof( DBEVENTINFO );
dbei.szModule = m_szModuleName;
dbei.timestamp = ::time( NULL );
dbei.flags = DBEF_UTF;
dbei.eventType = EVENTTYPE_AUTHREQUEST;
dbei.cbBlob = (DWORD)(sizeof( DWORD )*2 + fbu->real_name.length() + 5);
PBYTE pCurBlob = dbei.pBlob = ( PBYTE ) mir_alloc( dbei.cbBlob );
*(PDWORD)pCurBlob = 0; pCurBlob += sizeof(DWORD); // UID
*(PDWORD)pCurBlob = (DWORD)hContact; pCurBlob += sizeof(DWORD); // Contact Handle
strcpy((char*)pCurBlob, fbu->real_name.data()); pCurBlob += fbu->real_name.length()+1; // Nickname
*pCurBlob = '\0'; pCurBlob++; // First Name
*pCurBlob = '\0'; pCurBlob++; // Last Name
*pCurBlob = '\0'; pCurBlob++; // E-mail
*pCurBlob = '\0'; // Reason
CallService(MS_DB_EVENT_ADD, 0, (LPARAM)&dbei);
LOG(" (New) Friendship request from: %s (%s) [%s]", fbu->real_name.c_str(), fbu->user_id.c_str(), time.c_str());
} else {
LOG(" (Old) Friendship request from: %s (%s) [%s]", fbu->real_name.c_str(), fbu->user_id.c_str(), time.c_str());
}
} else {
LOG(" !!! Wrong friendship request");
LOG(req.c_str());
}
}
facy.handle_success( "friendRequests" );
}
void FacebookProto::ProcessFeeds( void* data )
{
if ( data == NULL )
return;
std::string* resp = (std::string*)data;
if (!isOnline())
goto exit;
CODE_BLOCK_TRY
LOG("***** Starting processing feeds");
std::vector< facebook_newsfeed* > news;
std::string::size_type pos = 0;
UINT limit = 0;
*resp = utils::text::slashu_to_utf8(*resp);
*resp = utils::text::source_get_value(resp, 2, "\"html\":\"", ">\"");
while ( ( pos = resp->find( "
find( "
length();
std::string post = resp->substr( pos, pos2 - pos );
pos += 5;
std::string post_header = utils::text::source_get_value(&post, 4, "