2018-11-02 11:19:19 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
/*
|
2018-11-02 11:19:19 -05:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
*/
|
|
|
|
|
2021-06-19 15:40:53 -05:00
|
|
|
#include <config.h>
|
|
|
|
|
2018-10-25 13:27:48 -05:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
#include <iostream>
|
2018-10-17 14:41:01 -05:00
|
|
|
#include <thread>
|
2018-10-25 13:27:48 -05:00
|
|
|
#include <string.h>
|
|
|
|
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <webkit2/webkit2.h>
|
2018-11-01 16:21:04 -05:00
|
|
|
#if !WEBKIT_CHECK_VERSION(2,22,0)
|
|
|
|
# include<JavaScriptCore/JavaScript.h>
|
|
|
|
#endif
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
|
|
|
|
#include "FakeSocket.hpp"
|
|
|
|
#include "Log.hpp"
|
2021-11-18 06:08:14 -06:00
|
|
|
#include "COOLWSD.hpp"
|
2018-10-17 14:41:01 -05:00
|
|
|
#include "Protocol.hpp"
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
#include "Util.hpp"
|
|
|
|
|
2018-10-17 14:41:01 -05:00
|
|
|
const int SHOW_JS_MAXLEN = 70;
|
|
|
|
|
2021-11-18 06:08:14 -06:00
|
|
|
int coolwsd_server_socket_fd = -1;
|
2018-10-17 14:41:01 -05:00
|
|
|
|
|
|
|
static std::string fileURL;
|
2021-11-18 06:08:14 -06:00
|
|
|
static COOLWSD *coolwsd = nullptr;
|
2018-10-17 14:41:01 -05:00
|
|
|
static int fakeClientFd;
|
|
|
|
static int closeNotificationPipeForForwardingThread[2];
|
|
|
|
static WebKitWebView *webView;
|
|
|
|
|
|
|
|
static void send2JS_ready_callback(GObject *source_object,
|
|
|
|
GAsyncResult *res,
|
2018-11-02 11:19:19 -05:00
|
|
|
gpointer user_data)
|
2018-10-17 14:41:01 -05:00
|
|
|
{
|
2018-10-25 13:27:48 -05:00
|
|
|
free(user_data);
|
2018-10-17 14:41:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void send2JS(const std::vector<char>& buffer)
|
|
|
|
{
|
2021-11-18 06:08:14 -06:00
|
|
|
LOG_TRC_NOFILE("Send to JS: " << COOLProtocol::getAbbreviatedMessage(buffer.data(), buffer.size()));
|
2018-10-17 14:41:01 -05:00
|
|
|
|
|
|
|
std::string js;
|
|
|
|
|
|
|
|
// Check if the message is binary. We say that any message that isn't just a single line is
|
|
|
|
// "binary" even if that strictly speaking isn't the case; for instance the commandvalues:
|
|
|
|
// message has a long bunch of non-binary JSON on multiple lines. But _onMessage() in Socket.js
|
|
|
|
// handles it fine even if such a message, too, comes in as an ArrayBuffer. (Look for the
|
|
|
|
// "textMsg = String.fromCharCode.apply(null, imgBytes);".)
|
|
|
|
|
|
|
|
const char *newline = (const char *)memchr(buffer.data(), '\n', buffer.size());
|
|
|
|
if (newline != nullptr)
|
|
|
|
{
|
|
|
|
// The data needs to be an ArrayBuffer
|
2019-02-19 16:56:59 -06:00
|
|
|
js = "window.TheFakeWebSocket.onmessage({'data': Base64ToArrayBuffer('";
|
2018-10-17 14:41:01 -05:00
|
|
|
gchar *base64 = g_base64_encode((const guchar*)buffer.data(), buffer.size());
|
|
|
|
js = js + std::string(base64);
|
|
|
|
g_free(base64);
|
2019-02-19 16:56:59 -06:00
|
|
|
js = js + "')});";
|
2018-10-17 14:41:01 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const unsigned char *ubufp = (const unsigned char *)buffer.data();
|
|
|
|
std::vector<char> data;
|
|
|
|
for (int i = 0; i < buffer.size(); i++)
|
|
|
|
{
|
|
|
|
if (ubufp[i] < ' ' || ubufp[i] == '\'' || ubufp[i] == '\\')
|
|
|
|
{
|
|
|
|
data.push_back('\\');
|
|
|
|
data.push_back('x');
|
|
|
|
data.push_back("0123456789abcdef"[(ubufp[i] >> 4) & 0x0F]);
|
|
|
|
data.push_back("0123456789abcdef"[ubufp[i] & 0x0F]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data.push_back(ubufp[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data.push_back(0);
|
|
|
|
|
2019-02-19 16:56:59 -06:00
|
|
|
js = "window.TheFakeWebSocket.onmessage({'data': '";
|
2018-10-25 13:27:48 -05:00
|
|
|
js = js + std::string(buffer.data(), buffer.size());
|
2018-10-17 14:41:01 -05:00
|
|
|
js = js + "'});";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string subjs = js.substr(0, std::min(std::string::size_type(SHOW_JS_MAXLEN), js.length()));
|
|
|
|
if (js.length() > SHOW_JS_MAXLEN)
|
|
|
|
subjs += "...";
|
|
|
|
|
|
|
|
LOG_TRC_NOFILE( "Evaluating JavaScript: " << subjs);
|
|
|
|
|
|
|
|
char *jscopy = strdup(js.c_str());
|
2018-10-17 15:25:28 -05:00
|
|
|
g_idle_add([](gpointer data)
|
|
|
|
{
|
|
|
|
char *jscopy = (char*) data;
|
2018-11-02 11:19:19 -05:00
|
|
|
webkit_web_view_run_javascript(webView, jscopy, nullptr, send2JS_ready_callback, jscopy);
|
2018-10-17 15:25:28 -05:00
|
|
|
return FALSE;
|
|
|
|
}, jscopy);
|
2018-10-17 14:41:01 -05:00
|
|
|
}
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
|
2018-11-01 16:21:04 -05:00
|
|
|
static char *js_result_as_gstring(WebKitJavascriptResult *js_result)
|
2018-10-16 17:04:05 -05:00
|
|
|
{
|
2018-11-01 16:21:04 -05:00
|
|
|
#if WEBKIT_CHECK_VERSION(2,22,0) // unclear when this API changed ...
|
2018-10-16 17:04:05 -05:00
|
|
|
JSCValue *value = webkit_javascript_result_get_js_value(js_result);
|
|
|
|
if (jsc_value_is_string(value))
|
2018-11-01 16:21:04 -05:00
|
|
|
return jsc_value_to_string(value);
|
|
|
|
else
|
|
|
|
return nullptr;
|
|
|
|
#else // older Webkits
|
|
|
|
JSValueRef value = webkit_javascript_result_get_value(js_result);
|
|
|
|
JSContextRef ctx = webkit_javascript_result_get_global_context(js_result);
|
|
|
|
if (JSValueIsString(ctx, value))
|
|
|
|
{
|
|
|
|
const JSStringRef js_str = JSValueToStringCopy(ctx, value, nullptr);
|
|
|
|
size_t gstring_max = JSStringGetMaximumUTF8CStringSize(js_str);
|
|
|
|
char *gstring = (char *)g_malloc(gstring_max);
|
|
|
|
if (gstring)
|
|
|
|
JSStringGetUTF8CString(js_str, gstring, gstring_max);
|
|
|
|
else
|
|
|
|
LOG_TRC_NOFILE("No string");
|
|
|
|
JSStringRelease(js_str);
|
|
|
|
return gstring;
|
|
|
|
}
|
2018-10-16 17:04:05 -05:00
|
|
|
else
|
2018-11-01 16:21:04 -05:00
|
|
|
LOG_TRC_NOFILE("Unexpected object type " << JSValueGetType(ctx, value));
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void handle_message(const char * type, WebKitJavascriptResult *js_result)
|
|
|
|
{
|
|
|
|
gchar *string_value = js_result_as_gstring(js_result);
|
|
|
|
|
|
|
|
if (string_value)
|
|
|
|
LOG_TRC_NOFILE("From JS: " << type << ": " << string_value);
|
|
|
|
else
|
|
|
|
LOG_TRC_NOFILE("From JS: " << type << ": some object");
|
|
|
|
|
|
|
|
g_free(string_value);
|
2018-10-16 17:04:05 -05:00
|
|
|
}
|
|
|
|
|
2021-11-18 06:08:14 -06:00
|
|
|
static void handle_cool_message(WebKitUserContentManager *manager,
|
2018-10-16 17:04:05 -05:00
|
|
|
WebKitJavascriptResult *js_result,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2018-11-01 16:21:04 -05:00
|
|
|
gchar *string_value = js_result_as_gstring(js_result);
|
2018-10-17 14:41:01 -05:00
|
|
|
|
2018-11-01 16:21:04 -05:00
|
|
|
if (string_value)
|
2018-10-17 14:41:01 -05:00
|
|
|
{
|
2021-11-15 10:25:18 -06:00
|
|
|
LOG_TRC_NOFILE("From JS: cool: " << string_value);
|
2018-10-17 14:41:01 -05:00
|
|
|
|
|
|
|
if (strcmp(string_value, "HULLO") == 0)
|
|
|
|
{
|
|
|
|
// Now we know that the JS has started completely
|
|
|
|
|
2021-11-18 06:08:14 -06:00
|
|
|
// Contact the permanently (during app lifetime) listening COOLWSD server
|
2018-10-17 14:41:01 -05:00
|
|
|
// "public" socket
|
2021-11-18 06:08:14 -06:00
|
|
|
assert(coolwsd_server_socket_fd != -1);
|
|
|
|
int rc = fakeSocketConnect(fakeClientFd, coolwsd_server_socket_fd);
|
2018-10-17 14:41:01 -05:00
|
|
|
assert(rc != -1);
|
|
|
|
|
|
|
|
// Create a socket pair to notify the below thread when the document has been closed
|
|
|
|
fakeSocketPipe2(closeNotificationPipeForForwardingThread);
|
|
|
|
|
|
|
|
// Start another thread to read responses and forward them to the JavaScript
|
|
|
|
std::thread([]
|
|
|
|
{
|
|
|
|
Util::setThreadName("app2js");
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
struct pollfd pollfd[2];
|
|
|
|
pollfd[0].fd = fakeClientFd;
|
|
|
|
pollfd[0].events = POLLIN;
|
|
|
|
pollfd[1].fd = closeNotificationPipeForForwardingThread[1];
|
|
|
|
pollfd[1].events = POLLIN;
|
|
|
|
if (fakeSocketPoll(pollfd, 2, -1) > 0)
|
|
|
|
{
|
|
|
|
if (pollfd[1].revents == POLLIN)
|
|
|
|
{
|
|
|
|
// The code below handling the "BYE" fake Websocket
|
|
|
|
// message has closed the other end of the
|
|
|
|
// closeNotificationPipeForForwardingThread. Let's close
|
|
|
|
// the other end too just for cleanliness, even if a
|
|
|
|
// FakeSocket as such is not a system resource so nothing
|
|
|
|
// is saved by closing it.
|
|
|
|
fakeSocketClose(closeNotificationPipeForForwardingThread[1]);
|
|
|
|
|
|
|
|
// Close our end of the fake socket connection to the
|
|
|
|
// ClientSession thread, so that it terminates
|
|
|
|
fakeSocketClose(fakeClientFd);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (pollfd[0].revents == POLLIN)
|
|
|
|
{
|
|
|
|
int n = fakeSocketAvailableDataLength(fakeClientFd);
|
|
|
|
if (n == 0)
|
|
|
|
return;
|
|
|
|
std::vector<char> buf(n);
|
|
|
|
n = fakeSocketRead(fakeClientFd, buf.data(), n);
|
|
|
|
send2JS(buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
assert(false);
|
|
|
|
}).detach();
|
|
|
|
|
|
|
|
// First we simply send it the URL. This corresponds to the GET request with Upgrade to
|
|
|
|
// WebSocket.
|
|
|
|
LOG_TRC_NOFILE("Actually sending to Online:" << fileURL);
|
|
|
|
|
2018-10-17 15:25:28 -05:00
|
|
|
// Must do this in a thread, too, so that we can return to the GTK+ main loop
|
|
|
|
std::thread([]
|
|
|
|
{
|
|
|
|
struct pollfd pollfd;
|
|
|
|
pollfd.fd = fakeClientFd;
|
|
|
|
pollfd.events = POLLOUT;
|
|
|
|
fakeSocketPoll(&pollfd, 1, -1);
|
|
|
|
fakeSocketWrite(fakeClientFd, fileURL.c_str(), fileURL.size());
|
|
|
|
}).detach();
|
2018-10-17 14:41:01 -05:00
|
|
|
}
|
|
|
|
else if (strcmp(string_value, "BYE") == 0)
|
|
|
|
{
|
|
|
|
LOG_TRC_NOFILE("Document window terminating on JavaScript side. Closing our end of the socket.");
|
|
|
|
|
|
|
|
// Close one end of the socket pair, that will wake up the forwarding thread above
|
|
|
|
fakeSocketClose(closeNotificationPipeForForwardingThread[0]);
|
|
|
|
|
|
|
|
// ???
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-17 15:25:28 -05:00
|
|
|
// As above
|
2018-10-25 13:27:48 -05:00
|
|
|
char *string_copy = strdup(string_value);
|
|
|
|
std::thread([=]
|
2018-10-17 15:25:28 -05:00
|
|
|
{
|
|
|
|
struct pollfd pollfd;
|
|
|
|
pollfd.fd = fakeClientFd;
|
|
|
|
pollfd.events = POLLOUT;
|
|
|
|
fakeSocketPoll(&pollfd, 1, -1);
|
2018-10-25 13:27:48 -05:00
|
|
|
fakeSocketWrite(fakeClientFd, string_copy, strlen(string_copy));
|
|
|
|
free(string_copy);
|
2018-10-17 15:25:28 -05:00
|
|
|
}).detach();
|
2018-10-17 14:41:01 -05:00
|
|
|
}
|
|
|
|
g_free(string_value);
|
|
|
|
}
|
2018-10-16 17:04:05 -05:00
|
|
|
else
|
2021-11-15 10:25:18 -06:00
|
|
|
LOG_TRC_NOFILE("From JS: cool: some object");
|
2018-10-16 17:04:05 -05:00
|
|
|
}
|
|
|
|
|
2018-11-01 16:21:04 -05:00
|
|
|
static void handle_debug_message(WebKitUserContentManager *manager,
|
|
|
|
WebKitJavascriptResult *js_result,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
handle_message("debug", js_result);
|
|
|
|
}
|
|
|
|
|
2018-10-16 17:04:05 -05:00
|
|
|
static void handle_error_message(WebKitUserContentManager *manager,
|
|
|
|
WebKitJavascriptResult *js_result,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2018-11-01 16:21:04 -05:00
|
|
|
handle_message("error", js_result);
|
2018-10-16 17:04:05 -05:00
|
|
|
}
|
|
|
|
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
2018-10-26 03:53:45 -05:00
|
|
|
if (argc != 2)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Usage: %s document\n", argv[0]);
|
2018-11-02 11:19:19 -05:00
|
|
|
_exit(1); // avoid log cleanup
|
2018-10-26 03:53:45 -05:00
|
|
|
}
|
|
|
|
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
Log::initialize("Mobile", "trace", false, false, {});
|
|
|
|
Util::setThreadName("main");
|
2018-11-02 11:19:19 -05:00
|
|
|
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
fakeSocketSetLoggingCallback([](const std::string& line)
|
|
|
|
{
|
|
|
|
LOG_TRC_NOFILE(line);
|
|
|
|
});
|
|
|
|
|
2018-10-17 14:41:01 -05:00
|
|
|
std::thread([]
|
|
|
|
{
|
2021-11-18 06:08:14 -06:00
|
|
|
assert(coolwsd == nullptr);
|
2018-10-17 14:41:01 -05:00
|
|
|
char *argv[2];
|
|
|
|
argv[0] = strdup("mobile");
|
|
|
|
argv[1] = nullptr;
|
|
|
|
Util::setThreadName("app");
|
|
|
|
while (true)
|
|
|
|
{
|
2021-11-18 06:08:14 -06:00
|
|
|
coolwsd = new COOLWSD();
|
|
|
|
coolwsd->run(1, argv);
|
|
|
|
delete coolwsd;
|
|
|
|
LOG_TRC("One run of COOLWSD completed");
|
2018-10-17 14:41:01 -05:00
|
|
|
}
|
|
|
|
}).detach();
|
|
|
|
|
|
|
|
fakeClientFd = fakeSocketSocket();
|
|
|
|
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
gtk_init(&argc, &argv);
|
|
|
|
|
2018-11-02 11:19:19 -05:00
|
|
|
GtkWidget *mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_window_set_default_size(GTK_WINDOW(mainWindow), 1000, 800);
|
|
|
|
g_signal_connect(mainWindow, "destroy", G_CALLBACK(gtk_main_quit), nullptr);
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
|
|
|
|
WebKitUserContentManager *userContentManager = WEBKIT_USER_CONTENT_MANAGER(webkit_user_content_manager_new());
|
|
|
|
|
2018-11-02 11:19:19 -05:00
|
|
|
g_signal_connect(userContentManager, "script-message-received::debug", G_CALLBACK(handle_debug_message), nullptr);
|
2021-11-18 06:08:14 -06:00
|
|
|
g_signal_connect(userContentManager, "script-message-received::cool", G_CALLBACK(handle_cool_message), nullptr);
|
2018-11-02 11:19:19 -05:00
|
|
|
g_signal_connect(userContentManager, "script-message-received::error", G_CALLBACK(handle_error_message), nullptr);
|
2018-10-16 17:04:05 -05:00
|
|
|
|
|
|
|
webkit_user_content_manager_register_script_message_handler(userContentManager, "debug");
|
2021-11-15 10:25:18 -06:00
|
|
|
webkit_user_content_manager_register_script_message_handler(userContentManager, "cool");
|
2018-10-16 17:04:05 -05:00
|
|
|
webkit_user_content_manager_register_script_message_handler(userContentManager, "error");
|
|
|
|
|
2018-10-17 14:41:01 -05:00
|
|
|
webView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_user_content_manager(userContentManager));
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
|
2018-11-02 11:19:19 -05:00
|
|
|
gtk_container_add(GTK_CONTAINER(mainWindow), GTK_WIDGET(webView));
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
|
2020-07-05 16:51:02 -05:00
|
|
|
fileURL = "file://" + FileUtil::realpath(argv[1]);
|
2018-10-17 14:41:01 -05:00
|
|
|
|
|
|
|
std::string urlAndQuery =
|
2021-11-03 09:22:46 -05:00
|
|
|
"file://" TOPSRCDIR "/browser/dist/cool.html"
|
2018-10-17 14:41:01 -05:00
|
|
|
"?file_path=" + fileURL +
|
|
|
|
"&closebutton=1"
|
|
|
|
"&permission=edit"
|
|
|
|
"&debug=true";
|
|
|
|
|
|
|
|
webkit_web_view_load_uri(webView, urlAndQuery.c_str());
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
|
|
|
|
gtk_widget_grab_focus(GTK_WIDGET(webView));
|
2018-11-02 11:19:19 -05:00
|
|
|
gtk_widget_show_all(mainWindow);
|
Start on a gtk+-based workalike to the iOS app
The idea is that it would work sufficiently identically, so that even
people without a Mac and without an iOS device could participate in
development of the non-iOS-specific bits, like the JavaScript, or the
online MOBILEAPP-specific plumbing. Which would be great.
No, this doesn't do anything sane yet. It does compile the same online
C++ files as the iOS app, though. (Some minor tweaks were needed in a
couple of them to silence gcc warnings.)
There is a plain Makefile, but I should change to using autofoo, too.
Eventually, this will need to be built in a separate tree from a
normal online, just like when using the --enable-iosapp configure
switch. (But for now, doesn't matter.)
Change-Id: I13e4d921acb99d802d2f9da4b0df4a237ca60ad6
2018-10-16 16:40:49 -05:00
|
|
|
gtk_main();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|