* mixi-ja.texi: New file.
[elisp/mixi.git] / mixi-utils.el
index 58f76d7..e4cb651 100644 (file)
@@ -1,4 +1,4 @@
-;; mixi-utils.el --- Utilities for mixi object
+;; mixi-utils.el --- Utilities for mixi object -*- coding: euc-jp -*-
 
 ;; Copyright (C) 2007 OHASHI Akira
 
@@ -18,9 +18,9 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, you can either send email to this
-;; program's maintainer or write to: The Free Software Foundation,
-;; Inc.; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
                 (subject (mixi-object-title object))
                 (suffix (when add-parent
                           (concat " ("
-                                  (if (eq class 'mixi-diary)
-                                      (mixi-friend-nick
-                                       (mixi-diary-owner object))
-                                    (mixi-community-name
-                                     (mixi-bbs-community object)))
+                                  (cond ((eq class 'mixi-diary)
+                                         (mixi-friend-nick
+                                          (mixi-diary-owner object)))
+                                        ((eq class 'mixi-news)
+                                         (mixi-news-media object))
+                                        (t
+                                         (mixi-community-name
+                                          (mixi-bbs-community object))))
                                   ")"))))
             (concat prefix subject suffix))))))
 
 (defun mixi-make-content (object)
   (with-mixi-class object
     (cond ((eq class 'mixi-event)
-          (let ((limit (mixi-event-limit object)))
-            (setq limit (if limit
-                            (format-time-string "%Yǯ%m·î%dÆü" limit)
-                          "»ØÄê¤Ê¤·"))
-            (concat "<dl>"
-                    "<dt>³«ºÅÆü»þ¡§</dt>"
-                    "<dd>" (mixi-event-date object) "</dd>\n"
-                    "<dt>³«ºÅ¾ì½ê¡§</dt>"
-                    "<dd>" (mixi-event-place object) "</dd>\n"
-                    "<dt>¾ÜºÙ¡§</dt>"
-                    "<dd>" (mixi-event-detail object) "</dd>\n"
-                    "<dt>Ê罸´ü¸Â¡§</dt>"
-                    "<dd>" limit "</dd>\n"
-                    "<dt>»²²Ã¼Ô¡§</dt>"
-                    "<dd>" (mixi-event-members object) "</dd>\n"
-                    "</dl>")))
+          (concat "<dl>"
+                  "<dt>³«ºÅÆü»þ¡§</dt>"
+                  "<dd>" (mixi-event-date object) "</dd>\n"
+                  "<dt>³«ºÅ¾ì½ê¡§</dt>"
+                  "<dd>" (mixi-event-place object) "</dd>\n"
+                  "<dt>¾ÜºÙ¡§</dt>"
+                  "<dd>" (mixi-event-detail object) "</dd>\n"
+                  "<dt>Ê罸´ü¸Â¡§</dt>"
+                  "<dd>" (mixi-event-limit object) "</dd>\n"
+                  "<dt>»²²Ã¼Ô¡§</dt>"
+                  "<dd>" (mixi-event-members object) "</dd>\n"
+                  "</dl>"))
          ((eq class 'mixi-friend)
           (if (mixi-object-realized-p object)
               (let ((sex (if (eq (mixi-friend-sex object) 'male) "ÃË" "½÷"))
-                    (age (number-to-string (mixi-friend-age object)))
-                    (birthday
-                     (concat (mapconcat (lambda (number)
-                                          (number-to-string number))
-                                        (mixi-friend-birthday object) "·î")
-                             "Æü"))
-                    (blood-type (symbol-name
-                                 (mixi-friend-blood-type object)))
+                    (age (if (numberp (mixi-friend-age object))
+                             (number-to-string (mixi-friend-age object))
+                           "??"))
+                    (birthday (if (mixi-friend-birthday object)
+                                  (concat
+                                   (mapconcat (lambda (number)
+                                                (number-to-string number))
+                                              (mixi-friend-birthday object)
+                                              "·î") "Æü")
+                                "??·î??Æü"))
+                    (blood-type (if (mixi-friend-blood-type object)
+                                    (symbol-name
+                                     (mixi-friend-blood-type object))
+                                  "?"))
                     (hobby (mapconcat 'identity
                                       (mixi-friend-hobby object) ", ")))
                 (concat "<dl>"
                  (concat mixi-reply-to "message;"
                          (mixi-friend-id object))))))))
 
+(defconst mixi-to-regexp
+  "^mixi;\\([a-z]+\\);?\\([a-z0-9]+\\)?;?\\([0-9]+\\)?;?\\([0-9]+\\)?")
+
+(defun mixi-send-mail (to title content)
+  (when (string-match mixi-to-regexp to)
+    (let ((method (match-string 1 to)))
+      (cond ((string= method "comment")
+            (let ((parent (match-string 2 to))
+                  (owner-id (match-string 3 to))
+                  (id (match-string 4 to)))
+              (if (string= parent "diary")
+                  (mixi-post-comment
+                   (mixi-make-diary (mixi-make-friend owner-id) id) content)
+                (let ((func (intern
+                             (concat mixi-object-prefix "make-" parent))))
+                  (mixi-post-comment
+                   (funcall func (mixi-make-community owner-id) id)
+                   content)))))
+           ((string= method "topic")
+            (mixi-post-topic (mixi-make-community (match-string 2 to))
+                             title content))
+           ((string= method "diary")
+            (mixi-post-diary title content))
+           ((string= method "message")
+            (mixi-post-message (mixi-make-friend (match-string 2 to))
+                               title content))))))
+
 (provide 'mixi-utils)
 
 ;;; mixi-utils.el ends here