[izpack-changes] r1666 - in izpack-src/trunk: . src/doc-ng/XHTML src/lib/com/coi/tools/os/win src/native/win/COIOSHelper/Release src/native/win/COIOSHelper/Release_Unicode

noreply at berlios.de noreply at berlios.de
Wed Dec 13 18:09:51 CET 2006


Author: bartzkau
Date: 2006-12-13 18:09:51 +0100 (Wed, 13 Dec 2006)
New Revision: 1666

Modified:
   izpack-src/trunk/Versions.txt
   izpack-src/trunk/src/doc-ng/XHTML/izpack-doc.html
   izpack-src/trunk/src/doc-ng/XHTML/node4.html
   izpack-src/trunk/src/doc-ng/XHTML/node9.html
   izpack-src/trunk/src/lib/com/coi/tools/os/win/RegistryImpl.java
   izpack-src/trunk/src/native/win/COIOSHelper/Release/COIOSHelper.dll
   izpack-src/trunk/src/native/win/COIOSHelper/Release_Unicode/COIOSHelper.dll
Log:
Handling of keys and values directly under a root implemented.


Modified: izpack-src/trunk/Versions.txt
===================================================================
--- izpack-src/trunk/Versions.txt	2006-12-07 11:04:26 UTC (rev 1665)
+++ izpack-src/trunk/Versions.txt	2006-12-13 17:09:51 UTC (rev 1666)
@@ -12,6 +12,8 @@
 - Added conditions to UserInputPanel-fields (Dennis Reil)
 - Heading panel strings can be depend on the panelid (Klaus Bartz, thanks
   to Stefan Wachter).
+- Registry access extended to keys and values directly under a root key
+  (Klaus Bartz, thanks to Markus Schlegel).
 - Added dtd for conditions (Dennis Reil)
 - Added support for panelid in InstallerImage-Definition (Dennis Reil)
 - Added support for customicons (Dennis Reil)

Modified: izpack-src/trunk/src/doc-ng/XHTML/izpack-doc.html
===================================================================
--- izpack-src/trunk/src/doc-ng/XHTML/izpack-doc.html	2006-12-07 11:04:26 UTC (rev 1665)
+++ izpack-src/trunk/src/doc-ng/XHTML/izpack-doc.html	2006-12-13 17:09:51 UTC (rev 1666)
@@ -275,6 +275,10 @@
               <li>
                 <a name="tex2html84" href="node4.html#SECTION00441000000000000000">HelloPanel</a>
               </li>
+			  <li>
+			    <a name="tex2html84a" href="node4.html#SECTION00441000000000000000a">CheckedHelloPanel</a>
+			  </li>
+
               <li>
                 <a name="tex2html85" href="node4.html#SECTION00442000000000000000">InfoPanel and htmlInfoPanel</a>
               </li>

Modified: izpack-src/trunk/src/doc-ng/XHTML/node4.html
===================================================================
--- izpack-src/trunk/src/doc-ng/XHTML/node4.html	2006-12-07 11:04:26 UTC (rev 1665)
+++ izpack-src/trunk/src/doc-ng/XHTML/node4.html	2006-12-13 17:09:51 UTC (rev 1666)
@@ -129,6 +129,8 @@
 <ul>
 <li><a name="tex2html400" href="node4.html#SECTION00441000000000000000">HelloPanel</a></li>
 
+<li><a name="tex2html400a" href="node4.html#SECTION00441000000000000000a">CheckedHelloPanel</a></li>
+
 <li><a name="tex2html401" href="node4.html#SECTION00442000000000000000">InfoPanel and HTMLInfoPanel</a></li>
 
 <li><a name="tex2html402" href="node4.html#SECTION00443000000000000000">LicencePanel and HTMLLicencePanel</a></li>
@@ -1048,6 +1050,14 @@
 <p>This panel welcomes the user by displaying the project name, the version, the URL as well as the authors.<br />
 </p>
 
+<h2><a name="SECTION00441000000000000000a">CheckedHelloPanel</a></h2>
+
+<p>This panel welcomes the user also by displaying the project name, the version, the URL as well as the authors.<br />
+<p>Additonal on windows the registry will be scanned for an entry which determines that the product is already installed.
+If so, a dialog will be shown which ask whether to install a second version of the product or not. If you use this
+panel do not forget to add the <a href="./node9.html#RegistryListener">registry feature</a> into your installation.</p>
+</p>
+
 <h2><a name="SECTION00442000000000000000">InfoPanel and HTMLInfoPanel</a></h2>
 
 <p>This is a kind of 'README' panel. It presents text of any length. The text is specified by the <tt>(HTML)InfoPanel.info</tt> resource. Starting from IzPack 3.7.0, variables substitution is

