diff sat/plugins/plugin_xep_0166.py @ 4037:524856bd7b19

massive refactoring to switch from camelCase to snake_case: historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a pre-PEP8 code, to use the same coding style as in Twisted. However, snake_case is more readable and it's better to follow PEP8 best practices, so it has been decided to move on full snake_case. Because Libervia has a huge codebase, this ended with a ugly mix of camelCase and snake_case. To fix that, this patch does a big refactoring by renaming every function and method (including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case. This is a massive change, and may result in some bugs.
author Goffi <goffi@goffi.org>
date Sat, 08 Apr 2023 13:54:42 +0200
parents 8e7d5796fb23
children
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0166.py	Fri Apr 07 15:18:39 2023 +0200
+++ b/sat/plugins/plugin_xep_0166.py	Sat Apr 08 13:54:42 2023 +0200
@@ -110,13 +110,13 @@
             XEP_0166.TRANSPORT_STREAMING: [],
         }
 
-    def profileConnected(self, client):
+    def profile_connected(self, client):
         client.jingle_sessions = {}  # key = sid, value = session_data
 
-    def getHandler(self, client):
+    def get_handler(self, client):
         return XEP_0166_handler(self)
 
-    def _delSession(self, client, sid):
+    def _del_session(self, client, sid):
         try:
             del client.jingle_sessions[sid]
         except KeyError:
@@ -128,7 +128,7 @@
 
     ## helpers methods to build stanzas ##
 
-    def _buildJingleElt(self, client, session, action):
+    def _build_jingle_elt(self, client, session, action):
         iq_elt = client.IQ("set")
         iq_elt["from"] = session['local_jid'].full()
         iq_elt["to"] = session["peer_jid"].full()
@@ -149,7 +149,7 @@
         if jingle_condition is not None:
             iq_elt.error.addElement((NS_JINGLE_ERROR, jingle_condition))
         if error.STANZA_CONDITIONS[error_condition]["type"] == "cancel" and sid:
-            self._delSession(client, sid)
+            self._del_session(client, sid)
             log.warning(
                 "Error while managing jingle session, cancelling: {condition}".format(
                     condition=error_condition
@@ -157,7 +157,7 @@
             )
         return client.send(iq_elt)
 
-    def _terminateEb(self, failure_):
+    def _terminate_eb(self, failure_):
         log.warning(_("Error while terminating session: {msg}").format(msg=failure_))
 
     def terminate(self, client, reason, session, text=None):
@@ -168,7 +168,7 @@
             if a list of element, add them as children of the <reason/> element
         @param session(dict): data of the session
         """
-        iq_elt, jingle_elt = self._buildJingleElt(
+        iq_elt, jingle_elt = self._build_jingle_elt(
             client, session, XEP_0166.A_SESSION_TERMINATE
         )
         reason_elt = jingle_elt.addElement("reason")
@@ -179,14 +179,14 @@
                 reason_elt.addChild(elt)
         if text is not None:
             reason_elt.addElement("text", content=text)
-        self._delSession(client, session["id"])
+        self._del_session(client, session["id"])
         d = iq_elt.send()
-        d.addErrback(self._terminateEb)
+        d.addErrback(self._terminate_eb)
         return d
 
     ## errors which doesn't imply a stanza sending ##
 
-    def _iqError(self, failure_, sid, client):
+    def _iq_error(self, failure_, sid, client):
         """Called when we got an <iq/> error
 
         @param failure_(failure.Failure): the exceptions raised
@@ -197,9 +197,9 @@
                 failure_=failure_.value
             )
         )
-        self._delSession(client, sid)
+        self._del_session(client, sid)
 
-    def _jingleErrorCb(self, failure_, session, request, client):
+    def _jingle_error_cb(self, failure_, session, request, client):
         """Called when something is going wrong while parsing jingle request
 
         The error condition depend of the exceptions raised:
@@ -224,7 +224,7 @@
 
     ## methods used by other plugins ##
 
-    def registerApplication(self, namespace, handler):
+    def register_application(self, namespace, handler):
         """Register an application plugin
 
         @param namespace(unicode): application namespace managed by the plugin
@@ -235,10 +235,10 @@
                     - if it return True the session is accepted, else rejected.
                         A Deferred can be returned
                     - if not present, a generic accept dialog will be used
