File Coverage

blib/lib/Config/Apple/Profile/Payload/Types.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


line stmt bran cond sub pod time code
1             package Config::Apple::Profile::Payload::Types;
2              
3 7     7   89 use 5.14.4;
  7         24  
  7         316  
4 7     7   40 use strict;
  7         13  
  7         228  
5 7     7   35 use warnings FATAL => 'all';
  7         15  
  7         647  
6              
7             our $VERSION = '0.55';
8              
9             use Exporter::Easy (
10 7         89 OK => [qw(
11             $ProfileString $ProfileNumber $ProfileData $ProfileBool
12             $ProfileReal $ProfileDate $ProfileDict $ProfileArray
13             $ProfileNSDataBlob $ProfileUUID $ProfileIdentifier
14             )],
15             TAGS => [
16             'all' => [qw(
17             $ProfileString $ProfileNumber $ProfileData $ProfileBool
18             $ProfileReal $ProfileDate $ProfileDict $ProfileArray
19             $ProfileNSDataBlob $ProfileUUID $ProfileIdentifier $ProfileClass
20             )],
21             ],
22 7     7   6624 );
  7         21393  
23 7     7   3078 use Readonly;
  7         17  
  7         2184  
24              
25              
26             =encoding utf8
27              
28             =head1 NAME
29              
30             Config::Apple::Profile::Payload::Types - Data types for payload keys.
31              
32             =head1 DESCRIPTION
33              
34             Apple Configuration Profiles contain one or more I. Each payload
35             contains a dictionary, which can be thought of like a Perl hash. Within a
36             payload's dictionary, each key's value is restricted to a specific type.
37             One key might require a number; a different key might require a string, or some
38             binary data.
39              
40             Provided in this module are a number of Readonly scalars that will be used
41             (instead of strings) to identify the data types for configuration profile keys.
42             The scalars are all OK for import into your local namespace, or you can simply
43             import C<:all> to get all of them at once.
44              
45             =head1 TYPES
46              
47             Apple Configuration Profile payloads use the following types:
48              
49             =head2 String (C<$ProfileString>)
50              
51             A UTF-8 string. The client should simply provide a Perl string (NOT a binary
52             string). Multi-line strings are allowed, although specific payload keys may
53             not allow this. Empty strings are B allowed.
54              
55             B If your source data was not ASCII, and not UTF-8, then please make
56             sure you have converted it before doing anything else! "converted it" normally
57             means using C to convert from the original encoding. Your
58             string will not be valid unless it can be encoded as UTF-8.
59              
60             =cut
61              
62             Readonly our $ProfileString => 1;
63              
64              
65             =head2 Number (C<$ProfileNumber>)
66              
67             An Integer, which may be positive, zero, or negative. The plist standard
68             doesn't specify a range, but one may be imposed by specific keys.
69              
70             =cut
71              
72             Readonly our $ProfileNumber => 2;
73              
74              
75             =head2 Real (C<$ProfileReal>)
76              
77             A real number, which may be positive, zero, or negative. It may also have
78             an exponent. The plist standard doesn't specify a range, but one may be
79             imposed by specific keys.
80              
81             =cut
82              
83             Readonly our $ProfileReal => 5;
84              
85              
86             =head2 Data (C<$ProfileData>)
87              
88             Binary data.
89              
90             Binary data may be provided by the client in multiple ways.
91             Clients can provide an open filehandle, or an open C object.
92             C is used to make sure the handle/object is open.
93              
94             The file needs to be open for reading.
95              
96             The client may also provide a string. If a string is provided, then it must be
97             a I, I string. In other words, C needs to
98             return C. If the flag is C, then you probably need to use
99             C (or maybe C) to get a binary string.
100              
101             =cut
102              
103             Readonly our $ProfileData => 3;
104              
105              
106             =head2 Boolean (C<$ProfileBool>)
107              
108             Either True for False. When reading a boolean from a payload's contents, a 1
109             is used to represent true, and 0 is returned for false. When setting a boolean,
110             the value provided is filtered using the code C<($value) ? 1 : 0>. As long as
111             you aren't providing C as the input, your input will probably be
112             accepted!
113              
114             =cut
115              
116             Readonly our $ProfileBool => 4;
117              
118              
119             =head2 Date (C<$ProfileDate>)
120              
121             A date. This is stored internally as a C object, and when read a
122             C object will be returned. When serialized into plist form, the
123             time will be in UTC, but no other guarantees are made about the timezone when
124             the object is stored internally, so if you read a Date, be sure to call
125             C<< ->set_time_zone() >> before outputting it yourself.
126              
127             If a string is provided, L will be used to parse it.
128             For best results, parse it yourself, and provide the resulting C
129             object!
130              
131             =cut
132              
133             Readonly our $ProfileDate => 5;
134              
135              
136             =head2 Dictionary (C<$ProfileDict>)
137              
138             A dictionary is the plist equivalent to a Perl hash, and that is what will be
139             made available. The client should expect the hash to restrict what key names,
140             and what values, are accepted. For more information, see the
141             documentation for the specific payload key.
142              
143             =cut
144              
145             Readonly our $ProfileDict => 10;
146              
147              
148             =head2 Array (C<$ProfileArray>)
149              
150             An array, similar to a Perl array. The client should expect the array to only
151             accept certain data types. For more information, see the documentation for the
152             specific payload key.
153              
154             =cut
155              
156             Readonly our $ProfileArray => 11;
157              
158              
159             =head2 NSData Blob
160              
161             This is a weird type. The only place it appears in the I
162             Reference> (the edition dated 2014-03-20) is in the C key in the
163             Exchange payload. I don't really understand this, though I'm guessing it's
164             really a Data type, and the I is referring to the contents.
165              
166             Until I get more information on what exactly this is, this type will likely go
167             unimplemnented. Right now, the same checks are performed as for the
168             C type.
169              
170             =cut
171              
172             Readonly our $ProfileNSDataBlob => 20;
173              
174              
175             =head1 CUSTOM TYPES
176              
177             The following types are not defined in the plist standard, but they are being
178             treated specially here.
179              
180             =head2 UUID (C<$ProfileUUID>)
181              
182             I
183              
184             Although the plist format does not have a special type for UUIDs (a simple
185             String is used), these modules designate a special type for UUIDs as a
186             convenience to the client. All payloads have a UUID as one of the required
187             keys. If the client does not specify a UUID when creating a payload, then
188             one will be lazily auto-generated.
189              
190             If you would like to set an explicit UUID, you may provide a C
191             object, a C object, or a string that C can parse. When
192             reading, a C object is returned, but that can be converted into a
193             string very easily:
194              
195             $uuid = "$uuid";
196              
197             =cut
198              
199             Readonly our $ProfileUUID => 21;
200              
201              
202             =head2 Identifier (C<$ProfileIdentifier>)
203              
204             This is another convenience type. All payloads require an identifier,
205             which is a reverse-DNS-style (Java-style) string. If the client does not
206             specify an identifier, then one will be lazily auto-generated.
207              
208             See RFC 1035 for the standard relating to host and domain names, but please note
209             that spaces are I acceptable here, even though they may be in RFC 1035.
210              
211             =cut
212              
213             Readonly our $ProfileIdentifier => 22;
214              
215              
216             =head2 Class (C<$ProfileClass>)
217              
218             This profile type is used to indicate that the value is an instance of a class.
219             The class is a sub-class of C, so the
220             methods implemented in that class are all available. More information about
221             what specific sub-class is used can be found in the documentation for the
222             specific payload key.
223              
224             =cut
225              
226             Readonly our $ProfileClass => 24;
227              
228              
229             =head1 SEE ALSO
230              
231             L, L, L, L, L,
232             L,
233             L
234              
235             =head1 ACKNOWLEDGEMENTS
236              
237             Refer to L for acknowledgements.
238              
239             =head1 AUTHOR
240              
241             A. Karl Kornel, C<< >>
242              
243             =head1 COPYRIGHT AND LICENSE
244              
245             Copyright © 2014 A. Karl Kornel.
246              
247             This program is free software; you can redistribute it and/or modify it
248             under the terms of either: the GNU General Public License as published
249             by the Free Software Foundation; or the Artistic License.
250              
251             See L for more information.
252              
253             =cut
254              
255             1;