001 | #!/usr/bin/env osascript |
---|
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
---|
003 | # |
---|
004 | # com.cocolog-nifty.quicktimer.icefloe |
---|
005 | # |
---|
006 | # |
---|
007 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
---|
008 | use AppleScript version "2.8" |
---|
009 | use framework "Foundation" |
---|
010 | use framework "AppKit" |
---|
011 | use scripting additions |
---|
012 | property refMe : a reference to current application |
---|
013 | |
---|
014 | # |
---|
015 | set aliasPathToMe to (path to me) as alias |
---|
016 | set strPathToMe to (POSIX path of aliasPathToMe) as text |
---|
017 | set ocidPathToMeStr to refMe's NSString's stringWithString:(strPathToMe) |
---|
018 | set ocidPathToMe to ocidPathToMeStr's stringByStandardizingPath() |
---|
019 | set ocidPathToMeURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidPathToMe) isDirectory:(false) |
---|
020 | set ocidContainerDirPathURL to ocidPathToMeURL's URLByDeletingLastPathComponent() |
---|
021 | set ocidPrefDirPathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:("Registered Products") isDirectory:(true) |
---|
022 | #URLの収集 |
---|
023 | set appFileManager to refMe's NSFileManager's defaultManager() |
---|
024 | set ocidOption to (refMe's NSDirectoryEnumerationSkipsHiddenFiles) |
---|
025 | set ocidKeyArray to refMe's NSMutableArray's alloc()'s init() |
---|
026 | ocidKeyArray's addObject:(refMe's NSURLPathKey) |
---|
027 | set listSubPathResult to (appFileManager's contentsOfDirectoryAtURL:(ocidPrefDirPathURL) includingPropertiesForKeys:(ocidKeyArray) options:(ocidOption) |error| :(reference)) |
---|
028 | set ocidSubPathURLArray to item 1 of listSubPathResult |
---|
029 | #収集ARRAY |
---|
030 | set ocidManifestArray to refMe's NSMutableArray's alloc()'s init() |
---|
031 | set ocidServicesUpdaterArray to refMe's NSMutableArray's alloc()'s init() |
---|
032 | set ocidARMDCArray to refMe's NSMutableArray's alloc()'s init() |
---|
033 | #収集したURL |
---|
034 | repeat with itemSubPath in ocidSubPathURLArray |
---|
035 | set ocidSubPathURLstring to itemSubPath's absoluteString() |
---|
036 | set boolContainARM to (ocidSubPathURLstring's containsString:("ARM")) |
---|
037 | set boolContainServicesupdater to (ocidSubPathURLstring's containsString:("servicesupdater")) |
---|
038 | if boolContainARM is true then |
---|
039 | (ocidARMDCArray's addObject:(itemSubPath)) |
---|
040 | else if boolContainServicesupdater is true then |
---|
041 | (ocidServicesUpdaterArray's addObject:(itemSubPath)) |
---|
042 | else |
---|
043 | (ocidManifestArray's addObject:(itemSubPath)) |
---|
044 | end if |
---|
045 | end repeat |
---|
046 | ##収集用Array |
---|
047 | set ocidOutputArrayM to refMe's NSMutableArray's alloc()'s init() |
---|
048 | |
---|
049 | |
---|
050 | #################################### |
---|
051 | #Manifest |
---|
052 | repeat with itemURL in ocidManifestArray |
---|
053 | #マニフェストのURLを取得 |
---|
054 | set ocidManifestURL to doGetManifest(itemURL) |
---|
055 | #拡張子置換 |
---|
056 | set ocidBaseManifestURL to ocidManifestURL's URLByDeletingPathExtension() |
---|
057 | set ocidManifestURL to (ocidBaseManifestURL's URLByAppendingPathExtension:("arm")) |
---|
058 | log ocidManifestURL's absoluteString() as text |
---|
059 | #マニフェストをダウンロード |
---|
060 | set ocidManifestFileURL to doURL2Download(ocidManifestURL) |
---|
061 | #pkgを解凍してXMLのパスの取得 |
---|
062 | set ocidXmlFilePathURL to doExpand2Pkg(ocidManifestFileURL) |
---|
063 | log ocidXmlFilePathURL's absoluteString() as text |
---|
064 | #解凍したマニフェストからURLを取り出し |
---|
065 | set ocidURLArray to doGetPkgURL(ocidXmlFilePathURL) |
---|
066 | (ocidOutputArrayM's addObjectsFromArray:(ocidURLArray)) |
---|
067 | end repeat |
---|
068 | #ソート |
---|
069 | set ocidDescriptor to refMe's NSSortDescriptor's sortDescriptorWithKey:("absoluteString") ascending:(false) selector:("localizedStandardCompare:") |
---|
070 | set ocidDescriptorArray to refMe's NSArray's arrayWithObject:(ocidDescriptor) |
---|
071 | set ocidSortedArray to ocidOutputArrayM's sortedArrayUsingDescriptors:(ocidDescriptorArray) |
---|
072 | # |
---|
073 | set ocidSCAArrayM to refMe's NSMutableArray's alloc()'s init() |
---|
074 | set ocidDCArrayM to refMe's NSMutableArray's alloc()'s init() |
---|
075 | set ocidClassicArrayM to refMe's NSMutableArray's alloc()'s init() |
---|
076 | |
---|
077 | repeat with itemURL in ocidSortedArray |
---|
078 | set ocidURLString to itemURL's absoluteString() |
---|
079 | set boolSCA to (ocidURLString's containsString:("SCA")) |
---|
080 | set boolDC to (ocidURLString's containsString:("DC")) |
---|
081 | if boolSCA is true then |
---|
082 | (ocidSCAArrayM's addObject:(ocidURLString)) |
---|
083 | else if boolDC is true then |
---|
084 | (ocidDCArrayM's addObject:(ocidURLString)) |
---|
085 | else |
---|
086 | (ocidClassicArrayM's addObject:(ocidURLString)) |
---|
087 | end if |
---|
088 | end repeat |
---|
089 | #ソート |
---|
090 | set ocidDescriptor to refMe's NSSortDescriptor's sortDescriptorWithKey:("self") ascending:(false) selector:("localizedStandardCompare:") |
---|
091 | set ocidDescriptorArray to refMe's NSArray's arrayWithObject:(ocidDescriptor) |
---|
092 | set ocidSCAArray to ocidSCAArrayM's sortedArrayUsingDescriptors:(ocidDescriptorArray) |
---|
093 | set ocidDCArray to ocidDCArrayM's sortedArrayUsingDescriptors:(ocidDescriptorArray) |
---|
094 | set ocidClassicArray to ocidClassicArrayM's sortedArrayUsingDescriptors:(ocidDescriptorArray) |
---|
095 | |
---|
096 | #################################### |
---|
097 | set strDateString to doGetDateNo({"GGyy年MM月dd日EEEE", 2}) |
---|
098 | |
---|
099 | #出力 |
---|
100 | set ocidOutputString to refMe's NSMutableString's alloc()'s init() |
---|
101 | |
---|
102 | ocidOutputString's setString:(strDateString & ":取得 Acrobatアップデーター\n") |
---|
103 | ocidOutputString's appendString:("https://ardownload3でエラーになる場合は\nardownload2とardownloadを試してみてください\n") |
---|
104 | ocidOutputString's appendString:("dmg版が存在する場合もあります。拡張子をdmgにして試してみだくさい\n") |
---|
105 | ocidOutputString's appendString:("古いバージョンはすでにサーバーから削除されているpkgもあります\n") |
---|
106 | ocidOutputString's appendString:("incr: 差分アップデータ サイズが小さい\n") |
---|
107 | ocidOutputString's appendString:("MUI: マルチリンガル版\n") |
---|
108 | ocidOutputString's appendString:("Mini: SCA版Reader\n") |
---|
109 | ocidOutputString's appendString:("Inter: SCA版Standard\n") |
---|
110 | ocidOutputString's appendString:("FULL: SCA版Pro\n") |
---|
111 | ocidOutputString's appendString:("Next: SCA版BETA\n") |
---|
112 | |
---|
113 | ocidOutputString's appendString:("\n--\n") |
---|
114 | ocidOutputString's appendString:("【DC】Document Cloud版\n") |
---|
115 | ocidOutputString's appendString:("【DC】Reader無償版\n") |
---|
116 | repeat with itemString in ocidDCArray |
---|
117 | set boolReader to (itemString's containsString:("Rdr")) |
---|
118 | if boolReader is true then |
---|
119 | (ocidOutputString's appendString:(itemString)) |
---|
120 | (ocidOutputString's appendString:("\n")) |
---|
121 | end if |
---|
122 | end repeat |
---|
123 | (ocidOutputString's appendString:("\n")) |
---|
124 | ocidOutputString's appendString:("【DC】 Pro有償版\n") |
---|
125 | repeat with itemString in ocidDCArray |
---|
126 | set boolAcro to (itemString's containsString:("/acrobat/")) |
---|
127 | if boolAcro is true then |
---|
128 | (ocidOutputString's appendString:(itemString)) |
---|
129 | (ocidOutputString's appendString:("\n")) |
---|
130 | end if |
---|
131 | end repeat |
---|
132 | |
---|
133 | ocidOutputString's appendString:("\n--\n") |
---|
134 | ocidOutputString's appendString:("【SCA】Single Client App Unified App版\n") |
---|
135 | ocidOutputString's appendString:("Reader Mini無償版\n") |
---|
136 | ocidOutputString's appendString:("【SCA】 Classic Reader\n") |
---|
137 | set boolFirstItem to (missing value) |
---|
138 | repeat with itemString in ocidSCAArray |
---|
139 | set boolReader to (itemString's containsString:("Rdr")) |
---|
140 | if boolReader is true then |
---|
141 | if boolFirstItem is missing value then |
---|
142 | set boolScaDc to (itemString's containsString:("/AcrobatDC/")) |
---|
143 | if boolScaDc is true then |
---|
144 | (ocidOutputString's appendString:("【SCA】 DC Reader\n")) |
---|
145 | set boolFirstItem to true |
---|
146 | end if |
---|
147 | end if |
---|
148 | (ocidOutputString's appendString:(itemString)) |
---|
149 | (ocidOutputString's appendString:("\n")) |
---|
150 | end if |
---|
151 | end repeat |
---|
152 | (ocidOutputString's appendString:("\n")) |
---|
153 | ocidOutputString's appendString:("Acrobat 有償版\n") |
---|
154 | ocidOutputString's appendString:("【SCA】 Classic DC\n") |
---|
155 | set boolFirstItem to (missing value) |
---|
156 | repeat with itemString in ocidSCAArray |
---|
157 | set boolReader to (itemString's containsString:("AcrobatSCA")) |
---|
158 | if boolReader is true then |
---|
159 | if boolFirstItem is missing value then |
---|
160 | set boolScaDc to (itemString's containsString:("/AcrobatDC/")) |
---|
161 | if boolScaDc is true then |
---|
162 | (ocidOutputString's appendString:("【SCA】 DC Reader\n")) |
---|
163 | set boolFirstItem to true |
---|
164 | end if |
---|
165 | end if |
---|
166 | (ocidOutputString's appendString:(itemString)) |
---|
167 | (ocidOutputString's appendString:("\n")) |
---|
168 | end if |
---|
169 | end repeat |
---|
170 | ocidOutputString's appendString:("\n--\n") |
---|
171 | ocidOutputString's appendString:("【2020】Classic Track版\n") |
---|
172 | ocidOutputString's appendString:("【2020】Reader\n") |
---|
173 | repeat with itemString in ocidClassicArrayM |
---|
174 | set itemString to (itemString's stringByReplacingOccurrencesOfString:("https://ardownload2.adobe.com") withString:("https://ardownload3.adobe.com")) |
---|
175 | set itemString to (itemString's stringByReplacingOccurrencesOfString:("http://ardownload.adobe.com") withString:("https://ardownload3.adobe.com")) |
---|
176 | |
---|
177 | set bool2020 to (itemString's containsString:("/Acrobat2020/")) |
---|
178 | if bool2020 is true then |
---|
179 | set boolReader to (itemString's containsString:("/reader/")) |
---|
180 | if boolReader is true then |
---|
181 | (ocidOutputString's appendString:(itemString)) |
---|
182 | (ocidOutputString's appendString:("\n")) |
---|
183 | end if |
---|
184 | end if |
---|
185 | |
---|
186 | end repeat |
---|
187 | |
---|
188 | |
---|
189 | ocidOutputString's appendString:("【2020】製品版\n") |
---|
190 | repeat with itemString in ocidClassicArrayM |
---|
191 | set itemString to (itemString's stringByReplacingOccurrencesOfString:("https://ardownload2.adobe.com") withString:("https://ardownload3.adobe.com")) |
---|
192 | set itemString to (itemString's stringByReplacingOccurrencesOfString:("http://ardownload.adobe.com") withString:("https://ardownload3.adobe.com")) |
---|
193 | |
---|
194 | set bool2020 to (itemString's containsString:("/Acrobat2020/")) |
---|
195 | if bool2020 is true then |
---|
196 | set boolReader to (itemString's containsString:("/reader/")) |
---|
197 | if boolReader is false then |
---|
198 | (ocidOutputString's appendString:(itemString)) |
---|
199 | (ocidOutputString's appendString:("\n")) |
---|
200 | end if |
---|
201 | end if |
---|
202 | |
---|
203 | end repeat |
---|
204 | |
---|
205 | ocidOutputString's appendString:("\n--\n") |
---|
206 | ocidOutputString's appendString:("【旧製品】Classic Track版(リンク切れ多いです)\n") |
---|
207 | ocidOutputString's appendString:("【旧製品】Reader版\n") |
---|
208 | repeat with itemString in ocidClassicArrayM |
---|
209 | set itemString to (itemString's stringByReplacingOccurrencesOfString:("https://ardownload2.adobe.com") withString:("https://ardownload3.adobe.com")) |
---|
210 | set itemString to (itemString's stringByReplacingOccurrencesOfString:("http://ardownload.adobe.com") withString:("https://ardownload3.adobe.com")) |
---|
211 | |
---|
212 | set bool2020 to (itemString's containsString:("/Acrobat2020/")) |
---|
213 | if bool2020 is false then |
---|
214 | set boolReader to (itemString's containsString:("/reader/")) |
---|
215 | if boolReader is true then |
---|
216 | (ocidOutputString's appendString:(itemString)) |
---|
217 | (ocidOutputString's appendString:("\n")) |
---|
218 | end if |
---|
219 | end if |
---|
220 | |
---|
221 | end repeat |
---|
222 | ocidOutputString's appendString:("【旧製品】製品版\n") |
---|
223 | repeat with itemString in ocidClassicArrayM |
---|
224 | set itemString to (itemString's stringByReplacingOccurrencesOfString:("https://ardownload2.adobe.com") withString:("https://ardownload3.adobe.com")) |
---|
225 | set itemString to (itemString's stringByReplacingOccurrencesOfString:("http://ardownload.adobe.com") withString:("https://ardownload3.adobe.com")) |
---|
226 | |
---|
227 | set bool2020 to (itemString's containsString:("/Acrobat2020/")) |
---|
228 | if bool2020 is false then |
---|
229 | set boolReader to (itemString's containsString:("/reader/")) |
---|
230 | if boolReader is false then |
---|
231 | (ocidOutputString's appendString:(itemString)) |
---|
232 | (ocidOutputString's appendString:("\n")) |
---|
233 | end if |
---|
234 | end if |
---|
235 | |
---|
236 | end repeat |
---|
237 | |
---|
238 | |
---|
239 | |
---|
240 | |
---|
241 | ############ |
---|
242 | # |
---|
243 | set ociURLlistFilePathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:("URLlist/URLlist.txt") isDirectory:(true) |
---|
244 | # |
---|
245 | set listReadStrings to refMe's NSString's alloc()'s initWithContentsOfURL:(ociURLlistFilePathURL) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference) |
---|
246 | set ocidReadStrings to (item 1 of listReadStrings) |
---|
247 | (ocidOutputString's appendString:("\n")) |
---|
248 | (ocidOutputString's appendString:("------------------------------\n")) |
---|
249 | (ocidOutputString's appendString:("新規インストーラーリスト\n")) |
---|
250 | (ocidOutputString's appendString:(ocidReadStrings)) |
---|
251 | |
---|
252 | ############ |
---|
253 | # |
---|
254 | #テンポラリ(再起動時に自動削除) |
---|
255 | set appFileManager to refMe's NSFileManager's defaultManager() |
---|
256 | set ocidTempDirURL to appFileManager's temporaryDirectory() |
---|
257 | set ocidUUID to refMe's NSUUID's alloc()'s init() |
---|
258 | set ocidUUIDString to ocidUUID's UUIDString |
---|
259 | set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:(true) |
---|
260 | #保存先ディレクトリ |
---|
261 | set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0 |
---|
262 | ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions) |
---|
263 | set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference) |
---|
264 | #ログファイルパス |
---|
265 | set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("index.txt") isDirectory:(false) |
---|
266 | # |
---|
267 | |
---|
268 | |
---|
269 | set listDone to ocidOutputString's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference) |
---|
270 | if (item 1 of listDone) is true then |
---|
271 | set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace() |
---|
272 | set boolDone to appSharedWorkspace's openURL:(ocidSaveFilePathURL) |
---|
273 | return "writeToURL 正常終了" |
---|
274 | else if (item 1 of listDone) is false then |
---|
275 | log (item 2 of listDone)'s localizedDescription() as text |
---|
276 | return "保存に失敗しました" |
---|
277 | end if |
---|
278 | |
---|
279 | |
---|
280 | |
---|
281 | |
---|
282 | |
---|
283 | return |
---|
284 | |
---|
285 | ############ |
---|
286 | #XMLからURLを取得 |
---|
287 | to doGetPkgURL(argXmlFilePathURL) |
---|
288 | #NSXML |
---|
289 | set ocidOption to (refMe's NSDataReadingMappedIfSafe) |
---|
290 | set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(argXmlFilePathURL) options:(ocidOption) |error| :(reference) |
---|
291 | if (item 2 of listResponse) = (missing value) then |
---|
292 | log "initWithContentsOfURL 正常処理" |
---|
293 | set ocidHTMLData to (item 1 of listResponse) |
---|
294 | else if (item 2 of listResponse) ≠ (missing value) then |
---|
295 | log (item 2 of listResponse)'s code() as text |
---|
296 | log (item 2 of listResponse)'s localizedDescription() as text |
---|
297 | return "NSDATAエラーしました" |
---|
298 | end if |
---|
299 | #XML |
---|
300 | set ocidOption to (refMe's NSXMLNodePreserveAll) + (refMe's NSXMLDocumentTidyXML) |
---|
301 | set listResponse to refMe's NSXMLDocument's alloc()'s initWithData:(ocidHTMLData) options:(ocidOption) |error| :(reference) |
---|
302 | if (item 2 of listResponse) = (missing value) then |
---|
303 | log "initWithData 正常処理" |
---|
304 | set ocidXMLDoc to (item 1 of listResponse) |
---|
305 | else if (item 2 of listResponse) ≠ (missing value) then |
---|
306 | log (item 2 of listResponse)'s code() as text |
---|
307 | log (item 2 of listResponse)'s localizedDescription() as text |
---|
308 | log "NSXMLDocumentエラー 警告がありました" |
---|
309 | set ocidXMLDoc to (item 1 of listResponse) |
---|
310 | end if |
---|
311 | set listResponse to (ocidXMLDoc's nodesForXPath:"//dItem" |error| :(reference)) |
---|
312 | set ocidElementArray to (item 1 of listResponse) |
---|
313 | #戻し用のArray |
---|
314 | set ocidURLArray to refMe's NSMutableArray's alloc()'s init() |
---|
315 | #エレメントの数だけ繰り返し |
---|
316 | repeat with itemElement in ocidElementArray |
---|
317 | #アトリビュートを取り出して |
---|
318 | set ocidHost to (itemElement's attributeForName:("httpURLBase"))'s stringValue() |
---|
319 | set ocidPath to (itemElement's attributeForName:("URL"))'s stringValue() |
---|
320 | set ocidFile to (itemElement's attributeForName:("fileName"))'s stringValue() |
---|
321 | #URLにして |
---|
322 | set ocidHostURL to (refMe's NSURL's alloc()'s initWithString:(ocidHost)) |
---|
323 | set ocidURL to (ocidHostURL's URLByAppendingPathComponent:(ocidPath)) |
---|
324 | set ocidURL to (ocidURL's URLByAppendingPathComponent:(ocidFile)) |
---|
325 | #戻し用のArrayに追加 |
---|
326 | (ocidURLArray's addObject:(ocidURL)) |
---|
327 | end repeat |
---|
328 | return ocidURLArray |
---|
329 | |
---|
330 | end doGetPkgURL |
---|
331 | |
---|
332 | ############ |
---|
333 | #マニフェストのURL |
---|
334 | to doGetManifest(argPlistFilePathURL) |
---|
335 | set listResponse to refMe's NSDictionary's alloc()'s initWithContentsOfURL:(argPlistFilePathURL) |error| :(reference) |
---|
336 | set ocidPlistDict to (item 1 of listResponse) |
---|
337 | set ocidManifestDict to ocidPlistDict's objectForKey:("ManifestFileURL") |
---|
338 | set ocidURLbase to ocidManifestDict's valueForKey:("httpsURLBase") |
---|
339 | set ocidURLpath to ocidManifestDict's valueForKey:("URL") |
---|
340 | # |
---|
341 | set ocidURLhost to refMe's NSURL's alloc()'s initWithString:(ocidURLbase) |
---|
342 | set ocidURL to ocidURLhost's URLByAppendingPathComponent:(ocidURLpath) |
---|
343 | return ocidURL |
---|
344 | |
---|
345 | end doGetManifest |
---|
346 | |
---|
347 | |
---|
348 | ############ |
---|
349 | #ローカルのインストール済みのバージョン |
---|
350 | to doGetProductVersion(argPlistFilePathURL) |
---|
351 | set listResponse to refMe's NSDictionary's alloc()'s initWithContentsOfURL:(argPlistFilePathURL) |error| :(reference) |
---|
352 | set ocidPlistDict to (item 1 of listResponse) |
---|
353 | set ocidProductPathArray to ocidPlistDict's objectForKey:("Version") |
---|
354 | -->この戻り値はテキストなので |
---|
355 | set ocidAppPlistPathStr to ocidProductPathArray's firstObject() |
---|
356 | -->パスにしてから |
---|
357 | set ocidAppPlistPath to ocidAppPlistPathStr's stringByStandardizingPath() |
---|
358 | -->ファイルパスURLにする |
---|
359 | set ocidAppPlistPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidAppPlistPath) |
---|
360 | # |
---|
361 | set listResponse to refMe's NSDictionary's alloc()'s initWithContentsOfURL:(ocidAppPlistPathURL) |error| :(reference) |
---|
362 | set ocidAppPlistDict to (item 1 of listResponse) |
---|
363 | |
---|
364 | if ocidAppPlistDict ≠ (missing value) then |
---|
365 | set ocidProductVersion to ocidAppPlistDict's valueForKey:("CFBundleVersion") |
---|
366 | if ocidProductVersion = (missing value) then |
---|
367 | set ocidVersionKey to ocidProductPathArray's lastObject() |
---|
368 | set ocidProductVersion to ocidAppPlistDict's valueForKey:(ocidVersionKey) |
---|
369 | end if |
---|
370 | set ocidProductVersion to (ocidProductVersion's stringByReplacingOccurrencesOfString:(" ") withString:("")) |
---|
371 | |
---|
372 | else if ocidAppPlistDict = (missing value) then |
---|
373 | set ocidProductVersion to (missing value) |
---|
374 | end if |
---|
375 | return ocidProductVersion |
---|
376 | |
---|
377 | end doGetProductVersion |
---|
378 | |
---|
379 | |
---|
380 | ############ |
---|
381 | #バージョンURLの取得 |
---|
382 | to doGetVersion(argPlistFilePathURL) |
---|
383 | set listResponse to refMe's NSDictionary's alloc()'s initWithContentsOfURL:(argPlistFilePathURL) |error| :(reference) |
---|
384 | set ocidPlistDict to (item 1 of listResponse) |
---|
385 | set ocidVersionFileURLDict to ocidPlistDict's objectForKey:("VersionFileURL") |
---|
386 | set ocidURLbase to ocidVersionFileURLDict's valueForKey:("httpsURLBase") |
---|
387 | set ocidURLpath to ocidVersionFileURLDict's valueForKey:("URL") |
---|
388 | set ocidURLhost to refMe's NSURL's alloc()'s initWithString:(ocidURLbase) |
---|
389 | set ocidURL to ocidURLhost's URLByAppendingPathComponent:(ocidURLpath) |
---|
390 | # |
---|
391 | set listReadStrings to refMe's NSString's alloc()'s initWithContentsOfURL:(ocidURL) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference) |
---|
392 | set ocidReadStrings to (item 1 of listReadStrings) |
---|
393 | set boolNotFound to ocidReadStrings's containsString:("Not Found") |
---|
394 | if boolNotFound is true then |
---|
395 | set ocidReadStrings to (missing value) |
---|
396 | end if |
---|
397 | return ocidReadStrings |
---|
398 | |
---|
399 | end doGetVersion |
---|
400 | |
---|
401 | ############ |
---|
402 | #解凍 |
---|
403 | to doExpand2Pkg(argURL) |
---|
404 | #テンポラリ(再起動時に自動削除) |
---|
405 | set appFileManager to refMe's NSFileManager's defaultManager() |
---|
406 | set ocidTempDirURL to appFileManager's temporaryDirectory() |
---|
407 | set ocidUUID to refMe's NSUUID's alloc()'s init() |
---|
408 | set ocidUUIDString to ocidUUID's UUIDString |
---|
409 | set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:(true) |
---|
410 | #保存先ディレクトリ |
---|
411 | set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0 |
---|
412 | ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions) |
---|
413 | set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference) |
---|
414 | #ログファイルパス |
---|
415 | set ocidLogFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("exec.log") isDirectory:(false) |
---|
416 | set ocidLogFilePath to ocidLogFilePathURL's |path|() |
---|
417 | #ログファイル生成 |
---|
418 | set ocidNulString to refMe's NSString's alloc()'s init() |
---|
419 | set listDone to ocidNulString's writeToURL:(ocidLogFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference) |
---|
420 | #ログファイルのアクセス権 644 |
---|
421 | ocidAttrDict's setValue:(420) forKey:(refMe's NSFilePosixPermissions) |
---|
422 | set listDone to appFileManager's setAttributes:(ocidAttrDict) ofItemAtPath:(ocidLogFilePath) |error| :(reference) |
---|
423 | #パスにする |
---|
424 | set ocidFilePath to argURL's |path|() |
---|
425 | set ocidExpandDirPathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:("Expand") isDirectory:(true) |
---|
426 | set ocidExpandDirPath to ocidExpandDirPathURL's |path|() |
---|
427 | #コマンド実行 |
---|
428 | set strComandText to "/usr/sbin/pkgutil --expand-full \"" & (ocidFilePath as text) & "\" \"" & (ocidExpandDirPath as text) & "\"" as text |
---|
429 | log strComandText |
---|
430 | #コマンド実行 |
---|
431 | set ocidTermTask to refMe's NSTask's alloc()'s init() |
---|
432 | ocidTermTask's setLaunchPath:("/bin/zsh") |
---|
433 | set ocidArgumentsArray to refMe's NSMutableArray's alloc()'s init() |
---|
434 | ocidArgumentsArray's addObject:("-c") |
---|
435 | ocidArgumentsArray's addObject:(strComandText) |
---|
436 | ocidTermTask's setArguments:(ocidArgumentsArray) |
---|
437 | set ocidOutPut to refMe's NSPipe's pipe() |
---|
438 | set ocidError to refMe's NSPipe's pipe() |
---|
439 | ocidTermTask's setStandardOutput:(ocidOutPut) |
---|
440 | ocidTermTask's setStandardError:(ocidError) |
---|
441 | ocidTermTask's setCurrentDirectoryURL:(ocidSaveDirPathURL) |
---|
442 | set listDoneReturn to ocidTermTask's launchAndReturnError:(reference) |
---|
443 | if (item 1 of listDoneReturn) is (false) then |
---|
444 | log "エラーコード:" & (item 2 of listDoneReturn)'s code() as text |
---|
445 | log "エラードメイン:" & (item 2 of listDoneReturn)'s domain() as text |
---|
446 | log "Description:" & (item 2 of listDoneReturn)'s localizedDescription() as text |
---|
447 | log "FailureReason:" & (item 2 of listDoneReturn)'s localizedFailureReason() as text |
---|
448 | end if |
---|
449 | #終了待ち |
---|
450 | ocidTermTask's waitUntilExit() |
---|
451 | #標準出力をログに |
---|
452 | set ocidOutPutData to ocidOutPut's fileHandleForReading() |
---|
453 | set listResponse to ocidOutPutData's readDataToEndOfFileAndReturnError:(reference) |
---|
454 | set ocidStdOut to (item 1 of listResponse) |
---|
455 | set ocidStdOut to refMe's NSString's alloc()'s initWithData:(ocidStdOut) encoding:(refMe's NSUTF8StringEncoding) |
---|
456 | ##これが戻り値 |
---|
457 | log ocidStdOut as text |
---|
458 | set listDone to ocidStdOut's writeToURL:(ocidLogFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference) |
---|
459 | # |
---|
460 | set ocidAssetDirPathURL to ocidExpandDirPathURL's URLByAppendingPathComponent:("ASSET") isDirectory:(true) |
---|
461 | set appFileManager to refMe's NSFileManager's defaultManager() |
---|
462 | set ocidOption to (refMe's NSDirectoryEnumerationSkipsHiddenFiles) |
---|
463 | set ocidKeyArray to refMe's NSMutableArray's alloc()'s init() |
---|
464 | ocidKeyArray's addObject:(refMe's NSURLPathKey) |
---|
465 | set listSubPathResult to (appFileManager's contentsOfDirectoryAtURL:(ocidAssetDirPathURL) includingPropertiesForKeys:(ocidKeyArray) options:(ocidOption) |error| :(reference)) |
---|
466 | set ocidSubPathURLArray to item 1 of listSubPathResult |
---|
467 | set ocidXmlFilePathURL to ocidSubPathURLArray's firstObject() |
---|
468 | return ocidXmlFilePathURL |
---|
469 | |
---|
470 | end doExpand2Pkg |
---|
471 | |
---|
472 | |
---|
473 | ############ |
---|
474 | #ダウンロード |
---|
475 | to doURL2Download(argURL) |
---|
476 | #テンポラリ(再起動時に自動削除) |
---|
477 | set appFileManager to refMe's NSFileManager's defaultManager() |
---|
478 | set ocidTempDirURL to appFileManager's temporaryDirectory() |
---|
479 | set ocidUUID to refMe's NSUUID's alloc()'s init() |
---|
480 | set ocidUUIDString to ocidUUID's UUIDString |
---|
481 | set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:(true) |
---|
482 | #保存先ディレクトリ |
---|
483 | set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0 |
---|
484 | ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions) |
---|
485 | set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference) |
---|
486 | #保存先パス |
---|
487 | set ocidFileName to argURL's lastPathComponent() |
---|
488 | set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(ocidFileName) isDirectory:(false) |
---|
489 | ##NSDATAに読み込む |
---|
490 | set ocidOption to (refMe's NSDataReadingMappedIfSafe) |
---|
491 | set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(argURL) options:(ocidOption) |error| :(reference) |
---|
492 | if (item 2 of listResponse) = (missing value) then |
---|
493 | log "initWithContentsOfURL 正常処理" |
---|
494 | set ocidReadData to (item 1 of listResponse) |
---|
495 | else if (item 2 of listResponse) ≠ (missing value) then |
---|
496 | set strErrorNO to (item 2 of listResponse)'s code() as text |
---|
497 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
---|
498 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
---|
499 | return "initWithContentsOfURL エラーしました" & strErrorNO & strErrorMes |
---|
500 | end if |
---|
501 | ##NSDataで保存 |
---|
502 | set ocidOption to (refMe's NSDataWritingAtomic) |
---|
503 | set listDone to ocidReadData's writeToURL:(ocidSaveFilePathURL) options:(ocidOption) |error| :(reference) |
---|
504 | if (item 1 of listDone) is true then |
---|
505 | log "writeToURL 正常処理" |
---|
506 | else if (item 2 of listDone) ≠ (missing value) then |
---|
507 | set strErrorNO to (item 2 of listDone)'s code() as text |
---|
508 | set strErrorMes to (item 2 of listDone)'s localizedDescription() as text |
---|
509 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
---|
510 | return "writeToURL エラーしました" & strErrorNO & strErrorMes |
---|
511 | end if |
---|
512 | return ocidSaveFilePathURL |
---|
513 | |
---|
514 | end doURL2Download |
---|
515 | |
---|
516 | |
---|
517 | |
---|
518 | ################################ |
---|
519 | # 日付 doGetDateNo(argDateFormat,argCalendarNO) |
---|
520 | # argCalendarNO 1 NSCalendarIdentifierGregorian 西暦 |
---|
521 | # argCalendarNO 2 NSCalendarIdentifierJapanese 和暦 |
---|
522 | ################################ |
---|
523 | to doGetDateNo({argDateFormat, argCalendarNO}) |
---|
524 | ##渡された値をテキストで確定させて |
---|
525 | set strDateFormat to argDateFormat as text |
---|
526 | set intCalendarNO to argCalendarNO as integer |
---|
527 | ###日付情報の取得 |
---|
528 | set ocidDate to current application's NSDate's |date|() |
---|
529 | ###日付のフォーマットを定義(日本語) |
---|
530 | set ocidFormatterJP to current application's NSDateFormatter's alloc()'s init() |
---|
531 | ###和暦 西暦 カレンダー分岐 |
---|
532 | if intCalendarNO = 1 then |
---|
533 | set ocidCalendarID to (current application's NSCalendarIdentifierGregorian) |
---|
534 | else if intCalendarNO = 2 then |
---|
535 | set ocidCalendarID to (current application's NSCalendarIdentifierJapanese) |
---|
536 | else |
---|
537 | set ocidCalendarID to (current application's NSCalendarIdentifierISO8601) |
---|
538 | end if |
---|
539 | set ocidCalendarJP to current application's NSCalendar's alloc()'s initWithCalendarIdentifier:(ocidCalendarID) |
---|
540 | set ocidTimezoneJP to current application's NSTimeZone's alloc()'s initWithName:("Asia/Tokyo") |
---|
541 | set ocidLocaleJP to current application's NSLocale's alloc()'s initWithLocaleIdentifier:("ja_JP_POSIX") |
---|
542 | ###設定 |
---|
543 | ocidFormatterJP's setTimeZone:(ocidTimezoneJP) |
---|
544 | ocidFormatterJP's setLocale:(ocidLocaleJP) |
---|
545 | ocidFormatterJP's setCalendar:(ocidCalendarJP) |
---|
546 | # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterNoStyle) |
---|
547 | # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterShortStyle) |
---|
548 | # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterMediumStyle) |
---|
549 | # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterLongStyle) |
---|
550 | ocidFormatterJP's setDateStyle:(current application's NSDateFormatterFullStyle) |
---|
551 | ###渡された値でフォーマット定義 |
---|
552 | ocidFormatterJP's setDateFormat:(strDateFormat) |
---|
553 | ###フォーマット適応 |
---|
554 | set ocidDateAndTime to ocidFormatterJP's stringFromDate:(ocidDate) |
---|
555 | ###テキストで戻す |
---|
556 | set strDateAndTime to ocidDateAndTime as text |
---|
557 | return strDateAndTime |
---|
558 | end doGetDateNo |
---|
559 | |
---|
560 | |
---|
561 | |
---|
562 | |
---|
563 | return |
---|
564 | #以下URLのメモ |
---|
565 | "/arm-manifests/mac/Acrobat2015/acrobat/AcrobatManifest.arm" |
---|
566 | "/arm-manifests/mac/Acrobat2015/acrobat/current_version.txt" |
---|
567 | "/arm-manifests/mac/ServicesUpdater/acrobat/2015/AcroManifest.arm" |
---|
568 | "/arm-manifests/mac/ServicesUpdater/acrobat/2015/current_version.txt" |
---|
569 | |
---|
570 | "/arm-manifests/mac/Acrobat2015/reader/ReaderManifest.arm" |
---|
571 | "/arm-manifests/mac/Acrobat2015/reader/current_version.txt" |
---|
572 | "/arm-manifests/mac/ServicesUpdater/reader/2015/RdrManifest.arm" |
---|
573 | "/arm-manifests/mac/ServicesUpdater/reader/2015/current_version.txt" |
---|
574 | |
---|
575 | "/arm-manifests/mac/Acrobat2017/acrobat/AcrobatManifest.arm" |
---|
576 | "/arm-manifests/mac/Acrobat2017/acrobat/current_version.txt" |
---|
577 | "/arm-manifests/mac/ServicesUpdater/acrobat/2017/AcroManifest.arm" |
---|
578 | "/arm-manifests/mac/ServicesUpdater/acrobat/2017/current_version.txt" |
---|
579 | |
---|
580 | "/arm-manifests/mac/Acrobat2017/reader/ReaderManifest.arm" |
---|
581 | "/arm-manifests/mac/Acrobat2017/reader/current_version.txt" |
---|
582 | "/arm-manifests/mac/ServicesUpdater/reader/2017/RdrManifest.arm" |
---|
583 | "/arm-manifests/mac/ServicesUpdater/reader/2017/current_version.txt" |
---|
584 | |
---|
585 | "/arm-manifests/mac/Acrobat2020/acrobat/AcrobatManifest.arm" |
---|
586 | "/arm-manifests/mac/Acrobat2020/acrobat/current_version.txt" |
---|
587 | "/arm-manifests/mac/ServicesUpdater/acrobat/2020/AcroManifest.arm" |
---|
588 | "/arm-manifests/mac/ServicesUpdater/acrobat/2020/current_version.txt" |
---|
589 | |
---|
590 | "/arm-manifests/mac/Acrobat2020/reader/ReaderManifest.arm" |
---|
591 | "/arm-manifests/mac/Acrobat2020/reader/current_version.txt" |
---|
592 | "/arm-manifests/mac/ServicesUpdater/reader/2020/RdrManifest.arm" |
---|
593 | "/arm-manifests/mac/ServicesUpdater/reader/2020/current_version.txt" |
---|
594 | |
---|
595 | "/arm-manifests/mac/AcrobatDC/acrobat/AcrobatManifest.arm" |
---|
596 | "/arm-manifests/mac/AcrobatDC/acrobat/current_version.txt" |
---|
597 | "/arm-manifests/mac/ServicesUpdater/acrobat/DC/AcroManifest.arm" |
---|
598 | "/arm-manifests/mac/ServicesUpdater/acrobat/DC/current_version.txt" |
---|
599 | |
---|
600 | "/arm-manifests/mac/AcrobatDC/reader/ReaderManifest.arm" |
---|
601 | "/arm-manifests/mac/AcrobatDC/reader/current_version.txt" |
---|
602 | "/arm-manifests/mac/ServicesUpdater/reader/DC/RdrManifest.arm" |
---|
603 | "/arm-manifests/mac/ServicesUpdater/reader/DC/current_version.txt" |
---|
604 | |
---|
605 | "/arm-manifests/mac/AcrobatDC/acrobatSCA/AcrobatSCAManifest.arm" |
---|
606 | "/arm-manifests/mac/AcrobatDC/acrobatSCA/current_version.txt" |
---|
607 | "/arm-manifests/mac/ServicesUpdater/acrobatSCA/DC/AcroSCAManifest.arm" |
---|
608 | "/arm-manifests/mac/ServicesUpdater/acrobatSCA/DC/current_version.txt" |
---|
609 | |
---|
610 | "/arm-manifests/mac/Classic/acrobatSCA/AcrobatSCAManifest.arm" |
---|
611 | "/arm-manifests/mac/Classic/acrobatSCA/current_version.txt" |
---|
612 | "/arm-manifests/mac/ServicesUpdater/acrobatSCA/Classic/AcroSCAManifest.arm" |
---|
613 | "/arm-manifests/mac/ServicesUpdater/acrobatSCA/Classic/current_version.txt" |
---|
614 | |
---|
615 | |
---|
616 | "/arm-manifests/mac/ARMDC/ARMDCHelperManifest.arm" |
---|
617 | "/arm-manifests/mac/ARMDC/current_version.txt" |
---|
618 | "/Library/Application Support/Adobe/ARMDC/Application/Acrobat Update Helper.app/Contents/Info.plist" |
---|
619 | |
---|