From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/27954 Path: main.gmane.org!not-for-mail From: wmperry@aventail.com (William M. Perry) Newsgroups: gmane.emacs.gnus.general Subject: Re: nnimap URLs? (Was: What now?) Date: 08 Dec 1999 13:23:08 -0500 Sender: owner-ding@hpc.uh.edu Message-ID: <86ogc11ecz.fsf@localhost.localdomain> References: <84bt8kpxba.fsf@snoopy.apana.org.au> <7s4se2uqao.fsf@brutus.mts.jhu.edu> <66yh2sev.fsf@apl.washington.edu> <199912070536.AAA01920@wmperry.bp.aventail.com> <199912071609.IAA05231@newman.aventail.com> <8666y91klw.fsf@localhost.localdomain> Reply-To: wmperry@aventail.com NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1035164887 27296 80.91.224.250 (21 Oct 2002 01:48:07 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 01:48:07 +0000 (UTC) Cc: Steinar Bang , ding@gnus.org Return-Path: Original-Received: from bart.math.uh.edu (bart.math.uh.edu [129.7.128.48]) by sclp3.sclp.com (8.8.5/8.8.5) with ESMTP id NAA12510 for ; Wed, 8 Dec 1999 13:15:44 -0500 (EST) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by bart.math.uh.edu (8.9.1/8.9.1) with ESMTP id MAB21651; Wed, 8 Dec 1999 12:15:33 -0600 (CST) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Wed, 08 Dec 1999 12:15:38 -0600 (CST) Original-Received: from sclp3.sclp.com (root@sclp3.sclp.com [204.252.123.139]) by sina.hpc.uh.edu (8.9.3/8.9.3) with ESMTP id MAA10532 for ; Wed, 8 Dec 1999 12:15:22 -0600 (CST) Original-Received: from newman.aventail.com (newman.aventail.com [216.207.80.1]) by sclp3.sclp.com (8.8.5/8.8.5) with ESMTP id NAA12498 for ; Wed, 8 Dec 1999 13:14:56 -0500 (EST) Original-Received: from leo.in.aventail.com (leo.in.aventail.com [192.168.1.136]) by newman.aventail.com (8.9.3/8.9.3) with ESMTP id KAA04864; Wed, 8 Dec 1999 10:14:54 -0800 Original-Received: from localhost.localdomain.aventail.com (sighup.in.aventail.com [192.168.1.150]) by leo.in.aventail.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2448.0) id YG2W1SZH; Wed, 8 Dec 1999 10:17:25 -0800 Original-To: Simon Josefsson X-Face: O~Rn;(l][/-o1sALg4A@xpE:9-"'IR[%;,,!m7 writes: > William M. Perry writes: > > > I'm not sure if I know enough about the guts of 'imap.el' to hack this > > together or not. Fortunately, it is easy to add a new URL type. :) If > > anyone (simon?) wants to work on this, let me know and I'll concentrate on > > getting the documentation on how to do this written tonight. I would LOVE > > to see this get written. > > If there is a url-nntp.el to look at I could have a go at it. This is a work-in-progress, but should be a good starting point. Will this be able to be asynchronous? I noticed there was an imap-fetch-asynch call, but I didn't see how it ever got a callback or anything like that handed to it. If it is, you need to add: (defconst url-imap-asynchronous-p t "IMAP retrievals are asynchronous.") And the url-imap routine would get a callback and a cbargs argument that it is expected to call with the current buffer set to where the article is. If there is no data to return, it just never calls the callback. If nil is returned (or the callback is not activated), then that means there is no real data to return (ie: someone did imap://mail.server.com/ and we just go straight into gnus) to the calling app. Basically, the new URL stuff expects a buffer to look like a MIME message, with headers intact at the top, including a content-type and content-length when available. Any questions, lemme know. -Bill P. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=url-news.el ;;; url-news.el --- News Uniform Resource Locator retrieval code ;; Author: $Author: wmperry $ ;; Created: $Date: 1999/11/20 11:37:53 $ ;; Version: $Revision: 1.3 $ ;; Keywords: comm, data, processes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Copyright (c) 1993 - 1996 by William M. Perry ;;; Copyright (c) 1996 - 1999 Free Software Foundation, Inc. ;;; ;;; This file is part of GNU Emacs. ;;; ;;; GNU Emacs is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 2, or (at your option) ;;; any later version. ;;; ;;; GNU Emacs is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Emacs; see the file COPYING. If not, write to the ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;;; Boston, MA 02111-1307, USA. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (require 'url-vars) (require 'url-util) (require 'url-parse) (defconst url-nntp-default-port 119 "Default NNTP port.") (defconst url-news-default-port 119 "Default NNTP port.") (defgroup url-news nil "News related options" :group 'url) (defun url-news-open-host (host port user pass) (if (fboundp 'nnheader-init-server-buffer) (nnheader-init-server-buffer)) (nntp-open-server host (list (string-to-int port))) (if (and user pass) (progn (nntp-send-command "^.*\r?\n" "AUTHINFO USER" user) (nntp-send-command "^.*\r?\n" "AUTHINFO PASS" pass) (if (not (nntp-server-opened host)) (url-warn 'url (format "NNTP authentication to `%s' as `%s' failed" host user)))))) (defun url-news-fetch-message-id (host message-id) (let ((buf (generate-new-buffer " *url-news*"))) (if (eq ?> (aref message-id (1- (length message-id)))) nil (setq message-id (concat "<" message-id ">"))) (if (cdr-safe (nntp-request-article message-id nil host buf)) ;; Successfully retrieved the article nil (save-excursion (set-buffer buf) (insert "Content-type: text/html\n\n" "\n" " \n" " Error\n" " \n" " \n" "
\n" "

Error requesting article...

\n" "

\n" " The status message returned by the NNTP server was:" "


\n" " \n" (nntp-status-message) " \n" "

\n" "

\n" " If you If you feel this is an error, send me mail\n" "

\n" "
\n" " \n" "\n" "\n" ))) buf)) (defun url-news-fetch-newsgroup (newsgroup host) (if (string-match "^/+" newsgroup) (setq newsgroup (substring newsgroup (match-end 0)))) (if (string-match "/+$" newsgroup) (setq newsgroup (substring newsgroup 0 (match-beginning 0)))) ;; This saves us from checking new news if GNUS is already running ;; FIXME - is it relatively safe to use gnus-alive-p here? FIXME (if (or (not (get-buffer gnus-group-buffer)) (save-excursion (set-buffer gnus-group-buffer) (not (eq major-mode 'gnus-group-mode)))) (gnus)) (set-buffer gnus-group-buffer) (goto-char (point-min)) (gnus-group-read-ephemeral-group newsgroup (list 'nntp host) nil (cons (current-buffer) 'browse))) (defun url-news (article) ;; Find a news reference (let* ((host (or (url-host url) url-news-server)) (port (url-port url)) (article-brackets nil) (buf nil) (article (url-filename url))) (url-news-open-host host port (url-user url) (url-password url)) (setq article (url-unhex-string article)) (cond ((string-match "@" article) ; Its a specific article (setq buf (url-news-fetch-message-id host article))) ((string= article "") ; List all newsgroups (gnus)) (t ; Whole newsgroup (url-news-fetch-newsgroup article host))) buf)) (defun url-nntp (url) ;; Find a news reference (let* ((host (or (url-host url) url-news-server)) (port (url-port url)) (article-brackets nil) (buf nil) (article (url-filename url))) (url-news-open-host host port (url-user url) (url-password url)) (setq article (url-unhex-string article)) (cond ((string-match "@" article) ; Its a specific article (url-news-fetch-message-id host article)) ((string= article "") ; List all newsgroups (gnus)) ((string-match "/\\([0-9]+\\)$" article) ; Specific article # (setq buf (generate-new-buffer " *url-news*")) (nntp-request-article article newsgroup host buf)) (t ; Whole newsgroup (url-news-fetch-newsgroup article host))))) (provide 'url-news) --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=url-imap.el ;;; url-http.el --- IMAP retrieval routines ;; Author: $Author: wmperry $ ;; Created: $Date: 1999/12/05 16:06:01 $ ;; Version: $Revision: 1.5 $ ;; Keywords: comm, data, processes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Copyright (c) 1999 Free Software Foundation, Inc. ;;; ;;; This file is part of GNU Emacs. ;;; ;;; GNU Emacs is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 2, or (at your option) ;;; any later version. ;;; ;;; GNU Emacs is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Emacs; see the file COPYING. If not, write to the ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;;; Boston, MA 02111-1307, USA. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (require 'url-util) (require 'url-parse) (require 'imap) (defconst url-imap-default-port 143 "Default IMAP port") (defun url-imap (url) (let ((host (url-host url)) (port (url-port url)) (credentials (url-user url-user url)) (mailbox (url-unhex-string (url-filename url))) (attributes (url-attributes url))) ) ) --=-=-= --=-=-=--