mirror of
https://github.com/LibreOffice/online.git
synced 2025-08-16 17:42:05 +00:00
Revert "android: Various fixes to make the sending from the core to JS..."
Lets leave this optimization for later, this is incomplete, and does not
fix the problem which it was originally supposed to address.
This reverts commit bce922e8fd
.
Change-Id: I5d2ee19058261c7612d36014181f509604c8acde
This commit is contained in:
@ -64,14 +64,14 @@ static void send2JS(jclass mainActivityClz, jobject mainActivityObj, const std::
|
||||
{
|
||||
// The data needs to be an ArrayBuffer
|
||||
std::stringstream ss;
|
||||
ss << "{'base64data':'";
|
||||
ss << "Base64ToArrayBuffer('";
|
||||
|
||||
Poco::Base64Encoder encoder(ss);
|
||||
encoder.rdbuf()->setLineLength(0); // unlimited
|
||||
encoder << std::string(buffer.data(), buffer.size());
|
||||
encoder.close();
|
||||
|
||||
ss << "'}";
|
||||
ss << "')";
|
||||
|
||||
js = ss.str();
|
||||
}
|
||||
@ -93,8 +93,9 @@ static void send2JS(jclass mainActivityClz, jobject mainActivityObj, const std::
|
||||
data.push_back(ubufp[i]);
|
||||
}
|
||||
}
|
||||
data.push_back(0);
|
||||
|
||||
js = "{'data':'" + std::string(data.data(), data.size()) + "'}";
|
||||
js = std::string(data.data(), data.size());
|
||||
}
|
||||
|
||||
std::string subjs = js.substr(0, std::min(std::string::size_type(SHOW_JS_MAXLEN), js.length()));
|
||||
|
@ -181,7 +181,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
mWebView.post(new Runnable() {
|
||||
public void run() {
|
||||
Log.i(TAG,"Forwarding to the WebView: " + message);
|
||||
mWebView.loadUrl("javascript:window.TheFakeWebSocket.onmessage(" + message + ");");
|
||||
mWebView.loadUrl("javascript:window.TheFakeWebSocket.onmessage({'data': '" + message + "'});");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -58,11 +58,11 @@ static void send2JS(const std::vector<char>& buffer)
|
||||
if (newline != nullptr)
|
||||
{
|
||||
// The data needs to be an ArrayBuffer
|
||||
js = "window.TheFakeWebSocket.onmessage({'base64data':'";
|
||||
js = "window.TheFakeWebSocket.onmessage({'data': Base64ToArrayBuffer('";
|
||||
gchar *base64 = g_base64_encode((const guchar*)buffer.data(), buffer.size());
|
||||
js = js + std::string(base64);
|
||||
g_free(base64);
|
||||
js = js + "'});";
|
||||
js = js + "')});";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -84,7 +84,7 @@ static void send2JS(const std::vector<char>& buffer)
|
||||
}
|
||||
data.push_back(0);
|
||||
|
||||
js = "window.TheFakeWebSocket.onmessage({'data':'";
|
||||
js = "window.TheFakeWebSocket.onmessage({'data': '";
|
||||
js = js + std::string(buffer.data(), buffer.size());
|
||||
js = js + "'});";
|
||||
}
|
||||
|
@ -82,9 +82,9 @@
|
||||
const char *newline = (const char *)memchr(buffer, '\n', length);
|
||||
if (newline != nullptr) {
|
||||
// The data needs to be an ArrayBuffer
|
||||
js = @"window.TheFakeWebSocket.onmessage({'base64data':'";
|
||||
js = @"window.TheFakeWebSocket.onmessage({'data': Base64ToArrayBuffer('";
|
||||
js = [js stringByAppendingString: [[NSData dataWithBytes:buffer length:length] base64EncodedStringWithOptions:0]];
|
||||
js = [js stringByAppendingString:@"'});"];
|
||||
js = [js stringByAppendingString:@"')});"];
|
||||
NSString *subjs = [js substringToIndex:std::min(100ul, js.length)];
|
||||
if (subjs.length < js.length)
|
||||
subjs = [subjs stringByAppendingString:@"..."];
|
||||
@ -116,7 +116,7 @@
|
||||
}
|
||||
data.push_back(0);
|
||||
|
||||
js = @"window.TheFakeWebSocket.onmessage({'data':'";
|
||||
js = @"window.TheFakeWebSocket.onmessage({'data': '";
|
||||
js = [js stringByAppendingString:[NSString stringWithUTF8String:data.data()]];
|
||||
js = [js stringByAppendingString:@"'});"];
|
||||
|
||||
|
@ -12,7 +12,7 @@ define([_foreachq],[ifelse([$#],[3],[],[define([$1],[$4])$2[]$0([$1],[$2],shift(
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<script>
|
||||
dnl# Define MOBILEAPP as true if this is either for the iOS app, Android app or for the gtk+ "app" testbed
|
||||
dnl# Define MOBILEAPP as true if this is either for the iOS app or for the gtk+ "app" testbed
|
||||
define([MOBILEAPP],[])
|
||||
ifelse(IOSAPP,[true],[define([MOBILEAPP],[true])])
|
||||
ifelse(GTKAPP,[true],[define([MOBILEAPP],[true])])
|
||||
@ -31,6 +31,16 @@ ifelse(MOBILEAPP,[],
|
||||
};
|
||||
window.addEventListener('message', PostMessageReadyListener, false);
|
||||
)dnl
|
||||
|
||||
var Base64ToArrayBuffer = function(base64Str) {
|
||||
var binStr = atob(base64Str);
|
||||
var ab = new ArrayBuffer(binStr.length);
|
||||
var bv = new Uint8Array(ab);
|
||||
for (var i = 0, l = binStr.length; i < l; i++) {
|
||||
bv[[i]] = binStr.charCodeAt(i);
|
||||
}
|
||||
return ab;
|
||||
}
|
||||
</script>
|
||||
|
||||
ifelse(MOBILEAPP,[true],
|
||||
|
@ -241,10 +241,7 @@ L.Socket = L.Class.extend({
|
||||
_onMessage: function (e) {
|
||||
var imgBytes, index, textMsg;
|
||||
|
||||
if (typeof(e.base64data) === 'string') {
|
||||
textMsg = atob(e.base64data);
|
||||
}
|
||||
else if (typeof (e.data) === 'string') {
|
||||
if (typeof (e.data) === 'string') {
|
||||
textMsg = e.data;
|
||||
}
|
||||
else if (typeof (e.data) === 'object') {
|
||||
|
Reference in New Issue
Block a user