From 2ec2fe72f5754f59363335f9d5578600022661a1 Mon Sep 17 00:00:00 2001 From: watcherhd Date: Thu, 26 Apr 2012 20:02:14 +0000 Subject: FacebookRM: version bump Version 0.0.8.1 ! Fixed getting notifications on login ! Fixed getting unread messages on login ! Getting unread messages on login with right timestamp ! Fixed getting newsfeeds ! Fixed related to deleting contacts from miranda/server + New newsfeed type option "Applications and Games" + Contacts now have MirVer "Facebook" (for Fingerpring plugin) + Getting attachements for unread messages on login ! Fixed avatars in Miranda 0.10.0#3 and newer (thanks borkra) ! Some small fixes (thanks borkra) x Doesn't work notification about friend requests git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@289 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- FacebookRM/json.cpp | 98 +++++++---------------------------------------------- 1 file changed, 12 insertions(+), 86 deletions(-) (limited to 'FacebookRM/json.cpp') diff --git a/FacebookRM/json.cpp b/FacebookRM/json.cpp index 93fa30e..4293f33 100644 --- a/FacebookRM/json.cpp +++ b/FacebookRM/json.cpp @@ -140,83 +140,6 @@ int facebook_json_parser::parse_buddy_list( void* data, List::List< facebook_use return EXIT_SUCCESS; } -int facebook_json_parser::parse_facepiles( void* data, std::map< std::string, std::string > *facepiles ) -{ - using namespace json; - - try - { - std::string buddyData = static_cast< std::string* >( data )->substr( 9 ); - std::istringstream sDocument( buddyData ); - Object objDocument; - Reader::Read(objDocument, sDocument); - std::map< std::string, std::string >::iterator it; - - const Object& objRoot = objDocument; -/* const Array& infos = objRoot["payload"]["facepile_click_info"]; - - for ( Array::const_iterator info( infos.Begin() ); - info != infos.End(); ++info) - { - const Object& objMember = *info; - - if (objMember.Find("uid") != objMember.End()) { - const Number& id = objMember["uid"]; - char was_id[32]; - lltoa( id.Value(), was_id, 10 ); - - const String& name = objMember["name"]; - std::string user_name = utils::text::slashu_to_utf8( - utils::text::special_expressions_decode( name.Value() ) ); - - it = facepiles->find( std::string( was_id ) ); - if ( it == facepiles->end() ) { - facepiles->insert( std::make_pair( was_id, user_name ) ); - } - } - } */ - - // Contacts in chat are getting by parsing html response. Don't know if it will work also for many people in chat room. - const String& response_html = objRoot["payload"]["response_html"]; - std::string contacts = utils::text::slashu_to_utf8( utils::text::special_expressions_decode( response_html.Value( ) ) ); - - std::string::size_type pos = 0; - while ((pos = contacts.find("") - pos); - - std::string status = utils::text::source_get_value2( &row, "chat", "\" " ); // "Online" or "Idle" - std::string name = utils::text::source_get_value( &row, 2, "title=\"", "\"" ); - std::string id = utils::text::source_get_value( &row, 3, "href=\"", "/profile.php?id=", "\"" ); - if (id.empty()) - id = utils::text::source_get_value( &row, 3, "href=\"", "facebook.com/", "\"" ); - - it = facepiles->find( id ); - if ( it == facepiles->end() ) { - facepiles->insert( std::make_pair( id, name ) ); - } - - pos++; - } - - } - catch (Reader::ParseException& e) - { - proto->Log( "!!!!! Caught json::ParseException: %s", e.what() ); - proto->Log( " Line/offset: %d/%d", e.m_locTokenBegin.m_nLine + 1, e.m_locTokenBegin.m_nLineOffset + 1 ); - } - catch (const Exception& e) - { - proto->Log( "!!!!! Caught json::Exception: %s", e.what() ); - } - catch (const std::exception& e) - { - proto->Log( "!!!!! Caught std::exception: %s", e.what() ); - } - - return EXIT_SUCCESS; -} - - int facebook_json_parser::parse_friends( void* data, std::map< std::string, facebook_user* >* friends ) { using namespace json; @@ -289,24 +212,27 @@ int facebook_json_parser::parse_notifications( void *data, std::vector< facebook Reader::Read(objDocument, sDocument); const Object& objRoot = objDocument; - const Object& payload = objRoot["payload"]["markup_map"]; + const Object& payload = objRoot["payload"]["notifications"]; for ( Object::const_iterator payload_item( payload.Begin() ); payload_item != payload.End(); ++payload_item) { const Object::Member& member = *payload_item; + + const Object& objMember = member.element; - const String& content = member.element; - + const String& content = objMember["markup"]; + const Number& unread = objMember["unread"]; + + if (unread.Value() == 0) // ignore old notifications + continue; + std::string text = utils::text::slashu_to_utf8( utils::text::special_expressions_decode( content.Value() ) ); - if (text.find("jewelItemNew") == std::string::npos) - continue; // we want only unread notifications - facebook_notification* notification = new facebook_notification( ); notification->text = utils::text::remove_html( utils::text::source_get_value(&text, 1, "link = utils::text::source_get_value(&text, 2, "link = utils::text::source_get_value(&text, 3, "push_back( notification ); } @@ -377,7 +303,7 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess facebook_message* message = new facebook_message( ); message->message_text = utils::text::special_expressions_decode( utils::text::slashu_to_utf8( text.Value( ) ) ); - message->time = ::time( NULL ); + message->time = ::time( NULL ); // TODO: use real time from facebook message->user_id = was_id; messages->push_back( message ); @@ -425,7 +351,7 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess message->sender_name = utils::text::special_expressions_decode( utils::text::slashu_to_utf8( sender_name.Value( ) ) ); - message->time = ::time( NULL ); + message->time = ::time( NULL ); // TODO: user real time from facebook message->user_id = was_id; // TODO: Check if we have contact with this ID in friendlist and then do something different? if (row.find("uiSplitPic",0) != std::string::npos) { -- cgit v1.2.3