summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-03-15 10:22:11 +0000
committerRobert Pösel <robyer@seznam.cz>2014-03-15 10:22:11 +0000
commit7846764cedc3ebc2827e891d683fec31e2149baa (patch)
tree1cb561f95f6d46e7f62ccd022637b5bc9bf78065 /protocols/FacebookRM/src
parent9ba2c4ec23e4079b69988719b56d8dd2f5d132ae (diff)
Facebook: use clientid parameter in channel requests (fixes #536), version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@8613 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r--protocols/FacebookRM/src/client.h3
-rw-r--r--protocols/FacebookRM/src/communication.cpp4
-rw-r--r--protocols/FacebookRM/src/connection.cpp3
-rw-r--r--protocols/FacebookRM/src/utils.cpp15
-rw-r--r--protocols/FacebookRM/src/utils.h3
-rw-r--r--protocols/FacebookRM/src/version.h4
6 files changed, 25 insertions, 7 deletions
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h
index ab701f4a15..8184e34513 100644
--- a/protocols/FacebookRM/src/client.h
+++ b/protocols/FacebookRM/src/client.h
@@ -39,7 +39,7 @@ public:
{
username_ = password_ = \
chat_sequence_num_ = chat_channel_host_ = chat_channel_partition_ = \
- dtsg_ = logout_hash_ = chat_sticky_num_ = chat_conn_num_ = "";
+ dtsg_ = logout_hash_ = chat_sticky_num_ = chat_conn_num_ = chat_clientid_ = "";
msgid_ = error_count_ = last_feeds_update_ = last_notification_time_ = 0;
@@ -75,6 +75,7 @@ public:
std::string chat_reconnect_reason_;
std::string chat_sticky_num_;
std::string chat_conn_num_;
+ std::string chat_clientid_;
bool invisible_;
bool is_typing_;
bool is_idle_;
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 6168a26f8c..53e2bd08a8 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -499,7 +499,9 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
std::string action = "/pull?channel=" + (this->chat_channel_.empty() ? "p_" + self_.user_id : this->chat_channel_);
action += "&seq=" + (this->chat_sequence_num_.empty() ? "0" : this->chat_sequence_num_);
action += "&partition=" + (this->chat_channel_partition_.empty() ? "0" : this->chat_channel_partition_);
- action += "&clientid=&cb=&idle=0&state=active";
+ action += "&clientid=" + this->chat_clientid_;
+ action += "&cb=" + utils::text::rand_string(4, "0123456789abcdefghijklmnopqrstuvwxyz");
+ action += "&idle=0&state=active";
if (!this->chat_sticky_num_.empty())
action += "&sticky_token=" + this->chat_sticky_num_;
diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp
index 2c9496add2..dff3474234 100644
--- a/protocols/FacebookRM/src/connection.cpp
+++ b/protocols/FacebookRM/src/connection.cpp
@@ -161,6 +161,9 @@ bool FacebookProto::NegotiateConnection()
// Get info about secured connection
facy.https_ = getByte(FACEBOOK_KEY_FORCE_HTTPS, DEFAULT_FORCE_HTTPS) != 0;
+ // Generate random clientid for this connection
+ facy.chat_clientid_ = utils::text::rand_string(8, "0123456789abcdef");
+
// Create default group for new contacts
ptrT groupName( getTStringA(FACEBOOK_KEY_DEF_GROUP));
if (groupName != NULL)
diff --git a/protocols/FacebookRM/src/utils.cpp b/protocols/FacebookRM/src/utils.cpp
index 81a0826239..4da9cd44e0 100644
--- a/protocols/FacebookRM/src/utils.cpp
+++ b/protocols/FacebookRM/src/utils.cpp
@@ -450,8 +450,19 @@ std::string utils::text::source_get_form_data(std::string* data)
return values;
}
-int utils::number::random()
+std::string utils::text::rand_string(int len, const char *chars)
{
+ std::stringstream out;
+
srand(::time(NULL));
- return rand();
+ for (int i = 0; i < len; ++i) {
+ out << chars[utils::number::random(0, strlen(chars))];
+ }
+
+ return out.str();
+}
+
+int utils::number::random(int min, int max)
+{
+ return (rand() % (max - min)) + min;
}
diff --git a/protocols/FacebookRM/src/utils.h b/protocols/FacebookRM/src/utils.h
index 35f043410b..c6fade2c49 100644
--- a/protocols/FacebookRM/src/utils.h
+++ b/protocols/FacebookRM/src/utils.h
@@ -48,7 +48,7 @@ namespace utils
namespace number
{
- int random();
+ int random(int min, int max);
};
namespace text
@@ -64,6 +64,7 @@ namespace utils
std::string source_get_value(std::string* data, unsigned int argument_count, ...);
std::string source_get_value2(std::string* data, const char *term, const char *endings, bool wholeString = false);
std::string source_get_form_data(std::string* data);
+ std::string rand_string(int len, const char *chars = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz");
void explode(std::string str, std::string separator, std::vector<std::string>* results);
void append_ordinal(unsigned long value, std::string* data);
};
diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h
index 180e78fcd0..96e0535f12 100644
--- a/protocols/FacebookRM/src/version.h
+++ b/protocols/FacebookRM/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 2
#define __RELEASE_NUM 3
-#define __BUILD_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>
@@ -11,4 +11,4 @@
#define __AUTHOR "Michal Zelinka, Robert P\xf6" "sel"
#define __AUTHOREMAIL "robyer@seznam.cz"
#define __AUTHORWEB "http://miranda-ng.org/p/Facebook/"
-#define __COPYRIGHT "© 2009-11 Michal Zelinka, 2011-13 Robert P\xf6" "sel"
+#define __COPYRIGHT "© 2009-11 Michal Zelinka, 2011-14 Robert P\xf6" "sel"