Permalink
Browse files

added initial support for the transport abstraction to affected

components
* obby/rudel-obby-client (require rudel-tls): required for STARTTLS
  encryption
* obby/rudel-obby.el (header): added version 0.3 to history section
  (rudel-obby-backend::rudel-ask-connect-info): return info list
  containing entries for transport and protocol backend
  (rudel-obby-backend::rudel-connect): added transport argument; use
  transport object instead of creating a socket
  (zeroconf service registration): register transport and protocol
  backend
* rudel-protocol.el (header): history section fix
  (rudel-protocol-backend::rudel-ask-connect-info): renamed
  `rudel-ask-join-info' -> `rudel-ask-connect-info'
  (rudel-protocol-backend::rudel-connect): renamed `rudel-join ->
  `rudel-connect; added argument transport; updated documentation
  string
* rudel.el (header): added version 0.2 to history section
  (rudel-join-session): obtain transport and protocol backends from
  info; create a transport object; return created session object
* zeroconf/rudel-zeroconf.el (header): downcased keywords; updated
  commentary section; added version 0.2 to history
  (rudel-zeroconf-version): bumped to 0.2
  (rudel-zeroconf-service-types): updated documentation string
  (rudel-zeroconf-service-backend): removed
  (rudel-zeroconf-transport-backend): new; accessor for transport
  backend
  (rudel-zeroconf-protocol-backend): new; accessor for protocol
  backend
  (rudel-zeroconf-register-service): accept a transport and a protocol
  backend argument; update documentation string
  (initialize-instance): remove &rest from argument slots
  (rudel-advertise): handle transport and protocol backend
  (rudel-zeroconf-services): updated to work with new service
  representation
  (rudel-zeroconf-services-present-p): updated to work with new
  service representation
  (rudel-zeroconf-publish): accept a transport and a protocol backend
  argument
  (rudel-zeroconf-service->plist): handle transport and protocol
  backends
  • Loading branch information...
1 parent ee144a4 commit 259d5a776f3cd6b2748fdb15762142b37970df0c @scymtym committed Dec 1, 2009
Showing with 214 additions and 112 deletions.
  1. +85 −0 ChangeLog
  2. +1 −0 obby/rudel-obby-client.el
  3. +24 −37 obby/rudel-obby.el
  4. +9 −6 rudel-protocol.el
  5. +31 −20 rudel.el
  6. +2 −1 tls/rudel-tls.el
  7. +62 −48 zeroconf/rudel-zeroconf.el
