summaryrefslogtreecommitdiff
path: root/protocols/Facebook/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-07-04 13:48:35 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-07-04 13:48:35 +0300
commita19f36229e9e131f000161d23e729b1fbca58b3e (patch)
tree7c1242abd257de1e1c38ef502cbbc91be836a6fe /protocols/Facebook/src
parent20efbab2c0f19489ac7bb731bbfcb2e716c5cd6a (diff)
Facebook: localized zlib code
Diffstat (limited to 'protocols/Facebook/src')
-rw-r--r--protocols/Facebook/src/mqtt.cpp50
-rw-r--r--protocols/Facebook/src/mqtt.h2
-rw-r--r--protocols/Facebook/src/proto.cpp2
-rw-r--r--protocols/Facebook/src/proto.h2
4 files changed, 21 insertions, 35 deletions
diff --git a/protocols/Facebook/src/mqtt.cpp b/protocols/Facebook/src/mqtt.cpp
index 5e3008def8..a5aed4584f 100644
--- a/protocols/Facebook/src/mqtt.cpp
+++ b/protocols/Facebook/src/mqtt.cpp
@@ -165,13 +165,6 @@ bool FacebookProto::MqttConnect()
return false;
}
- memset(&zStreamIn, 0, sizeof(zStreamOut));
- memset(&zStreamOut, 0, sizeof(zStreamOut));
-
- if (deflateInit(&zStreamOut, Z_BEST_COMPRESSION) == Z_OK)
- if (inflateInit(&zStreamIn) == Z_OK)
- m_zlibAvailable = true;
-
return true;
}
@@ -189,7 +182,7 @@ void FacebookProto::MqttOpen()
thrift.writeInt64(m_uid);
thrift.writeField(FB_THRIFT_TYPE_STRING); // User agent
- thrift << NETLIB_USER_AGENT;
+ thrift << FACEBOOK_ORCA_AGENT;
thrift.writeField(FB_THRIFT_TYPE_I64);
thrift.writeInt64(23);
@@ -223,31 +216,26 @@ void FacebookProto::MqttOpen()
fwrite(thrift.data(), 1, thrift.size(), out);
fclose(out);
- BYTE *pData;
- size_t dataSize;
- if (m_zlibAvailable) {
- dataSize = thrift.size() + 100;
- pData = (BYTE *)mir_alloc(dataSize);
-
- zStreamOut.avail_in = (unsigned)thrift.size();
- zStreamOut.next_in = (BYTE *)thrift.data();
- zStreamOut.avail_out = (unsigned)dataSize;
- zStreamOut.next_out = (BYTE *)pData;
-
- switch (deflate(&zStreamOut, Z_SYNC_FLUSH)) {
- case Z_OK: debugLogA("Deflate: Z_OK"); break;
- case Z_BUF_ERROR: debugLogA("Deflate: Z_BUF_ERROR"); break;
- case Z_DATA_ERROR: debugLogA("Deflate: Z_DATA_ERROR"); break;
- case Z_MEM_ERROR: debugLogA("Deflate: Z_MEM_ERROR"); break;
- }
-
- dataSize = dataSize - zStreamOut.avail_out;
- }
- else {
- dataSize = thrift.size();
- pData = (BYTE *)thrift.data();
+ size_t dataSize = thrift.size() + 100;
+ BYTE *pData = (BYTE *)mir_alloc(dataSize);
+
+ z_stream zStreamOut = {};
+ deflateInit(&zStreamOut, Z_BEST_COMPRESSION);
+ zStreamOut.avail_in = (unsigned)thrift.size();
+ zStreamOut.next_in = (BYTE *)thrift.data();
+ zStreamOut.avail_out = (unsigned)dataSize;
+ zStreamOut.next_out = (BYTE *)pData;
+
+ switch (deflate(&zStreamOut, Z_SYNC_FLUSH)) {
+ case Z_OK: debugLogA("Deflate: Z_OK"); break;
+ case Z_BUF_ERROR: debugLogA("Deflate: Z_BUF_ERROR"); break;
+ case Z_DATA_ERROR: debugLogA("Deflate: Z_DATA_ERROR"); break;
+ case Z_MEM_ERROR: debugLogA("Deflate: Z_MEM_ERROR"); break;
}
+ deflateEnd(&zStreamOut);
+ dataSize = dataSize - zStreamOut.avail_out;
+
uint8_t protocolVersion = 3;
uint8_t flags = FB_MQTT_CONNECT_FLAG_USER | FB_MQTT_CONNECT_FLAG_PASS | FB_MQTT_CONNECT_FLAG_CLR | FB_MQTT_CONNECT_FLAG_QOS1;
MqttMessage payload(FB_MQTT_MESSAGE_TYPE_CONNECT, 0, dataSize - 3);
diff --git a/protocols/Facebook/src/mqtt.h b/protocols/Facebook/src/mqtt.h
index 55c071d0e3..e1652230ca 100644
--- a/protocols/Facebook/src/mqtt.h
+++ b/protocols/Facebook/src/mqtt.h
@@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
+#define FACEBOOK_ORCA_AGENT "[FBAN/Orca-Android;FBAV/192.0.0.31.101;FBPN/com.facebook.orca;FBLC/en_US;FBBV/52182662]"
+
#define FB_THRIFT_TYPE_STOP 0
#define FB_THRIFT_TYPE_VOID 1
#define FB_THRIFT_TYPE_BOOL 2
diff --git a/protocols/Facebook/src/proto.cpp b/protocols/Facebook/src/proto.cpp
index 6fe0d5acd4..a30b7c1ac1 100644
--- a/protocols/Facebook/src/proto.cpp
+++ b/protocols/Facebook/src/proto.cpp
@@ -70,8 +70,6 @@ FacebookProto::FacebookProto(const char *proto_name, const wchar_t *username) :
FacebookProto::~FacebookProto()
{
- deflateEnd(&zStreamOut);
- inflateEnd(&zStreamIn);
}
void FacebookProto::OnModulesLoaded()
diff --git a/protocols/Facebook/src/proto.h b/protocols/Facebook/src/proto.h
index 153749776a..6f8c4fd110 100644
--- a/protocols/Facebook/src/proto.h
+++ b/protocols/Facebook/src/proto.h
@@ -72,7 +72,6 @@ class FacebookProto : public PROTO<FacebookProto>
void MqttOpen();
HNETLIBCONN m_mqttConn;
- z_stream zStreamIn, zStreamOut;
// internal data
CMStringA m_szDeviceID; // stored, GUID that identifies this miranda's account
@@ -82,7 +81,6 @@ class FacebookProto : public PROTO<FacebookProto>
bool m_invisible;
bool m_bOnline;
- bool m_zlibAvailable;
CMStringA m_szAuthToken; // calculated