1 ;;; gnus-offline.el --- To process mail & news at offline environment.
2 ;;; $Id: gnus-offline.el,v 1.1.4.2 1999-01-06 22:26:30 yamaoka Exp $
4 ;;; Copyright (C) 1998 Tatsuya Ichikawa
6 ;;; Author: Tatsuya Ichikawa <t-ichi@po.shiojiri.ne.jp>
7 ;;; Yukihiro Ito <ito@rs.civil.tohoku.ac.jp>
8 ;;; Hidekazu Nakamura <u90121@uis-inf.co.jp>
11 ;;; Keywords: news , mail , offline , gnus
14 ;;; Keiichi Suzuki <kei-suzu@mail.wbs.or.jp>
15 ;;; KORIYAMA Naohiro <kory@ba2.so-net.or.jp>
16 ;;; Katsumi Yamaoka <yamaoka@jpl.org>
18 ;;; This file is part of Semi-gnus.
20 ;;; GNU Emacs is free software; you can redistribute it and/or modify
21 ;;; it under the terms of the GNU General Public License as published by
22 ;;; the Free Software Foundation; either version 2, or (at your option)
23 ;;; any later version.
25 ;;; GNU Emacs is distributed in the hope that it will be useful,
26 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
27 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 ;;; GNU General Public License for more details.
30 ;;; You should have received a copy of the GNU General Public License
31 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
32 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
33 ;;; Boston, MA 02111-1307, USA.
37 ;;; This file works only with after version of Emacs 19.30.
38 ;;; This file needs miee.el and SEMI.
39 ;;; If you set gnus-offline-drafts-queue-type to 'agent , you don't need
41 ;;; You must use Semi-gnus 6.X.X.
45 ;;; Add following code at the end in your .emacs
47 ;;; (load "gnus-ofsetup")
48 ;;; (gnus-setup-for-offline)
49 ;;; (load gnus-offline-setting-file)
51 ;;; If you use gnus-agent as souper , put gnus-agent setup code in you .gnus.el
53 ;;; If you use nnspool as souper , put following code in your .emacs before
54 ;;; gnus-offline setting.
56 ;;; Then , put hang.exe in exec-path directory.
58 ;;; In Gnus group buffer , type g to get all news and mail.
59 ;;; Then send mail and news in spool directory.
62 ;;; gnus-offline-dialup-program-arguments
63 ;;; ... List of dialup program arguments.
64 ;;; gnus-offline-hangup-program-arguments
65 ;;; ... List of hangup program arguments.
66 ;;; gnus-offline-mail-treat-environ ... toggle sending mail online/offline.
67 ;;; gnus-offline-articles-to-fetch ... toggle fetch articles.
68 ;;; both->mail->news->both...
69 ;;; gnus-offline-load-hook ... hook before gnus-offline load.
70 ;;; gnus-offline-before-online-hook ... hook before all online jobs.
71 ;;; gnus-offline-after-online-hook ... hook after all online jobs.
72 ;;; gnus-offline-interval-time ... Interval time to do all online jobs.
74 ;;; gnus-offline-dialup-function ... Function to diualup.
75 ;;; gnus-offline-hangup-function ... Function to hangup.
79 (eval '(run-hooks 'gnus-offline-load-hook))
86 (unless (and (condition-case ()
92 (defmacro defgroup (&rest args))
93 (defmacro defcustom (symbol value &optional doc &rest args)
94 (` (defvar (, symbol) (, value) (, doc))))
96 (defgroup gnus-offline nil
97 "Offline backend utility for Gnus."
98 :prefix "gnus-offline-"
102 (defconst gnus-offline-version-number "2.02")
103 (defconst gnus-offline-codename
105 ;; "This is the time" ; 2.00
106 ;; "A matter of trust"
111 (defconst gnus-offline-version (format "Gnus offline backend utiliy v%s"
112 gnus-offline-version-number))
114 (defcustom gnus-offline-dialup-program-arguments nil
115 "*Program arguments of gnus-offline-dialup-program."
117 :type '(repeat (string :tag "Argument")))
119 (defcustom gnus-offline-hangup-program-arguments nil
120 "*Program arguments of gnus-offline-hangup-program."
122 :type '(repeat (string :tag "Argument")))
124 (defcustom gnus-offline-auto-hangup t
125 "*Whether dialup-network automatically hang up when all online jobs has done."
129 (defcustom gnus-offline-load-hook nil
130 "*Hook to be run after the gnus-offline package has been loaded."
134 (defcustom gnus-offline-before-online-hook nil
135 "*Hook to be run before all online jobs."
139 (defcustom gnus-offline-after-online-hook nil
140 "*Hook to be run after all online jobs."
144 (defcustom gnus-offline-mail-treat-environ 'offline
145 "*If online , gnus-offline send all mail under online environ.
146 If offline , gnus-offline send all mail temporary to spool dir."
148 :type '(choice (const offline)
151 (defcustom gnus-offline-articles-to-fetch 'both
152 "*If both , gnus-offline fetch mail and news articles.
153 If mail , gnus-offline only fetch mail articles.
154 If news , gnus-offline only fetch news articles."
156 :type '(choice (const both)
160 (defcustom gnus-offline-interval-time 0
161 "*Interval time(minutes) to do online jobs.
162 If set to 0 , timer call is disabled."
166 (defcustom gnus-offline-mail-group-level 1
167 "*Group level for mail group."
171 (defcustom gnus-offline-after-empting-spool-hook nil
172 "*Hook to be run before empting spool."
176 (defcustom gnus-offline-before-empting-spool-hook nil
177 "*Hook to be run after empting spool."
181 (defcustom gnus-offline-dialup-function 'gnus-offline-connect-server
182 "*Function to dialup."
186 (defcustom gnus-offline-hangup-function 'gnus-offline-hangup-line
187 "*Function to hangup."
191 ;;; Internal variables.
192 (defvar gnus-offline-connected nil
193 "*If value is t , dialup line is connected status.
194 If value is nil , dialup line is disconnected status.")
196 (defvar gnus-offline-news-fetch-method nil
197 "*Method to fetch news articles.")
199 (defvar gnus-offline-mail-fetch-method nil
200 "*Method to fetch mail articles.")
202 (defvar gnus-offline-header-string
203 (format "%s - \"%s\""
205 gnus-offline-codename)
206 "*Header string for gnus-offline.")
208 (defvar gnus-offline-stored-group-level nil
209 "*Mail Group level before changing.")
211 (defvar gnus-offline-movemail-arguments nil
212 "*All command line arguments of exec-directory/movemail.")
214 ;;; Temporary variable:
221 (defvar gnus-offline-error-buffer " *Error*")
222 (defvar gnus-offline-map (make-sparse-keymap))
224 ;;; To silence byte compiler
226 (fboundp 'eval-when-compile)
230 (eval-region (point-min) (point)))
231 (let (case-fold-search)
235 (unless (boundp symbol)
236 (make-local-variable symbol)
237 (eval (list 'setq symbol nil)))))
240 sendmail-to-spool-directory
241 news-spool-request-post-directory
249 gnus-agent-handle-level
251 (make-local-variable 'byte-compile-warnings)
252 (setq byte-compile-warnings nil))))
254 (put 'gnus-offline-set-unplugged-state 'menu-enable 'gnus-offline-connected)
255 (if (eq system-type 'windows-nt)
256 (define-process-argument-editing "/hang\\.exe\\'"
257 (lambda (x) (general-process-argument-editing-function
258 x nil t t nil t t))))
263 (defun gnus-offline-setup ()
264 "*Initialize gnus-offline function"
266 ;; Load setting file - required.
267 (load gnus-offline-setting-file)
270 (gnus-offline-define-menu-and-key)
272 ;; To transfer Mail/News function.
273 (cond ((eq gnus-offline-mail-treat-environ 'offline)
274 ;; send mail under offline environ.
275 (gnus-offline-set-offline-sendmail-function))
276 ((eq gnus-offline-mail-treat-environ 'online)
277 ;; send mail under offline environ.
278 (gnus-offline-set-online-sendmail-function))))
279 ;; (add-hook 'gnus-group-mode-hook 'gnus-offline-setup))
282 ;; Setting Error check.
283 (defun gnus-offline-error-check ()
284 ;; Check gnus-agent and nnspool setting.
285 (cond ((eq gnus-offline-news-fetch-method 'nnagent)
286 ;; nnagent and gnus-agent loaded ??
287 (if (not (and (featurep 'gnus-agent)
288 (featurep 'nnagent)))
290 (get-buffer-create gnus-offline-error-buffer)
291 (set-buffer gnus-offline-error-buffer)
293 (insert "WARNING!!: gnus-agent.el or nnagent.el is not loaded.\n")
294 (insert "Please check your .emacs or .gnus.el to work gnus-agent fine.")
295 (pop-to-buffer gnus-offline-error-buffer))))
297 ((eq gnus-offline-news-fetch-method 'nnspool)
298 (if (not (featurep 'nnspool))
300 (get-buffer-create gnus-offline-error-buffer)
301 (set-buffer gnus-offline-error-buffer)
303 (insert "WARNING!!: nnspool.el is not loaded.\n")
304 (insert "Please check your .emacs or .gnus.el to work nnspool fine.")
305 (pop-to-buffer gnus-offline-error-buffer))))))
308 (defun gnus-offline-set-offline-sendmail-function ()
309 "*Initialize sendmail-function when unplugged status."
310 (if (eq gnus-offline-drafts-queue-type 'miee)
312 (if (eq gnus-offline-news-fetch-method 'nnagent)
313 (setq gnus-agent-send-mail-function 'sendmail-to-spool-in-gnspool-format))
314 (setq message-send-mail-function 'sendmail-to-spool-in-gnspool-format))
315 (setq gnus-agent-send-mail-function (gnus-offline-set-online-sendmail-function)
316 message-send-mail-function 'gnus-agent-send-mail)))
318 (defun gnus-offline-set-online-sendmail-function ()
319 "*Initialize sendmail-function when plugged status."
320 (if (eq gnus-offline-MTA-type 'smtp)
321 (setq message-send-mail-function 'message-send-mail-with-smtp)
322 (setq message-send-mail-function 'message-send-mail-with-sendmail)))
324 (defun gnus-offline-set-offline-post-news-function ()
325 "*Initialize sendnews-function when unplugged status."
326 (if (eq gnus-offline-drafts-queue-type 'miee)
327 (setq message-send-news-function 'gnspool-request-post)))
329 (defun gnus-offline-set-online-post-news-function ()
330 "*Initialize sendnews-function when plugged status."
331 (setq message-send-news-function 'message-send-news-with-gnus))
333 ;; Get new news jobs. (gnus-agent and nnspool)
335 (defun gnus-offline-gnus-get-new-news (&optional arg)
336 "*Override function \"gnus-group-get-new-news\"."
338 (run-hooks 'gnus-offline-before-online-hook)
339 (if (functionp gnus-offline-dialup-function)
340 (funcall gnus-offline-dialup-function))
341 (gnus-offline-get-new-news-function)
342 (gnus-group-get-new-news arg))
347 (defun gnus-offline-connect-server ()
349 ;; Dialup if gnus-offline-dialup-program is specified
350 (if (stringp gnus-offline-dialup-program)
352 (message "Dialing ...")
353 (apply 'call-process gnus-offline-dialup-program nil nil nil
354 gnus-offline-dialup-program-arguments)
356 (message "Dialing ... done."))))
359 ;; Jobs before get new news , send mail and post news.
361 (defun gnus-offline-get-new-news-function ()
362 "*Prepare to get new news/mail."
363 ;; Set mail group level
364 (if (eq gnus-offline-articles-to-fetch 'mail)
365 (gnus-offline-set-mail-group-level gnus-offline-mail-group-level))
367 ;; Set to online environ.
368 (setq gnus-offline-connected t)
370 ;; Set send mail/news functions to online functions.
371 (gnus-offline-set-online-sendmail-function)
372 (gnus-offline-set-online-post-news-function)
373 (message "Set to online status.")
376 (if (eq gnus-offline-articles-to-fetch 'news)
377 (gnus-offline-disable-fetch-mail))
379 ;; fetch both mail and news. or Only mail.
380 (gnus-offline-enable-fetch-news)
381 (if (memq gnus-offline-articles-to-fetch '(both mail))
382 (gnus-offline-enable-fetch-mail))
384 ;; fetch only mail for gnus-agent
385 (if (and (eq gnus-offline-news-fetch-method 'nnagent)
386 (eq gnus-offline-articles-to-fetch 'mail))
387 (setq gnus-agent-handle-level gnus-offline-mail-group-level)))
390 ;; Change mail group level to handle only mail.
392 (defun gnus-offline-set-mail-group-level (level)
393 "*Set nnm* group level."
394 (switch-to-buffer gnus-group-buffer)
395 (goto-char (point-min))
397 ;; Save current level
398 (if (not gnus-offline-stored-group-level)
399 (while (re-search-forward " nnm" nil t)
400 (setq gnus-offline-stored-group-level
401 (append gnus-offline-stored-group-level
402 (list (gnus-group-group-level)))))
406 (goto-char (point-min))
407 (while (re-search-forward " nnm" nil t)
408 (gnus-group-set-current-level 1 level)
413 ;; Restore mail group level
415 (defun gnus-offline-restore-mail-group-level ()
416 "*Restore nnm* group level."
417 (switch-to-buffer gnus-group-buffer)
418 (goto-char (point-min))
420 (while (re-search-forward " nnm" nil t)
421 (gnus-group-set-current-level 1 (nth num gnus-offline-stored-group-level))
424 (beginning-of-line)))
426 ;; Jobs after getting new news.
428 (defun gnus-offline-after-get-new-news ()
429 "*After getting news and mail jobs."
430 (if (memq gnus-offline-articles-to-fetch '(both mail))
433 ;; send mail/news in spool
434 (gnus-offline-empting-spool)
435 (if (eq gnus-offline-articles-to-fetch 'mail)
437 ;; Send only mail and hang up...
438 (if (and gnus-offline-connected
439 gnus-offline-auto-hangup)
440 (gnus-offline-set-unplugged-state))
441 ;; Disable fetch mail.
442 (gnus-offline-disable-fetch-mail)
443 (gnus-offline-after-jobs-done)))))
446 (if (memq gnus-offline-articles-to-fetch '(both news))
448 (if gnus-offline-connected
449 (cond ((eq gnus-offline-news-fetch-method 'nnagent)
450 ;; Get New News (gnus-agent)
451 (gnus-agent-toggle-plugged t)
454 (gnus-agent-fetch-session)
456 ;; Hang Up line. then set to offline status.
457 (if (and gnus-offline-connected
458 gnus-offline-auto-hangup)
459 (gnus-offline-set-unplugged-state))
461 ;; All online jobs has done.
462 (gnus-offline-after-jobs-done))
464 (if (eq gnus-offline-news-fetch-method 'nnspool)
465 ;; Get New News (nnspool)
466 (gnspool-get-news))))))))
468 ;; Disable fetch mail
470 (defun gnus-offline-disable-fetch-mail ()
471 "*Set do not fetch mail."
472 (setq nnmail-spool-file nil))
476 (defun gnus-offline-enable-fetch-mail ()
477 "*Set to fetch mail."
478 (setq gnus-offline-mail-fetch-method 'nnmail)
479 (setq nnmail-movemail-program 'pop3-fma-movemail)
480 (setq nnmail-spool-file (append
481 pop3-fma-local-spool-file-alist
485 pop3-fma-spool-file-alist))))
489 (defun gnus-offline-enable-fetch-news ()
490 "*Set to fetch news."
491 (if (eq gnus-offline-news-fetch-method 'nnagent)
493 (setq gnus-agent-handle-level gnus-level-subscribed)
494 (gnus-agent-toggle-plugged t))))
497 ;; Add your custom header.
499 (defun gnus-offline-add-custom-header (header string)
500 "*Add X-Gnus-Offline-Backend header to Mail/News message."
502 (progn (goto-char (point-min))
504 (concat "^" (regexp-quote mail-header-separator) "\n"))
506 (goto-char (point-min))
507 (or (re-search-forward (concat "^" header) delimline t)
509 (goto-char delimline)
512 (setq hdr (concat header " "))
513 (setq str (concat hdr string))
514 (setq hdr (concat str "\n"))
515 (insert-string hdr)))))
517 ;; Add X-Offline-Backend header.
519 (defun gnus-offline-message-add-header ()
520 "*Add X-Gnus-Offline-Backend header to Mail/News message."
521 (if (eq gnus-offline-mail-treat-environ 'offline)
523 (if (eq gnus-offline-news-fetch-method 'nnagent)
524 (setq ver nnagent-version)
525 (setq ver nnspool-version))
526 (setq str (format "\n with %s" ver)
527 string (concat gnus-offline-header-string str))
528 (gnus-offline-add-custom-header "X-Gnus-Offline-Backend:" string))))
532 ;; Toggle plugged/unplugged
534 (defun gnus-offline-toggle-plugged (plugged)
535 "*Override function \"Jj\" - gnus-agent-toggle-plugged."
536 (interactive (list (not gnus-offline-connected)))
539 (setq gnus-offline-connected plugged)
540 (gnus-agent-toggle-plugged plugged)
541 ;; Set send mail/news function to offline functions.
542 (gnus-offline-set-online-sendmail-function)
543 (gnus-offline-set-online-post-news-function))
544 ;; Set to offline status
545 (gnus-offline-set-unplugged-state)))
547 ;; Function of hang up line.
549 (defun gnus-offline-set-unplugged-state ()
550 "*Set to unplugged state."
553 (if (functionp gnus-offline-hangup-function)
554 (funcall gnus-offline-hangup-function))
555 (setq gnus-offline-connected nil)
556 (if (eq gnus-offline-news-fetch-method 'nnagent)
557 (gnus-agent-toggle-plugged nil))
559 ;; Set send mail/news function to offline functions.
560 (gnus-offline-set-offline-sendmail-function)
561 (gnus-offline-set-offline-post-news-function)
563 (setenv "MAILHOST" nil))
565 ;; Hangup line function
567 (defun gnus-offline-hangup-line ()
568 "*Hangup line function."
569 (message "Hang up line ... ")
570 (if (stringp gnus-offline-hangup-program)
571 (apply 'start-process "hup" nil gnus-offline-hangup-program
572 gnus-offline-hangup-program-arguments))
573 (message "Hang up line ... done."))
575 ;; Hang Up line routine whe using nnspool
577 (defun gnus-offline-nnspool-hangup-line ()
578 (if (and gnus-offline-connected
579 gnus-offline-auto-hangup)
580 (gnus-offline-set-unplugged-state))
581 (gnus-offline-after-jobs-done))
583 ;; Function of all jobs has done.
585 (defun gnus-offline-after-jobs-done ()
586 "*Jobs after all online jobs."
587 (run-hooks 'gnus-offline-after-online-hook)
588 (if (eq gnus-offline-articles-to-fetch 'mail)
589 (gnus-offline-restore-mail-group-level))
590 (if (eq gnus-offline-news-fetch-method 'nnagent)
591 (or gnus-agent-expire-all
592 (gnus-offline-agent-expire)))
593 (if (and (featurep 'xemacs)
594 (fboundp 'play-sound-file))
597 (gnus-group-save-newsrc)
598 (message "All online jobs has done."))
602 ;; Toggle auto hang up
604 (defun gnus-offline-toggle-auto-hangup ()
605 "*Toggle auto hangup flag."
607 (setq string "Auto hang up logic")
608 (if gnus-offline-auto-hangup
610 (setq gnus-offline-auto-hangup nil
612 (setq gnus-offline-auto-hangup t
614 (message (format "%s %s" string str)))
616 ;; Toggle offline/online to send mail.
618 (defun gnus-offline-toggle-on/off-send-mail ()
619 "*Toggel online/offline sendmail."
621 (if (eq gnus-offline-mail-treat-environ 'offline)
623 ;; Sending mail under online environ.
624 (gnus-offline-set-online-sendmail-function)
625 (setq gnus-offline-mail-treat-environ 'online)
626 (message "Sending mail immidiately."))
627 ;; Sending mail under offline environ.
628 (gnus-offline-set-offline-sendmail-function)
629 (setq gnus-offline-mail-treat-environ 'offline)
630 (message "Sending mail temporary to spool directory.")))
632 ;; Toggle articles to fetch ... both -> mail -> news -> both
634 (defun gnus-offline-toggle-articles-to-fetch ()
635 "*Set articles to fetch... both(Mail/News) -> mail only -> News only -> both"
637 (setq string "Articles fetch from server.")
638 (cond ((eq gnus-offline-articles-to-fetch 'both)
639 (setq gnus-offline-articles-to-fetch 'mail
641 ((eq gnus-offline-articles-to-fetch 'mail)
642 (setq gnus-offline-articles-to-fetch 'news
645 (setq gnus-offline-articles-to-fetch 'both
646 str "Mail/News both")))
647 (message (format "%s %s" string str)))
649 ;; Toggle movemail program pop3.el -> movemail -> pop3.el
651 (defun gnus-offline-toggle-movemail-program ()
652 "*Toggle movemail program movemail -> pop3.el -> movemail ->..."
654 (setq string "Set nnmail-movemail-program")
655 (cond ((eq pop3-fma-movemail-type 'lisp)
656 (setq pop3-fma-movemail-type 'exe
659 (setq pop3-fma-movemail-type 'lisp
661 (message (format "%s %s" string str)))
663 ;; Send mail and Post news using Miee or gnus-agent.
665 (defun gnus-offline-empting-spool ()
666 "*Send all drafts on queue."
667 (run-hooks 'gnus-offline-before-empting-spool-hook)
668 (if (eq gnus-offline-drafts-queue-type 'miee)
669 ;; Send queued message by miee.el.
671 (if (eq gnus-offline-mail-treat-environ 'offline)
673 (message "Sending mails in spool ...")
674 ;; Using miee to send mail.
676 (message "Sending mails in spool ... done.")))
677 (message "Posting news in spool ...")
678 ;; Using miee to post news.
679 (if (and (not (stringp msspool-news-server))
680 (not msspool-news-service))
682 (setq msspool-news-server (nth 1 gnus-select-method))
683 (setq msspool-news-service 119)))
685 (message "Posting news in spool ... done."))
686 ;; Send queued message by gnus-agent
687 (message "Sending messages in spool ...")
688 (gnus-group-send-drafts)
689 (message "Sending messages in spool ... done."))
691 (run-hooks 'gnus-offline-after-empting-spool-hook))
695 (defun gnus-offline-set-interval-time ()
696 "*Set interval time for gnus-daemon."
698 (setq gnus-offline-interval-time
699 (string-to-int (read-from-minibuffer
700 (format "Interval time (now %s minutes) : "
701 gnus-offline-interval-time)
703 (if (< gnus-offline-interval-time 2)
705 (message "Retrieving message logic by timer is disabled.")
706 (setq gnus-offline-interval-time 0))
707 (message (format "Interval time set to %d minutes" gnus-offline-interval-time)))
708 (gnus-offline-processed-by-timer))
710 ;; Expire articles using gnus-agent.
712 (defun gnus-offline-agent-expire ()
713 "*Expire expirable article on News group."
719 (defun gnus-offline-define-menu-and-key ()
721 (if (eq gnus-offline-drafts-queue-type 'miee)
722 (if (featurep 'xemacs)
723 (add-hook 'gnus-group-mode-hook 'gnus-offline-define-menu-on-miee)
724 (gnus-offline-define-menu-on-miee))
725 (add-hook 'gnus-group-mode-hook 'gnus-offline-define-menu-on-agent))
726 (add-hook 'gnus-group-mode-hook
728 (local-set-key "\C-coh" 'gnus-offline-set-unplugged-state)
729 (local-set-key "\C-com" 'gnus-offline-toggle-movemail-program)
730 (local-set-key "\C-cof" 'gnus-offline-toggle-articles-to-fetch)
731 (local-set-key "\C-coo" 'gnus-offline-toggle-on/off-send-mail)
732 (local-set-key "\C-cox" 'gnus-offline-toggle-auto-hangup)
733 (local-set-key "\C-cos" 'gnus-offline-set-interval-time)
734 (substitute-key-definition
735 'gnus-group-get-new-news 'gnus-offline-gnus-get-new-news
737 (if (eq gnus-offline-news-fetch-method 'nnagent)
739 (substitute-key-definition
740 'gnus-agent-toggle-plugged 'gnus-offline-toggle-plugged
741 gnus-agent-group-mode-map)
742 (local-set-key "\C-coe" 'gnus-offline-agent-expire)))
743 (or (featurep 'xemacs)
744 (define-key gnus-group-mode-map
745 (if (eq system-type 'windows-nt) [S-mouse-2] [mouse-3])
746 'gnus-offline-popup-menu))))
747 (if (eq gnus-offline-news-fetch-method 'nnagent)
748 (add-hook 'gnus-summary-mode-hook
750 (substitute-key-definition
751 'gnus-agent-toggle-plugged 'gnus-offline-toggle-plugged
752 gnus-agent-summary-mode-map))))
753 (if (featurep 'xemacs)
754 ;; Overwrite the toolbar spec for gnus-group-mode.
755 (add-hook 'gnus-startup-hook
757 (let ((i 0) (stat t) but)
758 (while (and stat (setq but (nth i gnus-group-toolbar)))
759 (and (equal 'gnus-group-get-new-news (aref but 1))
760 (aset but 1 'gnus-offline-gnus-get-new-news)
762 (setq i (1+ i))))))))
765 (defun gnus-offline-define-menu-on-miee ()
766 "*Set and change menu bar on MIEE menu."
768 (if (featurep 'meadow)
773 ["Spool
\e$B$K$"$k5-;v$NAw?.
\e(B" news-spool-post t]
774 ["Spool
\e$B$K$"$k
\e(B Mail
\e$B$NAw?.
\e(B" mail-spool-send t]
776 ["Offline
\e$B>uBV$X
\e(B" message-offline-state (not message-offline-state)]
777 ["Online
\e$B>uBV$X
\e(B" message-online-state message-offline-state]
780 ["movemail
\e$B$N@ZBX$(
\e(B" gnus-offline-toggle-movemail-program t]
781 ["
\e$B<hF@5-;v<oN`$NJQ99
\e(B" gnus-offline-toggle-articles-to-fetch t]
782 ["Mail
\e$BAw?.J}K!
\e(B(On/Off)
\e$B$N@ZBX$(
\e(B" gnus-offline-toggle-on/off-send-mail t]
783 ["
\e$B<+F0@ZCG$N@ZBX$(
\e(B" gnus-offline-toggle-auto-hangup t]
785 ["
\e$B<hF@:Q5-;v$r>C$9
\e(B" gnus-offline-agent-expire (eq gnus-offline-news-fetch-method 'nnagent)]
786 ["
\e$B5-;v<hF@4V3V;~4V$N@_Dj
\e(B" gnus-offline-set-interval-time t]
788 ["
\e$B2s@~$N@ZCG
\e(B" gnus-offline-set-unplugged-state gnus-offline-connected])
794 ["Post news in spool" news-spool-post t]
795 ["Send mails in spool" mail-spool-send t]
797 ["Message Offline" message-offline-state (not message-offline-state)]
798 ["Message Online" message-online-state message-offline-state]
801 ["Toggle movemail program" gnus-offline-toggle-movemail-program t]
802 ["Toggle articles to fetch" gnus-offline-toggle-articles-to-fetch t]
803 ["Toggle online/offline send mail" gnus-offline-toggle-on/off-send-mail t]
804 ["Toggle auto hangup" gnus-offline-toggle-auto-hangup t]
806 ["Expire articles" gnus-offline-agent-expire (eq gnus-offline-news-fetch-method 'nnagent)]
807 ["Set interval time" gnus-offline-set-interval-time t]
809 ["Hang up Line." gnus-offline-set-unplugged-state gnus-offline-connected]
811 (and (featurep 'xemacs)
812 (easy-menu-add menu))))
814 ;; define menu without miee.
816 (defun gnus-offline-define-menu-on-agent ()
817 "*Set menu bar on OFFLINE menu."
819 gnus-offline-menu-on-agent
822 (if (featurep 'meadow)
824 ["movemail
\e$B$N@ZBX$(
\e(B" gnus-offline-toggle-movemail-program t]
825 ["
\e$B<hF@5-;v<oN`$NJQ99
\e(B" gnus-offline-toggle-articles-to-fetch t]
826 ["Mail
\e$BAw?.J}K!
\e(B(On/Off)
\e$B$N@ZBX$(
\e(B" gnus-offline-toggle-on/off-send-mail t]
827 ["
\e$B<+F0@ZCG$N@ZBX$(
\e(B" gnus-offline-toggle-auto-hangup t]
829 ["
\e$B<hF@:Q5-;v$r>C$9
\e(B" gnus-offline-agent-expire (eq gnus-offline-news-fetch-method 'nnagent)]
830 ["
\e$B5-;v<hF@4V3V;~4V$N@_Dj
\e(B" gnus-offline-set-interval-time t]
832 ["
\e$B2s@~$N@ZCG
\e(B" gnus-offline-set-unplugged-state gnus-offline-connected])
834 ["Toggle movemail program" gnus-offline-toggle-movemail-program t]
835 ["Toggle articles to fetch" gnus-offline-toggle-articles-to-fetch t]
836 ["Toggle online/offline send mail" gnus-offline-toggle-on/off-send-mail t]
837 ["Toggle auto hangup" gnus-offline-toggle-auto-hangup t]
839 ["Expire articles" gnus-offline-agent-expire (eq gnus-offline-news-fetch-method 'nnagent)]
840 ["Set interval time" gnus-offline-set-interval-time t]
842 ["Hang up Line." gnus-offline-set-unplugged-state gnus-offline-connected])))
843 (and (featurep 'xemacs)
844 (easy-menu-add gnus-offline-menu-on-agent)))
846 ;; Popup menu within the group buffer (under Emacs).
848 (defun gnus-offline-popup-menu (event)
849 "Popup menu for Gnus offline."
852 (and (boundp 'miee-popup-menu)
853 (assoc 'keymap (assoc 'Miee (assoc 'menu-bar global-map))))
854 gnus-offline-menu-on-agent))
855 (pop (x-popup-menu t menu))
856 (func (and pop (lookup-key menu (apply 'vector pop)))))
857 (and pop func (funcall func))))
861 (defun gnus-offline-processed-by-timer ()
862 "*Set timer interval."
863 (if (and (> gnus-offline-interval-time 0)
864 (not gnus-offline-connected))
866 (gnus-demon-add-handler 'gnus-offline-gnus-get-new-news
867 gnus-offline-interval-time
868 gnus-offline-interval-time))
869 (if (= gnus-offline-interval-time 0)
870 (gnus-demon-remove-handler 'gnus-offline-gnus-get-new-news t)))
873 (provide 'gnus-offline)
874 ;;; gnus-offline.el ends here