summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/FacebookRM/src/contacts.cpp18
-rw-r--r--protocols/FacebookRM/src/process.cpp34
2 files changed, 12 insertions, 40 deletions
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index 8f4bf3489b..3433941bca 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -177,9 +177,7 @@ std::string FacebookProto::ThreadIDToContactID(const std::string &thread_id)
if (resp.code == HTTP_CODE_OK) {
try {
- facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_thread_info(&resp.data, &user_id);
- delete p;
+ facebook_json_parser(this).parse_thread_info(&resp.data, &user_id);
if (!user_id.empty())
facy.thread_id_to_user_id.insert(std::make_pair(thread_id, user_id));
@@ -210,10 +208,7 @@ void FacebookProto::LoadContactInfo(facebook_user* fbu)
if (resp.code == HTTP_CODE_OK) {
try {
- facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_user_info(&resp.data, fbu);
- delete p;
-
+ facebook_json_parser(this).parse_user_info(&resp.data, fbu);
debugLogA("*** Contact thread info processed");
}
catch (const std::exception &e) {
@@ -281,10 +276,7 @@ void FacebookProto::LoadParticipantsNames(facebook_chatroom *fbc)
if (resp.code == HTTP_CODE_OK) {
try {
// TODO: We can cache these results and next time (e.g. for different chatroom) we can use that already cached names
- facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_chat_participant_names(&resp.data, &fbc->participants);
- delete p;
-
+ facebook_json_parser(this).parse_chat_participant_names(&resp.data, &fbc->participants);
debugLogA("*** Participant names processed");
}
catch (const std::exception &e) {
@@ -323,9 +315,7 @@ void FacebookProto::LoadChatInfo(facebook_chatroom *fbc)
}
try {
- facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_chat_info(&resp.data, fbc);
- delete p;
+ facebook_json_parser(this).parse_chat_info(&resp.data, fbc);
// Load missing participants names
LoadParticipantsNames(fbc);
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index 4bc3867d0b..9a9746b1c7 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -62,9 +62,7 @@ void FacebookProto::ProcessFriendList(void*)
bool loadAllContacts = getBool(FACEBOOK_KEY_LOAD_ALL_CONTACTS, DEFAULT_LOAD_ALL_CONTACTS);
bool pagesAlwaysOnline = getBool(FACEBOOK_KEY_PAGES_ALWAYS_ONLINE, DEFAULT_PAGES_ALWAYS_ONLINE);
- facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_friends(&resp.data, &friends, loadAllContacts);
- delete p;
+ facebook_json_parser(this).parse_friends(&resp.data, &friends, loadAllContacts);
// Check and update old contacts
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
@@ -195,10 +193,7 @@ void FacebookProto::ProcessUnreadMessages(void*)
try {
std::vector<std::string> threads;
-
- facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_unread_threads(&resp.data, &threads);
- delete p;
+ facebook_json_parser(this).parse_unread_threads(&resp.data, &threads);
ForkThread(&FacebookProto::ProcessUnreadMessage, new std::vector<std::string>(threads));
@@ -248,13 +243,9 @@ void FacebookProto::ProcessUnreadMessage(void *pParam)
if (resp.code == HTTP_CODE_OK) {
try {
std::vector<facebook_message> messages;
-
- facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_thread_messages(&resp.data, &messages, false);
- delete p;
+ facebook_json_parser(this).parse_thread_messages(&resp.data, &messages, false);
ReceiveMessages(messages, true);
-
debugLogA("*** Unread messages processed");
}
catch (const std::exception &e) {
@@ -317,13 +308,9 @@ void FacebookProto::LoadLastMessages(void *pParam)
try {
std::vector<facebook_message> messages;
-
- facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_thread_messages(&resp.data, &messages, false);
- delete p;
+ facebook_json_parser(this).parse_thread_messages(&resp.data, &messages, false);
ReceiveMessages(messages, true);
-
debugLogA("*** Thread messages processed");
}
catch (const std::exception &e) {
@@ -684,7 +671,7 @@ void FacebookProto::ProcessMemories(void *p)
facy.info_notify(TranslateT("Loading memories..."));
}
- int numMemories = 0;
+ size_t numMemories = 0;
facy.handle_entry(__FUNCTION__);
@@ -985,10 +972,7 @@ void FacebookProto::ProcessMessages(void* data)
try {
std::vector<facebook_message> messages;
-
- facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_messages(resp, &messages, &facy.notifications);
- delete p;
+ facebook_json_parser(this).parse_messages(resp, &messages, &facy.notifications);
ReceiveMessages(messages);
@@ -1045,11 +1029,9 @@ void FacebookProto::ProcessNotifications(void *p)
debugLogA("*** Starting processing notifications");
try {
- int numNotifications = facy.notifications.size();
+ size_t numNotifications = facy.notifications.size();
- facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_notifications(&(resp.data), &facy.notifications);
- delete p;
+ facebook_json_parser(this).parse_notifications(&resp.data, &facy.notifications);
if (manuallyTriggered) {
numNotifications = facy.notifications.size() - numNotifications;