120 likes | 311 Views
Thunderbird extension. outline. Introduction Demo Reference. Introduction. XUL (XML User Interface Language) Mozilla 以 XML 為基礎所發展的語言 , 用來描述用戶介面 RDF (Resource Definition Framework) 透過這個格式來存放 Extension 的註冊訊息與描述資訊 JavaScript 開發 extension 的核心語言 , 是 Mozilla 平臺最為出色的 技術 。 XPInstall
E N D
outline • Introduction • Demo • Reference
Introduction • XUL (XML User Interface Language) Mozilla以XML為基礎所發展的語言,用來描述用戶介面 • RDF (Resource Definition Framework) 透過這個格式來存放Extension的註冊訊息與描述資訊 • JavaScript 開發extension的核心語言,是Mozilla平臺最為出色的技術。 • XPInstall Mozilla 的跨平台安裝技術,提供了一個標準的方式將 XUL 應用程式的各個元件包裝成安裝檔,讓 Mozilla users 可以下載並且安裝執行,以 XPI 格式為標準。XPI 的格式同 ZIP 及 JAR,為 PKZIP 壓縮後的檔案,只是內含可供管理安裝方式的腳本
Introduction(cont.) • XPCOM(Cross-platform Component Object Model) 是一種跨平台元件物件模型,類似於微軟的 COM。它有多種語言繫結(Language Binding),使 XPCOM 元件可使用並實現於C++、JavaScript、Java 及 Python。XPCOM 的介面是由稱為 XPIDL(IDL 的方言)所定義。 XPCOM 自身提供了一套核心元件和類別,例如,檔案和記憶體管理、線程、基本資料結構(strings, arrays, variants)等。大多數 XPCOM 元件並非由核心元件所提供,而是由其他平台(例如 Gecko或 Necko)或應用程式、甚至是延伸套件所提供。
Folder structure helloworld/ chrome.manifest -> Tells thunderbird where your chrome files(UI) are and what to do with them install.rdf -> The description file for your extension ("Install manifest") helloworld.xpi -> Installing packag chrome/ helloworld.jar/ content/ contents.rdf -> The information file for package and overlay overlay.js -> The file with scripts to run in the browser window overlay.xul -> The file describing UI elements to add to the browser window
Install.rdf <?xml version="1.0"?><RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#"> <Description about="urn:mozilla:install-manifest"> <em:id>{241b5bc7-a8aa-44a6-a18d-3054dc6047cf}</em:id> <em:name>Hello World</em:name> <em:version>1.0</em:version> <em:type>2</em:type> <em:creator>phinecos</em:creator> <em:description>”hello world demo” </em:description> <em:homepageURL>http://kb.mozillazine.org/Getting_started_with_extension_development</em:homepageURL> <em:targetApplication> <!-- Thunderbird --> <Description> <em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id> <em:minVersion>2.0</em:minVersion> <em:maxVersion>2.0.0.*</em:maxVersion> </Description> </em:targetApplication> <!-- This is not needed for Firefox 1.1 and later. Only include this if you want to make your extension compatible with older versions --> <em:file> <Description about="urn:mozilla:extension:file:helloworld.jar"> <em:package>content/</em:package> </Description> </em:file> </Description></RDF>
chrome.manifest overlay chrome://messenger/content/mailWindowOverlay.xul chrome://helloworld/content/overlay.xul contenthelloworldjar:chrome/helloworld.jar!/content
overlay.js function helloWorld(){ alert("Hello, world!");}
overlay.xul • <?xml version="1.0"?><overlay id="helloworld-overlay"xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script type="application/x-javascript" src="overlay.js"/> <menubar id="mail-menubar"> <menu id="MyAboutMenu" label="About" insertbefore="tasksMenu"> <menupopup id="menu_TestAbout"> <menuitem id="helloworld-hello" label="Hello, world!" oncommand="helloWorld();"/> </menupopup> </menu> </menubar></overlay>
Contents.rdf <?xml version="1.0"?><RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"xmlns:chrome="http://www.mozilla.org/rdf/chrome#"> <RDF:Seq about="urn:mozilla:package:root"> <RDF:li resource="urn:mozilla:package:helloworld"/> </RDF:Seq> <!-- package information --> <RDF:DescriptionRDF:about="urn:mozilla:package:helloworld"chrome:name="helloworld"chrome:extension="true"chrome:displayName="Hello World"chrome:author="phinecos"chrome:authorURL="http://kb.mozillazine.org/Getting_started_with_extension_development"chrome:description="The Classical Demo With Hello World"> </RDF:Description> <!-- overlay information --> <RDF:Seq about="urn:mozilla:overlays"> <RDF:li resource="chrome://messenger/content/mailWindowOverlay.xul"/> </RDF:Seq> <RDF:Seq about="chrome://messenger/content/mailWindowOverlay.xul"> <RDF:li>chrome://helloworld/content/overlay.xul</RDF:li> </RDF:Seq></RDF:RDF>
helloworld.xpi • 壓縮 content資料夾成helloworld.zip,接著更改檔案類型為.jar • 接著將chrome資料夾以及chrome.manifest,install.rdf壓縮成helloworld.zip,街著將檔案類型改成.xpi以進行後續的安裝
Reference http://www.cnblogs.com/phinecos/archive/2008/04/21/1164466.html http://kb.mozillazine.org/Getting_started_with_extension_development