-                - jingleSessionInit(client, self, session, content_name[, *args, **kwargs]): must return the domish.Element used for initial content
-                - jingleHandler(client, self, action, session, content_name, transport_elt):
+                - jingle_session_init(client, self, session, content_name[, *args, **kwargs]): must return the domish.Element used for initial content
+                - jingle_handler(client, self, action, session, content_name, transport_elt):
                     called on several action to negociate the application or transport
-                - jingleTerminate: called on session terminate, with reason_elt
+                - jingle_terminate: called on session terminate, with reason_elt
                     May be used to clean session
         """
         if namespace in self._applications:
@@ -250,15 +250,15 @@
         )
         log.debug("new jingle application registered")
 
-    def registerTransport(self, namespace, transport_type, handler, priority=0):
+    def register_transport(self, namespace, transport_type, handler, priority=0):
         """Register a transport plugin
 
         @param namespace(unicode): the XML namespace used for this transport
         @param transport_type(unicode): type of transport to use (see XEP-0166 §8)
         @param handler(object): instance of a class which manage the application.
             Must have the following methods:
-                - jingleSessionInit(client, self, session, content_name[, *args, **kwargs]): must return the domish.Element used for initial content
-                - jingleHandler(client, self, action, session, content_name, transport_elt):
+                - jingle_session_init(client, self, session, content_name[, *args, **kwargs]): must return the domish.Element used for initial content
+                - jingle_handler(client, self, action, session, content_name, transport_elt):
                     called on several action to negociate the application or transport
         @param priority(int): priority of this transport
         """
@@ -281,7 +281,7 @@
         log.debug("new jingle transport registered")
 
     @defer.inlineCallbacks
-    def transportReplace(self, client, transport_ns, session, content_name):
+    def transport_replace(self, client, transport_ns, session, content_name):
         """Replace a transport
 
         @param transport_ns(unicode): namespace of the new transport to use
@@ -297,35 +297,35 @@
             transport = self._transports[transport_ns]
         except KeyError:
             raise exceptions.InternalError("Unkown transport")
