| 1 | package WiX3::XML::File; | ||
| 2 | |||
| 3 | use 5.008003; | ||
| 4 | |||
| 5 | # Must be done before Moose, or it won't get picked up. | ||
| 6 | use metaclass ( | ||
| 7 | metaclass => 'Moose::Meta::Class', | ||
| 8 | error_class => 'WiX3::Util::Error', | ||
| 9 | ); | ||
| 10 | use Moose 2; | ||
| 11 | use WiX3::Types qw( YesNoType PositiveInt NonNegativeInt ); | ||
| 12 | use WiX3::XML::TagTypes qw( ShortcutTag ); | ||
| 13 | use MooseX::Types::Moose qw( Str Maybe Int ArrayRef ); | ||
| 14 | use WiX3::Util::StrictConstructor; | ||
| 15 | |||
| 16 | our $VERSION = '0.011'; | ||
| 17 | |||
| 18 | with 'WiX3::XML::Role::TagAllowsChildTags'; | ||
| 19 | |||
| 20 | # http://wix.sourceforge.net/manual-wix3/wix_xsd_file.htm | ||
| 21 | |||
| 22 | # Allows child tags (WiX namespace:) AppId, AssemblyName, Class, CopyFile, | ||
| 23 | # ODBCDriver, ODBCTranslator, Permission, PermissionEx, Shortcut, SymbolPath, | ||
| 24 | # TypeLib | ||
| 25 | |||
| 26 | has '+child_tags' => ( isa => ArrayRef [ShortcutTag] ); | ||
| 27 | |||
| 28 | |||
| 29 | ##################################################################### | ||
| 30 | # Attributes: | ||
| 31 | |||
| 32 | has _assembly => ( | ||
| 33 | is => 'ro', | ||
| 34 | isa => Maybe [Str], # '.net', 'no', or 'win32' | ||
| 35 | reader => '_get_assembly', | ||
| 36 | init_arg => 'assembly', | ||
| 37 | default => undef, | ||
| 38 | ); | ||
| 39 | |||
| 40 | has _assemblyapplication => ( | ||
| 41 | is => 'ro', | ||
| 42 | isa => Maybe [Str], | ||
| 43 | reader => '_get_assemblyapplication', | ||
| 44 | init_arg => 'assemblyapplication', | ||
| 45 | default => undef, | ||
| 46 | ); | ||
| 47 | |||
| 48 | has _assemblymanifest => ( | ||
| 49 | is => 'ro', | ||
| 50 | isa => Maybe [Str], | ||
| 51 | reader => '_get_assemblymanifest', | ||
| 52 | init_arg => 'assemblymanifest', | ||
| 53 | default => undef, | ||
| 54 | ); | ||
| 55 | |||
| 56 | has _bindpath => ( | ||
| 57 | is => 'ro', | ||
| 58 | isa => Maybe [Str], | ||
| 59 | reader => '_get_bindpath', | ||
| 60 | init_arg => 'bindpath', | ||
| 61 | default => undef, | ||
| 62 | ); | ||
| 63 | |||
| 64 | has _checksum => ( | ||
| 65 | is => 'ro', | ||
| 66 | isa => Maybe [YesNoType], # Becomes yes/no. | ||
| 67 | reader => '_get_checksum', | ||
| 68 | init_arg => 'checksum', | ||
| 69 | default => undef, | ||
| 70 | ); | ||
| 71 | |||
| 72 | has _companionfile => ( | ||
| 73 | is => 'ro', | ||
| 74 | isa => Maybe [Str], | ||
| 75 | reader => '_get_companionfile', | ||
| 76 | init_arg => 'companionfile', | ||
| 77 | default => undef, | ||
| 78 | ); | ||
| 79 | |||
| 80 | has _compressed => ( | ||
| 81 | is => 'ro', | ||
| 82 | isa => Maybe [Str], #'yes', 'no', or 'default' | ||
| 83 | reader => '_get_compressed', | ||
| 84 | init_arg => 'compressed', | ||
| 85 | default => undef, | ||
| 86 | ); | ||
| 87 | |||
| 88 | has _defaultlanguage => ( | ||
| 89 | is => 'ro', | ||
| 90 | isa => Maybe [Str], | ||
| 91 | reader => '_get_defaultlanguage', | ||
| 92 | init_arg => 'defaultlanguage', | ||
| 93 | default => undef, | ||
| 94 | ); | ||
| 95 | |||
| 96 | has _defaultsize => ( | ||
| 97 | is => 'ro', | ||
| 98 | isa => Maybe [NonNegativeInt], | ||
| 99 | reader => '_get_defaultsize', | ||
| 100 | init_arg => 'defaultsize', | ||
| 101 | default => undef, | ||
| 102 | ); | ||
| 103 | |||
| 104 | has _defaultversion => ( | ||
| 105 | is => 'ro', | ||
| 106 | isa => Maybe [Str], | ||
| 107 | reader => '_get_defaultversion', | ||
| 108 | init_arg => 'defaultversion', | ||
| 109 | default => undef, | ||
| 110 | ); | ||
| 111 | |||
| 112 | has _diskid => ( | ||
| 113 | is => 'ro', | ||
| 114 | isa => Maybe [PositiveInt], | ||
| 115 | reader => '_get_diskid', | ||
| 116 | init_arg => 'diskid', | ||
| 117 | default => undef, | ||
| 118 | ); | ||
| 119 | |||
| 120 | has _fonttitle => ( | ||
| 121 | is => 'ro', | ||
| 122 | isa => Maybe [Str], | ||
| 123 | reader => '_get_fonttitle', | ||
| 124 | init_arg => 'fonttitle', | ||
| 125 | default => undef, | ||
| 126 | ); | ||
| 127 | |||
| 128 | has _hidden => ( | ||
| 129 | is => 'ro', | ||
| 130 | isa => Maybe [YesNoType], | ||
| 131 | reader => '_get_hidden', | ||
| 132 | init_arg => 'hidden', | ||
| 133 | default => undef, | ||
| 134 | ); | ||
| 135 | |||
| 136 | has id => ( | ||
| 137 | is => 'ro', | ||
| 138 | isa => Str, | ||
| 139 | reader => 'get_id', | ||
| 140 | default => undef, | ||
| 141 | ); | ||
| 142 | |||
| 143 | has _keypath => ( | ||
| 144 | is => 'ro', | ||
| 145 | isa => Maybe [YesNoType], | ||
| 146 | reader => '_get_keypath', | ||
| 147 | init_arg => 'keypath', | ||
| 148 | default => undef, | ||
| 149 | ); | ||
| 150 | |||
| 151 | has name => ( | ||
| 152 | is => 'ro', | ||
| 153 | isa => Maybe [Str], # LongNameFileType | ||
| 154 | reader => 'get_name', | ||
| 155 | default => undef, | ||
| 156 | ); | ||
| 157 | |||
| 158 | has _patchallowignoreonerror => ( | ||
| 159 | is => 'ro', | ||
| 160 | isa => Maybe [YesNoType], | ||
| 161 | reader => '_get_patchallowignoreonerror', | ||
| 162 | init_arg => 'patchallowignoreonerror', | ||
| 163 | default => undef, | ||
| 164 | ); | ||
| 165 | |||
| 166 | has _patchignore => ( | ||
| 167 | is => 'ro', | ||
| 168 | isa => Maybe [YesNoType], | ||
| 169 | reader => '_get_patchignore', | ||
| 170 | init_arg => 'patchignore', | ||
| 171 | default => undef, | ||
| 172 | ); | ||
| 173 | |||
| 174 | has _patchwholefile => ( | ||
| 175 | is => 'ro', | ||
| 176 | isa => Maybe [YesNoType], | ||
| 177 | reader => '_get_patchwholefile', | ||
| 178 | init_arg => 'patchwholefile', | ||
| 179 | default => undef, | ||
| 180 | ); | ||
| 181 | |||
| 182 | has _patchgroup => ( | ||
| 183 | is => 'ro', | ||
| 184 | isa => Maybe [PositiveInt], | ||
| 185 | reader => '_get_patchgroup', | ||
| 186 | init_arg => 'patchgroup', | ||
| 187 | default => undef, | ||
| 188 | ); | ||
| 189 | |||
| 190 | has _processorarchitecture => ( | ||
| 191 | is => 'ro', | ||
| 192 | isa => Maybe [Str], # 'msil', 'x86', 'x64', or 'ia64' | ||
| 193 | reader => '_get_processorarchitecture', | ||
| 194 | init_arg => 'processorarchitecture', | ||
| 195 | default => undef, | ||
| 196 | ); | ||
| 197 | |||
| 198 | has _readonly => ( | ||
| 199 | is => 'ro', | ||
| 200 | isa => Maybe [YesNoType], | ||
| 201 | reader => '_get_readonly', | ||
| 202 | init_arg => 'readonly', | ||
| 203 | default => undef, | ||
| 204 | ); | ||
| 205 | |||
| 206 | has _selfregcost => ( | ||
| 207 | is => 'ro', | ||
| 208 | isa => Maybe [Int], | ||
| 209 | reader => '_get_selfregcost', | ||
| 210 | init_arg => 'selfregcost', | ||
| 211 | default => undef, | ||
| 212 | ); | ||
| 213 | |||
| 214 | has _shortname => ( | ||
| 215 | is => 'ro', | ||
| 216 | isa => Maybe [Str], # ShortFileNameType | ||
| 217 | reader => '_get_shortname', | ||
| 218 | init_arg => 'shortname', | ||
| 219 | default => undef, | ||
| 220 | ); | ||
| 221 | |||
| 222 | has _source => ( | ||
| 223 | is => 'ro', | ||
| 224 | isa => Maybe [Str], | ||
| 225 | reader => '_get_source', | ||
| 226 | init_arg => 'source', | ||
| 227 | default => undef, | ||
| 228 | ); | ||
| 229 | |||
| 230 | has _system => ( | ||
| 231 | is => 'ro', | ||
| 232 | isa => Maybe [YesNoType], | ||
| 233 | reader => '_get_system', | ||
| 234 | init_arg => 'system', | ||
| 235 | default => undef, | ||
| 236 | ); | ||
| 237 | has _truetype => ( | ||
| 238 | is => 'ro', | ||
| 239 | isa => Maybe [YesNoType], | ||
| 240 | reader => '_get_truetype', | ||
| 241 | init_arg => 'truetype', | ||
| 242 | default => undef, | ||
| 243 | ); | ||
| 244 | |||
| 245 | has _vital => ( | ||
| 246 | is => 'ro', | ||
| 247 | isa => Maybe [YesNoType], | ||
| 248 | reader => '_get_vital', | ||
| 249 | init_arg => 'vital', | ||
| 250 | default => undef, | ||
| 251 | ); | ||
| 252 | |||
| 253 | ##################################################################### | ||
| 254 | # Methods to implement the Tag role. | ||
| 255 | |||
| 256 | sub as_string { | ||
| 257 | my $self = shift; | ||
| 258 | |||
| 259 | my $children = $self->has_child_tags(); | ||
| 260 | my $tags; | ||
| 261 | $tags = $self->print_attribute( 'Id', 'F_' . $self->get_id() ); | ||
| 262 | $tags .= $self->print_attribute( 'Name', $self->get_name() ); | ||
| 263 | $tags .= $self->print_attribute( 'DiskId', $self->_get_diskid() ); | ||
| 264 | $tags .= $self->print_attribute( 'Assembly', $self->_get_assembly() ); | ||
| 265 | $tags .= | ||
| 266 | $self->print_attribute( 'AssemblyApplication', | ||
| 267 | $self->_get_assemblyapplication() ); | ||
| 268 | $tags .= | ||
| 269 | $self->print_attribute( 'AssemblyManifest', | ||
| 270 | $self->_get_assemblymanifest() ); | ||
| 271 | $tags .= $self->print_attribute( 'BindPath', $self->_get_bindpath() ); | ||
| 272 | $tags .= $self->print_attribute( 'Checksum', $self->_get_checksum() ); | ||
| 273 | $tags .= | ||
| 274 | $self->print_attribute( 'CompanionFile', | ||
| 275 | $self->_get_companionfile() ); | ||
| 276 | $tags .= | ||
| 277 | $self->print_attribute( 'Compressed', $self->_get_compressed() ); | ||
| 278 | $tags .= | ||
| 279 | $self->print_attribute( 'DefaultLanguage', | ||
| 280 | $self->_get_defaultlanguage() ); | ||
| 281 | $tags .= | ||
| 282 | $self->print_attribute( 'DefaultSize', $self->_get_defaultsize() ); | ||
| 283 | $tags .= | ||
| 284 | $self->print_attribute( 'DefaultVersion', | ||
| 285 | $self->_get_defaultversion() ); | ||
| 286 | $tags .= $self->print_attribute( 'FontTitle', $self->_get_fonttitle() ); | ||
| 287 | $tags .= $self->print_attribute( 'Hidden', $self->_get_hidden() ); | ||
| 288 | $tags .= $self->print_attribute( 'KeyPath', $self->_get_keypath() ); | ||
| 289 | $tags .= | ||
| 290 | $self->print_attribute( 'PatchAllowIgnoreOnError', | ||
| 291 | $self->_get_patchallowignoreonerror() ); | ||
| 292 | $tags .= | ||
| 293 | $self->print_attribute( 'PatchIgnore', $self->_get_patchignore() ); | ||
| 294 | $tags .= | ||
| 295 | $self->print_attribute( 'PatchWholeFile', | ||
| 296 | $self->_get_patchwholefile() ); | ||
| 297 | $tags .= | ||
| 298 | $self->print_attribute( 'PatchGroup', $self->_get_patchgroup() ); | ||
| 299 | $tags .= | ||
| 300 | $self->print_attribute( 'ProcessorArchitecture', | ||
| 301 | $self->_get_processorarchitecture() ); | ||
| 302 | $tags .= $self->print_attribute( 'ReadOnly', $self->_get_readonly() ); | ||
| 303 | $tags .= | ||
| 304 | $self->print_attribute( 'SelfRegCost', $self->_get_selfregcost() ); | ||
| 305 | $tags .= $self->print_attribute( 'ShortName', $self->_get_shortname() ); | ||
| 306 | $tags .= $self->print_attribute( 'Source', $self->_get_source() ); | ||
| 307 | $tags .= $self->print_attribute( 'System', $self->_get_system() ); | ||
| 308 | $tags .= $self->print_attribute( 'TrueType', $self->_get_truetype() ); | ||
| 309 | $tags .= $self->print_attribute( 'Vital', $self->_get_vital() ); | ||
| 310 | |||
| 311 | if ($children) { | ||
| 312 | my $child_string = $self->as_string_children(); | ||
| 313 | return qq{<File$tags>\n$child_string</File>\n}; | ||
| 314 | } else { | ||
| 315 | return qq{<File$tags />\n}; | ||
| 316 | } | ||
| 317 | } ## end sub as_string | ||
| 318 | |||
| 319 | sub get_namespace { | ||
| 320 | return q{xmlns='http://schemas.microsoft.com/wix/2006/wi'}; | ||
| 321 | } | ||
| 322 | |||
| 323 | __PACKAGE__->meta->make_immutable; | ||
| 324 | no Moose; | ||
| 325 | |||
| 326 | 1; | ||
| 327 | |||
| 328 | __END__ |