mirror of
https://github.com/osnr/TabFS.git
synced 2024-06-01 21:42:33 +02:00
Starting to move to native messaging.
Why? The WebSocket stuff is broken right now, and I want to get rid of the dep...
This commit is contained in:
parent
53de6736fe
commit
74b1b0f789
6
.gitmodules
vendored
6
.gitmodules
vendored
|
@ -1,9 +1,3 @@
|
||||||
[submodule "fs/cJSON"]
|
[submodule "fs/cJSON"]
|
||||||
path = fs/cJSON
|
path = fs/cJSON
|
||||||
url = https://github.com/DaveGamble/cJSON.git
|
url = https://github.com/DaveGamble/cJSON.git
|
||||||
[submodule "fs/mmx"]
|
|
||||||
path = fs/mmx
|
|
||||||
url = https://github.com/vurtun/mmx.git
|
|
||||||
[submodule "fs/base64"]
|
|
||||||
path = fs/base64
|
|
||||||
url = https://github.com/zhicheng/base64.git
|
|
||||||
|
|
23
Makefile
Normal file
23
Makefile
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
EXE_PATH=$(shell pwd)/fs/tabfs
|
||||||
|
define NATIVE_MESSAGING_APP_MANIFEST
|
||||||
|
{
|
||||||
|
"name": "com.rsnous.TabFS",
|
||||||
|
"description": "TabFS",
|
||||||
|
"path": "$(EXE_PATH)",
|
||||||
|
"type": "stdio",
|
||||||
|
"allowed_extensions": ["tabfs@rsnous.com"]
|
||||||
|
}
|
||||||
|
endef
|
||||||
|
export NATIVE_MESSAGING_APP_MANIFEST
|
||||||
|
|
||||||
|
# "allowed_origins": [
|
||||||
|
# "chrome-extension://knldjmfmopnpolahpmmgbagdohdnhkik/"
|
||||||
|
# ]
|
||||||
|
|
||||||
|
# ~/Library/Application Support/Google/Chrome/NativeMessagingHosts
|
||||||
|
MANIFEST_LOCATION="$$HOME/Library/Application Support/Mozilla/NativeMessagingHosts"
|
||||||
|
APP_NAME="com.rsnous.TabFS"
|
||||||
|
install:
|
||||||
|
# install native messaging json
|
||||||
|
mkdir -p $(MANIFEST_LOCATION)
|
||||||
|
echo "$$NATIVE_MESSAGING_APP_MANIFEST" > $(MANIFEST_LOCATION)/$(APP_NAME).json
|
|
@ -289,9 +289,9 @@ async function releasedir(path) {
|
||||||
if (route.releasedir) return route.releasedir(path);
|
if (route.releasedir) return route.releasedir(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
let ws;
|
let port;
|
||||||
async function onmessage(event) {
|
/* let ws;*/
|
||||||
const req = JSON.parse(event.data);
|
async function onMessage(req) {
|
||||||
console.log('req', req);
|
console.log('req', req);
|
||||||
|
|
||||||
let response = { op: req.op, error: unix.EIO };
|
let response = { op: req.op, error: unix.EIO };
|
||||||
|
@ -371,14 +371,18 @@ async function onmessage(event) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function tryConnect() {
|
function tryConnect() {
|
||||||
ws = new WebSocket("ws://localhost:8888");
|
port = chrome.runtime.connectNative('com.rsnous.TabFS');
|
||||||
updateToolbarIcon();
|
updateToolbarIcon();
|
||||||
ws.onopen = ws.onclose = updateToolbarIcon;
|
port.onMessage.addListener(onMessage);
|
||||||
ws.onmessage = onmessage;
|
|
||||||
|
/* ws = new WebSocket("ws://localhost:8888");
|
||||||
|
* updateToolbarIcon();
|
||||||
|
* ws.onopen = ws.onclose = updateToolbarIcon;
|
||||||
|
* ws.onmessage = onmessage;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateToolbarIcon() {
|
function updateToolbarIcon() {
|
||||||
if (ws && ws.readyState == 1) { // OPEN
|
if (port && port.onMessage) { // OPEN
|
||||||
chrome.browserAction.setBadgeBackgroundColor({color: 'blue'});
|
chrome.browserAction.setBadgeBackgroundColor({color: 'blue'});
|
||||||
chrome.browserAction.setBadgeText({text: 'f'});
|
chrome.browserAction.setBadgeText({text: 'f'});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -5,12 +5,18 @@
|
||||||
"description": "Connects to TabFS filesystem",
|
"description": "Connects to TabFS filesystem",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
|
|
||||||
"permissions": ["tabs", "debugger"],
|
"permissions": ["tabs", "debugger", "nativeMessaging"],
|
||||||
|
|
||||||
"browser_action": {},
|
"browser_action": {},
|
||||||
|
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": ["background.js"],
|
"scripts": ["background.js"],
|
||||||
"persistent": true
|
"persistent": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"browser_specific_settings": {
|
||||||
|
"gecko": {
|
||||||
|
"id": "tabfs@rsnous.com"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
fs/mmx
1
fs/mmx
|
@ -1 +0,0 @@
|
||||||
Subproject commit dc54ba5c8cf6518d9876eb8586c83603b683a118
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "base64/base64.c"
|
#include "base64/base64.c"
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "ws.h"
|
|
||||||
|
|
||||||
static cJSON *send_request_then_await_response(cJSON *req) {
|
static cJSON *send_request_then_await_response(cJSON *req) {
|
||||||
// Will be freed at receiver (ws.c, receive_tabfs_request_then_send_to_browser).
|
// Will be freed at receiver (ws.c, receive_tabfs_request_then_send_to_browser).
|
||||||
|
|
Loading…
Reference in a new issue