View
@@ -1,5 +1,90 @@
+2009-12-01 Jan Moringen <scymtym@users.sourceforge.net>
+
+ added initial support for the transport abstraction to affected
+ components
+ * obby/rudel-obby-client (require rudel-tls): required for
+ STARTTLS encryption
+ * obby/rudel-obby.el (header): added version 0.3 to history
+ section
+ (rudel-obby-backend::rudel-ask-connect-info): return info list
+ containing entries for transport and protocol backend
+ (rudel-obby-backend::rudel-connect): added transport argument; use
+ transport object instead of creating a socket
+ (zeroconf service registration): register transport and protocol
+ backend
+ * rudel-protocol.el (header): history section fix
+ (rudel-protocol-backend::rudel-ask-connect-info): renamed
+ `rudel-ask-join-info' -> `rudel-ask-connect-info'
+ (rudel-protocol-backend::rudel-connect): renamed `rudel-join ->
+ `rudel-connect; added argument transport; updated documentation
+ string
+ * rudel.el (header): added version 0.2 to history section
+ (rudel-join-session): obtain transport and protocol backends from
+ info; create a transport object; return created session object
+ * zeroconf/rudel-zeroconf.el (header): downcased keywords; updated
+ commentary section; added version 0.2 to history
+ (rudel-zeroconf-version): bumped to 0.2
+ (rudel-zeroconf-service-types): updated documentation string
+ (rudel-zeroconf-service-backend): removed
+ (rudel-zeroconf-transport-backend): new; accessor for transport
+ backend
+ (rudel-zeroconf-protocol-backend): new; accessor for protocol
+ backend
+ (rudel-zeroconf-register-service): accept a transport and a
+ protocol backend argument; update documentation string
+ (initialize-instance): remove &rest from argument slots
+ (rudel-advertise): handle transport and protocol backend
+ (rudel-zeroconf-services): updated to work with new service
+ representation
+ (rudel-zeroconf-services-present-p): updated to work with new
+ service representation
+ (rudel-zeroconf-publish): accept a transport and a protocol
+ backend argument
+ (rudel-zeroconf-service->plist): handle transport and protocol
+ backends
+
2009-11-30 Jan Moringen <scymtym@users.sourceforge.net>
+ * rudel-compile.el (top-level): added tls directory to list of
+ directories with autoloads
+ * tls/rudel-tls.el (header): added 0.2 to version section
+ (require rudel-socket): required since base class of
+ `rudel-start-tls-transport'
+ (rudel-start-tls-transport): new class; socket transport with
+ START TLS ability
+ (rudel-start-tls-transport::rudel-enable-encryption): new method;
+ enable TLS encryption
+ (rudel-start-tls-backend): new class; START TLS transport backend
+ (rudel-start-tls-backend::initialize-instance): new method
+ (rudel-start-tls-backend::rudel-make-connection): new method;
+ create new START TLS transport object
+ (autoloading): added autoloaded registration of the backend
+
+ * rudel-util.el: (rudel-assemble-lines): new function assemble
+ complete lines from string fragments
+
+ * socket/rudel-socket.el (footer): changed provided feature
+ rudel-tcp -> rudel-socket; changed comment
+
+ * tls/rudel-tls.el (rudel-tls-wait-init): use
+ `rudel-assemble-fragments' instead of
+ `rudel-assemble-line-fragments'; use `rudel-loop-fragments'
+ instead of `rudel-loop-lines'
+ (rudel-tls-wait-handshake): use `rudel-assemble-fragments' instead
+ of `rudel-assemble-line-fragments'; use `rudel-loop-fragments'
+ instead of `rudel-loop-lines'
+ (rudel-tls-established): use `rudel-assemble-fragments' instead of
+ `rudel-assemble-line-fragments'; use `rudel-loop-fragments'
+ instead of `rudel-loop-lines'
+
+ * rudel-util.el (rudel-loop-fragments): new macro; call a form for
+ each fragment
+
+ * tls/rudel-tls.el: moved to tls directory
+ * tls/Project.ede (target tls): added rudel-tls.el
+ * Project.ede (target autoloads): added tls directory
+ (target compile): removed rudel-tls.el
+
* rudel-compat.el (progress-spinner-values):
(progress-reporter-spinner-p):
(progress-reporter-force-update):
@@ -41,6 +41,7 @@
(require 'jupiter)
+(require 'rudel-tls)
(require 'rudel-state-machine)
(require 'rudel-operations)
(require 'rudel-chat)
View
@@ -31,9 +31,11 @@
;;; History:
;;
-;; 0.2 - Refactored client and server to employ state machine.
+;; 0.3 - Support for transports in client code
;;
-;; 0.1 - Initial revision.
+;; 0.2 - Refactored client and server to employ state machine
+;;
+;; 0.1 - Initial version
;;; Code:
@@ -55,7 +57,7 @@
;;; Constants
;;
-(defconst rudel-obby-version '(0 2)
+(defconst rudel-obby-version '(0 3)
"Version of the obby backend for Rudel.")
(defconst rudel-obby-protocol-version 8
@@ -109,19 +111,21 @@ connections and creates obby servers.")
(user-password (if (and info (member :user-password info))
(plist-get info :user-password)
(read-string "User password: " ""))))
- (append (list :host host
- :port port
- :username username
- :color color
- :encryption encryption
- :global-password (unless (string= global-password "")
- global-password)
- :user-password (unless (string= user-password "")
- user-password))
+ (append (list :transport-backend 'tcp
+ :protocol-backend 'obby
+ :host host
+ :port port
+ :username username
+ :color color
+ :encryption encryption
+ :global-password (unless (string= global-password "")
+ global-password)
+ :user-password (unless (string= user-password "")
+ user-password))
info))
)
-(defmethod rudel-connect ((this rudel-obby-backend) info)
+(defmethod rudel-connect ((this rudel-obby-backend) transport info)
"Connect to an obby server using the information INFO.
Return the connection object."
;; Before we start, load the client functionality.
@@ -131,35 +135,17 @@ Return the connection object."
(let* ((session (plist-get info :session))
(host (plist-get info :host))
(port (plist-get info :port))
- (encryption (plist-get info :encryption))
- ;; Create the network process
- (socket (funcall
- (if encryption
- (progn
- (require 'rudel-tls)
- #'rudel-tls-make-process)
- #'make-network-process)
- :name host
- :host host
- :service port
- ;; Install connection filter to redirect data to
- ;; the connection object
- :filter #'rudel-filter-dispatch
- ;; Install connection sentinel to redirect state
- ;; changes to the connection object
- :sentinel #'rudel-sentinel-dispatch
- ;; Do not start receiving immediately since the
- ;; filter function is not yet setup properly.
- :stop t))
(connection (rudel-obby-connection
host
:session session
- :socket socket
+ :socket (oref transport :socket)
:info info)))
;; Now start receiving and wait until the basic session setup is
;; complete.
- (continue-process socket)
+ (set-process-filter (oref transport :socket) #'rudel-filter-dispatch)
+ (set-process-sentinel (oref transport :socket) #'rudel-sentinel-dispatch)
+ (rudel-start transport)
;; Wait for the connection to reach one of the states idle,
;; join-failed and they-finalized.
@@ -170,7 +156,7 @@ Return the connection object."
;; For all states, just spin.
((consp state)
(progress-reporter-force-update
- reporter nil (format "Joining (%s)" (car state))))
+ reporter nil (format "Joining (%s)" (car state))))
;; Done
(t
@@ -483,7 +469,8 @@ calling this function."
;;;###autoload
(eval-after-load 'rudel-zeroconf
- '(rudel-zeroconf-register-service "_lobby._tcp" 'obby))
+ '(rudel-zeroconf-register-service "_lobby._tcp"
+ 'start-tls 'obby))
(provide 'rudel-obby)
;;; rudel-obby.el ends here
View
@@ -39,7 +39,7 @@
;;; History:
;;
-;; 0.1 - Initial revision
+;; 0.1 - Initial version
;;; Code:
@@ -58,15 +58,18 @@
"Interface implemented by protocol backends."
:abstract t)
-(defgeneric rudel-ask-join-info ((this rudel-protocol-backend))
+(defgeneric rudel-ask-connect-info ((this rudel-protocol-backend))
"Retrieve information for joining a session from user.
Return a property list that contains the collected information.")
-(defgeneric rudel-join ((this rudel-protocol-backend) info)
- "Create a new connection according to the data in the property list INFO.
+(defgeneric rudel-connect ((this rudel-protocol-backend) transport info)
+ "Create a new connection through TRANSPORT according to the data in INFO.
+TRANSPORT has to be an object of a class derived from `rudel-transport'.
+INFO has to be a property list.
+
Implementations can rely on the fact that the property :session
-contains the `rudel-session' object to which the new connection
-will be associated.")
+in INFO contains the `rudel-session' object to which the new
+connection will be associated.")
(defgeneric rudel-ask-host-info ((this rudel-protocol-backend))
"Retrieve information for hosting a session from user.
View
@@ -32,7 +32,9 @@
;;; History:
;;
-;; 0.1 - Initial revision.
+;; 0.2 - Support for transports
+;;
+;; 0.1 - Initial version
;;; Code:
@@ -805,41 +807,49 @@ will be prompted for."
(list
(let ((info)
(session-initiation-backend))
+ ;; Query the chosen backend until session info is available.
(while (not info)
(message "Discovering Sessions ...")
(let* ((sessions (rudel-session-initiation-discover
session-initiation-backend))
(maybe-info (if (= (length sessions) 1)
- (car sessions)
- (rudel-read-session
- sessions "Choose Session: " 'object))))
+ (car sessions)
+ (rudel-read-session
+ sessions "Choose Session: " 'object))))
(if (rudel-backend-cons-p maybe-info)
(setq session-initiation-backend (car maybe-info))
(setq info maybe-info))))
- info)))
+ info)))
;; First, create the session object.
- (let* ((backend (cdr (plist-get info :backend)))
- (session (rudel-client-session
- (plist-get info :name)
- :backend backend))
+ (let* ((session-name (plist-get info :name))
+ (transport-backend (cdr (plist-get info :transport-backend)))
+ (protocol-backend (cdr (plist-get info :protocol-backend)))
+
+ ;; First, create the session object.
+ (session (rudel-client-session
+ session-name
+ :backend protocol-backend))
+ (transport)
(connection))
+
;; Give the backend a chance to collect remaining connect
;; info. For session initiation methods like Zeroconf, we have the
;; _connection_ info, but are still missing the username and
;; stuff.
- (setq info (rudel-ask-connect-info backend info))
-
- ;; Add the session object to the connect information.
- (plist-put info :session session)
+ (setq info (rudel-ask-connect-info protocol-backend info))
- ;; Ask BACKEND to connect using INFO. Do not catch errors since
- ;; the error messages are probably the best feedback we can give.
- (setq connection (rudel-connect backend info))
+ ;; Add the session object to INFO.
+ (setq info (plist-put info :session session))
- ;; Set the connection slot of the session object and store it
- ;; globally.
+ ;; Create transport object and connection
+ (setq transport (rudel-make-connection
+ transport-backend info #'ignore))
+ (setq connection (rudel-connect
+ protocol-backend transport info))
(oset session :connection connection)
+
+ ;; Store the new session object globally.
(setq rudel-current-session session)
;; Reset the global session variable when the session ends.
@@ -848,8 +858,9 @@ will be prompted for."
(setq rudel-current-session nil)))
;; Run the hook.
- (run-hook-with-args 'rudel-session-start-hook session))
- )
+ (run-hook-with-args 'rudel-session-start-hook session)
+
+ session))
;;;###autoload
(defun rudel-host-session ()
View
@@ -261,7 +261,8 @@ and :port."
:stop t)))
(rudel-socket-transport
(format "to %s" host)
- :socket socket)))
+ :socket socket))
+ )
;;; Autoloading
Oops, something went wrong.

0 comments on commit 259d5a7

Please sign in to comment.