Skip to content
Permalink
Browse files

Support http proxy now!

  • Loading branch information...
manateelazycat committed Jul 21, 2018
1 parent 8cb075a commit ce98eff3939258a85835dd699eddb78ac3046f60
Showing with 30 additions and 2 deletions.
  1. +10 −0 README.md
  2. +5 −1 eaf.el
  3. +15 −1 eaf.py
@@ -111,6 +111,16 @@ Please don't run EAF with root user, root user just can access DBus's system bus

## Settings

### Proxy
If you can't access most awesome internet service like me, you perhaps need proxy settings like below:

```Elisp
(setq eaf-http-proxy-host "127.0.0.1")
(setq eaf-http-proxy-port "1080")
```

Then EAF browser are free. ;)

### Markdown Previewer
If you use markdown previewer, you need access [Personal access token](https://github.com/settings/tokens/new?scopes=), fill something in "Token description" and click button "Generate token" to get your personal token, then set token with code:

6 eaf.el
@@ -127,6 +127,10 @@

(defvar eaf-grip-token nil)

(defvar eaf-http-proxy-host "")

(defvar eaf-http-proxy-port "")

(defcustom eaf-name "*eaf*"
"Name of eaf buffer."
:type 'string
@@ -151,7 +155,7 @@
(apply 'start-process
eaf-name
eaf-name
"python3" (append (list eaf-python-file (eaf-get-emacs-xid)) (eaf-get-render-size))
"python3" (append (list eaf-python-file (eaf-get-emacs-xid)) (eaf-get-render-size) (list eaf-http-proxy-host eaf-http-proxy-port))
))
(set-process-query-on-exit-flag eaf-process nil)
(set-process-sentinel
16 eaf.py
@@ -25,6 +25,7 @@
from app.browser.buffer import AppBuffer as NeverUsed

from PyQt5.QtWidgets import QApplication
from PyQt5.QtNetwork import QNetworkProxy
from core.fake_key_event import fake_key_event
from core.utils import file_is_image, file_is_video
from core.view import View
@@ -47,14 +48,27 @@ def __init__(self, args):
dbus.service.BusName(EAF_DBUS_NAME, bus=dbus.SessionBus()),
EAF_OBJECT_NAME)

(emacs_xid, emacs_width, emacs_height) = (map(lambda x: int(x), args))
# (emacs_xid, emacs_width, emacs_height, proxy_host, proxy_port) = (map(lambda x: int(x), args))
(emacs_xid, emacs_width, emacs_height, proxy_host, proxy_port) = args
emacs_xid = int(emacs_xid)
emacs_width = int(emacs_width)
emacs_height = int(emacs_height)

self.buffer_dict = {}
self.view_dict = {}

self.start_finish()

self.session_file_path = os.path.expanduser("~/.emacs.d/eaf/session.json")

# Set HTTP proxy.
if proxy_host != "" and proxy_port != "":
proxy = QNetworkProxy()
proxy.setType(QNetworkProxy.HttpProxy)
proxy.setHostName(proxy_host)
proxy.setPort(int(proxy_port))
QNetworkProxy.setApplicationProxy(proxy)

@dbus.service.method(EAF_DBUS_NAME, in_signature="ssss", out_signature="s")
def new_buffer(self, buffer_id, url, app_name, arguments):
# NOTE: We need use function str convert dbus.String to String,

0 comments on commit ce98eff

Please sign in to comment.
You can’t perform that action at this time.