A XUL version of the math app example. Some assembly required with the
authorphasefx <phasefx@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 11 Feb 2005 15:50:47 +0000 (15:50 +0000)
committerphasefx <phasefx@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 11 Feb 2005 15:50:47 +0000 (15:50 +0000)
client_config.xml file.

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@46 9efc2488-bf62-4759-914b-345cdb29e865

examples/math_xul_client/Makefile [new file with mode: 0644]
examples/math_xul_client/install.js [new file with mode: 0644]
examples/math_xul_client/math/content/conf/client_config.xml [new file with mode: 0644]
examples/math_xul_client/math/content/contents.rdf [new file with mode: 0644]
examples/math_xul_client/math/content/math.xul [new file with mode: 0644]
examples/math_xul_client/math/content/math_app.js [new file with mode: 0644]
examples/math_xul_client/math/content/math_overlay.xul [new file with mode: 0644]
examples/math_xul_client/math/locale/en-US/contents.rdf [new file with mode: 0644]
examples/math_xul_client/math/locale/en-US/math.dtd [new file with mode: 0644]
examples/math_xul_client/math/skin/contents.rdf [new file with mode: 0644]
examples/math_xul_client/math/skin/math.css [new file with mode: 0644]

diff --git a/examples/math_xul_client/Makefile b/examples/math_xul_client/Makefile
new file mode 100644 (file)
index 0000000..41ac95c
--- /dev/null
@@ -0,0 +1,19 @@
+all: clean client
+       @echo
+
+client:
+       @echo We need the OpenSRF javascript code...
+       mkdir math/content/OpenSRF/
+       cp ../../src/javascript/*.js math/content/OpenSRF/
+       @echo We need a log directory...
+       mkdir math/content/log
+       touch math/content/log/preserve.directory.when.zipping
+       @echo We also need a math/content/conf/client_config.xml pointing to a running OpenSRF Math application.
+       @echo Then we package this into a Mozilla XPI file...
+       zip -q -r math.xpi install.js math/
+       @echo After installing the XPI, use the chrome URL:
+       @echo chrome://math/content/
+
+clean:
+       @echo Removing the OpenSRF javascript code, the log directory, and math.xpi...
+       rm -rf math/content/OpenSRF/ math/content/log math.xpi
diff --git a/examples/math_xul_client/install.js b/examples/math_xul_client/install.js
new file mode 100644 (file)
index 0000000..0b10d3d
--- /dev/null
@@ -0,0 +1,98 @@
+// ripped from Evergreen installation file
+
+/* We'll want to make this more flexible later */
+
+install();
+
+// ----------------------------------------------------------------------------
+// Performs the install
+// ----------------------------------------------------------------------------
+function install() {
+
+       // ----------------------------------------------------------------------------
+       var _authors = "PINES";
+       var _package = "math";
+       var _packg_l = "math";
+       var _version = "0.0.1";
+       // ----------------------------------------------------------------------------
+
+       var err; // track the error
+
+       err = initInstall( _package, "/"+_authors+"/"+_package, _version );
+       if( err != 0 ) { return warn( "initInstall: " + err );}
+
+       // ----------------------------------------------------------------------------
+       // Discovers the path to the install directory
+       // ----------------------------------------------------------------------------
+       install_dir = getFolder("Chrome", _packg_l );
+       logComment( "Installing to: " + install_dir );
+
+       // ----------------------------------------------------------------------------
+       // Directory where the 'content' is stored
+       // ----------------------------------------------------------------------------
+       content_dir = getFolder( install_dir, "content" );
+       if( err != 0 ) { return warn("getFolder:content_dir: " + err);}
+       
+       // ----------------------------------------------------------------------------
+       // Directory where the skins are stored
+       // ----------------------------------------------------------------------------
+       skin_dir = getFolder( install_dir, "skin" );
+       if( err != 0 ) { return warn("getFolder:skin: " + err);}
+
+       // ----------------------------------------------------------------------------
+       // Directory where the local data is stored
+       // ----------------------------------------------------------------------------
+       locale_dir = getFolder( install_dir, "locale" );
+       if( err != 0 ) { return warn("getFolder:locale: " + err);}
+
+       // ----------------------------------------------------------------------------
+       // Sets the install directory for Evergreen
+       // ----------------------------------------------------------------------------
+       err = setPackageFolder(install_dir);
+       if( err != 0 ) { return warn("setPackageFolder: " + err);}
+       
+       // ----------------------------------------------------------------------------
+       // Searches the .xpi file for the directory name stored in _packg_l and
+       // copies that directory from the .xpi into Mozilla's chrome directory.
+       // In this case, we are copying over the entire evergreen folder
+       // ----------------------------------------------------------------------------
+       err = addDirectory( _packg_l )
+       if( err != 0 ) { return warn("addDirectory: " + err);}
+       
+
+       // ----------------------------------------------------------------------------
+       // Register the content directory
+       // The final argument is where Mozilla should expect to find the contents.rdf 
+       // file *after* installation for the CONTENT portion of the package
+       // ----------------------------------------------------------------------------
+       err = registerChrome( Install.CONTENT, content_dir );
+       if( err != 0 ) { return warn("registerChrome:content  " + err );}
+       
+       // ----------------------------------------------------------------------------
+       // Register the skin directory
+       // ----------------------------------------------------------------------------
+       err = registerChrome( Install.SKIN, skin_dir );
+       if( err != 0 ) { return warn("registerChrome:skin " + err );}
+
+       // ----------------------------------------------------------------------------
+       // Register the locale directory 
+       // ----------------------------------------------------------------------------
+       //err = registerChrome( Install.LOCALE, locale_dir );
+       //if( err != 0 ) { return warn("registerChrome:locale " + err );}
+
+       err = registerChrome( Install.LOCALE, getFolder(locale_dir, "en-US") );
+       if( err != 0 ) { return warn("registerChrome:locale " + err );}
+
+       // ----------------------------------------------------------------------------
+       // Do it.
+       // ----------------------------------------------------------------------------
+       performInstall();
+       
+}
+
+function warn( message ) {
+       alert( message );
+       logComment( message );
+       return;
+}
+
diff --git a/examples/math_xul_client/math/content/conf/client_config.xml b/examples/math_xul_client/math/content/conf/client_config.xml
new file mode 100644 (file)
index 0000000..0dc75a9
--- /dev/null
@@ -0,0 +1,53 @@
+<?xml version="1.0" ?>
+
+<oils_config>
+
+       <!-- General system settings -->
+
+       <system>
+               <hostname>myhostname</hostname>
+
+               <!-- log_level
+                       Levels run between 0 and 3.  O is no logging.  3 is full debug output -->
+               <log_level>0</log_level>
+
+               <!--  stdout_log
+                       When set to 0, no stdout logging is done, when set to 1, all logging
+                       goes to both stdout as well as their destined log file, if set to
+                       2, the messages only go to stdout.  -->
+               <stdout_log>0</stdout_log>
+       </system>
+
+
+       <!-- Log files -->
+
+       <logs>
+               <debug>debug.log</debug>
+               <transport>transport.log</transport>
+               <error>error.log</error>
+       </logs>
+
+       <!-- Remote services -->
+
+       <remote_service>
+               <math>router@localhost/math</math>
+               <mathdb>router@localhost/mathdb</mathdb>
+               <storage>router@localhost/storage</storage>
+       </remote_service>
+       
+       <!-- Transport -->
+
+       <transport>
+               <transport_impl>jabber_connection</transport_impl>
+
+               <!-- connect_timeout doubles as both the low level transport timeout
+                       as well as the app connection timeout -->
+               <connect_timeout>15</connect_timeout>
+               <username>math_user</username>
+               <password>math_user_password</password>
+               <primary>localhost</primary>
+               <port>5222</port>
+               <ssl>0</ssl>
+       </transport>
+
+</oils_config>
diff --git a/examples/math_xul_client/math/content/contents.rdf b/examples/math_xul_client/math/content/contents.rdf
new file mode 100644 (file)
index 0000000..7a8fb13
--- /dev/null
@@ -0,0 +1,17 @@
+<?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:math"/>
+       </RDF:Seq>
+
+       <RDF:Description about="urn:mozilla:package:math"
+               chrome:displayName="Math"
+               chrome:author="PINES"
+               chrome:name="math"
+               chrome:extension="true"/>
+
+</RDF:RDF>
+
diff --git a/examples/math_xul_client/math/content/math.xul b/examples/math_xul_client/math/content/math.xul
new file mode 100644 (file)
index 0000000..1396a0b
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<!-- Test Application: Math -->
+
+<!-- Stylesheets -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://math/skin/math.css" type="text/css"?>
+
+<!-- Localization -->
+<!DOCTYPE window SYSTEM "chrome://math/locale/math.dtd">
+
+<window id="math_win" title="&math.title;" orient="vertical" style="overflow: auto"
+       xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+       <!-- Overlays for this XUL file -->
+       <?xul-overlay href="chrome://math/content/math_overlay.xul"?>
+
+       <!-- OpenSRF -->
+       <script>var myPackageDir = "math";</script>
+       <script src="OpenSRF/JSON.js" />
+       <script src="OpenSRF/md5.js" />
+       <script src="OpenSRF/opensrf_utils.js" />
+       <script src="OpenSRF/opensrf_config.js" />
+       <script src="OpenSRF/opensrf_dom_element.js" />
+       <script src="OpenSRF/opensrf_domain_object.js" />
+       <script src="OpenSRF/opensrf_transport.js" />
+       <script src="OpenSRF/opensrf_jabber_transport.js" />
+       <script src="OpenSRF/opensrf_msg_stack.js" />
+       <script src="OpenSRF/opensrf_app_session.js" />
+
+       <!-- The logic for this app -->
+       <script src="math_app.js" />
+
+       <!-- Layout to be filled in by overlays and javascript -->
+       <vbox id="main_vbox" class="test_class">
+       </vbox>
+
+</window>
+
diff --git a/examples/math_xul_client/math/content/math_app.js b/examples/math_xul_client/math/content/math_app.js
new file mode 100644 (file)
index 0000000..2b98694
--- /dev/null
@@ -0,0 +1,50 @@
+// connect and stup
+
+var ses;
+
+function execute( opp ) {
+
+       var a = document.getElementById("num1");
+       var b = document.getElementById("num2");
+       do_stuff( opp, a.value, b.value );
+
+}
+
+function do_stuff( opp, a, b ) {
+
+
+
+       try {
+
+               if( ses == null || ! AppSession.transport_handle.connected() ) {
+
+                       /* deprecated */
+                       ses = new AppSession( "user_name", "12345", "math" );
+                       if( ! ses.connect() ) { alert( "Connect timed out!" ); }
+               }
+
+               var meth = new oilsMethod(opp, [ a, b ] );
+
+               var req = new AppRequest( ses, meth );
+               req.make_request();
+               var resp = req.recv( 5000 );
+               if( ! resp ) {
+                       alert( "NO response from server!!!" );
+                       quit(); return;
+               }
+       
+               var scalar = resp.getContent();
+               var value = scalar.getValue();
+
+               var lab = document.getElementById( "answer" );
+               lab.value = "Answer: " + value;
+               req.finish();
+
+       } catch( E ) { alert( E.message ); }    
+
+}
+
+
+function quit() { ses.disconnect(); window.close(); }
+
+
diff --git a/examples/math_xul_client/math/content/math_overlay.xul b/examples/math_xul_client/math/content/math_overlay.xul
new file mode 100644 (file)
index 0000000..1a4b69c
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://math/skin/math.css" type="text/css"?>
+<!DOCTYPE overlay SYSTEM "chrome://math/locale/math.dtd">
+<overlay id="math_overlay" 
+       xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<vbox id="main_vbox" flex="1">
+       <label value="&math.title;" />
+       <textbox id="num1" />
+       <textbox id="num2" />
+       <grid flex="1" class="test_class">
+               <columns>
+                       <column />
+                       <column />
+               </columns>
+               <rows>
+                       <row>
+                               <button label="&math.add;" oncommand="execute('add');"/>
+                               <button label="&math.sub;" oncommand="execute('sub');"/>
+                       </row>
+                       <row>
+                               <button label="&math.mul;" oncommand="execute('mult');"/>
+                               <button label="&math.div;" oncommand="execute('div');"/>
+                       </row>
+               </rows>
+       </grid>
+       <label id="answer" value="" />
+       <button label="&math.quit;" oncommand="quit();"/>
+</vbox>
+
+</overlay>
diff --git a/examples/math_xul_client/math/locale/en-US/contents.rdf b/examples/math_xul_client/math/locale/en-US/contents.rdf
new file mode 100644 (file)
index 0000000..01b2e7f
--- /dev/null
@@ -0,0 +1,19 @@
+<?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:locale:root">
+               <RDF:li resource="urn:mozilla:locale:en-US"/>
+       </RDF:Seq>
+
+       <RDF:Description about="urn:mozilla:locale:en-US"
+               chrome:displayName="Math"
+               chrome:author="PINES"
+               chrome:name="en-US">
+               <chrome:packages>
+                       <RDF:Seq about="urn:mozilla:locale:en-US:packages">
+                               <RDF:li resource="urn:mozilla:locale:en-US:math"/>      
+                       </RDF:Seq>
+               </chrome:packages>
+       </RDF:Description>
+</RDF:RDF>
+
diff --git a/examples/math_xul_client/math/locale/en-US/math.dtd b/examples/math_xul_client/math/locale/en-US/math.dtd
new file mode 100644 (file)
index 0000000..16917f6
--- /dev/null
@@ -0,0 +1,7 @@
+<!ENTITY math.title "Math App">
+<!ENTITY math.add "Add">
+<!ENTITY math.sub "Subtract">
+<!ENTITY math.mul "Multiply">
+<!ENTITY math.div "Divide">
+<!ENTITY math.quit "Quit">
+
diff --git a/examples/math_xul_client/math/skin/contents.rdf b/examples/math_xul_client/math/skin/contents.rdf
new file mode 100644 (file)
index 0000000..b27f9ca
--- /dev/null
@@ -0,0 +1,23 @@
+<?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:skin:root">
+               <RDF:li resource="urn:mozilla:skin:math/1.0"/>
+       </RDF:Seq>
+
+       <RDF:Description about="urn:mozilla:skin:math/1.0"
+               chrome:displayName="Math"
+               chrome:author="PINES"
+               chrome:name="math/1.0">
+
+               <chrome:packages>
+                       <RDF:Seq about="urn:mozilla:skin:math/1.0:packages">
+                               <RDF:li resource="urn:mozilla:skin:math/1.0:math"/>     
+                       </RDF:Seq>
+               </chrome:packages>
+       </RDF:Description>
+
+</RDF:RDF>
+
diff --git a/examples/math_xul_client/math/skin/math.css b/examples/math_xul_client/math/skin/math.css
new file mode 100644 (file)
index 0000000..106bd74
--- /dev/null
@@ -0,0 +1,4 @@
+@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); 
+@namespace html url("http://www.w3.org/TR/REC-html40"); 
+
+.test_class { border: solid thin blue; }