<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Vidalia: wixtool.cpp Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.3 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_b47abd1aad201a152869566145babb61.html">src</a> » <a class="el" href="dir_beeb2bbed11c559150a792aad3aaec87.html">tools</a> » <a class="el" href="dir_a8046bfe51066efcf6df0875d23937f6.html">wixtool</a> </div> </div> <div class="contents"> <h1>wixtool.cpp</h1><a href="wixtool_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment">** $Id: wixtool.cpp 3810 2009-06-01 07:00:35Z edmanm $</span> <a name="l00003"></a>00003 <span class="comment">**</span> <a name="l00004"></a>00004 <span class="comment">** Copyright (C) 2009 The Tor Project, Inc.</span> <a name="l00005"></a>00005 <span class="comment">** See LICENSE file for terms; may be used according</span> <a name="l00006"></a>00006 <span class="comment">** Vidalia or Tor license constraints. (dual license)</span> <a name="l00007"></a>00007 <span class="comment">*/</span> <a name="l00008"></a>00008 <a name="l00009"></a>00009 <span class="preprocessor">#include <QFile></span> <a name="l00010"></a>00010 <span class="preprocessor">#include <QDomDocument></span> <a name="l00011"></a>00011 <span class="preprocessor">#include <QTextStream></span> <a name="l00012"></a>00012 <span class="preprocessor">#include <QTextCodec></span> <a name="l00013"></a>00013 <span class="preprocessor">#include <QStringList></span> <a name="l00014"></a>00014 <span class="preprocessor">#include <stdlib.h></span> <a name="l00015"></a>00015 <a name="l00016"></a><a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">00016</a> <span class="preprocessor">#define WIX_ATTR_ID "Id"</span> <a name="l00017"></a><a class="code" href="wixtool_8cpp.html#a31b8eed3d247ab5bd466a20deffe17e9">00017</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_ATTR_DIRACTION "uninstall"</span> <a name="l00018"></a><a class="code" href="wixtool_8cpp.html#a37baffd8c997df02348193be0158daaa">00018</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_ATTR_REGACTION "createAndRemoveOnUninstall"</span> <a name="l00019"></a><a class="code" href="wixtool_8cpp.html#a18644ebf7b31592a66555212cb539ae8">00019</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_ATTR_VALUE "Value"</span> <a name="l00020"></a><a class="code" href="wixtool_8cpp.html#a8641274e476cf339e4ebd74e9d7dd615">00020</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_ATTR_KEY "KeyPath"</span> <a name="l00021"></a><a class="code" href="wixtool_8cpp.html#aba5dcb0ff4d0a78b6f11a306bf59eabd">00021</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_ATTR_GUID "Guid"</span> <a name="l00022"></a><a class="code" href="wixtool_8cpp.html#a40f662f7202636b236c25abfa1da62af">00022</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_ATTR_NAME "Name"</span> <a name="l00023"></a><a class="code" href="wixtool_8cpp.html#ac563d2e9b2798387c9be8d55e44236fc">00023</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_ATTR_REG_TYPE "Type"</span> <a name="l00024"></a><a class="code" href="wixtool_8cpp.html#a511f83a245f8a1c1981196b750ba7336">00024</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_ATTR_REG_NAME "Name"</span> <a name="l00025"></a><a class="code" href="wixtool_8cpp.html#a9c4dcfe551a8558ab94ab54384e46c3a">00025</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_ATTR_REG_ROOT "Root"</span> <a name="l00026"></a><a class="code" href="wixtool_8cpp.html#ad1816185ff660a2fb0885657f9ade861">00026</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_ATTR_REG_KEYPATH "Key"</span> <a name="l00027"></a><a class="code" href="wixtool_8cpp.html#a6f50db3a92e55b993e273cfd218bdaa8">00027</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_ATTR_REG_ACTION "Action"</span> <a name="l00028"></a><a class="code" href="wixtool_8cpp.html#a6fe97c784c1a293fd1e7c9f2b8a47f1a">00028</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_REG_KEY_TYPE "integer"</span> <a name="l00029"></a><a class="code" href="wixtool_8cpp.html#a430130dcedd7ffcb8e88208ad3a99bbf">00029</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_TAG_FILE "File"</span> <a name="l00030"></a><a class="code" href="wixtool_8cpp.html#a0b0bc30ebd5f3a5f92dc1db591b61a6e">00030</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_TAG_DIR "Directory"</span> <a name="l00031"></a><a class="code" href="wixtool_8cpp.html#a1178294de893bae5938009925e44480c">00031</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_TAG_FEATURE "Feature"</span> <a name="l00032"></a><a class="code" href="wixtool_8cpp.html#a48e46c279592e6f277d0396242ae3373">00032</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_TAG_COMPONENT "Component"</span> <a name="l00033"></a><a class="code" href="wixtool_8cpp.html#aa6206134ae1d450c90844217e59e94c0">00033</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_TAG_COMPONENT_REF "ComponentRef"</span> <a name="l00034"></a><a class="code" href="wixtool_8cpp.html#a7e4d9b9d262b463ef0ecbd92f06ad058">00034</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_TAG_CREATEDIR "CreateFolder"</span> <a name="l00035"></a><a class="code" href="wixtool_8cpp.html#a155ab3376a9aeee10762f40bbd02b3e4">00035</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_TAG_REMOVEDIR "RemoveFolder"</span> <a name="l00036"></a><a class="code" href="wixtool_8cpp.html#a2c18182a8c853e5e510d455bde42f335">00036</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_TAG_REGKEY "RegistryKey"</span> <a name="l00037"></a><a class="code" href="wixtool_8cpp.html#a9f609246a92fc7b1df95a8c8c0e716be">00037</a> <span class="preprocessor"></span><span class="preprocessor">#define WIX_TAG_REGVAL "RegistryValue"</span> <a name="l00038"></a>00038 <span class="preprocessor"></span> <a name="l00039"></a><a class="code" href="wixtool_8cpp.html#ad0b549681d0e17f075c872214682d352">00039</a> <span class="keyword">typedef</span> void (*<a class="code" href="wixtool_8cpp.html#ad0b549681d0e17f075c872214682d352">TraverseCallback</a>)(<span class="keywordtype">void</span> *cbdata, QDomElement e); <a name="l00040"></a>00040 <a name="l00041"></a>00041 <span class="comment">/* Splice command takes an element or sub tree from one</span> <a name="l00042"></a>00042 <span class="comment"> * document and inserts it into another. This is useful for</span> <a name="l00043"></a>00043 <span class="comment"> * expanding placeholder elements with their desired content</span> <a name="l00044"></a>00044 <span class="comment"> * for example.</span> <a name="l00045"></a>00045 <span class="comment"> * If an element name is not unique the conventional WiX Id</span> <a name="l00046"></a>00046 <span class="comment"> * attribute can be used to identify the specific element.</span> <a name="l00047"></a>00047 <span class="comment"> */</span> <a name="l00048"></a><a class="code" href="structs___splice_data.html">00048</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structs___splice_data.html">s_SpliceData</a> { <a name="l00049"></a><a class="code" href="structs___splice_data.html#a47a2655cf10fb895df502f881c506339">00049</a> QString <a class="code" href="structs___splice_data.html#a47a2655cf10fb895df502f881c506339">dtag</a>; <a name="l00050"></a><a class="code" href="structs___splice_data.html#a125fbb23be285e11d591b222b24e51f5">00050</a> QString <a class="code" href="structs___splice_data.html#a125fbb23be285e11d591b222b24e51f5">did</a>; <a name="l00051"></a><a class="code" href="structs___splice_data.html#a7bee023ef9224ae8661084803a04c736">00051</a> QDomElement <a class="code" href="structs___splice_data.html#a7bee023ef9224ae8661084803a04c736">splice</a>; <a name="l00052"></a>00052 } <a class="code" href="structs___splice_data.html">SpliceData</a>; <a name="l00053"></a>00053 <a name="l00054"></a>00054 <span class="comment">/* Replace operates on tags by name or Id like Splice but</span> <a name="l00055"></a>00055 <span class="comment"> * only makes modifications to individual elements. Replace</span> <a name="l00056"></a>00056 <span class="comment"> * can also remove elements. (replace with null)</span> <a name="l00057"></a>00057 <span class="comment"> */</span> <a name="l00058"></a><a class="code" href="structs___replace_data.html">00058</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structs___replace_data.html">s_ReplaceData</a> { <a name="l00059"></a><a class="code" href="structs___replace_data.html#a14a678606b34bb631c8a9d7215e403fb">00059</a> QString <a class="code" href="structs___replace_data.html#a14a678606b34bb631c8a9d7215e403fb">dtag</a>; <a name="l00060"></a><a class="code" href="structs___replace_data.html#ad8b8420ccb84e651084f7d6aa5d713c7">00060</a> QString <a class="code" href="structs___replace_data.html#ad8b8420ccb84e651084f7d6aa5d713c7">did</a>; <a name="l00061"></a><a class="code" href="structs___replace_data.html#ad32e89a9adff443b90aac7bc95e8568f">00061</a> QString <a class="code" href="structs___replace_data.html#ad32e89a9adff443b90aac7bc95e8568f">dprop</a>; <a name="l00062"></a><a class="code" href="structs___replace_data.html#a0cf51c2332c0712bd437afdae9b378d3">00062</a> QString <a class="code" href="structs___replace_data.html#a0cf51c2332c0712bd437afdae9b378d3">newtag</a>; <a name="l00063"></a><a class="code" href="structs___replace_data.html#aeaa73889ce34249bb649a82452ef6b8a">00063</a> QString <a class="code" href="structs___replace_data.html#aeaa73889ce34249bb649a82452ef6b8a">newprop</a>; <a name="l00064"></a><a class="code" href="structs___replace_data.html#a2e4279e4902d095ea00ea9e7ede32c35">00064</a> QString <a class="code" href="structs___replace_data.html#a2e4279e4902d095ea00ea9e7ede32c35">newpropval</a>; <a name="l00065"></a>00065 } <a class="code" href="structs___replace_data.html">ReplaceData</a>; <a name="l00066"></a>00066 <a name="l00067"></a>00067 <span class="comment">/* Add operates on tags by name or Id as usual.</span> <a name="l00068"></a>00068 <span class="comment"> */</span> <a name="l00069"></a><a class="code" href="structs___add_data.html">00069</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structs___add_data.html">s_AddData</a> { <a name="l00070"></a><a class="code" href="structs___add_data.html#ab061fca83b4a6c437397943d092185cc">00070</a> QString <a class="code" href="structs___add_data.html#ab061fca83b4a6c437397943d092185cc">dtag</a>; <a name="l00071"></a><a class="code" href="structs___add_data.html#ae6e6f6c5d8869c151ba5ba0c51f72cef">00071</a> QString <a class="code" href="structs___add_data.html#ae6e6f6c5d8869c151ba5ba0c51f72cef">did</a>; <a name="l00072"></a><a class="code" href="structs___add_data.html#a923894fc4fbd9207c37c2e4882cb3be1">00072</a> QString <a class="code" href="structs___add_data.html#a923894fc4fbd9207c37c2e4882cb3be1">newtag</a>; <a name="l00073"></a><a class="code" href="structs___add_data.html#a2d94d08f7aff7c2b5d5a517fc146e8da">00073</a> QString <a class="code" href="structs___add_data.html#a2d94d08f7aff7c2b5d5a517fc146e8da">newprop</a>; <a name="l00074"></a><a class="code" href="structs___add_data.html#a7a44c340a72188b7067f1ff53da177c2">00074</a> QString <a class="code" href="structs___add_data.html#a7a44c340a72188b7067f1ff53da177c2">newpropval</a>; <a name="l00075"></a>00075 } <a class="code" href="structs___add_data.html">AddData</a>; <a name="l00076"></a>00076 <a name="l00077"></a>00077 <span class="comment">/* In order to support local per user installation some basic</span> <a name="l00078"></a>00078 <span class="comment"> * constrains must apply to every component included in a</span> <a name="l00079"></a>00079 <span class="comment"> * package. This includes using a key path for each component</span> <a name="l00080"></a>00080 <span class="comment"> * via registry keys and placing all application data under the</span> <a name="l00081"></a>00081 <span class="comment"> * local user profile folder.</span> <a name="l00082"></a>00082 <span class="comment"> * This utility will navigate the components and convert any</span> <a name="l00083"></a>00083 <span class="comment"> * keys to registry key paths and create folders in the deployment</span> <a name="l00084"></a>00084 <span class="comment"> * hierarchy as required.</span> <a name="l00085"></a>00085 <span class="comment"> */</span> <a name="l00086"></a><a class="code" href="structs___user_local_data.html">00086</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structs___user_local_data.html">s_UserLocalData</a> { <a name="l00087"></a><a class="code" href="structs___user_local_data.html#a9f799485ee8533c68e20261a38eac954">00087</a> QString <a class="code" href="structs___user_local_data.html#a9f799485ee8533c68e20261a38eac954">keypath</a>; <a name="l00088"></a><a class="code" href="structs___user_local_data.html#a2690e06d1f632f9d860868352ed8cb0d">00088</a> QString <a class="code" href="structs___user_local_data.html#a2690e06d1f632f9d860868352ed8cb0d">featureid</a>; <a name="l00089"></a><a class="code" href="structs___user_local_data.html#a9467d093017a24820e8334c5bcac1f8b">00089</a> QStringList <a class="code" href="structs___user_local_data.html#a9467d093017a24820e8334c5bcac1f8b">newcomps</a>; <a name="l00090"></a>00090 } <a class="code" href="structs___user_local_data.html">UserLocalData</a>; <a name="l00091"></a>00091 <a name="l00092"></a>00092 <a name="l00093"></a>00093 <span class="comment">/* Note that we must walk the tree ourselves as locate by ID</span> <a name="l00094"></a>00094 <span class="comment"> * nor suitable select by classification is available in the</span> <a name="l00095"></a>00095 <span class="comment"> * Qt API.</span> <a name="l00096"></a>00096 <span class="comment"> */</span> <a name="l00097"></a>00097 <span class="keywordtype">bool</span> <a name="l00098"></a><a class="code" href="wixtool_8cpp.html#a0b665ee3e037867bacccb945fe7d75df">00098</a> <a class="code" href="wixtool_8cpp.html#a0b665ee3e037867bacccb945fe7d75df">do_walkdoc</a>(QDomNode n, <a name="l00099"></a>00099 <a class="code" href="wixtool_8cpp.html#ad0b549681d0e17f075c872214682d352">TraverseCallback</a> cb, <a name="l00100"></a>00100 <span class="keywordtype">void</span> * cbdata, <a name="l00101"></a>00101 QString *errorMessage) <a name="l00102"></a>00102 { <a name="l00103"></a>00103 QTextStream <a class="code" href="namespacetc.html#aa7353218fd7baef0876bbb422ce818af">error</a>(stderr); <a name="l00104"></a>00104 <span class="keywordflow">if</span> ( !n.isNull() ) { <a name="l00105"></a>00105 <span class="keywordflow">if</span> ( n.isElement() ) { <a name="l00106"></a>00106 QDomElement e = n.toElement(); <a name="l00107"></a>00107 (*cb)(cbdata, e); <a name="l00108"></a>00108 } <a name="l00109"></a>00109 <span class="keywordflow">if</span> ( n.hasChildNodes() ) { <a name="l00110"></a>00110 QDomNodeList subnodes = n.childNodes(); <a name="l00111"></a>00111 <span class="keywordtype">int</span> <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a> = 0; <a name="l00112"></a>00112 <span class="keywordflow">while</span> (i < subnodes.count()) { <a name="l00113"></a>00113 <a class="code" href="wixtool_8cpp.html#a0b665ee3e037867bacccb945fe7d75df">do_walkdoc</a>(subnodes.item(i++), cb, cbdata, errorMessage); <a name="l00114"></a>00114 } <a name="l00115"></a>00115 } <a name="l00116"></a>00116 } <a name="l00117"></a>00117 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00118"></a>00118 } <a name="l00119"></a>00119 <a name="l00120"></a>00120 <span class="keywordtype">bool</span> <a name="l00121"></a><a class="code" href="wixtool_8cpp.html#aa05c0047dbc7b7642784f6d522627600">00121</a> <a class="code" href="wixtool_8cpp.html#aa05c0047dbc7b7642784f6d522627600">walkdoc</a>(QDomDocument *doc, <a name="l00122"></a>00122 <a class="code" href="wixtool_8cpp.html#ad0b549681d0e17f075c872214682d352">TraverseCallback</a> cb, <a name="l00123"></a>00123 <span class="keywordtype">void</span> * cbdata, <a name="l00124"></a>00124 QString *errorMessage) <a name="l00125"></a>00125 { <a name="l00126"></a>00126 QTextStream <a class="code" href="namespacetc.html#aa7353218fd7baef0876bbb422ce818af">error</a>(stderr); <a name="l00127"></a>00127 QDomNode n = doc->documentElement(); <a name="l00128"></a>00128 <a class="code" href="wixtool_8cpp.html#a0b665ee3e037867bacccb945fe7d75df">do_walkdoc</a>(n, cb, cbdata, errorMessage); <a name="l00129"></a>00129 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00130"></a>00130 } <a name="l00131"></a>00131 <a name="l00132"></a>00132 <span class="keywordtype">void</span> <a name="l00133"></a><a class="code" href="wixtool_8cpp.html#ac8e151fa0621b17aa611e9b451250b54">00133</a> <a class="code" href="wixtool_8cpp.html#ac8e151fa0621b17aa611e9b451250b54">splicefunc</a>(<span class="keywordtype">void</span> *cbdata, <a name="l00134"></a>00134 QDomElement e) <a name="l00135"></a>00135 { <a name="l00136"></a>00136 <a class="code" href="structs___splice_data.html">SpliceData</a> *d = <span class="keyword">reinterpret_cast<</span><a class="code" href="structs___splice_data.html">SpliceData</a> *<span class="keyword">></span>(cbdata); <a name="l00137"></a>00137 QString eid = e.attribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>); <a name="l00138"></a>00138 <a name="l00139"></a>00139 <span class="keywordflow">if</span> (e.tagName().compare(d-><a class="code" href="structs___splice_data.html#a47a2655cf10fb895df502f881c506339">dtag</a>) == 0) { <a name="l00140"></a>00140 <span class="comment">/* if a specific Id is set, verify it too. */</span> <a name="l00141"></a>00141 <span class="keywordflow">if</span> (d-><a class="code" href="structs___splice_data.html#a125fbb23be285e11d591b222b24e51f5">did</a>.isEmpty() || <a name="l00142"></a>00142 (eid.size() && !eid.compare(d-><a class="code" href="structs___splice_data.html#a125fbb23be285e11d591b222b24e51f5">did</a>)) ) { <a name="l00143"></a>00143 <a name="l00144"></a>00144 <span class="comment">/* expected behavior is to graft children of the splice under target.</span> <a name="l00145"></a>00145 <span class="comment"> * if we're only given a single element graft it instead.</span> <a name="l00146"></a>00146 <span class="comment"> */</span> <a name="l00147"></a>00147 <span class="keywordflow">if</span> (d-><a class="code" href="structs___splice_data.html#a7bee023ef9224ae8661084803a04c736">splice</a>.hasChildNodes()) { <a name="l00148"></a>00148 QDomNodeList subnodes = d-><a class="code" href="structs___splice_data.html#a7bee023ef9224ae8661084803a04c736">splice</a>.childNodes(); <a name="l00149"></a>00149 <span class="keywordtype">int</span> <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a> = 0; <a name="l00150"></a>00150 <span class="keywordflow">while</span> (i < subnodes.count()) { <a name="l00151"></a>00151 e.appendChild(e.ownerDocument().importNode(subnodes.item(i++), <span class="keyword">true</span>)); <a name="l00152"></a>00152 } <a name="l00153"></a>00153 } <a name="l00154"></a>00154 <span class="keywordflow">else</span> { <a name="l00155"></a>00155 e.appendChild(e.ownerDocument().importNode(d-><a class="code" href="structs___splice_data.html#a7bee023ef9224ae8661084803a04c736">splice</a>, <span class="keyword">true</span>)); <a name="l00156"></a>00156 } <a name="l00157"></a>00157 } <a name="l00158"></a>00158 } <a name="l00159"></a>00159 } <a name="l00160"></a>00160 <span class="comment"></span> <a name="l00161"></a>00161 <span class="comment">/** Make modifications to requested documents.</span> <a name="l00162"></a>00162 <span class="comment"> * returns false on error and <b>errorMessage</b> will be set.</span> <a name="l00163"></a>00163 <span class="comment"> */</span> <a name="l00164"></a>00164 <span class="keywordtype">bool</span> <a name="l00165"></a><a class="code" href="wixtool_8cpp.html#ab1ef43f0e2fc68c1779daa8ff1e99c88">00165</a> <a class="code" href="wixtool_8cpp.html#ab1ef43f0e2fc68c1779daa8ff1e99c88">docsplice</a>(QDomDocument *doc, <a name="l00166"></a>00166 QString arguments, <a name="l00167"></a>00167 QString *errorMessage) <a name="l00168"></a>00168 { <a name="l00169"></a>00169 Q_ASSERT(doc); <a name="l00170"></a>00170 Q_ASSERT(errorMessage); <a name="l00171"></a>00171 <a class="code" href="structs___splice_data.html">SpliceData</a> cbdata; <a name="l00172"></a>00172 <a name="l00173"></a>00173 QStringList spliceinfo = arguments.split(<span class="stringliteral">"="</span>); <a name="l00174"></a>00174 <span class="keywordflow">if</span> (spliceinfo.count() != 2) { <a name="l00175"></a>00175 *errorMessage = <span class="stringliteral">"Invalid argument for splice command: "</span> + arguments; <a name="l00176"></a>00176 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00177"></a>00177 } <a name="l00178"></a>00178 <span class="keywordflow">if</span> (spliceinfo[0].contains(<span class="charliteral">':'</span>)) { <a name="l00179"></a>00179 <span class="comment">/* Id syntax */</span> <a name="l00180"></a>00180 QStringList destinfo = spliceinfo[0].split(<span class="stringliteral">":"</span>); <a name="l00181"></a>00181 cbdata.<a class="code" href="structs___splice_data.html#a47a2655cf10fb895df502f881c506339">dtag</a> = destinfo[0]; <a name="l00182"></a>00182 cbdata.<a class="code" href="structs___splice_data.html#a125fbb23be285e11d591b222b24e51f5">did</a> = destinfo[1]; <a name="l00183"></a>00183 } <a name="l00184"></a>00184 <span class="keywordflow">else</span> { <a name="l00185"></a>00185 cbdata.<a class="code" href="structs___splice_data.html#a47a2655cf10fb895df502f881c506339">dtag</a> = spliceinfo[0]; <a name="l00186"></a>00186 } <a name="l00187"></a>00187 <a name="l00188"></a>00188 QStringList srcinfo = spliceinfo[1].split(<span class="stringliteral">":"</span>); <a name="l00189"></a>00189 <span class="keywordflow">if</span> (srcinfo.count() < 2) { <a name="l00190"></a>00190 *errorMessage = <span class="stringliteral">"Invalid source argument for splice command: "</span> + arguments; <a name="l00191"></a>00191 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00192"></a>00192 } <a name="l00193"></a>00193 QFile spliceFile(srcinfo[0]); <a name="l00194"></a>00194 <span class="keywordflow">if</span> (!spliceFile.open(QIODevice::ReadOnly | QIODevice::Text)) { <a name="l00195"></a>00195 *errorMessage = QString(<span class="stringliteral">"Unable to open '%1' for reading: %2\n"</span>) <a name="l00196"></a>00196 .arg(srcinfo[0]).arg(spliceFile.errorString()); <a name="l00197"></a>00197 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00198"></a>00198 } <a name="l00199"></a>00199 QTextStream sfiletxt(&spliceFile); <a name="l00200"></a>00200 QDomDocument sdoc; <a name="l00201"></a>00201 QString parseError; <a name="l00202"></a>00202 <span class="keywordtype">int</span> badline, badcol; <a name="l00203"></a>00203 <span class="keywordflow">if</span> (!sdoc.setContent (sfiletxt.readAll(), <span class="keyword">false</span>, &parseError, &badline, &badcol)) { <a name="l00204"></a>00204 *errorMessage = QString(<span class="stringliteral">"Error parsing splice document '%1' at line %2 and column %3: %4"</span>) <a name="l00205"></a>00205 .arg(srcinfo[0]).arg(badline).arg(badcol).arg(parseError); <a name="l00206"></a>00206 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00207"></a>00207 } <a name="l00208"></a>00208 <a name="l00209"></a>00209 QDomNodeList elist = sdoc.elementsByTagName(srcinfo[1]); <a name="l00210"></a>00210 <span class="keywordflow">if</span> (elist.count() == 0) { <a name="l00211"></a>00211 *errorMessage = QString(<span class="stringliteral">"Unable to locate splice element '%1' in document.\n"</span>).arg(srcinfo[1]); <a name="l00212"></a>00212 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00213"></a>00213 } <a name="l00214"></a>00214 <span class="keywordflow">if</span> (srcinfo.count() == 3) { <a name="l00215"></a>00215 <span class="comment">/* Id syntax for source elem */</span> <a name="l00216"></a>00216 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>=0; <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a> < elist.count(); <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>++) { <a name="l00217"></a>00217 QString eid = elist.item(<a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>).toElement().attribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>); <a name="l00218"></a>00218 <span class="keywordflow">if</span> (eid.size() && !eid.compare(srcinfo[2])) { <a name="l00219"></a>00219 cbdata.<a class="code" href="structs___splice_data.html#a7bee023ef9224ae8661084803a04c736">splice</a> = elist.item(<a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>).toElement(); <a name="l00220"></a>00220 } <a name="l00221"></a>00221 } <a name="l00222"></a>00222 } <a name="l00223"></a>00223 <span class="keywordflow">else</span> { <a name="l00224"></a>00224 <span class="comment">/* without an Id the tag name should be unique. */</span> <a name="l00225"></a>00225 cbdata.<a class="code" href="structs___splice_data.html#a7bee023ef9224ae8661084803a04c736">splice</a> = elist.item(0).toElement(); <a name="l00226"></a>00226 } <a name="l00227"></a>00227 <span class="keywordflow">return</span> <a class="code" href="wixtool_8cpp.html#aa05c0047dbc7b7642784f6d522627600">walkdoc</a>(doc, &<a class="code" href="wixtool_8cpp.html#ac8e151fa0621b17aa611e9b451250b54">splicefunc</a>, &cbdata, errorMessage); <a name="l00228"></a>00228 } <a name="l00229"></a>00229 <a name="l00230"></a>00230 <span class="keywordtype">void</span> <a name="l00231"></a><a class="code" href="wixtool_8cpp.html#a99be0a45eba760c1d6cc2b409dbbdc8f">00231</a> <a class="code" href="wixtool_8cpp.html#a99be0a45eba760c1d6cc2b409dbbdc8f">replacefunc</a>(<span class="keywordtype">void</span> *cbdata, <a name="l00232"></a>00232 QDomElement e) <a name="l00233"></a>00233 { <a name="l00234"></a>00234 <a class="code" href="structs___replace_data.html">ReplaceData</a> *d = <span class="keyword">reinterpret_cast<</span><a class="code" href="structs___replace_data.html">ReplaceData</a> *<span class="keyword">></span>(cbdata); <a name="l00235"></a>00235 QString eid = e.attribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>); <a name="l00236"></a>00236 <a name="l00237"></a>00237 <span class="keywordflow">if</span> (e.tagName().compare(d-><a class="code" href="structs___replace_data.html#a14a678606b34bb631c8a9d7215e403fb">dtag</a>) == 0) { <a name="l00238"></a>00238 <span class="comment">/* if a specific Id is set, verify it too. */</span> <a name="l00239"></a>00239 <span class="keywordflow">if</span> (d-><a class="code" href="structs___replace_data.html#ad8b8420ccb84e651084f7d6aa5d713c7">did</a>.isEmpty() || <a name="l00240"></a>00240 (eid.size() && !eid.compare(d-><a class="code" href="structs___replace_data.html#ad8b8420ccb84e651084f7d6aa5d713c7">did</a>)) ) { <a name="l00241"></a>00241 <a name="l00242"></a>00242 <span class="comment">/* no destination means remove node from tree */</span> <a name="l00243"></a>00243 <span class="keywordflow">if</span> (d-><a class="code" href="structs___replace_data.html#a0cf51c2332c0712bd437afdae9b378d3">newtag</a>.isNull()) { <a name="l00244"></a>00244 QDomNode parent = e.parentNode(); <a name="l00245"></a>00245 parent.removeChild(e); <a name="l00246"></a>00246 } <a name="l00247"></a>00247 <span class="keywordflow">else</span> { <a name="l00248"></a>00248 <span class="keywordflow">if</span> (d-><a class="code" href="structs___replace_data.html#a0cf51c2332c0712bd437afdae9b378d3">newtag</a>.compare(e.tagName())) { <a name="l00249"></a>00249 e.setTagName (d-><a class="code" href="structs___replace_data.html#a0cf51c2332c0712bd437afdae9b378d3">newtag</a>); <a name="l00250"></a>00250 } <a name="l00251"></a>00251 <span class="keywordflow">if</span> (d-><a class="code" href="structs___replace_data.html#aeaa73889ce34249bb649a82452ef6b8a">newprop</a>.isNull()) { <a name="l00252"></a>00252 <span class="comment">/* clear all attributes (except Id if present) */</span> <a name="l00253"></a>00253 QDomNamedNodeMap attrs = e.attributes(); <a name="l00254"></a>00254 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a> = 0; <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a> < attrs.count(); <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>++) { <a name="l00255"></a>00255 <span class="keywordflow">if</span> (attrs.item(<a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>).nodeName().compare(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>)) { <a name="l00256"></a>00256 e.removeAttribute(attrs.item(<a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>).nodeName()); <a name="l00257"></a>00257 } <a name="l00258"></a>00258 } <a name="l00259"></a>00259 } <a name="l00260"></a>00260 <span class="keywordflow">else</span> { <a name="l00261"></a>00261 <span class="comment">/* only modify / clear a specific property */</span> <a name="l00262"></a>00262 QDomNode prop = e.attributeNode(d-><a class="code" href="structs___replace_data.html#aeaa73889ce34249bb649a82452ef6b8a">newprop</a>); <a name="l00263"></a>00263 <span class="keywordflow">if</span> (!prop.isNull()) { <a name="l00264"></a>00264 e.setAttribute(d-><a class="code" href="structs___replace_data.html#aeaa73889ce34249bb649a82452ef6b8a">newprop</a>, d-><a class="code" href="structs___replace_data.html#a2e4279e4902d095ea00ea9e7ede32c35">newpropval</a>); <a name="l00265"></a>00265 } <a name="l00266"></a>00266 } <a name="l00267"></a>00267 } <a name="l00268"></a>00268 } <a name="l00269"></a>00269 } <a name="l00270"></a>00270 } <a name="l00271"></a>00271 <span class="comment"></span> <a name="l00272"></a>00272 <span class="comment">/** Make modifications to requested documents.</span> <a name="l00273"></a>00273 <span class="comment"> * returns false on error and <b>errorMessage</b> will be set.</span> <a name="l00274"></a>00274 <span class="comment"> */</span> <a name="l00275"></a>00275 <span class="keywordtype">bool</span> <a name="l00276"></a><a class="code" href="wixtool_8cpp.html#a528eb12ced26de43815d1a90e5fdcb2b">00276</a> <a class="code" href="wixtool_8cpp.html#a528eb12ced26de43815d1a90e5fdcb2b">docreplace</a>(QDomDocument *doc, <a name="l00277"></a>00277 QString arguments, <a name="l00278"></a>00278 QString *errorMessage) <a name="l00279"></a>00279 { <a name="l00280"></a>00280 Q_ASSERT(doc); <a name="l00281"></a>00281 Q_ASSERT(errorMessage); <a name="l00282"></a>00282 <a class="code" href="structs___replace_data.html">ReplaceData</a> cbdata; <a name="l00283"></a>00283 <a name="l00284"></a>00284 QStringList replaceinfo = arguments.split(<span class="stringliteral">"="</span>); <a name="l00285"></a>00285 <span class="keywordflow">if</span> (replaceinfo.count() < 1) { <a name="l00286"></a>00286 *errorMessage = <span class="stringliteral">"Invalid argument for replace command: "</span> + arguments; <a name="l00287"></a>00287 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00288"></a>00288 } <a name="l00289"></a>00289 <span class="keywordflow">if</span> (replaceinfo[0].contains(<span class="charliteral">':'</span>)) { <a name="l00290"></a>00290 <span class="comment">/* Id syntax */</span> <a name="l00291"></a>00291 QStringList destinfo = replaceinfo[0].split(<span class="stringliteral">":"</span>); <a name="l00292"></a>00292 cbdata.<a class="code" href="structs___replace_data.html#a14a678606b34bb631c8a9d7215e403fb">dtag</a> = destinfo[0]; <a name="l00293"></a>00293 cbdata.<a class="code" href="structs___replace_data.html#ad8b8420ccb84e651084f7d6aa5d713c7">did</a> = destinfo[1]; <a name="l00294"></a>00294 <span class="keywordflow">if</span> (destinfo.count() >= 3) { <a name="l00295"></a>00295 cbdata.<a class="code" href="structs___replace_data.html#ad32e89a9adff443b90aac7bc95e8568f">dprop</a> = destinfo[2]; <a name="l00296"></a>00296 } <a name="l00297"></a>00297 } <a name="l00298"></a>00298 <span class="keywordflow">else</span> { <a name="l00299"></a>00299 cbdata.<a class="code" href="structs___replace_data.html#a14a678606b34bb631c8a9d7215e403fb">dtag</a> = replaceinfo[0]; <a name="l00300"></a>00300 } <a name="l00301"></a>00301 <span class="keywordflow">if</span> (replaceinfo.count() > 1) { <a name="l00302"></a>00302 QStringList srcinfo = replaceinfo[1].split(<span class="stringliteral">":"</span>); <a name="l00303"></a>00303 <span class="keywordflow">if</span> (srcinfo.count() < 1) { <a name="l00304"></a>00304 *errorMessage = <span class="stringliteral">"Invalid target argument for replace command: "</span> + arguments; <a name="l00305"></a>00305 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00306"></a>00306 } <a name="l00307"></a>00307 <span class="keywordflow">if</span> (srcinfo.count() >= 1) { <a name="l00308"></a>00308 <span class="keywordflow">if</span> (srcinfo[0].length()) cbdata.<a class="code" href="structs___replace_data.html#a0cf51c2332c0712bd437afdae9b378d3">newtag</a> = srcinfo[0]; <a name="l00309"></a>00309 } <a name="l00310"></a>00310 <span class="keywordflow">if</span> (srcinfo.count() >= 2) { <a name="l00311"></a>00311 <span class="keywordflow">if</span> (srcinfo[1].length()) cbdata.<a class="code" href="structs___replace_data.html#aeaa73889ce34249bb649a82452ef6b8a">newprop</a> = srcinfo[1]; <a name="l00312"></a>00312 } <a name="l00313"></a>00313 <span class="keywordflow">if</span> (srcinfo.count() >= 3) { <a name="l00314"></a>00314 <span class="keywordflow">if</span> (srcinfo[2].length()) cbdata.<a class="code" href="structs___replace_data.html#a2e4279e4902d095ea00ea9e7ede32c35">newpropval</a> = srcinfo[2]; <a name="l00315"></a>00315 } <a name="l00316"></a>00316 } <a name="l00317"></a>00317 <span class="keywordflow">return</span> <a class="code" href="wixtool_8cpp.html#aa05c0047dbc7b7642784f6d522627600">walkdoc</a>(doc, &<a class="code" href="wixtool_8cpp.html#a99be0a45eba760c1d6cc2b409dbbdc8f">replacefunc</a>, &cbdata, errorMessage); <a name="l00318"></a>00318 } <a name="l00319"></a>00319 <a name="l00320"></a>00320 <span class="keywordtype">void</span> <a name="l00321"></a><a class="code" href="wixtool_8cpp.html#a6a855614f97f3d0e440e222b5fdf9243">00321</a> <a class="code" href="wixtool_8cpp.html#a6a855614f97f3d0e440e222b5fdf9243">addfunc</a>(<span class="keywordtype">void</span> *cbdata, <a name="l00322"></a>00322 QDomElement e) <a name="l00323"></a>00323 { <a name="l00324"></a>00324 <a class="code" href="structs___add_data.html">AddData</a> *d = <span class="keyword">reinterpret_cast<</span><a class="code" href="structs___add_data.html">AddData</a> *<span class="keyword">></span>(cbdata); <a name="l00325"></a>00325 QString eid = e.attribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>); <a name="l00326"></a>00326 <a name="l00327"></a>00327 <span class="keywordflow">if</span> (e.tagName().compare(d-><a class="code" href="structs___add_data.html#ab061fca83b4a6c437397943d092185cc">dtag</a>) == 0) { <a name="l00328"></a>00328 <span class="comment">/* if a specific Id is set, verify it too. */</span> <a name="l00329"></a>00329 <span class="keywordflow">if</span> (d-><a class="code" href="structs___add_data.html#ae6e6f6c5d8869c151ba5ba0c51f72cef">did</a>.isEmpty() || <a name="l00330"></a>00330 (eid.size() && !eid.compare(d-><a class="code" href="structs___add_data.html#ae6e6f6c5d8869c151ba5ba0c51f72cef">did</a>)) ) { <a name="l00331"></a>00331 <span class="keywordflow">if</span> (d-><a class="code" href="structs___add_data.html#a923894fc4fbd9207c37c2e4882cb3be1">newtag</a>.compare(d-><a class="code" href="structs___add_data.html#ab061fca83b4a6c437397943d092185cc">dtag</a>)) { <a name="l00332"></a>00332 QDomElement ne = e.ownerDocument().createElement(d-><a class="code" href="structs___add_data.html#a923894fc4fbd9207c37c2e4882cb3be1">newtag</a>); <a name="l00333"></a>00333 <span class="keywordflow">if</span> (!d-><a class="code" href="structs___add_data.html#a2d94d08f7aff7c2b5d5a517fc146e8da">newprop</a>.isNull()) { <a name="l00334"></a>00334 ne.setAttribute(d-><a class="code" href="structs___add_data.html#a2d94d08f7aff7c2b5d5a517fc146e8da">newprop</a>, d-><a class="code" href="structs___add_data.html#a7a44c340a72188b7067f1ff53da177c2">newpropval</a>); <a name="l00335"></a>00335 } <a name="l00336"></a>00336 e.appendChild(ne); <a name="l00337"></a>00337 } <a name="l00338"></a>00338 <span class="keywordflow">else</span> { <a name="l00339"></a>00339 e.setAttribute(d-><a class="code" href="structs___add_data.html#a2d94d08f7aff7c2b5d5a517fc146e8da">newprop</a>, d-><a class="code" href="structs___add_data.html#a7a44c340a72188b7067f1ff53da177c2">newpropval</a>); <a name="l00340"></a>00340 } <a name="l00341"></a>00341 } <a name="l00342"></a>00342 } <a name="l00343"></a>00343 } <a name="l00344"></a>00344 <span class="comment"></span> <a name="l00345"></a>00345 <span class="comment">/** Make modifications to requested documents.</span> <a name="l00346"></a>00346 <span class="comment"> * returns false on error and <b>errorMessage</b> will be set.</span> <a name="l00347"></a>00347 <span class="comment"> */</span> <a name="l00348"></a>00348 <span class="keywordtype">bool</span> <a name="l00349"></a><a class="code" href="wixtool_8cpp.html#aa68a06ad334306a3a45937c5b155cc77">00349</a> <a class="code" href="wixtool_8cpp.html#aa68a06ad334306a3a45937c5b155cc77">docadd</a>(QDomDocument *doc, <a name="l00350"></a>00350 QString arguments, <a name="l00351"></a>00351 QString *errorMessage) <a name="l00352"></a>00352 { <a name="l00353"></a>00353 Q_ASSERT(doc); <a name="l00354"></a>00354 Q_ASSERT(errorMessage); <a name="l00355"></a>00355 <a class="code" href="structs___add_data.html">AddData</a> cbdata; <a name="l00356"></a>00356 <a name="l00357"></a>00357 QStringList addinfo = arguments.split(<span class="stringliteral">"="</span>); <a name="l00358"></a>00358 <span class="keywordflow">if</span> (addinfo.count() < 1) { <a name="l00359"></a>00359 *errorMessage = <span class="stringliteral">"Invalid argument for add command: "</span> + arguments; <a name="l00360"></a>00360 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00361"></a>00361 } <a name="l00362"></a>00362 <span class="keywordflow">if</span> (addinfo[0].contains(<span class="charliteral">':'</span>)) { <a name="l00363"></a>00363 <span class="comment">/* Id syntax */</span> <a name="l00364"></a>00364 QStringList destinfo = addinfo[0].split(<span class="stringliteral">":"</span>); <a name="l00365"></a>00365 cbdata.<a class="code" href="structs___add_data.html#ab061fca83b4a6c437397943d092185cc">dtag</a> = destinfo[0]; <a name="l00366"></a>00366 cbdata.<a class="code" href="structs___add_data.html#ae6e6f6c5d8869c151ba5ba0c51f72cef">did</a> = destinfo[1]; <a name="l00367"></a>00367 } <a name="l00368"></a>00368 <span class="keywordflow">else</span> { <a name="l00369"></a>00369 cbdata.<a class="code" href="structs___add_data.html#ab061fca83b4a6c437397943d092185cc">dtag</a> = addinfo[0]; <a name="l00370"></a>00370 } <a name="l00371"></a>00371 <span class="keywordflow">if</span> (addinfo.count() > 1) { <a name="l00372"></a>00372 QStringList srcinfo = addinfo[1].split(<span class="stringliteral">":"</span>); <a name="l00373"></a>00373 <span class="keywordflow">if</span> (srcinfo.count() < 1) { <a name="l00374"></a>00374 *errorMessage = <span class="stringliteral">"Invalid target argument for add command: "</span> + arguments; <a name="l00375"></a>00375 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00376"></a>00376 } <a name="l00377"></a>00377 <span class="keywordflow">if</span> (srcinfo.count() >= 1) { <a name="l00378"></a>00378 <span class="keywordflow">if</span> (srcinfo[0].length()) cbdata.<a class="code" href="structs___add_data.html#a923894fc4fbd9207c37c2e4882cb3be1">newtag</a> = srcinfo[0]; <a name="l00379"></a>00379 } <a name="l00380"></a>00380 <span class="keywordflow">if</span> (srcinfo.count() >= 2) { <a name="l00381"></a>00381 <span class="keywordflow">if</span> (srcinfo[1].length()) cbdata.<a class="code" href="structs___add_data.html#a2d94d08f7aff7c2b5d5a517fc146e8da">newprop</a> = srcinfo[1]; <a name="l00382"></a>00382 } <a name="l00383"></a>00383 <span class="keywordflow">if</span> (srcinfo.count() >= 3) { <a name="l00384"></a>00384 <span class="keywordflow">if</span> (srcinfo[2].length()) cbdata.<a class="code" href="structs___add_data.html#a7a44c340a72188b7067f1ff53da177c2">newpropval</a> = srcinfo[2]; <a name="l00385"></a>00385 } <a name="l00386"></a>00386 } <a name="l00387"></a>00387 <span class="keywordflow">return</span> <a class="code" href="wixtool_8cpp.html#aa05c0047dbc7b7642784f6d522627600">walkdoc</a>(doc, &<a class="code" href="wixtool_8cpp.html#a6a855614f97f3d0e440e222b5fdf9243">addfunc</a>, &cbdata, errorMessage); <a name="l00388"></a>00388 } <a name="l00389"></a>00389 <a name="l00390"></a>00390 <span class="keywordtype">void</span> <a name="l00391"></a><a class="code" href="wixtool_8cpp.html#a9941fd3ceeb1369d0011e610d8e6bf9b">00391</a> <a class="code" href="wixtool_8cpp.html#a9941fd3ceeb1369d0011e610d8e6bf9b">createRegLocalComponent</a>(QDomElement e, <a name="l00392"></a>00392 QString dirName, <a name="l00393"></a>00393 QString keyPath) <a name="l00394"></a>00394 { <a name="l00395"></a>00395 QDomElement nrk = e.ownerDocument().createElement(<a class="code" href="wixtool_8cpp.html#a2c18182a8c853e5e510d455bde42f335">WIX_TAG_REGKEY</a>); <a name="l00396"></a>00396 QDomElement nrv = e.ownerDocument().createElement(<a class="code" href="wixtool_8cpp.html#a9f609246a92fc7b1df95a8c8c0e716be">WIX_TAG_REGVAL</a>); <a name="l00397"></a>00397 nrk.setAttribute(<a class="code" href="wixtool_8cpp.html#a9c4dcfe551a8558ab94ab54384e46c3a">WIX_ATTR_REG_ROOT</a>, <span class="stringliteral">"HKCU"</span>); <a name="l00398"></a>00398 nrk.setAttribute(<a class="code" href="wixtool_8cpp.html#a6f50db3a92e55b993e273cfd218bdaa8">WIX_ATTR_REG_ACTION</a>, <span class="stringliteral">"createAndRemoveOnUninstall"</span>); <a name="l00399"></a>00399 nrk.setAttribute(<a class="code" href="wixtool_8cpp.html#ad1816185ff660a2fb0885657f9ade861">WIX_ATTR_REG_KEYPATH</a>, keyPath); <a name="l00400"></a>00400 nrv.setAttribute(<a class="code" href="wixtool_8cpp.html#ac563d2e9b2798387c9be8d55e44236fc">WIX_ATTR_REG_TYPE</a>, <a class="code" href="wixtool_8cpp.html#a6fe97c784c1a293fd1e7c9f2b8a47f1a">WIX_REG_KEY_TYPE</a>); <a name="l00401"></a>00401 nrv.setAttribute(<a class="code" href="wixtool_8cpp.html#a511f83a245f8a1c1981196b750ba7336">WIX_ATTR_REG_NAME</a>, dirName); <a name="l00402"></a>00402 nrv.setAttribute(<a class="code" href="wixtool_8cpp.html#a18644ebf7b31592a66555212cb539ae8">WIX_ATTR_VALUE</a>, <span class="stringliteral">"1"</span>); <a name="l00403"></a>00403 nrv.setAttribute(<a class="code" href="wixtool_8cpp.html#a8641274e476cf339e4ebd74e9d7dd615">WIX_ATTR_KEY</a>, <span class="stringliteral">"yes"</span>); <a name="l00404"></a>00404 nrk.appendChild(nrv); <a name="l00405"></a>00405 e.appendChild(nrk); <a name="l00406"></a>00406 } <a name="l00407"></a>00407 <a name="l00408"></a>00408 <span class="keywordtype">void</span> <a name="l00409"></a><a class="code" href="wixtool_8cpp.html#a1afad9d3c7f28d2cb1735ba33206e00d">00409</a> <a class="code" href="wixtool_8cpp.html#a1afad9d3c7f28d2cb1735ba33206e00d">createDirMgmtComponent</a>(QDomElement e, <a name="l00410"></a>00410 QString dirName) <a name="l00411"></a>00411 { <a name="l00412"></a>00412 QDomElement nce; <a name="l00413"></a>00413 <span class="comment">/* An empty dir might produce a createdir, so only add if not present. */</span> <a name="l00414"></a>00414 <span class="keywordflow">if</span> (e.elementsByTagName(<a class="code" href="wixtool_8cpp.html#a7e4d9b9d262b463ef0ecbd92f06ad058">WIX_TAG_CREATEDIR</a>).count() == 0) { <a name="l00415"></a>00415 nce = e.ownerDocument().createElement(<a class="code" href="wixtool_8cpp.html#a7e4d9b9d262b463ef0ecbd92f06ad058">WIX_TAG_CREATEDIR</a>); <a name="l00416"></a>00416 e.appendChild(nce); <a name="l00417"></a>00417 } <a name="l00418"></a>00418 nce = e.ownerDocument().createElement(<a class="code" href="wixtool_8cpp.html#a155ab3376a9aeee10762f40bbd02b3e4">WIX_TAG_REMOVEDIR</a>); <a name="l00419"></a>00419 nce.setAttribute(<span class="stringliteral">"On"</span>, <a class="code" href="wixtool_8cpp.html#a31b8eed3d247ab5bd466a20deffe17e9">WIX_ATTR_DIRACTION</a>); <a name="l00420"></a>00420 nce.setAttribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>, QString(<span class="stringliteral">"Remove"</span>).append(dirName)); <a name="l00421"></a>00421 e.appendChild(nce); <a name="l00422"></a>00422 } <a name="l00423"></a>00423 <a name="l00424"></a>00424 <span class="keywordtype">void</span> <a name="l00425"></a><a class="code" href="wixtool_8cpp.html#a72e7d465a52ab4a180000884a8203ef1">00425</a> <a class="code" href="wixtool_8cpp.html#a72e7d465a52ab4a180000884a8203ef1">userlocalfunc</a>(<span class="keywordtype">void</span> *cbdata, <a name="l00426"></a>00426 QDomElement e) <a name="l00427"></a>00427 { <a name="l00428"></a>00428 <a class="code" href="structs___user_local_data.html">UserLocalData</a> *ulinfo = <span class="keyword">reinterpret_cast<</span><a class="code" href="structs___user_local_data.html">UserLocalData</a> *<span class="keyword">></span>(cbdata); <a name="l00429"></a>00429 QString eid = e.attribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>); <a name="l00430"></a>00430 <a name="l00431"></a>00431 <span class="keywordflow">if</span> (e.tagName().compare(<a class="code" href="wixtool_8cpp.html#a430130dcedd7ffcb8e88208ad3a99bbf">WIX_TAG_FILE</a>) == 0) { <a name="l00432"></a>00432 e.removeAttribute(<a class="code" href="wixtool_8cpp.html#a8641274e476cf339e4ebd74e9d7dd615">WIX_ATTR_KEY</a>); <a name="l00433"></a>00433 } <a name="l00434"></a>00434 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (e.tagName().compare(<a class="code" href="wixtool_8cpp.html#a48e46c279592e6f277d0396242ae3373">WIX_TAG_COMPONENT</a>) == 0) { <a name="l00435"></a>00435 <span class="comment">/* If the WiX tools get confused we need to remove KeyPath attrs</span> <a name="l00436"></a>00436 <span class="comment"> * on any component elements after creation or merging.</span> <a name="l00437"></a>00437 <span class="comment"> * Empty directories with a CreateFolder and nothing else will do this.</span> <a name="l00438"></a>00438 <span class="comment"> */</span> <a name="l00439"></a>00439 e.removeAttribute(<a class="code" href="wixtool_8cpp.html#a8641274e476cf339e4ebd74e9d7dd615">WIX_ATTR_KEY</a>); <a name="l00440"></a>00440 } <a name="l00441"></a>00441 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (e.tagName().compare(<a class="code" href="wixtool_8cpp.html#a1178294de893bae5938009925e44480c">WIX_TAG_FEATURE</a>) == 0) { <a name="l00442"></a>00442 <span class="comment">/* be sure to remove any default feature names; changed added above. */</span> <a name="l00443"></a>00443 QDomNodeList cnl = e.elementsByTagName(<a class="code" href="wixtool_8cpp.html#aa6206134ae1d450c90844217e59e94c0">WIX_TAG_COMPONENT_REF</a>); <a name="l00444"></a>00444 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a> = 0; <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a> < cnl.count(); <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>++) { <a name="l00445"></a>00445 QDomElement cre = cnl.item(<a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>).toElement(); <a name="l00446"></a>00446 <span class="keywordflow">if</span> (cre.attribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>).compare(<a class="code" href="wixtool_8cpp.html#a48e46c279592e6f277d0396242ae3373">WIX_TAG_COMPONENT</a>) == 0) { <a name="l00447"></a>00447 e.removeChild(cre); <a name="l00448"></a>00448 } <a name="l00449"></a>00449 } <a name="l00450"></a>00450 <span class="keywordflow">if</span> (ulinfo-><a class="code" href="structs___user_local_data.html#a2690e06d1f632f9d860868352ed8cb0d">featureid</a>.compare(e.attribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>)) == 0) { <a name="l00451"></a>00451 <span class="comment">/* this is the target feature element for the new components, if any. */</span> <a name="l00452"></a>00452 QDomElement ne; <a name="l00453"></a>00453 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a> = 0; <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a> < ulinfo-><a class="code" href="structs___user_local_data.html#a9467d093017a24820e8334c5bcac1f8b">newcomps</a>.count(); <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>++) { <a name="l00454"></a>00454 QString currid = ulinfo-><a class="code" href="structs___user_local_data.html#a9467d093017a24820e8334c5bcac1f8b">newcomps</a>[<a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>]; <a name="l00455"></a>00455 ne = e.ownerDocument().createElement(<a class="code" href="wixtool_8cpp.html#aa6206134ae1d450c90844217e59e94c0">WIX_TAG_COMPONENT_REF</a>); <a name="l00456"></a>00456 ne.setAttribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>, currid); <a name="l00457"></a>00457 e.appendChild(ne); <a name="l00458"></a>00458 } <a name="l00459"></a>00459 } <a name="l00460"></a>00460 } <a name="l00461"></a>00461 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (e.tagName().compare(<a class="code" href="wixtool_8cpp.html#a0b0bc30ebd5f3a5f92dc1db591b61a6e">WIX_TAG_DIR</a>) == 0) { <a name="l00462"></a>00462 QString dirName = e.attribute(<a class="code" href="wixtool_8cpp.html#a40f662f7202636b236c25abfa1da62af">WIX_ATTR_NAME</a>); <a name="l00463"></a>00463 QString dirId = e.attribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>); <a name="l00464"></a>00464 <span class="comment">/* find all child components for this dir and see if it contains:</span> <a name="l00465"></a>00465 <span class="comment"> * create/remove folder elements, a registry element</span> <a name="l00466"></a>00466 <span class="comment"> */</span> <a name="l00467"></a>00467 <span class="keywordflow">if</span> ( e.hasChildNodes() ) { <a name="l00468"></a>00468 QDomElement fc; <a name="l00469"></a>00469 <span class="keywordtype">bool</span> hasComponent = <span class="keyword">false</span>; <a name="l00470"></a>00470 <span class="keywordtype">bool</span> hasRegKey; <a name="l00471"></a>00471 QDomNodeList subnodes = e.childNodes(); <a name="l00472"></a>00472 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a> = 0; <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a> < subnodes.count(); <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>++) { <a name="l00473"></a>00473 hasRegKey = <span class="keyword">false</span>; <a name="l00474"></a>00474 <span class="keywordflow">if</span> (subnodes.item(<a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>).isElement()) { <a name="l00475"></a>00475 QDomElement ce = subnodes.item(<a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>).toElement(); <a name="l00476"></a>00476 <span class="keywordflow">if</span> (ce.tagName().compare(<a class="code" href="wixtool_8cpp.html#a48e46c279592e6f277d0396242ae3373">WIX_TAG_COMPONENT</a>) == 0) { <a name="l00477"></a>00477 <span class="keywordflow">if</span> (!hasComponent) { <a name="l00478"></a>00478 hasComponent = <span class="keyword">true</span>; <a name="l00479"></a>00479 fc = ce; <a name="l00480"></a>00480 <span class="keywordflow">if</span> (ce.attribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>).compare(<a class="code" href="wixtool_8cpp.html#a48e46c279592e6f277d0396242ae3373">WIX_TAG_COMPONENT</a>) == 0) { <a name="l00481"></a>00481 <span class="comment">/* Fix default named components before adding registry elements. */</span> <a name="l00482"></a>00482 ce.setAttribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>, QString(<span class="stringliteral">"DCOMP"</span>).append(dirName)); <a name="l00483"></a>00483 ulinfo-><a class="code" href="structs___user_local_data.html#a9467d093017a24820e8334c5bcac1f8b">newcomps</a>.append(ce.attribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>)); <a name="l00484"></a>00484 } <a name="l00485"></a>00485 <span class="keywordflow">if</span> (ce.elementsByTagName(<a class="code" href="wixtool_8cpp.html#a155ab3376a9aeee10762f40bbd02b3e4">WIX_TAG_REMOVEDIR</a>).count() == 0) { <a name="l00486"></a>00486 <a class="code" href="wixtool_8cpp.html#a1afad9d3c7f28d2cb1735ba33206e00d">createDirMgmtComponent</a>(ce, ce.attribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>)); <a name="l00487"></a>00487 } <a name="l00488"></a>00488 } <a name="l00489"></a>00489 QDomNodeList compnodes = ce.childNodes(); <a name="l00490"></a>00490 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j < compnodes.count(); j++) { <a name="l00491"></a>00491 <span class="keywordflow">if</span> (compnodes.item(j).isElement()) { <a name="l00492"></a>00492 QDomElement compe = compnodes.item(j).toElement(); <a name="l00493"></a>00493 <span class="keywordflow">if</span> (compe.tagName().compare(<a class="code" href="wixtool_8cpp.html#a2c18182a8c853e5e510d455bde42f335">WIX_TAG_REGKEY</a>) == 0) { <a name="l00494"></a>00494 hasRegKey = <span class="keyword">true</span>; <a name="l00495"></a>00495 } <a name="l00496"></a>00496 } <a name="l00497"></a>00497 } <a name="l00498"></a>00498 <span class="keywordflow">if</span> (!hasRegKey) { <a name="l00499"></a>00499 <a class="code" href="wixtool_8cpp.html#a9941fd3ceeb1369d0011e610d8e6bf9b">createRegLocalComponent</a>(ce, QString(<span class="stringliteral">"RK"</span>).append(ce.attribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>)), ulinfo-><a class="code" href="structs___user_local_data.html#a9f799485ee8533c68e20261a38eac954">keypath</a>); <a name="l00500"></a>00500 } <a name="l00501"></a>00501 } <a name="l00502"></a>00502 } <a name="l00503"></a>00503 } <a name="l00504"></a>00504 <span class="keywordflow">if</span> (!hasComponent) { <a name="l00505"></a>00505 <span class="comment">/* Certain system directories must be ignored; we don't manage them. */</span> <a name="l00506"></a>00506 <span class="keywordflow">if</span> (dirId.compare(<span class="stringliteral">"LocalAppDataFolder"</span>) && <a name="l00507"></a>00507 dirId.compare(<span class="stringliteral">"AppDataFolder"</span>) && <a name="l00508"></a>00508 dirId.compare(<span class="stringliteral">"CommonAppDataFolder"</span>) && <a name="l00509"></a>00509 dirId.compare(<span class="stringliteral">"CommonFilesFolder"</span>) && <a name="l00510"></a>00510 dirId.compare(<span class="stringliteral">"DesktopFolder"</span>) && <a name="l00511"></a>00511 dirId.compare(<span class="stringliteral">"PersonalFolder"</span>) && <a name="l00512"></a>00512 dirId.compare(<span class="stringliteral">"ProgramFilesFolder"</span>) && <a name="l00513"></a>00513 dirId.compare(<span class="stringliteral">"ProgramMenuFolder"</span>) && <a name="l00514"></a>00514 dirId.compare(<span class="stringliteral">"StartMenuFolder"</span>) && <a name="l00515"></a>00515 dirId.compare(<span class="stringliteral">"StartupFolder"</span>) && <a name="l00516"></a>00516 dirId.compare(<span class="stringliteral">"SystemFolder"</span>) && <a name="l00517"></a>00517 dirId.compare(<span class="stringliteral">"TempFolder"</span>) && <a name="l00518"></a>00518 dirId.compare(<span class="stringliteral">"WindowsFolder"</span>) ) { <a name="l00519"></a>00519 <span class="comment">/* if there is no component under this dir parent then we</span> <a name="l00520"></a>00520 <span class="comment"> * must create a component for the sole purpose of dir</span> <a name="l00521"></a>00521 <span class="comment"> * creation with the requisite registry key path.</span> <a name="l00522"></a>00522 <span class="comment"> */</span> <a name="l00523"></a>00523 QDomElement ne = e.ownerDocument().createElement(<a class="code" href="wixtool_8cpp.html#a48e46c279592e6f277d0396242ae3373">WIX_TAG_COMPONENT</a>); <a name="l00524"></a>00524 QString compId = QString(<span class="stringliteral">"ULDirComp_"</span>).append(dirName); <a name="l00525"></a>00525 ne.setAttribute(<a class="code" href="wixtool_8cpp.html#aba5dcb0ff4d0a78b6f11a306bf59eabd">WIX_ATTR_GUID</a>, <span class="stringliteral">"*"</span>); <a name="l00526"></a>00526 ne.setAttribute(<a class="code" href="wixtool_8cpp.html#a8833185f31dbd0ffc7726ded9ca4d2aa">WIX_ATTR_ID</a>, compId); <a name="l00527"></a>00527 e.appendChild(ne); <a name="l00528"></a>00528 <a class="code" href="wixtool_8cpp.html#a1afad9d3c7f28d2cb1735ba33206e00d">createDirMgmtComponent</a>(ne, dirName); <a name="l00529"></a>00529 <a class="code" href="wixtool_8cpp.html#a9941fd3ceeb1369d0011e610d8e6bf9b">createRegLocalComponent</a>(ne, QString(<span class="stringliteral">"DRK"</span>).append(dirName), ulinfo-><a class="code" href="structs___user_local_data.html#a9f799485ee8533c68e20261a38eac954">keypath</a>); <a name="l00530"></a>00530 ulinfo-><a class="code" href="structs___user_local_data.html#a9467d093017a24820e8334c5bcac1f8b">newcomps</a>.append(compId); <a name="l00531"></a>00531 } <a name="l00532"></a>00532 } <a name="l00533"></a>00533 } <a name="l00534"></a>00534 } <a name="l00535"></a>00535 } <a name="l00536"></a>00536 <span class="comment"></span> <a name="l00537"></a>00537 <span class="comment">/** Make modifications to requested documents.</span> <a name="l00538"></a>00538 <span class="comment"> * returns false on error and <b>errorMessage</b> will be set.</span> <a name="l00539"></a>00539 <span class="comment"> */</span> <a name="l00540"></a>00540 <span class="keywordtype">bool</span> <a name="l00541"></a><a class="code" href="wixtool_8cpp.html#a592b959ed0a7ff346f49430fa79a7a84">00541</a> <a class="code" href="wixtool_8cpp.html#a592b959ed0a7ff346f49430fa79a7a84">docuserlocal</a>(QDomDocument *doc, <a name="l00542"></a>00542 QString argument, <a name="l00543"></a>00543 QString *errorMessage) <a name="l00544"></a>00544 { <a name="l00545"></a>00545 Q_ASSERT(doc); <a name="l00546"></a>00546 Q_ASSERT(errorMessage); <a name="l00547"></a>00547 <a class="code" href="structs___user_local_data.html">UserLocalData</a> cbdata; <a name="l00548"></a>00548 <a name="l00549"></a>00549 QStringList ulinfo = argument.split(<span class="stringliteral">":"</span>); <a name="l00550"></a>00550 <span class="keywordflow">if</span> (ulinfo.count() < 2) { <a name="l00551"></a>00551 *errorMessage = <span class="stringliteral">"Invalid argument for userlocal command: "</span> + argument; <a name="l00552"></a>00552 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00553"></a>00553 } <a name="l00554"></a>00554 cbdata.<a class="code" href="structs___user_local_data.html#a9f799485ee8533c68e20261a38eac954">keypath</a> = ulinfo[0]; <a name="l00555"></a>00555 cbdata.<a class="code" href="structs___user_local_data.html#a2690e06d1f632f9d860868352ed8cb0d">featureid</a> = ulinfo[1]; <a name="l00556"></a>00556 <span class="keywordflow">return</span> <a class="code" href="wixtool_8cpp.html#aa05c0047dbc7b7642784f6d522627600">walkdoc</a>(doc, &<a class="code" href="wixtool_8cpp.html#a72e7d465a52ab4a180000884a8203ef1">userlocalfunc</a>, &cbdata, errorMessage); <a name="l00557"></a>00557 } <a name="l00558"></a>00558 <span class="comment"></span> <a name="l00559"></a>00559 <span class="comment">/** Display application usage and exit. */</span> <a name="l00560"></a>00560 <span class="keywordtype">void</span> <a name="l00561"></a><a class="code" href="wixtool_8cpp.html#a068e9e76bf4a101f996e30fd122df007">00561</a> <a class="code" href="nsh2po_8cpp.html#a068e9e76bf4a101f996e30fd122df007">print_usage_and_exit</a>() <a name="l00562"></a>00562 { <a name="l00563"></a>00563 QTextStream <a class="code" href="namespacetc.html#aa7353218fd7baef0876bbb422ce818af">error</a>(stderr); <a name="l00564"></a>00564 error << <span class="stringliteral">"usage: wixtool <command> [-q] -i <infile> -o <outfile> <Arg0> [... <ArgN>]"</span> << endl; <a name="l00565"></a>00565 error << <span class="stringliteral">" command one of: "</span> << endl; <a name="l00566"></a>00566 error << <span class="stringliteral">" splice Splice children from one document into another."</span> << endl; <a name="l00567"></a>00567 error << <span class="stringliteral">" replace Replace elements or attributes in a document."</span> << endl; <a name="l00568"></a>00568 error << <span class="stringliteral">" add Add elements or attributes into a document."</span> << endl; <a name="l00569"></a>00569 error << <span class="stringliteral">" userlocal Convert File elements into per-user local elements."</span> << endl; <a name="l00570"></a>00570 error << <span class="stringliteral">" -i <infile> Input or template file"</span> << endl; <a name="l00571"></a>00571 error << <span class="stringliteral">" -o <outfile> Output file"</span> << endl; <a name="l00572"></a>00572 error << endl; <a name="l00573"></a>00573 error << <span class="stringliteral">" splice args: desttagname[:Id]=file:basetag[:Id]"</span> << endl; <a name="l00574"></a>00574 error << <span class="stringliteral">" Splice children of basetag in file under desttagname"</span> << endl; <a name="l00575"></a>00575 error << endl; <a name="l00576"></a>00576 error << <span class="stringliteral">" replace args: tagname[:Id]:property=newtagname[:Id]:property:value"</span> << endl; <a name="l00577"></a>00577 error << <span class="stringliteral">" If newtagname is empty the element is deleted"</span> << endl; <a name="l00578"></a>00578 error << <span class="stringliteral">" If newproperty is empty the property is deleted"</span> << endl; <a name="l00579"></a>00579 error << endl; <a name="l00580"></a>00580 error << <span class="stringliteral">" add args: desttagname[:Id]=newtagname[:Id]:property:value"</span> << endl; <a name="l00581"></a>00581 error << <span class="stringliteral">" Add properties or child elements to target"</span> << endl; <a name="l00582"></a>00582 error << <span class="stringliteral">" If newtagname is empty only properties added to dest"</span> << endl; <a name="l00583"></a>00583 error << endl; <a name="l00584"></a>00584 error << <span class="stringliteral">" userlocal arg: <registry key path>:<dest feature id>"</span> << endl; <a name="l00585"></a>00585 error << <span class="stringliteral">" Convert KeyPath File elements into the per user local idiom"</span> << endl; <a name="l00586"></a>00586 error << <span class="stringliteral">" with corresponding Create/RemoveDir and RegistryKey elements."</span> << endl; <a name="l00587"></a>00587 error << endl; <a name="l00588"></a>00588 error << <span class="stringliteral">" NOTE: text content within an element is not accessible."</span> << endl; <a name="l00589"></a>00589 error << <span class="stringliteral">" Use the Value= attribute syntax if necessary."</span> << endl; <a name="l00590"></a>00590 error << <span class="stringliteral">" The optional :Id syntax restricts matching to elements with"</span> << endl; <a name="l00591"></a>00591 error << <span class="stringliteral">" the Id attribute set to the value indicated."</span> << endl; <a name="l00592"></a>00592 error.flush(); <a name="l00593"></a>00593 exit(1); <a name="l00594"></a>00594 } <a name="l00595"></a>00595 <a name="l00596"></a>00596 <span class="keywordtype">int</span> <a name="l00597"></a><a class="code" href="wixtool_8cpp.html#a0ddf1224851353fc92bfbff6f499fa97">00597</a> <a class="code" href="_c_make_c_x_x_compiler_id_8cpp.html#a0ddf1224851353fc92bfbff6f499fa97">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]) <a name="l00598"></a>00598 { <a name="l00599"></a>00599 QTextStream <a class="code" href="namespacetc.html#aa7353218fd7baef0876bbb422ce818af">error</a>(stderr); <a name="l00600"></a>00600 QString command, errorMessage; <a name="l00601"></a>00601 <span class="keywordtype">char</span> *infile = 0, *outfile = 0; <a name="l00602"></a>00602 QTextCodec *codec = QTextCodec::codecForName(<span class="stringliteral">"utf-8"</span>); <a name="l00603"></a>00603 <span class="keywordtype">bool</span> quiet = <span class="keyword">false</span>; <a name="l00604"></a>00604 QStringList commandargs; <a name="l00605"></a>00605 <a name="l00606"></a>00606 <span class="comment">/* Check for the correct number of input parameters. */</span> <a name="l00607"></a>00607 <span class="keywordflow">if</span> (argc < 6) <a name="l00608"></a>00608 <a class="code" href="nsh2po_8cpp.html#a068e9e76bf4a101f996e30fd122df007">print_usage_and_exit</a>(); <a name="l00609"></a>00609 <a name="l00610"></a>00610 <span class="comment">/* Verify command is supported. */</span> <a name="l00611"></a>00611 command = argv[1]; <a name="l00612"></a>00612 <span class="keywordflow">if</span> ( command.compare(<span class="stringliteral">"splice"</span>, Qt::CaseInsensitive) && <a name="l00613"></a>00613 command.compare(<span class="stringliteral">"replace"</span>, Qt::CaseInsensitive) && <a name="l00614"></a>00614 command.compare(<span class="stringliteral">"add"</span>, Qt::CaseInsensitive) && <a name="l00615"></a>00615 command.compare(<span class="stringliteral">"userlocal"</span>, Qt::CaseInsensitive) ) { <a name="l00616"></a>00616 <a class="code" href="nsh2po_8cpp.html#a068e9e76bf4a101f996e30fd122df007">print_usage_and_exit</a>(); <a name="l00617"></a>00617 } <a name="l00618"></a>00618 <a name="l00619"></a>00619 <span class="comment">/* Gather remaining arguments. */</span> <a name="l00620"></a>00620 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a> = 2; <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a> < argc; <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>++) { <a name="l00621"></a>00621 QString arg(argv[<a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>]); <a name="l00622"></a>00622 <span class="keywordflow">if</span> (!arg.compare(<span class="stringliteral">"-q"</span>, Qt::CaseInsensitive)) <a name="l00623"></a>00623 quiet = <span class="keyword">true</span>; <a name="l00624"></a>00624 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!arg.compare(<span class="stringliteral">"-i"</span>, Qt::CaseInsensitive) && ++i < argc) <a name="l00625"></a>00625 infile = argv[i]; <a name="l00626"></a>00626 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!arg.compare(<span class="stringliteral">"-o"</span>, Qt::CaseInsensitive) && ++i < argc) <a name="l00627"></a>00627 outfile = argv[i]; <a name="l00628"></a>00628 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (infile && outfile) { <a name="l00629"></a>00629 commandargs.append(arg); <a name="l00630"></a>00630 } <a name="l00631"></a>00631 } <a name="l00632"></a>00632 <span class="keywordflow">if</span> ( !infile || !outfile || !commandargs.count() ) { <a name="l00633"></a>00633 <a class="code" href="nsh2po_8cpp.html#a068e9e76bf4a101f996e30fd122df007">print_usage_and_exit</a>(); <a name="l00634"></a>00634 } <a name="l00635"></a>00635 <a name="l00636"></a>00636 <span class="comment">/* Open the source document for reading. */</span> <a name="l00637"></a>00637 QFile srcFile(infile); <a name="l00638"></a>00638 QTextStream sfiletxt(&srcFile); <a name="l00639"></a>00639 sfiletxt.setCodec(codec); <a name="l00640"></a>00640 <span class="keywordflow">if</span> (!srcFile.open(QIODevice::ReadOnly | QIODevice::Text)) { <a name="l00641"></a>00641 error << QString(<span class="stringliteral">"Unable to open '%1' for reading: %2\n"</span>).arg(infile) <a name="l00642"></a>00642 .arg(srcFile.errorString()); <a name="l00643"></a>00643 <span class="keywordflow">return</span> 2; <a name="l00644"></a>00644 } <a name="l00645"></a>00645 <a name="l00646"></a>00646 <span class="comment">/* Make sure the outfile does not exist before we use it. */</span> <a name="l00647"></a>00647 <span class="keywordflow">if</span> (QFile::exists(outfile)) { <a name="l00648"></a>00648 <span class="keywordflow">if</span> (!QFile::remove(outfile)) { <a name="l00649"></a>00649 error << QString(<span class="stringliteral">"Unable to truncate outfile '%1'\n"</span>).arg(outfile); <a name="l00650"></a>00650 <span class="keywordflow">return</span> 2; <a name="l00651"></a>00651 } <a name="l00652"></a>00652 } <a name="l00653"></a>00653 <a name="l00654"></a>00654 QDomDocument doc; <a name="l00655"></a>00655 QString parseError; <a name="l00656"></a>00656 <span class="keywordtype">int</span> badline, badcol; <a name="l00657"></a>00657 <span class="keywordflow">if</span> (!doc.setContent (sfiletxt.readAll(), <span class="keyword">false</span>, &parseError, &badline, &badcol)) { <a name="l00658"></a>00658 error << QString(<span class="stringliteral">"Error parsing source document '%1' at line %2 and column %3: %4"</span>) <a name="l00659"></a>00659 .arg(infile).arg(badline).arg(badcol).arg(parseError); <a name="l00660"></a>00660 <span class="keywordflow">return</span> 3; <a name="l00661"></a>00661 } <a name="l00662"></a>00662 <a name="l00663"></a>00663 <span class="keywordflow">if</span> (!command.compare(<span class="stringliteral">"userlocal"</span>, Qt::CaseInsensitive)) { <a name="l00664"></a>00664 <span class="keywordflow">if</span> (!<a class="code" href="wixtool_8cpp.html#a592b959ed0a7ff346f49430fa79a7a84">docuserlocal</a>(&doc, commandargs[0], &errorMessage)) { <a name="l00665"></a>00665 error << QString(<span class="stringliteral">"Unable to convert document components to user local: %1\n"</span>) <a name="l00666"></a>00666 .arg(errorMessage); <a name="l00667"></a>00667 <span class="keywordflow">return</span> 4; <a name="l00668"></a>00668 } <a name="l00669"></a>00669 } <a name="l00670"></a>00670 <span class="keywordflow">else</span> { <a name="l00671"></a>00671 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a> = 0; <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a> < commandargs.count(); <a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>++) { <a name="l00672"></a>00672 <span class="keywordflow">if</span> (!command.compare(<span class="stringliteral">"splice"</span>, Qt::CaseInsensitive)) { <a name="l00673"></a>00673 <span class="keywordflow">if</span> (!<a class="code" href="wixtool_8cpp.html#ab1ef43f0e2fc68c1779daa8ff1e99c88">docsplice</a>(&doc, commandargs[<a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>], &errorMessage)) { <a name="l00674"></a>00674 error << QString(<span class="stringliteral">"Unable to process splice command '%1': %2\n"</span>) <a name="l00675"></a>00675 .arg(commandargs[i]).arg(errorMessage); <a name="l00676"></a>00676 <span class="keywordflow">return</span> 4; <a name="l00677"></a>00677 } <a name="l00678"></a>00678 } <a name="l00679"></a>00679 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!command.compare(<span class="stringliteral">"replace"</span>, Qt::CaseInsensitive)) { <a name="l00680"></a>00680 <span class="keywordflow">if</span> (!<a class="code" href="wixtool_8cpp.html#a528eb12ced26de43815d1a90e5fdcb2b">docreplace</a>(&doc, commandargs[<a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>], &errorMessage)) { <a name="l00681"></a>00681 error << QString(<span class="stringliteral">"Unable to process replace command '%1': %2\n"</span>) <a name="l00682"></a>00682 .arg(commandargs[i]).arg(errorMessage); <a name="l00683"></a>00683 <span class="keywordflow">return</span> 4; <a name="l00684"></a>00684 } <a name="l00685"></a>00685 } <a name="l00686"></a>00686 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!command.compare(<span class="stringliteral">"add"</span>, Qt::CaseInsensitive)) { <a name="l00687"></a>00687 <span class="keywordflow">if</span> (!<a class="code" href="wixtool_8cpp.html#aa68a06ad334306a3a45937c5b155cc77">docadd</a>(&doc, commandargs[<a class="code" href="html_8cpp.html#a4a5dba6492ea149585950c59c210ff47">i</a>], &errorMessage)) { <a name="l00688"></a>00688 error << QString(<span class="stringliteral">"Unable to process add command '%1': %2\n"</span>) <a name="l00689"></a>00689 .arg(commandargs[i]).arg(errorMessage); <a name="l00690"></a>00690 <span class="keywordflow">return</span> 4; <a name="l00691"></a>00691 } <a name="l00692"></a>00692 } <a name="l00693"></a>00693 } <a name="l00694"></a>00694 } <a name="l00695"></a>00695 <a name="l00696"></a>00696 <span class="comment">/* Open the output file for writing. */</span> <a name="l00697"></a>00697 QFile docFile(outfile); <a name="l00698"></a>00698 <span class="keywordflow">if</span> (!docFile.open(QIODevice::WriteOnly | QIODevice::Text)) { <a name="l00699"></a>00699 error << QString(<span class="stringliteral">"Unable to open '%1' for writing: %2\n"</span>).arg(outfile) <a name="l00700"></a>00700 .arg(docFile.errorString()); <a name="l00701"></a>00701 <span class="keywordflow">return</span> 5; <a name="l00702"></a>00702 } <a name="l00703"></a>00703 <a name="l00704"></a>00704 <span class="comment">/* Write the .wxl output. */</span> <a name="l00705"></a>00705 QTextStream out(&docFile); <a name="l00706"></a>00706 out << doc.toString(4); <a name="l00707"></a>00707 <a name="l00708"></a>00708 <span class="keywordflow">return</span> 0; <a name="l00709"></a>00709 } <a name="l00710"></a>00710 </pre></div></div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Mon Aug 30 22:58:55 2010 for Vidalia by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>