-        yield content_data["transport"].handler.jingleHandler(
+        yield content_data["transport"].handler.jingle_handler(
             client, XEP_0166.A_DESTROY, session, content_name, None
         )
         content_data["transport"] = transport
         transport_data.clear()
 
-        iq_elt, jingle_elt = self._buildJingleElt(
+        iq_elt, jingle_elt = self._build_jingle_elt(
             client, session, XEP_0166.A_TRANSPORT_REPLACE
         )
         content_elt = jingle_elt.addElement("content")
         content_elt["name"] = content_name
         content_elt["creator"] = content_data["creator"]
 
-        transport_elt = transport.handler.jingleSessionInit(client, session, content_name)
+        transport_elt = transport.handler.jingle_session_init(client, session, content_name)
         content_elt.addChild(transport_elt)
         iq_elt.send()
 
-    def buildAction(self, client, action, session, content_name):
+    def build_action(self, client, action, session, content_name):
         """Build an element according to requested action
 
         @param action(unicode): a jingle action (see XEP-0166 §7.2),
             session-* actions are not managed here
-            transport-replace is managed in the dedicated [transportReplace] method
+            transport-replace is managed in the dedicated [transport_replace] method
         @param session(dict): jingle session data
         @param content_name(unicode): name of the content
         @return (tuple[domish.Element, domish.Element]): parent <iq> element, <transport> or <description> element, according to action
         """
         # we first build iq, jingle and content element which are the same in every cases
-        iq_elt, jingle_elt = self._buildJingleElt(client, session, action)
+        iq_elt, jingle_elt = self._build_jingle_elt(client, session, action)
         # FIXME: XEP-0260 § 2.3 Ex 5 has an initiator attribute, but it should not according to XEP-0166 §7.1 table 1, must be checked
         content_data = session["contents"][content_name]
         content_elt = jingle_elt.addElement("content")
@@ -342,13 +342,13 @@
 
         return iq_elt, context_elt
 
-    def buildSessionInfo(self, client, session):
+    def build_session_info(self, client, session):
         """Build a session-info action
 
         @param session(dict): jingle session data
         @return (tuple[domish.Element, domish.Element]): parent <iq> element, <jingle> element
         """
-        return self._buildJingleElt(client, session, XEP_0166.A_SESSION_INFO)
+        return self._build_jingle_elt(client, session, XEP_0166.A_SESSION_INFO)
 
     def getApplication(self, namespace: str) -> object:
         """Retreive application corresponding to a namespace
@@ -362,7 +362,7 @@
                 f"No application registered for {namespace}"
             )
 
-    def getContentData(self, content: dict) -> Tuple[object, list, dict, str]:
+    def get_content_data(self, content: dict) -> Tuple[object, list, dict, str]:
         """"Retrieve application and its argument from content"""
         app_ns = content["app_ns"]
         try:
@@ -414,13 +414,13 @@
             "contents": {},
         }
 
-        if not await self.host.trigger.asyncPoint(
+        if not await self.host.trigger.async_point(
             "XEP-0166_initiate",
             client, session, contents
         ):
             return
 
-        iq_elt, jingle_elt = self._buildJingleElt(
+        iq_elt, jingle_elt = self._build_jingle_elt(
             client, session, XEP_0166.A_SESSION_INITIATE
         )
         jingle_elt["initiator"] = initiator.full()
@@ -429,7 +429,7 @@
 
         for content in contents:
             # we get the application plugin
-            application, app_args, app_kwargs, content_name = self.getContentData(content)
+            application, app_args, app_kwargs, content_name = self.get_content_data(content)
 
             # and the transport plugin
             transport_type = content.get("transport_type", XEP_0166.TRANSPORT_STREAMING)
@@ -465,20 +465,20 @@
                 pass
 
             # then the description element
-            desc_elt = await utils.asDeferred(
-                application.handler.jingleSessionInit,
+            desc_elt = await utils.as_deferred(
+                application.handler.jingle_session_init,
                 client, session, content_name, *app_args, **app_kwargs
             )
             content_elt.addChild(desc_elt)
 
             # and the transport one
-            transport_elt = await utils.asDeferred(
-                transport.handler.jingleSessionInit,
+            transport_elt = await utils.as_deferred(
+                transport.handler.jingle_session_init,
                 client, session, content_name
             )
             content_elt.addChild(transport_elt)
 
-        if not await self.host.trigger.asyncPoint(
+        if not await self.host.trigger.async_point(
             "XEP-0166_initiate_elt_built",
             client, session, iq_elt, jingle_elt
         ):
@@ -494,17 +494,17 @@
             await iq_elt.send()
         except Exception as e:
             failure_ = failure.Failure(e)
-            self._iqError(failure_, sid, client)
+            self._iq_error(failure_, sid, client)
             raise failure_
 
-    def delayedContentTerminate(self, *args, **kwargs):
-        """Put contentTerminate in queue but don't execute immediately
+    def delayed_content_terminate(self, *args, **kwargs):
+        """Put content_terminate in queue but don't execute immediately
 
         This is used to terminate a content inside a handler, to avoid modifying contents
         """
-        reactor.callLater(0, self.contentTerminate, *args, **kwargs)
+        reactor.callLater(0, self.content_terminate, *args, **kwargs)
 
-    def contentTerminate(self, client, session, content_name, reason=REASON_SUCCESS):
+    def content_terminate(self, client, session, content_name, reason=REASON_SUCCESS):
         """Terminate and remove a content
 
         if there is no more content, then session is terminated
@@ -519,12 +519,12 @@
 
     ## defaults methods called when plugin doesn't have them ##
 
-    def jingleRequestConfirmationDefault(
+    def jingle_request_confirmation_default(
         self, client, action, session, content_name, desc_elt
     ):
         """This method request confirmation for a jingle session"""
         log.debug("Using generic jingle confirmation method")
-        return xml_tools.deferConfirm(
+        return xml_tools.defer_confirm(
             self.host,
             _(CONFIRM_TXT).format(entity=session["peer_jid"].full()),
             _("Confirm Jingle session"),
@@ -620,27 +620,27 @@
                 raise exceptions.InternalError
 
         if action == XEP_0166.A_SESSION_INITIATE:
-            await self.onSessionInitiate(client, request, jingle_elt, session)
+            await self.on_session_initiate(client, request, jingle_elt, session)
         elif action == XEP_0166.A_SESSION_TERMINATE:
-            self.onSessionTerminate(client, request, jingle_elt, session)
+            self.on_session_terminate(client, request, jingle_elt, session)
         elif action == XEP_0166.A_SESSION_ACCEPT:
-            self.onSessionAccept(client, request, jingle_elt, session)
+            self.on_session_accept(client, request, jingle_elt, session)
         elif action == XEP_0166.A_SESSION_INFO:
-            self.onSessionInfo(client, request, jingle_elt, session)
+            self.on_session_info(client, request, jingle_elt, session)
         elif action == XEP_0166.A_TRANSPORT_INFO:
-            self.onTransportInfo(client, request, jingle_elt, session)
+            self.on_transport_info(client, request, jingle_elt, session)
         elif action == XEP_0166.A_TRANSPORT_REPLACE:
-            self.onTransportReplace(client, request, jingle_elt, session)
+            self.on_transport_replace(client, request, jingle_elt, session)
         elif action == XEP_0166.A_TRANSPORT_ACCEPT:
-            self.onTransportAccept(client, request, jingle_elt, session)
+            self.on_transport_accept(client, request, jingle_elt, session)
         elif action == XEP_0166.A_TRANSPORT_REJECT:
-            self.onTransportReject(client, request, jingle_elt, session)
+            self.on_transport_reject(client, request, jingle_elt, session)
         else:
             raise exceptions.InternalError("Unknown action {}".format(action))
 
     ## Actions callbacks ##
 
-    def _parseElements(
+    def _parse_elements(
         self,
         jingle_elt,
         session,
@@ -759,14 +759,14 @@
                 content_data["transport_elt"] = transport_elt
 
     def _ignore(self, client, action, session, content_name, elt):
-        """Dummy method used when not exception must be raised if a method is not implemented in _callPlugins
+        """Dummy method used when not exception must be raised if a method is not implemented in _call_plugins
 
         must be used as app_default_cb and/or transp_default_cb
         """
         return elt
 
-    def _callPlugins(self, client, action, session, app_method_name="jingleHandler",
-                     transp_method_name="jingleHandler", app_default_cb=None,
+    def _call_plugins(self, client, action, session, app_method_name="jingle_handler",
+                     transp_method_name="jingle_handler", app_default_cb=None,
                      transp_default_cb=None, delete=True, elements=True,
                      force_element=None):
         """Call application and transport plugin methods for all contents
@@ -784,7 +784,7 @@
         @param delete(bool): if True, remove desc_elt and transport_elt from session
             ignored if elements is False
         @param elements(bool): True if elements(desc_elt and tranport_elt) must be managed
-            must be True if _callPlugins is used in a request, and False if it used after a request
+            must be True if _call_plugins is used in a request, and False if it used after a request
             (i.e. on <iq> result or error)
         @param force_element(None, domish.Element, object): if elements is False, it is used as element parameter
             else it is ignored
@@ -815,14 +815,14 @@
                     elt = content_data.pop(elt_name) if delete else content_data[elt_name]
                 else:
                     elt = force_element
-                d = utils.asDeferred(
+                d = utils.as_deferred(
                     method, client, action, session, content_name, elt
                 )
                 defers_list.append(d)
 
         return defers_list
 
-    async def onSessionInitiate(
+    async def on_session_initiate(
         self,
         client: SatXMPPEntity,
         request: domish.Element,
@@ -831,8 +831,8 @@
     ) -> None:
         """Called on session-initiate action
 
-        The "jingleRequestConfirmation" method of each application will be called
-        (or self.jingleRequestConfirmationDefault if the former doesn't exist).
+        The "jingle_request_confirmation" method of each application will be called
+        (or self.jingle_request_confirmation_default if the former doesn't exist).
         The session is only accepted if all application are confirmed.
         The application must manage itself multiple contents scenari (e.g. audio/video).
         @param client: %(doc_client)s
@@ -847,7 +847,7 @@
         session["contents"] = contents_dict = {}
 
         try:
-            self._parseElements(
+            self._parse_elements(
                 jingle_elt, session, request, client, True, XEP_0166.ROLE_INITIATOR
             )
         except exceptions.CancelError:
@@ -862,7 +862,7 @@
         client.send(xmlstream.toResponse(request, "result"))
 
 
-        if not await self.host.trigger.asyncPoint(
+        if not await self.host.trigger.async_point(
             "XEP-0166_on_session_initiate",
             client, session, request, jingle_elt
         ):
@@ -870,21 +870,21 @@
 
         # we now request each application plugin confirmation
         # and if all are accepted, we can accept the session
-        confirm_defers = self._callPlugins(
+        confirm_defers = self._call_plugins(
             client,
             XEP_0166.A_SESSION_INITIATE,
             session,
-            "jingleRequestConfirmation",
+            "jingle_request_confirmation",
             None,
-            self.jingleRequestConfirmationDefault,
+            self.jingle_request_confirmation_default,
             delete=False,
         )
 
         confirm_dlist = defer.gatherResults(confirm_defers)
-        confirm_dlist.addCallback(self._confirmationCb, session, jingle_elt, client)
-        confirm_dlist.addErrback(self._jingleErrorCb, session, request, client)
+        confirm_dlist.addCallback(self._confirmation_cb, session, jingle_elt, client)
+        confirm_dlist.addErrback(self._jingle_error_cb, session, request, client)
 
-    def _confirmationCb(self, confirm_results, session, jingle_elt, client):
+    def _confirmation_cb(self, confirm_results, session, jingle_elt, client):
         """Method called when confirmation from user has been received
 
         This method is only called for the responder
@@ -897,7 +897,7 @@
         if not confirmed:
             return self.terminate(client, XEP_0166.REASON_DECLINE, session)
 
-        iq_elt, jingle_elt = self._buildJingleElt(
+        iq_elt, jingle_elt = self._build_jingle_elt(
             client, session, XEP_0166.A_SESSION_ACCEPT
         )
         jingle_elt["responder"] = session['local_jid'].full()
@@ -915,9 +915,9 @@
             content_elt["name"] = content_name
 
             application = content_data["application"]
-            app_session_accept_cb = application.handler.jingleHandler
+            app_session_accept_cb = application.handler.jingle_handler
 
-            app_d = utils.asDeferred(
+            app_d = utils.as_deferred(
                 app_session_accept_cb,
                 client,
                 XEP_0166.A_SESSION_INITIATE,
@@ -929,9 +929,9 @@
             defers_list.append(app_d)
 
             transport = content_data["transport"]
-            transport_session_accept_cb = transport.handler.jingleHandler
+            transport_session_accept_cb = transport.handler.jingle_handler
 
-            transport_d = utils.asDeferred(
+            transport_d = utils.as_deferred(
                 transport_session_accept_cb,
                 client,
                 XEP_0166.A_SESSION_INITIATE,
@@ -944,7 +944,7 @@
 
         d_list = defer.DeferredList(defers_list)
         d_list.addCallback(
-            lambda __: self._callPlugins(
+            lambda __: self._call_plugins(
                 client,
                 XEP_0166.A_PREPARE_RESPONDER,
                 session,
@@ -954,19 +954,19 @@
         )
         d_list.addCallback(lambda __: iq_elt.send())
 
-        def changeState(__, session):
+        def change_state(__, session):
             session["state"] = STATE_ACTIVE
 
-        d_list.addCallback(changeState, session)
+        d_list.addCallback(change_state, session)
         d_list.addCallback(
-            lambda __: self._callPlugins(
+            lambda __: self._call_plugins(
                 client, XEP_0166.A_ACCEPTED_ACK, session, elements=False
             )
         )
-        d_list.addErrback(self._iqError, session["id"], client)
+        d_list.addErrback(self._iq_error, session["id"], client)
         return d_list
 
-    def onSessionTerminate(self, client, request, jingle_elt, session):
+    def on_session_terminate(self, client, request, jingle_elt, session):
         # TODO: check reason, display a message to user if needed
         log.debug("Jingle Session {} terminated".format(session["id"]))
         try:
@@ -975,12 +975,12 @@
             log.warning("No reason given for session termination")
             reason_elt = jingle_elt.addElement("reason")
 
-        terminate_defers = self._callPlugins(
+        terminate_defers = self._call_plugins(
             client,
             XEP_0166.A_SESSION_TERMINATE,
             session,
-            "jingleTerminate",
-            "jingleTerminate",
+            "jingle_terminate",
+            "jingle_terminate",
             self._ignore,
             self._ignore,
             elements=False,
@@ -988,10 +988,10 @@
         )
         terminate_dlist = defer.DeferredList(terminate_defers)
 
-        terminate_dlist.addCallback(lambda __: self._delSession(client, session["id"]))
+        terminate_dlist.addCallback(lambda __: self._del_session(client, session["id"]))
         client.send(xmlstream.toResponse(request, "result"))
 
-    def onSessionAccept(self, client, request, jingle_elt, session):
+    def on_session_accept(self, client, request, jingle_elt, session):
         """Method called once session is accepted
 
         This method is only called for initiator
@@ -1003,7 +1003,7 @@
         log.debug("Jingle session {} has been accepted".format(session["id"]))
 
         try:
-            self._parseElements(jingle_elt, session, request, client)
+            self._parse_elements(jingle_elt, session, request, client)
         except exceptions.CancelError:
             return
 
@@ -1013,28 +1013,28 @@
         session["state"] = STATE_ACTIVE
 
         negociate_defers = []
-        negociate_defers = self._callPlugins(client, XEP_0166.A_SESSION_ACCEPT, session)
+        negociate_defers = self._call_plugins(client, XEP_0166.A_SESSION_ACCEPT, session)
 
         negociate_dlist = defer.gatherResults(negociate_defers)
 
         # after negociations we start the transfer
         negociate_dlist.addCallback(
-            lambda __: self._callPlugins(
+            lambda __: self._call_plugins(
                 client, XEP_0166.A_START, session, app_method_name=None, elements=False
             )
         )
 
-    def _onSessionCb(self, result, client, request, jingle_elt, session):
+    def _on_session_cb(self, result, client, request, jingle_elt, session):
         client.send(xmlstream.toResponse(request, "result"))
 
-    def _onSessionEb(self, failure_, client, request, jingle_elt, session):
-        log.error("Error while handling onSessionInfo: {}".format(failure_.value))
+    def _on_session_eb(self, failure_, client, request, jingle_elt, session):
+        log.error("Error while handling on_session_info: {}".format(failure_.value))
         # XXX: only error managed so far, maybe some applications/transports need more
         self.sendError(
             client, "feature-not-implemented", None, request, "unsupported-info"
         )
 
-    def onSessionInfo(self, client, request, jingle_elt, session):
+    def on_session_info(self, client, request, jingle_elt, session):
         """Method called when a session-info action is received from other peer
 
         This method is only called for initiator
@@ -1051,28 +1051,28 @@
         try:
             # XXX: session-info is most likely only used for application, so we don't call transport plugins
             #      if a future transport use it, this behaviour must be adapted
-            defers = self._callPlugins(
+            defers = self._call_plugins(
                 client,
                 XEP_0166.A_SESSION_INFO,
                 session,
-                "jingleSessionInfo",
+                "jingle_session_info",
                 None,
                 elements=False,
                 force_element=jingle_elt,
             )
         except exceptions.NotFound as e:
-            self._onSessionEb(failure.Failure(e), client, request, jingle_elt, session)
+            self._on_session_eb(failure.Failure(e), client, request, jingle_elt, session)
             return
 
         dlist = defer.DeferredList(defers, fireOnOneErrback=True)
-        dlist.addCallback(self._onSessionCb, client, request, jingle_elt, session)
-        dlist.addErrback(self._onSessionCb, client, request, jingle_elt, session)
+        dlist.addCallback(self._on_session_cb, client, request, jingle_elt, session)
+        dlist.addErrback(self._on_session_cb, client, request, jingle_elt, session)
 
     @defer.inlineCallbacks
-    def onTransportReplace(self, client, request, jingle_elt, session):
+    def on_transport_replace(self, client, request, jingle_elt, session):
         """A transport change is requested
 
-        The request is parsed, and jingleHandler is called on concerned transport plugin(s)
+        The request is parsed, and jingle_handler is called on concerned transport plugin(s)
         @param client: %(doc_client)s
         @param request(domish.Element): full <iq> request
         @param jingle_elt(domish.Element): the <jingle> element
@@ -1080,7 +1080,7 @@
         """
         log.debug("Other peer wants to replace the transport")
         try:
-            self._parseElements(
+            self._parse_elements(
                 jingle_elt, session, request, client, with_application=False
             )
         except exceptions.CancelError:
@@ -1111,7 +1111,7 @@
 
         if content_name is None:
             # wa can't accept the replacement
-            iq_elt, reject_jingle_elt = self._buildJingleElt(
+            iq_elt, reject_jingle_elt = self._build_jingle_elt(
                 client, session, XEP_0166.A_TRANSPORT_REJECT
             )
             for child in jingle_elt.children:
@@ -1122,12 +1122,12 @@
 
         # at this point, everything is alright and we can replace the transport(s)
         # this is similar to an session-accept action, but for transports only
-        iq_elt, accept_jingle_elt = self._buildJingleElt(
+        iq_elt, accept_jingle_elt = self._build_jingle_elt(
             client, session, XEP_0166.A_TRANSPORT_ACCEPT
         )
         for content_name, content_data, transport, transport_elt in to_replace:
             # we can now actually replace the transport
-            yield content_data["transport"].handler.jingleHandler(
+            yield content_data["transport"].handler.jingle_handler(
                 client, XEP_0166.A_DESTROY, session, content_name, None
             )
             content_data["transport"] = transport
@@ -1137,18 +1137,18 @@
             content_elt["name"] = content_name
             content_elt["creator"] = content_data["creator"]
             # we notify the transport and insert its <transport/> in the answer
-            accept_transport_elt = yield transport.handler.jingleHandler(
+            accept_transport_elt = yield transport.handler.jingle_handler(
                 client, XEP_0166.A_TRANSPORT_REPLACE, session, content_name, transport_elt
             )
             content_elt.addChild(accept_transport_elt)
             # there is no confirmation needed here, so we can directly prepare it
-            yield transport.handler.jingleHandler(
+            yield transport.handler.jingle_handler(
                 client, XEP_0166.A_PREPARE_RESPONDER, session, content_name, None
             )
 
         iq_elt.send()
 
-    def onTransportAccept(self, client, request, jingle_elt, session):
+    def on_transport_accept(self, client, request, jingle_elt, session):
         """Method called once transport replacement is accepted
 
         @param client: %(doc_client)s
@@ -1159,7 +1159,7 @@
         log.debug("new transport has been accepted")
 
         try:
-            self._parseElements(
+            self._parse_elements(
                 jingle_elt, session, request, client, with_application=False
             )
         except exceptions.CancelError:
@@ -1169,7 +1169,7 @@
         client.send(xmlstream.toResponse(request, "result"))
 
         negociate_defers = []
-        negociate_defers = self._callPlugins(
+        negociate_defers = self._call_plugins(
             client, XEP_0166.A_TRANSPORT_ACCEPT, session, app_method_name=None
         )
 
@@ -1177,12 +1177,12 @@
 
         # after negociations we start the transfer
         negociate_dlist.addCallback(
-            lambda __: self._callPlugins(
+            lambda __: self._call_plugins(
                 client, XEP_0166.A_START, session, app_method_name=None, elements=False
             )
         )
 
-    def onTransportReject(self, client, request, jingle_elt, session):
+    def on_transport_reject(self, client, request, jingle_elt, session):
         """Method called when a transport replacement is refused
 
         @param client: %(doc_client)s
@@ -1194,10 +1194,10 @@
         #      this behaviour may change in the future
         self.terminate(client, "failed-transport", session)
 
-    def onTransportInfo(self, client, request, jingle_elt, session):
+    def on_transport_info(self, client, request, jingle_elt, session):
         """Method called when a transport-info action is received from other peer
 
-        The request is parsed, and jingleHandler is called on concerned transport plugin(s)
+        The request is parsed, and jingle_handler is called on concerned transport plugin(s)
         @param client: %(doc_client)s
         @param request(domish.Element): full <iq> request
         @param jingle_elt(domish.Element): the <jingle> element
@@ -1206,7 +1206,7 @@
         log.debug("Jingle session {} has been accepted".format(session["id"]))
 
         try:
-            self._parseElements(
+            self._parse_elements(
                 jingle_elt, session, request, client, with_application=False
             )
         except exceptions.CancelError:
@@ -1221,7 +1221,7 @@
             except KeyError:
                 continue
             else:
-                content_data["transport"].handler.jingleHandler(
+                content_data["transport"].handler.jingle_handler(
                     client,
                     XEP_0166.A_TRANSPORT_INFO,
                     session,