author Mozilla Releng Treescript <>
Fri, 30 Jul 2021 08:38:48 +0000
changeset 43240 22baf10cd25074c77c08be1e01284ac9f30ee361
parent 25296 140e94c99688dbd26d102ac2f511dfdbcc54a6b4
permissions -rw-r--r--
no bug - Bumping Thunderbird l10n changesets r=release a=l10n-bump DONTBUILD cs -> f1c527a6f2f1ee55e8417d56e4c14a2518864598 da -> b5b6f26bf5e057fe83237830784e0b60dbc7ac5b de -> 2ac9e34866d97d1d4968804ada2f26d90db945a0 dsb -> 36b5e0e869c31bac80c0ad8ba62684a5f049ac2d el -> 53ce6fe0d56a69eff22ee9d5bc9af344ec89c8ba en-CA -> 18d1b4329a1b330eeade2437a4ba8029f161207f es-AR -> 7f0650e0139ecaf99e5105548280749be477db46 fi -> cde41017e766082c509896f0a548f867853f21fa fr -> a62c145f366a42373029936580682d54b2385fd5 gl -> a11e1f378f5e528f40c53464c8e41d43d7ff83fb he -> 451084278a96f5b75a1c222b2bfd47b23b677475 hsb -> 92867ac0c5c0fbc3175accbba9f17edf5853ab56 it -> 02b99bbe16c8e9d6a436e1dcfba68bccb93a744e kab -> 182fd87767fdd70b0d62602fac31f3d5acb82929 ko -> 20c10df80d494ed2db6e552f8860941d1e29e09a nb-NO -> 42ebec53f695e357c0ed4699354c4e483dd0d7bc nl -> eb50f08d22bfd038141871876fcca9cdd7d916bb pl -> 575fb80af0a5eb9d1dc457fb475128a5e3c665be pt-BR -> cfcabb3c4f81572218873915aa19a2e119c33998 sl -> 559358f238aa79b184fff65fcc5c3298c7722a61 tr -> f35d615de41823c52772a32ddcc9ed4756f310a4 uk -> cacfb29bee1f0551f5baf21fe9955f1710e0a609 zh-CN -> 63ddc513e80002f5fd13a91767a114e3d1a3ac89

<!DOCTYPE html>
    <meta charset="utf-8" />
    <title>JsAccount Usage and Architecture</title>
    <p>JsAccount is a technology that allows message account types to be created
      in Mozilla Mailnews code using JavaScript. Although this is primarily
      targeted at allowing extensions to create new accounts, it might also be
      useful as a bridge to convert existing account types from being C++ based
      to JavaScript based.</p>
    <h2>Existing C++-based architecture of mailnews accounts</h2>
    <p>In mailnews code, an account type is a set of classes that allow
      implementation of a messaging particular protocol. The account type is
      given a short string identifier ("imap", "news", "pop3") and is then used
      to create objects of the appropriate type by appending that string to the
      end of a base XPCOM contractID. So, for example, to create an imap server,
      you generate a contractID using a base ID,
      ";1?type=", then append "imap" to get:</p>
    <p>In the C++ code, there is a base object implementing shared
      functionality. An account-specific class inherits that base functionality,
      then extends it to represent the account-specific behavior that is needed.
      This same basic concept is used to represent a whole series of classes
      that are necessary to implement a specific mailnews account type.</p>
    <p>For the server example, there is a base class named
      nsMsgIncomingServer.cpp that implements that base interface
      nsIMsgIncomingServer.idl. For imap, there is a specific class
      nsImapIncomingServer.cpp that inherits from nsMsgIncomingServer.cpp,
      overrides some of the methods in nsIMsgIncomingServer.idl, and also
      implements an imap-specific interface nsIImapIncomingServer.idl. All of
      this works fine using C++ inheritance and polymorphism.</p>
    <p>Although JsAccount is intended mostly for mailnews accounts, the same
      basic method of using a base class extended for specific types is also used
      in other ways in mailnews code, including for addressbook types and views.
      The technology may also be applied to those other object types as well.</p>
    <h2>Role of JsAccount</h2>
    <p>The JavaScript class system works very differently than the C++ system,
      and you cannot use normal language constructs to override a C++ class with
      a JavaScript class. What JsAccount allows you to do is to create XPCOM
      objects in JavaScript, and use those objects to override or extend the
      methods from the C++ base class in a way that will function correctly
      whether those objects are executed from within C++ code or JavaScript
      code. This allows you to create a new account using JavaScript code, while
      using the same base class functionality that is used by the core C++
      account types. Thus a new account type may be created in JavaScript-based
      extension. The technology may also be used to create JavaScript
      versions of existing account types in an incremental manner, slowly
      converting methods from C++ to JavaScript.</p>