Modified: izpack-src/trunk/src/doc-ng/XHTML/node9.html
===================================================================
--- izpack-src/trunk/src/doc-ng/XHTML/node9.html	2006-12-07 11:04:26 UTC (rev 1665)
+++ izpack-src/trunk/src/doc-ng/XHTML/node9.html	2006-12-13 17:09:51 UTC (rev 1666)
@@ -702,7 +702,9 @@
 	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND</p>
 	<p>The listeners themselves are only able to write into the Windows registry at installation and
 	delet the writing at uninstall time. But it is also possible to use the registry 
-	handler as a registry reader in custom panels or costum actions.</p>
+	handler as a registry reader in custom panels or costum actions. 
+	The <a href="./node4.html#SECTION00441000000000000000a">CheckedHelloPanel</a> reads the registry and
+	can be used as example for it.</p>
 	<p>To add registry support to an installation some changes in the installation definition
 	file (often called<tt>install.xml</tt>) are to be made. First the declaration of the listener 
 	themselves:</p>
@@ -768,6 +770,17 @@
     structure in install.xml (for more information see also installation.dtd). Only the "things"
     included in the <tt>&lt;pack&gt;</tt> are performed, if a pack with the same name was chosen to
     be installed. Valid "things" are &lt;key&gt; &lt;value&gt;.</p>
+	<p><a name="RegRootEntry"></a> The registry stuff self allows to create keys and values directly under a registry root.
+	But Windows self allows this not on "real" roots like HKEY_LOCAL_MACHINE or HKEY_USERS. Only link like
+	roots as HKEY_CLASSES_ROOT are writeable. A try e.g. on HKLM will be cause an exception and the installation
+	fails. The error number in this case normally will be 87 with the meaning "wrong parameter", not 
+	"permission denied".</p>
+	<p>We do NOT recommend to create a key or a value directly on a registry root. IzPack
+	allows it now as a result of some user requests about it.
+	Most it is not needed. E.g. an extension entry under HKEY_CLASSES_ROOT is really an entry on
+	HKEY_LOCAL_MACHINE\Software\Classes. Why not write directly there?Reading is in opposite to writing
+	no problem.</p>
+	
 
     <h3><a name="RegListKeyElm"></a><tt>&lt;key&gt;</tt>: define a key</h3>
 
@@ -775,7 +788,9 @@
 
     <ul>
       <li>
-        <tt>keypath</tt> : required. The path of the key in Windows syntax without the root.
+        <tt>keypath</tt> : required. The path of the key in Windows syntax without the root.<br>
+		If the key should be placed directly under a registry root (<a href="#RegRootEntry">not recommended; 
+		often not possible)</a>) write the key name without any backslash.
       </li>
 
       <li>
@@ -790,11 +805,16 @@
 
     <ul>
       <li>
-        <tt>name</tt> : required. The name of the value to be set or modified without a path.
+        <tt>name</tt> : required. The name of the value to be set or modified without a path.<br>
+		The default value will be written as the empty string &quot;&quot;.
       </li>
       <li>
         <tt>keypath</tt> : required. The key path under which the value should be placed 
                  in Windows syntax without the root and value name.
+		If the key of the value should be placed directly under a registry root (if not exist,  
+		<a href="#RegRootEntry">not recommended; often not possible)</a>) write the key name without any backslash.<br>
+		If the value should be placed directly under a registry root (also not recommended and
+		often not possible) write as keypath the empty string &quot;&quot;.
       </li>
 
       <li>

Modified: izpack-src/trunk/src/lib/com/coi/tools/os/win/RegistryImpl.java
===================================================================
--- izpack-src/trunk/src/lib/com/coi/tools/os/win/RegistryImpl.java	2006-12-07 11:04:26 UTC (rev 1665)
+++ izpack-src/trunk/src/lib/com/coi/tools/os/win/RegistryImpl.java	2006-12-13 17:09:51 UTC (rev 1666)
@@ -83,6 +83,8 @@
      */
     public RegDataContainer getValue(String key, String value) throws NativeLibException
     {
+        if( key == null)
+            key = "";
         return (getValue(currentRoot, key, value));
     }
 
@@ -97,6 +99,8 @@
      */
     public Object getValueAsObject(String key, String value) throws NativeLibException
     {
+        if( key == null)
+            key = "";
         return (getValue(currentRoot, key, value).getDataAsObject());
     }
 
@@ -109,6 +113,8 @@
      */
     public String[] getSubkeys(String key) throws NativeLibException
     {
+        if( key == null)
+            key = "";
         return (getSubkeyNames(currentRoot, key));
     }
 
@@ -121,6 +127,8 @@
      */
     public String[] getValueNames(String key) throws NativeLibException
     {
+        if( key == null)
+            key = "";
         return (getValueNames(currentRoot, key));
     }
 
