title.c_str(), news[i]->text.c_str());
TCHAR* szTitle = mir_a2t_cp(news[i]->title.c_str(), CP_UTF8);
TCHAR* szText = mir_a2t_cp(news[i]->text.c_str(), CP_UTF8);
TCHAR* szUrl = mir_a2t_cp(news[i]->link.c_str(), CP_UTF8);
NotifyEvent(szTitle,szText,this->ContactIDToHContact(news[i]->user_id),FACEBOOK_EVENT_NEWSFEED, szUrl);
mir_free(szTitle);
mir_free(szText);
// mir_free(szUrl); // URL is free'd in popup procedure
delete news[i];
}
news.clear();
this->facy.last_feeds_update_ = ::time(NULL);
LOG("***** Feeds processed");
CODE_BLOCK_CATCH
LOG("***** Error processing feeds: %s", e.what());
CODE_BLOCK_END
exit:
delete resp;
}
void FacebookProto::SearchAckThread(void *targ)
{
facy.handle_entry("searchAckThread");
int count = 0;
char *arg = mir_utf8encodeT((TCHAR*)targ);
std::string search = utils::url::encode(arg);
std::string ssid;
while (count < 50 && !isOffline())
{
std::string get_data = search + "&s=" + utils::conversion::to_string(&count, UTILS_CONV_UNSIGNED_NUMBER);
if (!ssid.empty())
get_data += "&ssid=" + ssid;
http::response resp = facy.flap(FACEBOOK_REQUEST_SEARCH, NULL, &get_data);
// Process result data
facy.validate_response(&resp);
if (resp.code == HTTP_CODE_OK)
{
std::string items = utils::text::source_get_value(&resp.data, 2, "");
std::string::size_type pos = 0;
std::string::size_type pos2 = 0;
while ((pos = items.find("", pos)) != std::string::npos) {
std::string item = items.substr(pos, items.find("", pos) - pos);
pos++; count++;
std::string id = utils::text::source_get_value2(&item, "?id=", "&\"");
if (id.empty())
id = utils::text::source_get_value2(&item, "?slog=", "&\"");
std::string name = utils::text::source_get_value(&item, 4, " | ", "", "");
std::string surname;
std::string nick;
std::string common = utils::text::source_get_value(&item, 2, "", "");
if ((pos2 = name.find(" ")) != std::string::npos) {
nick = name.substr(pos2 + 31, name.length() - pos2 - 32); // also remove brackets around nickname
name = name.substr(0, pos2);
}
if ((pos2 = name.find(" ")) != std::string::npos) {
surname = name.substr(pos2 + 1, name.length() - pos2 - 1);
name = name.substr(0, pos2);
}
// ignore self contact and empty ids
if (id.empty() || id == facy.self_.user_id)
continue;
TCHAR* tid = mir_a2t_cp(id.c_str(), CP_UTF8);
TCHAR* tname = mir_a2t_cp(name.c_str(), CP_UTF8);
TCHAR* tsurname = mir_a2t_cp(surname.c_str(), CP_UTF8);
TCHAR* tnick = mir_a2t_cp(nick.c_str(), CP_UTF8);
TCHAR* tcommon = mir_a2t_cp(common.c_str(), CP_UTF8);
PROTOSEARCHRESULT isr = {0};
isr.cbSize = sizeof(isr);
isr.flags = PSR_TCHAR;
isr.id = tid;
isr.nick = tnick;
isr.firstName = tname;
isr.lastName = tsurname;
isr.email = tcommon;
ProtoBroadcastAck(m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, targ, (LPARAM)&isr);
mir_free(tid);
mir_free(tnick);
mir_free(tname);
mir_free(tsurname);
mir_free(tcommon);
}
ssid = utils::text::source_get_value(&items, 3, "id=\"more_objects\"", "ssid=", "&");
if (ssid.empty())
break; // No more results
}
}
ProtoBroadcastAck(m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, targ, 0);
facy.handle_success("searchAckThread");
mir_free(targ);
mir_free(arg);
}
|