* mixi.el: Try to require `url' and `w3m'.
[elisp/mixi.git] / mixi.el
diff --git a/mixi.el b/mixi.el
index 6051d7d..9755b99 100644 (file)
--- a/mixi.el
+++ b/mixi.el
@@ -98,7 +98,8 @@
 
 ;;; Code:
 
-(require 'w3m)
+(require 'url "url" t)
+(require 'w3m "w3m" t)
 (eval-when-compile (require 'cl))
 
 (defgroup mixi nil
   :type 'coding-system
   :group 'mixi)
 
+(defcustom mixi-retrieve-function
+  (if (and (require 'url "url" t)
+          (fboundp 'url-retrieve-synchronously))
+      'mixi-w3-retrieve 'mixi-w3m-retrieve)
+  "*The function for retrieving."
+  :type '(choice (const :tag "Using w3" mixi-w3-retrieve)
+                (const :tag "Using w3m" mixi-w3m-retrieve)
+                (function :format "Other function: %v\n" :size 0))
+  :group 'mixi)
+
 (defcustom mixi-default-email nil
   "*Default E-mail address that is used to login automatically."
   :type '(choice (string :tag "E-mail address")
   :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 +166,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,33 +184,66 @@ while `mixi' is waiting for a server's response."
 ¼õ¤±¤é¤ì¤Þ¤·¤¿¤Î¤Ç¡¢°ì»þŪ¤ËÁàºî¤òÄä»ß¤µ¤»¤Æ¤¤¤¿¤À¤­¤Þ¤¹¡£¿½¤·Ìõ¤´¤¶¤¤¤Þ<br>
 ¤»¤ó¤¬¡¢¤·¤Ð¤é¤¯¤Î´Ö¤ªÂÔ¤Á¤¯¤À¤µ¤¤¡£")
 
-(defun mixi-retrieve (url &optional post-data)
+(defun mixi-retrieve-1 (buffer url &optional post-data)
+  (when (string-match mixi-message-adult-contents buffer)
+    (if mixi-accept-adult-contents
+       (setq buffer (funcall mixi-retrieve-function url "submit=agree"))
+      (setq buffer (funcall mixi-retrieve-function (concat url "?")))))
+  (when (string-match mixi-warning-continuously-accessing buffer)
+    (error (mixi-message "Continuously accessing")))
+  (if (not (string-match mixi-message-continuously-accessing buffer))
+      buffer
+    (message (mixi-message "Waiting for continuously accessing..."))
+    (sit-for mixi-continuously-access-interval)
+    (funcall mixi-retrieve-function url post-data)))
+
+(defun mixi-w3-retrieve (url &optional post-data)
+  "Retrieve the URL and return getted strings."
+  (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))
+      (if (re-search-forward "HTTP/[0-9.]+ 302 Moved" nil t)
+         (if (re-search-forward
+              (concat "Location: " mixi-url "\\(.+\\)") nil t)
+             (setq ret (mixi-w3-retrieve (match-string 1) post-data))
+           (setq ret (mixi-w3-retrieve "/home.pl" post-data)))
+       (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)
+       (setq ret (mixi-retrieve-1 ret url post-data))))
+    ret))
+
+(defun mixi-w3m-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 (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))))
+         (mixi-retrieve-1 ret url post-data))))))
 
 (defconst mixi-my-id-regexp
   "<a href=\"add_diary\\.pl\\?id=\\([0-9]+\\)")
 
 (defun mixi-login (&optional email password)
   "Login to mixi."
-  (unless w3m-use-cookies
+  (when (and (eq mixi-retrieve-function 'mixi-w3m-retrieve)
+            (not w3m-use-cookies))
     (error
      (mixi-message
       "Require to accept cookies.  Please set `w3m-use-cookies' to t.")))
@@ -214,29 +251,29 @@ while `mixi' is waiting for a server's response."
                   (read-from-minibuffer (mixi-message "Login Email: "))))
        (password (or password mixi-default-password
                      (read-passwd (mixi-message "Login Password: ")))))
-    (let ((buffer (mixi-retrieve "/login.pl"
-                                (concat "email=" email
-                                        "&password=" password
-                                        "&next_url=/home.pl"
-                                        "&sticky=on"))))
+    (let ((buffer (funcall mixi-retrieve-function "/login.pl"
+                          (concat "email=" email
+                                  "&password=" password
+                                  "&next_url=/home.pl"
+                                  "&sticky=on"))))
       (unless (string-match "url=/check\\.pl\\?n=" buffer)
        (error (mixi-message "Cannot login")))
-      (setq buffer (mixi-retrieve "/check.pl?n=home.pl"))
+      (setq buffer (funcall mixi-retrieve-function "/check.pl?n=home.pl"))
       (if (string-match mixi-my-id-regexp buffer)
          (setq mixi-me (mixi-make-friend
                         (string-to-number (match-string 1 buffer))))
        (error (mixi-message "Cannot login"))))))
 
 (defun mixi-logout ()
-  (mixi-retrieve "/logout.pl"))
+  (funcall mixi-retrieve-function "/logout.pl"))
 
 (defmacro with-mixi-retrieve (url &rest body)
   `(let (buffer)
      (when ,url
-       (setq buffer (mixi-retrieve ,url))
+       (setq buffer (funcall mixi-retrieve-function ,url))
        (when (string-match "login.pl" buffer)
         (mixi-login)
-        (setq buffer (mixi-retrieve ,url))))
+        (setq buffer (funcall mixi-retrieve-function ,url))))
      ,@body))
 (put 'with-mixi-retrieve 'lisp-indent-function 'defun)
 
@@ -266,6 +303,7 @@ while `mixi' is waiting for a server's response."
     ;; FIXME: Sort? Now order by newest.
     (reverse ids)))
 
+;; stolen (and modified) from shimbun.el
 (defun mixi-remove-markup (string)
   "Remove markups from STRING."
   (with-temp-buffer
@@ -282,7 +320,6 @@ while `mixi' is waiting for a server's response."
       (goto-char (point-min))
       (while (re-search-forward "\r" nil t)
        (replace-match "\n" t t)))
-    (w3m-decode-entities)
     (buffer-string)))
 
 ;; Cache.
@@ -333,7 +370,8 @@ while `mixi' is waiting for a server's response."
 (defvar mixi-friend-cache (make-hash-table :test 'equal))
 (defun mixi-make-friend (id &optional nick)
   "Return a friend object."
-  (mixi-make-cache id (cons 'mixi-friend (vector nil id nick nil))
+  (mixi-make-cache id (cons 'mixi-friend (vector nil id nick nil nil nil nil
+                                                nil nil nil nil nil nil nil))
                   mixi-friend-cache))
 
 (defun mixi-make-me ()
@@ -353,29 +391,71 @@ while `mixi' is waiting for a server's response."
 
 (defconst mixi-friend-nick-regexp
   "<img alt=\"\\*\" src=\"http://img\\.mixi\\.jp/img/dot0\\.gif\" width=\"1\" height=\"5\"><br>\n\\(.*\\)¤µ¤ó([0-9]+)")
-(defconst mixi-friend-name-regexp
-  "<td BGCOLOR=#F2DDB7 WIDTH=80 NOWRAP><font COLOR=#996600>̾&nbsp;Á°</font></td>\n<td WIDTH=345>\\([^<]+\\)</td>")
-(defconst mixi-my-name-regexp
-  "<td BGCOLOR=#F2DDB7 WIDTH=80 NOWRAP><font COLOR=#996600>̾ Á°</font></td>\n\n<td WIDTH=345>\\([^<]+\\)</td>")
+(defconst mixi-friend-name-sex-regexp
+  "<td BGCOLOR=#F2DDB7 WIDTH=80 NOWRAP><font COLOR=#996600>̾\\(&nbsp;\\| \\)Á°</font></td>\n+<td WIDTH=345>\\([^<]+\\) (\\([Ã˽÷]\\)À­)</td>")
+(defconst mixi-friend-address-regexp
+  "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¸½½»½ê</font></td>\n<td>\\(.+\\)\\(\n.+\n\\)?</td></tr>")
+(defconst mixi-friend-age-regexp
+  "<td BGCOLOR=#F2DDB7><font COLOR=#996600>ǯ\\(&nbsp;\\| \\)Îð</font></td>\n<td>\\([0-9]+\\)ºÐ\\(\n.+\n\\)?</td></tr>")
+(defconst mixi-friend-birthday-regexp
+  "<td BGCOLOR=#F2DDB7><font COLOR=#996600>ÃÂÀ¸Æü</font></td>\n<td>\\([0-9]+\\)·î\\([0-9]+\\)Æü\\(\n.+\n\\)?</td></tr>")
+(defconst mixi-friend-blood-type-regexp
+  "<td BGCOLOR=#F2DDB7><font COLOR=#996600>·ì±Õ·¿</font></td>\n<td>\\([ABO]B?\\)·¿\\(\n\n\\)?</td></tr>")
+(defconst mixi-friend-birthplace-regexp
+  "<td BGCOLOR=#F2DDB7><font COLOR=#996600>½Ð¿ÈÃÏ</font>\n?</td>\n<td>\\(.+\\)\\(\n.+\n\\)?</td></tr>")
+(defconst mixi-friend-hobby-regexp
+  "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¼ñ\\(&nbsp;\\| \\)Ì£</font></td>\n<td>\\(.+\\)</td></tr>")
+(defconst mixi-friend-job-regexp
+  "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¿¦\\(&nbsp;\\| \\)¶È</font></td>\n<td>\\(.+\\)\\(\n.+\n\\)?</td></tr>")
+(defconst mixi-friend-organization-regexp
+  "<td BGCOLOR=#F2DDB7><font COLOR=#996600>½ê\\(&nbsp;\\| \\)°</font></td>\n<td[^>]*>\\(.+\\)\\(\n.+\n\\)?</td></tr>")
+(defconst mixi-friend-profile-regexp
+  "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¼«¸Ê¾Ò²ð</font></td>\n<td CLASS=h120>\\(.+\\)</td></tr>")
 
 (defun mixi-friend-realize (friend)
   "Realize a FRIEND."
   ;; FIXME: Check a expiration of cache?
   (unless (mixi-friend-realize-p friend)
-    (let (name)
+    (let (buf)
       (with-mixi-retrieve (mixi-friend-page friend)
-       (if (string-match mixi-friend-nick-regexp buffer)
-           (mixi-friend-set-nick friend (match-string 1 buffer))
-         (signal 'error (list 'cannot-find-nick friend)))
-       (when (string-match mixi-friend-name-regexp buffer)
-         (setq name (match-string 1 buffer))))
-      ;; For getting my name.
-      (unless name
+       (setq buf buffer))
+      (if (string-match mixi-friend-nick-regexp buf)
+         (mixi-friend-set-nick friend (match-string 1 buf))
+       (signal 'error (list 'cannot-find-nick friend)))
+      ;; For getting my profile.
+      (unless (string-match mixi-friend-name-sex-regexp buf)
        (with-mixi-retrieve "/show_profile.pl"
-         (if (string-match mixi-my-name-regexp buffer)
-             (setq name (match-string 1 buffer))
-           (signal 'error (list 'cannot-find-name friend)))))
-      (mixi-friend-set-name friend name))
+         (setq buf buffer)))
+      (if (string-match mixi-friend-name-sex-regexp buf)
+         (progn
+           (mixi-friend-set-name friend (match-string 2 buf))
+           (mixi-friend-set-sex friend
+                                (if (string= (match-string 3 buf) "ÃË")
+                                    'male 'female)))
+       (signal 'error (list 'cannot-find-name-or-sex friend)))
+      (when (string-match mixi-friend-address-regexp buf)
+       (mixi-friend-set-address friend (match-string 1 buf)))
+      (when (string-match mixi-friend-age-regexp buf)
+       (mixi-friend-set-age
+        friend (string-to-number (match-string 2 buf))))
+      (when (string-match mixi-friend-birthday-regexp buf)
+       (mixi-friend-set-birthday
+        friend (list (string-to-number (match-string 1 buf))
+                     (string-to-number (match-string 2 buf)))))
+      (when (string-match mixi-friend-blood-type-regexp buf)
+       (mixi-friend-set-blood-type friend (intern (match-string 1 buf))))
+      (when (string-match mixi-friend-birthplace-regexp buf)
+       (mixi-friend-set-birthplace friend (match-string 1 buf)))
+      (when (string-match mixi-friend-hobby-regexp buf)
+       (mixi-friend-set-hobby
+        friend (split-string (match-string 2 buf) ", ")))
+      (when (string-match mixi-friend-job-regexp buf)
+       (mixi-friend-set-job friend (match-string 2 buf)))
+      (when (string-match mixi-friend-organization-regexp buf)
+       (mixi-friend-set-organization friend (match-string 2 buf)))
+      (when (string-match mixi-friend-profile-regexp buf)
+       (mixi-friend-set-profile
+        friend (mixi-remove-markup (match-string 1 buf)))))
     (mixi-friend-touch friend)))
 
 (defun mixi-friend-realize-p (friend)
@@ -405,6 +485,76 @@ while `mixi' is waiting for a server's response."
   (mixi-friend-realize friend)
   (aref (cdr friend) 3))
 
+(defun mixi-friend-sex (friend)
+  "Return the sex of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (mixi-friend-realize friend)
+  (aref (cdr friend) 4))
+
+(defun mixi-friend-address (friend)
+  "Return the address of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (mixi-friend-realize friend)
+  (aref (cdr friend) 5))
+
+(defun mixi-friend-age (friend)
+  "Return the age of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (mixi-friend-realize friend)
+  (aref (cdr friend) 6))
+
+(defun mixi-friend-birthday (friend)
+  "Return the birthday of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (mixi-friend-realize friend)
+  (aref (cdr friend) 7))
+
+(defun mixi-friend-blood-type (friend)
+  "Return the blood type of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (mixi-friend-realize friend)
+  (aref (cdr friend) 8))
+
+(defun mixi-friend-birthplace (friend)
+  "Return the birthplace of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (mixi-friend-realize friend)
+  (aref (cdr friend) 9))
+
+(defun mixi-friend-hobby (friend)
+  "Return the hobby of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (mixi-friend-realize friend)
+  (aref (cdr friend) 10))
+
+(defun mixi-friend-job (friend)
+  "Return the job of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (mixi-friend-realize friend)
+  (aref (cdr friend) 11))
+
+(defun mixi-friend-organization (friend)
+  "Return the organization of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (mixi-friend-realize friend)
+  (aref (cdr friend) 12))
+
+(defun mixi-friend-profile (friend)
+  "Return the pforile of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (mixi-friend-realize friend)
+  (aref (cdr friend) 13))
+
 (defun mixi-friend-touch (friend)
   "Set the timestamp of FRIEND."
   (unless (mixi-friend-p friend)
@@ -423,6 +573,66 @@ while `mixi' is waiting for a server's response."
     (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
   (aset (cdr friend) 3 name))
 
+(defun mixi-friend-set-sex (friend sex)
+  "Set the sex of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (aset (cdr friend) 4 sex))
+
+(defun mixi-friend-set-address (friend address)
+  "Set the address of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (aset (cdr friend) 5 address))
+
+(defun mixi-friend-set-age (friend age)
+  "Set the age of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (aset (cdr friend) 6 age))
+
+(defun mixi-friend-set-birthday (friend birthday)
+  "Set the birthday of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (aset (cdr friend) 7 birthday))
+
+(defun mixi-friend-set-blood-type (friend blood-type)
+  "Set the blood type of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (aset (cdr friend) 8 blood-type))
+
+(defun mixi-friend-set-birthplace (friend birthplace)
+  "Set the birthplace of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (aset (cdr friend) 9 birthplace))
+
+(defun mixi-friend-set-hobby (friend hobby)
+  "Set the hobby of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (aset (cdr friend) 10 hobby))
+
+(defun mixi-friend-set-job (friend job)
+  "Set the job of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (aset (cdr friend) 11 job))
+
+(defun mixi-friend-set-organization (friend organization)
+  "Set the organization of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (aset (cdr friend) 12 organization))
+
+(defun mixi-friend-set-profile (friend profile)
+  "Set the profile of FRIEND."
+  (unless (mixi-friend-p friend)
+    (signal 'wrong-type-argument (list 'mixi-friend-p friend)))
+  (aset (cdr friend) 13 profile))
+
 (defmacro mixi-friend-list-page (&optional friend)
   `(concat "/list_friend.pl?page=%d"
           (when ,friend (concat "&id=" (number-to-string
@@ -675,7 +885,7 @@ while `mixi' is waiting for a server's response."
 (defun mixi-make-community (id &optional name)
   "Return a community object."
   (mixi-make-cache id (cons 'mixi-community (vector nil id name nil nil nil
-                                                   nil))
+                                                   nil nil nil nil))
                   mixi-community-cache))
 
 (defmacro mixi-community-p (community)
@@ -696,6 +906,13 @@ while `mixi' is waiting for a server's response."
   "<td BGCOLOR=#F2DDB7><font COLOR=#996600>´ÉÍý¿Í</font></td>\n<td>\n\n<a href=\"\\(home\\.pl\\|show_friend\\.pl\\?id=\\([0-9]+\\)\\)\">\n\\(.+\\)</a>")
 (defconst mixi-community-category-regexp
   "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¥«¥Æ¥´¥ê</font></td>\n<td>\\([^<]+\\)</td>")
+(defconst mixi-community-members-regexp
+  "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¥á¥ó¥Ð¡¼¿ô</font></td>\n<td>\\([0-9]+\\)¿Í</td></tr>")
+(defconst mixi-community-open-level-regexp
+  "<td BGCOLOR=#F2DDB7><font COLOR=#996600>»²²Ã¾ò·ï¤È<br>¸ø³«¥ì¥Ù¥ë</font></td>
+<td>\\(.+\\)</td></tr>")
+(defconst mixi-community-authority-regexp
+  "<td BGCOLOR=#F2DDB7><font COLOR=#996600>¥È¥Ô¥Ã¥¯ºîÀ®¤Î¸¢¸Â</font></td>\n<td>\\(.+\\)</td></tr>")
 (defconst mixi-community-description-regexp
   "<td CLASS=h120>\\(.+\\)</td>")
 
@@ -728,8 +945,19 @@ while `mixi' is waiting for a server's response."
        (if (string-match mixi-community-category-regexp buffer)
            (mixi-community-set-category community (match-string 1 buffer))
          (signal 'error (list 'cannot-find-category community)))
+       (if (string-match mixi-community-members-regexp buffer)
+           (mixi-community-set-members
+            community (string-to-number (match-string 1 buffer)))
+         (signal 'error (list 'cannot-find-members community)))
+       (if (string-match mixi-community-open-level-regexp buffer)
+           (mixi-community-set-open-level community (match-string 1 buffer))
+         (signal 'error (list 'cannot-find-open-level community)))
+       (if (string-match mixi-community-authority-regexp buffer)
+           (mixi-community-set-authority community (match-string 1 buffer))
+         (signal 'error (list 'cannot-find-authority community)))
        (if (string-match mixi-community-description-regexp buffer)
-           (mixi-community-set-description community (match-string 1 buffer))
+           (mixi-community-set-description
+            community (mixi-remove-markup (match-string 1 buffer)))
          (signal 'error (list 'cannot-find-description community)))))
     (mixi-community-touch community)))
 
