xwem-devel
[Top] [All Lists]

aMule "connectedness" indicator

From: Richard Klinda <ignotus@xxxxxxxxxxx>
Subject: aMule "connectedness" indicator
Date: Thu, 28 Apr 2005 17:04:33 +0200
Organization: BARBARA STANWYCK makes me nervous!!
Sender: ignotus@xxxxxxxxxxx
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux)
Hello guys, here is another "useful" snippet :)

I use the aMule edonkey client, but unfortunately it sometimes (very
rarely) disconnects from the network, I don't know why neither I want to
investigate this, I usually just hit on "connect" and it goes back but I
don't want to periodically check this by hand.  Because of that I made
this code snippet that connects to aMule, and periodically checks
whether it is connected to the edonkey server or not, if not it sets a
variable to NIL so I can use this variable to put a signal on my XWEM
OSD:).

Only thing, to use this you have to run aMule like this:

,----
| alias amule="touch /tmp/amule.runs; amule; rm /tmp/amule.runs"
`----

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;;; //////////////////////////////////////////////////////////////////////
;; amule stuff (no XWEM specific parts here)

;; i need a little warning indicator when aMule is disconnected

(defvar amule-process nil)

(defvar amule:connected-p 'dontknow)    ;when NIL, then amule is
                                        ;disconnected!

;; (amule-start-connection)
(defun amule-start-connection ()
  (when (and (amule-running-p)
             (or (not (process-live-p amule-process))
                 (not (amule-process-alive-p))))
    (setq amule-process (start-process "amulecmd" nil "amulecmd"))
    (set-process-filter amule-process 'amule-process-filter)
    (sleep-for 0.3)
    ;; password
    (process-send-string amule-process "\n")
    ))

(defun amule-stop-connection ()
  (kill-process amule-process))

(defun amule-process-alive-p ()
  (when amule-process
    (eq (process-status amule-process) 'run)))

(defun amule-running-p ()
  (file-exists-p "/tmp/amule.runs"))

;; (amule-serverstatus-query)
(defun amule-serverstatus-query ()
  (when (and (amule-running-p)
             (amule-process-alive-p))
    (process-send-string amule-process "serverstatus\n")))

(defun amule-process-filter (process output)
  (with-temp-buffer
    (insert output)
    (goto-char (point-min))
    (cond ((re-search-forward "^Connected" nil t)
           (setq amule:connected-p t))
          ((re-search-forward "^Not Connected" nil t)
           (setq amule:connected-p nil))
          ((re-search-forward "^Connecting" nil t)
           (setq amule:connected-p 'connecting)))))

;; (amule-connected-p)
(defun amule-connected-p ()
  (or (eq amule:connected-p 'dontknow)
      (and amule:connected-p
           (amule-running-p)
           (amule-process-alive-p))))

;; start it
(start-itimer "amule-connection" 'amule-start-connection 180 180)
(start-itimer "amule-serverstatus" 'amule-serverstatus-query 20 20)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Signalling is done by:

,----
|       ;; amule disconnected?
|       (when (and (not (amule-connected-p))
|                  (amule-running-p))
|         (xwem-osd-line-add ign-erc-osd
|                            0 27 74 27
|                            1
|                            "red"))
`----


-- 
Richard Klinda  \/
                /\  Show me your init.el and I'll you tell who you are.

<Prev in Thread] Current Thread [Next in Thread>
  • aMule "connectedness" indicator, Richard Klinda <=