From 46e6bc973915f2a2aae27b2003dd53f10f269efb Mon Sep 17 00:00:00 2001 From: bg66 Date: Mon, 23 Oct 2006 02:06:30 +0000 Subject: [PATCH] * mixi.el: Require `url' instead of `w3m'. (mixi-retrieve): Follow the change above. (mixi-login): Ditto. (mixi-continuously-access-interval): Increase to 4.0. (mixi-verbose): Abolish. (mixi-friend-to-id): Ditto. (mixi-community-to-id): Ditto. --- ChangeLog | 10 +++++++ mixi.el | 88 ++++++++++++++++++++++++------------------------------------- 2 files changed, 45 insertions(+), 53 deletions(-) diff --git a/ChangeLog b/ChangeLog index d81a08e..6e4ad01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-10-23 OHASHI Akira + + * mixi.el: Require `url' instead of `w3m'. + (mixi-retrieve): Follow the change above. + (mixi-login): Ditto. + (mixi-continuously-access-interval): Increase to 4.0. + (mixi-verbose): Abolish. + (mixi-friend-to-id): Ditto. + (mixi-community-to-id): Ditto. + 2006-10-22 OHASHI Akira * mixi.el (mixi-make-community): New slot `members'. diff --git a/mixi.el b/mixi.el index 62900a9..2a08cb6 100644 --- a/mixi.el +++ b/mixi.el @@ -98,7 +98,7 @@ ;;; Code: -(require 'w3m) +(require 'url) (eval-when-compile (require 'cl)) (defgroup mixi nil @@ -132,7 +132,7 @@ :type 'boolean :group 'mixi) -(defcustom mixi-continuously-access-interval 3.0 +(defcustom mixi-continuously-access-interval 4.0 "*Time interval between each mixi access. Increase this value when unexpected error frequently occurs." :type 'number @@ -155,13 +155,6 @@ Increase this value when unexpected error frequently occurs." :type 'directory :group 'mixi) -(defcustom mixi-verbose t - "*Flag controls whether `mixi' should be verbose. -If it is non-ni, the `w3m-verbose' variable will be bound to nil -while `mixi' is waiting for a server's response." - :type 'boolean - :group 'mixi) - (defvar mixi-me nil) ;; Utilities. @@ -180,36 +173,46 @@ while `mixi' is waiting for a server's response." ¼õ¤±¤é¤ì¤Þ¤·¤¿¤Î¤Ç¡¢°ì»þŪ¤ËÁàºî¤òÄä»ß¤µ¤»¤Æ¤¤¤¿¤À¤­¤Þ¤¹¡£¿½¤·Ìõ¤´¤¶¤¤¤Þ
¤»¤ó¤¬¡¢¤·¤Ð¤é¤¯¤Î´Ö¤ªÂÔ¤Á¤¯¤À¤µ¤¤¡£") +;; FIXME: Don't use `url-retrieve-synchronously'? (defun mixi-retrieve (url &optional post-data) "Retrieve the URL and return getted strings." - (let ((url (w3m-expand-url url mixi-url))) - (with-temp-buffer - (let ((w3m-verbose (if mixi-verbose nil w3m-verbose))) - (if (not (string= (w3m-retrieve url nil nil post-data) "text/html")) - (error (mixi-message "Cannot retrieve")) - (w3m-decode-buffer url) - (let ((ret (buffer-substring-no-properties (point-min) (point-max)))) - (when (string-match mixi-message-adult-contents ret) - (if mixi-accept-adult-contents - (setq ret (mixi-retrieve url "submit=agree")) - (setq ret (mixi-retrieve (concat url "?"))))) - (when (string-match mixi-warning-continuously-accessing ret) - (error (mixi-message "Continuously accessing"))) - (if (not (string-match mixi-message-continuously-accessing ret)) - ret - (message (mixi-message "Waiting for continuously accessing...")) - (sit-for mixi-continuously-access-interval) - (mixi-retrieve url post-data)))))))) + (if post-data + (progn + (setq url-request-method "POST") + (setq url-request-data post-data)) + (setq url-request-method "GET") + (setq url-request-data nil)) + (let* ((url (url-expand-file-name url mixi-url)) + (buffer (url-retrieve-synchronously url)) + ret) + (unless (bufferp buffer) + (error (mixi-message "Cannot retrieve"))) + (with-current-buffer buffer + (goto-char (point-min)) + (unless (re-search-forward "HTTP/[0-9.]+ 200 OK" nil t) + (error (mixi-message "Cannot retrieve"))) + (search-forward "\n\n") + (setq ret (mm-decode-coding-string + (buffer-substring-no-properties (point) (point-max)) + mixi-coding-system)) + (kill-buffer buffer)) + (when (string-match mixi-message-adult-contents ret) + (if mixi-accept-adult-contents + (setq ret (mixi-retrieve url "submit=agree")) + (setq ret (mixi-retrieve (concat url "?"))))) + (when (string-match mixi-warning-continuously-accessing ret) + (error (mixi-message "Continuously accessing"))) + (if (not (string-match mixi-message-continuously-accessing ret)) + ret + (message (mixi-message "Waiting for continuously accessing...")) + (sit-for mixi-continuously-access-interval) + (mixi-retrieve url post-data)))) (defconst mixi-my-id-regexp "