@@ -774,12 +1002,33 @@ while `mixi' is waiting for a server's response."
   (mixi-community-realize community)
   (aref (cdr community) 5))
 
+(defun mixi-community-members (community)
+  "Return the members of COMMUNITY."
+  (unless (mixi-community-p community)
+    (signal 'wrong-type-argument (list 'mixi-community-p community)))
+  (mixi-community-realize community)
+  (aref (cdr community) 6))
+
+(defun mixi-community-open-level (community)
+  "Return the open-level of COMMUNITY."
+  (unless (mixi-community-p community)
+    (signal 'wrong-type-argument (list 'mixi-community-p community)))
+  (mixi-community-realize community)
+  (aref (cdr community) 7))
+
+(defun mixi-community-authority (community)
+  "Return the authority of COMMUNITY."
+  (unless (mixi-community-p community)
+    (signal 'wrong-type-argument (list 'mixi-community-p community)))
+  (mixi-community-realize community)
+  (aref (cdr community) 8))
+
 (defun mixi-community-description (community)
   "Return the description of COMMUNITY."
   (unless (mixi-community-p community)
     (signal 'wrong-type-argument (list 'mixi-community-p community)))
   (mixi-community-realize community)
-  (aref (cdr community) 6))
+  (aref (cdr community) 9))
 
 (defun mixi-community-touch (community)
   "Set the timestamp of COMMUNITY."
@@ -813,11 +1062,29 @@ while `mixi' is waiting for a server's response."
     (signal 'wrong-type-argument (list 'mixi-community-p community)))
   (aset (cdr community) 5 category))
 