@@ -136,7 +144,13 @@
     }
 
     /**
-     * Creates the given key under the given root.
+     * Creates the given key under the given root. 
+     * It is possible to declare keys without a sub path.
+     * This is only possible on roots which are no real roots
+     * (e.g. HKEY_CURRENT_USER which is a link to
+     * HKEY_USERS\GUID of current user). Therefore this method
+     * will be raise an exception if root is a real root and
+     * key contains no sub path.
      * 
      * @param root to be used
      * @param key key to be created
@@ -145,12 +159,13 @@
     public void createKey(int root, String key) throws NativeLibException
     {
         int pathEnd = key.lastIndexOf('\\');
-        if (pathEnd < 0)
-            throw new NativeLibException("Keys directly under the root are not allowed!");
-        String subkey = key.substring(0, pathEnd);
-        if (!exist(root, subkey))
-        { // Create missing sub keys
-            createKey(root, subkey);
+        if( pathEnd > 0 )
+        {
+            String subkey = key.substring(0, pathEnd);
+            if (!exist(root, subkey))
+            { // Create missing sub keys
+                createKey(root, subkey);
+            }
         }
         // Create key
         createKeyN(root, key);
@@ -204,6 +219,8 @@
      */
     public boolean valueExist(String key, String value) throws NativeLibException
     {
+        if( key == null)
+            key = "";
         try
         {
             this.getValue(currentRoot, key, value);
@@ -309,6 +326,10 @@
     {
         RegDataContainer oldContents = null;
         String localValue = value;
+        if( key == null)
+            key = "";
+        if(value == null)   // We allow it for the default value...
+            value = "";
         // May be someone do not like backslashes ...
         key = key.replace('/', '\\');
 
@@ -414,6 +435,8 @@
      */
     private void deleteValueL(int root, String key, String value) throws NativeLibException
     {
+        if( key == null)
+            key = "";
         RegDataContainer oldContents = getValue(currentRoot, key, value);
         RegistryLogItem rli = new RegistryLogItem(RegistryLogItem.REMOVED_VALUE, root, key, value,
                 null, oldContents);
@@ -437,6 +460,8 @@
             while (iter.hasNext())
             {
                 RegistryLogItem rli = (RegistryLogItem) iter.next();
+                String rliValueName = (DEFAULT_PLACEHOLDER.equals(rli.getValueName())) ? "" : rli
+                        .getValueName();
                 switch (rli.getType())
                 {
                 case RegistryLogItem.CREATED_KEY:
@@ -447,12 +472,10 @@
                     break;
                 case RegistryLogItem.CREATED_VALUE:
                     RegDataContainer currentContents = null;
-                    // Delete value only if reg entry exists and equal to the
-                    // stored
-                    // value.
+                    // Delete value only if reg entry exists and is equal to the stored value.
                     try
                     {
-                        currentContents = getValue(rli.getRoot(), rli.getKey(), rli.getValueName());
+                        currentContents = getValue(rli.getRoot(), rli.getKey(), rliValueName);
                     }
                     catch (NativeLibException nle)
                     {
@@ -460,7 +483,7 @@
                     }
                     if (currentContents.equals(rli.getNewValue()))
                     {
-                        deleteValueN(rli.getRoot(), rli.getKey(), rli.getValueName());
+                        deleteValueN(rli.getRoot(), rli.getKey(), rliValueName);
                     }
                     // TODO: what todo if value has changed?
                     break;
@@ -468,11 +491,11 @@
                     // Set old value only if reg entry not exists.
                     try
                     {
-                        getValue(rli.getRoot(), rli.getKey(), rli.getValueName());
+                        getValue(rli.getRoot(), rli.getKey(), rliValueName);
                     }
                     catch (NativeLibException nle)
                     {
-                        setValueN(rli.getRoot(), rli.getKey(), rli.getValueName(), rli
+                        setValueN(rli.getRoot(), rli.getKey(), rliValueName, rli
                                 .getOldValue());
                     }
                     break;
@@ -482,7 +505,7 @@
                     // stored value.
                     try
                     {
-                        currentContents = getValue(rli.getRoot(), rli.getKey(), rli.getValueName());
+                        currentContents = getValue(rli.getRoot(), rli.getKey(), rliValueName);
                     }
                     catch (NativeLibException nle)
                     {
@@ -490,7 +513,7 @@
                     }
                     if (currentContents.equals(rli.getNewValue()))
                     {
-                        setValueN(rli.getRoot(), rli.getKey(), rli.getValueName(), rli
+                        setValueN(rli.getRoot(), rli.getKey(), rliValueName, rli
                                 .getOldValue());
                     }
                     break;

Modified: izpack-src/trunk/src/native/win/COIOSHelper/Release/COIOSHelper.dll
===================================================================
(Binary files differ)

Modified: izpack-src/trunk/src/native/win/COIOSHelper/Release_Unicode/COIOSHelper.dll
===================================================================
(Binary files differ)




More information about the izpack-changes mailing list