summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2013-05-16 14:55:16 +0000
committerRobert Pösel <robyer@seznam.cz>2013-05-16 14:55:16 +0000
commiteec9743cc90715180fec9b184ae343dc5083e780 (patch)
treeac804835491fdd565596864347afe9255b8a97ee
parent016efa8dd058f9af5a57a33a6541736ce710a5a7 (diff)
Facebook:
- fixed getting login error message - cleanup of close_chat method and related things - added Poke support (contact menu) - support for sending "Seen" info (add in db "MarkRead" (byte) with value "1") - support for language specific fb errors (add in db "Locale" (string) with locale value ("en_US", "cs_CZ" etc.) - mir_a2t_cp(..., CP_UTF8) changed to mir_utf8decodeT(...) git-svn-id: http://svn.miranda-ng.org/main/trunk@4677 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/FacebookRM/facebook_10.vcxproj2
-rw-r--r--protocols/FacebookRM/facebook_10.vcxproj.filters6
-rw-r--r--protocols/FacebookRM/res/facebook.rc5
-rw-r--r--protocols/FacebookRM/src/chat.cpp4
-rw-r--r--protocols/FacebookRM/src/client.h3
-rw-r--r--protocols/FacebookRM/src/communication.cpp74
-rw-r--r--protocols/FacebookRM/src/constants.h6
-rw-r--r--protocols/FacebookRM/src/contacts.cpp36
-rw-r--r--protocols/FacebookRM/src/db.h5
-rw-r--r--protocols/FacebookRM/src/entities.h4
-rw-r--r--protocols/FacebookRM/src/json.cpp15
-rw-r--r--protocols/FacebookRM/src/messages.cpp41
-rw-r--r--protocols/FacebookRM/src/process.cpp41
-rw-r--r--protocols/FacebookRM/src/proto.cpp15
-rw-r--r--protocols/FacebookRM/src/proto.h4
-rw-r--r--protocols/FacebookRM/src/resource.h6
-rw-r--r--protocols/FacebookRM/src/theme.cpp23
-rw-r--r--protocols/FacebookRM/src/theme.h3
18 files changed, 179 insertions, 114 deletions
diff --git a/protocols/FacebookRM/facebook_10.vcxproj b/protocols/FacebookRM/facebook_10.vcxproj
index 042a5b54da..4bb69be9b0 100644
--- a/protocols/FacebookRM/facebook_10.vcxproj
+++ b/protocols/FacebookRM/facebook_10.vcxproj
@@ -222,6 +222,8 @@
<None Include="res\auth_revoke.ico" />
<None Include="res\facebook.ico" />
<None Include="res\mind.ico" />
+ <None Include="res\notification.ico" />
+ <None Include="res\poke.ico" />
<None Include="src\JSON_CAJUN\elements.inl" />
<None Include="src\JSON_CAJUN\reader.inl" />
<None Include="src\JSON_CAJUN\writer.inl" />
diff --git a/protocols/FacebookRM/facebook_10.vcxproj.filters b/protocols/FacebookRM/facebook_10.vcxproj.filters
index 326a245303..ceabb2ebb4 100644
--- a/protocols/FacebookRM/facebook_10.vcxproj.filters
+++ b/protocols/FacebookRM/facebook_10.vcxproj.filters
@@ -157,6 +157,12 @@
<None Include="res\auth_revoke.ico">
<Filter>Resource Files</Filter>
</None>
+ <None Include="res\poke.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="res\notification.ico">
+ <Filter>Resource Files</Filter>
+ </None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\facebook.rc">
diff --git a/protocols/FacebookRM/res/facebook.rc b/protocols/FacebookRM/res/facebook.rc
index 5570e9482b..12ceaf1738 100644
--- a/protocols/FacebookRM/res/facebook.rc
+++ b/protocols/FacebookRM/res/facebook.rc
@@ -56,6 +56,8 @@ IDI_MIND ICON "mind.ico"
IDI_AUTH_GRANT ICON "auth_grant.ico"
IDI_AUTH_ASK ICON "auth_ask.ico"
IDI_AUTH_REVOKE ICON "auth_revoke.ico"
+IDI_POKE ICON "poke.ico"
+IDI_NOTIFICATION ICON "notification.ico"
/////////////////////////////////////////////////////////////////////////////
//
@@ -259,8 +261,7 @@ END
//
// Generated from the TEXTINCLUDE 3 resource.
//
-
-
+
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp
index 5bfb562713..01279a9df9 100644
--- a/protocols/FacebookRM/src/chat.cpp
+++ b/protocols/FacebookRM/src/chat.cpp
@@ -45,10 +45,6 @@ void FacebookProto::UpdateChat(const char *chat_id, const char *id, const char *
mir_free(const_cast<TCHAR*>(gce.ptszNick));
mir_free(const_cast<TCHAR*>(gce.ptszText));
mir_free(const_cast<TCHAR*>(gcd.ptszID));
-
-
- // Close chat window, if set
- ForkThread(&FacebookProto::MessagingWorker, this, new send_messaging(chat_id, FACEBOOK_SEND_MESSAGE));
}
int FacebookProto::OnChatOutgoing(WPARAM wParam,LPARAM lParam)
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h
index 62a9a7f2c0..214e5a81ce 100644
--- a/protocols/FacebookRM/src/client.h
+++ b/protocols/FacebookRM/src/client.h
@@ -149,9 +149,6 @@ public:
bool channel();
bool send_message(std::string message_recipient, std::string message_text, std::string *error_text, int method);
- void close_chat(std::string message_recipient);
- void chat_mark_read(std::string message_recipient);
-
////////////////////////////////////////////////////////////
// Status handling
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 48fc76e741..e86519a85f 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -243,8 +243,9 @@ DWORD facebook_client::choose_security_level(int request_type)
// case FACEBOOK_REQUEST_THREAD_INFO:
// case FACEBOOK_REQUEST_MESSAGES_RECEIVE:
// case FACEBOOK_REQUEST_VISIBILITY:
-// case FACEBOOK_REQUEST_TABS:
+// case FACEBOOK_REQUEST_POKE:
// case FACEBOOK_REQUEST_ASYNC:
+// case FACEBOOK_REQUEST_MARK_READ:
// case FACEBOOK_REQUEST_UNREAD_MESSAGES:
// case FACEBOOK_REQUEST_TYPING_SEND:
default:
@@ -264,8 +265,9 @@ int facebook_client::choose_method(int request_type)
case FACEBOOK_REQUEST_MESSAGE_SEND2:
case FACEBOOK_REQUEST_THREAD_INFO:
case FACEBOOK_REQUEST_VISIBILITY:
- case FACEBOOK_REQUEST_TABS:
+ case FACEBOOK_REQUEST_POKE:
case FACEBOOK_REQUEST_ASYNC:
+ case FACEBOOK_REQUEST_MARK_READ:
case FACEBOOK_REQUEST_TYPING_SEND:
case FACEBOOK_REQUEST_LOGOUT:
case FACEBOOK_REQUEST_DELETE_FRIEND:
@@ -331,8 +333,9 @@ std::string facebook_client::choose_server(int request_type, std::string* data,
// case FACEBOOK_REQUEST_MESSAGE_SEND2:
// case FACEBOOK_REQUEST_THREAD_INFO:
// case FACEBOOK_REQUEST_VISIBILITY:
-// case FACEBOOK_REQUEST_TABS:
+// case FACEBOOK_REQUEST_POKE:
// case FACEBOOK_REQUEST_ASYNC:
+// case FACEBOOK_REQUEST_MARK_READ:
// case FACEBOOK_REQUEST_TYPING_SEND:
// case FACEBOOK_REQUEST_SETUP_MACHINE:
// case FACEBOOK_REQUEST_DELETE_FRIEND:
@@ -478,8 +481,8 @@ std::string facebook_client::choose_action(int request_type, std::string* data,
case FACEBOOK_REQUEST_VISIBILITY:
return "/ajax/chat/privacy/visibility.php?__a=1";
- case FACEBOOK_REQUEST_TABS:
- return "/ajax/chat/tabs.php?__a=1";
+ case FACEBOOK_REQUEST_POKE:
+ return "/ajax/poke_dialog.php?__a=1";
case FACEBOOK_REQUEST_ASYNC:
{
@@ -490,6 +493,9 @@ std::string facebook_client::choose_action(int request_type, std::string* data,
return action;
}
+ case FACEBOOK_REQUEST_MARK_READ:
+ return "/ajax/mercury/change_read_status.php?__a=1";
+
case FACEBOOK_REQUEST_TYPING_SEND:
return "/ajax/messaging/typ.php?__a=1";
@@ -608,9 +614,13 @@ bool facebook_client::login(const std::string &username,const std::string &passw
flap(FACEBOOK_REQUEST_HOME, NULL);
// Prepare login data
- std::string data = "charset_test=%e2%82%ac%2c%c2%b4%2c%e2%82%ac%2c%c2%b4%2c%e6%b0%b4%2c%d0%94%2c%d0%84&locale=en&pass_placeHolder=Password&login=Login&persistent=1";
+ std::string data = "charset_test=%e2%82%ac%2c%c2%b4%2c%e2%82%ac%2c%c2%b4%2c%e6%b0%b4%2c%d0%94%2c%d0%84&pass_placeHolder=Password&login=Login&persistent=1";
data += "&email=" + utils::url::encode(username);
- data += "&pass=" + utils::url::encode(password);
+ data += "&pass=" + utils::url::encode(password);
+
+ mir_ptr<char> locale = db_get_sa(NULL, parent->m_szModuleName, FACEBOOK_KEY_LOCALE);
+ if (locale != NULL)
+ data += "&locale=" + std::string(locale);
// Send validation
http::response resp = flap(FACEBOOK_REQUEST_LOGIN, &data);
@@ -707,16 +717,14 @@ bool facebook_client::login(const std::string &username,const std::string &passw
utils::text::special_expressions_decode(
utils::text::remove_html(
utils::text::edit_html(
- utils::text::source_get_value(&resp.data, 3, "login_error_box", "<p>", "</p>")))));
-
- if (!error_str.length())
- error_str = Translate("Unknown login error");
- parent->Log(" ! ! Login error: %s", error_str.c_str());
-
- std::string message = Translate("Login error: ") + error_str;
- TCHAR* tmessage = mir_a2t(message.c_str());
- client_notify(tmessage);
- mir_free(tmessage);
+ utils::text::source_get_value(&resp.data, 4, "login_error_box", "<div", ">", "</div>")))));
+
+ parent->Log(" ! ! Login error: %s", error_str.length() ? error_str.c_str() : "Unknown error");
+
+ TCHAR buf[200];
+ mir_sntprintf(buf, SIZEOF(buf), TranslateT("Login error: %s"),
+ (!error_str.length()) ? TranslateT("Unknown error") : mir_ptr<TCHAR>(mir_utf8decodeT(error_str.c_str())));
+ client_notify(buf);
}
case HTTP_CODE_FORBIDDEN: // Forbidden
case HTTP_CODE_NOT_FOUND: // Not Found
@@ -1165,38 +1173,6 @@ bool facebook_client::send_message(std::string message_recipient, std::string me
}
}
-void facebook_client::close_chat(std::string message_recipient)
-{
- // TODO RM: better optimalization for close_chat
- // add items to list and then checking every x seconds
-/* if ((::time(NULL) - parent->facy.last_close_chat_time_) < 8)
- return;*/
- // parent->facy.last_close_chat_time_ = ::time(NULL);
-
- /* Wait some time before close window, because sometimes facebook
- can't close it so soon. But maybe this didnt help also. */
- Sleep(300);
-
- std::string data = "close_chat=" + message_recipient;
- data += "&window_id=0";
- data += "&fb_dtsg=" + (this->dtsg_.length() ? this->dtsg_ : "0");
- data += "&__user=" + self_.user_id;
-
- http::response resp = flap(FACEBOOK_REQUEST_TABS, &data);
-}
-
-void facebook_client::chat_mark_read(std::string message_recipient)
-{
- // TODO RM: optimalization?
-
- std::string data = "action=chatMarkRead";
- data += "&other_user=" + message_recipient;
- data += "&fb_dtsg=" + (this->dtsg_.length() ? this->dtsg_ : "0");
- data += "&lsd=&__user=" + self_.user_id;
-
- http::response resp = flap(FACEBOOK_REQUEST_ASYNC, &data);
-}
-
bool facebook_client::set_status(const std::string &status_text)
{
handle_entry("set_status");
diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h
index f70ba28f40..647576a4a9 100644
--- a/protocols/FacebookRM/src/constants.h
+++ b/protocols/FacebookRM/src/constants.h
@@ -103,12 +103,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FACEBOOK_REQUEST_MESSAGES_RECEIVE 302 // receiving messages
#define FACEBOOK_REQUEST_TYPING_SEND 304 // sending typing notification
#define FACEBOOK_REQUEST_VISIBILITY 305 // setting chat visibility
-#define FACEBOOK_REQUEST_TABS 306 // closing message window
#define FACEBOOK_REQUEST_ASYNC 307 // marking messages read and getting other things
+#define FACEBOOK_REQUEST_MARK_READ 308 // marking messages read (new)
#define FACEBOOK_REQUEST_THREAD_INFO 310 // getting thread info
-
-#define FACEBOOK_RECV_MESSAGE 1
-#define FACEBOOK_SEND_MESSAGE 2
+#define FACEBOOK_REQUEST_POKE 311 // sending pokes
// Send message types
#define MESSAGE_INBOX 0
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index 0fd4a2b1e9..d1eaad91cd 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -321,6 +321,42 @@ void FacebookProto::CancelFriendsRequest(void *data)
facy.handle_error("CancelFriendsRequest");
}
+void FacebookProto::SendPokeWorker(void *p)
+{
+ facy.handle_entry("SendPokeWorker");
+
+ if (p == NULL)
+ return;
+
+ std::string id = (*(std::string*)p);
+ delete p;
+
+ std::string data = "uid=" + id;
+ data += "&phstamp=0&pokeback=0&ask_for_confirm=0";
+ data += "&fb_dtsg=" + facy.dtsg_;
+ data += "&__user=" + facy.self_.user_id;
+
+ // Send poke
+ http::response resp = facy.flap(FACEBOOK_REQUEST_POKE, &data);
+
+ // Process result data
+ facy.validate_response(&resp);
+
+ if (resp.data.find("\"payload\":null", 0) != std::string::npos) {
+
+ std::string message = utils::text::special_expressions_decode(
+ utils::text::remove_html(
+ utils::text::slashu_to_utf8(
+ utils::text::source_get_value(&resp.data, 3, "\"body\":", "__html\":\"", "\"}"))));
+
+ TCHAR* tmessage = mir_utf8decodeT(message.c_str());
+ NotifyEvent(m_tszUserName, tmessage, NULL, FACEBOOK_EVENT_OTHER, NULL);
+ mir_free(tmessage);
+ }
+
+ facy.handle_success("SendPokeWorker");
+}
+
HANDLE FacebookProto::GetAwayMsg(HANDLE hContact)
{
diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h
index 373bf8163a..f8d0e857ac 100644
--- a/protocols/FacebookRM/src/db.h
+++ b/protocols/FacebookRM/src/db.h
@@ -61,12 +61,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FACEBOOK_KEY_MAP_STATUSES "MapStatuses"
#define FACEBOOK_KEY_LOAD_MOBILE "LoadMobile"
#define FACEBOOK_KEY_CUSTOM_SMILEYS "CustomSmileys"
+#define FACEBOOK_KEY_MESSAGE_ID "LastMessageId"
#define FACEBOOK_KEY_POLL_RATE "PollRate" // [HIDDEN]
#define FACEBOOK_KEY_TIMEOUTS_LIMIT "TimeoutsLimit" // [HIDDEN]
#define FACEBOOK_KEY_DISABLE_LOGOUT "DisableLogout" // [HIDDEN]
#define FACEBOOK_KEY_VALIDATE_RESPONSE "ValidateResponse" // [HIDDEN] - 0 = standard, 1 = always, 2 = never
-#define FACEBOOK_KEY_LOCAL_TIMESTAMP "UseLocalTimestamp" // [HIDDEN]
+#define FACEBOOK_KEY_LOCAL_TIMESTAMP "UseLocalTimestamp" // [HIDDEN] - 0 = use facebook timestamps for messages, 1 = use local timestamps
+#define FACEBOOK_KEY_MARK_READ "MarkRead" // [HIDDEN] - 0 = marking messages as read without "Seen" info, 1 = with "Seen" info
+#define FACEBOOK_KEY_LOCALE "Locale" // [HIDDEN] - en_US, cs_CZ, etc.
#define FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE "EventNotificationsEnable"
#define FACEBOOK_KEY_EVENT_FEEDS_ENABLE "EventFeedsEnable"
diff --git a/protocols/FacebookRM/src/entities.h b/protocols/FacebookRM/src/entities.h
index a5e85d23a6..76fe5cf965 100644
--- a/protocols/FacebookRM/src/entities.h
+++ b/protocols/FacebookRM/src/entities.h
@@ -64,11 +64,12 @@ struct facebook_message
std::string user_id;
std::string message_text;
std::string sender_name;
+ std::string message_id;
DWORD time;
facebook_message()
{
- this->user_id = this->message_text = this->sender_name = "";
+ this->user_id = this->message_text = this->sender_name = this->message_id = "";
this->time = 0;
}
@@ -77,6 +78,7 @@ struct facebook_message
this->user_id = msg.user_id;
this->message_text = msg.message_text;
this->sender_name = msg.sender_name;
+ this->message_id = msg.message_id;
this->time = msg.time;
}
};
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 34660bc1d6..b07f6244b2 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -303,6 +303,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
const Object& messageContent = objMember["msg"];
const String& text = messageContent["text"];
+ const String& message_id = messageContent["messageId"];
//"tab_type":"friend", objMember["tab_type"]
const Number& time_sent = messageContent["time"];
@@ -317,10 +318,10 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
} else if (last_msg != text.Value()) {
last_msg = text.Value();
facebook_message* message = new facebook_message();
- message->message_text = utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8(text.Value()));
+ message->message_text = utils::text::special_expressions_decode(utils::text::slashu_to_utf8(text.Value()));
message->time = utils::time::fix_timestamp(time_sent.Value());
message->user_id = was_id;
+ message->message_id = message_id;
messages->push_back(message);
} else {
@@ -359,6 +360,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
const String& sender_name = messageContent["sender_name"];
const String& text = messageContent["body"];
const String& tid = messageContent["tid"];
+ const String& mid = messageContent["mid"];
const Number& time_sent = messageContent["timestamp"];
char was_id[32];
@@ -384,7 +386,8 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
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 otherwise do something different?
-
+ message->message_id = mid.Value();
+
messages->push_back(message);
} else {
std::string msg = "????? Got duplicit inbox message?\n";
@@ -430,9 +433,9 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
proto->Log(" Got multichat message");
- TCHAR* szTitle = mir_a2t_cp(title.c_str(), CP_UTF8);
- TCHAR* szText = mir_a2t_cp(popup_text.c_str(), CP_UTF8);
- TCHAR* szUrl = mir_a2t_cp(url.c_str(), CP_UTF8);
+ TCHAR* szTitle = mir_utf8decodeT(title.c_str());
+ TCHAR* szText = mir_utf8decodeT(popup_text.c_str());
+ TCHAR* szUrl = mir_utf8decodeT(url.c_str());
proto->NotifyEvent(szTitle,szText,NULL,FACEBOOK_EVENT_OTHER, szUrl);
mir_free(szTitle);
mir_free(szText);
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp
index 0ef3bdb325..29fbbcdcca 100644
--- a/protocols/FacebookRM/src/messages.cpp
+++ b/protocols/FacebookRM/src/messages.cpp
@@ -24,14 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
int FacebookProto::RecvMsg(HANDLE hContact, PROTORECVEVENT *pre)
{
- DBVARIANT dbv;
-
- if (!db_get_s(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv))
- {
- ForkThread(&FacebookProto::MessagingWorker, this, new send_messaging(dbv.pszVal, FACEBOOK_RECV_MESSAGE));
- db_free(&dbv);
- }
-
+ ForkThread(&FacebookProto::ReadMessageWorker, this, hContact);
CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
return Proto_RecvMessage(hContact, pre);
@@ -66,7 +59,6 @@ void FacebookProto::SendMsgWorker(void *p)
if (result) {
ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_MESSAGE,ACKRESULT_SUCCESS, data->msgid,0);
CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)data->hContact, NULL);
- MessagingWorker(new send_messaging(dbv.pszVal, FACEBOOK_SEND_MESSAGE));
} else {
char *err = mir_utf8decodeA(error_text.c_str());
ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_MESSAGE,ACKRESULT_FAILED, data->msgid,(LPARAM)err);
@@ -171,17 +163,38 @@ void FacebookProto::SendTypingWorker(void *p)
delete typing;
}
-void FacebookProto::MessagingWorker(void *p)
+void FacebookProto::ReadMessageWorker(void *p)
{
if (p == NULL)
return;
- send_messaging *data = static_cast<send_messaging*>(p);
+ return;
- if (data->type == FACEBOOK_RECV_MESSAGE)
- facy.chat_mark_read(data->user_id);
+ HANDLE hContact = static_cast<HANDLE>(p);
- delete data;
+ if (!db_get_b(NULL, m_szModuleName, FACEBOOK_KEY_MARK_READ, 0)) {
+ // old variant - no seen info updated
+ mir_ptr<char> id = db_get_sa(hContact, m_szModuleName, FACEBOOK_KEY_ID);
+ if (id == NULL) return;
+
+ std::string data = "action=chatMarkRead";
+ data += "&other_user=" + std::string(id);
+ data += "&fb_dtsg=" + (facy.dtsg_.length() ? facy.dtsg_ : "0");
+ data += "&lsd=&__user=" + facy.self_.user_id;
+
+ http::response resp = facy.flap(FACEBOOK_REQUEST_ASYNC, &data);
+ } else {
+ // new variant - with seen info
+ mir_ptr<char> mid = db_get_sa(hContact, m_szModuleName, FACEBOOK_KEY_MESSAGE_ID);
+ if (mid == NULL) return;
+
+ std::string data = "ids[" + std::string(mid) + "]=true";
+ data += "&fb_dtsg=" + (facy.dtsg_.length() ? facy.dtsg_ : "0");
+ data += "&__user=" + facy.self_.user_id;
+ data += "&__a=1&__dyn=&__req=j&phstamp=0";
+
+ http::response resp = facy.flap(FACEBOOK_REQUEST_MARK_READ, &data);
+ }
}
void FacebookProto::parseSmileys(std::string message, HANDLE hContact)
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index da46e3c8f0..321d4a66d2 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -124,8 +124,8 @@ void FacebookProto::ProcessBuddyList(void* data)
std::string url = FACEBOOK_URL_PROFILE + fbu->user_id;
- TCHAR* szTitle = mir_a2t_cp(fbu->real_name.c_str(), CP_UTF8);
- TCHAR* szUrl = mir_a2t_cp(url.c_str(), CP_UTF8);
+ TCHAR* szTitle = mir_utf8decodeT(fbu->real_name.c_str());
+ TCHAR* szUrl = mir_utf8decodeT(url.c_str());
NotifyEvent(szTitle, TranslateT("Contact is back on server-list."), fbu->handle, FACEBOOK_EVENT_OTHER, szUrl);
mir_free(szTitle);
// mir_free(szUrl); // url is free'd in popup procedure
@@ -215,8 +215,8 @@ void FacebookProto::ProcessFriendList(void* data)
std::string url = FACEBOOK_URL_PROFILE + fbu->user_id;
- TCHAR* szTitle = mir_a2t_cp(fbu->real_name.c_str(), CP_UTF8);
- TCHAR* szUrl = mir_a2t_cp(url.c_str(), CP_UTF8);
+ TCHAR* szTitle = mir_utf8decodeT(fbu->real_name.c_str());
+ TCHAR* szUrl = mir_utf8decodeT(url.c_str());
NotifyEvent(szTitle, TranslateT("Contact is back on server-list."), hContact, FACEBOOK_EVENT_OTHER, szUrl);
mir_free(szTitle);
// mir_free(szUrl); // url is free'd in popup procedure
@@ -246,8 +246,8 @@ void FacebookProto::ProcessFriendList(void* data)
std::string url = FACEBOOK_URL_PROFILE + id;
- TCHAR* szTitle = mir_a2t_cp(contactname.c_str(), CP_UTF8);
- TCHAR* szUrl = mir_a2t_cp(url.c_str(), CP_UTF8);
+ TCHAR* szTitle = mir_utf8decodeT(contactname.c_str());
+ TCHAR* szUrl = mir_utf8decodeT(url.c_str());
NotifyEvent(szTitle, TranslateT("Contact is no longer on server-list."), hContact, FACEBOOK_EVENT_OTHER, szUrl);
mir_free(szTitle);
// mir_free(szUrl); // url is free'd in popup procedure
@@ -477,6 +477,7 @@ void FacebookProto::ProcessMessages(void* data)
fbu.user_id = messages[i]->user_id;
HANDLE hContact = AddToContactList(&fbu, FACEBOOK_CONTACT_NONE, false, messages[i]->sender_name.c_str());
+ db_set_s(hContact, m_szModuleName, FACEBOOK_KEY_MESSAGE_ID, messages[i]->message_id.c_str());
// TODO: if contact is newly added, get his user info
// TODO: maybe create new "receiveMsg" function and use it for offline and channel messages?
@@ -496,9 +497,9 @@ void FacebookProto::ProcessMessages(void* data)
for(std::vector<facebook_notification*>::size_type i=0; i<notifications.size(); i++)
{
LOG(" Got notification: %s", notifications[i]->text.c_str());
- TCHAR* szTitle = mir_a2t_cp(this->m_szModuleName, CP_UTF8);
- TCHAR* szText = mir_a2t_cp(notifications[i]->text.c_str(), CP_UTF8);
- TCHAR* szUrl = mir_a2t_cp(notifications[i]->link.c_str(), CP_UTF8);
+ TCHAR* szTitle = mir_utf8decodeT(this->m_szModuleName);
+ TCHAR* szText = mir_utf8decodeT(notifications[i]->text.c_str());
+ TCHAR* szUrl = mir_utf8decodeT(notifications[i]->link.c_str());
NotifyEvent(szTitle, szText, ContactIDToHContact(notifications[i]->user_id), FACEBOOK_EVENT_NOTIFICATION, szUrl);
mir_free(szTitle);
mir_free(szText);
@@ -556,9 +557,9 @@ void FacebookProto::ProcessNotifications(void*)
for(std::vector<facebook_notification*>::size_type i=0; i<notifications.size(); i++)
{
LOG(" Got notification: %s", notifications[i]->text.c_str());
- TCHAR* szTitle = mir_a2t_cp(this->m_szModuleName, CP_UTF8);
- TCHAR* szText = mir_a2t_cp(notifications[i]->text.c_str(), CP_UTF8);
- TCHAR* szUrl = mir_a2t_cp(notifications[i]->link.c_str(), CP_UTF8);
+ TCHAR* szTitle = mir_utf8decodeT(this->m_szModuleName);
+ TCHAR* szText = mir_utf8decodeT(notifications[i]->text.c_str());
+ TCHAR* szUrl = mir_utf8decodeT(notifications[i]->link.c_str());
NotifyEvent(szTitle, szText, ContactIDToHContact(notifications[i]->user_id), FACEBOOK_EVENT_NOTIFICATION, szUrl);
mir_free(szTitle);
mir_free(szText);
@@ -752,9 +753,9 @@ void FacebookProto::ProcessFeeds(void* data)
for(std::vector<facebook_newsfeed*>::size_type i=0; i<news.size(); i++)
{
LOG(" Got newsfeed: %s %s", news[i]->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);
+ TCHAR* szTitle = mir_utf8decodeT(news[i]->title.c_str());
+ TCHAR* szText = mir_utf8decodeT(news[i]->text.c_str());
+ TCHAR* szUrl = mir_utf8decodeT(news[i]->link.c_str());
NotifyEvent(szTitle,szText,this->ContactIDToHContact(news[i]->user_id),FACEBOOK_EVENT_NEWSFEED, szUrl);
mir_free(szTitle);
mir_free(szText);
@@ -832,11 +833,11 @@ void FacebookProto::SearchAckThread(void *targ)
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);
+ TCHAR* tid = mir_utf8decodeT(id.c_str());
+ TCHAR* tname = mir_utf8decodeT(name.c_str());
+ TCHAR* tsurname = mir_utf8decodeT(surname.c_str());
+ TCHAR* tnick = mir_utf8decodeT(nick.c_str());
+ TCHAR* tcommon = mir_utf8decodeT(common.c_str());
PROTOSEARCHRESULT isr = {0};
isr.cbSize = sizeof(isr);
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index 61d07d41b2..59c4261bc9 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -491,6 +491,21 @@ int FacebookProto::VisitFriendship(WPARAM wParam,LPARAM lParam)
return 0;
}
+int FacebookProto::Poke(WPARAM wParam,LPARAM lParam)
+{
+ if (wParam == NULL || isOffline())
+ return 1;
+
+ HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
+
+ mir_ptr<char> id = db_get_sa(hContact, m_szModuleName, FACEBOOK_KEY_ID);
+ if (id == NULL)
+ return 1;
+
+ ForkThread(&FacebookProto::SendPokeWorker, this, new std::string(id));
+ return 0;
+}
+
int FacebookProto::CancelFriendship(WPARAM wParam,LPARAM lParam)
{
if (wParam == NULL || isOffline())
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h
index 3383be21a7..c0cf2fc56b 100644
--- a/protocols/FacebookRM/src/proto.h
+++ b/protocols/FacebookRM/src/proto.h
@@ -107,6 +107,7 @@ public:
int __cdecl GetAvatarCaps(WPARAM, LPARAM);
int __cdecl VisitProfile(WPARAM, LPARAM);
int __cdecl VisitFriendship(WPARAM, LPARAM);
+ int __cdecl Poke(WPARAM, LPARAM);
int __cdecl CancelFriendship(WPARAM, LPARAM);
int __cdecl RequestFriendship(WPARAM, LPARAM);
int __cdecl ApproveFriendship(WPARAM, LPARAM);
@@ -154,11 +155,12 @@ public:
void __cdecl SendMsgWorker(void*);
void __cdecl SendChatMsgWorker(void*);
void __cdecl SendTypingWorker(void*);
- void __cdecl MessagingWorker(void*);
+ void __cdecl ReadMessageWorker(void*);
void __cdecl DeleteContactFromServer(void*);
void __cdecl AddContactToServer(void*);
void __cdecl ApproveContactToServer(void*);
void __cdecl CancelFriendsRequest(void*);
+ void __cdecl SendPokeWorker(void*);
// Contacts handling
bool IsMyContact(HANDLE, bool include_chat = false);
diff --git a/protocols/FacebookRM/src/resource.h b/protocols/FacebookRM/src/resource.h
index 5e1fa69790..a888e45a8d 100644
--- a/protocols/FacebookRM/src/resource.h
+++ b/protocols/FacebookRM/src/resource.h
@@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by Z:\Myranda\trunk\protocols\FacebookRM\res\facebook.rc
+// Used by D:\Development\Miranda NG\protocols\FacebookRM\res\facebook.rc
//
#define IDI_FACEBOOK 101
#define IDI_MIND 102
@@ -12,6 +12,8 @@
#define IDD_OPTIONS 113
#define IDD_OPTIONS_EVENTS 114
#define IDD_OPTIONS_ADVANCED 115
+#define IDI_POKE 127
+#define IDI_NOTIFICATION 128
#define IDC_UN 1001
#define IDC_PW 1002
#define IDC_NEWACCOUNTLINK 1003
@@ -60,7 +62,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 126
+#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1202
#define _APS_NEXT_SYMED_VALUE 131
diff --git a/protocols/FacebookRM/src/theme.cpp b/protocols/FacebookRM/src/theme.cpp
index 31eb90cb70..e514da51b2 100644
--- a/protocols/FacebookRM/src/theme.cpp
+++ b/protocols/FacebookRM/src/theme.cpp
@@ -26,16 +26,18 @@ extern OBJLIST<FacebookProto> g_Instances;
static IconItem icons[] =
{
- { LPGEN("Facebook Icon"), "facebook", IDI_FACEBOOK },
+ { LPGEN("Facebook icon"), "facebook", IDI_FACEBOOK },
{ LPGEN("Mind"), "mind", IDI_MIND },
+ { LPGEN("Poke"), "poke", IDI_POKE },
+ { LPGEN("Notification"), "notification", IDI_NOTIFICATION },
{ LPGEN("Cancel friendship"), "authRevoke", IDI_AUTH_REVOKE },
{ LPGEN("Cancel friendship request"), "authRevokeReq", IDI_AUTH_REVOKE },
{ LPGEN("Request friendship"), "authAsk", IDI_AUTH_ASK },
{ LPGEN("Approve friendship"), "authGrant", IDI_AUTH_GRANT },
- { LPGEN("Visit Profile"), "homepage", 0 },
- { LPGEN("Friendship Details"), "friendship", 0 },
+ { LPGEN("Visit profile"), "homepage", 0 },
+ { LPGEN("Visit friendship details"), "friendship", 0 },
};
// TODO: uninit
@@ -117,27 +119,34 @@ void InitContactMenus()
g_hContactMenuItems[CMI_VISIT_FRIENDSHIP] = Menu_AddContactMenuItem(&mi);
mi.position=-2000006002;
+ mi.icolibItem = GetIconHandle("poke");
+ mi.pszName = GetIconDescription("poke");
+ mi.pszService = "FacebookProto/Poke";
+ CreateServiceFunction(mi.pszService,GlobalService<&FacebookProto::Poke>);
+ g_hContactMenuItems[CMI_POKE] = Menu_AddContactMenuItem(&mi);
+
+ mi.position=-2000006010;
mi.icolibItem = GetIconHandle("authRevoke");
mi.pszName = GetIconDescription("authRevoke");
mi.pszService = "FacebookProto/CancelFriendship";
CreateServiceFunction(mi.pszService,GlobalService<&FacebookProto::CancelFriendship>);
g_hContactMenuItems[CMI_AUTH_REVOKE] = Menu_AddContactMenuItem(&mi);
- mi.position=-2000006003;
+ mi.position=-2000006011;
mi.icolibItem = GetIconHandle("authRevokeReq");
mi.pszName = GetIconDescription("authRevokeReq");
mi.pszService = "FacebookProto/CancelFriendshipRequest";
CreateServiceFunction(mi.pszService,GlobalService<&FacebookProto::OnCancelFriendshipRequest>);
g_hContactMenuItems[CMI_AUTH_CANCEL] = Menu_AddContactMenuItem(&mi);
- mi.position=-2000006004;
+ mi.position=-2000006012;
mi.icolibItem = GetIconHandle("authAsk");
mi.pszName = GetIconDescription("authAsk");
mi.pszService = "FacebookProto/RequestFriendship";
CreateServiceFunction(mi.pszService,GlobalService<&FacebookProto::RequestFriendship>);
g_hContactMenuItems[CMI_AUTH_ASK] = Menu_AddContactMenuItem(&mi);
- mi.position=-2000006005;
+ mi.position=-2000006013;
mi.icolibItem = GetIconHandle("authGrant");
mi.pszName = GetIconDescription("authGrant");
mi.pszService = "FacebookProto/ApproveFriendship";
@@ -168,6 +177,8 @@ int FacebookProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam)
Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_GRANT], ctrlPressed || type == FACEBOOK_CONTACT_APPROVE);
Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_REVOKE], ctrlPressed || type == FACEBOOK_CONTACT_FRIEND);
Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_CANCEL], ctrlPressed || type == FACEBOOK_CONTACT_REQUEST);
+
+ Menu_ShowItem(g_hContactMenuItems[CMI_POKE], true);
}
return 0;
diff --git a/protocols/FacebookRM/src/theme.h b/protocols/FacebookRM/src/theme.h
index f472b4f9ce..12984682f4 100644
--- a/protocols/FacebookRM/src/theme.h
+++ b/protocols/FacebookRM/src/theme.h
@@ -35,5 +35,6 @@ void UninitContactMenus(void);
#define CMI_AUTH_ASK 3
#define CMI_AUTH_GRANT 4
#define CMI_AUTH_CANCEL 5
+#define CMI_POKE 6
-#define CMITEMS_COUNT 6 \ No newline at end of file
+#define CMITEMS_COUNT 7 \ No newline at end of file