Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Icon images are retrieved by `twittering-send-http-request'.

* twittering-mode.el: `twittering-resolve-url-request' uses
`twittering-send-http-request' instead of `url-retrieve'.
(twittering-resolve-url-request): use
`twittering-send-http-request' instead of `url-retrieve'.
(twittering-url-retrieve-async-sentinel): new function.
(twittering-url-retrieve-async-clean-up-sentinel): new function.
  • Loading branch information...
commit bb7026fc19aa4ba4336431d6cd92081f083fd78a 1 parent 0d8ea3e
@cvmat cvmat authored
Showing with 51 additions and 45 deletions.
  1. +7 −0 ChangeLog
  2. +4 −0 NEWS
  3. +4 −0 NEWS.ja
  4. +36 −45 twittering-mode.el
View
7 ChangeLog
@@ -34,6 +34,13 @@
(twittering-start): `twittering-redisplay-status-on-buffer' is
called by `run-with-idle-timer'.
+ * twittering-mode.el: `twittering-resolve-url-request' uses
+ `twittering-send-http-request' instead of `url-retrieve'.
+ (twittering-resolve-url-request): use
+ `twittering-send-http-request' instead of `url-retrieve'.
+ (twittering-url-retrieve-async-sentinel): new function.
+ (twittering-url-retrieve-async-clean-up-sentinel): new function.
+
2010-11-13 Tadashi MATSUO <tad@mymail.twin.jp>
* twittering-mode.el: `twittering-send-http-request' correctly
View
4 NEWS
@@ -92,6 +92,10 @@
remains idle for a certain time specified by the variable
`twittering-timer-interval-for-redisplaying', which is 1 second by
default.
+* Retrieval of icon images by `curl' and `wget'.
+ Icon images can be retrieved by the same connection method as that used
+ for retrieving tweets. The priority of methods is similarly determined
+ by `twittering-connection-type-order'.
* ...
### Bug fixes
View
4 NEWS.ja
@@ -94,6 +94,10 @@
入力待ち状態(idle状態)に入り、その状態が一定時間継続してから行うように
しました。待ち時間は変数`twittering-timer-interval-for-redisplaying'で
指定できます。デフォルトの待ち時間は1秒です。
+* curlやwgetでのアイコン画像取得に対応
+ アイコン画像の取得にtweet取得と同じ通信方法(connection method)が使える
+ ようになりました。各methodの優先順位はtweet取得と同じく変数
+ `twittering-connection-type-order'で決定されます。
* ...
### バグ修正
View
81 twittering-mode.el
@@ -2685,8 +2685,6 @@ like following:
(defvar twittering-internal-url-queue nil)
(defvar twittering-url-request-resolving-p nil)
(defvar twittering-url-request-retry-limit 3)
-(defconst twittering-url-request-dummy-buffer-name
- " *twittering-dummy-for-url-retrieve-async*")
(defun twittering-remove-redundant-queries (queue)
(remove nil
@@ -2712,49 +2710,42 @@ like following:
(twittering-remove-redundant-queries twittering-internal-url-queue))
(if (null twittering-internal-url-queue)
(setq twittering-url-request-resolving-p nil)
- (let ((url (car twittering-internal-url-queue))
- (coding-system-for-read 'binary)
- (require-final-newline nil))
- (twittering-url-wrapper
- 'url-retrieve
- url
- (lambda (&rest args)
- (let* ((status (if (< 21 emacs-major-version)
- (car args)
- nil))
- (callback-args (if (< 21 emacs-major-version)
- (cdr args)
- args))
- (url (elt callback-args 0)))
- (goto-char (point-min))
- (if (and (or (null status) (not (member :error status)))
- (search-forward-regexp "\r?\n\r?\n" nil t))
- (let ((body (buffer-substring (match-end 0) (point-max))))
- (puthash url body twittering-url-data-hash)
- (setq twittering-internal-url-queue
- (remove url twittering-internal-url-queue))
- (let ((sentinels
- (gethash url twittering-url-request-sentinel-hash)))
- (when sentinels
- (remhash url twittering-url-request-sentinel-hash)
- (mapc (lambda (func)
- (funcall func url body))
- sentinels))))
- (let ((current (gethash url twittering-url-data-hash)))
- (cond
- ((null current)
- (puthash url 1 twittering-url-data-hash))
- ((integerp current)
- (puthash url (1+ current) twittering-url-data-hash))
- (t
- nil))))
- (let ((current (current-buffer)))
- (set-buffer (get-buffer-create
- twittering-url-request-dummy-buffer-name))
- (kill-buffer current))
- (setq twittering-url-request-resolving-p nil)
- (twittering-resolve-url-request)))
- `(,url))))))
+ (let* ((url (car twittering-internal-url-queue))
+ (request (twittering-make-http-request-from-uri "GET" nil url))
+ (additional-info nil))
+ (twittering-send-http-request
+ request additional-info
+ 'twittering-url-retrieve-async-sentinel
+ 'twittering-url-retrieve-async-clean-up-sentinel)))))
+
+(defun twittering-url-retrieve-async-sentinel (proc status connection-info header-info)
+ (let ((status-line (cdr (assq 'status-line header-info)))
+ (status-code (cdr (assq 'status-code header-info)))
+ (uri (cdr (assq 'uri (assq 'request connection-info)))))
+ (when (string= status-code "200")
+ (let ((body (string-as-unibyte (buffer-string))))
+ (puthash uri body twittering-url-data-hash)
+ (setq twittering-internal-url-queue
+ (remove uri twittering-internal-url-queue))
+ (let ((sentinels (gethash uri twittering-url-request-sentinel-hash)))
+ (when sentinels
+ (remhash uri twittering-url-request-sentinel-hash)
+ (mapc (lambda (func)
+ (funcall func uri body))
+ sentinels)
+ ;; Without the following nil, it seems that the value of
+ ;; `sentinels' is displayed.
+ nil))))))
+
+(defun twittering-url-retrieve-async-clean-up-sentinel (proc status connection-info)
+ (when (memq status '(exit signal closed failed))
+ (let* ((uri (cdr (assq 'uri connection-info)))
+ (current (gethash uri twittering-url-data-hash)))
+ (when (or (null current) (integerp current))
+ ;; Increment the counter on failure.
+ (puthash uri (1+ (or current 0)) twittering-url-data-hash)))
+ (setq twittering-url-request-resolving-p nil)
+ (twittering-resolve-url-request)))
(defun twittering-url-retrieve-async (url &optional sentinel)
"Retrieve URL asynchronously and call SENTINEL with the retrieved data.
Please sign in to comment.
Something went wrong with that request. Please try again.