diff options
author | Robert Pösel <robyer@seznam.cz> | 2012-05-25 20:20:00 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2012-05-25 20:20:00 +0000 |
commit | 11705ab059a43f26a6928775179c0abcd369d1a3 (patch) | |
tree | 00bd11dfc120955c98d26b52e500134e4241553c /protocols | |
parent | 8b40cd9cc08fa1f252948db272c148cc72adccec (diff) |
Facebook: More search results (up to 50)
git-svn-id: http://svn.miranda-ng.org/main/trunk@179 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/FacebookRM/process.cpp | 139 |
1 files changed, 77 insertions, 62 deletions
diff --git a/protocols/FacebookRM/process.cpp b/protocols/FacebookRM/process.cpp index 4c51141cb1..056b8115dc 100644 --- a/protocols/FacebookRM/process.cpp +++ b/protocols/FacebookRM/process.cpp @@ -730,80 +730,95 @@ void FacebookProto::SearchAckThread(void *targ) {
facy.handle_entry( "searchAckThread" );
- char *arg = mir_utf8encodeT((TCHAR*)targ);
- std::string search = utils::url::encode( arg );
+ int count = 0;
- // Get notifications
- http::response resp = facy.flap( FACEBOOK_REQUEST_SEARCH, NULL, &search );
+ char *arg = mir_utf8encodeT((TCHAR*)targ);
+ std::string search = utils::url::encode( arg );
+ std::string ssid;
- // Process result data
- facy.validate_response(&resp);
-
- if (resp.code == HTTP_CODE_OK)
+ while (count < 50 && !isOffline())
{
- std::string items = utils::text::source_get_value(&resp.data, 3, "<body", "<div class=\"c\">", "</body>");
+ std::string get_data = search + "&s=" + utils::conversion::to_string(&count, UTILS_CONV_UNSIGNED_NUMBER);
+ if (!ssid.empty())
+ get_data += "&ssid=" + ssid;
- std::string::size_type pos = 0;
- std::string::size_type pos2 = 0;
- bool last = false;
+ // Get notifications
+ http::response resp = facy.flap( FACEBOOK_REQUEST_SEARCH, NULL, &get_data );
- while (!last) {
- std::string item;
- if ((pos2 = items.find("<div class=\"c\">", pos)) != std::string::npos) {
- item = items.substr(pos, pos2 - pos);
- pos = pos2 + 14;
- } else {
- item = items.substr(pos);
- last = true;
- }
+ // Process result data
+ facy.validate_response(&resp);
- std::string id = utils::text::source_get_value2(&item, "?id=", "&\"");
- if (id.empty())
- id = utils::text::source_get_value2(&item, "?slog=", "&\"");
+ if (resp.code == HTTP_CODE_OK)
+ {
+ std::string items = utils::text::source_get_value(&resp.data, 3, "<body", "<div class=\"c\">", "</body>");
+
+ std::string::size_type pos = 0;
+ std::string::size_type pos2 = 0;
+ bool last = false;
+
+ while (!last) {
+ std::string item;
+ if ((pos2 = items.find("<div class=\"c\">", pos)) != std::string::npos) {
+ item = items.substr(pos, pos2 - pos);
+ pos = pos2 + 14;
+ } else {
+ item = items.substr(pos);
+ last = true;
+ }
- std::string name = utils::text::source_get_value(&item, 2, "<span>", "</span>");
- std::string surname;
- std::string nick;
- std::string common = utils::text::source_get_value(&item, 2, "<span class=\"fcg\">", "</span>");
+ count++;
- if ((pos2 = name.find(" <span class=\"alternate_name\">")) != std::string::npos) {
- nick = name.substr(pos2 + 31, name.length() - pos2 - 32); // also remove brackets around nickname
- name = name.substr(0, pos2);
- }
+ 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, 2, "<span>", "</span>");
+ std::string surname;
+ std::string nick;
+ std::string common = utils::text::source_get_value(&item, 2, "<span class=\"fcg\">", "</span>");
+
+ if ((pos2 = name.find(" <span class=\"alternate_name\">")) != 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);
+ }
- 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);
}
- // 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);
|