summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/json.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2013-04-10 07:17:34 +0000
committerRobert Pösel <robyer@seznam.cz>2013-04-10 07:17:34 +0000
commit567faf65895cc362a714fc60508fb676863031af (patch)
tree39ae3caef87285d8c66777a809181de96bf6f83b /protocols/FacebookRM/src/json.cpp
parent2db0f15d4e99fc869402268195fdf63d6131b34f (diff)
Removed spaces around brackets
git-svn-id: http://svn.miranda-ng.org/main/trunk@4406 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/json.cpp')
-rw-r--r--protocols/FacebookRM/src/json.cpp162
1 files changed, 81 insertions, 81 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 89e2359dfa..5ca3496c43 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -25,52 +25,52 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "JSON_CAJUN/writer.h"
#include "JSON_CAJUN/elements.h"
-int facebook_json_parser::parse_buddy_list( void* data, List::List< facebook_user >* buddy_list )
+int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user >* buddy_list)
{
using namespace json;
try
{
facebook_user* current = NULL;
- std::string buddyData = static_cast< std::string* >( data )->substr( 9 );
- std::istringstream sDocument( buddyData );
+ std::string buddyData = static_cast< std::string* >(data)->substr(9);
+ std::istringstream sDocument(buddyData);
Object objDocument;
Reader::Read(objDocument, sDocument);
const Object& objRoot = objDocument;
/* const Array& wasAvailableIDs = objRoot["payload"]["buddy_list"]["wasAvailableIDs"];
- for ( Array::const_iterator itWasAvailable( wasAvailableIDs.Begin());
+ for (Array::const_iterator itWasAvailable(wasAvailableIDs.Begin());
itWasAvailable != wasAvailableIDs.End(); ++itWasAvailable)
{
const Number& member = *itWasAvailable;
char was_id[32];
- lltoa( member.Value(), was_id, 10 );
+ lltoa(member.Value(), was_id, 10);
- current = buddy_list->find( std::string( was_id ));
- if ( current != NULL )
+ current = buddy_list->find(std::string(was_id));
+ if (current != NULL)
current->status_id = ID_STATUS_OFFLINE;
}*/ // Facebook removed support for "wasAvailableIDs"
// Set all contacts in map to offline
- for ( List::Item< facebook_user >* i = buddy_list->begin( ); i != NULL; i = i->next ) {
+ for (List::Item< facebook_user >* i = buddy_list->begin(); i != NULL; i = i->next) {
i->data->status_id = ID_STATUS_OFFLINE;
}
const Array& mobileFriends = objRoot["payload"]["buddy_list"]["mobile_friends"];
// Find mobile friends
- for ( Array::const_iterator buddy( mobileFriends.Begin()); buddy != mobileFriends.End(); ++buddy) {
+ for (Array::const_iterator buddy(mobileFriends.Begin()); buddy != mobileFriends.End(); ++buddy) {
const Number& member = *buddy;
char was_id[32];
- lltoa( member.Value(), was_id, 10 );
+ lltoa(member.Value(), was_id, 10);
std::string id = was_id;
if (!id.empty()) {
- current = buddy_list->find( id );
+ current = buddy_list->find(id);
- if ( current == NULL) {
- buddy_list->insert( std::make_pair( id, new facebook_user( )) );
- current = buddy_list->find( id );
+ if (current == NULL) {
+ buddy_list->insert(std::make_pair(id, new facebook_user()));
+ current = buddy_list->find(id);
current->user_id = id;
}
@@ -87,12 +87,12 @@ int facebook_json_parser::parse_buddy_list( void* data, List::List< facebook_use
const Object& objMember = member.element;
const Boolean idle = objMember["i"]; // In new version of Facebook "i" means "offline"
- current = buddy_list->find( member.name );
- if ( current == NULL) {
+ current = buddy_list->find(member.name);
+ if (current == NULL) {
if (idle) continue; // Just little optimalization
- buddy_list->insert( std::make_pair( member.name, new facebook_user( )) );
- current = buddy_list->find( member.name );
+ buddy_list->insert(std::make_pair(member.name, new facebook_user()));
+ current = buddy_list->find(member.name);
current->user_id = current->real_name = member.name;
}
@@ -106,8 +106,8 @@ int facebook_json_parser::parse_buddy_list( void* data, List::List< facebook_use
{
const Object::Member& member = *itUserInfo;
- current = buddy_list->find( member.name );
- if ( current == NULL )
+ current = buddy_list->find(member.name);
+ if (current == NULL)
continue;
const Object& objMember = member.element;
@@ -115,43 +115,43 @@ int facebook_json_parser::parse_buddy_list( void* data, List::List< facebook_use
const String& imageUrl = objMember["thumbSrc"];
current->real_name = utils::text::slashu_to_utf8(
- utils::text::special_expressions_decode( realName.Value( )) );
+ utils::text::special_expressions_decode(realName.Value()));
current->image_url = utils::text::slashu_to_utf8(
- utils::text::special_expressions_decode( imageUrl.Value( )) );
+ utils::text::special_expressions_decode(imageUrl.Value()));
}
}
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 );
+ 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());
+ proto->Log("!!!!! Caught json::Exception: %s", e.what());
}
catch (const std::exception& e)
{
- proto->Log( "!!!!! Caught std::exception: %s", e.what());
+ 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 )
+int facebook_json_parser::parse_friends(void* data, std::map< std::string, facebook_user* >* friends)
{
using namespace json;
try
{
- std::string buddyData = static_cast< std::string* >( data )->substr( 9 );
- std::istringstream sDocument( buddyData );
+ std::string buddyData = static_cast< std::string* >(data)->substr(9);
+ std::istringstream sDocument(buddyData);
Object objDocument;
Reader::Read(objDocument, sDocument);
const Object& objRoot = objDocument;
const Object& payload = objRoot["payload"];
- for ( Object::const_iterator payload_item( payload.Begin()); payload_item != payload.End(); ++payload_item)
+ for (Object::const_iterator payload_item(payload.Begin()); payload_item != payload.End(); ++payload_item)
{
const Object::Member& member = *payload_item;
@@ -166,9 +166,9 @@ int facebook_json_parser::parse_friends( void* data, std::map< std::string, face
fbu->user_id = member.name;
fbu->real_name = utils::text::slashu_to_utf8(
- utils::text::special_expressions_decode( realName.Value()) );
+ utils::text::special_expressions_decode(realName.Value()));
fbu->image_url = utils::text::slashu_to_utf8(
- utils::text::special_expressions_decode( imageUrl.Value()) );
+ utils::text::special_expressions_decode(imageUrl.Value()));
if (gender.Value() == 1) {
fbu->gender = 70; // female
@@ -176,42 +176,42 @@ int facebook_json_parser::parse_friends( void* data, std::map< std::string, face
fbu->gender = 77; // male
}
- friends->insert( std::make_pair( member.name, fbu ));
+ friends->insert(std::make_pair(member.name, fbu));
}
}
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 );
+ 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());
+ proto->Log("!!!!! Caught json::Exception: %s", e.what());
}
catch (const std::exception& e)
{
- proto->Log( "!!!!! Caught std::exception: %s", e.what());
+ proto->Log("!!!!! Caught std::exception: %s", e.what());
}
return EXIT_SUCCESS;
}
-int facebook_json_parser::parse_notifications( void *data, std::vector< facebook_notification* > *notifications )
+int facebook_json_parser::parse_notifications(void *data, std::vector< facebook_notification* > *notifications)
{
using namespace json;
try
{
- std::string notificationsData = static_cast< std::string* >( data )->substr( 9 );
- std::istringstream sDocument( notificationsData );
+ std::string notificationsData = static_cast< std::string* >(data)->substr(9);
+ std::istringstream sDocument(notificationsData);
Object objDocument;
Reader::Read(objDocument, sDocument);
const Object& objRoot = objDocument;
const Object& payload = objRoot["payload"]["notifications"];
- for ( Object::const_iterator payload_item( payload.Begin()); payload_item != payload.End(); ++payload_item)
+ for (Object::const_iterator payload_item(payload.Begin()); payload_item != payload.End(); ++payload_item)
{
const Object::Member& member = *payload_item;
@@ -224,42 +224,42 @@ int facebook_json_parser::parse_notifications( void *data, std::vector< facebook
continue;
std::string text = utils::text::slashu_to_utf8(
- utils::text::special_expressions_decode( content.Value()) );
+ utils::text::special_expressions_decode(content.Value()));
- facebook_notification* notification = new facebook_notification( );
+ facebook_notification* notification = new facebook_notification();
- notification->text = utils::text::remove_html( utils::text::source_get_value(&text, 1, "<abbr"));
+ notification->text = utils::text::remove_html(utils::text::source_get_value(&text, 1, "<abbr"));
notification->link = utils::text::source_get_value(&text, 3, "<a ", "href=\"", "\"");
- notifications->push_back( notification );
+ notifications->push_back(notification);
}
}
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 );
+ 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());
+ proto->Log("!!!!! Caught json::Exception: %s", e.what());
}
catch (const std::exception& e)
{
- proto->Log( "!!!!! Caught std::exception: %s", e.what());
+ proto->Log("!!!!! Caught std::exception: %s", e.what());
}
return EXIT_SUCCESS;
}
-int facebook_json_parser::parse_messages( void* data, std::vector< facebook_message* >* messages, std::vector< facebook_notification* >* notifications )
+int facebook_json_parser::parse_messages(void* data, std::vector< facebook_message* >* messages, std::vector< facebook_notification* >* notifications)
{
using namespace json;
try
{
- std::string messageData = static_cast< std::string* >( data )->substr( 9 );
- std::istringstream sDocument( messageData );
+ std::string messageData = static_cast< std::string* >(data)->substr(9);
+ std::istringstream sDocument(messageData);
Object objDocument;
Reader::Read(objDocument, sDocument);
@@ -274,11 +274,11 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess
const String& type = objMember["type"];
- if ( type.Value( ) == "msg" || type.Value() == "offline_msg" ) // direct message
+ if (type.Value() == "msg" || type.Value() == "offline_msg") // direct message
{
const Number& from = objMember["from"];
char was_id[32];
- lltoa( from.Value(), was_id, 10 );
+ lltoa(from.Value(), was_id, 10);
const Object& messageContent = objMember["msg"];
const String& text = messageContent["text"];
@@ -295,20 +295,20 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess
proto->Log(msg.c_str());
} else if (last_msg != text.Value()) {
last_msg = text.Value();
- facebook_message* message = new facebook_message( );
+ facebook_message* message = new facebook_message();
message->message_text = utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8( text.Value( )) );
- message->time = utils::time::fix_timestamp( time_sent.Value());
+ utils::text::slashu_to_utf8(text.Value()));
+ message->time = utils::time::fix_timestamp(time_sent.Value());
message->user_id = was_id;
- messages->push_back( message );
+ messages->push_back(message);
} else {
std::string msg = "????? Got duplicit message?\n";
msg += utils::text::special_expressions_decode(utils::text::slashu_to_utf8(text.Value()));
proto->Log(msg.c_str());
}
}
- else if ( type.Value( ) == "messaging" ) // inbox message (multiuser or direct)
+ else if (type.Value() == "messaging") // inbox message (multiuser or direct)
{
const String& type = objMember["event"];
@@ -317,7 +317,7 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess
const Number& from = messageContent["sender_fbid"];
char was_id[32];
- lltoa( from.Value(), was_id, 10 );
+ lltoa(from.Value(), was_id, 10);
// Ignore if message is from self user
@@ -338,21 +338,21 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess
if (last_msg != text.Value()) {
last_msg = text.Value();
- facebook_message* message = new facebook_message( );
+ facebook_message* message = new facebook_message();
message->message_text = utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8( text.Value( )) );
+ utils::text::slashu_to_utf8(text.Value()));
message->sender_name = utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8( sender_name.Value( )) );
+ utils::text::slashu_to_utf8(sender_name.Value()));
- message->time = utils::time::fix_timestamp( time_sent.Value());
+ message->time = utils::time::fix_timestamp(time_sent.Value());
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) {
// This is multiuser message
std::string authors = utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8( row ));
+ utils::text::slashu_to_utf8(row));
authors = utils::text::source_get_value(&authors, 2, "<strong class=\"authors\">", "<");
const String& to_id = messageContent["tid"];
@@ -378,7 +378,7 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess
mir_free(szText);
} else {
- messages->push_back( message );
+ messages->push_back(message);
}
} else {
std::string msg = "????? Got duplicit inbox message?\n";
@@ -387,7 +387,7 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess
}
}
}
- else if ( type.Value( ) == "thread_msg" ) // multiuser message
+ else if (type.Value() == "thread_msg") // multiuser message
{
const String& from_name = objMember["from_name"];
const String& to_name = objMember["to_name"]["__html"];
@@ -395,7 +395,7 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess
const Number& from = objMember["from"];
char was_id[32];
- lltoa( from.Value(), was_id, 10 );
+ lltoa(from.Value(), was_id, 10);
// Ignore if message is from self user
if (was_id == proto->facy.self_.user_id)
@@ -409,15 +409,15 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess
std::string popup_text = utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8( from_name.Value( )) );
+ utils::text::slashu_to_utf8(from_name.Value()));
popup_text += ": ";
popup_text += utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8( text.Value( )) );
+ utils::text::slashu_to_utf8(text.Value()));
std::string title = Translate("Multichat");
title += ": ";
title += utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8( to_name.Value( )) );
+ utils::text::slashu_to_utf8(to_name.Value()));
std::string url = "/?action=read&sk=inbox&page&query&tid=";
url += to_id.Value();
@@ -431,7 +431,7 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess
mir_free(szTitle);
mir_free(szText);
}
- else if ( type.Value() == "notification_json" ) // event notification
+ else if (type.Value() == "notification_json") // event notification
{
if (!db_get_b(NULL, proto->m_szModuleName, FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE, DEFAULT_EVENT_NOTIFICATIONS_ENABLE))
continue;
@@ -459,18 +459,18 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess
}
}
}
- else if ( type.Value( ) == "typ" ) // chat typing notification
+ else if (type.Value() == "typ") // chat typing notification
{
const Number& from = objMember["from"];
char user_id[32];
- lltoa( from.Value(), user_id, 10 );
+ lltoa(from.Value(), user_id, 10);
facebook_user fbu;
fbu.user_id = user_id;
HANDLE hContact = proto->AddToContactList(&fbu, FACEBOOK_CONTACT_FRIEND);
- if ( db_get_w(hContact,proto->m_szModuleName,"Status", 0) == ID_STATUS_OFFLINE )
+ if (db_get_w(hContact,proto->m_szModuleName,"Status", 0) == ID_STATUS_OFFLINE)
db_set_w(hContact,proto->m_szModuleName,"Status",ID_STATUS_ONLINE);
const Number& state = objMember["st"];
@@ -479,16 +479,16 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess
else
CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
}
- else if ( type.Value( ) == "privacy_changed")
+ else if (type.Value() == "privacy_changed")
{
const String& event_type = objMember["event"];
const Object& event_data = objMember["data"];
- if ( event_type.Value( ) == "visibility_update" )
+ if (event_type.Value() == "visibility_update")
{ // change of chat status
const Boolean visibility = event_data["visibility"];
proto->Log(" Requested chat switch to %s", visibility ? "Online" : "Offline");
- proto->SetStatus( visibility ? ID_STATUS_ONLINE : ID_STATUS_INVISIBLE );
+ proto->SetStatus(visibility ? ID_STATUS_ONLINE : ID_STATUS_INVISIBLE);
}
}
else
@@ -497,12 +497,12 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess
}
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 );
+ 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());
+ proto->Log ("!!!!! Caught json::Exception: %s", e.what());
}
return EXIT_SUCCESS;