+(defun mixi-community-set-members (community members)
+  "Set the name of COMMUNITY."
+  (unless (mixi-community-p community)
+    (signal 'wrong-type-argument (list 'mixi-community-p community)))
+  (aset (cdr community) 6 members))
+
+(defun mixi-community-set-open-level (community open-level)
+  "Set the name of COMMUNITY."
+  (unless (mixi-community-p community)
+    (signal 'wrong-type-argument (list 'mixi-community-p community)))
+  (aset (cdr community) 7 open-level))
+
+(defun mixi-community-set-authority (community authority)
+  "Set the name of COMMUNITY."
+  (unless (mixi-community-p community)
+    (signal 'wrong-type-argument (list 'mixi-community-p community)))
+  (aset (cdr community) 8 authority))
+
 (defun mixi-community-set-description (community description)
   "Set the name of COMMUNITY."
   (unless (mixi-community-p community)
     (signal 'wrong-type-argument (list 'mixi-community-p community)))
-  (aset (cdr community) 6 description))
+  (aset (cdr community) 9 description))
 
 (defmacro mixi-community-list-page (&optional friend)
   `(concat "/list_community.pl?page=%d"
@@ -1119,7 +1386,7 @@ while `mixi' is waiting for a server's response."
 (defun mixi-get-comments (parent)
   "Get comments of PARENT."
   (unless (mixi-object-p parent)
-    (signal 'wrong-type-argument (list 'mixi-object-p object)))
+    (signal 'wrong-type-argument (list 'mixi-object-p parent)))
   (let* ((name (mixi-object-name parent))
         (list-page (intern (concat mixi-object-prefix name
                                    "-comment-list-page")))
@@ -1143,7 +1410,7 @@ while `mixi' is waiting for a server's response."
 (defconst mixi-new-comment-list-regexp
   "<a href=\"view_diary\\.pl\\?id=\\([0-9]+\\)&owner_id=\\([0-9]+\\)&comment_count=[0-9]+\" class=\"new_link\">")
 
-(defvar mixi-new-community-max-pages nil)
+(defvar mixi-new-comment-max-pages nil)
 (defun mixi-get-new-comments ()
   "Get new comments."
   (let ((items (mixi-get-matched-items (mixi-new-comment-list-page)
@@ -1156,27 +1423,6 @@ while `mixi' is waiting for a server's response."
                (mixi-get-comments diary)))
            items)))
 
-;;
-
-;; FIXME: Move to the class method.
-
-;; FIXME: When it got some results, this function doesn't work fine.
-(defun mixi-friend-to-id (friend)
-  (with-mixi-retrieve (concat "/search.pl?submit=main&nickname="
-                             (w3m-url-encode-string friend
-                                                    mixi-coding-system))
-    (when (string-match "show_friend\\.pl\\?id=\\([0-9]+\\)" buffer)
-      (string-to-number (match-string 1 buffer)))))
-
-;; FIXME: When it got some results, this function doesn't work fine.
-(defun mixi-community-to-id (community)
-  (with-mixi-retrieve (concat "/search_community.pl?sort="
-                             "&type=com&submit=main&keyword="
-                             (w3m-url-encode-string community
-                                                    mixi-coding-system))
-    (when (string-match "view_community\\.pl\\?id=\\([0-9]+\\)" buffer)
-      (string-to-number (match-string 1 buffer)))))
-
 (provide 'mixi)
 
 ;;; mixi.el ends here