diff --git a/gomuks.el b/gomuks.el index b2331bf..bd68a71 100644 --- a/gomuks.el +++ b/gomuks.el @@ -18,7 +18,7 @@ ;;; Commentary: -;; Depends on websocket and request. +;; Depends on websocket, request, and notifications. ;;; Code: @@ -34,7 +34,11 @@ (defvar gomuks-socket-buffer "*gomuks-socket-frame*") (defvar gomuks-server-name "*gomuks-server*") -(defcustom gomuks-server-binary "~/Downloads/gomuks" +(defvar gomuks-auth-cookie nil) +(defvar gomuks-websocket nil) +(defvar gomuks-ping-timer nil) + +(defcustom gomuks-server-binary "~/tmp/gomuks" "The Gomuks backend binary." :type 'string :group 'gomuks) @@ -42,12 +46,16 @@ (defun gomuks-server-start () "Start the gomuks server process" (interactive) - (start-process gomuks-server-name (get-buffer-create gomuks-server-buffer) gomuks-server-bin)) + (start-process gomuks-server-name (get-buffer-create gomuks-server-buffer) gomuks-server-binary) + (notifications-notify :title "Gomuks Server Running" :app-name "gomuks.el")) (defun gomuks-server-kill () "Kill the gomuks server process" (interactive) - (kill-process gomuks-server-name)) + (when (websocket-openp gomuks-websocket) + (gomuks-disconnect)) + (kill-process gomuks-server-name) + (notifications-notify :title "Gomuks Server Closed" :app-name "gomuks.el")) (defvar gomuks-url "http://localhost:29325") (defvar gomuks-auth-endpoint (concat gomuks-url "/_gomuks/auth")) @@ -55,13 +63,10 @@ (defvar gomuks-ws-endpoint (concat gomuks-url "/_gomuks/websocket")) -(defvar gomuks-auth-cookie nil) -(defvar gomuks-websocket nil) -(defvar gomuks-ping-timer nil) (defun gomuks-connect (gomuks-username) "Opens a websocket connection with the specified gomuks endpoint" (interactive "sGomuks Username: \n") - (let ((gomuks-password (read-passwd "Gomuks Password:"))) + (let ((gomuks-password (read-passwd "Gomuks Password: "))) (setq gomuks-auth-cookie (let ((request--curl-cookie-jar (expand-file-name (make-temp-name "gomuks-cookie-") temporary-file-directory))) (request gomuks-auth-endpoint