mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-23 04:34:27 +00:00
Compare commits
577
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
409b35c20f | ||
|
|
aa92d572dd | ||
|
|
f1d3e4dd7f | ||
|
|
8a45304d55 | ||
|
|
f56a6025a0 | ||
|
|
805447d748 | ||
|
|
cdfd506cc0 | ||
|
|
90098dae5a | ||
|
|
3148182f1b | ||
|
|
31172f61f9 | ||
|
|
d35a68f5be | ||
|
|
6745346f1d | ||
|
|
1ab5de851f | ||
|
|
358933f965 | ||
|
|
a60255c95c | ||
|
|
2c54ec012d | ||
|
|
b671c6bef6 | ||
|
|
6f24f56f0d | ||
|
|
59f9e0ee1b | ||
|
|
ac7fd917d3 | ||
|
|
53f0f4f9ee | ||
|
|
55c57abd2f | ||
|
|
006e71fa89 | ||
|
|
c6d47ed68d | ||
|
|
fd906d9589 | ||
|
|
3e6431f94d | ||
|
|
4a015ada8f | ||
|
|
2c1b3783e4 | ||
|
|
808bde2699 | ||
|
|
fde6b4775e | ||
|
|
92bafa92bf | ||
|
|
7e2d4b019e | ||
|
|
10b8872afb | ||
|
|
d4d984f42c | ||
|
|
bd98b33e25 | ||
|
|
79f447d537 | ||
|
|
a4759c871e | ||
|
|
a3b9a74fe1 | ||
|
|
faba759574 | ||
|
|
91800e3036 | ||
|
|
d7dbbe4bb9 | ||
|
|
2579f2c3a3 | ||
|
|
01e9bd82be | ||
|
|
d34d2853f6 | ||
|
|
fd1ffce3e2 | ||
|
|
6ae7b68659 | ||
|
|
54dc6d0071 | ||
|
|
a773ac5856 | ||
|
|
686c87242c | ||
|
|
f2eaaeb4a3 | ||
|
|
5676acaebc | ||
|
|
0055adcc52 | ||
|
|
ad518eb209 | ||
|
|
20100c283f | ||
|
|
fc88f94d5d | ||
|
|
222ab3edd9 | ||
|
|
4b831a1394 | ||
|
|
bdc45d7e47 | ||
|
|
6ca5c3a337 | ||
|
|
4ab8fd1010 | ||
|
|
3f40f444db | ||
|
|
f1d5103a07 | ||
|
|
890f1fb393 | ||
|
|
d7993257fe | ||
|
|
c99378c170 | ||
|
|
00d8b64b41 | ||
|
|
6a79789d32 | ||
|
|
ec8f46af91 | ||
|
|
2ae8248c35 | ||
|
|
d9d3ff2a8e | ||
|
|
b420ad65be | ||
|
|
5504d6896f | ||
|
|
d888705fd8 | ||
|
|
8d1109b59f | ||
|
|
25aca9f56f | ||
|
|
e75a9b0591 | ||
|
|
5dfc6ab3b2 | ||
|
|
76cca58776 | ||
|
|
7141818b31 | ||
|
|
52bee98867 | ||
|
|
b262c2b581 | ||
|
|
192c3b4c2d | ||
|
|
cfe375b5f3 | ||
|
|
271970697e | ||
|
|
1539c0c077 | ||
|
|
aa25194536 | ||
|
|
6ab4163957 | ||
|
|
dfa27acde2 | ||
|
|
50c3df3a6f | ||
|
|
31a49c83b5 | ||
|
|
a57eb736cb | ||
|
|
52b2d75d63 | ||
|
|
9ea81e21b9 | ||
|
|
eda214a3ec | ||
|
|
d2b7fd6236 | ||
|
|
77ce7c19e9 | ||
|
|
048ce10ed5 | ||
|
|
b23d4a9641 | ||
|
|
843bbe7ece | ||
|
|
a7dbe4184c | ||
|
|
3287299f53 | ||
|
|
1b71d3ebd1 | ||
|
|
ef8edef094 | ||
|
|
c793adf2ed | ||
|
|
5cf229ba41 | ||
|
|
4789ebdec5 | ||
|
|
0ed83cf9f2 | ||
|
|
c37fc01bb1 | ||
|
|
7fae28135e | ||
|
|
82c722ba37 | ||
|
|
aba5567a15 | ||
|
|
1325d3fe40 | ||
|
|
8d2054e62a | ||
|
|
d593a04dda | ||
|
|
8fa758f8aa | ||
|
|
2a0d8afe4e | ||
|
|
3e3a11bd0f | ||
|
|
41b2f054f8 | ||
|
|
93ebf843c2 | ||
|
|
984aac852f | ||
|
|
69c9c70d21 | ||
|
|
478c7fd8cd | ||
|
|
243fdf8f7f | ||
|
|
337002f421 | ||
|
|
a7ba6a7421 | ||
|
|
7b3928db9b | ||
|
|
b86770c39f | ||
|
|
f6622104bf | ||
|
|
860739fce2 | ||
|
|
08065bc05b | ||
|
|
38eb63a7a2 | ||
|
|
f7daf04204 | ||
|
|
2350c59cc8 | ||
|
|
4eebdb82c4 | ||
|
|
066d634ef6 | ||
|
|
9e2e489109 | ||
|
|
f9c428ee06 | ||
|
|
16cdd6bf64 | ||
|
|
e657bcf03a | ||
|
|
d138f64bd6 | ||
|
|
3c37f775fb | ||
|
|
7a283bfaeb | ||
|
|
c1510a5bea | ||
|
|
7a20432b1b | ||
|
|
3d8be2d2da | ||
|
|
a59e8ff958 | ||
|
|
26077f47af | ||
|
|
118f3c5141 | ||
|
|
22b65a3095 | ||
|
|
05c51a1c05 | ||
|
|
21f95465da | ||
|
|
ab74bdca79 | ||
|
|
69d471aefb | ||
|
|
d620dc0b52 | ||
|
|
d3f975816e | ||
|
|
91ac9178f1 | ||
|
|
ae52d2743e | ||
|
|
a4082a0e54 | ||
|
|
9c8e825289 | ||
|
|
9662452c09 | ||
|
|
0a3051349a | ||
|
|
1c258cb690 | ||
|
|
4ba453f337 | ||
|
|
6960045e2b | ||
|
|
803925f2cf | ||
|
|
97c71ef700 | ||
|
|
595c6ce491 | ||
|
|
6b7752792d | ||
|
|
b7dc2438a7 | ||
|
|
12904a5af6 | ||
|
|
7fc9e32ce7 | ||
|
|
9aa3015929 | ||
|
|
09f0c43e7c | ||
|
|
a570191859 | ||
|
|
d7dea30de6 | ||
|
|
409e7e22bf | ||
|
|
ed456740b0 | ||
|
|
8a25500eca | ||
|
|
cdfcd1469e | ||
|
|
4c54349c23 | ||
|
|
4d00e8c569 | ||
|
|
02088e0da6 | ||
|
|
f341d0c3a9 | ||
|
|
833081ffa9 | ||
|
|
faed494d4e | ||
|
|
dbebe4b3b2 | ||
|
|
e27828d248 | ||
|
|
44cf0d0e51 | ||
|
|
320b3aa62a | ||
|
|
1d8adc8fac | ||
|
|
bc458a6ab5 | ||
|
|
6be55685c8 | ||
|
|
29b7321094 | ||
|
|
449b00ed3e | ||
|
|
4c2573702e | ||
|
|
88d4b348d9 | ||
|
|
bf07a9435b | ||
|
|
799b2a381f | ||
|
|
8b4cf14e53 | ||
|
|
515511d5e9 | ||
|
|
aca8cc6fbf | ||
|
|
1bc3834345 | ||
|
|
73e96cdcab | ||
|
|
760e32c5bd | ||
|
|
cf1b167954 | ||
|
|
5ef6c64568 | ||
|
|
7e05e97c95 | ||
|
|
5cd98c5508 | ||
|
|
e6deed9c56 | ||
|
|
290f64f552 | ||
|
|
59caa1f300 | ||
|
|
882b5c9b8a | ||
|
|
7ba0c583af | ||
|
|
b275cab13f | ||
|
|
6a48420e07 | ||
|
|
59f9236009 | ||
|
|
f20c121745 | ||
|
|
25040affc2 | ||
|
|
82e6250250 | ||
|
|
9f2d53a3a2 | ||
|
|
ec4ebbdcfb | ||
|
|
716bb30e7c | ||
|
|
aeeae26d1c | ||
|
|
095d223e70 | ||
|
|
55eed9efd8 | ||
|
|
d092ae9295 | ||
|
|
5457476e4a | ||
|
|
5dce90eafa | ||
|
|
268ea201da | ||
|
|
613b759077 | ||
|
|
02e090c291 | ||
|
|
f6a2e76685 | ||
|
|
8f5b9f03ac | ||
|
|
bb682da743 | ||
|
|
bf38b0c9fd | ||
|
|
e64516c089 | ||
|
|
fc725cce01 | ||
|
|
95398cd26f | ||
|
|
b515c15f9b | ||
|
|
01e8cf90c6 | ||
|
|
7152bd0ffa | ||
|
|
05861e5340 | ||
|
|
aa853a0f0f | ||
|
|
a47151c638 | ||
|
|
06642bba20 | ||
|
|
f04a460d63 | ||
|
|
7d4ce0daeb | ||
|
|
a2bcd53eaa | ||
|
|
5a47fb64c3 | ||
|
|
c96aa2eda8 | ||
|
|
e30a342813 | ||
|
|
320672c1f9 | ||
|
|
0bd27c0cb7 | ||
|
|
436107f20e | ||
|
|
abda56d047 | ||
|
|
950e3894b3 | ||
|
|
2300f2bcb0 | ||
|
|
a6d776ca04 | ||
|
|
76e79d6f92 | ||
|
|
9cc1905f87 | ||
|
|
78e24a6fe6 | ||
|
|
f1a353840a | ||
|
|
0f34252f4a | ||
|
|
000a24c63b | ||
|
|
32d4f249d4 | ||
|
|
96272fce7d | ||
|
|
dc925712dc | ||
|
|
e71915b4fb | ||
|
|
31b9ba8dde | ||
|
|
83708695af | ||
|
|
bb363db7f8 | ||
|
|
ba6c3b6854 | ||
|
|
200da2b1be | ||
|
|
db652744ef | ||
|
|
9f3d4fb524 | ||
|
|
86b6502342 | ||
|
|
fa671073fa | ||
|
|
4f1e5a72a0 | ||
|
|
bca574119b | ||
|
|
acb8f5f076 | ||
|
|
16ff5c6683 | ||
|
|
67d53c04b7 | ||
|
|
910f78b569 | ||
|
|
fdaf26e95d | ||
|
|
a8854375f5 | ||
|
|
9937e5a17b | ||
|
|
67b0860a9f | ||
|
|
5b90432f7e | ||
|
|
7cd8974b7e | ||
|
|
9c042a5767 | ||
|
|
3db00fa137 | ||
|
|
f6710e2379 | ||
|
|
990dee6a8d | ||
|
|
7bfec0f3c0 | ||
|
|
3ea1a9eee4 | ||
|
|
f6e292fad3 | ||
|
|
1cce7890d8 | ||
|
|
61340cab17 | ||
|
|
4a95dbeddc | ||
|
|
45178111b3 | ||
|
|
eef0f5f0dc | ||
|
|
1e1025f17d | ||
|
|
69407123ba | ||
|
|
096d43a7a6 | ||
|
|
00b67269d6 | ||
|
|
5fe0a7cb59 | ||
|
|
7baf50506b | ||
|
|
40616b864a | ||
|
|
561bbbe294 | ||
|
|
fba7231261 | ||
|
|
b3ac18f173 | ||
|
|
e2a59fccb2 | ||
|
|
a8f26b16c2 | ||
|
|
b7a3999da8 | ||
|
|
a5c8e0b1e2 | ||
|
|
2768e60ce1 | ||
|
|
9075d4a037 | ||
|
|
da35ef695b | ||
|
|
394319e1fc | ||
|
|
0c6e6fdd84 | ||
|
|
39bb82bd9a | ||
|
|
25d7faea7b | ||
|
|
a0c2de60d3 | ||
|
|
e8299fd116 | ||
|
|
4548228238 | ||
|
|
fe1372c962 | ||
|
|
a6fcfa61b5 | ||
|
|
c34e9b3c34 | ||
|
|
ea81eeec57 | ||
|
|
19ae8506ab | ||
|
|
803676d56a | ||
|
|
5975703b13 | ||
|
|
ecd2ce227b | ||
|
|
3f502b6151 | ||
|
|
fb43787317 | ||
|
|
f81bfd9f1c | ||
|
|
24ebb7b379 | ||
|
|
2460f2fcf7 | ||
|
|
401e696590 | ||
|
|
29035199f3 | ||
|
|
b4210d8f61 | ||
|
|
c120af6b1f | ||
|
|
96ea09e44f | ||
|
|
f5a1b1c27d | ||
|
|
5cdfffa521 | ||
|
|
a5245accf4 | ||
|
|
9bc63ccf7e | ||
|
|
2e3ed79753 | ||
|
|
da3b5c2570 | ||
|
|
756b37d4a5 | ||
|
|
36b7d434ad | ||
|
|
b21b308203 | ||
|
|
dab8a36a13 | ||
|
|
152e6f9572 | ||
|
|
f8fbf370bc | ||
|
|
61291c77d7 | ||
|
|
b90df8b254 | ||
|
|
4dbc0dd47f | ||
|
|
9d3db1b103 | ||
|
|
b8c8b9e605 | ||
|
|
d7260665d6 | ||
|
|
b96c95066c | ||
|
|
3d352c6fcd | ||
|
|
874572f7bb | ||
|
|
8f0d7d0805 | ||
|
|
65f8d2629a | ||
|
|
c0ca2249a5 | ||
|
|
efe903bc73 | ||
|
|
fd20e0725b | ||
|
|
6c8f094bbe | ||
|
|
50b76d59f7 | ||
|
|
4f76b42bb5 | ||
|
|
d593ab38ad | ||
|
|
a17f974357 | ||
|
|
40dee9958b | ||
|
|
575bdda768 | ||
|
|
9b116929ad | ||
|
|
2e8fa61a5a | ||
|
|
cd93eb9098 | ||
|
|
4c765d86ee | ||
|
|
fa8aaced55 | ||
|
|
1b02ab5f7f | ||
|
|
0e609cc528 | ||
|
|
5ec4c74b0b | ||
|
|
4d7006950a | ||
|
|
e49a69895a | ||
|
|
27f2b9c219 | ||
|
|
db820fbb0f | ||
|
|
ad4e9c74e0 | ||
|
|
4797446f7c | ||
|
|
0ffcde4fbb | ||
|
|
f555e1143f | ||
|
|
bc3fd4542b | ||
|
|
d3fac14586 | ||
|
|
d0425a140a | ||
|
|
64ec0c317e | ||
|
|
5f694f82af | ||
|
|
590122f25a | ||
|
|
9b670b9ea7 | ||
|
|
65e836cba1 | ||
|
|
c634f61f2a | ||
|
|
776e78c459 | ||
|
|
a03235851c | ||
|
|
d2f843f92c | ||
|
|
e9c69673ad | ||
|
|
a453afa29a | ||
|
|
cee669c276 | ||
|
|
2e0c1b0086 | ||
|
|
7686c86792 | ||
|
|
2e0f0211d1 | ||
|
|
4f8d745305 | ||
|
|
9788c6849e | ||
|
|
48dfbac37a | ||
|
|
e4eccce811 | ||
|
|
097c2fea42 | ||
|
|
5a5b171a68 | ||
|
|
343d6866c4 | ||
|
|
2ad144c739 | ||
|
|
983ad61d78 | ||
|
|
27e87143e1 | ||
|
|
d0b802e09b | ||
|
|
8c67631efb | ||
|
|
18df114b70 | ||
|
|
c51bf739cf | ||
|
|
43a0a7db4f | ||
|
|
bbcfe7edf4 | ||
|
|
a11578a863 | ||
|
|
b546304d5d | ||
|
|
d7774c0dc0 | ||
|
|
bd80144c7b | ||
|
|
315cbaab1b | ||
|
|
af37928283 | ||
|
|
6a3df43017 | ||
|
|
c747ffc35b | ||
|
|
7bfbe83d87 | ||
|
|
a871569867 | ||
|
|
65b071eb86 | ||
|
|
0e99d4fa80 | ||
|
|
8f00c3c274 | ||
|
|
4fad53007f | ||
|
|
e7435964a2 | ||
|
|
8ea15468b4 | ||
|
|
9025bef687 | ||
|
|
ffc44bb089 | ||
|
|
6c968489eb | ||
|
|
2fc1b66a79 | ||
|
|
bd99d0451d | ||
|
|
d62e47cd2e | ||
|
|
ab23fedd0c | ||
|
|
43a603c1cc | ||
|
|
9b5b541c82 | ||
|
|
119bac527f | ||
|
|
e9bc6a2915 | ||
|
|
2979338f8a | ||
|
|
830f633a6e | ||
|
|
0d51d12e43 | ||
|
|
2d47989616 | ||
|
|
f259b5e825 | ||
|
|
3800b33c1a | ||
|
|
dfe0eff095 | ||
|
|
8cdec40a03 | ||
|
|
6169234300 | ||
|
|
3ff2d82ecf | ||
|
|
3ef4c09f71 | ||
|
|
79bd7ac090 | ||
|
|
6e648f14f4 | ||
|
|
c3d8254324 | ||
|
|
15095640eb | ||
|
|
6070419761 | ||
|
|
db2f48ad09 | ||
|
|
cfe5206252 | ||
|
|
975f679148 | ||
|
|
b571a3d58d | ||
|
|
5090d4b3a0 | ||
|
|
799b00211d | ||
|
|
afe8afc41f | ||
|
|
090e7c0ecb | ||
|
|
e557b78394 | ||
|
|
c53f961690 | ||
|
|
9e6b51fac9 | ||
|
|
a6f98158a7 | ||
|
|
ca040bdf9a | ||
|
|
f95cf6454d | ||
|
|
827c6adc03 | ||
|
|
59d9ece06b | ||
|
|
1dd1b09e5f | ||
|
|
58296ecaf7 | ||
|
|
3b0674320f | ||
|
|
a8b2b4f962 | ||
|
|
6fc32b6800 | ||
|
|
1e20d43c2a | ||
|
|
52814bcbd0 | ||
|
|
74fccaaab5 | ||
|
|
6813a06455 | ||
|
|
e423cfee35 | ||
|
|
7316a00e9c | ||
|
|
54299d766a | ||
|
|
f2a7b4b349 | ||
|
|
150718ad6f | ||
|
|
0904ec151c | ||
|
|
dff6e0832c | ||
|
|
e983c03232 | ||
|
|
d1c54608f7 | ||
|
|
24b6c88935 | ||
|
|
6397e56c06 | ||
|
|
9785111857 | ||
|
|
522ffb08f0 | ||
|
|
22129e3ec7 | ||
|
|
4431864770 | ||
|
|
23a57f7876 | ||
|
|
05b75aa44c | ||
|
|
e35a1ca231 | ||
|
|
1cc6c2b9ca | ||
|
|
8c092c7453 | ||
|
|
6631fce15f | ||
|
|
7071142aad | ||
|
|
34586bca5a | ||
|
|
516638a6d7 | ||
|
|
d4c39a2ad9 | ||
|
|
d6288c175e | ||
|
|
08b785083a | ||
|
|
a7818f0f64 | ||
|
|
52642aa11a | ||
|
|
27c886f6b9 | ||
|
|
85eb5a7496 | ||
|
|
91c242ac04 | ||
|
|
8ff6c147f2 | ||
|
|
8b4bb5a078 | ||
|
|
9d260f9b0e | ||
|
|
59cd48f3de | ||
|
|
b11db20742 | ||
|
|
f186aa6896 | ||
|
|
2bedf000a8 | ||
|
|
3d6f4544f1 | ||
|
|
13deac9b58 | ||
|
|
21c60ef7ce | ||
|
|
83adbb2979 | ||
|
|
c614b679e1 | ||
|
|
10bcc69c80 | ||
|
|
9eb4368d6f | ||
|
|
783fd4b475 | ||
|
|
00efab8ad2 | ||
|
|
d73b3745bf | ||
|
|
ccd44c0cb2 | ||
|
|
9a0acca849 | ||
|
|
95f9658a7e | ||
|
|
0fa24ce313 | ||
|
|
28ad466aa8 | ||
|
|
7e9fc0f20b | ||
|
|
7f5689835b | ||
|
|
478e0a53d0 | ||
|
|
588cad8d91 | ||
|
|
1d3ab8d6bb | ||
|
|
e086aa1660 | ||
|
|
188a15a948 | ||
|
|
874660f52e | ||
|
|
29bd46d68d | ||
|
|
cb80e0ef51 | ||
|
|
ccef53a3d3 | ||
|
|
d201803259 | ||
|
|
74b206dc77 | ||
|
|
42cda2d2e0 | ||
|
|
c386b704b5 | ||
|
|
84be00b29f | ||
|
|
d064b589ae | ||
|
|
90edd12e43 | ||
|
|
c71bf3ccbe | ||
|
|
724b4de07e | ||
|
|
444b0a928d | ||
|
|
ec8fcbc02f | ||
|
|
68e2cd67d1 | ||
|
|
c21e1aba35 | ||
|
|
ec7f38d157 | ||
|
|
5b38483981 | ||
|
|
46312a2d15 | ||
|
|
8a240f7c46 | ||
|
|
17ca061cda |
No files matched your search
@@ -1,4 +0,0 @@
|
||||
*.pbxuser
|
||||
.DS_Store
|
||||
*.perspective*
|
||||
.svn
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
# Xcode
|
||||
build/*
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
*.xcworkspace
|
||||
!default.xcworkspace
|
||||
xcuserdata/
|
||||
profile
|
||||
*.moved-aside
|
||||
|
||||
## Ignore incredibly annoying .DS_Store files
|
||||
.DS_Store
|
||||
DerivedData/
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
# 1.6.1
|
||||
|
||||
* Removed archive password prompt (Kornel Lesiński)
|
||||
* (Re)fixes bug where URLs are naively double escaped (Andrew Madsen)
|
||||
* Fixed typo that caused crashes in BinaryDelta (Tamas Lustyik)
|
||||
* SUStandardVersionComparator.h is public (Vincent CARLIER)
|
||||
* Remove pre-10.6-specific code. (C.W. Betts)
|
||||
* Objective C 2 getters and setters. (C.W. Betts)
|
||||
* Define correct dependencies on locale scripts (Antonin Hildebrand)
|
||||
|
||||
# 1.6.0
|
||||
|
||||
* Cleaned up and deleted redundant strings files (Kornel Lesiński)
|
||||
* Modern Objective C syntax, properties where possible. (C.W. Betts)
|
||||
* Make SUAppcastDelegate a formal protocol. (C.W. Betts)
|
||||
* Fixed default font in release notes WebView (Kornel Lesiński)
|
||||
* Configurable name for finish_installation.app (Kornel Lesiński)
|
||||
* Removed code for 10.4 (Kornel Lesiński)
|
||||
* Convert all strings files to UTF-8 (UTF-16 must die) (Kornel Lesiński)
|
||||
* Removing GC target (Matt Thomas)
|
||||
* finish_installation.app and pkg files will not removed when we use *.pkg installer and restart system in the installer (Takayama Fumihiko)
|
||||
* Select Korean and Slovak for Sparkle.strings localization (Shon Frazier)
|
||||
* Updated the Romanian translation (Gabe)
|
||||
* pt-BR localization polishing (BR Lingo)
|
||||
* update zh_CN (61)
|
||||
* Shut up some warnings & make build with newer Xcode (Uli Kusterer)
|
||||
* Less unsafety with format strings (Uli Kusterer)
|
||||
* New icon (Rick Fillion)
|
||||
* fixed a 'content rectangle not entirely onscreen' warning (Simone Manganelli)
|
||||
* updated sends system profile to use info.plist if user defaults key isn't present (Jamie Pinkham)
|
||||
* Support for notifications on some updater events (Doug Russell)
|
||||
* Allow the delegate to trigger a silent install and relaunch (Matt Stevens)
|
||||
* Support silent relaunches (Matt Stevens)
|
||||
* Increment the sudden termination counter if installing on quit (Matt Stevens)
|
||||
* Prompts the user to update after a week (rather than a day) if he doesn't quit the app (Andy Matuschak)
|
||||
* Adding <sparkle:tags> appcast item element, <sparkle:criticalUpdate /> tag (Andy Matuschak)
|
||||
* We have this check box that says "Automatically download and install updates in the future." But we only download them automatically. We still ask permission again before installing them. (Andy Matuschak)
|
||||
@@ -0,0 +1,4 @@
|
||||
// BinaryDelta tool only
|
||||
|
||||
PRODUCT_NAME = BinaryDelta
|
||||
GCC_PREFIX_HEADER =
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "ConfigCommon.xcconfig"
|
||||
#include "ConfigCommonDebug.xcconfig"
|
||||
#include "ConfigBinaryDelta.xcconfig"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "ConfigCommon.xcconfig"
|
||||
#include "ConfigCommonRelease.xcconfig"
|
||||
#include "ConfigBinaryDelta.xcconfig"
|
||||
@@ -1,39 +1,29 @@
|
||||
// Common
|
||||
|
||||
PREBINDING = NO
|
||||
ZERO_LINK = NO
|
||||
CURRENT_PROJECT_VERSION = 1.5
|
||||
SDKROOT = $(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk
|
||||
MACOSX_DEPLOYMENT_TARGET[arch=ppc] = 10.3
|
||||
MACOSX_DEPLOYMENT_TARGET[arch=ppc64] = 10.5
|
||||
MACOSX_DEPLOYMENT_TARGET[arch=i386] = 10.4
|
||||
MACOSX_DEPLOYMENT_TARGET[arch=x86_64] = 10.5
|
||||
GCC_C_LANGUAGE_STANDARD = c99
|
||||
GCC_ENABLE_OBJC_EXCEPTIONS = YES
|
||||
GCC_DEBUGGING_SYMBOLS = full
|
||||
FINISH_INSTALL_TOOL_NAME = Autoupdate
|
||||
|
||||
CURRENT_PROJECT_VERSION = 1.6
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES
|
||||
GCC_PREFIX_HEADER = $(SDKROOT)/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h
|
||||
GCC_FAST_OBJC_DISPATCH = YES
|
||||
GCC_FAST_OBJC_DISPATCH[arch=ppc] = NO // requires 10.4
|
||||
ARCHS = i386 x86_64
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS = FINISH_INSTALL_TOOL_NAME=$(FINISH_INSTALL_TOOL_NAME)
|
||||
|
||||
// Enable warnings
|
||||
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES
|
||||
GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES
|
||||
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES
|
||||
GCC_WARN_SHADOW = YES
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES
|
||||
GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = YES
|
||||
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES
|
||||
GCC_WARN_MISSING_PARENTHESES = YES
|
||||
GCC_WARN_ABOUT_MISSING_NEWLINE = YES
|
||||
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES
|
||||
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES
|
||||
GCC_WARN_ABOUT_POINTER_SIGNEDNESS = YES
|
||||
GCC_WARN_SIGN_COMPARE = YES
|
||||
GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES
|
||||
GCC_WARN_UNKNOWN_PRAGMAS = YES
|
||||
GCC_WARN_UNUSED_VARIABLE = YES
|
||||
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES
|
||||
GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = YES
|
||||
WARNING_CFLAGS = -Wall
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES
|
||||
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES
|
||||
GCC_WARN_UNUSED_FUNCTION = YES
|
||||
GCC_WARN_UNUSED_LABEL = YES
|
||||
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES
|
||||
@@ -3,6 +3,6 @@
|
||||
GCC_OPTIMIZATION_LEVEL = 0
|
||||
DEBUG_INFORMATION_FORMAT = dwarf
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
||||
SPARKLE_EXTRA_DEBUG = -DDEBUG -fstack-protector -D_FORTIFY_SOURCE=2
|
||||
SPARKLE_EXTRA_DEBUG = -DDEBUG
|
||||
OTHER_CFLAGS = $(SPARKLE_EXTRA_DEBUG)
|
||||
ARCHS = $(NATIVE_ARCH_ACTUAL)
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
GCC_OPTIMIZATION_LEVEL = s
|
||||
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = NO
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
||||
DEAD_CODE_STRIPPING = YES
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = YES
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES
|
||||
ARCHS = ppc i386 x86_64
|
||||
@@ -5,7 +5,6 @@ DYLIB_COMPATIBILITY_VERSION = 1.5
|
||||
DYLIB_CURRENT_VERSION = 1.5
|
||||
PRODUCT_NAME = Sparkle
|
||||
WRAPPER_EXTENSION = framework
|
||||
OTHER_LDFLAGS = -lcrypto
|
||||
FRAMEWORK_VERSION = A
|
||||
INFOPLIST_FILE = Info.plist
|
||||
GCC_PREFIX_HEADER = Sparkle.pch
|
||||
@@ -2,4 +2,3 @@
|
||||
#include "ConfigCommonDebug.xcconfig"
|
||||
#include "ConfigFramework.xcconfig"
|
||||
|
||||
OTHER_CFLAGS = -fsingle-precision-constant -DDEBUG
|
||||
@@ -4,6 +4,3 @@
|
||||
|
||||
STRIP_INSTALLED_PRODUCT = YES
|
||||
DEPLOYMENT_POSTPROCESSING = YES
|
||||
STRIPFLAGS = -u -r
|
||||
STRIP_STYLE = non-global
|
||||
SEPARATE_STRIP = YES
|
||||
@@ -1,3 +0,0 @@
|
||||
#include "ConfigFrameworkRelease.xcconfig"
|
||||
|
||||
GCC_ENABLE_OBJC_GC = supported
|
||||
@@ -1,3 +1,4 @@
|
||||
// Relaunch Tool only
|
||||
|
||||
PRODUCT_NAME = relaunch
|
||||
PRODUCT_NAME = $(FINISH_INSTALL_TOOL_NAME)
|
||||
SKIP_INSTALL = YES
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "ConfigCommon.xcconfig"
|
||||
#include "ConfigCommonDebug.xcconfig"
|
||||
#include "ConfigRelaunch.xcconfig"
|
||||
|
||||
OTHER_CFLAGS = -fsingle-precision-constant -DDEBUG
|
||||
@@ -2,4 +2,3 @@
|
||||
#include "ConfigCommonDebug.xcconfig"
|
||||
#include "ConfigTestApp.xcconfig"
|
||||
|
||||
OTHER_CFLAGS = -fsingle-precision-constant -DDEBUG
|
||||
@@ -0,0 +1,9 @@
|
||||
// Unit Test only
|
||||
|
||||
INFOPLIST_FILE = Tests/Sparkle Unit Tests-Info.plist
|
||||
OTHER_LDFLAGS = -framework Cocoa -framework SenTestingKit
|
||||
PRODUCT_NAME = Sparkle Unit Tests
|
||||
WRAPPER_EXTENSION = octest
|
||||
FRAMEWORK_SEARCH_PATHS = $(DEVELOPER_LIBRARY_DIR)/Frameworks
|
||||
GCC_PREFIX_HEADER = $(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "ConfigCommon.xcconfig"
|
||||
#include "ConfigCommonDebug.xcconfig"
|
||||
#include "ConfigUnitTest.xcconfig"
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "ConfigCommon.xcconfig"
|
||||
#include "ConfigCommonRelease.xcconfig"
|
||||
#include "ConfigUnitTest.xcconfig"
|
||||
+5
-5
@@ -6,22 +6,22 @@
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.andymatuschak.Sparkle</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${CURRENT_PROJECT_VERSION} git</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.5</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.5 Beta (bzr)</string>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
|
||||
+32
-1
@@ -4,4 +4,35 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
=================
|
||||
EXTERNAL LICENSES
|
||||
=================
|
||||
|
||||
License for bspatch.c and bsdiff.c, from bsdiff 4.3 (<http://www.daemonology.net/bsdiff/>:
|
||||
/*-
|
||||
* Copyright 2003-2005 Colin Percival
|
||||
* All rights reserved
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted providing that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
+8
-1
@@ -11,6 +11,7 @@
|
||||
|
||||
@interface NTSynchronousTask : NSObject
|
||||
{
|
||||
@private
|
||||
NSTask *mv_task;
|
||||
NSPipe *mv_outputPipe;
|
||||
NSPipe *mv_inputPipe;
|
||||
@@ -19,10 +20,16 @@
|
||||
BOOL mv_done;
|
||||
int mv_result;
|
||||
}
|
||||
@property (readonly, retain) NSData *output;
|
||||
@property (readonly) int result;
|
||||
|
||||
// pass nil for directory if not needed
|
||||
// returns the result
|
||||
+ (NSData*)task:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input;
|
||||
+(int) task:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input output: (NSData**)outData;
|
||||
|
||||
+(NSData*)task:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input;
|
||||
|
||||
- (void)run:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+105
-176
@@ -6,44 +6,54 @@
|
||||
// Copyright 2005 Steve Gehrman. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Sparkle.h"
|
||||
#import "SUUpdater.h"
|
||||
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "NTSynchronousTask.h"
|
||||
|
||||
@interface NTSynchronousTask (Private)
|
||||
- (void)run:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input;
|
||||
|
||||
- (NSTask *)task;
|
||||
- (void)setTask:(NSTask *)theTask;
|
||||
|
||||
- (NSPipe *)outputPipe;
|
||||
- (void)setOutputPipe:(NSPipe *)theOutputPipe;
|
||||
|
||||
- (NSPipe *)inputPipe;
|
||||
- (void)setInputPipe:(NSPipe *)theInputPipe;
|
||||
|
||||
- (NSData *)output;
|
||||
- (void)setOutput:(NSData *)theOutput;
|
||||
|
||||
- (BOOL)done;
|
||||
- (void)setDone:(BOOL)flag;
|
||||
|
||||
- (int)result;
|
||||
- (void)setResult:(int)theResult;
|
||||
@interface NTSynchronousTask ()
|
||||
@property (retain) NSTask *task;
|
||||
@property (retain) NSPipe *outputPipe;
|
||||
@property (retain) NSPipe *inputPipe;
|
||||
@property (readwrite, retain) NSData *output;
|
||||
@property (getter = isDone) BOOL done;
|
||||
@property (readwrite) int result;
|
||||
@end
|
||||
|
||||
@implementation NTSynchronousTask
|
||||
@synthesize output = mv_output;
|
||||
@synthesize result = mv_result;
|
||||
@synthesize task = mv_task;
|
||||
@synthesize outputPipe = mv_outputPipe;
|
||||
@synthesize inputPipe = mv_inputPipe;
|
||||
@synthesize done = mv_done;
|
||||
|
||||
- (void)taskOutputAvailable:(NSNotification*)note
|
||||
{
|
||||
self.output = [[note userInfo] objectForKey:NSFileHandleNotificationDataItem];
|
||||
|
||||
self.done = YES;
|
||||
}
|
||||
|
||||
- (void)taskDidTerminate:(NSNotification*)note
|
||||
{
|
||||
self.result = [self.task terminationStatus];
|
||||
}
|
||||
|
||||
- (id)init;
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
[self setTask:[[[NSTask alloc] init] autorelease]];
|
||||
[self setOutputPipe:[[[NSPipe alloc] init] autorelease]];
|
||||
[self setInputPipe:[[[NSPipe alloc] init] autorelease]];
|
||||
self.task = [[[NSTask alloc] init] autorelease];
|
||||
self.outputPipe = [[[NSPipe alloc] init] autorelease];
|
||||
self.inputPipe = [[[NSPipe alloc] init] autorelease];
|
||||
|
||||
[[self task] setStandardInput:[self inputPipe]];
|
||||
[[self task] setStandardOutput:[self outputPipe]];
|
||||
self.task.standardInput = self.inputPipe;
|
||||
self.task.standardOutput = self.outputPipe;
|
||||
self.task.standardError = self.outputPipe;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -56,55 +66,23 @@
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
[self setTask:nil];
|
||||
[self setOutputPipe:nil];
|
||||
[self setInputPipe:nil];
|
||||
[self setOutput:nil];
|
||||
self.task = nil;
|
||||
self.outputPipe = nil;
|
||||
self.inputPipe = nil;
|
||||
self.output = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
+ (NSData*)task:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input;
|
||||
{
|
||||
// we need this wacky pool here, otherwise we run out of pipes, the pipes are internally autoreleased
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSData* result=nil;
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
NTSynchronousTask* task = [[NTSynchronousTask alloc] init];
|
||||
|
||||
[task run:toolPath directory:currentDirectory withArgs:args input:input];
|
||||
|
||||
if ([task result] == 0)
|
||||
result = [[task output] retain];
|
||||
|
||||
[task release];
|
||||
}
|
||||
NS_HANDLER;
|
||||
NS_ENDHANDLER;
|
||||
|
||||
[pool drain];
|
||||
|
||||
// retained above
|
||||
[result autorelease];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTSynchronousTask (Private)
|
||||
|
||||
- (void)run:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input;
|
||||
- (void)run:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input
|
||||
{
|
||||
BOOL success = NO;
|
||||
|
||||
if (currentDirectory)
|
||||
[[self task] setCurrentDirectoryPath: currentDirectory];
|
||||
self.task.currentDirectoryPath = currentDirectory;
|
||||
|
||||
[[self task] setLaunchPath:toolPath];
|
||||
[[self task] setArguments:args];
|
||||
self.task.launchPath = toolPath;
|
||||
self.task.arguments = args;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(taskOutputAvailable:)
|
||||
@@ -118,24 +96,24 @@
|
||||
|
||||
[[[self outputPipe] fileHandleForReading] readToEndOfFileInBackgroundAndNotifyForModes:[NSArray arrayWithObjects:NSDefaultRunLoopMode, NSModalPanelRunLoopMode, NSEventTrackingRunLoopMode, nil]];
|
||||
|
||||
NS_DURING
|
||||
[[self task] launch];
|
||||
@try
|
||||
{
|
||||
[self.task launch];
|
||||
success = YES;
|
||||
NS_HANDLER
|
||||
;
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
@catch (NSException *localException) { }
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (input)
|
||||
{
|
||||
// feed the running task our input
|
||||
[[[self inputPipe] fileHandleForWriting] writeData:input];
|
||||
[[[self inputPipe] fileHandleForWriting] closeFile];
|
||||
[[self.inputPipe fileHandleForWriting] writeData:input];
|
||||
[[self.inputPipe fileHandleForWriting] closeFile];
|
||||
}
|
||||
|
||||
// loop until we are done receiving the data
|
||||
if (![self done])
|
||||
if (!self.done)
|
||||
{
|
||||
double resolution = 1;
|
||||
BOOL isRunning;
|
||||
@@ -146,117 +124,68 @@
|
||||
|
||||
isRunning = [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
|
||||
beforeDate:next];
|
||||
} while (isRunning && ![self done]);
|
||||
} while (isRunning && !self.done);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// task
|
||||
//----------------------------------------------------------
|
||||
- (NSTask *)task
|
||||
+ (NSData*)task:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input
|
||||
{
|
||||
return mv_task;
|
||||
}
|
||||
|
||||
- (void)setTask:(NSTask *)theTask
|
||||
{
|
||||
if (mv_task != theTask) {
|
||||
[mv_task release];
|
||||
mv_task = [theTask retain];
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// outputPipe
|
||||
//----------------------------------------------------------
|
||||
- (NSPipe *)outputPipe
|
||||
{
|
||||
return mv_outputPipe;
|
||||
}
|
||||
|
||||
- (void)setOutputPipe:(NSPipe *)theOutputPipe
|
||||
{
|
||||
if (mv_outputPipe != theOutputPipe) {
|
||||
[mv_outputPipe release];
|
||||
mv_outputPipe = [theOutputPipe retain];
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// inputPipe
|
||||
//----------------------------------------------------------
|
||||
- (NSPipe *)inputPipe
|
||||
{
|
||||
return mv_inputPipe;
|
||||
}
|
||||
|
||||
- (void)setInputPipe:(NSPipe *)theInputPipe
|
||||
{
|
||||
if (mv_inputPipe != theInputPipe) {
|
||||
[mv_inputPipe release];
|
||||
mv_inputPipe = [theInputPipe retain];
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// output
|
||||
//----------------------------------------------------------
|
||||
- (NSData *)output
|
||||
{
|
||||
return mv_output;
|
||||
}
|
||||
|
||||
- (void)setOutput:(NSData *)theOutput
|
||||
{
|
||||
if (mv_output != theOutput) {
|
||||
[mv_output release];
|
||||
mv_output = [theOutput retain];
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// done
|
||||
//----------------------------------------------------------
|
||||
- (BOOL)done
|
||||
{
|
||||
return mv_done;
|
||||
}
|
||||
|
||||
- (void)setDone:(BOOL)flag
|
||||
{
|
||||
mv_done = flag;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// result
|
||||
//----------------------------------------------------------
|
||||
- (int)result
|
||||
{
|
||||
return mv_result;
|
||||
}
|
||||
|
||||
- (void)setResult:(int)theResult
|
||||
{
|
||||
mv_result = theResult;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTSynchronousTask (Notifications)
|
||||
|
||||
- (void)taskOutputAvailable:(NSNotification*)note
|
||||
{
|
||||
[self setOutput:[[note userInfo] objectForKey:NSFileHandleNotificationDataItem]];
|
||||
// we need this wacky pool here, otherwise we run out of pipes, the pipes are internally autoreleased
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSData* result = nil;
|
||||
|
||||
[self setDone:YES];
|
||||
@try
|
||||
{
|
||||
NTSynchronousTask* task = [[NTSynchronousTask alloc] init];
|
||||
|
||||
[task run:toolPath directory:currentDirectory withArgs:args input:input];
|
||||
|
||||
if ([task result] == 0)
|
||||
result = [[task output] retain];
|
||||
|
||||
[task release];
|
||||
}
|
||||
@catch (NSException *localException) { }
|
||||
|
||||
[pool drain];
|
||||
|
||||
// retained above
|
||||
[result autorelease];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)taskDidTerminate:(NSNotification*)note
|
||||
|
||||
+(int) task:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input output: (NSData**)outData
|
||||
{
|
||||
[self setResult:[[self task] terminationStatus]];
|
||||
// we need this wacky pool here, otherwise we run out of pipes, the pipes are internally autoreleased
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
int taskResult = 0;
|
||||
if( outData )
|
||||
*outData = nil;
|
||||
|
||||
@try {
|
||||
NTSynchronousTask* task = [[NTSynchronousTask alloc] init];
|
||||
|
||||
[task run:toolPath directory:currentDirectory withArgs:args input:input];
|
||||
|
||||
taskResult = [task result];
|
||||
if( outData )
|
||||
*outData = [[task output] retain];
|
||||
|
||||
[task release];
|
||||
} @catch (NSException *localException) {
|
||||
taskResult = errCppGeneral;
|
||||
}
|
||||
|
||||
[pool drain];
|
||||
|
||||
// retained above
|
||||
if( outData )
|
||||
[*outData autorelease];
|
||||
|
||||
return taskResult;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# Sparkle <img src="Sparkle.png" width=48 height=48 alt="">
|
||||
is an easy-to-use software update framework for Cocoa developers.
|
||||
|
||||
## This fork
|
||||
|
||||
* Up to date with 10.9 SDK and Xcode 5.1.
|
||||
* Merged bugfixes, security fixes and some features from multiple Sparkle forks.
|
||||
* Merged official Sparkle branch with truly automatic background updates (no UI at all) when user agreed to "Automatically download and install updates in the future."
|
||||
* Ability to mark updates as critical.
|
||||
* Progress and status notifications for the host app.
|
||||
* Name of finish_installation.app can be configured to match your app's name.
|
||||
|
||||
## Features
|
||||
|
||||
* True self-updating—no work required from the user.
|
||||
* Displays release notes to the user via WebKit.
|
||||
* Displays a detailed progress window to the user.
|
||||
* Supports authentication for installing in secure locations.
|
||||
* Really, really easy to install.
|
||||
* Uses appcasts for release information.
|
||||
* The user can choose to automatically download and install all updates.
|
||||
* Seamless integration—there's no mention of Sparkle; your icons and app name are used.
|
||||
* Supports DSA signatures for ultra-secure updates.
|
||||
* Sparkle requires no code in your app, so it's trivial to upgrade or remove the module.
|
||||
* Optionally sends user demographic information to the server when checking for updates.
|
||||
* Sparkle doesn't bug the user until second launch for better first impressions.
|
||||
* Sparkle can install .pkg files for more complicated products.
|
||||
* Supports bundles, preference panes, plugins, and other non-.app software.
|
||||
* Supports branches due to minimum OS version requirements.
|
||||
* Deep delegate support to make Sparkle work exactly as you need.
|
||||
+11
-7
@@ -9,23 +9,27 @@
|
||||
#ifndef SUAPPCAST_H
|
||||
#define SUAPPCAST_H
|
||||
|
||||
@protocol SUAppcastDelegate;
|
||||
|
||||
@class SUAppcastItem;
|
||||
@interface SUAppcast : NSObject {
|
||||
@interface SUAppcast : NSObject<NSURLDownloadDelegate>
|
||||
{
|
||||
@private
|
||||
NSArray *items;
|
||||
NSString *userAgentString;
|
||||
id delegate;
|
||||
NSMutableData *incrementalData;
|
||||
id<SUAppcastDelegate> delegate;
|
||||
NSString *downloadFilename;
|
||||
NSURLDownload *download;
|
||||
}
|
||||
@property (assign) id<SUAppcastDelegate> delegate;
|
||||
@property (copy) NSString *userAgentString;
|
||||
|
||||
- (void)fetchAppcastFromURL:(NSURL *)url;
|
||||
- (void)setDelegate:delegate;
|
||||
- (void)setUserAgentString:(NSString *)userAgentString;
|
||||
|
||||
- (NSArray *)items;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSObject (SUAppcastDelegate)
|
||||
@protocol SUAppcastDelegate <NSObject>
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)appcast;
|
||||
- (void)appcast:(SUAppcast *)appcast failedToLoadWithError:(NSError *)error;
|
||||
@end
|
||||
|
||||
+107
-59
@@ -6,53 +6,110 @@
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Sparkle.h"
|
||||
#import "SUAppcast.h"
|
||||
#import "SUUpdater.h"
|
||||
|
||||
@interface SUAppcast (Private)
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUAppcast.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
|
||||
@interface NSXMLElement (SUAppcastExtensions)
|
||||
- (NSDictionary *)attributesAsDictionary;
|
||||
@end
|
||||
|
||||
@implementation NSXMLElement (SUAppcastExtensions)
|
||||
- (NSDictionary *)attributesAsDictionary
|
||||
{
|
||||
NSEnumerator *attributeEnum = [[self attributes] objectEnumerator];
|
||||
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||
|
||||
for (NSXMLNode *attribute in attributeEnum) {
|
||||
[dictionary setObject:[attribute stringValue] forKey:[attribute name]];
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface SUAppcast () <NSURLDownloadDelegate>
|
||||
@property (copy) NSString *downloadFilename;
|
||||
@property (retain) NSURLDownload *download;
|
||||
@property (copy) NSArray *items;
|
||||
- (void)reportError:(NSError *)error;
|
||||
- (NSXMLNode *)bestNodeInNodes:(NSArray *)nodes;
|
||||
@end
|
||||
|
||||
@implementation SUAppcast
|
||||
@synthesize downloadFilename;
|
||||
@synthesize delegate;
|
||||
@synthesize userAgentString;
|
||||
@synthesize download;
|
||||
@synthesize items;
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[items release];
|
||||
self.items = nil;
|
||||
self.userAgentString = nil;
|
||||
self.downloadFilename = nil;
|
||||
self.download = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSArray *)items
|
||||
{
|
||||
return items;
|
||||
}
|
||||
|
||||
- (void)fetchAppcastFromURL:(NSURL *)url
|
||||
{
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
|
||||
if (userAgentString)
|
||||
[request setValue:userAgentString forHTTPHeaderField:@"User-Agent"];
|
||||
|
||||
incrementalData = [[NSMutableData alloc] init];
|
||||
NSURLConnection *connection = [NSURLConnection connectionWithRequest:request delegate:self];
|
||||
CFRetain(connection);
|
||||
self.download = [[[NSURLDownload alloc] initWithRequest:request delegate:self] autorelease];
|
||||
}
|
||||
|
||||
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
|
||||
- (void)download:(NSURLDownload *)aDownload decideDestinationWithSuggestedFilename:(NSString *)filename
|
||||
{
|
||||
[incrementalData appendData:data];
|
||||
NSString* destinationFilename = NSTemporaryDirectory();
|
||||
if (destinationFilename)
|
||||
{
|
||||
destinationFilename = [destinationFilename stringByAppendingPathComponent:filename];
|
||||
[download setDestination:destinationFilename allowOverwrite:NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
|
||||
- (void)download:(NSURLDownload *)aDownload didCreateDestination:(NSString *)path
|
||||
{
|
||||
CFRelease(connection);
|
||||
|
||||
self.downloadFilename = path;
|
||||
}
|
||||
|
||||
- (void)downloadDidFinish:(NSURLDownload *)aDownload
|
||||
{
|
||||
NSError *error = nil;
|
||||
NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:incrementalData options:0 error:&error];
|
||||
|
||||
NSXMLDocument *document = nil;
|
||||
BOOL failed = NO;
|
||||
NSArray *xmlItems = nil;
|
||||
NSMutableArray *appcastItems = [NSMutableArray array];
|
||||
|
||||
if (downloadFilename)
|
||||
{
|
||||
NSUInteger options = 0;
|
||||
if (NSAppKitVersionNumber < NSAppKitVersionNumber10_7) {
|
||||
// In order to avoid including external entities when parsing the appcast (a potential security vulnerability; see https://github.com/andymatuschak/Sparkle/issues/169), we ask NSXMLDocument to "tidy" the XML first. This happens to remove these external entities; it wouldn't be a future-proof approach, but it worked in these historical versions of OS X, and we have a more rigorous approach for 10.7+.
|
||||
options = NSXMLDocumentTidyXML;
|
||||
} else {
|
||||
// In 10.7 and later, there's a real option for the behavior we desire.
|
||||
options = NSXMLNodeLoadExternalEntitiesSameOriginOnly;
|
||||
}
|
||||
document = [[[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:downloadFilename] options:options error:&error] autorelease];
|
||||
|
||||
[[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:nil];
|
||||
self.downloadFilename = nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
failed = YES;
|
||||
}
|
||||
|
||||
if (nil == document)
|
||||
{
|
||||
failed = YES;
|
||||
@@ -97,20 +154,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
NSEnumerator *nameEnum = [nodesDict keyEnumerator];
|
||||
NSString *name;
|
||||
while ((name = [nameEnum nextObject]))
|
||||
for (NSString *name in nodesDict)
|
||||
{
|
||||
node = [self bestNodeInNodes:[nodesDict objectForKey:name]];
|
||||
if ([name isEqualToString:@"enclosure"])
|
||||
{
|
||||
// enclosure is flattened as a separate dictionary for some reason
|
||||
NSEnumerator *attributeEnum = [[(NSXMLElement *)node attributes] objectEnumerator];
|
||||
NSXMLNode *attribute;
|
||||
NSMutableDictionary *encDict = [NSMutableDictionary dictionary];
|
||||
|
||||
while ((attribute = [attributeEnum nextObject]))
|
||||
[encDict setObject:[attribute stringValue] forKey:[attribute name]];
|
||||
NSDictionary *encDict = [(NSXMLElement *)node attributesAsDictionary];
|
||||
[dict setObject:encDict forKey:@"enclosure"];
|
||||
|
||||
}
|
||||
@@ -121,35 +171,46 @@
|
||||
if (date)
|
||||
[dict setObject:date forKey:name];
|
||||
}
|
||||
else if (name != nil)
|
||||
{
|
||||
else if ([name isEqualToString:@"sparkle:deltas"])
|
||||
{
|
||||
NSMutableArray *deltas = [NSMutableArray array];
|
||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||
for (NSXMLNode *child in childEnum) {
|
||||
if ([[child name] isEqualToString:@"enclosure"])
|
||||
[deltas addObject:[(NSXMLElement *)child attributesAsDictionary]];
|
||||
}
|
||||
[dict setObject:deltas forKey:@"deltas"];
|
||||
}
|
||||
else if (name != nil)
|
||||
{
|
||||
// add all other values as strings
|
||||
[dict setObject:[[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] forKey:name];
|
||||
NSString *theValue = [[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
if (theValue != nil) {
|
||||
[dict setObject:theValue forKey:name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SUAppcastItem *anItem = [[SUAppcastItem alloc] initWithDictionary:dict];
|
||||
NSString *errString;
|
||||
SUAppcastItem *anItem = [[[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString] autorelease];
|
||||
if (anItem)
|
||||
{
|
||||
[appcastItems addObject:anItem];
|
||||
[anItem release];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Sparkle Updater: Failed to parse appcast item with appcast dictionary %@!", dict);
|
||||
SULog(@"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
|
||||
}
|
||||
[nodesDict removeAllObjects];
|
||||
[dict removeAllObjects];
|
||||
}
|
||||
}
|
||||
|
||||
[document release];
|
||||
|
||||
if ([appcastItems count])
|
||||
{
|
||||
NSSortDescriptor *sort = [[[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO] autorelease];
|
||||
[appcastItems sortUsingDescriptors:[NSArray arrayWithObject:sort]];
|
||||
items = [appcastItems copy];
|
||||
self.items = appcastItems;
|
||||
}
|
||||
|
||||
if (failed)
|
||||
@@ -162,14 +223,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError *)error
|
||||
- (void)download:(NSURLDownload *)aDownload didFailWithError:(NSError *)error
|
||||
{
|
||||
CFRelease(connection);
|
||||
if (downloadFilename)
|
||||
{
|
||||
[[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:nil];
|
||||
}
|
||||
self.downloadFilename = nil;
|
||||
|
||||
[self reportError:error];
|
||||
}
|
||||
|
||||
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse
|
||||
- (NSURLRequest *)download:(NSURLDownload *)aDownload willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse
|
||||
{
|
||||
return request;
|
||||
}
|
||||
@@ -190,15 +255,12 @@
|
||||
else if ([nodes count] == 0)
|
||||
return nil;
|
||||
|
||||
NSEnumerator *nodeEnum = [nodes objectEnumerator];
|
||||
NSXMLElement *node;
|
||||
NSMutableArray *languages = [NSMutableArray array];
|
||||
NSString *lang;
|
||||
NSInteger i;
|
||||
while ((node = [nodeEnum nextObject]))
|
||||
{
|
||||
NSUInteger i;
|
||||
for (NSXMLElement *node in nodes) {
|
||||
lang = [[node attributeForName:@"xml:lang"] stringValue];
|
||||
[languages addObject:(lang ?: @"")];
|
||||
[languages addObject:(lang ? lang : @"")];
|
||||
}
|
||||
lang = [[NSBundle preferredLocalizationsFromArray:languages] objectAtIndex:0];
|
||||
i = [languages indexOfObject:([languages containsObject:lang] ? lang : @"")];
|
||||
@@ -207,18 +269,4 @@
|
||||
return [nodes objectAtIndex:i];
|
||||
}
|
||||
|
||||
- (void)setUserAgentString:(NSString *)uas
|
||||
{
|
||||
if (uas != userAgentString)
|
||||
{
|
||||
[userAgentString release];
|
||||
userAgentString = [uas copy];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setDelegate:del
|
||||
{
|
||||
delegate = del;
|
||||
}
|
||||
|
||||
@end
|
||||
+28
-13
@@ -9,39 +9,54 @@
|
||||
#ifndef SUAPPCASTITEM_H
|
||||
#define SUAPPCASTITEM_H
|
||||
|
||||
@interface SUAppcastItem : NSObject {
|
||||
@interface SUAppcastItem : NSObject
|
||||
{
|
||||
@private
|
||||
NSString *title;
|
||||
NSDate *date;
|
||||
NSString *description;
|
||||
NSString *itemDescription;
|
||||
|
||||
NSURL *releaseNotesURL;
|
||||
|
||||
NSString *DSASignature;
|
||||
NSString *minimumSystemVersion;
|
||||
NSString *maximumSystemVersion;
|
||||
|
||||
NSURL *fileURL;
|
||||
NSString *versionString;
|
||||
NSString *displayVersionString;
|
||||
|
||||
|
||||
NSDictionary *deltaUpdates;
|
||||
|
||||
NSDictionary *propertiesDictionary;
|
||||
|
||||
NSURL *infoURL; // UK 2007-08-31
|
||||
}
|
||||
@property (copy, readonly) NSString *title;
|
||||
@property (copy, readonly) NSDate *date;
|
||||
@property (copy, readonly) NSString *itemDescription;
|
||||
@property (retain, readonly) NSURL *releaseNotesURL;
|
||||
@property (copy, readonly) NSString *DSASignature;
|
||||
@property (copy, readonly) NSString *minimumSystemVersion;
|
||||
@property (copy, readonly) NSString *maximumSystemVersion;
|
||||
@property (retain, readonly) NSURL *fileURL;
|
||||
@property (copy, readonly) NSString *versionString;
|
||||
@property (copy, readonly) NSString *displayVersionString;
|
||||
@property (copy, readonly) NSDictionary *deltaUpdates;
|
||||
@property (retain, readonly) NSURL *infoURL;
|
||||
|
||||
// Initializes with data from a dictionary provided by the RSS class.
|
||||
- initWithDictionary:(NSDictionary *)dict;
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict;
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString**)error;
|
||||
|
||||
- (NSString *)title;
|
||||
- (NSString *)versionString;
|
||||
- (NSString *)displayVersionString;
|
||||
- (NSDate *)date;
|
||||
- (NSString *)description;
|
||||
- (NSURL *)releaseNotesURL;
|
||||
- (NSURL *)fileURL;
|
||||
- (NSString *)DSASignature;
|
||||
- (NSString *)minimumSystemVersion;
|
||||
- (BOOL)isDeltaUpdate;
|
||||
- (BOOL)isCriticalUpdate;
|
||||
|
||||
// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.
|
||||
- (NSDictionary *)propertiesDictionary;
|
||||
|
||||
- (NSURL *)infoURL; // UK 2007-08-31
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
+139
-125
@@ -6,102 +6,59 @@
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Sparkle.h"
|
||||
#import "SUUpdater.h"
|
||||
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SULog.h"
|
||||
|
||||
@interface SUAppcastItem ()
|
||||
@property (copy, readwrite) NSString *title;
|
||||
@property (copy, readwrite) NSDate *date;
|
||||
@property (copy, readwrite) NSString *itemDescription;
|
||||
@property (retain, readwrite) NSURL *releaseNotesURL;
|
||||
@property (copy, readwrite) NSString *DSASignature;
|
||||
@property (copy, readwrite) NSString *minimumSystemVersion;
|
||||
@property (copy, readwrite) NSString *maximumSystemVersion;
|
||||
@property (retain, readwrite) NSURL *fileURL;
|
||||
@property (copy, readwrite) NSString *versionString;
|
||||
@property (copy, readwrite) NSString *displayVersionString;
|
||||
@property (copy, readwrite) NSDictionary *deltaUpdates;
|
||||
@property (retain, readwrite) NSURL *infoURL;
|
||||
@end
|
||||
|
||||
@implementation SUAppcastItem
|
||||
@synthesize date;
|
||||
@synthesize deltaUpdates;
|
||||
@synthesize displayVersionString;
|
||||
@synthesize DSASignature;
|
||||
@synthesize fileURL;
|
||||
@synthesize infoURL;
|
||||
@synthesize itemDescription;
|
||||
@synthesize maximumSystemVersion;
|
||||
@synthesize minimumSystemVersion;
|
||||
@synthesize releaseNotesURL;
|
||||
@synthesize title;
|
||||
@synthesize versionString;
|
||||
|
||||
// Attack of accessors!
|
||||
|
||||
- (NSString *)title { return [[title retain] autorelease]; }
|
||||
|
||||
- (void)setTitle:(NSString *)aTitle
|
||||
- (BOOL)isDeltaUpdate
|
||||
{
|
||||
if (title == aTitle) return;
|
||||
[title release];
|
||||
title = [aTitle copy];
|
||||
return [[propertiesDictionary objectForKey:@"enclosure"] objectForKey:@"sparkle:deltaFrom"] != nil;
|
||||
}
|
||||
|
||||
|
||||
- (NSDate *)date { return [[date retain] autorelease]; }
|
||||
|
||||
- (void)setDate:(NSDate *)aDate
|
||||
- (BOOL)isCriticalUpdate
|
||||
{
|
||||
if (date == aDate) return;
|
||||
[date release];
|
||||
date = [aDate copy];
|
||||
}
|
||||
|
||||
|
||||
- (NSString *)description { return [[description retain] autorelease]; }
|
||||
|
||||
- (void)setDescription:(NSString *)aDescription
|
||||
{
|
||||
if (description == aDescription) return;
|
||||
[description release];
|
||||
description = [aDescription copy];
|
||||
}
|
||||
|
||||
|
||||
- (NSURL *)releaseNotesURL { return [[releaseNotesURL retain] autorelease]; }
|
||||
|
||||
- (void)setReleaseNotesURL:(NSURL *)aReleaseNotesURL
|
||||
{
|
||||
if (releaseNotesURL == aReleaseNotesURL) return;
|
||||
[releaseNotesURL release];
|
||||
releaseNotesURL = [aReleaseNotesURL copy];
|
||||
}
|
||||
|
||||
|
||||
- (NSString *)DSASignature { return [[DSASignature retain] autorelease]; }
|
||||
|
||||
- (void)setDSASignature:(NSString *)aDSASignature
|
||||
{
|
||||
if (DSASignature == aDSASignature) return;
|
||||
[DSASignature release];
|
||||
DSASignature = [aDSASignature copy];
|
||||
}
|
||||
|
||||
|
||||
- (NSURL *)fileURL { return [[fileURL retain] autorelease]; }
|
||||
|
||||
- (void)setFileURL:(NSURL *)aFileURL
|
||||
{
|
||||
if (fileURL == aFileURL) return;
|
||||
[fileURL release];
|
||||
fileURL = [aFileURL copy];
|
||||
}
|
||||
|
||||
|
||||
- (NSString *)versionString { return [[versionString retain] autorelease]; }
|
||||
|
||||
- (void)setVersionString:(NSString *)s
|
||||
{
|
||||
if (versionString == s) return;
|
||||
[versionString release];
|
||||
versionString = [s copy];
|
||||
}
|
||||
|
||||
|
||||
- (NSString *)displayVersionString { return [[displayVersionString retain] autorelease]; }
|
||||
|
||||
- (void)setDisplayVersionString:(NSString *)s
|
||||
{
|
||||
if (displayVersionString == s) return;
|
||||
[displayVersionString release];
|
||||
displayVersionString = [s copy];
|
||||
}
|
||||
|
||||
|
||||
- (NSString *)minimumSystemVersion { return [[minimumSystemVersion retain] autorelease]; }
|
||||
- (void)setMinimumSystemVersion:(NSString *)systemVersionString
|
||||
{
|
||||
if (minimumSystemVersion == systemVersionString) return;
|
||||
[minimumSystemVersion release];
|
||||
minimumSystemVersion = [systemVersionString copy];
|
||||
return [[propertiesDictionary objectForKey:@"sparkle:tags"] containsObject:@"sparkle:criticalUpdate"];
|
||||
}
|
||||
|
||||
- initWithDictionary:(NSDictionary *)dict
|
||||
{
|
||||
return [self initWithDictionary:dict failureReason:nil];
|
||||
}
|
||||
|
||||
- initWithDictionary:(NSDictionary *)dict failureReason:(NSString**)error
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
@@ -117,7 +74,9 @@
|
||||
// The big caveat with this is that you can't have underscores in your version strings, as that'll confuse Sparkle.
|
||||
// Feel free to change the separator string to a hyphen or something more suited to your needs if you like.
|
||||
NSString *newVersion = [enclosure objectForKey:@"sparkle:version"];
|
||||
if (newVersion == nil) // no sparkle:version attribute
|
||||
if( newVersion == nil )
|
||||
newVersion = [dict objectForKey:@"sparkle:version"]; // UK 2007-08-31 Get version from the item, in case it's a download-less item (i.e. paid upgrade).
|
||||
if (newVersion == nil) // no sparkle:version attribute anywhere?
|
||||
{
|
||||
// Separate the url by underscores and take the last component, as that'll be closest to the end,
|
||||
// then we remove the extension. Hopefully, this will be the version.
|
||||
@@ -125,38 +84,91 @@
|
||||
if ([fileComponents count] > 1)
|
||||
newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
|
||||
}
|
||||
|
||||
if(!newVersion )
|
||||
{
|
||||
if (error)
|
||||
*error = @"Feed item lacks sparkle:version attribute, and version couldn't be deduced from file name (would have used last component of a file name like AppName_1.3.4.zip)";
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (enclosure == nil || [enclosure objectForKey:@"url"] == nil || newVersion == nil)
|
||||
{
|
||||
[self release];
|
||||
self = nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
propertiesDictionary = [[NSMutableDictionary alloc] initWithDictionary:dict];
|
||||
[self setTitle:[dict objectForKey:@"title"]];
|
||||
[self setDate:[dict objectForKey:@"pubDate"]];
|
||||
[self setDescription:[dict objectForKey:@"description"]];
|
||||
|
||||
[self setFileURL:[NSURL URLWithString:[[enclosure objectForKey:@"url"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
|
||||
[self setDSASignature:[enclosure objectForKey:@"sparkle:dsaSignature"]];
|
||||
|
||||
[self setVersionString:newVersion];
|
||||
[self setMinimumSystemVersion:[dict objectForKey:@"sparkle:minimumSystemVersion"]];
|
||||
|
||||
NSString *shortVersionString = [enclosure objectForKey:@"sparkle:shortVersionString"];
|
||||
if (shortVersionString)
|
||||
[self setDisplayVersionString:shortVersionString];
|
||||
else
|
||||
[self setDisplayVersionString:[self versionString]];
|
||||
|
||||
// Find the appropriate release notes URL.
|
||||
if ([dict objectForKey:@"sparkle:releaseNotesLink"])
|
||||
[self setReleaseNotesURL:[NSURL URLWithString:[dict objectForKey:@"sparkle:releaseNotesLink"]]];
|
||||
else if ([[self description] hasPrefix:@"http://"]) // if the description starts with http://, use that.
|
||||
[self setReleaseNotesURL:[NSURL URLWithString:[self description]]];
|
||||
else
|
||||
[self setReleaseNotesURL:nil];
|
||||
propertiesDictionary = [[NSMutableDictionary alloc] initWithDictionary:dict];
|
||||
self.title = [dict objectForKey:@"title"];
|
||||
self.date = [dict objectForKey:@"pubDate"];
|
||||
self.itemDescription = [dict objectForKey:@"description"];
|
||||
|
||||
NSString* theInfoURL = [dict objectForKey:@"link"];
|
||||
if( theInfoURL )
|
||||
{
|
||||
if( ![theInfoURL isKindOfClass: [NSString class]] )
|
||||
SULog(@"SUAppcastItem -initWithDictionary: Info URL is not of valid type.");
|
||||
else
|
||||
self.infoURL = [NSURL URLWithString:theInfoURL];
|
||||
}
|
||||
|
||||
// Need an info URL or an enclosure URL. Former to show "More Info"
|
||||
// page, latter to download & install:
|
||||
if( !enclosure && !theInfoURL )
|
||||
{
|
||||
if (error)
|
||||
*error = @"No enclosure in feed item";
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString* enclosureURLString = [enclosure objectForKey:@"url"];
|
||||
if( !enclosureURLString && !theInfoURL )
|
||||
{
|
||||
if (error)
|
||||
*error = @"Feed item's enclosure lacks URL";
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
if( enclosureURLString ) {
|
||||
NSString *fileURLString = [[enclosureURLString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
self.fileURL = [NSURL URLWithString:fileURLString];
|
||||
}
|
||||
if( enclosure )
|
||||
self.DSASignature = [enclosure objectForKey:@"sparkle:dsaSignature"];
|
||||
|
||||
self.versionString = newVersion;
|
||||
self.minimumSystemVersion = [dict objectForKey:@"sparkle:minimumSystemVersion"];
|
||||
self.maximumSystemVersion = [dict objectForKey:@"sparkle:maximumSystemVersion"];
|
||||
|
||||
NSString *shortVersionString = [enclosure objectForKey:@"sparkle:shortVersionString"];
|
||||
if (nil == shortVersionString)
|
||||
shortVersionString = [dict objectForKey:@"sparkle:shortVersionString"]; // fall back on the <item>
|
||||
|
||||
if (shortVersionString)
|
||||
self.displayVersionString = shortVersionString;
|
||||
else
|
||||
self.displayVersionString = [self versionString];
|
||||
|
||||
// Find the appropriate release notes URL.
|
||||
if ([dict objectForKey:@"sparkle:releaseNotesLink"])
|
||||
self.releaseNotesURL = [NSURL URLWithString:[dict objectForKey:@"sparkle:releaseNotesLink"]];
|
||||
else if ([self.itemDescription hasPrefix:@"http://"] || [self.itemDescription hasPrefix:@"https://"]) // if the description starts with http:// or https:// use that.
|
||||
self.releaseNotesURL = [NSURL URLWithString:self.itemDescription];
|
||||
else
|
||||
self.releaseNotesURL = nil;
|
||||
|
||||
if ([dict objectForKey:@"deltas"])
|
||||
{
|
||||
NSMutableDictionary *deltas = [NSMutableDictionary dictionary];
|
||||
NSArray *deltaDictionaries = [dict objectForKey:@"deltas"];
|
||||
for (NSDictionary *deltaDictionary in [deltaDictionaries objectEnumerator]) {
|
||||
NSMutableDictionary *fakeAppCastDict = [dict mutableCopy];
|
||||
[fakeAppCastDict removeObjectForKey:@"deltas"];
|
||||
[fakeAppCastDict setObject:deltaDictionary forKey:@"enclosure"];
|
||||
SUAppcastItem *deltaItem = [[[self class] alloc] initWithDictionary:fakeAppCastDict];
|
||||
[fakeAppCastDict release];
|
||||
|
||||
[deltas setObject:deltaItem forKey:[deltaDictionary objectForKey:@"sparkle:deltaFrom"]];
|
||||
[deltaItem release];
|
||||
}
|
||||
self.deltaUpdates = deltas;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
@@ -164,14 +176,16 @@
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self setTitle:nil];
|
||||
[self setDate:nil];
|
||||
[self setDescription:nil];
|
||||
[self setReleaseNotesURL:nil];
|
||||
[self setDSASignature:nil];
|
||||
[self setFileURL:nil];
|
||||
[self setVersionString:nil];
|
||||
[self setDisplayVersionString:nil];
|
||||
self.title = nil;
|
||||
self.date = nil;
|
||||
self.itemDescription = nil;
|
||||
self.releaseNotesURL = nil;
|
||||
self.DSASignature = nil;
|
||||
self.minimumSystemVersion = nil;
|
||||
self.fileURL = nil;
|
||||
self.versionString = nil;
|
||||
self.displayVersionString = nil;
|
||||
self.infoURL = nil;
|
||||
[propertiesDictionary release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#import "SUWindowController.h"
|
||||
|
||||
@protocol SUAutomaticUpdateAlertDelegateProtocol;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SUInstallNowChoice,
|
||||
@@ -21,18 +23,18 @@ typedef enum
|
||||
@class SUAppcastItem, SUHost;
|
||||
@interface SUAutomaticUpdateAlert : SUWindowController {
|
||||
SUAppcastItem *updateItem;
|
||||
id delegate;
|
||||
id<SUAutomaticUpdateAlertDelegateProtocol> delegate;
|
||||
SUHost *host;
|
||||
}
|
||||
|
||||
- (id)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)hostBundle delegate:delegate;
|
||||
- (id)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)hostBundle delegate:(id<SUAutomaticUpdateAlertDelegateProtocol>)delegate;
|
||||
- (IBAction)installNow:sender;
|
||||
- (IBAction)installLater:sender;
|
||||
- (IBAction)doNotInstall:sender;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSObject (SUAutomaticUpdateAlertDelegateProtocol)
|
||||
@protocol SUAutomaticUpdateAlertDelegateProtocol <NSObject>
|
||||
- (void)automaticUpdateAlert:(SUAutomaticUpdateAlert *)aua finishedWithChoice:(SUAutomaticInstallationChoice)choice;
|
||||
@end
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
@implementation SUAutomaticUpdateAlert
|
||||
|
||||
- (id)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost delegate:del;
|
||||
- (id)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost delegate:(id<SUAutomaticUpdateAlertDelegateProtocol>)del
|
||||
{
|
||||
self = [super initWithHost:aHost windowNibName:@"SUAutomaticUpdateAlert"];
|
||||
if (self)
|
||||
@@ -33,6 +33,7 @@
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; }
|
||||
|
||||
- (IBAction)installNow:sender
|
||||
{
|
||||
@@ -59,12 +60,26 @@
|
||||
|
||||
- (NSString *)titleText
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is ready to install!", nil), [host name]];
|
||||
if ([updateItem isCriticalUpdate])
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"An important update to %@ is ready to install", nil), [host name]];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is ready to install!", nil), [host name]];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)descriptionText
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?", nil), [host name], [host displayVersion]];
|
||||
if ([updateItem isCriticalUpdate])
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! This is an important update; would you like to install it and relaunch %1$@ now?", nil), [host name], [updateItem displayVersionString]];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?", nil), [host name], [updateItem displayVersionString]];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -11,11 +11,15 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUBasicUpdateDriver.h"
|
||||
#import "SUAutomaticUpdateAlert.h"
|
||||
|
||||
@class SUAutomaticUpdateAlert;
|
||||
@interface SUAutomaticUpdateDriver : SUBasicUpdateDriver {
|
||||
@interface SUAutomaticUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate, SUAutomaticUpdateAlertDelegateProtocol>
|
||||
{
|
||||
@private
|
||||
BOOL postponingInstallation, showErrors;
|
||||
BOOL willUpdateOnTermination;
|
||||
SUAutomaticUpdateAlert *alert;
|
||||
NSTimer *showUpdateAlertTimer;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+101
-13
@@ -10,18 +10,107 @@
|
||||
|
||||
#import "SUAutomaticUpdateAlert.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUConstants.h"
|
||||
|
||||
// If the user hasn't quit in a week, ask them if they want to relaunch to get the latest bits. It doesn't matter that this measure of "one day" is imprecise.
|
||||
static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 24 * 7;
|
||||
|
||||
@implementation SUAutomaticUpdateDriver
|
||||
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)ua
|
||||
- (void)showUpdateAlert
|
||||
{
|
||||
isInterruptible = NO;
|
||||
alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:updateItem host:host delegate:self];
|
||||
|
||||
// If the app is a menubar app or the like, we need to focus it first and alter the
|
||||
// update prompt to behave like a normal window. Otherwise if the window were hidden
|
||||
// there may be no way for the application to be activated to make it visible again.
|
||||
if ([host isBackgroundApplication])
|
||||
{
|
||||
[[alert window] setHidesOnDeactivate:NO];
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
if ([NSApp isActive])
|
||||
[[alert window] makeKeyAndOrderFront:self];
|
||||
else
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
}
|
||||
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)ua
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
|
||||
|
||||
// Sudden termination is available on 10.6+
|
||||
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
|
||||
[processInfo disableSuddenTermination];
|
||||
|
||||
willUpdateOnTermination = YES;
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationInvocation:)])
|
||||
{
|
||||
BOOL relaunch = YES;
|
||||
BOOL showUI = NO;
|
||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:displayingUserInterface:)]];
|
||||
[invocation setSelector:@selector(installWithToolAndRelaunch:displayingUserInterface:)];
|
||||
[invocation setArgument:&relaunch atIndex:2];
|
||||
[invocation setArgument:&showUI atIndex:3];
|
||||
[invocation setTarget:self];
|
||||
|
||||
[[updater delegate] updater:updater willInstallUpdateOnQuit:updateItem immediateInstallationInvocation:invocation];
|
||||
}
|
||||
|
||||
// If this is marked as a critical update, we'll prompt the user to install it right away.
|
||||
if ([updateItem isCriticalUpdate])
|
||||
{
|
||||
[self showUpdateAlert];
|
||||
}
|
||||
else
|
||||
{
|
||||
showUpdateAlertTimer = [[NSTimer scheduledTimerWithTimeInterval:SUAutomaticUpdatePromptImpatienceTimer target:self selector:@selector(showUpdateAlert) userInfo:nil repeats:NO] retain];
|
||||
|
||||
// At this point the driver is idle, allow it to be interrupted for user-initiated update checks.
|
||||
isInterruptible = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)stopUpdatingOnTermination
|
||||
{
|
||||
if (willUpdateOnTermination)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationWillTerminateNotification object:nil];
|
||||
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
|
||||
[processInfo enableSuddenTermination];
|
||||
|
||||
willUpdateOnTermination = NO;
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didCancelInstallUpdateOnQuit:)])
|
||||
[[updater delegate] updater:updater didCancelInstallUpdateOnQuit:updateItem];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)invalidateShowUpdateAlertTimer
|
||||
{
|
||||
[showUpdateAlertTimer invalidate];
|
||||
[showUpdateAlertTimer release];
|
||||
showUpdateAlertTimer = nil;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self stopUpdatingOnTermination];
|
||||
[self invalidateShowUpdateAlertTimer];
|
||||
[alert release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)abortUpdate
|
||||
{
|
||||
[self stopUpdatingOnTermination];
|
||||
[self invalidateShowUpdateAlertTimer];
|
||||
[super abortUpdate];
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)aNotification
|
||||
{
|
||||
[[alert window] makeKeyAndOrderFront:self];
|
||||
@@ -33,12 +122,15 @@
|
||||
switch (choice)
|
||||
{
|
||||
case SUInstallNowChoice:
|
||||
[self installUpdate];
|
||||
[self stopUpdatingOnTermination];
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
break;
|
||||
|
||||
case SUInstallLaterChoice:
|
||||
postponingInstallation = YES;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
|
||||
// We're already waiting on quit, just indicate that we're idle.
|
||||
isInterruptible = YES;
|
||||
break;
|
||||
|
||||
case SUDoNotInstallChoice:
|
||||
@@ -50,22 +142,18 @@
|
||||
|
||||
- (BOOL)shouldInstallSynchronously { return postponingInstallation; }
|
||||
|
||||
- (void)installUpdate
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
|
||||
{
|
||||
showErrors = YES;
|
||||
[super installUpdate];
|
||||
if (relaunch)
|
||||
[self stopUpdatingOnTermination];
|
||||
|
||||
showErrors = YES;
|
||||
[super installWithToolAndRelaunch:relaunch displayingUserInterface:showUI];
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(NSNotification *)note
|
||||
{
|
||||
[self installUpdate];
|
||||
}
|
||||
|
||||
- (void)installerFinishedForHost:(SUHost *)aHost
|
||||
{
|
||||
if (aHost != host) { return; }
|
||||
if (!postponingInstallation)
|
||||
[self relaunchHostApp];
|
||||
[self installWithToolAndRelaunch:NO];
|
||||
}
|
||||
|
||||
- (void)abortUpdateWithError:(NSError *)error
|
||||
|
||||
+11
-10
@@ -11,21 +11,22 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUUpdateDriver.h"
|
||||
#import "SUUnarchiver.h"
|
||||
#import "SUAppcast.h"
|
||||
|
||||
@class SUAppcastItem, SUUnarchiver, SUAppcast, SUUnarchiver, SUHost;
|
||||
@interface SUBasicUpdateDriver : SUUpdateDriver {
|
||||
@class SUAppcastItem, SUHost;
|
||||
@interface SUBasicUpdateDriver : SUUpdateDriver<NSURLDownloadDelegate, SUUnarchiverDelegate, SUAppcastDelegate> {
|
||||
SUAppcastItem *updateItem;
|
||||
SUAppcastItem *nonDeltaUpdateItem;
|
||||
|
||||
NSURLDownload *download;
|
||||
NSString *downloadPath;
|
||||
NSString *tempDir;
|
||||
|
||||
NSString *relaunchPath;
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)appcastURL host:(SUHost *)host;
|
||||
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)ac;
|
||||
- (void)appcast:(SUAppcast *)ac failedToLoadWithError:(NSError *)error;
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
|
||||
|
||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui;
|
||||
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
|
||||
@@ -42,13 +43,13 @@
|
||||
- (void)extractUpdate;
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)ua;
|
||||
- (void)unarchiverDidFail:(SUUnarchiver *)ua;
|
||||
- (void)failedToApplyDeltaUpdate;
|
||||
|
||||
- (void)installUpdate;
|
||||
- (void)installerFinishedForHost:(SUHost *)host;
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch;
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI;
|
||||
- (void)installerForHost:(SUHost *)host failedWithError:(NSError *)error;
|
||||
|
||||
- (void)relaunchHostApp;
|
||||
- (void)cleanUp;
|
||||
- (void)cleanUpDownload;
|
||||
|
||||
- (void)abortUpdate;
|
||||
- (void)abortUpdateWithError:(NSError *)error;
|
||||
|
||||
+211
-106
@@ -13,12 +13,28 @@
|
||||
#import "SUInstaller.h"
|
||||
#import "SUStandardVersionComparator.h"
|
||||
#import "SUUnarchiver.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
#import "SUPlainInstaller.h"
|
||||
#import "SUPlainInstallerInternals.h"
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SUUpdater_Private.h"
|
||||
|
||||
#ifdef FINISH_INSTALL_TOOL_NAME
|
||||
// FINISH_INSTALL_TOOL_NAME expands to unquoted finish_install
|
||||
#define QUOTE_NS_STRING2(str) @"" #str
|
||||
#define QUOTE_NS_STRING1(str) QUOTE_NS_STRING2(str)
|
||||
#define FINISH_INSTALL_TOOL_NAME_STRING QUOTE_NS_STRING1(FINISH_INSTALL_TOOL_NAME)
|
||||
#else
|
||||
#error FINISH_INSTALL_TOOL_NAME not defined
|
||||
#endif
|
||||
|
||||
@implementation SUBasicUpdateDriver
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)appcastURL host:(SUHost *)aHost
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
|
||||
{
|
||||
[super checkForUpdatesAtURL:appcastURL host:aHost];
|
||||
[super checkForUpdatesAtURL:URL host:aHost];
|
||||
if ([aHost isRunningOnReadOnlyVolume])
|
||||
{
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again.", nil), [aHost name]] forKey:NSLocalizedDescriptionKey]]];
|
||||
@@ -30,15 +46,11 @@
|
||||
[appcast release];
|
||||
|
||||
[appcast setDelegate:self];
|
||||
NSString *userAgent = [NSString stringWithFormat: @"%@/%@ Sparkle/%@", [aHost name], [aHost displayVersion], ([SPARKLE_BUNDLE objectForInfoDictionaryKey:@"CFBundleVersion"] ?: nil)];
|
||||
NSData * cleanedAgent = [userAgent dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
|
||||
userAgent = [NSString stringWithCString:[cleanedAgent bytes] length:[cleanedAgent length]];
|
||||
[appcast setUserAgentString:userAgent];
|
||||
[appcast fetchAppcastFromURL:appcastURL];
|
||||
[host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey];
|
||||
[appcast setUserAgentString:[updater userAgentString]];
|
||||
[appcast fetchAppcastFromURL:URL];
|
||||
}
|
||||
|
||||
- (id <SUVersionComparison>)_versionComparator
|
||||
- (id <SUVersionComparison>)versionComparator
|
||||
{
|
||||
id <SUVersionComparison> comparator = nil;
|
||||
|
||||
@@ -55,20 +67,33 @@
|
||||
|
||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui
|
||||
{
|
||||
return [[self _versionComparator] compareVersion:[host version] toVersion:[ui versionString]] == NSOrderedAscending;
|
||||
return [[self versionComparator] compareVersion:[host version] toVersion:[ui versionString]] == NSOrderedAscending;
|
||||
}
|
||||
|
||||
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui
|
||||
{
|
||||
if ([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) { return YES; }
|
||||
return [[SUStandardVersionComparator defaultComparator] compareVersion:[ui minimumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedDescending;
|
||||
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
|
||||
([ui maximumSystemVersion] == nil || [[ui maximumSystemVersion] isEqualToString:@""])) { return YES; }
|
||||
|
||||
BOOL minimumVersionOK = TRUE;
|
||||
BOOL maximumVersionOK = TRUE;
|
||||
|
||||
// Check minimum and maximum System Version
|
||||
if ([ui minimumSystemVersion] != nil && ![[ui minimumSystemVersion] isEqualToString:@""]) {
|
||||
minimumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui minimumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedDescending;
|
||||
}
|
||||
if ([ui maximumSystemVersion] != nil && ![[ui maximumSystemVersion] isEqualToString:@""]) {
|
||||
maximumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui maximumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedAscending;
|
||||
}
|
||||
|
||||
return minimumVersionOK && maximumVersionOK;
|
||||
}
|
||||
|
||||
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
|
||||
{
|
||||
NSString *skippedVersion = [host objectForUserDefaultsKey:SUSkippedVersionKey];
|
||||
if (skippedVersion == nil) { return NO; }
|
||||
return [[self _versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending;
|
||||
return [[self versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending;
|
||||
}
|
||||
|
||||
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
|
||||
@@ -80,23 +105,36 @@
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)])
|
||||
[[updater delegate] updater:updater didFinishLoadingAppcast:ac];
|
||||
|
||||
|
||||
NSDictionary *userInfo = (ac != nil) ? @{SUUpdaterAppcastNotificationKey : ac} : nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFinishLoadingAppCastNotification object:updater userInfo:userInfo];
|
||||
|
||||
SUAppcastItem *item = nil;
|
||||
|
||||
// Now we have to find the best valid update in the appcast.
|
||||
if ([[updater delegate] respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it?
|
||||
{
|
||||
updateItem = [[updater delegate] bestValidUpdateInAppcast:ac forUpdater:updater];
|
||||
item = [[updater delegate] bestValidUpdateInAppcast:ac forUpdater:updater];
|
||||
}
|
||||
else // If not, we'll take care of it ourselves.
|
||||
{
|
||||
// Find the first update we can actually use.
|
||||
NSEnumerator *updateEnumerator = [[ac items] objectEnumerator];
|
||||
do {
|
||||
updateItem = [updateEnumerator nextObject];
|
||||
} while (updateItem && ![self hostSupportsItem:updateItem]);
|
||||
|
||||
[updateItem retain];
|
||||
item = [updateEnumerator nextObject];
|
||||
} while (item && ![self hostSupportsItem:item]);
|
||||
|
||||
if (binaryDeltaSupported()) {
|
||||
SUAppcastItem *deltaUpdateItem = [[item deltaUpdates] objectForKey:[host version]];
|
||||
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
|
||||
nonDeltaUpdateItem = [item retain];
|
||||
item = deltaUpdateItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
CFRelease(ac); // Remember that we're explicitly managing the memory of the appcast.
|
||||
|
||||
updateItem = [item retain];
|
||||
if (ac) { CFRelease(ac); } // Remember that we're explicitly managing the memory of the appcast.
|
||||
if (updateItem == nil) { [self didNotFindUpdate]; return; }
|
||||
|
||||
if ([self itemContainsValidUpdate:updateItem])
|
||||
@@ -107,7 +145,7 @@
|
||||
|
||||
- (void)appcast:(SUAppcast *)ac failedToLoadWithError:(NSError *)error
|
||||
{
|
||||
CFRelease(ac); // Remember that we're explicitly managing the memory of the appcast.
|
||||
if (ac) { CFRelease(ac); } // Remember that we're explicitly managing the memory of the appcast.
|
||||
[self abortUpdateWithError:error];
|
||||
}
|
||||
|
||||
@@ -115,6 +153,8 @@
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)])
|
||||
[[updater delegate] updater:updater didFindValidUpdate:updateItem];
|
||||
NSDictionary *userInfo = (updateItem != nil) ? @{SUUpdaterAppcastItemNotificationKey : updateItem} : nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFinishLoadingAppCastNotification object:updater userInfo:userInfo];
|
||||
[self downloadUpdate];
|
||||
}
|
||||
|
||||
@@ -122,49 +162,68 @@
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)])
|
||||
[[updater delegate] updaterDidNotFindUpdate:updater];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
|
||||
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUNoUpdateError userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:SULocalizedString(@"You already have the newest version of %@.", nil), [host name]] forKey:NSLocalizedDescriptionKey]]];
|
||||
}
|
||||
|
||||
- (void)downloadUpdate
|
||||
{
|
||||
download = [[NSURLDownload alloc] initWithRequest:[NSURLRequest requestWithURL:[updateItem fileURL]] delegate:self];
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[updateItem fileURL]];
|
||||
[request setValue:[updater userAgentString] forHTTPHeaderField:@"User-Agent"];
|
||||
download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *)d decideDestinationWithSuggestedFilename:(NSString *)name
|
||||
{
|
||||
// If name ends in .txt, the server probably has a stupid MIME configuration. We'll give the developer the benefit of the doubt and chop that off.
|
||||
if ([[name pathExtension] isEqualToString:@"txt"])
|
||||
name = [name stringByDeletingPathExtension];
|
||||
|
||||
// We create a temporary directory in /tmp and stick the file there.
|
||||
// Not using a GUID here because hdiutil for some reason chokes on GUIDs. Too long? I really have no idea.
|
||||
NSString *prefix = [NSString stringWithFormat:@"%@ %@ Update", [host name], [host version]];
|
||||
NSString *tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:prefix];
|
||||
NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [host name], [updateItem versionString]];
|
||||
|
||||
|
||||
[tempDir release];
|
||||
tempDir = [[[host appSupportPath] stringByAppendingPathComponent:downloadFileName] retain];
|
||||
int cnt=1;
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999999)
|
||||
tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", prefix, cnt++]];
|
||||
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:tempDir attributes:nil];
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999)
|
||||
{
|
||||
[tempDir release];
|
||||
tempDir = [[[host appSupportPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]] retain];
|
||||
}
|
||||
|
||||
// Create the temporary directory if necessary.
|
||||
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||
if (!success)
|
||||
{
|
||||
// Okay, something's really broken with /tmp
|
||||
// Okay, something's really broken with this user's file structure.
|
||||
[download cancel];
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.",tempDir] forKey:NSLocalizedDescriptionKey]]];
|
||||
}
|
||||
|
||||
|
||||
downloadPath = [[tempDir stringByAppendingPathComponent:name] retain];
|
||||
[download setDestination:downloadPath allowOverwrite:YES];
|
||||
}
|
||||
|
||||
- (void)downloadDidFinish:(NSURLDownload *)d
|
||||
- (BOOL)validateUpdateDownloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature publicDSAKey:(NSString *)publicDSAKey
|
||||
{
|
||||
NSString *newBundlePath = [SUInstaller appPathInUpdateFolder:extractedPath forHost:host];
|
||||
if (newBundlePath)
|
||||
{
|
||||
NSError *error = nil;
|
||||
if ([SUCodeSigningVerifier codeSignatureIsValidAtPath:newBundlePath error:&error]) {
|
||||
return YES;
|
||||
} else {
|
||||
SULog(@"Code signature check on update failed: %@", error);
|
||||
}
|
||||
}
|
||||
|
||||
return [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
|
||||
}
|
||||
|
||||
- (void)downloadDidFinish:(NSURLDownload *)d
|
||||
{
|
||||
[self extractUpdate];
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error
|
||||
{
|
||||
// Get rid of what we've downloaded so far, if anything.
|
||||
if (downloadPath != nil)
|
||||
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[downloadPath stringByDeletingLastPathComponent] destination:@"" files:[NSArray arrayWithObject:[downloadPath lastPathComponent]] tag:NULL];
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil), NSLocalizedDescriptionKey, [error localizedDescription], NSLocalizedFailureReasonErrorKey, nil]]];
|
||||
}
|
||||
|
||||
@@ -176,21 +235,11 @@
|
||||
}
|
||||
|
||||
- (void)extractUpdate
|
||||
{
|
||||
// DSA verification, if activated by the developer
|
||||
if ([[host objectForInfoDictionaryKey:SUExpectsDSASignatureKey] boolValue])
|
||||
{
|
||||
if (![SUDSAVerifier validatePath:downloadPath withEncodedDSASignature:[updateItem DSASignature] withPublicDSAKey:[host publicDSAKey]])
|
||||
{
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSignatureError userInfo:[NSDictionary dictionaryWithObject:@"The update is improperly signed." forKey:NSLocalizedDescriptionKey]]];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:downloadPath];
|
||||
{
|
||||
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:downloadPath updatingHost:host];
|
||||
if (!unarchiver)
|
||||
{
|
||||
NSLog(@"Sparkle Error: No valid unarchiver for %@!", downloadPath);
|
||||
SULog(@"Sparkle Error: No valid unarchiver for %@!", downloadPath);
|
||||
[self unarchiverDidFail:nil];
|
||||
return;
|
||||
}
|
||||
@@ -199,91 +248,145 @@
|
||||
[unarchiver start];
|
||||
}
|
||||
|
||||
- (void)failedToApplyDeltaUpdate
|
||||
{
|
||||
// When a delta update fails to apply we fall back on updating via a full install.
|
||||
[updateItem release];
|
||||
updateItem = nonDeltaUpdateItem;
|
||||
nonDeltaUpdateItem = nil;
|
||||
|
||||
[self downloadUpdate];
|
||||
}
|
||||
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)ua
|
||||
{
|
||||
if (ua) { CFRelease(ua); }
|
||||
[self installUpdate];
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
}
|
||||
|
||||
- (void)unarchiverDidFail:(SUUnarchiver *)ua
|
||||
{
|
||||
if (ua) { CFRelease(ua); }
|
||||
|
||||
if ([updateItem isDeltaUpdate]) {
|
||||
[self failedToApplyDeltaUpdate];
|
||||
return;
|
||||
}
|
||||
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:[NSDictionary dictionaryWithObject:SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil) forKey:NSLocalizedDescriptionKey]]];
|
||||
}
|
||||
|
||||
- (BOOL)shouldInstallSynchronously { return NO; }
|
||||
|
||||
- (void)installUpdate
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch
|
||||
{
|
||||
// Perhaps a poor assumption but: if we're not relaunching, we assume we shouldn't be showing any UI either. Because non-relaunching installations are kicked off without any user interaction, we shouldn't be interrupting them.
|
||||
[self installWithToolAndRelaunch:relaunch displayingUserInterface:relaunch];
|
||||
}
|
||||
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
|
||||
{
|
||||
#if !ENDANGER_USERS_WITH_INSECURE_UPDATES
|
||||
if (![self validateUpdateDownloadedToPath:downloadPath extractedToPath:tempDir DSASignature:[updateItem DSASignature] publicDSAKey:[host publicDSAKey]])
|
||||
{
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSignatureError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil), NSLocalizedDescriptionKey, @"The update is improperly signed.", NSLocalizedFailureReasonErrorKey, nil]]];
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (![updater mayUpdateAndRestart])
|
||||
{
|
||||
[self abortUpdate];
|
||||
return;
|
||||
}
|
||||
|
||||
// Give the host app an opportunity to postpone the install and relaunch.
|
||||
static BOOL postponedOnce = NO;
|
||||
if (!postponedOnce && [[updater delegate] respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
|
||||
{
|
||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
|
||||
[invocation setSelector:@selector(installWithToolAndRelaunch:)];
|
||||
[invocation setArgument:&relaunch atIndex:2];
|
||||
[invocation setTarget:self];
|
||||
postponedOnce = YES;
|
||||
if ([[updater delegate] updater:updater shouldPostponeRelaunchForUpdate:updateItem untilInvoking:invocation])
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:willInstallUpdate:)])
|
||||
[[updater delegate] updater:updater willInstallUpdate:updateItem];
|
||||
|
||||
NSString *const finishInstallToolName = FINISH_INSTALL_TOOL_NAME_STRING;
|
||||
|
||||
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
|
||||
NSString *relaunchPathToCopy = [[NSBundle bundleForClass:[self class]] pathForResource:@"relaunch" ofType:@""];
|
||||
NSString *targetPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
|
||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems
|
||||
[[NSFileManager defaultManager] removeFileAtPath:targetPath handler:nil];
|
||||
if ([[NSFileManager defaultManager] copyPath:relaunchPathToCopy toPath:targetPath handler:nil])
|
||||
relaunchPath = [targetPath retain];
|
||||
|
||||
[SUInstaller installFromUpdateFolder:[downloadPath stringByDeletingLastPathComponent] overHost:host delegate:self synchronously:[self shouldInstallSynchronously]];
|
||||
}
|
||||
|
||||
- (void)installerFinishedForHost:(SUHost *)aHost
|
||||
{
|
||||
if (aHost != host) { return; }
|
||||
[self relaunchHostApp];
|
||||
}
|
||||
|
||||
- (void)relaunchHostApp
|
||||
{
|
||||
// Give the host app an opportunity to postpone the relaunch.
|
||||
static BOOL postponedOnce = NO;
|
||||
if (!postponedOnce && [[updater delegate] respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
|
||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
||||
NSString *relaunchPathToCopy = [SPARKLE_BUNDLE pathForResource:finishInstallToolName ofType:@"app"];
|
||||
if (relaunchPathToCopy != nil)
|
||||
{
|
||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[[self class] instanceMethodSignatureForSelector:@selector(relaunchHostApp)] retain]];
|
||||
[invocation setSelector:@selector(relaunchHostApp)];
|
||||
[invocation setTarget:self];
|
||||
postponedOnce = YES;
|
||||
if ([[updater delegate] updater:updater shouldPostponeRelaunchForUpdate:updateItem untilInvoking:invocation])
|
||||
return;
|
||||
NSString *targetPath = [[host appSupportPath] stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
|
||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
||||
NSError *error = nil;
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath: [targetPath stringByDeletingLastPathComponent] withIntermediateDirectories: YES attributes: [NSDictionary dictionary] error: &error];
|
||||
|
||||
if( [SUPlainInstaller copyPathWithAuthentication: relaunchPathToCopy overPath: targetPath temporaryName: nil error: &error] )
|
||||
relaunchPath = [targetPath retain];
|
||||
else
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil), NSLocalizedDescriptionKey, [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@", relaunchPathToCopy, targetPath, (error ? [error localizedDescription] : @"")], NSLocalizedFailureReasonErrorKey, nil]]];
|
||||
}
|
||||
|
||||
[self cleanUp]; // Clean up the download and extracted files.
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterWillRelaunchApplication)])
|
||||
[[updater delegate] updaterWillRelaunchApplication:updater];
|
||||
|
||||
if(!relaunchPath || ![[NSFileManager defaultManager] fileExistsAtPath:relaunchPath])
|
||||
{
|
||||
// Note that we explicitly use the host app's name here, since updating plugin for Mail relaunches Mail, not just the plugin.
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [host name]], NSLocalizedDescriptionKey, [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", relaunchPath], NSLocalizedFailureReasonErrorKey, nil]]];
|
||||
// We intentionally don't abandon the update here so that the host won't initiate another.
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *pathToRelaunch = [host bundlePath];
|
||||
if ([[updater delegate] respondsToSelector:@selector(pathToRelaunchForUpdater:)])
|
||||
pathToRelaunch = [[updater delegate] pathToRelaunchForUpdater:updater];
|
||||
[NSTask launchedTaskWithLaunchPath:relaunchPath arguments:[NSArray arrayWithObjects:pathToRelaunch, [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], nil]];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterWillRelaunchApplication:)])
|
||||
[[updater delegate] updaterWillRelaunchApplication:updater];
|
||||
|
||||
[NSApp terminate:self];
|
||||
if(!relaunchPath || ![[NSFileManager defaultManager] fileExistsAtPath:relaunchPath])
|
||||
{
|
||||
// Note that we explicitly use the host app's name here, since updating plugin for Mail relaunches Mail, not just the plugin.
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [host name]], NSLocalizedDescriptionKey, [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", relaunchPath], NSLocalizedFailureReasonErrorKey, nil]]];
|
||||
// We intentionally don't abandon the update here so that the host won't initiate another.
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *pathToRelaunch = [host bundlePath];
|
||||
if ([[updater delegate] respondsToSelector:@selector(pathToRelaunchForUpdater:)])
|
||||
pathToRelaunch = [[updater delegate] pathToRelaunchForUpdater:updater];
|
||||
NSString *relaunchToolPath = [[relaunchPath stringByAppendingPathComponent: @"/Contents/MacOS"] stringByAppendingPathComponent: finishInstallToolName];
|
||||
[NSTask launchedTaskWithLaunchPath: relaunchToolPath arguments:[NSArray arrayWithObjects:
|
||||
[host bundlePath],
|
||||
pathToRelaunch,
|
||||
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
|
||||
tempDir,
|
||||
relaunch ? @"1" : @"0",
|
||||
showUI ? @"1" : @"0",
|
||||
nil]];
|
||||
|
||||
[NSApp terminate:self];
|
||||
}
|
||||
|
||||
- (void)cleanUp
|
||||
- (void)cleanUpDownload
|
||||
{
|
||||
[[NSFileManager defaultManager] removeFileAtPath:[downloadPath stringByDeletingLastPathComponent] handler:nil];
|
||||
if (tempDir != nil) // tempDir contains downloadPath, so we implicitly delete both here.
|
||||
{
|
||||
BOOL success = NO;
|
||||
NSError * error = nil;
|
||||
success = [[NSFileManager defaultManager] removeItemAtPath: tempDir error: &error]; // Clean up the copied relauncher
|
||||
if( !success )
|
||||
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[tempDir stringByDeletingLastPathComponent] destination:@"" files:[NSArray arrayWithObject:[tempDir lastPathComponent]] tag:NULL];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)installerForHost:(SUHost *)aHost failedWithError:(NSError *)error
|
||||
{
|
||||
if (aHost != host) { return; }
|
||||
[[NSFileManager defaultManager] removeFileAtPath:relaunchPath handler:NULL]; // Clean up the copied relauncher.
|
||||
NSError * dontThrow = nil;
|
||||
[[NSFileManager defaultManager] removeItemAtPath: relaunchPath error: &dontThrow]; // Clean up the copied relauncher
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:SULocalizedString(@"An error occurred while installing the update. Please try again later.", nil), NSLocalizedDescriptionKey, [error localizedDescription], NSLocalizedFailureReasonErrorKey, nil]]];
|
||||
}
|
||||
|
||||
- (void)abortUpdate
|
||||
{
|
||||
[[self retain] autorelease]; // In case the notification center was the last one holding on to us.
|
||||
[self cleanUpDownload];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[super abortUpdate];
|
||||
}
|
||||
@@ -291,9 +394,9 @@
|
||||
- (void)abortUpdateWithError:(NSError *)error
|
||||
{
|
||||
if ([error code] != SUNoUpdateError) // Let's not bother logging this.
|
||||
NSLog(@"Sparkle Error: %@", [error localizedDescription]);
|
||||
SULog(@"Sparkle Error: %@", [error localizedDescription]);
|
||||
if ([error localizedFailureReason])
|
||||
NSLog(@"Sparkle Error (continued): %@", [error localizedFailureReason]);
|
||||
SULog(@"Sparkle Error (continued): %@", [error localizedFailureReason]);
|
||||
if (download)
|
||||
[download cancel];
|
||||
[self abortUpdate];
|
||||
@@ -301,9 +404,11 @@
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[host release];
|
||||
[updateItem release];
|
||||
[nonDeltaUpdateItem release];
|
||||
[download release];
|
||||
[downloadPath release];
|
||||
[tempDir release];
|
||||
[relaunchPath release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// SUBinaryDeltaApply.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mark Rowe on 2009-06-01.
|
||||
// Copyright 2009 Mark Rowe. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUBINARYDELTAAPPLY_H
|
||||
#define SUBINARYDELTAAPPLY_H
|
||||
|
||||
@class NSString;
|
||||
int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,101 @@
|
||||
//
|
||||
// SUBinaryDeltaApply.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mark Rowe on 2009-06-01.
|
||||
// Copyright 2009 Mark Rowe. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUBinaryDeltaApply.h"
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#include <bspatch.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <xar/xar.h>
|
||||
|
||||
static void applyBinaryDeltaToFile(xar_t x, xar_file_t file, NSString *sourceFilePath, NSString *destinationFilePath)
|
||||
{
|
||||
NSString *patchFile = temporaryFilename(@"apply-binary-delta");
|
||||
xar_extract_tofile(x, file, [patchFile fileSystemRepresentation]);
|
||||
const char *argv[] = {"/usr/bin/bspatch", [sourceFilePath fileSystemRepresentation], [destinationFilePath fileSystemRepresentation], [patchFile fileSystemRepresentation]};
|
||||
bspatch(4, (char **)argv);
|
||||
unlink([patchFile fileSystemRepresentation]);
|
||||
}
|
||||
|
||||
int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile)
|
||||
{
|
||||
xar_t x = xar_open([patchFile UTF8String], READ);
|
||||
if (!x) {
|
||||
fprintf(stderr, "Unable to open %s. Giving up.\n", [patchFile UTF8String]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
NSString *expectedBeforeHash = nil;
|
||||
NSString *expectedAfterHash = nil;
|
||||
xar_subdoc_t subdoc;
|
||||
for (subdoc = xar_subdoc_first(x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
|
||||
if (!strcmp(xar_subdoc_name(subdoc), "binary-delta-attributes")) {
|
||||
const char *value = 0;
|
||||
xar_subdoc_prop_get(subdoc, "before-sha1", &value);
|
||||
if (value)
|
||||
expectedBeforeHash = [NSString stringWithUTF8String:value];
|
||||
|
||||
xar_subdoc_prop_get(subdoc, "after-sha1", &value);
|
||||
if (value)
|
||||
expectedAfterHash = [NSString stringWithUTF8String:value];
|
||||
}
|
||||
}
|
||||
|
||||
if (!expectedBeforeHash || !expectedAfterHash) {
|
||||
fprintf(stderr, "Unable to find before-sha1 or after-sha1 metadata in delta. Giving up.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Verifying source... ");
|
||||
NSString *beforeHash = hashOfTree(source);
|
||||
|
||||
if (![beforeHash isEqualToString:expectedBeforeHash]) {
|
||||
fprintf(stderr, "Source doesn't have expected hash (%s != %s). Giving up.\n", [expectedBeforeHash UTF8String], [beforeHash UTF8String]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf(stderr, "\nCopying files... ");
|
||||
removeTree(destination);
|
||||
copyTree(source, destination);
|
||||
|
||||
fprintf(stderr, "\nPatching... ");
|
||||
xar_file_t file;
|
||||
xar_iter_t iter = xar_iter_new();
|
||||
for (file = xar_file_first(x, iter); file; file = xar_file_next(iter)) {
|
||||
NSString *path = [NSString stringWithUTF8String:xar_get_path(file)];
|
||||
NSString *sourceFilePath = [source stringByAppendingPathComponent:path];
|
||||
NSString *destinationFilePath = [destination stringByAppendingPathComponent:path];
|
||||
|
||||
const char *value;
|
||||
if (!xar_prop_get(file, "delete", &value) || !xar_prop_get(file, "delete-then-extract", &value)) {
|
||||
removeTree(destinationFilePath);
|
||||
if (!xar_prop_get(file, "delete", &value))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!xar_prop_get(file, "binary-delta", &value))
|
||||
applyBinaryDeltaToFile(x, file, sourceFilePath, destinationFilePath);
|
||||
else
|
||||
xar_extract_tofile(x, file, [destinationFilePath fileSystemRepresentation]);
|
||||
}
|
||||
xar_close(x);
|
||||
|
||||
fprintf(stderr, "\nVerifying destination... ");
|
||||
NSString *afterHash = hashOfTree(destination);
|
||||
|
||||
if (![afterHash isEqualToString:expectedAfterHash]) {
|
||||
fprintf(stderr, "Destination doesn't have expected hash (%s != %s). Giving up.\n", [expectedAfterHash UTF8String], [afterHash UTF8String]);
|
||||
removeTree(destination);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf(stderr, "\nDone!\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// SUBinaryDeltaCommon.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mark Rowe on 2009-06-01.
|
||||
// Copyright 2009 Mark Rowe. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUBINARYDELTACOMMON_H
|
||||
#define SUBINARYDELTACOMMON_H
|
||||
|
||||
#include <fts.h>
|
||||
|
||||
@class NSString;
|
||||
@class NSData;
|
||||
|
||||
extern int binaryDeltaSupported(void);
|
||||
extern int compareFiles(const FTSENT **a, const FTSENT **b);
|
||||
extern NSData *hashOfFile(FTSENT *ent);
|
||||
extern NSString *hashOfTree(NSString *path);
|
||||
extern void removeTree(NSString *path);
|
||||
extern void copyTree(NSString *source, NSString *dest);
|
||||
extern NSString *pathRelativeToDirectory(NSString *directory, NSString *path);
|
||||
NSString *temporaryFilename(NSString *base);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,156 @@
|
||||
//
|
||||
// SUBinaryDeltaCommon.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mark Rowe on 2009-06-01.
|
||||
// Copyright 2009 Mark Rowe. All rights reserved.
|
||||
//
|
||||
|
||||
#include "SUBinaryDeltaCommon.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <xar/xar.h>
|
||||
|
||||
int binaryDeltaSupported(void)
|
||||
{
|
||||
// OS X 10.4 didn't include libxar, so we link against it weakly.
|
||||
// This checks whether libxar is available at runtime.
|
||||
return xar_close != 0;
|
||||
}
|
||||
|
||||
int compareFiles(const FTSENT **a, const FTSENT **b)
|
||||
{
|
||||
return strcoll((*a)->fts_name, (*b)->fts_name);
|
||||
}
|
||||
|
||||
NSString *pathRelativeToDirectory(NSString *directory, NSString *path)
|
||||
{
|
||||
NSUInteger directoryLength = [directory length];
|
||||
if ([path hasPrefix:directory])
|
||||
return [path substringFromIndex:directoryLength];
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
NSString *temporaryFilename(NSString *base)
|
||||
{
|
||||
NSString *template = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.XXXXXXXXXX", base]];
|
||||
char buffer[MAXPATHLEN];
|
||||
strcpy(buffer, [template fileSystemRepresentation]);
|
||||
return [NSString stringWithUTF8String:mktemp(buffer)];
|
||||
}
|
||||
|
||||
static void _hashOfBuffer(unsigned char *hash, const char* buffer, size_t bufferLength)
|
||||
{
|
||||
assert(bufferLength <= UINT32_MAX);
|
||||
CC_SHA1_CTX hashContext;
|
||||
CC_SHA1_Init(&hashContext);
|
||||
CC_SHA1_Update(&hashContext, buffer, (CC_LONG)bufferLength);
|
||||
CC_SHA1_Final(hash, &hashContext);
|
||||
}
|
||||
|
||||
static void _hashOfFile(unsigned char* hash, FTSENT *ent)
|
||||
{
|
||||
if (ent->fts_info == FTS_SL) {
|
||||
char linkDestination[MAXPATHLEN + 1];
|
||||
ssize_t linkDestinationLength = readlink(ent->fts_path, linkDestination, MAXPATHLEN);
|
||||
if (linkDestinationLength < 0) {
|
||||
perror("readlink");
|
||||
return;
|
||||
}
|
||||
|
||||
_hashOfBuffer(hash, linkDestination, linkDestinationLength);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ent->fts_info == FTS_F) {
|
||||
int fileDescriptor = open(ent->fts_path, O_RDONLY);
|
||||
if (fileDescriptor == -1) {
|
||||
perror("open");
|
||||
return;
|
||||
}
|
||||
|
||||
size_t fileSize = (size_t)ent->fts_statp->st_size;
|
||||
if (fileSize == 0) {
|
||||
_hashOfBuffer(hash, NULL, 0);
|
||||
close(fileDescriptor);
|
||||
return;
|
||||
}
|
||||
|
||||
void *buffer = mmap(0, fileSize, PROT_READ, MAP_FILE | MAP_PRIVATE, fileDescriptor, 0);
|
||||
if (buffer == (void*)-1) {
|
||||
close(fileDescriptor);
|
||||
perror("mmap");
|
||||
return;
|
||||
}
|
||||
|
||||
_hashOfBuffer(hash, buffer, fileSize);
|
||||
munmap(buffer, fileSize);
|
||||
close(fileDescriptor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ent->fts_info == FTS_D)
|
||||
memset(hash, 0xdd, CC_SHA1_DIGEST_LENGTH);
|
||||
}
|
||||
|
||||
NSData *hashOfFile(FTSENT *ent)
|
||||
{
|
||||
unsigned char fileHash[CC_SHA1_DIGEST_LENGTH];
|
||||
_hashOfFile(fileHash, ent);
|
||||
return [NSData dataWithBytes:fileHash length:CC_SHA1_DIGEST_LENGTH];
|
||||
}
|
||||
|
||||
NSString *hashOfTree(NSString *path)
|
||||
{
|
||||
const char *sourcePaths[] = {[path UTF8String], 0};
|
||||
FTS *fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||
if (!fts) {
|
||||
perror("fts_open");
|
||||
return nil;
|
||||
}
|
||||
|
||||
CC_SHA1_CTX hashContext;
|
||||
CC_SHA1_Init(&hashContext);
|
||||
|
||||
FTSENT *ent = 0;
|
||||
while ((ent = fts_read(fts))) {
|
||||
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL)
|
||||
continue;
|
||||
|
||||
unsigned char fileHash[CC_SHA1_DIGEST_LENGTH];
|
||||
_hashOfFile(fileHash, ent);
|
||||
CC_SHA1_Update(&hashContext, fileHash, sizeof(fileHash));
|
||||
|
||||
NSString *relativePath = pathRelativeToDirectory(path, [NSString stringWithUTF8String:ent->fts_path]);
|
||||
NSData *relativePathBytes = [relativePath dataUsingEncoding:NSUTF8StringEncoding];
|
||||
CC_SHA1_Update(&hashContext, [relativePathBytes bytes], (uint32_t)[relativePathBytes length]);
|
||||
}
|
||||
fts_close(fts);
|
||||
|
||||
unsigned char hash[CC_SHA1_DIGEST_LENGTH];
|
||||
CC_SHA1_Final(hash, &hashContext);
|
||||
|
||||
char hexHash[CC_SHA1_DIGEST_LENGTH * 2 + 1];
|
||||
size_t i;
|
||||
for (i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
|
||||
sprintf(hexHash + i * 2, "%02x", hash[i]);
|
||||
|
||||
return [NSString stringWithUTF8String:hexHash];
|
||||
}
|
||||
|
||||
void removeTree(NSString *path)
|
||||
{
|
||||
[[NSFileManager defaultManager] removeItemAtPath:path error:nil];
|
||||
}
|
||||
|
||||
void copyTree(NSString *source, NSString *dest)
|
||||
{
|
||||
[[NSFileManager defaultManager] copyItemAtPath:source toPath:dest error:nil];
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
//
|
||||
// SUBinaryDeltaTool.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mark Rowe on 2009-06-01.
|
||||
// Copyright 2009 Mark Rowe. All rights reserved.
|
||||
//
|
||||
|
||||
#define _DARWIN_NO_64_BIT_INODE 1
|
||||
|
||||
#include "SUBinaryDeltaCommon.h"
|
||||
#include "SUBinaryDeltaApply.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <fcntl.h>
|
||||
#include <fts.h>
|
||||
#include <libgen.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <xar/xar.h>
|
||||
|
||||
extern int bsdiff(int argc, const char **argv);
|
||||
|
||||
@interface CreateBinaryDeltaOperation : NSOperation
|
||||
{
|
||||
NSString *_relativePath;
|
||||
NSString *_fromPath;
|
||||
NSString *_toPath;
|
||||
NSString *_resultPath;
|
||||
}
|
||||
- (id)initWithRelativePath:(NSString *)relativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree;
|
||||
|
||||
- (NSString *)relativePath;
|
||||
- (NSString *)resultPath;
|
||||
@end
|
||||
|
||||
@implementation CreateBinaryDeltaOperation
|
||||
|
||||
- (id)initWithRelativePath:(NSString *)relativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_relativePath = [relativePath copy];
|
||||
_fromPath = [[oldTree stringByAppendingPathComponent:relativePath] retain];
|
||||
_toPath = [[newTree stringByAppendingPathComponent:relativePath] retain];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)relativePath
|
||||
{
|
||||
return [[_relativePath retain] autorelease];
|
||||
}
|
||||
|
||||
- (NSString *)resultPath
|
||||
{
|
||||
return [[_resultPath retain] autorelease];
|
||||
}
|
||||
|
||||
- (void)main
|
||||
{
|
||||
NSString *temporaryFile = temporaryFilename(@"BinaryDelta");
|
||||
const char *argv[] = {"/usr/bin/bsdiff", [_fromPath fileSystemRepresentation], [_toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation]};
|
||||
int result = bsdiff(4, argv);
|
||||
if (!result)
|
||||
_resultPath = [temporaryFile retain];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
static NSDictionary *infoForFile(FTSENT *ent)
|
||||
{
|
||||
NSData *hash = hashOfFile(ent);
|
||||
NSNumber *size = nil;
|
||||
if (ent->fts_info != FTS_D)
|
||||
size = [NSNumber numberWithUnsignedLongLong:ent->fts_statp->st_size];
|
||||
return [NSDictionary dictionaryWithObjectsAndKeys:hash, @"hash", [NSNumber numberWithUnsignedShort:ent->fts_info], @"type", size, @"size", nil];
|
||||
}
|
||||
|
||||
static NSString *absolutePath(NSString *path)
|
||||
{
|
||||
NSURL *url = [[[NSURL alloc] initFileURLWithPath:path] autorelease];
|
||||
return [[url absoluteURL] path];
|
||||
}
|
||||
|
||||
static NSString *temporaryPatchFile(NSString *patchFile)
|
||||
{
|
||||
NSString *path = absolutePath(patchFile);
|
||||
NSString *directory = [path stringByDeletingLastPathComponent];
|
||||
NSString *file = [path lastPathComponent];
|
||||
return [NSString stringWithFormat:@"%@/.%@.tmp", directory, file];
|
||||
}
|
||||
|
||||
static BOOL shouldSkipDeltaCompression(NSString *key, NSDictionary* originalInfo, NSDictionary *newInfo)
|
||||
{
|
||||
unsigned long long fileSize = [[newInfo objectForKey:@"size"] unsignedLongLongValue];
|
||||
if (fileSize < 4096)
|
||||
return YES;
|
||||
|
||||
if (!originalInfo)
|
||||
return YES;
|
||||
|
||||
if ([[originalInfo objectForKey:@"type"] unsignedShortValue] != [[newInfo objectForKey:@"type"] unsignedShortValue])
|
||||
return YES;
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
static BOOL shouldDeleteThenExtract(NSString *key, NSDictionary* originalInfo, NSDictionary *newInfo)
|
||||
{
|
||||
if (!originalInfo)
|
||||
return NO;
|
||||
|
||||
if ([[originalInfo objectForKey:@"type"] unsignedShortValue] != [[newInfo objectForKey:@"type"] unsignedShortValue])
|
||||
return YES;
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 5) {
|
||||
usage:
|
||||
fprintf(stderr, "Usage: BinaryDelta [create | apply] before-tree after-tree patch-file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSString *command = [NSString stringWithUTF8String:argv[1]];
|
||||
NSString *oldPath = [NSString stringWithUTF8String:argv[2]];
|
||||
NSString *newPath = [NSString stringWithUTF8String:argv[3]];
|
||||
NSString *patchFile = [NSString stringWithUTF8String:argv[4]];
|
||||
|
||||
if ([command isEqualToString:@"apply"]) {
|
||||
int result = applyBinaryDelta(oldPath, newPath, patchFile);
|
||||
[pool drain];
|
||||
return result;
|
||||
}
|
||||
if (![command isEqualToString:@"create"]) {
|
||||
[pool drain];
|
||||
goto usage;
|
||||
}
|
||||
|
||||
NSMutableDictionary *originalTreeState = [NSMutableDictionary dictionary];
|
||||
|
||||
const char *sourcePaths[] = {[oldPath fileSystemRepresentation], 0};
|
||||
FTS *fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||
if (!fts) {
|
||||
[pool drain];
|
||||
perror("fts_open");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Processing %s...", [oldPath UTF8String]);
|
||||
FTSENT *ent = 0;
|
||||
while ((ent = fts_read(fts))) {
|
||||
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D)
|
||||
continue;
|
||||
|
||||
NSString *key = pathRelativeToDirectory(oldPath, [NSString stringWithUTF8String:ent->fts_path]);
|
||||
if (![key length])
|
||||
continue;
|
||||
|
||||
NSDictionary *info = infoForFile(ent);
|
||||
[originalTreeState setObject:info forKey:key];
|
||||
}
|
||||
fts_close(fts);
|
||||
|
||||
NSString *beforeHash = hashOfTree(oldPath);
|
||||
|
||||
NSMutableDictionary *newTreeState = [NSMutableDictionary dictionary];
|
||||
for (NSString *key in originalTreeState)
|
||||
{
|
||||
[newTreeState setObject:[NSNull null] forKey:key];
|
||||
}
|
||||
|
||||
fprintf(stderr, "\nProcessing %s... ", [newPath UTF8String]);
|
||||
sourcePaths[0] = [newPath fileSystemRepresentation];
|
||||
fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||
if (!fts) {
|
||||
[pool drain];
|
||||
perror("fts_open");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
while ((ent = fts_read(fts))) {
|
||||
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D)
|
||||
continue;
|
||||
|
||||
NSString *key = pathRelativeToDirectory(newPath, [NSString stringWithUTF8String:ent->fts_path]);
|
||||
if (![key length])
|
||||
continue;
|
||||
|
||||
NSDictionary *info = infoForFile(ent);
|
||||
NSDictionary *oldInfo = [originalTreeState objectForKey:key];
|
||||
|
||||
if ([info isEqual:oldInfo])
|
||||
[newTreeState removeObjectForKey:key];
|
||||
else
|
||||
[newTreeState setObject:info forKey:key];
|
||||
}
|
||||
fts_close(fts);
|
||||
|
||||
NSString *afterHash = hashOfTree(newPath);
|
||||
|
||||
fprintf(stderr, "\nGenerating delta... ");
|
||||
|
||||
NSString *temporaryFile = temporaryPatchFile(patchFile);
|
||||
xar_t x = xar_open([temporaryFile fileSystemRepresentation], WRITE);
|
||||
xar_opt_set(x, XAR_OPT_COMPRESSION, "bzip2");
|
||||
xar_subdoc_t attributes = xar_subdoc_new(x, "binary-delta-attributes");
|
||||
xar_subdoc_prop_set(attributes, "before-sha1", [beforeHash UTF8String]);
|
||||
xar_subdoc_prop_set(attributes, "after-sha1", [afterHash UTF8String]);
|
||||
|
||||
NSOperationQueue *deltaQueue = [[NSOperationQueue alloc] init];
|
||||
NSMutableArray *deltaOperations = [NSMutableArray array];
|
||||
|
||||
NSArray *keys = [[newTreeState allKeys] sortedArrayUsingSelector:@selector(compare:)];
|
||||
for (NSString* key in keys) {
|
||||
id value = [newTreeState valueForKey:key];
|
||||
|
||||
if ([value isEqual:[NSNull null]]) {
|
||||
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
|
||||
assert(newFile);
|
||||
xar_prop_set(newFile, "delete", "true");
|
||||
continue;
|
||||
}
|
||||
|
||||
NSDictionary *originalInfo = [originalTreeState objectForKey:key];
|
||||
NSDictionary *newInfo = [newTreeState objectForKey:key];
|
||||
if (shouldSkipDeltaCompression(key, originalInfo, newInfo)) {
|
||||
NSString *path = [newPath stringByAppendingPathComponent:key];
|
||||
xar_file_t newFile = xar_add_frompath(x, 0, [key fileSystemRepresentation], [path fileSystemRepresentation]);
|
||||
assert(newFile);
|
||||
if (shouldDeleteThenExtract(key, originalInfo, newInfo))
|
||||
xar_prop_set(newFile, "delete-then-extract", "true");
|
||||
} else {
|
||||
CreateBinaryDeltaOperation *operation = [[CreateBinaryDeltaOperation alloc] initWithRelativePath:key oldTree:oldPath newTree:newPath];
|
||||
[deltaQueue addOperation:operation];
|
||||
[deltaOperations addObject:operation];
|
||||
[operation release];
|
||||
}
|
||||
}
|
||||
|
||||
[deltaQueue waitUntilAllOperationsAreFinished];
|
||||
[deltaQueue release];
|
||||
|
||||
for (CreateBinaryDeltaOperation *operation in deltaOperations) {
|
||||
NSString *resultPath = [operation resultPath];
|
||||
xar_file_t newFile = xar_add_frompath(x, 0, [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]);
|
||||
assert(newFile);
|
||||
xar_prop_set(newFile, "binary-delta", "true");
|
||||
unlink([resultPath fileSystemRepresentation]);
|
||||
}
|
||||
|
||||
xar_close(x);
|
||||
|
||||
unlink([patchFile fileSystemRepresentation]);
|
||||
link([temporaryFile fileSystemRepresentation], [patchFile fileSystemRepresentation]);
|
||||
unlink([temporaryFile fileSystemRepresentation]);
|
||||
fprintf(stderr, "Done!\n");
|
||||
|
||||
[pool drain];
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// SUBinaryDeltaUnarchiver.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mark Rowe on 2009-06-03.
|
||||
// Copyright 2009 Mark Rowe. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUBINARYDELTAUNARCHIVER_H
|
||||
#define SUBINARYDELTAUNARCHIVER_H
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUUnarchiver.h"
|
||||
|
||||
@interface SUBinaryDeltaUnarchiver : SUUnarchiver
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// SUBinaryDeltaUnarchiver.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mark Rowe on 2009-06-03.
|
||||
// Copyright 2009 Mark Rowe. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
#import "SUBinaryDeltaUnarchiver.h"
|
||||
#import "SUBinaryDeltaApply.h"
|
||||
#import "SUUnarchiver_Private.h"
|
||||
#import "SUHost.h"
|
||||
#import "NTSynchronousTask.h"
|
||||
|
||||
@implementation SUBinaryDeltaUnarchiver
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
return binaryDeltaSupported() && [[path pathExtension] isEqualToString:@"delta"];
|
||||
}
|
||||
|
||||
- (void)applyBinaryDelta
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSString *sourcePath = [[updateHost bundle] bundlePath];
|
||||
NSString *targetPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
|
||||
|
||||
int result = applyBinaryDelta(sourcePath, targetPath, archivePath);
|
||||
if (!result)
|
||||
[self performSelectorOnMainThread:@selector(notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO];
|
||||
else
|
||||
[self performSelectorOnMainThread:@selector(notifyDelegateOfFailure) withObject:nil waitUntilDone:NO];
|
||||
|
||||
[pool drain];
|
||||
}
|
||||
|
||||
- (void)start
|
||||
{
|
||||
[NSThread detachNewThreadSelector:@selector(applyBinaryDelta) toTarget:self withObject:nil];
|
||||
}
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
[self registerImplementation:self];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// SUCodeSigningVerifier.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 7/5/12.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef SUCODESIGNINGVERIFIER_H
|
||||
#define SUCODESIGNINGVERIFIER_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface SUCodeSigningVerifier : NSObject
|
||||
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)destinationPath error:(NSError **)error;
|
||||
+ (BOOL)hostApplicationIsCodeSigned;
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// SUCodeSigningVerifier.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 7/5/12.
|
||||
//
|
||||
//
|
||||
|
||||
#include <Security/CodeSigning.h>
|
||||
#include <Security/SecCode.h>
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SULog.h"
|
||||
|
||||
@implementation SUCodeSigningVerifier
|
||||
|
||||
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)destinationPath error:(NSError **)error
|
||||
{
|
||||
OSStatus result;
|
||||
SecRequirementRef requirement = NULL;
|
||||
SecStaticCodeRef staticCode = NULL;
|
||||
SecCodeRef hostCode = NULL;
|
||||
|
||||
result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
|
||||
if (result != 0) {
|
||||
SULog(@"Failed to copy host code %d", result);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
|
||||
if (result != 0) {
|
||||
SULog(@"Failed to copy designated requirement %d", result);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
NSBundle *newBundle = [NSBundle bundleWithPath:destinationPath];
|
||||
if (!newBundle) {
|
||||
SULog(@"Failed to load NSBundle for update");
|
||||
result = -1;
|
||||
goto finally;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCreateWithPath((CFURLRef)[newBundle executableURL], kSecCSDefaultFlags, &staticCode);
|
||||
if (result != 0) {
|
||||
SULog(@"Failed to get static code %d", result);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, kSecCSDefaultFlags | kSecCSCheckAllArchitectures, requirement, (CFErrorRef *)error);
|
||||
if (result != 0 && error) [*error autorelease];
|
||||
|
||||
finally:
|
||||
if (hostCode) CFRelease(hostCode);
|
||||
if (staticCode) CFRelease(staticCode);
|
||||
if (requirement) CFRelease(requirement);
|
||||
return (result == 0);
|
||||
}
|
||||
|
||||
+ (BOOL)hostApplicationIsCodeSigned
|
||||
{
|
||||
OSStatus result;
|
||||
SecCodeRef hostCode = NULL;
|
||||
result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
|
||||
if (result != 0) return NO;
|
||||
|
||||
SecRequirementRef requirement = NULL;
|
||||
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
|
||||
if (hostCode) CFRelease(hostCode);
|
||||
if (requirement) CFRelease(requirement);
|
||||
return (result == 0);
|
||||
}
|
||||
|
||||
@end
|
||||
+54
-36
@@ -10,28 +10,62 @@
|
||||
#ifndef SUCONSTANTS_H
|
||||
#define SUCONSTANTS_H
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Preprocessor flags:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
extern NSString *SUUpdaterWillRestartNotification;
|
||||
extern NSString *SUTechnicalErrorInformationKey;
|
||||
// Turn off DSA signature check (practically invites man-in-the-middle attacks):
|
||||
#define ENDANGER_USERS_WITH_INSECURE_UPDATES 0
|
||||
|
||||
extern NSString *SUFeedURLKey;
|
||||
extern NSString *SUHasLaunchedBeforeKey;
|
||||
extern NSString *SUShowReleaseNotesKey;
|
||||
extern NSString *SUSkippedVersionKey;
|
||||
extern NSString *SUScheduledCheckIntervalKey;
|
||||
extern NSString *SULastCheckTimeKey;
|
||||
extern NSString *SUExpectsDSASignatureKey;
|
||||
extern NSString *SUPublicDSAKeyKey;
|
||||
extern NSString *SUPublicDSAKeyFileKey;
|
||||
extern NSString *SUAutomaticallyUpdateKey;
|
||||
extern NSString *SUAllowsAutomaticUpdatesKey;
|
||||
extern NSString *SUEnableAutomaticChecksKey;
|
||||
extern NSString *SUEnableAutomaticChecksKeyOld;
|
||||
extern NSString *SUEnableSystemProfilingKey;
|
||||
extern NSString *SUSendProfileInfoKey;
|
||||
extern NSString *SULastProfileSubmitDateKey;
|
||||
// Sparkle usually doesn't allow downgrades as they're usually accidental, but
|
||||
// if your app has a downgrade function or URL handler, turn this on:
|
||||
#define PERMIT_AUTOMATED_DOWNGRADES 0
|
||||
|
||||
extern NSString *SUSparkleErrorDomain;
|
||||
// If your app file on disk is named "MyApp 1.1b4", Sparkle usually updates it
|
||||
// in place, giving you an app named 1.1b4 that is actually 1.2. Turn the
|
||||
// following on to always reset the name back to "MyApp":
|
||||
#define NORMALIZE_INSTALLED_APP_NAME 0
|
||||
|
||||
|
||||
#define TRY_TO_APPEND_VERSION_NUMBER 1
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Notifications:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
extern NSString *const SUUpdaterWillRestartNotification;
|
||||
|
||||
extern NSString *const SUTechnicalErrorInformationKey;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// PList keys::
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
extern NSString *const SUFeedURLKey;
|
||||
extern NSString *const SUHasLaunchedBeforeKey;
|
||||
extern NSString *const SUShowReleaseNotesKey;
|
||||
extern NSString *const SUSkippedVersionKey;
|
||||
extern NSString *const SUScheduledCheckIntervalKey;
|
||||
extern NSString *const SULastCheckTimeKey;
|
||||
extern NSString *const SUPublicDSAKeyKey;
|
||||
extern NSString *const SUPublicDSAKeyFileKey;
|
||||
extern NSString *const SUAutomaticallyUpdateKey;
|
||||
extern NSString *const SUAllowsAutomaticUpdatesKey;
|
||||
extern NSString *const SUEnableAutomaticChecksKey;
|
||||
extern NSString *const SUEnableAutomaticChecksKeyOld;
|
||||
extern NSString *const SUEnableSystemProfilingKey;
|
||||
extern NSString *const SUSendProfileInfoKey;
|
||||
extern NSString *const SULastProfileSubmitDateKey;
|
||||
extern NSString *const SUPromptUserOnFirstLaunchKey;
|
||||
extern NSString *const SUFixedHTMLDisplaySizeKey;
|
||||
extern NSString *const SUKeepDownloadOnFailedInstallKey;
|
||||
extern NSString *const SUDefaultsDomainKey;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Errors:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
extern NSString *const SUSparkleErrorDomain;
|
||||
// Appcast phase errors.
|
||||
extern OSStatus SUAppcastParseError;
|
||||
extern OSStatus SUNoUpdateError;
|
||||
@@ -52,22 +86,6 @@ extern OSStatus SUMissingUpdateError;
|
||||
extern OSStatus SUMissingInstallerToolError;
|
||||
extern OSStatus SURelaunchError;
|
||||
extern OSStatus SUInstallationError;
|
||||
|
||||
// NSInteger is a type that was added to Leopard.
|
||||
// Here is some glue to ensure that NSInteger will work with pre-10.5 SDKs:
|
||||
#ifndef NSINTEGER_DEFINED
|
||||
#ifdef NS_BUILD_32_LIKE_64
|
||||
typedef long NSInteger;
|
||||
typedef unsigned long NSUInteger;
|
||||
#else
|
||||
typedef int NSInteger;
|
||||
typedef unsigned int NSUInteger;
|
||||
#endif
|
||||
#define NSIntegerMax LONG_MAX
|
||||
#define NSIntegerMin LONG_MIN
|
||||
#define NSUIntegerMax ULONG_MAX
|
||||
#define NSINTEGER_DEFINED 1
|
||||
#endif
|
||||
|
||||
extern OSStatus SUDowngradeError;
|
||||
|
||||
#endif
|
||||
+29
-20
@@ -6,30 +6,38 @@
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Sparkle.h"
|
||||
#import "SUUpdater.h"
|
||||
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUConstants.h"
|
||||
|
||||
NSString *SUUpdaterWillRestartNotification = @"SUUpdaterWillRestartNotificationName";
|
||||
NSString *SUTechnicalErrorInformationKey = @"SUTechnicalErrorInformation";
|
||||
NSString *const SUUpdaterWillRestartNotification = @"SUUpdaterWillRestartNotificationName";
|
||||
NSString *const SUTechnicalErrorInformationKey = @"SUTechnicalErrorInformation";
|
||||
|
||||
NSString *SUHasLaunchedBeforeKey = @"SUHasLaunchedBefore";
|
||||
NSString *SUFeedURLKey = @"SUFeedURL";
|
||||
NSString *SUShowReleaseNotesKey = @"SUShowReleaseNotes";
|
||||
NSString *SUSkippedVersionKey = @"SUSkippedVersion";
|
||||
NSString *SUScheduledCheckIntervalKey = @"SUScheduledCheckInterval";
|
||||
NSString *SULastCheckTimeKey = @"SULastCheckTime";
|
||||
NSString *SUExpectsDSASignatureKey = @"SUExpectsDSASignature";
|
||||
NSString *SUPublicDSAKeyKey = @"SUPublicDSAKey";
|
||||
NSString *SUPublicDSAKeyFileKey = @"SUPublicDSAKeyFile";
|
||||
NSString *SUAutomaticallyUpdateKey = @"SUAutomaticallyUpdate";
|
||||
NSString *SUAllowsAutomaticUpdatesKey = @"SUAllowsAutomaticUpdates";
|
||||
NSString *SUEnableSystemProfilingKey = @"SUEnableSystemProfiling";
|
||||
NSString *SUEnableAutomaticChecksKey = @"SUEnableAutomaticChecks";
|
||||
NSString *SUEnableAutomaticChecksKeyOld = @"SUCheckAtStartup";
|
||||
NSString *SUSendProfileInfoKey = @"SUSendProfileInfo";
|
||||
NSString *SULastProfileSubmitDateKey = @"SULastProfileSubmissionDate";
|
||||
NSString *const SUHasLaunchedBeforeKey = @"SUHasLaunchedBefore";
|
||||
NSString *const SUFeedURLKey = @"SUFeedURL";
|
||||
NSString *const SUShowReleaseNotesKey = @"SUShowReleaseNotes";
|
||||
NSString *const SUSkippedVersionKey = @"SUSkippedVersion";
|
||||
NSString *const SUScheduledCheckIntervalKey = @"SUScheduledCheckInterval";
|
||||
NSString *const SULastCheckTimeKey = @"SULastCheckTime";
|
||||
NSString *const SUExpectsDSASignatureKey = @"SUExpectsDSASignature";
|
||||
NSString *const SUPublicDSAKeyKey = @"SUPublicDSAKey";
|
||||
NSString *const SUPublicDSAKeyFileKey = @"SUPublicDSAKeyFile";
|
||||
NSString *const SUAutomaticallyUpdateKey = @"SUAutomaticallyUpdate";
|
||||
NSString *const SUAllowsAutomaticUpdatesKey = @"SUAllowsAutomaticUpdates";
|
||||
NSString *const SUEnableSystemProfilingKey = @"SUEnableSystemProfiling";
|
||||
NSString *const SUEnableAutomaticChecksKey = @"SUEnableAutomaticChecks";
|
||||
NSString *const SUEnableAutomaticChecksKeyOld = @"SUCheckAtStartup";
|
||||
NSString *const SUSendProfileInfoKey = @"SUSendProfileInfo";
|
||||
NSString *const SULastProfileSubmitDateKey = @"SULastProfileSubmissionDate";
|
||||
NSString *const SUPromptUserOnFirstLaunchKey = @"SUPromptUserOnFirstLaunch";
|
||||
NSString *const SUFixedHTMLDisplaySizeKey = @"SUFixedHTMLDisplaySize";
|
||||
NSString *const SUKeepDownloadOnFailedInstallKey = @"SUKeepDownloadOnFailedInstall";
|
||||
NSString *const SUDefaultsDomainKey = @"SUDefaultsDomain";
|
||||
|
||||
NSString *SUSparkleErrorDomain = @"SUSparkleErrorDomain";
|
||||
NSString *const SUSparkleErrorDomain = @"SUSparkleErrorDomain";
|
||||
OSStatus SUAppcastParseError = 1000;
|
||||
OSStatus SUNoUpdateError = 1001;
|
||||
OSStatus SUAppcastError = 1002;
|
||||
@@ -46,3 +54,4 @@ OSStatus SUMissingUpdateError = 4002;
|
||||
OSStatus SUMissingInstallerToolError = 4003;
|
||||
OSStatus SURelaunchError = 4004;
|
||||
OSStatus SUInstallationError = 4005;
|
||||
OSStatus SUDowngradeError = 4006;
|
||||
+3
-2
@@ -9,8 +9,9 @@
|
||||
#ifndef SUDSAVERIFIER_H
|
||||
#define SUDSAVERIFIER_H
|
||||
|
||||
// For the paranoid folks!
|
||||
@interface SUDSAVerifier : NSObject {}
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface SUDSAVerifier : NSObject
|
||||
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString;
|
||||
@end
|
||||
|
||||
|
||||
+329
-124
@@ -6,145 +6,350 @@
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
// DSA stuff adapted from code provided by Allan Odgaard. Thanks, Allan!
|
||||
|
||||
#import "SUDSAVerifier.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import <stdio.h>
|
||||
#import <openssl/evp.h>
|
||||
#import <openssl/bio.h>
|
||||
#import <openssl/pem.h>
|
||||
#import <openssl/rsa.h>
|
||||
#import <openssl/sha.h>
|
||||
#include <Security/cssm.h>
|
||||
|
||||
long b64decode(unsigned char* str)
|
||||
{
|
||||
unsigned char *cur, *start;
|
||||
int d, dlast, phase;
|
||||
unsigned char c;
|
||||
static int table[256] = {
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 00-0F */
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 10-1F */
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63, /* 20-2F */
|
||||
52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1, /* 30-3F */
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, /* 40-4F */
|
||||
15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1, /* 50-5F */
|
||||
-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, /* 60-6F */
|
||||
41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1, /* 70-7F */
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 80-8F */
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 90-9F */
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* A0-AF */
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* B0-BF */
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* C0-CF */
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* D0-DF */
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* E0-EF */
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 /* F0-FF */
|
||||
};
|
||||
|
||||
d = dlast = phase = 0;
|
||||
start = str;
|
||||
for (cur = str; *cur != '\0'; ++cur )
|
||||
{
|
||||
if(*cur == '\n' || *cur == '\r'){phase = dlast = 0; continue;}
|
||||
d = table[(int)*cur];
|
||||
if(d != -1)
|
||||
{
|
||||
switch(phase)
|
||||
{
|
||||
case 0:
|
||||
++phase;
|
||||
break;
|
||||
case 1:
|
||||
c = ((dlast << 2) | ((d & 0x30) >> 4));
|
||||
*str++ = c;
|
||||
++phase;
|
||||
break;
|
||||
case 2:
|
||||
c = (((dlast & 0xf) << 4) | ((d & 0x3c) >> 2));
|
||||
*str++ = c;
|
||||
++phase;
|
||||
break;
|
||||
case 3:
|
||||
c = (((dlast & 0x03 ) << 6) | d);
|
||||
*str++ = c;
|
||||
phase = 0;
|
||||
break;
|
||||
}
|
||||
dlast = d;
|
||||
}
|
||||
}
|
||||
*str = '\0';
|
||||
return str - start;
|
||||
}
|
||||
/* CDSA Specific */
|
||||
static CSSM_CSP_HANDLE cdsaInit( void );
|
||||
static void cdsaRelease( CSSM_CSP_HANDLE cspHandle );
|
||||
static CSSM_KEY_PTR cdsaCreateKey( CFDataRef rawKey );
|
||||
static void cdsaReleaseKey( CSSM_KEY_PTR key );
|
||||
static BOOL cdsaVerifyKey( CSSM_CSP_HANDLE cspHandle, const CSSM_KEY_PTR key );
|
||||
static BOOL cdsaVerifySignature( CSSM_CSP_HANDLE cspHandle, const CSSM_KEY_PTR key, const CFDataRef msg, const CFDataRef signature );
|
||||
static CFDataRef cdsaCreateSHA1Digest( CSSM_CSP_HANDLE cspHandle, const CFDataRef bytes );
|
||||
|
||||
EVP_PKEY* load_dsa_key(char *key)
|
||||
{
|
||||
EVP_PKEY* pkey = NULL;
|
||||
BIO *bio;
|
||||
if((bio = BIO_new_mem_buf(key, (int)strlen(key))))
|
||||
{
|
||||
DSA* dsa_key = 0;
|
||||
if(PEM_read_bio_DSA_PUBKEY(bio, &dsa_key, NULL, NULL))
|
||||
{
|
||||
if((pkey = EVP_PKEY_new()))
|
||||
{
|
||||
if(EVP_PKEY_assign_DSA(pkey, dsa_key) != 1)
|
||||
{
|
||||
DSA_free(dsa_key);
|
||||
EVP_PKEY_free(pkey);
|
||||
pkey = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
BIO_free(bio);
|
||||
}
|
||||
return pkey;
|
||||
}
|
||||
/* Helper Functions */
|
||||
static NSData *b64decode( NSString *str );
|
||||
static NSData *rawKeyData( NSString *str );
|
||||
|
||||
@implementation SUDSAVerifier
|
||||
#pragma mark -
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString
|
||||
{
|
||||
if ( !encodedSignature || !pkeyString || !path ) return NO;
|
||||
BOOL result = NO;
|
||||
if (!encodedSignature) { return NO; }
|
||||
if (!pkeyString) { return NO; }
|
||||
NSData *pathData = nil, *sigData = nil;
|
||||
CFDataRef hashData = NULL;
|
||||
CSSM_KEY_PTR pubKey = cdsaCreateKey((CFDataRef)rawKeyData(pkeyString)); // Create the DSA key
|
||||
CSSM_CSP_HANDLE cspHandle = CSSM_INVALID_HANDLE;
|
||||
|
||||
// Remove whitespace around each line of the key.
|
||||
NSMutableArray *pkeyTrimmedLines = [NSMutableArray array];
|
||||
NSEnumerator *pkeyLinesEnumerator = [[pkeyString componentsSeparatedByString:@"\n"] objectEnumerator];
|
||||
NSString *pkeyLine;
|
||||
while ((pkeyLine = [pkeyLinesEnumerator nextObject]) != nil)
|
||||
{
|
||||
[pkeyTrimmedLines addObject:[pkeyLine stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]];
|
||||
if ( !pubKey ) return NO;
|
||||
if ( (cspHandle = cdsaInit()) == CSSM_INVALID_HANDLE ) goto validate_end; // Init CDSA
|
||||
if ( !cdsaVerifyKey(cspHandle, pubKey) ) goto validate_end; // Verify the key is valid
|
||||
if ( (pathData = [NSData dataWithContentsOfFile:path]) == nil ) goto validate_end; // File data
|
||||
if ( (hashData = cdsaCreateSHA1Digest(cspHandle, (CFDataRef)pathData)) == NULL ) goto validate_end; // Hash
|
||||
|
||||
// Remove any line feeds from end of signature
|
||||
// (Not likely needed, but the verify _can_ fail if there is, so...)
|
||||
if ( [encodedSignature characterAtIndex:[encodedSignature length] - 1] == '\n' ) {
|
||||
NSMutableString *sig = [[encodedSignature mutableCopy] autorelease];
|
||||
while ( [sig characterAtIndex:[sig length] - 1] == '\n' )
|
||||
[sig deleteCharactersInRange:NSMakeRange([sig length] - 1, 1)];
|
||||
encodedSignature = sig;
|
||||
}
|
||||
pkeyString = [pkeyTrimmedLines componentsJoinedByString:@"\n"]; // Put them back together.
|
||||
if ( (sigData = b64decode(encodedSignature)) == nil ) goto validate_end; // Decode signature
|
||||
|
||||
// Verify the signature on the file
|
||||
result = cdsaVerifySignature( cspHandle, pubKey, hashData, (CFDataRef)sigData );
|
||||
|
||||
EVP_PKEY* pkey = NULL;
|
||||
pkey = load_dsa_key((char *)[pkeyString UTF8String]);
|
||||
if (!pkey) { return NO; }
|
||||
|
||||
// Now, the signature is in base64; we have to decode it into a binary stream.
|
||||
unsigned char *signature = (unsigned char *)[encodedSignature UTF8String];
|
||||
long length = b64decode(signature); // Decode the signature in-place and get the new length of the signature string.
|
||||
validate_end:
|
||||
cdsaReleaseKey( pubKey );
|
||||
cdsaRelease( cspHandle );
|
||||
if ( hashData ) CFRelease( hashData );
|
||||
|
||||
// We've got the signature, now get the file data.
|
||||
NSData *pathData = [NSData dataWithContentsOfFile:path];
|
||||
if (!pathData) { return NO; }
|
||||
|
||||
// Hash the file with SHA-1.
|
||||
unsigned char md[SHA_DIGEST_LENGTH];
|
||||
SHA1([pathData bytes], [pathData length], md);
|
||||
|
||||
// Actually verify the signature on the file.
|
||||
EVP_MD_CTX ctx;
|
||||
if(EVP_VerifyInit(&ctx, EVP_dss1()) == 1) // We're using DSA keys.
|
||||
{
|
||||
EVP_VerifyUpdate(&ctx, md, SHA_DIGEST_LENGTH);
|
||||
result = (EVP_VerifyFinal(&ctx, signature, (unsigned int)length, pkey) == 1);
|
||||
}
|
||||
|
||||
EVP_PKEY_free(pkey);
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Misc Helper Functions
|
||||
#pragma mark -
|
||||
|
||||
static NSData *b64decode( NSString *str )
|
||||
{
|
||||
if ( !str ) return nil;
|
||||
NSMutableData *retval = nil;
|
||||
NSData *input = [str dataUsingEncoding:NSUTF8StringEncoding];
|
||||
UInt8 *ibuf = (UInt8 *)[input bytes], *buf = NULL, *a = NULL;
|
||||
size_t len = [input length], i = 0, j = 0, size = ((len + 3) / 4) * 3;
|
||||
static UInt8 table[256] = {
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 00-0F */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 10-1F */
|
||||
99,99,99,99,99,99,99,99,99,99,99,62,99,99,99,63, /* 20-2F */
|
||||
52,53,54,55,56,57,58,59,60,61,99,99,99,99,99,99, /* 30-3F */
|
||||
99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, /* 40-4F */
|
||||
15,16,17,18,19,20,21,22,23,24,25,99,99,99,99,99, /* 50-5F */
|
||||
99,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, /* 60-6F */
|
||||
41,42,43,44,45,46,47,48,49,50,51,99,99,99,99,99, /* 70-7F */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 80-8F */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 90-9F */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* A0-AF */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* B0-BF */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* C0-CF */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* D0-DF */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* E0-EF */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99 /* F0-FF */
|
||||
};
|
||||
|
||||
retval = [NSMutableData dataWithLength:size];
|
||||
buf = [retval mutableBytes];
|
||||
|
||||
if ( (a = calloc(4, sizeof(UInt8))) == NULL ) return nil;
|
||||
|
||||
do {
|
||||
size_t ai = 0;
|
||||
a[0] = a[1] = a[2] = a[3] = 0;
|
||||
do {
|
||||
UInt8 d = table[ibuf[i++]];
|
||||
if ( d != 99 ) {
|
||||
a[ai] = d;
|
||||
ai++;
|
||||
if ( ai == 4 ) break;
|
||||
}
|
||||
} while ( i < len );
|
||||
if ( ai >= 2 ) buf[j] = (a[0] << 2) | (a[1] >> 4);
|
||||
if ( ai >= 3 ) buf[j+1] = (a[1] << 4) | (a[2] >> 2);
|
||||
if ( ai >= 4 ) buf[j+2] = (a[2] << 6) | a[3];
|
||||
j += ai-1;
|
||||
} while ( i < len );
|
||||
|
||||
free( a );
|
||||
if ( j < size ) [retval setLength:j];
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static NSData *rawKeyData( NSString *key )
|
||||
{
|
||||
if ( (key == nil) || ([key length] == 0) ) return nil;
|
||||
NSMutableString *t = [[key mutableCopy] autorelease];
|
||||
|
||||
// Remove the PEM guards (if present)
|
||||
[t replaceOccurrencesOfString:@"-" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [t length])];
|
||||
[t replaceOccurrencesOfString:@"BEGIN PUBLIC KEY" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [t length])];
|
||||
[t replaceOccurrencesOfString:@"END PUBLIC KEY" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [t length])];
|
||||
|
||||
// Remove any line feeds from the beginning of the key
|
||||
while ( [t characterAtIndex:0] == '\n' ) {
|
||||
[t deleteCharactersInRange:NSMakeRange(0, 1)];
|
||||
}
|
||||
|
||||
// Remove any line feeds at the end of the key
|
||||
while ( [t characterAtIndex:[t length] - 1] == '\n' ) {
|
||||
[t deleteCharactersInRange:NSMakeRange([t length] - 1, 1)];
|
||||
}
|
||||
|
||||
// Remove whitespace around each line of the key.
|
||||
NSMutableArray *pkeyTrimmedLines = [NSMutableArray array];
|
||||
NSCharacterSet *whiteSet = [NSCharacterSet whitespaceCharacterSet];
|
||||
for (NSString *pkeyLine in [t componentsSeparatedByString:@"\n"])
|
||||
{
|
||||
[pkeyTrimmedLines addObject:[pkeyLine stringByTrimmingCharactersInSet:whiteSet]];
|
||||
}
|
||||
key = [pkeyTrimmedLines componentsJoinedByString:@"\n"]; // Put them back together.
|
||||
|
||||
// Base64 decode to return the raw key bits (DER format rather than PEM)
|
||||
return b64decode( key );
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark CDSA
|
||||
#pragma mark -
|
||||
|
||||
/* Helper Functions */
|
||||
static CSSM_DATA_PTR su_createData( CFDataRef bytes );
|
||||
static void su_freeData( CSSM_DATA_PTR data, Boolean freeData );
|
||||
static Boolean su_copyBytesToData( CSSM_DATA_PTR data, CSSM_SIZE size, const uint8 *bytes );
|
||||
|
||||
/* Memory functions */
|
||||
static void *su_malloc( CSSM_SIZE size, void *ref );
|
||||
static void su_free( void *ptr, void *ref );
|
||||
static void *su_realloc( void *ptr, CSSM_SIZE size, void *ref );
|
||||
static void *su_calloc( uint32 num, CSSM_SIZE size, void *ref );
|
||||
|
||||
/* Constants & Typedefs */
|
||||
static CSSM_VERSION vers = { 2, 0 };
|
||||
static const CSSM_GUID su_guid = { 'S', 'p', 'a', { 'r', 'k', 'l', 'e', 0, 0, 0, 0 } };
|
||||
static CSSM_BOOL cssmInited = CSSM_FALSE;
|
||||
|
||||
static CSSM_API_MEMORY_FUNCS SU_MemFuncs = {
|
||||
su_malloc,
|
||||
su_free,
|
||||
su_realloc,
|
||||
su_calloc,
|
||||
NULL
|
||||
};
|
||||
|
||||
static CSSM_CSP_HANDLE cdsaInit( void )
|
||||
{
|
||||
CSSM_CSP_HANDLE cspHandle = CSSM_INVALID_HANDLE;
|
||||
CSSM_RETURN crtn;
|
||||
|
||||
if ( !cssmInited ) {
|
||||
CSSM_PVC_MODE pvcPolicy = CSSM_PVC_NONE;
|
||||
crtn = CSSM_Init( &vers, CSSM_PRIVILEGE_SCOPE_NONE, &su_guid, CSSM_KEY_HIERARCHY_NONE, &pvcPolicy, NULL );
|
||||
if ( crtn ) return CSSM_INVALID_HANDLE;
|
||||
cssmInited = CSSM_TRUE;
|
||||
}
|
||||
|
||||
crtn = CSSM_ModuleLoad( &gGuidAppleCSP, CSSM_KEY_HIERARCHY_NONE, NULL, NULL );
|
||||
if ( crtn ) return CSSM_INVALID_HANDLE;
|
||||
|
||||
crtn = CSSM_ModuleAttach( &gGuidAppleCSP, &vers, &SU_MemFuncs, 0, CSSM_SERVICE_CSP, 0, CSSM_KEY_HIERARCHY_NONE, NULL, 0, NULL, &cspHandle );
|
||||
if ( crtn ) return CSSM_INVALID_HANDLE;
|
||||
|
||||
return cspHandle;
|
||||
}
|
||||
|
||||
static void cdsaRelease( CSSM_CSP_HANDLE cspHandle )
|
||||
{
|
||||
if ( CSSM_ModuleDetach(cspHandle) != CSSM_OK ) return;
|
||||
CSSM_ModuleUnload( &gGuidAppleCSP, NULL, NULL );
|
||||
}
|
||||
|
||||
static CSSM_KEY_PTR cdsaCreateKey( CFDataRef rawKey )
|
||||
{
|
||||
CSSM_KEY_PTR retval = NULL;
|
||||
|
||||
if ( !rawKey || (CFDataGetLength(rawKey) == 0) ) return NULL;
|
||||
|
||||
if ( (retval = su_malloc(sizeof(CSSM_KEY), NULL)) == NULL ) return NULL;
|
||||
|
||||
if ( !su_copyBytesToData(&(retval->KeyData), CFDataGetLength(rawKey), CFDataGetBytePtr(rawKey)) ) {
|
||||
su_free( retval, NULL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CSSM_KEYHEADER_PTR hdr = &(retval->KeyHeader);
|
||||
|
||||
memset( hdr, 0, sizeof(CSSM_KEYHEADER) );
|
||||
|
||||
hdr->HeaderVersion = CSSM_KEYHEADER_VERSION;
|
||||
hdr->CspId = su_guid;
|
||||
hdr->BlobType = CSSM_KEYBLOB_RAW;
|
||||
hdr->Format = CSSM_KEYBLOB_RAW_FORMAT_X509;
|
||||
hdr->AlgorithmId = CSSM_ALGID_DSA;
|
||||
hdr->KeyClass = CSSM_KEYCLASS_PUBLIC_KEY;
|
||||
hdr->KeyAttr = CSSM_KEYATTR_EXTRACTABLE;
|
||||
hdr->KeyUsage = CSSM_KEYUSE_ANY;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void cdsaReleaseKey( CSSM_KEY_PTR key )
|
||||
{
|
||||
if ( key ) {
|
||||
if ( key->KeyData.Data ) su_free( key->KeyData.Data, NULL );
|
||||
su_free( key, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
BOOL cdsaVerifyKey( CSSM_CSP_HANDLE cspHandle, CSSM_KEY_PTR key )
|
||||
{
|
||||
if ( key->KeyHeader.LogicalKeySizeInBits == 0 ) {
|
||||
CSSM_RETURN crtn;
|
||||
CSSM_KEY_SIZE keySize;
|
||||
|
||||
/* This will fail if the key isn't valid */
|
||||
crtn = CSSM_QueryKeySizeInBits( cspHandle, CSSM_INVALID_HANDLE, key, &keySize );
|
||||
if ( crtn ) return NO;
|
||||
key->KeyHeader.LogicalKeySizeInBits = keySize.LogicalKeySizeInBits;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
static BOOL cdsaVerifySignature( CSSM_CSP_HANDLE cspHandle, const CSSM_KEY_PTR key, const CFDataRef msg, const CFDataRef signature )
|
||||
{
|
||||
CSSM_CC_HANDLE ccHandle = CSSM_INVALID_HANDLE;
|
||||
CSSM_DATA_PTR plain = su_createData( msg ), cipher = su_createData( signature );
|
||||
BOOL retval = NO;
|
||||
|
||||
if ( !plain || !cipher || (CSSM_CSP_CreateSignatureContext(cspHandle, CSSM_ALGID_SHA1WithDSA, NULL, key, &ccHandle) != CSSM_OK) )
|
||||
goto verify_end;
|
||||
|
||||
retval = ( CSSM_VerifyData(ccHandle, plain, 1, CSSM_ALGID_NONE, cipher) == CSSM_OK );
|
||||
|
||||
verify_end:
|
||||
su_freeData( plain, true );
|
||||
su_freeData( cipher, true );
|
||||
if ( ccHandle ) CSSM_DeleteContext( ccHandle );
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static CFDataRef cdsaCreateSHA1Digest( CSSM_CSP_HANDLE cspHandle, const CFDataRef bytes )
|
||||
{
|
||||
CSSM_CC_HANDLE ccHandle = CSSM_INVALID_HANDLE;
|
||||
CSSM_DATA_PTR data = su_createData( bytes ), dgst = su_createData( NULL );
|
||||
CFDataRef retval = NULL;
|
||||
|
||||
if ( !data || !dgst || (CSSM_CSP_CreateDigestContext(cspHandle, CSSM_ALGID_SHA1, &ccHandle) != CSSM_OK) )
|
||||
goto digest_end;
|
||||
|
||||
if ( CSSM_DigestData(ccHandle, data, 1, dgst) == CSSM_OK )
|
||||
retval = CFDataCreate( kCFAllocatorDefault, (const UInt8 *)dgst->Data, (CFIndex)dgst->Length );
|
||||
|
||||
digest_end:
|
||||
su_freeData( data, true );
|
||||
su_freeData( dgst, true );
|
||||
if ( ccHandle ) CSSM_DeleteContext( ccHandle );
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Memory Functions */
|
||||
static void *su_malloc( CSSM_SIZE size, void *ref )
|
||||
{
|
||||
return malloc( size );
|
||||
}
|
||||
|
||||
static void su_free( void *ptr, void *ref )
|
||||
{
|
||||
free( ptr );
|
||||
}
|
||||
|
||||
static void *su_realloc( void *ptr, CSSM_SIZE size, void *ref )
|
||||
{
|
||||
return realloc( ptr, size );
|
||||
}
|
||||
|
||||
static void *su_calloc( uint32 num, CSSM_SIZE size, void *ref )
|
||||
{
|
||||
return calloc( num, size );
|
||||
}
|
||||
|
||||
/* Helper Functions */
|
||||
static CSSM_DATA_PTR su_createData( CFDataRef bytes )
|
||||
{
|
||||
CSSM_DATA_PTR data = su_malloc( sizeof(CSSM_DATA), NULL );
|
||||
if ( !data ) return NULL;
|
||||
data->Data = NULL;
|
||||
data->Length = 0;
|
||||
if ( bytes ) su_copyBytesToData( data, CFDataGetLength(bytes), CFDataGetBytePtr(bytes) );
|
||||
return data;
|
||||
}
|
||||
|
||||
static void su_freeData( CSSM_DATA_PTR data, Boolean freeData )
|
||||
{
|
||||
if ( data ) {
|
||||
if ( freeData && data->Data ) su_free( data->Data, NULL );
|
||||
su_free( data, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
static Boolean su_copyBytesToData( CSSM_DATA_PTR data, CSSM_SIZE size, const uint8 *bytes )
|
||||
{
|
||||
Boolean retval = false;
|
||||
if ( size && bytes ) {
|
||||
if ( (data->Data = su_malloc(size, NULL)) ) {
|
||||
memcpy( data->Data, bytes, size );
|
||||
data->Length = size;
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@@ -12,8 +12,7 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUUnarchiver.h"
|
||||
|
||||
@interface SUDiskImageUnarchiver : SUUnarchiver {
|
||||
}
|
||||
@interface SUDiskImageUnarchiver : SUUnarchiver
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+127
-36
@@ -9,74 +9,165 @@
|
||||
#import "SUDiskImageUnarchiver.h"
|
||||
#import "SUUnarchiver_Private.h"
|
||||
#import "NTSynchronousTask.h"
|
||||
#import "SULog.h"
|
||||
#include <CoreServices/CoreServices.h>
|
||||
|
||||
@implementation SUDiskImageUnarchiver
|
||||
|
||||
+ (BOOL)_canUnarchivePath:(NSString *)path
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
return [[path pathExtension] isEqualToString:@"dmg"];
|
||||
}
|
||||
|
||||
- (void)start
|
||||
// Called on a non-main thread.
|
||||
- (void)extractDMG
|
||||
{
|
||||
[NSThread detachNewThreadSelector:@selector(_extractDMG) toTarget:self withObject:nil];
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
[self extractDMGWithPassword:nil];
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
- (void)_extractDMG
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
// Called on a non-main thread.
|
||||
- (void)extractDMGWithPassword:(NSString *)password
|
||||
{
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
BOOL mountedSuccessfully = NO;
|
||||
|
||||
SULog(@"Extracting %@ as a DMG", archivePath);
|
||||
|
||||
// get a unique mount point path
|
||||
NSString *mountPoint = [@"/Volumes" stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]];
|
||||
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:mountPoint]) goto reportError;
|
||||
NSString *mountPointName = nil;
|
||||
NSString *mountPoint = nil;
|
||||
FSRef tmpRef;
|
||||
do
|
||||
{
|
||||
CFUUIDRef uuid = CFUUIDCreate(NULL);
|
||||
if (uuid)
|
||||
{
|
||||
CFStringRef uuidString = CFUUIDCreateString(NULL, uuid);
|
||||
if (uuidString)
|
||||
{
|
||||
mountPoint = [@"/Volumes" stringByAppendingPathComponent:(NSString*)uuidString];
|
||||
CFRelease(uuidString);
|
||||
}
|
||||
CFRelease(uuid);
|
||||
}
|
||||
}
|
||||
while (noErr == FSPathMakeRefWithOptions((UInt8 *)[mountPoint fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &tmpRef, NULL));
|
||||
|
||||
// create mount point folder
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:mountPoint attributes:nil];
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:mountPoint]) goto reportError;
|
||||
|
||||
NSArray* arguments = [NSArray arrayWithObjects:@"attach", archivePath, @"-mountpoint", mountPoint, @"-noverify", @"-nobrowse", @"-noautoopen", nil];
|
||||
// set up a pipe and push "yes" (y works too), this will accept any license agreement crap
|
||||
// not every .dmg needs this, but this will make sure it works with everyone
|
||||
NSData* yesData = [[[NSData alloc] initWithBytes:"yes\n" length:4] autorelease];
|
||||
NSData *promptData = nil;
|
||||
promptData = [NSData dataWithBytes:"yes\n" length:4];
|
||||
|
||||
NSData *result = [NTSynchronousTask task:@"/usr/bin/hdiutil" directory:@"/" withArgs:arguments input:yesData];
|
||||
if (!result) goto reportError;
|
||||
NSArray* arguments = [NSArray arrayWithObjects:@"attach", archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen", nil];
|
||||
|
||||
NSData *output = nil;
|
||||
NSInteger taskResult = -1;
|
||||
@try
|
||||
{
|
||||
NTSynchronousTask* task = [[NTSynchronousTask alloc] init];
|
||||
|
||||
[task run:@"/usr/bin/hdiutil" directory:@"/" withArgs:arguments input:promptData];
|
||||
|
||||
taskResult = [task result];
|
||||
output = [[[task output] copy] autorelease];
|
||||
[task release];
|
||||
}
|
||||
@catch (NSException *localException)
|
||||
{
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
if (taskResult != 0)
|
||||
{
|
||||
NSString* resultStr = output ? [[[NSString alloc] initWithData: output encoding: NSUTF8StringEncoding] autorelease] : nil;
|
||||
SULog( @"hdiutil failed with code: %d data: <<%@>>", taskResult, resultStr );
|
||||
goto reportError;
|
||||
}
|
||||
mountedSuccessfully = YES;
|
||||
|
||||
// Now that we've mounted it, we need to copy out its contents.
|
||||
NSString *targetPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[mountPoint lastPathComponent]];
|
||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:targetPath attributes:nil]) goto reportError;
|
||||
|
||||
// We can't just copyPath: from the volume root because that always fails. Seems to be a bug.
|
||||
id subpathEnumerator = [[[NSFileManager defaultManager] directoryContentsAtPath:mountPoint] objectEnumerator], currentSubpath;
|
||||
while ((currentSubpath = [subpathEnumerator nextObject]))
|
||||
{
|
||||
NSString *currentFullPath = [mountPoint stringByAppendingPathComponent:currentSubpath];
|
||||
// Don't bother trying (and failing) to copy out files we can't read. That's not going to be the app anyway.
|
||||
if (![[NSFileManager defaultManager] isReadableFileAtPath:currentFullPath]) continue;
|
||||
if (![[NSFileManager defaultManager] copyPath:currentFullPath toPath:[targetPath stringByAppendingPathComponent:currentSubpath] handler:nil])
|
||||
goto reportError;
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
|
||||
// On 10.7 and later we don't want to use the File Manager API and instead want to use NSFileManager (fixes #827357).
|
||||
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
|
||||
NSError *error = nil;
|
||||
NSArray *contents = [manager contentsOfDirectoryAtPath:mountPoint error:&error];
|
||||
if (error)
|
||||
{
|
||||
SULog(@"Couldn't enumerate contents of archive mounted at %@: %@", mountPoint, error);
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
for (NSString *item in contents)
|
||||
{
|
||||
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
|
||||
NSString *toPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
||||
|
||||
// We skip any files in the DMG which are not readable.
|
||||
if (![manager isReadableFileAtPath:fromPath])
|
||||
continue;
|
||||
|
||||
SULog(@"copyItemAtPath:%@ toPath:%@", fromPath, toPath);
|
||||
|
||||
if (![manager copyItemAtPath:fromPath toPath:toPath error:&error])
|
||||
{
|
||||
SULog(@"Couldn't copy item: %@ : %@", error, error.userInfo ? error.userInfo : @"");
|
||||
goto reportError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[self performSelectorOnMainThread:@selector(_notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO];
|
||||
else {
|
||||
FSRef srcRef, dstRef;
|
||||
OSStatus err;
|
||||
err = FSPathMakeRef((UInt8 *)[mountPoint fileSystemRepresentation], &srcRef, NULL);
|
||||
if (err != noErr) goto reportError;
|
||||
err = FSPathMakeRef((UInt8 *)[[archivePath stringByDeletingLastPathComponent] fileSystemRepresentation], &dstRef, NULL);
|
||||
if (err != noErr) goto reportError;
|
||||
|
||||
err = FSCopyObjectSync(&srcRef, &dstRef, (CFStringRef)mountPointName, NULL, kFSFileOperationSkipSourcePermissionErrors);
|
||||
if (err != noErr) goto reportError;
|
||||
}
|
||||
|
||||
[self performSelectorOnMainThread:@selector(notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO];
|
||||
goto finally;
|
||||
|
||||
reportError:
|
||||
[self performSelectorOnMainThread:@selector(_notifyDelegateOfFailure) withObject:nil waitUntilDone:NO];
|
||||
[self performSelectorOnMainThread:@selector(notifyDelegateOfFailure) withObject:nil waitUntilDone:NO];
|
||||
|
||||
finally:
|
||||
if (mountedSuccessfully)
|
||||
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:[NSArray arrayWithObjects:@"detach", mountPoint, @"-force", nil]];
|
||||
else
|
||||
[[NSFileManager defaultManager] removeFileAtPath:mountPoint handler:nil];
|
||||
SULog(@"Can't mount DMG %@",archivePath);
|
||||
[pool drain];
|
||||
}
|
||||
|
||||
- (void)start
|
||||
{
|
||||
[NSThread detachNewThreadSelector:@selector(extractDMG) toTarget:self withObject:nil];
|
||||
}
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
[self _registerImplementation:self];
|
||||
[self registerImplementation:self];
|
||||
}
|
||||
|
||||
- (BOOL)isEncrypted:(NSData*)resultData
|
||||
{
|
||||
BOOL result = NO;
|
||||
if(resultData)
|
||||
{
|
||||
NSString *data = [[[NSString alloc] initWithData:resultData encoding:NSUTF8StringEncoding] autorelease];
|
||||
|
||||
if ((data != nil) && !NSEqualRanges([data rangeOfString:@"passphrase-count"], NSMakeRange(NSNotFound, 0)))
|
||||
{
|
||||
result = YES;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -5,18 +5,26 @@
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Sparkle.h"
|
||||
#import "SUUpdater.h"
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
|
||||
@interface SUHost : NSObject
|
||||
{
|
||||
@private
|
||||
NSBundle *bundle;
|
||||
NSString *defaultsDomain;
|
||||
BOOL usesStandardUserDefaults;
|
||||
}
|
||||
@property (retain, readonly) NSBundle *bundle;
|
||||
|
||||
+ (NSString *)systemVersionString;
|
||||
|
||||
- (id)initWithBundle:(NSBundle *)aBundle;
|
||||
- (NSBundle *)bundle;
|
||||
- (NSString *)bundlePath;
|
||||
- (NSString *)appSupportPath;
|
||||
- (NSString *)installationPath;
|
||||
- (NSString *)name;
|
||||
- (NSString *)version;
|
||||
- (NSString *)displayVersion;
|
||||
@@ -32,4 +40,6 @@
|
||||
- (void)setObject:(id)value forUserDefaultsKey:(NSString *)defaultName;
|
||||
- (BOOL)boolForUserDefaultsKey:(NSString *)defaultName;
|
||||
- (void)setBool:(BOOL)value forUserDefaultsKey:(NSString *)defaultName;
|
||||
- (id)objectForKey:(NSString *)key;
|
||||
- (BOOL)boolForKey:(NSString *)key;
|
||||
@end
|
||||
@@ -7,37 +7,78 @@
|
||||
|
||||
#import "SUHost.h"
|
||||
|
||||
#import "SUConstants.h"
|
||||
#import "SUSystemProfiler.h"
|
||||
#import <sys/mount.h> // For statfs for isRunningOnReadOnlyVolume
|
||||
#include <sys/mount.h> // For statfs for isRunningOnReadOnlyVolume
|
||||
#import "SULog.h"
|
||||
|
||||
@interface SUHost ()
|
||||
@property (retain, readwrite) NSBundle *bundle;
|
||||
@end
|
||||
|
||||
@implementation SUHost
|
||||
@synthesize bundle;
|
||||
|
||||
- (id)initWithBundle:(NSBundle *)aBundle
|
||||
{
|
||||
if (aBundle == nil) aBundle = [NSBundle mainBundle];
|
||||
if ((self = [super init]))
|
||||
{
|
||||
bundle = [aBundle retain];
|
||||
if (aBundle == nil) aBundle = [NSBundle mainBundle];
|
||||
self.bundle = aBundle;
|
||||
if (![bundle bundleIdentifier])
|
||||
SULog(@"Sparkle Error: the bundle being updated at %@ has no CFBundleIdentifier! This will cause preference read/write to not work properly.", bundle);
|
||||
|
||||
defaultsDomain = [[bundle objectForInfoDictionaryKey:SUDefaultsDomainKey] retain];
|
||||
if (!defaultsDomain)
|
||||
defaultsDomain = [[bundle bundleIdentifier] retain];
|
||||
|
||||
// If we're using the main bundle's defaults we'll use the standard user defaults mechanism, otherwise we have to get CF-y.
|
||||
usesStandardUserDefaults = [defaultsDomain isEqualToString:[[NSBundle mainBundle] bundleIdentifier]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[bundle release];
|
||||
[defaultsDomain release];
|
||||
self.bundle = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSBundle *)bundle
|
||||
{
|
||||
return bundle;
|
||||
}
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self bundlePath], [self installationPath]]; }
|
||||
|
||||
- (NSString *)bundlePath
|
||||
{
|
||||
return [bundle bundlePath];
|
||||
}
|
||||
|
||||
- (NSString *)appSupportPath
|
||||
{
|
||||
NSArray *appSupportPaths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
||||
NSString *appSupportPath = nil;
|
||||
if (!appSupportPaths || [appSupportPaths count] == 0)
|
||||
{
|
||||
SULog(@"Failed to find app support directory! Using ~/Library/Application Support...");
|
||||
appSupportPath = [@"~/Library/Application Support" stringByExpandingTildeInPath];
|
||||
}
|
||||
else
|
||||
appSupportPath = [appSupportPaths objectAtIndex:0];
|
||||
appSupportPath = [appSupportPath stringByAppendingPathComponent:[self name]];
|
||||
appSupportPath = [appSupportPath stringByAppendingPathComponent:@".Sparkle"];
|
||||
return appSupportPath;
|
||||
}
|
||||
|
||||
- (NSString *)installationPath
|
||||
{
|
||||
#if NORMALIZE_INSTALLED_APP_NAME
|
||||
// We'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name.
|
||||
NSString *normalizedAppPath = [[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.%@", [bundle objectForInfoDictionaryKey:@"CFBundleName"], [[bundle bundlePath] pathExtension]]];
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:[[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.%@", [bundle objectForInfoDictionaryKey:@"CFBundleName"], [[bundle bundlePath] pathExtension]]]])
|
||||
return normalizedAppPath;
|
||||
#endif
|
||||
return [bundle bundlePath];
|
||||
}
|
||||
|
||||
- (NSString *)name
|
||||
{
|
||||
NSString *name = [bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
||||
@@ -51,7 +92,10 @@
|
||||
|
||||
- (NSString *)version
|
||||
{
|
||||
return [bundle objectForInfoDictionaryKey:@"CFBundleVersion"];
|
||||
NSString *version = [bundle objectForInfoDictionaryKey:@"CFBundleVersion"];
|
||||
if (!version || [version isEqualToString:@""])
|
||||
[NSException raise:@"SUNoVersionException" format:@"This host (%@) has no CFBundleVersion! This attribute is required.", [self bundlePath]];
|
||||
return version;
|
||||
}
|
||||
|
||||
- (NSString *)displayVersion
|
||||
@@ -76,12 +120,17 @@
|
||||
iconPath = [bundle pathForResource:[bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType: nil];
|
||||
NSImage *icon = [[[NSImage alloc] initWithContentsOfFile:iconPath] autorelease];
|
||||
// Use a default icon if none is defined.
|
||||
if (!icon) { icon = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kGenericApplicationIcon)]; }
|
||||
if (!icon) {
|
||||
BOOL isMainBundle = (bundle == [NSBundle mainBundle]);
|
||||
|
||||
NSString *fileType = isMainBundle ? (NSString*)kUTTypeApplication : (NSString*)kUTTypeBundle;
|
||||
icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType];
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
- (BOOL)isRunningOnReadOnlyVolume
|
||||
{
|
||||
{
|
||||
struct statfs statfs_info;
|
||||
statfs([[bundle bundlePath] fileSystemRepresentation], &statfs_info);
|
||||
return (statfs_info.f_flags & MNT_RDONLY);
|
||||
@@ -89,7 +138,13 @@
|
||||
|
||||
- (BOOL)isBackgroundApplication
|
||||
{
|
||||
return [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"LSUIElement"] doubleValue];
|
||||
ProcessSerialNumber PSN;
|
||||
GetCurrentProcess(&PSN);
|
||||
CFDictionaryRef processInfo = ProcessInformationCopyDictionary(&PSN, kProcessDictionaryIncludeAllInformationMask);
|
||||
BOOL isElement = [[(NSDictionary *)processInfo objectForKey:@"LSUIElement"] boolValue];
|
||||
if (processInfo)
|
||||
CFRelease(processInfo);
|
||||
return isElement;
|
||||
}
|
||||
|
||||
- (NSString *)publicDSAKey
|
||||
@@ -101,7 +156,8 @@
|
||||
// More likely, we've got a reference to a Resources file by filename:
|
||||
NSString *keyFilename = [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
|
||||
if (!keyFilename) { return nil; }
|
||||
return [NSString stringWithContentsOfFile:[bundle pathForResource:keyFilename ofType:nil]];
|
||||
NSError *ignoreErr = nil;
|
||||
return [NSString stringWithContentsOfFile:[bundle pathForResource:keyFilename ofType:nil] encoding:NSASCIIStringEncoding error: &ignoreErr];
|
||||
}
|
||||
|
||||
- (NSArray *)systemProfile
|
||||
@@ -121,41 +177,36 @@
|
||||
|
||||
- (id)objectForUserDefaultsKey:(NSString *)defaultName
|
||||
{
|
||||
// Under Tiger, CFPreferencesCopyAppValue doesn't get values from NSRegistratioDomain, so anything
|
||||
// Under Tiger, CFPreferencesCopyAppValue doesn't get values from NSRegistrationDomain, so anything
|
||||
// passed into -[NSUserDefaults registerDefaults:] is ignored. The following line falls
|
||||
// back to using NSUserDefaults, but only if the host bundle is the main bundle.
|
||||
if (bundle == [NSBundle mainBundle])
|
||||
if (usesStandardUserDefaults)
|
||||
return [[NSUserDefaults standardUserDefaults] objectForKey:defaultName];
|
||||
|
||||
CFPropertyListRef obj = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)[bundle bundleIdentifier]);
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED > 1050
|
||||
return [NSMakeCollectable(obj) autorelease];
|
||||
#else
|
||||
return [(id)obj autorelease];
|
||||
#endif
|
||||
CFPropertyListRef obj = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)defaultsDomain);
|
||||
return [(id)CFMakeCollectable(obj) autorelease];
|
||||
}
|
||||
|
||||
- (void)setObject:(id)value forUserDefaultsKey:(NSString *)defaultName;
|
||||
{
|
||||
// If we're using a .app, we'll use the standard user defaults mechanism; otherwise, we have to get CF-y.
|
||||
if (bundle == [NSBundle mainBundle])
|
||||
if (usesStandardUserDefaults)
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setObject:value forKey:defaultName];
|
||||
}
|
||||
else
|
||||
{
|
||||
CFPreferencesSetValue((CFStringRef)defaultName, value, (CFStringRef)[bundle bundleIdentifier], kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSynchronize((CFStringRef)[bundle bundleIdentifier], kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSetValue((CFStringRef)defaultName, value, (CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSynchronize((CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)boolForUserDefaultsKey:(NSString *)defaultName
|
||||
{
|
||||
if (bundle == [NSBundle mainBundle])
|
||||
if (usesStandardUserDefaults)
|
||||
return [[NSUserDefaults standardUserDefaults] boolForKey:defaultName];
|
||||
|
||||
BOOL value;
|
||||
CFPropertyListRef plr = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)[bundle bundleIdentifier]);
|
||||
CFPropertyListRef plr = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)defaultsDomain);
|
||||
if (plr == NULL)
|
||||
value = NO;
|
||||
else
|
||||
@@ -168,38 +219,43 @@
|
||||
|
||||
- (void)setBool:(BOOL)value forUserDefaultsKey:(NSString *)defaultName
|
||||
{
|
||||
// If we're using a .app, we'll use the standard user defaults mechanism; otherwise, we have to get CF-y.
|
||||
if (bundle == [NSBundle mainBundle])
|
||||
if (usesStandardUserDefaults)
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setBool:value forKey:defaultName];
|
||||
}
|
||||
else
|
||||
{
|
||||
CFPreferencesSetValue((CFStringRef)defaultName, (CFBooleanRef)[NSNumber numberWithBool:value], (CFStringRef)[bundle bundleIdentifier], kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSynchronize((CFStringRef)[bundle bundleIdentifier], kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSetValue((CFStringRef)defaultName, (CFBooleanRef)[NSNumber numberWithBool:value], (CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSynchronize((CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
}
|
||||
}
|
||||
|
||||
- (id)objectForKey:(NSString *)key {
|
||||
return [self objectForUserDefaultsKey:key] ? [self objectForUserDefaultsKey:key] : [self objectForInfoDictionaryKey:key];
|
||||
}
|
||||
|
||||
- (BOOL)boolForKey:(NSString *)key {
|
||||
return [self objectForUserDefaultsKey:key] ? [self boolForUserDefaultsKey:key] : [self boolForInfoDictionaryKey:key];
|
||||
}
|
||||
|
||||
+ (NSString *)systemVersionString
|
||||
{
|
||||
// This returns a version string of the form X.Y.Z
|
||||
// There may be a better way to deal with the problem that gestaltSystemVersionMajor
|
||||
// et al. are not defined in 10.3, but this is probably good enough.
|
||||
NSString* verStr = nil;
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
|
||||
SInt32 major, minor, bugfix;
|
||||
OSErr err1 = Gestalt(gestaltSystemVersionMajor, &major);
|
||||
OSErr err2 = Gestalt(gestaltSystemVersionMinor, &minor);
|
||||
OSErr err3 = Gestalt(gestaltSystemVersionBugFix, &bugfix);
|
||||
if (!err1 && !err2 && !err3)
|
||||
{
|
||||
verStr = [NSString stringWithFormat:@"%d.%d.%d", major, minor, bugfix];
|
||||
verStr = [NSString stringWithFormat:@"%ld.%ld.%ld", (long)major, (long)minor, (long)bugfix];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
NSString *versionPlistPath = @"/System/Library/CoreServices/SystemVersion.plist";
|
||||
verStr = [[[NSDictionary dictionaryWithContentsOfFile:versionPlistPath] objectForKey:@"ProductVersion"] retain];
|
||||
verStr = [[NSDictionary dictionaryWithContentsOfFile:versionPlistPath] objectForKey:@"ProductVersion"];
|
||||
}
|
||||
return verStr;
|
||||
}
|
||||
|
||||
+7
-3
@@ -10,11 +10,15 @@
|
||||
#define SUINSTALLER_H
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
|
||||
@class SUHost;
|
||||
@interface SUInstaller : NSObject { }
|
||||
+ (void)installFromUpdateFolder:(NSString *)updateFolder overHost:(SUHost *)host delegate:delegate synchronously:(BOOL)synchronously;
|
||||
+ (void)_finishInstallationWithResult:(BOOL)result host:(SUHost *)host error:(NSError *)error delegate:delegate;
|
||||
@interface SUInstaller : NSObject
|
||||
+ (NSString *) appPathInUpdateFolder:(NSString *)updateFolder forHost:(SUHost *)host;
|
||||
+ (void) installFromUpdateFolder:(NSString *)updateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath delegate:delegate synchronously:(BOOL)synchronously versionComparator:(id <SUVersionComparison>)comparator;
|
||||
+ (void) finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result host:(SUHost *)host error:(NSError *)error delegate:delegate;
|
||||
+ (NSString*) updateFolder;
|
||||
+ (void) notifyDelegateOfFailure: (NSDictionary*)dict;
|
||||
@end
|
||||
|
||||
@interface NSObject (SUInstallerDelegateInformalProtocol)
|
||||
|
||||
+108
-32
@@ -9,14 +9,21 @@
|
||||
#import "SUInstaller.h"
|
||||
#import "SUPlainInstaller.h"
|
||||
#import "SUPackageInstaller.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
|
||||
NSString *SUInstallerPathKey = @"SUInstallerPath";
|
||||
NSString *SUInstallerHostKey = @"SUInstallerHost";
|
||||
NSString *SUInstallerDelegateKey = @"SUInstallerDelegate";
|
||||
|
||||
@implementation SUInstaller
|
||||
|
||||
+ (BOOL)_isAliasFolderAtPath:(NSString *)path
|
||||
static NSString* sUpdateFolder = nil;
|
||||
|
||||
+(NSString*) updateFolder
|
||||
{
|
||||
return sUpdateFolder;
|
||||
}
|
||||
|
||||
+ (BOOL)isAliasFolderAtPath:(NSString *)path
|
||||
{
|
||||
FSRef fileRef;
|
||||
OSStatus err = noErr;
|
||||
@@ -35,16 +42,23 @@ NSString *SUInstallerDelegateKey = @"SUInstallerDelegate";
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
+ (void)installFromUpdateFolder:(NSString *)updateFolder overHost:(SUHost *)host delegate:delegate synchronously:(BOOL)synchronously
|
||||
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr
|
||||
{
|
||||
// Search subdirectories for the application
|
||||
NSString *currentFile, *newAppDownloadPath = nil, *bundleFileName = [[host bundlePath] lastPathComponent], *alternateBundleFileName = [[host name] stringByAppendingPathExtension:[[host bundlePath] pathExtension]];
|
||||
// Search subdirectories for the application
|
||||
NSString *currentFile,
|
||||
*newAppDownloadPath = nil,
|
||||
*bundleFileName = [[host bundlePath] lastPathComponent],
|
||||
*alternateBundleFileName = [[host name] stringByAppendingPathExtension:[[host bundlePath] pathExtension]];
|
||||
BOOL isPackage = NO;
|
||||
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:updateFolder];
|
||||
NSString *fallbackPackagePath = nil;
|
||||
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath: inUpdateFolder];
|
||||
|
||||
[sUpdateFolder release];
|
||||
sUpdateFolder = [inUpdateFolder retain];
|
||||
|
||||
while ((currentFile = [dirEnum nextObject]))
|
||||
{
|
||||
NSString *currentPath = [updateFolder stringByAppendingPathComponent:currentFile];
|
||||
NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile];
|
||||
if ([[currentFile lastPathComponent] isEqualToString:bundleFileName] ||
|
||||
[[currentFile lastPathComponent] isEqualToString:alternateBundleFileName]) // We found one!
|
||||
{
|
||||
@@ -52,55 +66,117 @@ NSString *SUInstallerDelegateKey = @"SUInstallerDelegate";
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
}
|
||||
else if (([[currentFile pathExtension] isEqualToString:@"pkg"] || [[currentFile pathExtension] isEqualToString:@"mpkg"]) &&
|
||||
[[[currentFile lastPathComponent] stringByDeletingPathExtension] isEqualToString:[bundleFileName stringByDeletingPathExtension]])
|
||||
else if ([[currentFile pathExtension] isEqualToString:@"pkg"] ||
|
||||
[[currentFile pathExtension] isEqualToString:@"mpkg"])
|
||||
{
|
||||
isPackage = YES;
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
if ([[[currentFile lastPathComponent] stringByDeletingPathExtension] isEqualToString:[bundleFileName stringByDeletingPathExtension]])
|
||||
{
|
||||
isPackage = YES;
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remember any other non-matching packages we have seen should we need to use one of them as a fallback.
|
||||
fallbackPackagePath = currentPath;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try matching on bundle identifiers in case the user has changed the name of the host app
|
||||
NSBundle *incomingBundle = [NSBundle bundleWithPath:currentPath];
|
||||
if(incomingBundle && [[incomingBundle bundleIdentifier] isEqualToString:[[host bundle] bundleIdentifier]])
|
||||
{
|
||||
isPackage = NO;
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Some DMGs have symlinks into /Applications! That's no good! And there's no point in looking in bundles.
|
||||
if ([self _isAliasFolderAtPath:currentPath] ||
|
||||
[[currentFile pathExtension] isEqualToString:[[host bundlePath] pathExtension]] ||
|
||||
[[currentFile pathExtension] isEqualToString:@"pkg"] ||
|
||||
[[currentFile pathExtension] isEqualToString:@"mpkg"])
|
||||
{
|
||||
// Some DMGs have symlinks into /Applications! That's no good!
|
||||
if ([self isAliasFolderAtPath:currentPath])
|
||||
[dirEnum skipDescendents];
|
||||
}
|
||||
}
|
||||
|
||||
// We don't have a valid path. Try to use the fallback package.
|
||||
|
||||
if (newAppDownloadPath == nil && fallbackPackagePath != nil)
|
||||
{
|
||||
isPackage = YES;
|
||||
newAppDownloadPath = fallbackPackagePath;
|
||||
}
|
||||
|
||||
if (isPackagePtr) *isPackagePtr = isPackage;
|
||||
return newAppDownloadPath;
|
||||
}
|
||||
|
||||
+ (NSString *)appPathInUpdateFolder:(NSString *)updateFolder forHost:(SUHost *)host
|
||||
{
|
||||
BOOL isPackage = NO;
|
||||
NSString *path = [self installSourcePathInUpdateFolder:updateFolder forHost:host isPackage:&isPackage];
|
||||
return isPackage ? nil : path;
|
||||
}
|
||||
|
||||
+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath delegate:delegate synchronously:(BOOL)synchronously versionComparator:(id <SUVersionComparison>)comparator
|
||||
{
|
||||
BOOL isPackage = NO;
|
||||
NSString *newAppDownloadPath = [self installSourcePathInUpdateFolder:inUpdateFolder forHost:host isPackage:&isPackage];
|
||||
|
||||
if (newAppDownloadPath == nil)
|
||||
{
|
||||
[self _finishInstallationWithResult:NO host:host error:[NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingUpdateError userInfo:[NSDictionary dictionaryWithObject:@"Couldn't find an appropriate update in the downloaded package." forKey:NSLocalizedDescriptionKey]] delegate:delegate];
|
||||
[self finishInstallationToPath:installationPath withResult:NO host:host error:[NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingUpdateError userInfo:[NSDictionary dictionaryWithObject:@"Couldn't find an appropriate update in the downloaded package." forKey:NSLocalizedDescriptionKey]] delegate:delegate];
|
||||
}
|
||||
else
|
||||
{
|
||||
[(isPackage ? [SUPackageInstaller class] : [SUPlainInstaller class]) performInstallationWithPath:newAppDownloadPath host:host delegate:delegate synchronously:synchronously];
|
||||
[(isPackage ? [SUPackageInstaller class] : [SUPlainInstaller class]) performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host delegate:delegate synchronously:synchronously versionComparator:comparator];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)_mdimportHost:(SUHost *)host
|
||||
+ (void)mdimportInstallationPath:(NSString *)installationPath
|
||||
{
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!
|
||||
|
||||
SULog( @"mdimporting" );
|
||||
|
||||
NSTask *mdimport = [[[NSTask alloc] init] autorelease];
|
||||
[mdimport setLaunchPath:@"/usr/bin/mdimport"];
|
||||
[mdimport setArguments:[NSArray arrayWithObject:[host bundlePath]]];
|
||||
[mdimport launch];
|
||||
[mdimport setArguments:[NSArray arrayWithObject:installationPath]];
|
||||
@try
|
||||
{
|
||||
[mdimport launch];
|
||||
[mdimport waitUntilExit];
|
||||
}
|
||||
@catch (NSException * launchException)
|
||||
{
|
||||
// No big deal.
|
||||
SULog(@"Sparkle Error: %@", [launchException description]);
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)_finishInstallationWithResult:(BOOL)result host:(SUHost *)host error:(NSError *)error delegate:delegate
|
||||
|
||||
#define SUNotifyDictHostKey @"SUNotifyDictHost"
|
||||
#define SUNotifyDictErrorKey @"SUNotifyDictError"
|
||||
#define SUNotifyDictDelegateKey @"SUNotifyDictDelegate"
|
||||
|
||||
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result host:(SUHost *)host error:(NSError *)error delegate:delegate
|
||||
{
|
||||
if (result == YES)
|
||||
if (result)
|
||||
{
|
||||
[self _mdimportHost:host];
|
||||
[self mdimportInstallationPath:installationPath];
|
||||
if ([delegate respondsToSelector:@selector(installerFinishedForHost:)])
|
||||
[delegate installerFinishedForHost:host];
|
||||
[delegate performSelectorOnMainThread: @selector(installerFinishedForHost:) withObject: host waitUntilDone: NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(installerForHost:failedWithError:)])
|
||||
[delegate installerForHost:host failedWithError:error];
|
||||
[self performSelectorOnMainThread: @selector(notifyDelegateOfFailure:) withObject: [NSDictionary dictionaryWithObjectsAndKeys: host, SUNotifyDictHostKey, error, SUNotifyDictErrorKey, delegate, SUNotifyDictDelegateKey, nil] waitUntilDone: NO];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+(void) notifyDelegateOfFailure: (NSDictionary*)dict
|
||||
{
|
||||
[[dict objectForKey: SUNotifyDictDelegateKey] installerForHost: [dict objectForKey: SUNotifyDictHostKey] failedWithError: [dict objectForKey: SUNotifyDictErrorKey]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* SULog.h
|
||||
* EyeTV
|
||||
*
|
||||
* Created by Uli Kusterer on 12/03/2009.
|
||||
* Copyright 2008 Elgato Systems GmbH. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
Log output for troubleshooting Sparkle failures on end-user machines.
|
||||
Your tech support will hug you if you tell them about this.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Headers:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Prototypes:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void SUClearLog( void );
|
||||
void SULog( NSString* format, ... );
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* SULog.m
|
||||
* EyeTV
|
||||
*
|
||||
* Created by Uli Kusterer on 12/03/2009.
|
||||
* Copyright 2009 Elgato Systems GmbH. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Headers:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "SULog.h"
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constants:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define LOG_FILE_PATH @"~/Library/Logs/SparkleUpdateLog.log"
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SUClearLog:
|
||||
// Erase the log at the start of an update. We don't want to litter the
|
||||
// user's hard disk with logging data that's mostly unused, so each app
|
||||
// should clear the log before it starts updating, so only the most recent
|
||||
// update is kept around.
|
||||
//
|
||||
// TAKES:
|
||||
// sender - Object that sent this message, typically of type X.
|
||||
//
|
||||
// GIVES:
|
||||
// param - who owns the returned value?
|
||||
// result - same here.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void SUClearLog( void )
|
||||
{
|
||||
FILE* logfile = fopen([[LOG_FILE_PATH stringByExpandingTildeInPath] fileSystemRepresentation],"w");
|
||||
if( logfile )
|
||||
fclose(logfile);
|
||||
else
|
||||
NSLog(@"----- Sparkle Log -----");
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SULog:
|
||||
// Like NSLog, but logs to one specific log file. Each line is prefixed
|
||||
// with the current date and time, to help in regressing issues.
|
||||
//
|
||||
// TAKES:
|
||||
// format - NSLog/printf-style format string.
|
||||
// ... - More parameters depending on format string's contents.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void SULog( NSString* format, ... )
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
NSString* theStr = [[[NSString alloc] initWithFormat: format arguments: ap] autorelease];
|
||||
FILE* logfile = fopen([[LOG_FILE_PATH stringByExpandingTildeInPath] fileSystemRepresentation],"a");
|
||||
if( !logfile )
|
||||
NSLog( @"%@",theStr );
|
||||
else
|
||||
{
|
||||
theStr = [NSString stringWithFormat: @"%@: %@", [NSDate date], theStr];
|
||||
NSData* theData = [theStr dataUsingEncoding: NSUTF8StringEncoding];
|
||||
char newlineChar = '\n';
|
||||
fwrite( [theData bytes], 1, [theData length], logfile );
|
||||
fwrite( &newlineChar, 1, 1, logfile ); // Append a newline.
|
||||
fclose( logfile );
|
||||
logfile = NULL;
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
+25
-17
@@ -4,6 +4,20 @@
|
||||
<dict>
|
||||
<key>ADP2,1</key>
|
||||
<string>Developer Transition Kit</string>
|
||||
<key>iMac1,1</key>
|
||||
<string>iMac G3 (Rev A-D)</string>
|
||||
<key>iMac4,1</key>
|
||||
<string>iMac (Core Duo)</string>
|
||||
<key>iMac4,2</key>
|
||||
<string>iMac for Education (17-inch, Core Duo)</string>
|
||||
<key>iMac5,1</key>
|
||||
<string>iMac (Core 2 Duo, 17 or 20 inch, SuperDrive)</string>
|
||||
<key>iMac5,2</key>
|
||||
<string>iMac (Core 2 Duo, 17 inch, Combo Drive)</string>
|
||||
<key>iMac6,1</key>
|
||||
<string>iMac (Core 2 Duo, 24 inch, SuperDrive)</string>
|
||||
<key>iMac8,1</key>
|
||||
<string>iMac (April 2008)</string>
|
||||
<key>MacBook1,1</key>
|
||||
<string>MacBook (Core Duo)</string>
|
||||
<key>MacBook2,1</key>
|
||||
@@ -12,6 +26,10 @@
|
||||
<string>MacBook (Core 2 Duo Feb 2008)</string>
|
||||
<key>MacBookAir1,1</key>
|
||||
<string>MacBook Air (January 2008)</string>
|
||||
<key>MacBookAir2,1</key>
|
||||
<string>MacBook Air (June 2009)</string>
|
||||
<key>MacBookAir3,1</key>
|
||||
<string>MacBook Air (October 2010)</string>
|
||||
<key>MacBookPro1,1</key>
|
||||
<string>MacBook Pro Core Duo (15-inch)</string>
|
||||
<key>MacBookPro1,2</key>
|
||||
@@ -26,14 +44,18 @@
|
||||
<string>MacBook Pro Core 2 Duo (17-inch HD, Core 2 Duo)</string>
|
||||
<key>MacBookPro4,1</key>
|
||||
<string>MacBook Pro (Core 2 Duo Feb 2008)</string>
|
||||
<key>Macmini1,1</key>
|
||||
<string>Mac Mini (Core Solo/Duo)</string>
|
||||
<key>MacPro1,1</key>
|
||||
<string>Mac Pro (four-core)</string>
|
||||
<key>MacPro2,1</key>
|
||||
<string>Mac Pro (eight-core)</string>
|
||||
<key>MacPro3,1</key>
|
||||
<string>Mac Pro (January 2008 4- or 8- core "Harpertown")</string>
|
||||
<key>Macmini1,1</key>
|
||||
<string>Mac Mini (Core Solo/Duo)</string>
|
||||
<string>Mac Pro (January 2008 4- or 8- core "Harpertown")</string>
|
||||
<key>MacPro4,1</key>
|
||||
<string>Mac Pro (March 2009)</string>
|
||||
<key>MacPro5,1</key>
|
||||
<string>Mac Pro (August 2010)</string>
|
||||
<key>PowerBook1,1</key>
|
||||
<string>PowerBook G3</string>
|
||||
<key>PowerBook2,1</key>
|
||||
@@ -156,19 +178,5 @@
|
||||
<string>Xserve (Intel Xeon)</string>
|
||||
<key>Xserve2,1</key>
|
||||
<string>Xserve (January 2008 quad-core)</string>
|
||||
<key>iMac1,1</key>
|
||||
<string>iMac G3 (Rev A-D)</string>
|
||||
<key>iMac4,1</key>
|
||||
<string>iMac (Core Duo)</string>
|
||||
<key>iMac4,2</key>
|
||||
<string>iMac for Education (17-inch, Core Duo)</string>
|
||||
<key>iMac5,1</key>
|
||||
<string>iMac (Core 2 Duo, 17 or 20 inch, SuperDrive)</string>
|
||||
<key>iMac5,2</key>
|
||||
<string>iMac (Core 2 Duo, 17 inch, Combo Drive)</string>
|
||||
<key>iMac6,1</key>
|
||||
<string>iMac (Core 2 Duo, 24 inch, SuperDrive)</string>
|
||||
<key>iMac8,1</key>
|
||||
<string>iMac (April 2008)</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -9,11 +9,14 @@
|
||||
#ifndef SUPACKAGEINSTALLER_H
|
||||
#define SUPACKAGEINSTALLER_H
|
||||
|
||||
#import "Sparkle.h"
|
||||
#import "SUUpdater.h"
|
||||
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUPlainInstaller.h"
|
||||
|
||||
@interface SUPackageInstaller : SUPlainInstaller { }
|
||||
+ (void)installPath:(NSString *)path overHost:(SUHost *)bundle delegate:delegate;
|
||||
@interface SUPackageInstaller : SUPlainInstaller
|
||||
@end
|
||||
|
||||
#endif
|
||||
+46
-12
@@ -7,26 +7,60 @@
|
||||
//
|
||||
|
||||
#import "SUPackageInstaller.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUConstants.h"
|
||||
|
||||
NSString *SUPackageInstallerCommandKey = @"SUPackageInstallerCommand";
|
||||
NSString *SUPackageInstallerArgumentsKey = @"SUPackageInstallerArguments";
|
||||
NSString *SUPackageInstallerHostKey = @"SUPackageInstallerHost";
|
||||
NSString *SUPackageInstallerDelegateKey = @"SUPackageInstallerDelegate";
|
||||
NSString *SUPackageInstallerInstallationPathKey = @"SUPackageInstallerInstallationPathKey";
|
||||
|
||||
@implementation SUPackageInstaller
|
||||
|
||||
+ (void)installPath:(NSString *)path overHost:(SUHost *)bundle delegate:delegate
|
||||
+ (void)finishInstallationWithInfo:(NSDictionary *)info
|
||||
{
|
||||
NSError *error = nil;
|
||||
BOOL result = YES;
|
||||
[self finishInstallationToPath:[info objectForKey:SUPackageInstallerInstallationPathKey] withResult:YES host:[info objectForKey:SUPackageInstallerHostKey] error:nil delegate:[info objectForKey:SUPackageInstallerDelegateKey]];
|
||||
}
|
||||
|
||||
+ (void)performInstallationWithInfo:(NSDictionary *)info
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSString *installerPath = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.apple.installer"];
|
||||
installerPath = [installerPath stringByAppendingString:@"/Contents/MacOS/Installer"];
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:installerPath])
|
||||
{
|
||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingInstallerToolError userInfo:[NSDictionary dictionaryWithObject:@"Couldn't find Apple's installer tool!" forKey:NSLocalizedDescriptionKey]];
|
||||
result = NO;
|
||||
}
|
||||
NSTask *installer = [NSTask launchedTaskWithLaunchPath:installerPath arguments:[NSArray arrayWithObjects:path, nil]];
|
||||
NSTask *installer = [NSTask launchedTaskWithLaunchPath:[info objectForKey:SUPackageInstallerCommandKey] arguments:[info objectForKey:SUPackageInstallerArgumentsKey]];
|
||||
[installer waitUntilExit];
|
||||
|
||||
// Known bug: if the installation fails or is canceled, Sparkle goes ahead and restarts, thinking everything is fine.
|
||||
[self _finishInstallationWithResult:result host:bundle error:error delegate:delegate];
|
||||
[self performSelectorOnMainThread:@selector(finishInstallationWithInfo:) withObject:info waitUntilDone:NO];
|
||||
|
||||
[pool drain];
|
||||
}
|
||||
|
||||
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host delegate:delegate synchronously:(BOOL)synchronously versionComparator:(id <SUVersionComparison>)comparator
|
||||
{
|
||||
NSString *command;
|
||||
NSArray *args;
|
||||
|
||||
// Run installer using the "open" command to ensure it is launched in front of current application.
|
||||
// -W = wait until the app has quit.
|
||||
// -n = Open another instance if already open.
|
||||
// -b = app bundle identifier
|
||||
command = @"/usr/bin/open";
|
||||
args = [NSArray arrayWithObjects:@"-W", @"-n", @"-b", @"com.apple.installer", path, nil];
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:command])
|
||||
{
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingInstallerToolError userInfo:[NSDictionary dictionaryWithObject:@"Couldn't find Apple's installer tool!" forKey:NSLocalizedDescriptionKey]];
|
||||
[self finishInstallationToPath:installationPath withResult:NO host:host error:error delegate:delegate];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:command, SUPackageInstallerCommandKey, args, SUPackageInstallerArgumentsKey, host, SUPackageInstallerHostKey, delegate, SUPackageInstallerDelegateKey, installationPath, SUPackageInstallerInstallationPathKey, nil];
|
||||
if (synchronously)
|
||||
[self performInstallationWithInfo:info];
|
||||
else
|
||||
[NSThread detachNewThreadSelector:@selector(performInstallationWithInfo:) toTarget:self withObject:info];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+1
-3
@@ -12,9 +12,7 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUUnarchiver.h"
|
||||
|
||||
@interface SUPipedUnarchiver : SUUnarchiver {
|
||||
|
||||
}
|
||||
@interface SUPipedUnarchiver : SUUnarchiver
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+56
-27
@@ -8,21 +8,21 @@
|
||||
|
||||
#import "SUPipedUnarchiver.h"
|
||||
#import "SUUnarchiver_Private.h"
|
||||
#import "SULog.h"
|
||||
|
||||
|
||||
@implementation SUPipedUnarchiver
|
||||
|
||||
+ (SEL)_selectorConformingToTypeOfPath:(NSString *)path
|
||||
+ (SEL)selectorConformingToTypeOfPath:(NSString *)path
|
||||
{
|
||||
static NSDictionary *typeSelectorDictionary;
|
||||
if (!typeSelectorDictionary)
|
||||
typeSelectorDictionary = [[NSDictionary dictionaryWithObjectsAndKeys:@"_extractZIP", @".zip", @"_extractTAR", @".tar",
|
||||
@"_extractTGZ", @".tar.gz", @"_extractTGZ", @".tgz",
|
||||
@"_extractTBZ", @".tar.bz2", @"_extractTBZ", @".tbz", nil] retain];
|
||||
typeSelectorDictionary = [[NSDictionary dictionaryWithObjectsAndKeys:@"extractZIP", @".zip", @"extractTAR", @".tar",
|
||||
@"extractTGZ", @".tar.gz", @"extractTGZ", @".tgz",
|
||||
@"extractTBZ", @".tar.bz2", @"extractTBZ", @".tbz", nil] retain];
|
||||
|
||||
NSString *lastPathComponent = [path lastPathComponent];
|
||||
NSEnumerator *typeEnumerator = [typeSelectorDictionary keyEnumerator];
|
||||
id currentType;
|
||||
while ((currentType = [typeEnumerator nextObject]))
|
||||
for (id currentType in typeSelectorDictionary)
|
||||
{
|
||||
if ([currentType length] > [lastPathComponent length]) continue;
|
||||
if ([[lastPathComponent substringFromIndex:[lastPathComponent length] - [currentType length]] isEqualToString:currentType])
|
||||
@@ -33,22 +33,28 @@
|
||||
|
||||
- (void)start
|
||||
{
|
||||
[NSThread detachNewThreadSelector:[[self class] _selectorConformingToTypeOfPath:archivePath] toTarget:self withObject:nil];
|
||||
[NSThread detachNewThreadSelector:[[self class] selectorConformingToTypeOfPath:archivePath] toTarget:self withObject:nil];
|
||||
}
|
||||
|
||||
+ (BOOL)_canUnarchivePath:(NSString *)path
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
return ([self _selectorConformingToTypeOfPath:path] != nil);
|
||||
return ([self selectorConformingToTypeOfPath:path] != nil);
|
||||
}
|
||||
|
||||
// This method abstracts the types that use a command line tool piping data from stdin.
|
||||
- (void)_extractArchivePipingDataToCommand:(NSString *)command
|
||||
- (void)extractArchivePipingDataToCommand:(NSString *)command
|
||||
{
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
FILE *fp = NULL, *cmdFP = NULL;
|
||||
char *oldDestinationString = NULL;
|
||||
|
||||
SULog(@"Extracting %@ using '%@'",archivePath,command);
|
||||
|
||||
// Get the file size.
|
||||
NSNumber *fs = [[[NSFileManager defaultManager] fileAttributesAtPath:archivePath traverseLink:NO] objectForKey:NSFileSize];
|
||||
NSNumber *fs = [[[NSFileManager defaultManager] attributesOfItemAtPath:archivePath error:nil] objectForKey:NSFileSize];
|
||||
if (fs == nil) goto reportError;
|
||||
|
||||
// Thank you, Allan Odgaard!
|
||||
@@ -56,54 +62,77 @@
|
||||
fp = fopen([archivePath fileSystemRepresentation], "r");
|
||||
if (!fp) goto reportError;
|
||||
|
||||
oldDestinationString = getenv("DESTINATION");
|
||||
setenv("DESTINATION", [[archivePath stringByDeletingLastPathComponent] fileSystemRepresentation], 1);
|
||||
cmdFP = popen([command fileSystemRepresentation], "w");
|
||||
size_t written;
|
||||
if (!cmdFP) goto reportError;
|
||||
|
||||
char buf[32*1024];
|
||||
long len;
|
||||
size_t len;
|
||||
while((len = fread(buf, 1, 32*1024, fp)))
|
||||
{
|
||||
fwrite(buf, 1, len, cmdFP);
|
||||
[self performSelectorOnMainThread:@selector(_notifyDelegateOfExtractedLength:) withObject:[NSNumber numberWithLong:len] waitUntilDone:NO];
|
||||
written = fwrite(buf, 1, len, cmdFP);
|
||||
if( written < len )
|
||||
{
|
||||
pclose(cmdFP);
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
[self performSelectorOnMainThread:@selector(notifyDelegateOfExtractedLength:) withObject:[NSNumber numberWithUnsignedLong:len] waitUntilDone:NO];
|
||||
}
|
||||
pclose(cmdFP);
|
||||
|
||||
[self performSelectorOnMainThread:@selector(_notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO];
|
||||
if( ferror( fp ) )
|
||||
goto reportError;
|
||||
|
||||
[self performSelectorOnMainThread:@selector(notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO];
|
||||
goto finally;
|
||||
|
||||
reportError:
|
||||
[self performSelectorOnMainThread:@selector(_notifyDelegateOfFailure) withObject:nil waitUntilDone:NO];
|
||||
[self performSelectorOnMainThread:@selector(notifyDelegateOfFailure) withObject:nil waitUntilDone:NO];
|
||||
|
||||
finally:
|
||||
if (fp)
|
||||
fclose(fp);
|
||||
[pool drain];
|
||||
if (oldDestinationString)
|
||||
setenv("DESTINATION", oldDestinationString, 1);
|
||||
else
|
||||
unsetenv("DESTINATION");
|
||||
[pool release];
|
||||
}
|
||||
|
||||
- (void)_extractTAR
|
||||
- (void)extractTAR
|
||||
{
|
||||
return [self _extractArchivePipingDataToCommand:@"tar -xC \"$DESTINATION\""];
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
|
||||
return [self extractArchivePipingDataToCommand:@"tar -xC \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
- (void)_extractTGZ
|
||||
- (void)extractTGZ
|
||||
{
|
||||
return [self _extractArchivePipingDataToCommand:@"tar -zxC \"$DESTINATION\""];
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
|
||||
return [self extractArchivePipingDataToCommand:@"tar -zxC \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
- (void)_extractTBZ
|
||||
- (void)extractTBZ
|
||||
{
|
||||
return [self _extractArchivePipingDataToCommand:@"tar -jxC \"$DESTINATION\""];
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
|
||||
return [self extractArchivePipingDataToCommand:@"tar -jxC \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
- (void)_extractZIP
|
||||
- (void)extractZIP
|
||||
{
|
||||
return [self _extractArchivePipingDataToCommand:@"ditto -x -k - \"$DESTINATION\""];
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
|
||||
return [self extractArchivePipingDataToCommand:@"ditto -x -k - \"$DESTINATION\""];
|
||||
}
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
[self _registerImplementation:self];
|
||||
[self registerImplementation:self];
|
||||
}
|
||||
|
||||
@end
|
||||
+11
-4
@@ -9,11 +9,18 @@
|
||||
#ifndef SUPLAININSTALLER_H
|
||||
#define SUPLAININSTALLER_H
|
||||
|
||||
#import "Sparkle.h"
|
||||
#import "SUInstaller.h"
|
||||
#import "SUUpdater.h"
|
||||
|
||||
@interface SUPlainInstaller : SUInstaller { }
|
||||
+ (void)performInstallationWithPath:(NSString *)path host:(SUHost *)host delegate:delegate synchronously:(BOOL)synchronously;
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUInstaller.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
|
||||
@class SUHost;
|
||||
|
||||
@interface SUPlainInstaller : SUInstaller
|
||||
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host delegate:delegate synchronously:(BOOL)synchronously versionComparator:(id <SUVersionComparison>)comparator;
|
||||
@end
|
||||
|
||||
#endif
|
||||
+53
-13
@@ -8,36 +8,76 @@
|
||||
|
||||
#import "SUPlainInstaller.h"
|
||||
#import "SUPlainInstallerInternals.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SUHost.h"
|
||||
|
||||
extern NSString *SUInstallerPathKey;
|
||||
extern NSString *SUInstallerHostKey;
|
||||
extern NSString *SUInstallerDelegateKey;
|
||||
static NSString * const SUInstallerPathKey = @"SUInstallerPath";
|
||||
static NSString * const SUInstallerTargetPathKey = @"SUInstallerTargetPath";
|
||||
static NSString * const SUInstallerTempNameKey = @"SUInstallerTempName";
|
||||
static NSString * const SUInstallerHostKey = @"SUInstallerHost";
|
||||
static NSString * const SUInstallerDelegateKey = @"SUInstallerDelegate";
|
||||
static NSString * const SUInstallerResultKey = @"SUInstallerResult";
|
||||
static NSString * const SUInstallerErrorKey = @"SUInstallerError";
|
||||
static NSString * const SUInstallerInstallationPathKey = @"SUInstallerInstallationPath";
|
||||
|
||||
@implementation SUPlainInstaller
|
||||
|
||||
+ (void)installPath:(NSString *)path overHost:(SUHost *)bundle delegate:delegate
|
||||
+ (void)finishInstallationWithInfo:(NSDictionary *)info
|
||||
{
|
||||
NSError *error;
|
||||
BOOL result = [self copyPathWithAuthentication:path overPath:[bundle bundlePath] error:&error];
|
||||
[self _finishInstallationWithResult:result host:bundle error:error delegate:delegate];
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!
|
||||
|
||||
[self finishInstallationToPath:[info objectForKey:SUInstallerInstallationPathKey] withResult:[[info objectForKey:SUInstallerResultKey] boolValue] host:[info objectForKey:SUInstallerHostKey] error:[info objectForKey:SUInstallerErrorKey] delegate:[info objectForKey:SUInstallerDelegateKey]];
|
||||
}
|
||||
|
||||
+ (void)_performInstallationWithInfo:(NSDictionary *)info
|
||||
+ (void)performInstallationWithInfo:(NSDictionary *)info
|
||||
{
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
[self installPath:[info objectForKey:SUInstallerPathKey] overHost:[info objectForKey:SUInstallerHostKey] delegate:[info objectForKey:SUInstallerDelegateKey]];
|
||||
NSError *error = nil;
|
||||
|
||||
NSString * oldPath = [[info objectForKey:SUInstallerHostKey] bundlePath];
|
||||
NSString * installationPath = [info objectForKey:SUInstallerInstallationPathKey];
|
||||
BOOL result = [self copyPathWithAuthentication:[info objectForKey:SUInstallerPathKey] overPath: installationPath temporaryName:[info objectForKey:SUInstallerTempNameKey] error:&error];
|
||||
|
||||
if( result )
|
||||
{
|
||||
BOOL haveOld = [[NSFileManager defaultManager] fileExistsAtPath: oldPath];
|
||||
BOOL differentFromNew = ![oldPath isEqualToString: installationPath];
|
||||
if( haveOld && differentFromNew )
|
||||
[self _movePathToTrash: oldPath]; // On success, trash old copy if there's still one due to renaming.
|
||||
}
|
||||
NSMutableDictionary *mutableInfo = [[info mutableCopy] autorelease];
|
||||
[mutableInfo setObject:[NSNumber numberWithBool:result] forKey:SUInstallerResultKey];
|
||||
[mutableInfo setObject:installationPath forKey:SUInstallerInstallationPathKey];
|
||||
if (!result && error)
|
||||
[mutableInfo setObject:error forKey:SUInstallerErrorKey];
|
||||
[self performSelectorOnMainThread:@selector(finishInstallationWithInfo:) withObject:mutableInfo waitUntilDone:NO];
|
||||
|
||||
[pool drain];
|
||||
}
|
||||
|
||||
+ (void)performInstallationWithPath:(NSString *)path host:(SUHost *)host delegate:delegate synchronously:(BOOL)synchronously;
|
||||
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host delegate:delegate synchronously:(BOOL)synchronously versionComparator:(id <SUVersionComparison>)comparator
|
||||
{
|
||||
NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:path, SUInstallerPathKey, host, SUInstallerHostKey, delegate, SUInstallerDelegateKey, nil];
|
||||
// Prevent malicious downgrades:
|
||||
#if !PERMIT_AUTOMATED_DOWNGRADES
|
||||
if ([comparator compareVersion:[host version] toVersion:[[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]] == NSOrderedDescending)
|
||||
{
|
||||
NSString * errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Possible attack in progress! Attempting to \"upgrade\" from %@ to %@. Aborting update.", [host version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]];
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
|
||||
[self finishInstallationToPath:installationPath withResult:NO host:host error:error delegate:delegate];
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
NSString *targetPath = [host installationPath];
|
||||
NSString *tempName = [self temporaryNameForPath:targetPath];
|
||||
NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:path, SUInstallerPathKey, targetPath, SUInstallerTargetPathKey, tempName, SUInstallerTempNameKey, host, SUInstallerHostKey, delegate, SUInstallerDelegateKey, installationPath, SUInstallerInstallationPathKey, nil];
|
||||
if (synchronously)
|
||||
[self _performInstallationWithInfo:info];
|
||||
[self performInstallationWithInfo:info];
|
||||
else
|
||||
[NSThread detachNewThreadSelector:@selector(_performInstallationWithInfo:) toTarget:self withObject:info];
|
||||
[NSThread detachNewThreadSelector:@selector(performInstallationWithInfo:) toTarget:self withObject:info];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -12,7 +12,11 @@
|
||||
#import "SUPlainInstaller.h"
|
||||
|
||||
@interface SUPlainInstaller (Internals)
|
||||
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst error:(NSError **)error;
|
||||
+ (NSString *)temporaryNameForPath:(NSString *)path;
|
||||
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)tmp error:(NSError **)error;
|
||||
+ (void)_movePathToTrash:(NSString *)path;
|
||||
+ (BOOL)_removeFileAtPath:(NSString *)path error: (NSError**)error;
|
||||
+ (BOOL)_removeFileAtPathWithForcedAuthentication:(NSString *)src error:(NSError **)error;
|
||||
@end
|
||||
|
||||
#endif
|
||||
+375
-140
@@ -6,14 +6,23 @@
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Sparkle.h"
|
||||
#import "SUPlainInstallerInternals.h"
|
||||
#import "SUUpdater.h"
|
||||
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUPlainInstallerInternals.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <Security/Security.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#import <Security/Security.h>
|
||||
#import <sys/stat.h>
|
||||
#import <sys/wait.h>
|
||||
#import <dirent.h>
|
||||
#import <unistd.h>
|
||||
|
||||
@interface SUPlainInstaller (MMExtendedAttributes)
|
||||
// Removes the directory tree rooted at |root| from the file quarantine.
|
||||
@@ -38,9 +47,12 @@
|
||||
@end
|
||||
|
||||
// Authorization code based on generous contribution from Allan Odgaard. Thanks, Allan!
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // this is terrible; will fix later probably
|
||||
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char* executablePath, AuthorizationFlags options, const char* const* arguments)
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL);
|
||||
BOOL returnValue = YES;
|
||||
|
||||
@@ -57,77 +69,110 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
signal(SIGCHLD, oldSigChildHandler);
|
||||
return returnValue;
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@implementation SUPlainInstaller (Internals)
|
||||
|
||||
+ (BOOL)currentUserOwnsPath:(NSString *)oPath
|
||||
{
|
||||
const char *path = [oPath fileSystemRepresentation];
|
||||
uid_t uid = getuid();
|
||||
bool res = false;
|
||||
struct stat sb;
|
||||
if(stat(path, &sb) == 0)
|
||||
{
|
||||
if(sb.st_uid == uid)
|
||||
{
|
||||
res = true;
|
||||
if(sb.st_mode & S_IFDIR)
|
||||
{
|
||||
DIR* dir = opendir(path);
|
||||
struct dirent* entry = NULL;
|
||||
while(res && (entry = readdir(dir)))
|
||||
{
|
||||
if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
size_t len = strlen(path) + 1 + entry->d_namlen + 1;
|
||||
char descend[len];
|
||||
strlcpy(descend, path, len);
|
||||
strlcat(descend, "/", len);
|
||||
strlcat(descend, entry->d_name, len);
|
||||
NSString* newPath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:descend length:strlen(descend)];
|
||||
res = [self currentUserOwnsPath:newPath];
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
+ (NSString *)_temporaryCopyNameForPath:(NSString *)path
|
||||
+ (NSString *)temporaryNameForPath:(NSString *)path
|
||||
{
|
||||
// Let's try to read the version number so the filename will be more meaningful.
|
||||
NSString *postFix;
|
||||
NSBundle *bundle;
|
||||
if ((bundle = [NSBundle bundleWithPath:path]))
|
||||
NSString *version;
|
||||
if ((version = [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]) && ![version isEqualToString:@""])
|
||||
{
|
||||
// We'll clean it up a little for safety.
|
||||
// The cast is necessary because of a bug in the headers in pre-10.5 SDKs
|
||||
NSMutableCharacterSet *validCharacters = (id)[NSMutableCharacterSet alphanumericCharacterSet];
|
||||
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
|
||||
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
|
||||
postFix = [[bundle objectForInfoDictionaryKey:@"CFBundleVersion"] stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
|
||||
postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
|
||||
}
|
||||
else
|
||||
postFix = @"old";
|
||||
NSString *prefix = [[path stringByDeletingPathExtension] stringByAppendingFormat:@" (%@)", postFix];
|
||||
NSString *tempDir = [prefix stringByAppendingPathExtension:[path pathExtension]];
|
||||
// Now let's make sure we get a unique path.
|
||||
unsigned int cnt=2;
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999)
|
||||
tempDir = [NSString stringWithFormat:@"%@ %u.%@", prefix, cnt++, [path pathExtension]];
|
||||
return [tempDir lastPathComponent];
|
||||
}
|
||||
|
||||
+ (NSString *)_temporaryCopyNameForPath:(NSString *)path didFindTrash: (BOOL*)outDidFindTrash
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
NSString *tempDir = nil;
|
||||
|
||||
UInt8 trashPath[MAXPATHLEN +1] = { 0 };
|
||||
FSRef trashRef, pathRef;
|
||||
FSVolumeRefNum vSrcRefNum = kFSInvalidVolumeRefNum;
|
||||
FSCatalogInfo catInfo;
|
||||
memset( &catInfo, 0, sizeof(catInfo) );
|
||||
OSStatus err = FSPathMakeRef( (UInt8*) [path fileSystemRepresentation], &pathRef, NULL );
|
||||
if( err == noErr )
|
||||
{
|
||||
err = FSGetCatalogInfo( &pathRef, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL );
|
||||
vSrcRefNum = catInfo.volume;
|
||||
}
|
||||
if( err == noErr )
|
||||
err = FSFindFolder( vSrcRefNum, kTrashFolderType, kCreateFolder, &trashRef );
|
||||
if( err == noErr )
|
||||
err = FSGetCatalogInfo( &trashRef, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL );
|
||||
if( err == noErr && vSrcRefNum != catInfo.volume )
|
||||
err = nsvErr; // Couldn't find a trash folder on same volume as given path. Docs say this may happen in the future.
|
||||
if( err == noErr )
|
||||
err = FSRefMakePath( &trashRef, trashPath, MAXPATHLEN );
|
||||
if( err == noErr )
|
||||
tempDir = [[NSFileManager defaultManager] stringWithFileSystemRepresentation: (char*) trashPath length: strlen((char*) trashPath)];
|
||||
if( outDidFindTrash )
|
||||
*outDidFindTrash = (tempDir != nil);
|
||||
if( !tempDir )
|
||||
tempDir = [path stringByDeletingLastPathComponent];
|
||||
|
||||
// Let's try to read the version number so the filename will be more meaningful.
|
||||
#if TRY_TO_APPEND_VERSION_NUMBER
|
||||
NSString *postFix = nil;
|
||||
NSString *version = nil;
|
||||
if ((version = [[NSBundle bundleWithPath: path] objectForInfoDictionaryKey:@"CFBundleVersion"]) && ![version isEqualToString:@""])
|
||||
{
|
||||
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
|
||||
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
|
||||
postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
|
||||
}
|
||||
else
|
||||
postFix = @"old";
|
||||
NSString *prefix = [NSString stringWithFormat: @"%@ (%@)", [[path lastPathComponent] stringByDeletingPathExtension], postFix];
|
||||
#else
|
||||
NSString *prefix = [[path lastPathComponent] stringByDeletingPathExtension];
|
||||
#endif
|
||||
NSString *tempName = [prefix stringByAppendingPathExtension: [path pathExtension]];
|
||||
tempDir = [tempDir stringByAppendingPathComponent: tempName];
|
||||
|
||||
// Now let's make sure we get a unique path.
|
||||
int cnt=2;
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999999)
|
||||
tempDir = [NSString stringWithFormat:@"%@ %d.%@", prefix, cnt++, [path pathExtension]];
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 9999)
|
||||
tempDir = [[tempDir stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat:@"%@ %d.%@", prefix, cnt++, [path pathExtension]]];
|
||||
|
||||
return tempDir;
|
||||
}
|
||||
|
||||
+ (BOOL)_copyPathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst error:(NSError **)error
|
||||
+ (BOOL)_copyPathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst temporaryPath:(NSString *)tmp error:(NSError **)error
|
||||
{
|
||||
NSString *tmp = [self _temporaryCopyNameForPath:dst];
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
const char* srcPath = [src fileSystemRepresentation];
|
||||
const char* tmpPath = [tmp fileSystemRepresentation];
|
||||
const char* dstPath = [dst fileSystemRepresentation];
|
||||
|
||||
struct stat dstSB;
|
||||
stat(dstPath, &dstSB);
|
||||
if( stat(dstPath, &dstSB) != 0 ) // Doesn't exist yet, try containing folder.
|
||||
{
|
||||
const char* dstDirPath = [[dst stringByDeletingLastPathComponent] fileSystemRepresentation];
|
||||
if( stat(dstDirPath, &dstSB) != 0 )
|
||||
{
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Stat on %@ during authenticated file copy failed.", dst];
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
@@ -143,40 +188,9 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
res = YES;
|
||||
|
||||
char uidgid[42];
|
||||
snprintf(uidgid, sizeof(uidgid), "%d:%d",
|
||||
snprintf(uidgid, sizeof(uidgid), "%u:%u",
|
||||
dstSB.st_uid, dstSB.st_gid);
|
||||
|
||||
const char* executables[] = {
|
||||
"/bin/rm",
|
||||
"/bin/mv",
|
||||
"/bin/mv",
|
||||
"/bin/rm",
|
||||
NULL, // pause here and do some housekeeping before
|
||||
// continuing
|
||||
"/usr/sbin/chown",
|
||||
NULL // stop here for real
|
||||
};
|
||||
|
||||
// 4 is the maximum number of arguments to any command,
|
||||
// including the NULL that signals the end of an argument
|
||||
// list.
|
||||
const char* const argumentLists[][4] = {
|
||||
{ "-rf", tmpPath, NULL }, // make room for the temporary file... this is kinda unsafe; should probably do something better.
|
||||
{ "-f", dstPath, tmpPath, NULL }, // mv
|
||||
{ "-f", srcPath, dstPath, NULL }, // mv
|
||||
{ "-rf", tmpPath, NULL }, // rm
|
||||
{ NULL }, // pause
|
||||
{ "-R", uidgid, dstPath, NULL }, // chown
|
||||
{ NULL } // stop
|
||||
};
|
||||
|
||||
// Process the commands up until the first NULL
|
||||
int commandIndex = 0;
|
||||
for (; executables[commandIndex] != NULL; ++commandIndex) {
|
||||
if (res)
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, executables[commandIndex], kAuthorizationFlagDefaults, argumentLists[commandIndex]);
|
||||
}
|
||||
|
||||
// If the currently-running application is trusted, the new
|
||||
// version should be trusted as well. Remove it from the
|
||||
// quarantine to avoid a delay at launch, and to avoid
|
||||
@@ -189,17 +203,137 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
// done before "chown" changes ownership, because the ownership
|
||||
// change will almost certainly make it impossible to change
|
||||
// attributes to release the files from the quarantine.
|
||||
if (res) {
|
||||
[self releaseFromQuarantine:dst];
|
||||
if (res)
|
||||
{
|
||||
SULog(@"releaseFromQuarantine");
|
||||
[self performSelectorOnMainThread:@selector(releaseFromQuarantine:) withObject:src waitUntilDone:YES];
|
||||
}
|
||||
|
||||
// Now move past the NULL we found and continue executing
|
||||
// commands from the list.
|
||||
++commandIndex;
|
||||
if( res ) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
|
||||
{
|
||||
const char* coParams[] = { "-R", uidgid, srcPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams );
|
||||
if( !res )
|
||||
SULog( @"chown -R %s %s failed.", uidgid, srcPath );
|
||||
}
|
||||
|
||||
for (; executables[commandIndex] != NULL; ++commandIndex) {
|
||||
if (res)
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, executables[commandIndex], kAuthorizationFlagDefaults, argumentLists[commandIndex]);
|
||||
BOOL haveDst = [[NSFileManager defaultManager] fileExistsAtPath: dst];
|
||||
if( res && haveDst ) // If there's something at our tmp path (previous failed update or whatever) delete that first.
|
||||
{
|
||||
const char* rmParams[] = { "-rf", tmpPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
|
||||
if( !res )
|
||||
SULog( @"rm failed" );
|
||||
}
|
||||
|
||||
if( res && haveDst ) // Move old exe to tmp path.
|
||||
{
|
||||
const char* mvParams[] = { "-f", dstPath, tmpPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams );
|
||||
if( !res )
|
||||
SULog( @"mv 1 failed" );
|
||||
}
|
||||
|
||||
if( res ) // Move new exe to old exe's path.
|
||||
{
|
||||
const char* mvParams2[] = { "-f", srcPath, dstPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams2 );
|
||||
if( !res )
|
||||
SULog( @"mv 2 failed" );
|
||||
}
|
||||
|
||||
// if( res && haveDst /*&& !foundTrash*/ ) // If we managed to put the old exe in the trash, leave it there for the user to delete or recover.
|
||||
// { // ... Otherwise we better delete it, wouldn't want dozens of old versions lying around next to the new one.
|
||||
// const char* rmParams2[] = { "-rf", tmpPath, NULL };
|
||||
// res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams2 );
|
||||
// }
|
||||
|
||||
AuthorizationFree(auth, 0);
|
||||
|
||||
// If the currently-running application is trusted, the new
|
||||
// version should be trusted as well. Remove it from the
|
||||
// quarantine to avoid a delay at launch, and to avoid
|
||||
// presenting the user with a confusing trust dialog.
|
||||
//
|
||||
// This needs to be done after the application is moved to its
|
||||
// new home with "mv" in case it's moved across filesystems: if
|
||||
// that happens, "mv" actually performs a copy and may result
|
||||
// in the application being quarantined.
|
||||
if (res)
|
||||
{
|
||||
SULog(@"releaseFromQuarantine after installing");
|
||||
[self performSelectorOnMainThread:@selector(releaseFromQuarantine:) withObject:dst waitUntilDone:YES];
|
||||
}
|
||||
|
||||
if (!res)
|
||||
{
|
||||
// Something went wrong somewhere along the way, but we're not sure exactly where.
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file copy from %@ to %@ failed.", src, dst];
|
||||
if (error != nil)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error != nil)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:[NSDictionary dictionaryWithObject:@"Couldn't get permission to authenticate." forKey:NSLocalizedDescriptionKey]];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
+ (BOOL)_movePathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst error:(NSError **)error
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
const char* srcPath = [src fileSystemRepresentation];
|
||||
const char* dstPath = [dst fileSystemRepresentation];
|
||||
const char* dstContainerPath = [[dst stringByDeletingLastPathComponent] fileSystemRepresentation];
|
||||
|
||||
struct stat dstSB;
|
||||
stat(dstContainerPath, &dstSB);
|
||||
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
while( authStat == errAuthorizationDenied )
|
||||
{
|
||||
authStat = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
}
|
||||
|
||||
BOOL res = NO;
|
||||
if (authStat == errAuthorizationSuccess)
|
||||
{
|
||||
res = YES;
|
||||
|
||||
char uidgid[42];
|
||||
snprintf(uidgid, sizeof(uidgid), "%d:%d",
|
||||
dstSB.st_uid, dstSB.st_gid);
|
||||
|
||||
if( res ) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
|
||||
{
|
||||
const char* coParams[] = { "-R", uidgid, srcPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams );
|
||||
if( !res )
|
||||
SULog(@"Can't set permissions");
|
||||
}
|
||||
|
||||
BOOL haveDst = [[NSFileManager defaultManager] fileExistsAtPath: dst];
|
||||
if( res && haveDst ) // If there's something at our tmp path (previous failed update or whatever) delete that first.
|
||||
{
|
||||
const char* rmParams[] = { "-rf", dstPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
|
||||
if( !res )
|
||||
SULog(@"Can't remove destination file");
|
||||
}
|
||||
|
||||
if( res ) // Move!.
|
||||
{
|
||||
const char* mvParams[] = { "-f", srcPath, dstPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams );
|
||||
if( !res )
|
||||
SULog(@"Can't move source file");
|
||||
}
|
||||
|
||||
AuthorizationFree(auth, 0);
|
||||
@@ -207,7 +341,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
if (!res)
|
||||
{
|
||||
// Something went wrong somewhere along the way, but we're not sure exactly where.
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file copy from %@ to %@ failed.", src, dst];
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file move from %@ to %@ failed.", src, dst];
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
|
||||
}
|
||||
@@ -220,39 +354,150 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
return res;
|
||||
}
|
||||
|
||||
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst error:(NSError **)error
|
||||
|
||||
+ (BOOL)_removeFileAtPathWithForcedAuthentication:(NSString *)src error:(NSError **)error
|
||||
{
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:dst])
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
const char* srcPath = [src fileSystemRepresentation];
|
||||
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
while( authStat == errAuthorizationDenied )
|
||||
{
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Couldn't copy %@ over %@ because there is no file at %@.", src, dst, dst];
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![[NSFileManager defaultManager] isWritableFileAtPath:dst] || ![[NSFileManager defaultManager] isWritableFileAtPath:[dst stringByDeletingLastPathComponent]])
|
||||
return [self _copyPathWithForcedAuthentication:src toPath:dst error:error];
|
||||
|
||||
NSString *tmpPath = [self _temporaryCopyNameForPath:dst];
|
||||
|
||||
if (![[NSFileManager defaultManager] movePath:dst toPath:tmpPath handler:self])
|
||||
{
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]];
|
||||
return NO;
|
||||
}
|
||||
if (![[NSFileManager defaultManager] copyPath:src toPath:dst handler:self])
|
||||
{
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't copy %@ to %@.", src, dst] forKey:NSLocalizedDescriptionKey]];
|
||||
return NO;
|
||||
authStat = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
}
|
||||
|
||||
// Trash the old copy of the app.
|
||||
BOOL res = NO;
|
||||
if (authStat == errAuthorizationSuccess)
|
||||
{
|
||||
res = YES;
|
||||
|
||||
if( res ) // If there's something at our tmp path (previous failed update or whatever) delete that first.
|
||||
{
|
||||
const char* rmParams[] = { "-rf", srcPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams );
|
||||
if( !res )
|
||||
SULog(@"Can't remove destination file");
|
||||
}
|
||||
|
||||
AuthorizationFree(auth, 0);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
// Something went wrong somewhere along the way, but we're not sure exactly where.
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file remove from %@ failed.", src];
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:[NSDictionary dictionaryWithObject:@"Couldn't get permission to authenticate." forKey:NSLocalizedDescriptionKey]];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
+ (BOOL)_removeFileAtPath:(NSString *)path error: (NSError**)error
|
||||
{
|
||||
BOOL success = YES;
|
||||
if( ![[NSFileManager defaultManager] removeItemAtPath: path error: NULL] )
|
||||
{
|
||||
success = [self _removeFileAtPathWithForcedAuthentication: path error: error];
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
+ (void)_movePathToTrash:(NSString *)path
|
||||
{
|
||||
//SULog(@"Moving %@ to the trash.", path);
|
||||
NSInteger tag = 0;
|
||||
if (![[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[tmpPath stringByDeletingLastPathComponent] destination:@"" files:[NSArray arrayWithObject:[tmpPath lastPathComponent]] tag:&tag])
|
||||
NSLog(@"Sparkle error: couldn't move %@ to the trash. This is often a sign of a permissions error.", tmpPath);
|
||||
if (![[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[path stringByDeletingLastPathComponent] destination:@"" files:[NSArray arrayWithObject:[path lastPathComponent]] tag:&tag])
|
||||
{
|
||||
BOOL didFindTrash = NO;
|
||||
NSString* trashPath = [self _temporaryCopyNameForPath: path didFindTrash: &didFindTrash];
|
||||
if( didFindTrash )
|
||||
{
|
||||
NSError *err = nil;
|
||||
if( ![self _movePathWithForcedAuthentication: path toPath: trashPath error: &err] )
|
||||
SULog(@"Sparkle error: couldn't move %@ to the trash (%@). %@", path, trashPath, err);
|
||||
}
|
||||
else
|
||||
SULog(@"Sparkle error: couldn't move %@ to the trash. This is often a sign of a permissions error.", path);
|
||||
}
|
||||
else
|
||||
;//SULog(@"Moved %@ to the trash.", path);
|
||||
}
|
||||
|
||||
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)tmp error:(NSError **)error
|
||||
{
|
||||
FSRef srcRef, dstRef, dstDirRef, tmpDirRef;
|
||||
OSStatus err;
|
||||
BOOL hadFileAtDest = NO, didFindTrash = NO;
|
||||
NSString *tmpPath = [self _temporaryCopyNameForPath: dst didFindTrash: &didFindTrash];
|
||||
|
||||
// Make FSRef for destination:
|
||||
err = FSPathMakeRefWithOptions((UInt8 *)[dst fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &dstRef, NULL);
|
||||
hadFileAtDest = (err == noErr); // There is a file at the destination, move it aside. If we normalized the name, we might not get here, so don't error.
|
||||
if( hadFileAtDest )
|
||||
{
|
||||
if (0 != access([dst fileSystemRepresentation], W_OK) || 0 != access([[dst stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK))
|
||||
{
|
||||
return [self _copyPathWithForcedAuthentication:src toPath:dst temporaryPath:tmpPath error:error];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 != access([[dst stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK)
|
||||
|| 0 != access([[[dst stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK))
|
||||
{
|
||||
return [self _copyPathWithForcedAuthentication:src toPath:dst temporaryPath:tmpPath error:error];
|
||||
}
|
||||
}
|
||||
|
||||
if( hadFileAtDest )
|
||||
{
|
||||
err = FSPathMakeRef((UInt8 *)[[tmpPath stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
|
||||
if (err != noErr)
|
||||
FSPathMakeRef((UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
|
||||
}
|
||||
|
||||
err = FSPathMakeRef((UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &dstDirRef, NULL);
|
||||
|
||||
if (err == noErr && hadFileAtDest)
|
||||
{
|
||||
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
|
||||
BOOL success = [manager moveItemAtPath:dst toPath:tmpPath error:error];
|
||||
if (!success && hadFileAtDest)
|
||||
{
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
err = FSPathMakeRef((UInt8 *)[src fileSystemRepresentation], &srcRef, NULL);
|
||||
if (err == noErr)
|
||||
{
|
||||
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
|
||||
BOOL success = [manager copyItemAtPath:src toPath:dst error:error];
|
||||
if (!success)
|
||||
{
|
||||
// We better move the old version back to its old location
|
||||
if( hadFileAtDest )
|
||||
success = [manager moveItemAtPath:tmpPath toPath:dst error:error];
|
||||
if (!success && error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]];
|
||||
return NO;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// If the currently-running application is trusted, the new
|
||||
// version should be trusted as well. Remove it from the
|
||||
// quarantine to avoid a delay at launch, and to avoid
|
||||
@@ -262,7 +507,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
// new home in case it's moved across filesystems: if that
|
||||
// happens, the move is actually a copy, and it may result
|
||||
// in the application being quarantined.
|
||||
[self releaseFromQuarantine:dst];
|
||||
[self performSelectorOnMainThread:@selector(releaseFromQuarantine:) withObject:dst waitUntilDone:YES];
|
||||
|
||||
return YES;
|
||||
}
|
||||
@@ -279,19 +524,8 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
fromFile:(NSString*)file
|
||||
options:(int)options
|
||||
{
|
||||
typedef int (*removexattr_type)(const char*, const char*, int);
|
||||
// Reference removexattr directly, it's in the SDK.
|
||||
static removexattr_type removexattr_func = removexattr;
|
||||
|
||||
// Make sure that the symbol is present. This checks the deployment
|
||||
// target instead of the SDK so that it's able to catch dlsym failures
|
||||
// as well as the null symbol that would result from building with the
|
||||
// 10.4 SDK and a lower deployment target, and running on 10.3.
|
||||
if (!removexattr_func) {
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
const char* path = NULL;
|
||||
@try {
|
||||
path = [file fileSystemRepresentation];
|
||||
@@ -305,11 +539,13 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
return -1;
|
||||
}
|
||||
|
||||
return removexattr_func(path, name, options);
|
||||
return removexattr(path, name, options);
|
||||
}
|
||||
|
||||
+ (void)releaseFromQuarantine:(NSString*)root
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
const char* quarantineAttribute = "com.apple.quarantine";
|
||||
const int removeXAttrOptions = XATTR_NOFOLLOW;
|
||||
|
||||
@@ -319,8 +555,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
|
||||
|
||||
// Only recurse if it's actually a directory. Don't recurse into a
|
||||
// root-level symbolic link.
|
||||
NSDictionary* rootAttributes =
|
||||
[[NSFileManager defaultManager] fileAttributesAtPath:root traverseLink:NO];
|
||||
NSDictionary* rootAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:root error:nil];
|
||||
NSString* rootType = [rootAttributes objectForKey:NSFileType];
|
||||
|
||||
if (rootType == NSFileTypeDirectory) {
|
||||
|
||||
+10
-2
@@ -7,19 +7,27 @@
|
||||
//
|
||||
|
||||
#import "SUProbingUpdateDriver.h"
|
||||
|
||||
#import "SUUpdater.h"
|
||||
|
||||
@implementation SUProbingUpdateDriver
|
||||
|
||||
// Stop as soon as we have an answer! The superclasses will already have taken care of notifying the delegate.
|
||||
// Stop as soon as we have an answer! Since the superclass implementations are not called, we are responsible for notifying the delegate.
|
||||
|
||||
- (void)didFindValidUpdate
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)])
|
||||
[[updater delegate] updater:updater didFindValidUpdate:updateItem];
|
||||
NSDictionary *userInfo = (updateItem != nil) ? @{SUUpdaterAppcastItemNotificationKey : updateItem} : nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification object:updater userInfo:userInfo];
|
||||
[self abortUpdate];
|
||||
}
|
||||
|
||||
- (void)didNotFindUpdate
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)])
|
||||
[[updater delegate] updaterDidNotFindUpdate:updater];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
|
||||
|
||||
[self abortUpdate];
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUUIBasedUpdateDriver.h"
|
||||
|
||||
@interface SUScheduledUpdateDriver : SUUIBasedUpdateDriver {
|
||||
@interface SUScheduledUpdateDriver : SUUIBasedUpdateDriver
|
||||
{
|
||||
@private
|
||||
BOOL showErrors;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,11 @@
|
||||
//
|
||||
|
||||
#import "SUScheduledUpdateDriver.h"
|
||||
#import "Sparkle.h"
|
||||
#import "SUUpdater.h"
|
||||
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
|
||||
@implementation SUScheduledUpdateDriver
|
||||
|
||||
@@ -19,6 +23,10 @@
|
||||
|
||||
- (void)didNotFindUpdate
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)])
|
||||
[[updater delegate] updaterDidNotFindUpdate:updater];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
|
||||
|
||||
[self abortUpdate]; // Don't tell the user that no update was found; this was a scheduled update.
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,11 @@
|
||||
// Copyright 2007 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Sparkle.h"
|
||||
#import "SUUpdater.h"
|
||||
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUStandardVersionComparator.h"
|
||||
|
||||
@implementation SUStandardVersionComparator
|
||||
@@ -22,15 +26,19 @@
|
||||
typedef enum {
|
||||
kNumberType,
|
||||
kStringType,
|
||||
kPeriodType
|
||||
kSeparatorType,
|
||||
} SUCharacterType;
|
||||
|
||||
- (SUCharacterType)typeOfCharacter:(NSString *)character
|
||||
{
|
||||
if ([character isEqualToString:@"."]) {
|
||||
return kPeriodType;
|
||||
return kSeparatorType;
|
||||
} else if ([[NSCharacterSet decimalDigitCharacterSet] characterIsMember:[character characterAtIndex:0]]) {
|
||||
return kNumberType;
|
||||
} else if ([[NSCharacterSet whitespaceAndNewlineCharacterSet] characterIsMember:[character characterAtIndex:0]]) {
|
||||
return kSeparatorType;
|
||||
} else if ([[NSCharacterSet punctuationCharacterSet] characterIsMember:[character characterAtIndex:0]]) {
|
||||
return kSeparatorType;
|
||||
} else {
|
||||
return kStringType;
|
||||
}
|
||||
@@ -40,7 +48,8 @@ typedef enum {
|
||||
{
|
||||
NSString *character;
|
||||
NSMutableString *s;
|
||||
NSInteger i, n, oldType, newType;
|
||||
NSUInteger i, n;
|
||||
SUCharacterType oldType, newType;
|
||||
NSMutableArray *parts = [NSMutableArray array];
|
||||
if ([version length] == 0) {
|
||||
// Nothing to do here
|
||||
@@ -52,11 +61,10 @@ typedef enum {
|
||||
for (i = 1; i <= n; ++i) {
|
||||
character = [version substringWithRange:NSMakeRange(i, 1)];
|
||||
newType = [self typeOfCharacter:character];
|
||||
if (oldType != newType || oldType == kPeriodType) {
|
||||
if (oldType != newType || oldType == kSeparatorType) {
|
||||
// We've reached a new segment
|
||||
NSString *aPart = [[NSString alloc] initWithString:s];
|
||||
NSString *aPart = [[[NSString alloc] initWithString:s] autorelease];
|
||||
[parts addObject:aPart];
|
||||
[aPart release];
|
||||
[s setString:character];
|
||||
} else {
|
||||
// Add character to string and continue
|
||||
@@ -76,8 +84,10 @@ typedef enum {
|
||||
NSArray *partsB = [self splitVersionString:versionB];
|
||||
|
||||
NSString *partA, *partB;
|
||||
NSInteger i, n, typeA, typeB, intA, intB;
|
||||
|
||||
NSUInteger i, n;
|
||||
long long valueA, valueB;
|
||||
SUCharacterType typeA, typeB;
|
||||
|
||||
n = MIN([partsA count], [partsB count]);
|
||||
for (i = 0; i < n; ++i) {
|
||||
partA = [partsA objectAtIndex:i];
|
||||
@@ -90,11 +100,11 @@ typedef enum {
|
||||
if (typeA == typeB) {
|
||||
// Same type; we can compare
|
||||
if (typeA == kNumberType) {
|
||||
intA = [partA intValue];
|
||||
intB = [partB intValue];
|
||||
if (intA > intB) {
|
||||
valueA = [partA longLongValue];
|
||||
valueB = [partB longLongValue];
|
||||
if (valueA > valueB) {
|
||||
return NSOrderedDescending;
|
||||
} else if (intA < intB) {
|
||||
} else if (valueA < valueB) {
|
||||
return NSOrderedAscending;
|
||||
}
|
||||
} else if (typeA == kStringType) {
|
||||
|
||||
Generated
-56
@@ -1,56 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBClasses</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>SUWindowController</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>NSWindowController</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>NSApplication</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>NSResponder</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>FirstResponder</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>NSObject</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>NSObject</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>SUStatusController</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>OUTLETS</key>
|
||||
<dict>
|
||||
<key>actionButton</key>
|
||||
<string>NSButton</string>
|
||||
<key>progressBar</key>
|
||||
<string>NSProgressIndicator</string>
|
||||
</dict>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>SUWindowController</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>IBVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Generated
-20
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBFramework Version</key>
|
||||
<string>670</string>
|
||||
<key>IBLastKnownRelativeProjectPath</key>
|
||||
<string>Sparkle.xcodeproj</string>
|
||||
<key>IBOldestOS</key>
|
||||
<integer>5</integer>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>6</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>10A96</string>
|
||||
<key>targetFramework</key>
|
||||
<string>IBCocoaFramework</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Generated
BIN
Binary file not shown.
+589
@@ -0,0 +1,589 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1050</int>
|
||||
<string key="IBDocument.SystemVersion">10D573</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">762</string>
|
||||
<string key="IBDocument.AppKitVersion">1038.29</string>
|
||||
<string key="IBDocument.HIToolboxVersion">460.00</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys" id="0">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<integer value="6"/>
|
||||
</object>
|
||||
<reference key="IBDocument.PluginDependencies" ref="0"/>
|
||||
<object class="NSMutableDictionary" key="IBDocument.Metadata">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference key="dict.sortedKeys" ref="0"/>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="IBDocument.RootObjects" id="780577916">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSCustomObject" id="245526436">
|
||||
<string key="NSClassName">SUStatusController</string>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="879485556">
|
||||
<string key="NSClassName">FirstResponder</string>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="472338989">
|
||||
<string key="NSClassName">NSApplication</string>
|
||||
</object>
|
||||
<object class="NSWindowTemplate" id="661323156">
|
||||
<int key="NSWindowStyleMask">1</int>
|
||||
<int key="NSWindowBacking">2</int>
|
||||
<string key="NSWindowRect">{{200, 222}, {400, 107}}</string>
|
||||
<int key="NSWTFlags">1886912512</int>
|
||||
<string key="NSWindowTitle">Set in Code</string>
|
||||
<object class="NSMutableString" key="NSWindowClass">
|
||||
<characters key="NS.bytes">NSWindow</characters>
|
||||
</object>
|
||||
<object class="NSMutableString" key="NSViewClass">
|
||||
<characters key="NS.bytes">View</characters>
|
||||
</object>
|
||||
<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
|
||||
<string key="NSWindowContentMinSize">{213, 107}</string>
|
||||
<object class="NSView" key="NSWindowView" id="512815736">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
<object class="NSMutableArray" key="NSSubviews">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSImageView" id="56655866">
|
||||
<reference key="NSNextResponder" ref="512815736"/>
|
||||
<int key="NSvFlags">268</int>
|
||||
<object class="NSMutableSet" key="NSDragTypes">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="set.sortedObjects">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>Apple PDF pasteboard type</string>
|
||||
<string>Apple PICT pasteboard type</string>
|
||||
<string>Apple PNG pasteboard type</string>
|
||||
<string>NSFilenamesPboardType</string>
|
||||
<string>NeXT Encapsulated PostScript v1.2 pasteboard type</string>
|
||||
<string>NeXT TIFF v4.0 pasteboard type</string>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrame">{{24, 28}, {64, 64}}</string>
|
||||
<reference key="NSSuperview" ref="512815736"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSImageCell" key="NSCell" id="381943368">
|
||||
<int key="NSCellFlags">130560</int>
|
||||
<int key="NSCellFlags2">33554432</int>
|
||||
<object class="NSCustomResource" key="NSContents">
|
||||
<string key="NSClassName">NSImage</string>
|
||||
<string key="NSResourceName">NSApplicationIcon</string>
|
||||
</object>
|
||||
<int key="NSAlign">0</int>
|
||||
<int key="NSScale">1</int>
|
||||
<int key="NSStyle">0</int>
|
||||
<bool key="NSAnimates">NO</bool>
|
||||
</object>
|
||||
<bool key="NSEditable">YES</bool>
|
||||
</object>
|
||||
<object class="NSTextField" id="692218720">
|
||||
<reference key="NSNextResponder" ref="512815736"/>
|
||||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{106, 75}, {277, 17}}</string>
|
||||
<reference key="NSSuperview" ref="512815736"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSTextFieldCell" key="NSCell" id="597081861">
|
||||
<int key="NSCellFlags">67239424</int>
|
||||
<int key="NSCellFlags2">272629760</int>
|
||||
<string key="NSContents">Status Text (set by loc. string in code)</string>
|
||||
<object class="NSFont" key="NSSupport">
|
||||
<string key="NSName">LucidaGrande-Bold</string>
|
||||
<double key="NSSize">13</double>
|
||||
<int key="NSfFlags">2072</int>
|
||||
</object>
|
||||
<reference key="NSControlView" ref="692218720"/>
|
||||
<object class="NSColor" key="NSBackgroundColor" id="747797151">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">controlColor</string>
|
||||
<object class="NSColor" key="NSColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MC42NjY2NjY2ODY1AA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSColor" key="NSTextColor" id="640273742">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">controlTextColor</string>
|
||||
<object class="NSColor" key="NSColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MAA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSProgressIndicator" id="454270533">
|
||||
<reference key="NSNextResponder" ref="512815736"/>
|
||||
<int key="NSvFlags">1280</int>
|
||||
<object class="NSPSMatrix" key="NSDrawMatrix"/>
|
||||
<string key="NSFrame">{{107, 47}, {275, 20}}</string>
|
||||
<reference key="NSSuperview" ref="512815736"/>
|
||||
<int key="NSpiFlags">16394</int>
|
||||
<double key="NSMaxValue">100</double>
|
||||
</object>
|
||||
<object class="NSButton" id="566879706">
|
||||
<reference key="NSNextResponder" ref="512815736"/>
|
||||
<int key="NSvFlags">259</int>
|
||||
<string key="NSFrame">{{272, 12}, {114, 32}}</string>
|
||||
<reference key="NSSuperview" ref="512815736"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSButtonCell" key="NSCell" id="130218013">
|
||||
<int key="NSCellFlags">67239424</int>
|
||||
<int key="NSCellFlags2">134217728</int>
|
||||
<string key="NSContents">Button</string>
|
||||
<object class="NSFont" key="NSSupport" id="531315841">
|
||||
<string key="NSName">LucidaGrande</string>
|
||||
<double key="NSSize">13</double>
|
||||
<int key="NSfFlags">1044</int>
|
||||
</object>
|
||||
<reference key="NSControlView" ref="566879706"/>
|
||||
<int key="NSButtonFlags">-2038284033</int>
|
||||
<int key="NSButtonFlags2">1</int>
|
||||
<reference key="NSAlternateImage" ref="531315841"/>
|
||||
<string key="NSAlternateContents"/>
|
||||
<object class="NSMutableString" key="NSKeyEquivalent">
|
||||
<characters key="NS.bytes"/>
|
||||
</object>
|
||||
<int key="NSPeriodicDelay">200</int>
|
||||
<int key="NSPeriodicInterval">25</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSTextField" id="65200871">
|
||||
<reference key="NSNextResponder" ref="512815736"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
<string key="NSFrame">{{106, 22}, {167, 17}}</string>
|
||||
<reference key="NSSuperview" ref="512815736"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSTextFieldCell" key="NSCell" id="180962568">
|
||||
<int key="NSCellFlags">67239424</int>
|
||||
<int key="NSCellFlags2">272629760</int>
|
||||
<string key="NSContents">Small System Font Text</string>
|
||||
<reference key="NSSupport" ref="531315841"/>
|
||||
<reference key="NSControlView" ref="65200871"/>
|
||||
<reference key="NSBackgroundColor" ref="747797151"/>
|
||||
<reference key="NSTextColor" ref="640273742"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{400, 107}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
</object>
|
||||
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
|
||||
<string key="NSMinSize">{213, 129}</string>
|
||||
<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<object class="NSMutableArray" key="connectionRecords">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">value: applicationIcon</string>
|
||||
<reference key="source" ref="56655866"/>
|
||||
<reference key="destination" ref="245526436"/>
|
||||
<object class="NSNibBindingConnector" key="connector">
|
||||
<reference key="NSSource" ref="56655866"/>
|
||||
<reference key="NSDestination" ref="245526436"/>
|
||||
<string key="NSLabel">value: applicationIcon</string>
|
||||
<string key="NSBinding">value</string>
|
||||
<string key="NSKeyPath">applicationIcon</string>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">9</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">maxValue: maxProgressValue</string>
|
||||
<reference key="source" ref="454270533"/>
|
||||
<reference key="destination" ref="245526436"/>
|
||||
<object class="NSNibBindingConnector" key="connector" id="110266706">
|
||||
<reference key="NSSource" ref="454270533"/>
|
||||
<reference key="NSDestination" ref="245526436"/>
|
||||
<string key="NSLabel">maxValue: maxProgressValue</string>
|
||||
<string key="NSBinding">maxValue</string>
|
||||
<string key="NSKeyPath">maxProgressValue</string>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">13</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">value: statusText</string>
|
||||
<reference key="source" ref="65200871"/>
|
||||
<reference key="destination" ref="245526436"/>
|
||||
<object class="NSNibBindingConnector" key="connector">
|
||||
<reference key="NSSource" ref="65200871"/>
|
||||
<reference key="NSDestination" ref="245526436"/>
|
||||
<string key="NSLabel">value: statusText</string>
|
||||
<string key="NSBinding">value</string>
|
||||
<string key="NSKeyPath">statusText</string>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">17</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">title: buttonTitle</string>
|
||||
<reference key="source" ref="566879706"/>
|
||||
<reference key="destination" ref="245526436"/>
|
||||
<object class="NSNibBindingConnector" key="connector">
|
||||
<reference key="NSSource" ref="566879706"/>
|
||||
<reference key="NSDestination" ref="245526436"/>
|
||||
<string key="NSLabel">title: buttonTitle</string>
|
||||
<string key="NSBinding">title</string>
|
||||
<string key="NSKeyPath">buttonTitle</string>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">21</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">title: windowTitle</string>
|
||||
<reference key="source" ref="661323156"/>
|
||||
<reference key="destination" ref="245526436"/>
|
||||
<object class="NSNibBindingConnector" key="connector">
|
||||
<reference key="NSSource" ref="661323156"/>
|
||||
<reference key="NSDestination" ref="245526436"/>
|
||||
<string key="NSLabel">title: windowTitle</string>
|
||||
<string key="NSBinding">title</string>
|
||||
<string key="NSKeyPath">windowTitle</string>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">24</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">window</string>
|
||||
<reference key="source" ref="245526436"/>
|
||||
<reference key="destination" ref="661323156"/>
|
||||
</object>
|
||||
<int key="connectionID">25</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">value: title</string>
|
||||
<reference key="source" ref="692218720"/>
|
||||
<reference key="destination" ref="245526436"/>
|
||||
<object class="NSNibBindingConnector" key="connector">
|
||||
<reference key="NSSource" ref="692218720"/>
|
||||
<reference key="NSDestination" ref="245526436"/>
|
||||
<string key="NSLabel">value: title</string>
|
||||
<string key="NSBinding">value</string>
|
||||
<string key="NSKeyPath">title</string>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">26</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">value: progressValue</string>
|
||||
<reference key="source" ref="454270533"/>
|
||||
<reference key="destination" ref="245526436"/>
|
||||
<object class="NSNibBindingConnector" key="connector">
|
||||
<reference key="NSSource" ref="454270533"/>
|
||||
<reference key="NSDestination" ref="245526436"/>
|
||||
<string key="NSLabel">value: progressValue</string>
|
||||
<string key="NSBinding">value</string>
|
||||
<string key="NSKeyPath">progressValue</string>
|
||||
<reference key="NSPreviousConnector" ref="110266706"/>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">27</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">hidden: statusText</string>
|
||||
<reference key="source" ref="65200871"/>
|
||||
<reference key="destination" ref="245526436"/>
|
||||
<object class="NSNibBindingConnector" key="connector">
|
||||
<reference key="NSSource" ref="65200871"/>
|
||||
<reference key="NSDestination" ref="245526436"/>
|
||||
<string key="NSLabel">hidden: statusText</string>
|
||||
<string key="NSBinding">hidden</string>
|
||||
<string key="NSKeyPath">statusText</string>
|
||||
<object class="NSDictionary" key="NSOptions">
|
||||
<string key="NS.key.0">NSValueTransformerName</string>
|
||||
<string key="NS.object.0">NSIsNil</string>
|
||||
</object>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">33</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">actionButton</string>
|
||||
<reference key="source" ref="245526436"/>
|
||||
<reference key="destination" ref="566879706"/>
|
||||
</object>
|
||||
<int key="connectionID">34</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">progressBar</string>
|
||||
<reference key="source" ref="245526436"/>
|
||||
<reference key="destination" ref="454270533"/>
|
||||
</object>
|
||||
<int key="connectionID">49</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">0</int>
|
||||
<reference key="object" ref="0"/>
|
||||
<reference key="children" ref="780577916"/>
|
||||
<nil key="parent"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-2</int>
|
||||
<reference key="object" ref="245526436"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">File's Owner</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-1</int>
|
||||
<reference key="object" ref="879485556"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">First Responder</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-3</int>
|
||||
<reference key="object" ref="472338989"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">Application</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">5</int>
|
||||
<reference key="object" ref="661323156"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="512815736"/>
|
||||
</object>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">Window</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">6</int>
|
||||
<reference key="object" ref="512815736"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="56655866"/>
|
||||
<reference ref="692218720"/>
|
||||
<reference ref="454270533"/>
|
||||
<reference ref="566879706"/>
|
||||
<reference ref="65200871"/>
|
||||
</object>
|
||||
<reference key="parent" ref="661323156"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">7</int>
|
||||
<reference key="object" ref="56655866"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="381943368"/>
|
||||
</object>
|
||||
<reference key="parent" ref="512815736"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">8</int>
|
||||
<reference key="object" ref="692218720"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="597081861"/>
|
||||
</object>
|
||||
<reference key="parent" ref="512815736"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">11</int>
|
||||
<reference key="object" ref="454270533"/>
|
||||
<reference key="parent" ref="512815736"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">12</int>
|
||||
<reference key="object" ref="566879706"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="130218013"/>
|
||||
</object>
|
||||
<reference key="parent" ref="512815736"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">16</int>
|
||||
<reference key="object" ref="65200871"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="180962568"/>
|
||||
</object>
|
||||
<reference key="parent" ref="512815736"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">53</int>
|
||||
<reference key="object" ref="381943368"/>
|
||||
<reference key="parent" ref="56655866"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">54</int>
|
||||
<reference key="object" ref="597081861"/>
|
||||
<reference key="parent" ref="692218720"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">55</int>
|
||||
<reference key="object" ref="130218013"/>
|
||||
<reference key="parent" ref="566879706"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">56</int>
|
||||
<reference key="object" ref="180962568"/>
|
||||
<reference key="parent" ref="65200871"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>-3.ImportedFromIB2</string>
|
||||
<string>11.ImportedFromIB2</string>
|
||||
<string>12.ImportedFromIB2</string>
|
||||
<string>16.ImportedFromIB2</string>
|
||||
<string>5.IBEditorWindowLastContentRect</string>
|
||||
<string>5.IBWindowTemplateEditedContentRect</string>
|
||||
<string>5.ImportedFromIB2</string>
|
||||
<string>5.windowTemplate.hasMinSize</string>
|
||||
<string>5.windowTemplate.minSize</string>
|
||||
<string>6.ImportedFromIB2</string>
|
||||
<string>7.ImportedFromIB2</string>
|
||||
<string>8.ImportedFromIB2</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<boolean value="YES"/>
|
||||
<boolean value="YES"/>
|
||||
<boolean value="YES"/>
|
||||
<boolean value="YES"/>
|
||||
<string>{{294, 716}, {400, 107}}</string>
|
||||
<string>{{294, 716}, {400, 107}}</string>
|
||||
<boolean value="YES"/>
|
||||
<boolean value="YES"/>
|
||||
<string>{213, 107}</string>
|
||||
<boolean value="YES"/>
|
||||
<boolean value="YES"/>
|
||||
<boolean value="YES"/>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="unlocalizedProperties">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference key="dict.sortedKeys" ref="0"/>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
</object>
|
||||
<nil key="activeLocalization"/>
|
||||
<object class="NSMutableDictionary" key="localizations">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference key="dict.sortedKeys" ref="0"/>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">56</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">FirstResponder</string>
|
||||
<string key="superclassName">NSObject</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBUserSource</string>
|
||||
<string key="minorKey"/>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">NSApplication</string>
|
||||
<string key="superclassName">NSResponder</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBUserSource</string>
|
||||
<string key="minorKey"/>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">NSObject</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBUserSource</string>
|
||||
<string key="minorKey"/>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">SUStatusController</string>
|
||||
<string key="superclassName">SUWindowController</string>
|
||||
<object class="NSMutableDictionary" key="outlets">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>actionButton</string>
|
||||
<string>progressBar</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>NSButton</string>
|
||||
<string>NSProgressIndicator</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBUserSource</string>
|
||||
<string key="minorKey"/>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">SUWindowController</string>
|
||||
<string key="superclassName">NSWindowController</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBUserSource</string>
|
||||
<string key="minorKey"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
|
||||
<integer value="1050" key="NS.object.0"/>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
|
||||
<integer value="3100" key="NS.object.0"/>
|
||||
</object>
|
||||
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||
<string key="IBDocument.LastKnownRelativeProjectPath">Sparkle.xcodeproj</string>
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
<object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
|
||||
<string key="NS.key.0">NSApplicationIcon</string>
|
||||
<string key="NS.object.0">{128, 128}</string>
|
||||
</object>
|
||||
</data>
|
||||
</archive>
|
||||
+9
-10
@@ -12,7 +12,9 @@
|
||||
#import "SUWindowController.h"
|
||||
|
||||
@class SUHost;
|
||||
@interface SUStatusController : SUWindowController {
|
||||
@interface SUStatusController : SUWindowController
|
||||
{
|
||||
@private
|
||||
double progressValue, maxProgressValue;
|
||||
NSString *title, *statusText, *buttonTitle;
|
||||
IBOutlet NSButton *actionButton;
|
||||
@@ -20,6 +22,11 @@
|
||||
SUHost *host;
|
||||
}
|
||||
|
||||
@property (copy) NSString *statusText;
|
||||
@property double progressValue;
|
||||
@property (nonatomic) double maxProgressValue;
|
||||
@property (getter = isButtonEnabled) BOOL buttonEnabled;
|
||||
|
||||
- (id)initWithHost:(SUHost *)host;
|
||||
|
||||
// Pass 0 for the max progress value to get an indeterminate progress bar.
|
||||
@@ -27,15 +34,7 @@
|
||||
- (void)beginActionWithTitle:(NSString *)title maxProgressValue:(double)maxProgressValue statusText:(NSString *)statusText;
|
||||
|
||||
// If isDefault is YES, the button's key equivalent will be \r.
|
||||
- (void)setButtonTitle:(NSString *)buttonTitle target:target action:(SEL)action isDefault:(BOOL)isDefault;
|
||||
- (void)setButtonEnabled:(BOOL)enabled;
|
||||
|
||||
- (double)progressValue;
|
||||
- (void)setProgressValue:(double)value;
|
||||
- (double)maxProgressValue;
|
||||
- (void)setMaxProgressValue:(double)value;
|
||||
|
||||
- (void)setStatusText:(NSString *)statusText;
|
||||
- (void)setButtonTitle:(NSString *)buttonTitle target:(id)target action:(SEL)action isDefault:(BOOL)isDefault;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+42
-42
@@ -6,17 +6,33 @@
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Sparkle.h"
|
||||
#import "SUUpdater.h"
|
||||
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUStatusController.h"
|
||||
#import "SUHost.h"
|
||||
|
||||
@interface SUStatusController ()
|
||||
@property (copy) NSString *title, *buttonTitle;
|
||||
@property (retain) SUHost *host;
|
||||
@end
|
||||
|
||||
@implementation SUStatusController
|
||||
@synthesize progressValue;
|
||||
@synthesize maxProgressValue;
|
||||
@synthesize statusText;
|
||||
@synthesize title;
|
||||
@synthesize buttonTitle;
|
||||
@synthesize host;
|
||||
|
||||
- (id)initWithHost:(SUHost *)aHost
|
||||
{
|
||||
self = [super initWithHost:aHost windowNibName:@"SUStatus"];
|
||||
if (self)
|
||||
{
|
||||
host = [aHost retain];
|
||||
self.host = aHost;
|
||||
[self setShouldCascadeWindows:NO];
|
||||
}
|
||||
return self;
|
||||
@@ -24,15 +40,21 @@
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[host release];
|
||||
[title release];
|
||||
[statusText release];
|
||||
[buttonTitle release];
|
||||
self.host = nil;
|
||||
self.title = nil;
|
||||
self.statusText = nil;
|
||||
self.buttonTitle = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; }
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
if ([host isBackgroundApplication]) {
|
||||
[[self window] setLevel:NSFloatingWindowLevel];
|
||||
}
|
||||
|
||||
[[self window] center];
|
||||
[[self window] setFrameAutosaveName:@"SUStatusFrame"];
|
||||
[progressBar setUsesThreadedAnimation:YES];
|
||||
@@ -50,23 +72,15 @@
|
||||
|
||||
- (void)beginActionWithTitle:(NSString *)aTitle maxProgressValue:(double)aMaxProgressValue statusText:(NSString *)aStatusText
|
||||
{
|
||||
[self willChangeValueForKey:@"title"];
|
||||
title = [aTitle copy];
|
||||
[self didChangeValueForKey:@"title"];
|
||||
self.title = aTitle;
|
||||
|
||||
[self setMaxProgressValue:aMaxProgressValue];
|
||||
[self setStatusText:aStatusText];
|
||||
self.maxProgressValue = aMaxProgressValue;
|
||||
self.statusText = aStatusText;
|
||||
}
|
||||
|
||||
- (void)setButtonTitle:(NSString *)aButtonTitle target:target action:(SEL)action isDefault:(BOOL)isDefault
|
||||
- (void)setButtonTitle:(NSString *)aButtonTitle target:(id)target action:(SEL)action isDefault:(BOOL)isDefault
|
||||
{
|
||||
[self willChangeValueForKey:@"buttonTitle"];
|
||||
if (buttonTitle != aButtonTitle)
|
||||
{
|
||||
[buttonTitle release];
|
||||
buttonTitle = [aButtonTitle copy];
|
||||
}
|
||||
[self didChangeValueForKey:@"buttonTitle"];
|
||||
self.buttonTitle = aButtonTitle;
|
||||
|
||||
[self window];
|
||||
[actionButton sizeToFit];
|
||||
@@ -80,6 +94,9 @@
|
||||
[actionButton setTarget:target];
|
||||
[actionButton setAction:action];
|
||||
[actionButton setKeyEquivalent:isDefault ? @"\r" : @""];
|
||||
|
||||
// 06/05/2008 Alex: Avoid a crash when cancelling during the extraction
|
||||
[self setButtonEnabled: (target != nil)];
|
||||
}
|
||||
|
||||
- (BOOL)progressBarShouldAnimate
|
||||
@@ -92,36 +109,19 @@
|
||||
[actionButton setEnabled:enabled];
|
||||
}
|
||||
|
||||
- (double)progressValue
|
||||
- (BOOL)isButtonEnabled
|
||||
{
|
||||
return progressValue;
|
||||
}
|
||||
|
||||
- (void)setProgressValue:(double)value
|
||||
{
|
||||
progressValue = value;
|
||||
}
|
||||
|
||||
- (double)maxProgressValue
|
||||
{
|
||||
return maxProgressValue;
|
||||
return [actionButton isEnabled];
|
||||
}
|
||||
|
||||
- (void)setMaxProgressValue:(double)value
|
||||
{
|
||||
if (value < 0) value = 0;
|
||||
if (value < 0.0) value = 0.0;
|
||||
maxProgressValue = value;
|
||||
[self setProgressValue:0];
|
||||
[self setProgressValue:0.0];
|
||||
[progressBar setIndeterminate:(value == 0.0)];
|
||||
[progressBar startAnimation:self];
|
||||
}
|
||||
|
||||
- (void)setStatusText:(NSString *)aStatusText
|
||||
{
|
||||
if (statusText != aStatusText)
|
||||
{
|
||||
[statusText release];
|
||||
statusText = [aStatusText copy];
|
||||
}
|
||||
[progressBar setUsesThreadedAnimation: YES];
|
||||
}
|
||||
|
||||
@end
|
||||
+3
-1
@@ -9,8 +9,10 @@
|
||||
#ifndef SUSYSTEMPROFILER_H
|
||||
#define SUSYSTEMPROFILER_H
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@class SUHost;
|
||||
@interface SUSystemProfiler : NSObject {}
|
||||
@interface SUSystemProfiler : NSObject
|
||||
+ (SUSystemProfiler *)sharedSystemProfiler;
|
||||
- (NSMutableArray *)systemProfileArrayForHost:(SUHost *)host;
|
||||
@end
|
||||
|
||||
+20
-21
@@ -10,7 +10,7 @@
|
||||
#import "SUSystemProfiler.h"
|
||||
|
||||
#import "SUHost.h"
|
||||
#import <sys/sysctl.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
@implementation SUSystemProfiler
|
||||
+ (SUSystemProfiler *)sharedSystemProfiler
|
||||
@@ -34,9 +34,9 @@
|
||||
// Gather profile information and append it to the URL.
|
||||
NSMutableArray *profileArray = [NSMutableArray array];
|
||||
NSArray *profileDictKeys = [NSArray arrayWithObjects:@"key", @"displayKey", @"value", @"displayValue", nil];
|
||||
int error = 0 ;
|
||||
int value = 0 ;
|
||||
unsigned long length = sizeof(value) ;
|
||||
int error = 0;
|
||||
int value = 0;
|
||||
size_t length = sizeof(value);
|
||||
|
||||
// OS version
|
||||
NSString *currentSystemVersion = [SUHost systemVersionString];
|
||||
@@ -50,9 +50,9 @@
|
||||
cpuType = value;
|
||||
NSString *visibleCPUType;
|
||||
switch(value) {
|
||||
case 7: visibleCPUType=@"Intel"; break;
|
||||
case 18: visibleCPUType=@"PowerPC"; break;
|
||||
default: visibleCPUType=@"Unknown"; break;
|
||||
case CPU_TYPE_X86: visibleCPUType = @"Intel"; break;
|
||||
case CPU_TYPE_POWERPC: visibleCPUType = @"PowerPC"; break;
|
||||
default: visibleCPUType = @"Unknown"; break;
|
||||
}
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"cputype",@"CPU Type", [NSNumber numberWithInt:value], visibleCPUType,nil] forKeys:profileDictKeys]];
|
||||
}
|
||||
@@ -89,18 +89,18 @@
|
||||
}
|
||||
error = sysctlbyname("hw.model", NULL, &length, NULL, 0);
|
||||
if (error == 0) {
|
||||
char *cpuModel;
|
||||
cpuModel = (char *)malloc(sizeof(char) * length);
|
||||
error = sysctlbyname("hw.model", cpuModel, &length, NULL, 0);
|
||||
if (error == 0) {
|
||||
NSString *rawModelName = [NSString stringWithUTF8String:cpuModel];
|
||||
NSString *visibleModelName = [modelTranslation objectForKey:rawModelName];
|
||||
if (visibleModelName == nil)
|
||||
visibleModelName = rawModelName;
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"model",@"Mac Model", rawModelName, visibleModelName, nil] forKeys:profileDictKeys]];
|
||||
}
|
||||
if (cpuModel != NULL)
|
||||
char *cpuModel = (char *)malloc(sizeof(char) * length);
|
||||
if (cpuModel != NULL) {
|
||||
error = sysctlbyname("hw.model", cpuModel, &length, NULL, 0);
|
||||
if (error == 0) {
|
||||
NSString *rawModelName = [NSString stringWithUTF8String:cpuModel];
|
||||
NSString *visibleModelName = [modelTranslation objectForKey:rawModelName];
|
||||
if (visibleModelName == nil)
|
||||
visibleModelName = rawModelName;
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"model",@"Mac Model", rawModelName, visibleModelName, nil] forKeys:profileDictKeys]];
|
||||
}
|
||||
free(cpuModel);
|
||||
}
|
||||
}
|
||||
|
||||
// Number of CPUs
|
||||
@@ -111,7 +111,7 @@
|
||||
// User preferred language
|
||||
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
||||
NSArray *languages = [defs objectForKey:@"AppleLanguages"];
|
||||
if (languages && ([languages count] > 0))
|
||||
if ([languages count] > 0)
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"lang",@"Preferred Language", [languages objectAtIndex:0], [languages objectAtIndex:0],nil] forKeys:profileDictKeys]];
|
||||
|
||||
// Application sending the request
|
||||
@@ -124,9 +124,8 @@
|
||||
|
||||
// Number of displays?
|
||||
// CPU speed
|
||||
OSErr err;
|
||||
SInt32 gestaltInfo;
|
||||
err = Gestalt(gestaltProcClkSpeedMHz,&gestaltInfo);
|
||||
OSErr err = Gestalt(gestaltProcClkSpeedMHz,&gestaltInfo);
|
||||
if (err == noErr)
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"cpuFreqMHz",@"CPU Speed (GHz)", [NSNumber numberWithInt:gestaltInfo], [NSNumber numberWithDouble:gestaltInfo/1000.0],nil] forKeys:profileDictKeys]];
|
||||
|
||||
|
||||
@@ -11,14 +11,19 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUBasicUpdateDriver.h"
|
||||
#import "SUUpdateAlert.h"
|
||||
|
||||
@class SUStatusController, SUUpdateAlert;
|
||||
@interface SUUIBasedUpdateDriver : SUBasicUpdateDriver {
|
||||
@class SUStatusController;
|
||||
|
||||
@interface SUUIBasedUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate, SUUpdateAlertDelegate>
|
||||
{
|
||||
SUStatusController *statusController;
|
||||
SUUpdateAlert *updateAlert;
|
||||
}
|
||||
|
||||
- (void)showModalAlert:(NSAlert *)alert;
|
||||
- (IBAction)cancelDownload: (id)sender;
|
||||
- (void)installAndRestart: (id)sender;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+73
-28
@@ -9,8 +9,10 @@
|
||||
#import "SUUIBasedUpdateDriver.h"
|
||||
|
||||
#import "SUUpdateAlert.h"
|
||||
#import "SUUpdater_Private.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUStatusController.h"
|
||||
#import "SUConstants.h"
|
||||
|
||||
@implementation SUUIBasedUpdateDriver
|
||||
|
||||
@@ -19,6 +21,11 @@
|
||||
updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:updateItem host:host];
|
||||
[updateAlert setDelegate:self];
|
||||
|
||||
id<SUVersionDisplay> versDisp = nil;
|
||||
if ([[updater delegate] respondsToSelector:@selector(versionDisplayerForUpdater:)])
|
||||
versDisp = [[updater delegate] versionDisplayerForUpdater: updater];
|
||||
[updateAlert setVersionDisplayer: versDisp];
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)])
|
||||
[[updater delegate] updater:updater didFindValidUpdate:updateItem];
|
||||
|
||||
@@ -42,7 +49,9 @@
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)])
|
||||
[[updater delegate] updaterDidNotFindUpdate:updater];
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"You're up to date!", nil) defaultButton:SULocalizedString(@"OK", nil) alternateButton:nil otherButton:nil informativeTextWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [host name], [host displayVersion]];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
|
||||
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"You're up-to-date!", nil) defaultButton:SULocalizedString(@"OK", nil) alternateButton:nil otherButton:nil informativeTextWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [host name], [host displayVersion]];
|
||||
[self showModalAlert:alert];
|
||||
[self abortUpdate];
|
||||
}
|
||||
@@ -61,14 +70,22 @@
|
||||
{
|
||||
case SUInstallUpdateChoice:
|
||||
statusController = [[SUStatusController alloc] initWithHost:host];
|
||||
[statusController beginActionWithTitle:SULocalizedString(@"Downloading update\u2026", @"Take care not to overflow the status window.") maxProgressValue:0 statusText:nil];
|
||||
[statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[statusController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelDownload:) isDefault:NO];
|
||||
[statusController showWindow:self];
|
||||
[self downloadUpdate];
|
||||
break;
|
||||
|
||||
|
||||
case SUOpenInfoURLChoice:
|
||||
[[NSWorkspace sharedWorkspace] openURL: [updateItem infoURL]];
|
||||
[self abortUpdate];
|
||||
break;
|
||||
|
||||
case SUSkipThisVersionChoice:
|
||||
[host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
|
||||
[self abortUpdate];
|
||||
break;
|
||||
|
||||
case SURemindMeLaterChoice:
|
||||
[self abortUpdate];
|
||||
break;
|
||||
@@ -80,30 +97,30 @@
|
||||
[statusController setMaxProgressValue:[response expectedContentLength]];
|
||||
}
|
||||
|
||||
- (NSString *)_humanReadableSizeFromDouble:(double)value
|
||||
- (NSString *)humanReadableSizeFromDouble:(double)value
|
||||
{
|
||||
if (value < 1024)
|
||||
if (value < 1000)
|
||||
return [NSString stringWithFormat:@"%.0lf %@", value, SULocalizedString(@"B", @"the unit for bytes")];
|
||||
|
||||
if (value < 1024 * 1024)
|
||||
return [NSString stringWithFormat:@"%.0lf %@", value / 1024.0, SULocalizedString(@"KB", @"the unit for kilobytes")];
|
||||
if (value < 1000 * 1000)
|
||||
return [NSString stringWithFormat:@"%.0lf %@", value / 1000.0, SULocalizedString(@"KB", @"the unit for kilobytes")];
|
||||
|
||||
if (value < 1024 * 1024 * 1024)
|
||||
return [NSString stringWithFormat:@"%.1lf %@", value / 1024.0 / 1024.0, SULocalizedString(@"MB", @"the unit for megabytes")];
|
||||
if (value < 1000 * 1000 * 1000)
|
||||
return [NSString stringWithFormat:@"%.1lf %@", value / 1000.0 / 1000.0, SULocalizedString(@"MB", @"the unit for megabytes")];
|
||||
|
||||
return [NSString stringWithFormat:@"%.2lf %@", value / 1024.0 / 1024.0 / 1024.0, SULocalizedString(@"GB", @"the unit for gigabytes")];
|
||||
return [NSString stringWithFormat:@"%.2lf %@", value / 1000.0 / 1000.0 / 1000.0, SULocalizedString(@"GB", @"the unit for gigabytes")];
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *)download didReceiveDataOfLength:(NSUInteger)length
|
||||
{
|
||||
[statusController setProgressValue:[statusController progressValue] + length];
|
||||
if ([statusController maxProgressValue] > 0)
|
||||
[statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ of %@", nil), [self _humanReadableSizeFromDouble:[statusController progressValue]], [self _humanReadableSizeFromDouble:[statusController maxProgressValue]]]];
|
||||
[statusController setProgressValue:[statusController progressValue] + (double)length];
|
||||
if ([statusController maxProgressValue] > 0.0)
|
||||
[statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ of %@", nil), [self humanReadableSizeFromDouble:[statusController progressValue]], [self humanReadableSizeFromDouble:[statusController maxProgressValue]]]];
|
||||
else
|
||||
[statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ downloaded", nil), [self _humanReadableSizeFromDouble:[statusController progressValue]]]];
|
||||
[statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ downloaded", nil), [self humanReadableSizeFromDouble:[statusController progressValue]]]];
|
||||
}
|
||||
|
||||
- (IBAction)cancelDownload:sender
|
||||
- (IBAction)cancelDownload: (id)sender
|
||||
{
|
||||
if (download)
|
||||
[download cancel];
|
||||
@@ -113,40 +130,61 @@
|
||||
- (void)extractUpdate
|
||||
{
|
||||
// Now we have to extract the downloaded archive.
|
||||
[statusController beginActionWithTitle:SULocalizedString(@"Extracting update\u2026", @"Take care not to overflow the status window.") maxProgressValue:0 statusText:nil];
|
||||
[statusController beginActionWithTitle:SULocalizedString(@"Extracting update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[statusController setButtonEnabled:NO];
|
||||
[super extractUpdate];
|
||||
}
|
||||
|
||||
- (void)unarchiver:(SUUnarchiver *)ua extractedLength:(long)length
|
||||
- (void)unarchiver:(SUUnarchiver *)ua extractedLength:(unsigned long)length
|
||||
{
|
||||
// We do this here instead of in extractUpdate so that we only have a determinate progress bar for archives with progress.
|
||||
if ([statusController maxProgressValue] == 0)
|
||||
[statusController setMaxProgressValue:[[[[NSFileManager defaultManager] fileAttributesAtPath:downloadPath traverseLink:NO] objectForKey:NSFileSize] doubleValue]];
|
||||
[statusController setProgressValue:[statusController progressValue] + length];
|
||||
if ([statusController maxProgressValue] == 0.0)
|
||||
{
|
||||
NSDictionary * attributes;
|
||||
attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:downloadPath error:nil];
|
||||
[statusController setMaxProgressValue:[[attributes objectForKey:NSFileSize] doubleValue]];
|
||||
}
|
||||
[statusController setProgressValue:[statusController progressValue] + (double)length];
|
||||
}
|
||||
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)ua
|
||||
{
|
||||
[statusController beginActionWithTitle:SULocalizedString(@"Ready to Install", nil) maxProgressValue:1 statusText:nil];
|
||||
[statusController setProgressValue:1]; // Fill the bar.
|
||||
[statusController beginActionWithTitle:SULocalizedString(@"Ready to Install", nil) maxProgressValue:1.0 statusText:nil];
|
||||
[statusController setProgressValue:1.0]; // Fill the bar.
|
||||
[statusController setButtonEnabled:YES];
|
||||
[statusController setButtonTitle:SULocalizedString(@"Install and Relaunch", nil) target:self action:@selector(installAndRestart:) isDefault:YES];
|
||||
[[statusController window] makeKeyAndOrderFront: self];
|
||||
[NSApp requestUserAttention:NSInformationalRequest];
|
||||
}
|
||||
|
||||
- (void)installAndRestart:sender { [self installUpdate]; }
|
||||
|
||||
- (void)installUpdate
|
||||
- (void)installAndRestart: (id)sender
|
||||
{
|
||||
[statusController beginActionWithTitle:SULocalizedString(@"Installing update\u2026", @"Take care not to overflow the status window.") maxProgressValue:0 statusText:nil];
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
}
|
||||
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch
|
||||
{
|
||||
[statusController beginActionWithTitle:SULocalizedString(@"Installing update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[statusController setButtonEnabled:NO];
|
||||
[super installUpdate];
|
||||
[super installWithToolAndRelaunch:relaunch];
|
||||
|
||||
|
||||
// if a user chooses to NOT relaunch the app (as is the case with WebKit
|
||||
// when it asks you if you are sure you want to close the app with multiple
|
||||
// tabs open), the status window still stays on the screen and obscures
|
||||
// other windows; with this fix, it doesn't
|
||||
|
||||
if (statusController)
|
||||
{
|
||||
[statusController close];
|
||||
[statusController autorelease];
|
||||
statusController = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)abortUpdateWithError:(NSError *)error
|
||||
{
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"Update Error!", nil) defaultButton:SULocalizedString(@"Cancel Update", nil) alternateButton:nil otherButton:nil informativeTextWithFormat:[error localizedDescription]];
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"Update Error!", nil) defaultButton:SULocalizedString(@"Cancel Update", nil) alternateButton:nil otherButton:nil informativeTextWithFormat: @"%@", [error localizedDescription]];
|
||||
[self showModalAlert:alert];
|
||||
[super abortUpdateWithError:error];
|
||||
}
|
||||
@@ -157,18 +195,25 @@
|
||||
{
|
||||
[statusController close];
|
||||
[statusController autorelease];
|
||||
statusController = nil;
|
||||
}
|
||||
[super abortUpdate];
|
||||
}
|
||||
|
||||
- (void)showModalAlert:(NSAlert *)alert
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterWillShowModalAlert:)])
|
||||
[[updater delegate] updaterWillShowModalAlert: updater];
|
||||
|
||||
// When showing a modal alert we need to ensure that background applications
|
||||
// are focused to inform the user since there is no dock icon to notify them.
|
||||
if ([host isBackgroundApplication]) { [NSApp activateIgnoringOtherApps:YES]; }
|
||||
|
||||
[alert setIcon:[host icon]];
|
||||
[alert runModal];
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterDidShowModalAlert:)])
|
||||
[[updater delegate] updaterDidShowModalAlert: updater];
|
||||
}
|
||||
|
||||
@end
|
||||
+13
-9
@@ -9,22 +9,26 @@
|
||||
#ifndef SUUNARCHIVER_H
|
||||
#define SUUNARCHIVER_H
|
||||
|
||||
@interface SUUnarchiver : NSObject {
|
||||
id delegate;
|
||||
NSString *archivePath;
|
||||
}
|
||||
@class SUHost;
|
||||
@protocol SUUnarchiverDelegate;
|
||||
|
||||
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path;
|
||||
- (void)setDelegate:delegate;
|
||||
@interface SUUnarchiver : NSObject {
|
||||
id<SUUnarchiverDelegate> delegate;
|
||||
NSString *archivePath;
|
||||
SUHost *updateHost;
|
||||
}
|
||||
@property (assign) id<SUUnarchiverDelegate> delegate;
|
||||
|
||||
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHost:(SUHost *)host;
|
||||
|
||||
- (void)start;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSObject (SUUnarchiverDelegate)
|
||||
- (void)unarchiver:(SUUnarchiver *)unarchiver extractedLength:(long)length;
|
||||
@protocol SUUnarchiverDelegate <NSObject>
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)unarchiver;
|
||||
- (void)unarchiverDidFail:(SUUnarchiver *)unarchiver;
|
||||
@optional
|
||||
- (void)unarchiver:(SUUnarchiver *)unarchiver extractedLength:(unsigned long)length;
|
||||
@end
|
||||
|
||||
#endif
|
||||
+11
-13
@@ -7,30 +7,28 @@
|
||||
//
|
||||
|
||||
|
||||
#import "Sparkle.h"
|
||||
#import "SUUpdater.h"
|
||||
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUUnarchiver.h"
|
||||
#import "SUUnarchiver_Private.h"
|
||||
|
||||
@implementation SUUnarchiver
|
||||
@synthesize delegate;
|
||||
|
||||
extern NSMutableArray *__unarchiverImplementations;
|
||||
|
||||
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path
|
||||
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHost:(SUHost *)host
|
||||
{
|
||||
NSEnumerator *implementationEnumerator = [[self _unarchiverImplementations] objectEnumerator];
|
||||
id current;
|
||||
while ((current = [implementationEnumerator nextObject]))
|
||||
for (id current in [self unarchiverImplementations])
|
||||
{
|
||||
if ([current _canUnarchivePath:path])
|
||||
return [[[current alloc] _initWithPath:path] autorelease];
|
||||
if ([current canUnarchivePath:path])
|
||||
return [[[current alloc] initWithPath:path host:host] autorelease];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)setDelegate:del
|
||||
{
|
||||
delegate = del;
|
||||
}
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], archivePath]; }
|
||||
|
||||
- (void)start
|
||||
{
|
||||
|
||||
@@ -13,14 +13,14 @@
|
||||
#import "SUUnarchiver.h"
|
||||
|
||||
@interface SUUnarchiver (Private)
|
||||
+ (void)_registerImplementation:(Class)implementation;
|
||||
+ (NSArray *)_unarchiverImplementations;
|
||||
+ (BOOL)_canUnarchivePath:(NSString *)path;
|
||||
- _initWithPath:(NSString *)path;
|
||||
+ (void)registerImplementation:(Class)implementation;
|
||||
+ (NSArray *)unarchiverImplementations;
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path;
|
||||
- (id)initWithPath:(NSString *)path host:(SUHost *)host;
|
||||
|
||||
- (void)_notifyDelegateOfExtractedLength:(long)length;
|
||||
- (void)_notifyDelegateOfSuccess;
|
||||
- (void)_notifyDelegateOfFailure;
|
||||
- (void)notifyDelegateOfExtractedLength:(NSNumber *)length;
|
||||
- (void)notifyDelegateOfSuccess;
|
||||
- (void)notifyDelegateOfFailure;
|
||||
@end
|
||||
|
||||
#endif
|
||||
+17
-13
@@ -10,54 +10,58 @@
|
||||
|
||||
@implementation SUUnarchiver (Private)
|
||||
|
||||
- _initWithPath:(NSString *)path
|
||||
- (id)initWithPath:(NSString *)path host:(SUHost *)host
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
archivePath = [path copy];
|
||||
updateHost = [host retain];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[archivePath release];
|
||||
[updateHost release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
+ (BOOL)_canUnarchivePath:(NSString *)path
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)_notifyDelegateOfExtractedLength:(long)length
|
||||
- (void)notifyDelegateOfExtractedLength:(NSNumber *)length
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(unarchiver:extractedLength:)])
|
||||
[delegate unarchiver:self extractedLength:length];
|
||||
[delegate unarchiver:self extractedLength:[length unsignedLongValue]];
|
||||
}
|
||||
|
||||
- (void)_notifyDelegateOfSuccess
|
||||
- (void)notifyDelegateOfSuccess
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(unarchiverDidFinish:)])
|
||||
[delegate performSelector:@selector(unarchiverDidFinish:) withObject:self];
|
||||
}
|
||||
|
||||
- (void)_notifyDelegateOfFailure
|
||||
- (void)notifyDelegateOfFailure
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(unarchiverDidFail:)])
|
||||
[delegate performSelector:@selector(unarchiverDidFail:) withObject:self];
|
||||
}
|
||||
|
||||
static NSMutableArray *__unarchiverImplementations;
|
||||
static NSMutableArray *gUnarchiverImplementations;
|
||||
|
||||
+ (void)_registerImplementation:(Class)implementation
|
||||
+ (void)registerImplementation:(Class)implementation
|
||||
{
|
||||
if (!__unarchiverImplementations)
|
||||
__unarchiverImplementations = [[NSMutableArray alloc] init];
|
||||
[__unarchiverImplementations addObject:implementation];
|
||||
if (!gUnarchiverImplementations)
|
||||
gUnarchiverImplementations = [[NSMutableArray alloc] init];
|
||||
[gUnarchiverImplementations addObject:implementation];
|
||||
}
|
||||
|
||||
+ (NSArray *)_unarchiverImplementations
|
||||
+ (NSArray *)unarchiverImplementations
|
||||
{
|
||||
return [NSArray arrayWithArray:__unarchiverImplementations];
|
||||
return [NSArray arrayWithArray:gUnarchiverImplementations];
|
||||
}
|
||||
|
||||
@end
|
||||
+16
-4
@@ -10,37 +10,49 @@
|
||||
#define SUUPDATEALERT_H
|
||||
|
||||
#import "SUWindowController.h"
|
||||
#import "SUVersionDisplayProtocol.h"
|
||||
|
||||
@protocol SUUpdateAlertDelegate;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SUInstallUpdateChoice,
|
||||
SURemindMeLaterChoice,
|
||||
SUSkipThisVersionChoice
|
||||
SUSkipThisVersionChoice,
|
||||
SUOpenInfoURLChoice
|
||||
} SUUpdateAlertChoice;
|
||||
|
||||
@class WebView, SUAppcastItem, SUHost;
|
||||
@interface SUUpdateAlert : SUWindowController {
|
||||
SUAppcastItem *updateItem;
|
||||
SUHost *host;
|
||||
id delegate;
|
||||
id<SUUpdateAlertDelegate> delegate;
|
||||
id<SUVersionDisplay> versionDisplayer;
|
||||
|
||||
IBOutlet WebView *releaseNotesView;
|
||||
IBOutlet NSTextField *description;
|
||||
IBOutlet NSButton *installButton; // UK 2007-08-31.
|
||||
IBOutlet NSButton *skipButton;
|
||||
IBOutlet NSButton *laterButton;
|
||||
NSProgressIndicator *releaseNotesSpinner;
|
||||
BOOL webViewFinishedLoading;
|
||||
}
|
||||
@property (assign) id<SUUpdateAlertDelegate> delegate;
|
||||
|
||||
- (id)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host;
|
||||
- (void)setDelegate:delegate;
|
||||
|
||||
- (IBAction)installUpdate:sender;
|
||||
- (IBAction)skipThisVersion:sender;
|
||||
- (IBAction)remindMeLater:sender;
|
||||
|
||||
- (void)setVersionDisplayer: (id<SUVersionDisplay>)disp;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSObject (SUUpdateAlertDelegate)
|
||||
@protocol SUUpdateAlertDelegate <NSObject>
|
||||
- (void)updateAlert:(SUUpdateAlert *)updateAlert finishedWithChoice:(SUUpdateAlertChoice)updateChoice;
|
||||
@optional
|
||||
- (void)updateAlert:(SUUpdateAlert *)updateAlert shouldAllowAutoUpdate: (BOOL*)shouldAllowAutoUpdate;
|
||||
@end
|
||||
|
||||
#endif
|
||||
+200
-26
@@ -6,12 +6,27 @@
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Headers:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#import "SUUpdateAlert.h"
|
||||
|
||||
#import "SUHost.h"
|
||||
#import <WebKit/WebKit.h>
|
||||
|
||||
#import "SUConstants.h"
|
||||
|
||||
|
||||
@interface WebView ()
|
||||
|
||||
-(void) setDrawsBackground: (BOOL)state;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation SUUpdateAlert
|
||||
@synthesize delegate;
|
||||
|
||||
- (id)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost
|
||||
{
|
||||
@@ -21,10 +36,17 @@
|
||||
host = [aHost retain];
|
||||
updateItem = [item retain];
|
||||
[self setShouldCascadeWindows:NO];
|
||||
|
||||
// Alex: This dummy line makes sure that the binary is linked against WebKit.
|
||||
// The SUUpdateAlert.xib file contains a WebView and if we don't link against WebKit,
|
||||
// we will get a runtime crash when decoding the NIB. It is better to get a link error.
|
||||
[WebView MIMETypesShownAsHTML];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [host bundlePath]]; }
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[updateItem release];
|
||||
@@ -32,35 +54,54 @@
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)setVersionDisplayer: (id<SUVersionDisplay>)disp
|
||||
{
|
||||
versionDisplayer = disp;
|
||||
}
|
||||
|
||||
- (void)endWithSelection:(SUUpdateAlertChoice)choice
|
||||
{
|
||||
[releaseNotesView stopLoading:self];
|
||||
[releaseNotesView setFrameLoadDelegate:nil];
|
||||
[releaseNotesView setPolicyDelegate:nil];
|
||||
[releaseNotesView removeFromSuperview]; // Otherwise it gets sent Esc presses (why?!) and gets very confused.
|
||||
[self close];
|
||||
if ([delegate respondsToSelector:@selector(updateAlert:finishedWithChoice:)])
|
||||
[delegate updateAlert:self finishedWithChoice:choice];
|
||||
}
|
||||
|
||||
- (IBAction)installUpdate:sender
|
||||
- (IBAction)installUpdate: (id)sender
|
||||
{
|
||||
[self endWithSelection:SUInstallUpdateChoice];
|
||||
}
|
||||
|
||||
- (IBAction)skipThisVersion:sender
|
||||
- (IBAction)openInfoURL: (id)sender
|
||||
{
|
||||
[self endWithSelection:SUOpenInfoURLChoice];
|
||||
}
|
||||
|
||||
- (IBAction)skipThisVersion: (id)sender
|
||||
{
|
||||
[self endWithSelection:SUSkipThisVersionChoice];
|
||||
}
|
||||
|
||||
- (IBAction)remindMeLater:sender
|
||||
- (IBAction)remindMeLater: (id)sender
|
||||
{
|
||||
[self endWithSelection:SURemindMeLaterChoice];
|
||||
}
|
||||
|
||||
- (void)displayReleaseNotes
|
||||
{
|
||||
[[WebPreferences standardPreferences] setStandardFontFamily:[[NSFont systemFontOfSize:8] familyName]];
|
||||
[releaseNotesView setPreferences:[WebPreferences standardPreferences]];
|
||||
// Set the default font
|
||||
[releaseNotesView setPreferencesIdentifier:[SPARKLE_BUNDLE bundleIdentifier]];
|
||||
WebPreferences *prefs = [releaseNotesView preferences];
|
||||
NSString *familyName = [[NSFont systemFontOfSize:8] familyName];
|
||||
if ([familyName hasPrefix:@"."]) { // 10.9 returns ".Lucida Grande UI", which isn't a valid name for the WebView
|
||||
familyName = @"Lucida Grande";
|
||||
}
|
||||
[prefs setStandardFontFamily:familyName];
|
||||
[prefs setDefaultFontSize:(int)[NSFont systemFontSizeForControlSize:NSSmallControlSize]];
|
||||
[prefs setPlugInsEnabled:NO];
|
||||
[releaseNotesView setFrameLoadDelegate:self];
|
||||
[releaseNotesView setPolicyDelegate:self];
|
||||
|
||||
@@ -75,11 +116,18 @@
|
||||
// If there's a release notes URL, load it; otherwise, just stick the contents of the description into the web view.
|
||||
if ([updateItem releaseNotesURL])
|
||||
{
|
||||
[[releaseNotesView mainFrame] loadRequest:[NSURLRequest requestWithURL:[updateItem releaseNotesURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]];
|
||||
if ([[updateItem releaseNotesURL] isFileURL])
|
||||
{
|
||||
[[releaseNotesView mainFrame] loadHTMLString:@"Release notes with file:// URLs are not supported for security reasons—Javascript would be able to read files on your file system." baseURL:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[releaseNotesView mainFrame] loadRequest:[NSURLRequest requestWithURL:[updateItem releaseNotesURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[[releaseNotesView mainFrame] loadHTMLString:[updateItem description] baseURL:nil];
|
||||
[[releaseNotesView mainFrame] loadHTMLString:[updateItem itemDescription] baseURL:nil];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,51 +135,142 @@
|
||||
{
|
||||
NSNumber *shouldShowReleaseNotes = [host objectForInfoDictionaryKey:SUShowReleaseNotesKey];
|
||||
if (shouldShowReleaseNotes == nil)
|
||||
return YES; // defaults to YES
|
||||
{
|
||||
// UK 2007-09-18: Don't show release notes if RSS item contains no description and no release notes URL:
|
||||
return( ([updateItem itemDescription] != nil
|
||||
&& [[[updateItem itemDescription] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]] length] > 0)
|
||||
|| [updateItem releaseNotesURL] != nil );
|
||||
}
|
||||
else
|
||||
return [shouldShowReleaseNotes boolValue];
|
||||
}
|
||||
|
||||
- (BOOL)allowsAutomaticUpdates
|
||||
{
|
||||
if (![[host objectForInfoDictionaryKey:SUExpectsDSASignatureKey] boolValue])
|
||||
return NO; // Automatic updating requires DSA-signed updates
|
||||
if (![host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey])
|
||||
return YES; // defaults to YES
|
||||
return [[host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] boolValue];
|
||||
BOOL allowAutoUpdates = YES; // Defaults to YES.
|
||||
if( [host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] )
|
||||
allowAutoUpdates = [host boolForInfoDictionaryKey: SUAllowsAutomaticUpdatesKey];
|
||||
|
||||
// UK 2007-08-31: Give delegate a chance to modify this choice:
|
||||
if( delegate && [delegate respondsToSelector: @selector(updateAlert:shouldAllowAutoUpdate:)] )
|
||||
[delegate updateAlert: self shouldAllowAutoUpdate: &allowAutoUpdates];
|
||||
|
||||
return allowAutoUpdates;
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[[self window] setLevel:NSFloatingWindowLevel];
|
||||
NSString* sizeStr = [host objectForInfoDictionaryKey:SUFixedHTMLDisplaySizeKey];
|
||||
|
||||
if( [host isBackgroundApplication] )
|
||||
[[self window] setLevel:NSFloatingWindowLevel]; // This means the window will float over all other apps, if our app is switched out ?! UK 2007-09-04
|
||||
[[self window] setFrameAutosaveName: sizeStr ? @"" : @"SUUpdateAlertFrame"];
|
||||
|
||||
// We're gonna do some frame magic to match the window's size to the description field and the presence of the release notes view.
|
||||
NSRect frame = [[self window] frame];
|
||||
|
||||
if (![self showsReleaseNotes])
|
||||
NSRect frame = [[self window] frame];
|
||||
BOOL showReleaseNotes = [self showsReleaseNotes]; // UK 2007-09-18
|
||||
if (!showReleaseNotes) // UK 2007-09-18
|
||||
{
|
||||
// Resize the window to be appropriate for not having a huge release notes view.
|
||||
frame.size.height -= [releaseNotesView frame].size.height + 40; // Extra 40 is for the release notes label and margin.
|
||||
[[self window] setShowsResizeIndicator:NO];
|
||||
|
||||
if ([self allowsAutomaticUpdates])
|
||||
frame.size.height += 10; // Make room for the check box.
|
||||
|
||||
// Hiding the resize handles is not enough on 10.5, you can still click
|
||||
// where they would be, so we set the min/max sizes to be equal to
|
||||
// inhibit resizing completely:
|
||||
[[self window] setShowsResizeIndicator: NO];
|
||||
[[self window] setMinSize: frame.size];
|
||||
[[self window] setMaxSize: frame.size];
|
||||
}
|
||||
|
||||
if (![self allowsAutomaticUpdates])
|
||||
else if (![self allowsAutomaticUpdates])
|
||||
{
|
||||
NSRect boxFrame = [[[releaseNotesView superview] superview] frame];
|
||||
boxFrame.origin.y -= 20;
|
||||
boxFrame.size.height += 20;
|
||||
[[[releaseNotesView superview] superview] setFrame:boxFrame];
|
||||
}
|
||||
|
||||
if( [updateItem fileURL] == nil ) // UK 2007-08-31 (whole if clause)
|
||||
{
|
||||
[installButton setTitle: SULocalizedString( @"Learn More...", @"Alternate title for 'Install Update' button when there's no download in RSS feed." )];
|
||||
[installButton setAction: @selector(openInfoURL:)];
|
||||
}
|
||||
|
||||
[[self window] setFrame:frame display:NO];
|
||||
// Make sure button widths are OK:
|
||||
#define DISTANCE_BETWEEN_BUTTONS 3
|
||||
#define DISTANCE_BETWEEN_BUTTON_GROUPS 12
|
||||
|
||||
CGFloat minimumWindowWidth = [[self window] frame].size.width -NSMaxX([installButton frame]) +NSMinX([skipButton frame]); // Distance between contents and left/right edge.
|
||||
NSDictionary* attrs = [NSDictionary dictionaryWithObjectsAndKeys: [installButton font], NSFontAttributeName, nil];
|
||||
NSSize titleSize = [[installButton title] sizeWithAttributes: attrs];
|
||||
titleSize.width += (16 + 8) * 2; // 16 px for the end caps plus 8 px padding at each end or it'll look as ugly as calling -sizeToFit.
|
||||
NSRect installBtnBox = [installButton frame];
|
||||
installBtnBox.origin.x += installBtnBox.size.width -titleSize.width;
|
||||
installBtnBox.size.width = titleSize.width;
|
||||
[installButton setFrame: installBtnBox];
|
||||
minimumWindowWidth += titleSize.width;
|
||||
|
||||
titleSize = [[laterButton title] sizeWithAttributes: attrs];
|
||||
titleSize.width += (16 + 8) * 2; // 16 px for the end caps plus 8 px padding at each end or it'll look as ugly as calling -sizeToFit.
|
||||
NSRect laterBtnBox = [installButton frame];
|
||||
laterBtnBox.origin.x = installBtnBox.origin.x -DISTANCE_BETWEEN_BUTTONS -titleSize.width;
|
||||
laterBtnBox.size.width = titleSize.width;
|
||||
[laterButton setFrame: laterBtnBox];
|
||||
minimumWindowWidth += DISTANCE_BETWEEN_BUTTONS +titleSize.width;
|
||||
|
||||
titleSize = [[skipButton title] sizeWithAttributes: attrs];
|
||||
titleSize.width += (16 + 8) * 2; // 16 px for the end caps plus 8 px padding at each end or it'll look as ugly as calling -sizeToFit.
|
||||
NSRect skipBtnBox = [skipButton frame];
|
||||
skipBtnBox.size.width = titleSize.width;
|
||||
[skipButton setFrame: skipBtnBox];
|
||||
minimumWindowWidth += DISTANCE_BETWEEN_BUTTON_GROUPS +titleSize.width;
|
||||
|
||||
if( showReleaseNotes ) // UK 2007-09-18 (whole block)
|
||||
{
|
||||
if( sizeStr )
|
||||
{
|
||||
NSSize desiredSize = NSSizeFromString( sizeStr );
|
||||
NSSize sizeDiff = NSZeroSize;
|
||||
// NSBox* boxView = (NSBox*)[[releaseNotesView superview] superview];
|
||||
|
||||
//[boxView setBorderType: NSNoBorder];
|
||||
[releaseNotesView setDrawsBackground: NO];
|
||||
|
||||
sizeDiff.width = desiredSize.width -[releaseNotesView frame].size.width;
|
||||
sizeDiff.height = desiredSize.height -[releaseNotesView frame].size.height;
|
||||
frame.size.width += sizeDiff.width;
|
||||
frame.size.height += sizeDiff.height;
|
||||
|
||||
// No resizing:
|
||||
[[self window] setShowsResizeIndicator:NO];
|
||||
[[self window] setMinSize:frame.size];
|
||||
[[self window] setMaxSize:frame.size];
|
||||
}
|
||||
}
|
||||
|
||||
if( frame.size.width < minimumWindowWidth )
|
||||
frame.size.width = minimumWindowWidth;
|
||||
|
||||
[[self window] setFrame: frame display: NO];
|
||||
[[self window] center];
|
||||
|
||||
if ([self showsReleaseNotes])
|
||||
if (showReleaseNotes) // UK 2007-09-18
|
||||
{
|
||||
[self displayReleaseNotes];
|
||||
}
|
||||
|
||||
[[[releaseNotesView superview] superview] setHidden: !showReleaseNotes]; // UK 2007-09-18
|
||||
|
||||
}
|
||||
|
||||
-(BOOL)showsReleaseNotesText
|
||||
{
|
||||
return( [host objectForInfoDictionaryKey:SUFixedHTMLDisplaySizeKey] == nil );
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)windowShouldClose:note
|
||||
{
|
||||
[self endWithSelection:SURemindMeLaterChoice];
|
||||
@@ -150,7 +289,17 @@
|
||||
|
||||
- (NSString *)descriptionText
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available\u2014you have %@. Would you like to download it now?", nil), [host name], [updateItem displayVersionString], [host displayVersion]];
|
||||
NSString *updateItemVersion = [updateItem displayVersionString];
|
||||
NSString *hostVersion = [host displayVersion];
|
||||
// Display more info if the version strings are the same; useful for betas.
|
||||
if( !versionDisplayer && [updateItemVersion isEqualToString:hostVersion] )
|
||||
{
|
||||
updateItemVersion = [updateItemVersion stringByAppendingFormat:@" (%@)", [updateItem versionString]];
|
||||
hostVersion = [hostVersion stringByAppendingFormat:@" (%@)", [host version]];
|
||||
}
|
||||
else
|
||||
[versionDisplayer formatVersion: &updateItemVersion andVersion: &hostVersion];
|
||||
return [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to download it now?", nil), [host name], updateItemVersion, hostVersion];
|
||||
}
|
||||
|
||||
- (void)webView:(WebView *)sender didFinishLoadForFrame:frame
|
||||
@@ -164,7 +313,7 @@
|
||||
|
||||
- (void)webView:sender decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:frame decisionListener:listener
|
||||
{
|
||||
if (webViewFinishedLoading == YES) {
|
||||
if (webViewFinishedLoading) {
|
||||
[[NSWorkspace sharedWorkspace] openURL:[request URL]];
|
||||
|
||||
[listener ignore];
|
||||
@@ -174,9 +323,34 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setDelegate:del
|
||||
// Clean up the contextual menu.
|
||||
- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems
|
||||
{
|
||||
delegate = del;
|
||||
NSMutableArray *webViewMenuItems = [[defaultMenuItems mutableCopy] autorelease];
|
||||
|
||||
if (webViewMenuItems)
|
||||
{
|
||||
for (NSMenuItem *menuItem in defaultMenuItems)
|
||||
{
|
||||
NSInteger tag = [menuItem tag];
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case WebMenuItemTagOpenLinkInNewWindow:
|
||||
case WebMenuItemTagDownloadLinkToDisk:
|
||||
case WebMenuItemTagOpenImageInNewWindow:
|
||||
case WebMenuItemTagDownloadImageToDisk:
|
||||
case WebMenuItemTagOpenFrameInNewWindow:
|
||||
case WebMenuItemTagGoBack:
|
||||
case WebMenuItemTagGoForward:
|
||||
case WebMenuItemTagStop:
|
||||
case WebMenuItemTagReload:
|
||||
[webViewMenuItems removeObjectIdenticalTo: menuItem];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return webViewMenuItems;
|
||||
}
|
||||
|
||||
@end
|
||||
+7
-3
@@ -11,20 +11,24 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
extern NSString *SUUpdateDriverFinishedNotification;
|
||||
extern NSString * const SUUpdateDriverFinishedNotification;
|
||||
|
||||
@class SUHost, SUUpdater;
|
||||
@interface SUUpdateDriver : NSObject
|
||||
@interface SUUpdateDriver : NSObject<NSURLDownloadDelegate>
|
||||
{
|
||||
SUHost *host;
|
||||
SUUpdater *updater;
|
||||
NSURL *appcastURL;
|
||||
|
||||
BOOL finished;
|
||||
BOOL isInterruptible;
|
||||
}
|
||||
@property (retain) SUHost *host;
|
||||
|
||||
- initWithUpdater:(SUUpdater *)updater;
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)appcastURL host:(SUHost *)host;
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
|
||||
- (void)abortUpdate;
|
||||
- (BOOL)isInterruptible;
|
||||
- (BOOL)finished;
|
||||
|
||||
@end
|
||||
|
||||
+19
-2
@@ -7,10 +7,14 @@
|
||||
//
|
||||
|
||||
#import "SUUpdateDriver.h"
|
||||
#import "SUHost.h"
|
||||
|
||||
NSString *SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished";
|
||||
NSString * const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished";
|
||||
|
||||
@implementation SUUpdateDriver
|
||||
|
||||
@synthesize host;
|
||||
|
||||
- initWithUpdater:(SUUpdater *)anUpdater
|
||||
{
|
||||
if ((self = [super init]))
|
||||
@@ -18,8 +22,11 @@ NSString *SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished";
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)appcastURL host:(SUHost *)h
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; }
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)h
|
||||
{
|
||||
appcastURL = [URL copy];
|
||||
host = [h retain];
|
||||
}
|
||||
|
||||
@@ -29,5 +36,15 @@ NSString *SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished";
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdateDriverFinishedNotification object:self];
|
||||
}
|
||||
|
||||
- (BOOL)isInterruptible { return isInterruptible; }
|
||||
|
||||
- (BOOL)finished { return finished; }
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
self.host = nil;
|
||||
[appcastURL release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -24,6 +24,7 @@ typedef enum {
|
||||
IBOutlet NSTextField *descriptionTextField;
|
||||
IBOutlet NSView *moreInfoView;
|
||||
IBOutlet NSButton *moreInfoButton;
|
||||
IBOutlet NSTableView *profileTableView;
|
||||
BOOL isShowingMoreInfo, shouldSendProfile;
|
||||
}
|
||||
+ (void)promptWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile delegate:(id)d;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#import "SUUpdatePermissionPrompt.h"
|
||||
|
||||
#import "SUHost.h"
|
||||
#import "SUConstants.h"
|
||||
|
||||
@implementation SUUpdatePermissionPrompt
|
||||
|
||||
@@ -23,7 +24,7 @@
|
||||
if (self)
|
||||
{
|
||||
host = [aHost retain];
|
||||
delegate = [d retain];
|
||||
delegate = d;
|
||||
isShowingMoreInfo = NO;
|
||||
shouldSendProfile = [self shouldAskAboutProfile];
|
||||
systemProfileInformationArray = [profile retain];
|
||||
@@ -39,10 +40,12 @@
|
||||
// the user would not know why the application was paused.
|
||||
if ([aHost isBackgroundApplication]) { [NSApp activateIgnoringOtherApps:YES]; }
|
||||
|
||||
id prompt = [[[self class] alloc] initWithHost:aHost systemProfile:profile delegate:d];
|
||||
id prompt = [[[[self class] alloc] initWithHost:aHost systemProfile:profile delegate:d] autorelease];
|
||||
[NSApp runModalForWindow:[prompt window]];
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [host bundlePath]]; }
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
if (![self shouldAskAboutProfile])
|
||||
@@ -50,9 +53,14 @@
|
||||
NSRect frame = [[self window] frame];
|
||||
frame.size.height -= [moreInfoButton frame].size.height;
|
||||
[[self window] setFrame:frame display:YES];
|
||||
}
|
||||
} else {
|
||||
// Set the table view's delegate so we can disable row selection.
|
||||
[profileTableView setDelegate:(id)self];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row { return NO; }
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[host release];
|
||||
@@ -123,7 +131,6 @@
|
||||
[delegate updatePermissionPromptFinishedWithResult:([sender tag] == 1 ? SUAutomaticallyCheck : SUDoNotAutomaticallyCheck)];
|
||||
[[self window] close];
|
||||
[NSApp stopModal];
|
||||
[self autorelease];
|
||||
}
|
||||
|
||||
@end
|
||||
+84
-11
@@ -9,23 +9,28 @@
|
||||
#ifndef SUUPDATER_H
|
||||
#define SUUPDATER_H
|
||||
|
||||
#import <Sparkle/SUVersionComparisonProtocol.h>
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUVersionDisplayProtocol.h"
|
||||
|
||||
@class SUUpdateDriver, SUAppcastItem, SUHost, SUAppcast;
|
||||
@interface SUUpdater : NSObject {
|
||||
|
||||
@interface SUUpdater : NSObject
|
||||
{
|
||||
@private
|
||||
NSTimer *checkTimer;
|
||||
SUUpdateDriver *driver;
|
||||
|
||||
|
||||
NSString *customUserAgentString;
|
||||
SUHost *host;
|
||||
IBOutlet id delegate;
|
||||
}
|
||||
@property (assign) id delegate;
|
||||
|
||||
+ (SUUpdater *)sharedUpdater;
|
||||
+ (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
|
||||
- (NSBundle *)hostBundle;
|
||||
- (instancetype)initForBundle:(NSBundle *)bundle;
|
||||
|
||||
- (void)setDelegate:(id)delegate;
|
||||
- delegate;
|
||||
- (NSBundle *)hostBundle;
|
||||
|
||||
- (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyChecks;
|
||||
- (BOOL)automaticallyChecksForUpdates;
|
||||
@@ -34,31 +39,70 @@
|
||||
- (NSTimeInterval)updateCheckInterval;
|
||||
|
||||
- (void)setFeedURL:(NSURL *)feedURL;
|
||||
- (NSURL *)feedURL;
|
||||
- (NSURL *)feedURL; // *** MUST BE CALLED ON MAIN THREAD ***
|
||||
|
||||
- (void)setUserAgentString:(NSString *)userAgent;
|
||||
- (NSString *)userAgentString;
|
||||
|
||||
- (void)setSendsSystemProfile:(BOOL)sendsSystemProfile;
|
||||
- (BOOL)sendsSystemProfile;
|
||||
|
||||
- (void)setAutomaticallyDownloadsUpdates:(BOOL)automaticallyDownloadsUpdates;
|
||||
- (BOOL)automaticallyDownloadsUpdates;
|
||||
|
||||
// This IBAction is meant for a main menu item. Hook up any menu item to this action,
|
||||
// and Sparkle will check for updates and report back its findings verbosely.
|
||||
- (IBAction)checkForUpdates:sender;
|
||||
- (IBAction)checkForUpdates:(id)sender;
|
||||
|
||||
// This kicks off an update meant to be programmatically initiated. That is, it will display no UI unless it actually finds an update,
|
||||
// in which case it proceeds as usual. If the fully automated updating is turned on, however, this will invoke that behavior, and if an
|
||||
// update is found, it will be downloaded and prepped for installation.
|
||||
- (void)checkForUpdatesInBackground;
|
||||
|
||||
// Date of last update check. Returns nil if no check has been performed.
|
||||
- (NSDate*)lastUpdateCheckDate;
|
||||
|
||||
// This begins a "probing" check for updates which will not actually offer to update to that version. The delegate methods, though,
|
||||
// (up to updater:didFindValidUpdate: and updaterDidNotFindUpdate:), are called, so you can use that information in your UI.
|
||||
- (void)checkForUpdateInformation;
|
||||
|
||||
// Call this to appropriately schedule or cancel the update checking timer according to the preferences for time interval and automatic checks.
|
||||
// Call this to appropriately schedule or cancel the update checking timer according to the preferences for time interval and automatic checks. This call does not change the date of the next check, but only the internal NSTimer.
|
||||
- (void)resetUpdateCycle;
|
||||
|
||||
- (BOOL)updateInProgress;
|
||||
|
||||
@end
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SUUpdater Notifications for events that might be interesting to more than just the delegate
|
||||
// The updater will be the notification object
|
||||
// -----------------------------------------------------------------------------
|
||||
extern NSString *const SUUpdaterDidFinishLoadingAppCastNotification;
|
||||
extern NSString *const SUUpdaterDidFindValidUpdateNotification;
|
||||
extern NSString *const SUUpdaterDidNotFindUpdateNotification;
|
||||
extern NSString *const SUUpdaterWillInstallUpdateNotification;
|
||||
extern NSString *const SUUpdaterWillRelaunchApplicationNotification;
|
||||
|
||||
// Key for the SUAppcastItem object in the SUUpdaterDidFindValidUpdateNotification & SUUpdaterWillInstallUpdateNotification userInfos
|
||||
extern NSString *const SUUpdaterAppcastItemNotificationKey;
|
||||
// Key for the SUAppcast object in the SUUpdaterDidFinishLoadingAppCastNotification userInfo
|
||||
extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SUUpdater Delegate:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@interface NSObject (SUUpdaterDelegateInformalProtocol)
|
||||
|
||||
// Use this to keep Sparkle from popping up e.g. while your setup assistant is showing:
|
||||
- (BOOL)updaterMayCheckForUpdates:(SUUpdater *)bundle;
|
||||
|
||||
// This method allows you to add extra parameters to the appcast URL, potentially based on whether or not Sparkle will also be sending along the system profile. This method should return an array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user.
|
||||
- (NSArray *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
|
||||
|
||||
// Override this to dynamically specify the entire URL.
|
||||
- (NSString*)feedURLStringForUpdater:(SUUpdater*)updater;
|
||||
|
||||
// Use this to override the default behavior for Sparkle prompting the user about automatic update checks.
|
||||
- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SUUpdater *)bundle;
|
||||
|
||||
@@ -79,8 +123,14 @@
|
||||
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update;
|
||||
|
||||
// Return YES to delay the relaunch until you do some processing; invoke the given NSInvocation to continue.
|
||||
// This is not called if the user didn't relaunch on the previous update, in that case it will immediately
|
||||
// restart.
|
||||
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)update untilInvoking:(NSInvocation *)invocation;
|
||||
|
||||
// Some apps *can not* be relaunched in certain circumstances. They can use this method
|
||||
// to prevent a relaunch "hard":
|
||||
- (BOOL)updaterShouldRelaunchApplication:(SUUpdater *)updater;
|
||||
|
||||
// Called immediately before relaunching.
|
||||
- (void)updaterWillRelaunchApplication:(SUUpdater *)updater;
|
||||
|
||||
@@ -88,19 +138,42 @@
|
||||
// If you don't implement this method or return nil, the standard version comparator will be used.
|
||||
- (id <SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
|
||||
|
||||
// This method allows you to provide a custom version comparator.
|
||||
// If you don't implement this method or return nil, the standard version displayer will be used.
|
||||
- (id <SUVersionDisplay>)versionDisplayerForUpdater:(SUUpdater *)updater;
|
||||
|
||||
// Returns the path which is used to relaunch the client after the update is installed. By default, the path of the host bundle.
|
||||
- (NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
|
||||
|
||||
// Called before and after, respectively, an updater shows a modal alert window, to give the host
|
||||
// the opportunity to hide attached windows etc. that may get in the way:
|
||||
-(void) updaterWillShowModalAlert:(SUUpdater *)updater;
|
||||
-(void) updaterDidShowModalAlert:(SUUpdater *)updater;
|
||||
|
||||
// Called when an update is scheduled to be silently installed on quit.
|
||||
// The invocation can be used to trigger an immediate silent install and relaunch.
|
||||
- (void)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)update immediateInstallationInvocation:(NSInvocation *)invocation;
|
||||
- (void)updater:(SUUpdater *)updater didCancelInstallUpdateOnQuit:(SUAppcastItem *)update;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constants:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#ifndef DEBUG
|
||||
#define DEBUG 0
|
||||
#endif
|
||||
|
||||
// Define some minimum intervals to avoid DOS-like checking attacks. These are in seconds.
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && DEBUG && 0
|
||||
#define SU_MIN_CHECK_INTERVAL 60
|
||||
#else
|
||||
#define SU_MIN_CHECK_INTERVAL 60*60
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && DEBUG && 0
|
||||
#define SU_DEFAULT_CHECK_INTERVAL 60
|
||||
#else
|
||||
#define SU_DEFAULT_CHECK_INTERVAL 60*60*24
|
||||
|
||||
+274
-84
@@ -15,26 +15,44 @@
|
||||
#import "SUProbingUpdateDriver.h"
|
||||
#import "SUUserInitiatedUpdateDriver.h"
|
||||
#import "SUScheduledUpdateDriver.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#include <SystemConfiguration/SystemConfiguration.h>
|
||||
|
||||
@interface SUUpdater (Private)
|
||||
- initForBundle:(NSBundle *)bundle;
|
||||
NSString *const SUUpdaterDidFinishLoadingAppCastNotification = @"SUUpdaterDidFinishLoadingAppCastNotification";
|
||||
NSString *const SUUpdaterDidFindValidUpdateNotification = @"SUUpdaterDidFindValidUpdateNotification";
|
||||
NSString *const SUUpdaterDidNotFindUpdateNotification = @"SUUpdaterDidNotFindUpdateNotification";
|
||||
NSString *const SUUpdaterWillInstallUpdateNotification = @"SUUpdaterWillInstallUpdateNotification";
|
||||
NSString *const SUUpdaterWillRelaunchApplicationNotification = @"SUUpdaterWillRelaunchApplicationNotification";
|
||||
NSString *const SUUpdaterAppcastItemNotificationKey = @"SUUpdaterAppcastItemNotificationKey";
|
||||
NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotificationKey";
|
||||
|
||||
@interface SUUpdater ()
|
||||
@property (retain) NSTimer *checkTimer;
|
||||
- (id)initForBundle:(NSBundle *)bundle;
|
||||
- (void)startUpdateCycle;
|
||||
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)updateDriver;
|
||||
- (BOOL)_sendingSystemProfile;
|
||||
- (BOOL)automaticallyUpdates;
|
||||
- (BOOL)automaticallyDownloadsUpdates;
|
||||
- (void)scheduleNextUpdateCheck;
|
||||
- (void)registerAsObserver;
|
||||
- (void)unregisterAsObserver;
|
||||
- (void)updateDriverDidFinish:(NSNotification *)note;
|
||||
- initForBundle:(NSBundle *)bundle;
|
||||
- (NSURL *)parameterizedFeedURL;
|
||||
|
||||
-(void) notifyWillShowModalAlert;
|
||||
-(void) notifyDidShowModalAlert;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUUpdater
|
||||
@synthesize delegate;
|
||||
@synthesize checkTimer;
|
||||
|
||||
#pragma mark Initialization
|
||||
|
||||
static NSMutableDictionary *sharedUpdaters = nil;
|
||||
static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObservationContext";
|
||||
static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObservationContext";
|
||||
|
||||
+ (SUUpdater *)sharedUpdater
|
||||
{
|
||||
@@ -47,15 +65,20 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
if (bundle == nil) bundle = [NSBundle mainBundle];
|
||||
id updater = [sharedUpdaters objectForKey:[NSValue valueWithNonretainedObject:bundle]];
|
||||
if (updater == nil)
|
||||
updater = [[[self class] alloc] initForBundle:bundle];
|
||||
updater = [[[[self class] alloc] initForBundle:bundle] autorelease];
|
||||
return updater;
|
||||
}
|
||||
|
||||
// This is the designated initializer for SUUpdater, important for subclasses
|
||||
- initForBundle:(NSBundle *)bundle
|
||||
- (id)initForBundle:(NSBundle *)bundle
|
||||
{
|
||||
self = [super init];
|
||||
if (bundle == nil) bundle = [NSBundle mainBundle];
|
||||
|
||||
// Register as observer straight away to avoid exceptions on -dealloc when -unregisterAsObserver is called:
|
||||
if (self)
|
||||
[self registerAsObserver];
|
||||
|
||||
id updater = [sharedUpdaters objectForKey:[NSValue valueWithNonretainedObject:bundle]];
|
||||
if (updater)
|
||||
{
|
||||
@@ -68,18 +91,53 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
sharedUpdaters = [[NSMutableDictionary alloc] init];
|
||||
[sharedUpdaters setObject:self forKey:[NSValue valueWithNonretainedObject:bundle]];
|
||||
host = [[SUHost alloc] initWithBundle:bundle];
|
||||
[self registerAsObserver];
|
||||
|
||||
#if !ENDANGER_USERS_WITH_INSECURE_UPDATES
|
||||
// Saving-the-developer-from-a-stupid-mistake-check:
|
||||
BOOL hasPublicDSAKey = [host publicDSAKey] != nil;
|
||||
BOOL isMainBundle = [bundle isEqualTo:[NSBundle mainBundle]];
|
||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned];
|
||||
if (!isMainBundle && !hasPublicDSAKey) {
|
||||
[self notifyWillShowModalAlert];
|
||||
NSRunAlertPanel(@"Insecure update error!", @"For security reasons, you need to sign your updates with a DSA key. See Sparkle's documentation for more information.", @"OK", nil, nil);
|
||||
[self notifyDidShowModalAlert];
|
||||
} else if (isMainBundle && !(hasPublicDSAKey || hostIsCodeSigned)) {
|
||||
[self notifyWillShowModalAlert];
|
||||
NSRunAlertPanel(@"Insecure update error!", @"For security reasons, you need to code sign your application or sign your updates with a DSA key. See Sparkle's documentation for more information.", @"OK", nil, nil);
|
||||
[self notifyDidShowModalAlert];
|
||||
}
|
||||
#endif
|
||||
// This runs the permission prompt if needed, but never before the app has finished launching because the runloop won't run before that
|
||||
[self performSelector:@selector(startUpdateCycle) withObject:nil afterDelay:0];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
// This will be used when the updater is instantiated in a nib such as MainMenu
|
||||
- (id)init
|
||||
{
|
||||
return [self initForBundle:[NSBundle mainBundle]];
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)note
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; }
|
||||
|
||||
|
||||
-(void) notifyWillShowModalAlert
|
||||
{
|
||||
if( [delegate respondsToSelector: @selector(updaterWillShowModalAlert:)] )
|
||||
[delegate updaterWillShowModalAlert: self];
|
||||
}
|
||||
|
||||
|
||||
-(void) notifyDidShowModalAlert
|
||||
{
|
||||
if( [delegate respondsToSelector: @selector(updaterDidShowModalAlert:)] )
|
||||
[delegate updaterDidShowModalAlert: self];
|
||||
}
|
||||
|
||||
|
||||
- (void)startUpdateCycle
|
||||
{
|
||||
BOOL shouldPrompt = NO;
|
||||
|
||||
@@ -94,15 +152,19 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
shouldPrompt = [delegate updaterShouldPromptForPermissionToCheckForUpdates:self];
|
||||
}
|
||||
// Has he been asked already? And don't ask if the host has a default value set in its Info.plist.
|
||||
else if ([host objectForUserDefaultsKey:SUEnableAutomaticChecksKey] == nil &&
|
||||
[host objectForInfoDictionaryKey:SUEnableAutomaticChecksKey] == nil)
|
||||
else if ([host objectForKey:SUEnableAutomaticChecksKey] == nil)
|
||||
{
|
||||
if ([host objectForUserDefaultsKey:SUEnableAutomaticChecksKeyOld])
|
||||
[self setAutomaticallyChecksForUpdates:[host boolForUserDefaultsKey:SUEnableAutomaticChecksKeyOld]];
|
||||
// Now, we don't want to ask the user for permission to do a weird thing on the first launch.
|
||||
// We wait until the second launch.
|
||||
else if ([host boolForUserDefaultsKey:SUHasLaunchedBeforeKey] == NO)
|
||||
[host setBool:YES forUserDefaultsKey:SUHasLaunchedBeforeKey];
|
||||
// We wait until the second launch, unless explicitly overridden via SUPromptUserOnFirstLaunchKey.
|
||||
else if (![host objectForKey:SUPromptUserOnFirstLaunchKey])
|
||||
{
|
||||
if ([host boolForUserDefaultsKey:SUHasLaunchedBeforeKey] == NO)
|
||||
[host setBool:YES forUserDefaultsKey:SUHasLaunchedBeforeKey];
|
||||
else
|
||||
shouldPrompt = YES;
|
||||
}
|
||||
else
|
||||
shouldPrompt = YES;
|
||||
}
|
||||
@@ -110,8 +172,9 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
if (shouldPrompt)
|
||||
{
|
||||
NSArray *profileInfo = [host systemProfile];
|
||||
if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)])
|
||||
profileInfo = [profileInfo arrayByAddingObjectsFromArray:[delegate feedParametersForUpdater:self sendingSystemProfile:[self _sendingSystemProfile]]];
|
||||
// Always say we're sending the system profile here so that the delegate displays the parameters it would send.
|
||||
if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)])
|
||||
profileInfo = [profileInfo arrayByAddingObjectsFromArray:[delegate feedParametersForUpdater:self sendingSystemProfile:YES]];
|
||||
[SUUpdatePermissionPrompt promptWithHost:host systemProfile:profileInfo delegate:self];
|
||||
// We start the update checks and register as observer for changes after the prompt finishes
|
||||
}
|
||||
@@ -138,36 +201,112 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
}
|
||||
}
|
||||
|
||||
- (NSDate *)lastUpdateCheckDate
|
||||
{
|
||||
return [host objectForUserDefaultsKey:SULastCheckTimeKey];
|
||||
}
|
||||
|
||||
- (void)scheduleNextUpdateCheck
|
||||
{
|
||||
if (checkTimer)
|
||||
{
|
||||
[checkTimer invalidate];
|
||||
checkTimer = nil;
|
||||
self.checkTimer = nil; // UK 2009-03-16 Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
}
|
||||
if (![self automaticallyChecksForUpdates]) return;
|
||||
|
||||
// How long has it been since last we checked for an update?
|
||||
NSDate *lastCheckDate = [host objectForUserDefaultsKey:SULastCheckTimeKey];
|
||||
NSDate *lastCheckDate = [self lastUpdateCheckDate];
|
||||
if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; }
|
||||
NSTimeInterval intervalSinceCheck = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
|
||||
|
||||
// Now we want to figure out how long until we check again.
|
||||
NSTimeInterval delayUntilCheck;
|
||||
if (intervalSinceCheck < [self updateCheckInterval])
|
||||
delayUntilCheck = ([self updateCheckInterval] - intervalSinceCheck); // It hasn't been long enough.
|
||||
NSTimeInterval delayUntilCheck, updateCheckInterval = [self updateCheckInterval];
|
||||
if (updateCheckInterval < SU_MIN_CHECK_INTERVAL)
|
||||
updateCheckInterval = SU_MIN_CHECK_INTERVAL;
|
||||
if (intervalSinceCheck < updateCheckInterval)
|
||||
delayUntilCheck = (updateCheckInterval - intervalSinceCheck); // It hasn't been long enough.
|
||||
else
|
||||
delayUntilCheck = 0; // We're overdue! Run one now.
|
||||
checkTimer = [NSTimer scheduledTimerWithTimeInterval:delayUntilCheck target:self selector:@selector(checkForUpdatesInBackground) userInfo:nil repeats:NO];
|
||||
self.checkTimer = [NSTimer scheduledTimerWithTimeInterval:delayUntilCheck target:self selector:@selector(checkForUpdatesInBackground) userInfo:nil repeats:NO]; // UK 2009-03-16 Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
}
|
||||
|
||||
|
||||
-(void) putFeedURLIntoDictionary: (NSMutableDictionary*)theDict // You release this.
|
||||
{
|
||||
[theDict setObject: [self feedURL] forKey: @"feedURL"];
|
||||
}
|
||||
|
||||
-(void) checkForUpdatesInBgReachabilityCheckWithDriver: (SUUpdateDriver*)inDriver /* RUNS ON ITS OWN THREAD */
|
||||
{
|
||||
NS_DURING
|
||||
// This method *must* be called on its own thread. SCNetworkReachabilityCheckByName
|
||||
// can block, and it can be waiting a long time on slow networks, and we
|
||||
// wouldn't want to beachball the main thread for a background operation.
|
||||
// We could use asynchronous reachability callbacks, but those aren't
|
||||
// reliable enough and can 'get lost' sometimes, which we don't want.
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
SCNetworkConnectionFlags flags = 0;
|
||||
BOOL isNetworkReachable = YES;
|
||||
|
||||
// Don't perform automatic checks on unconnected laptops or dial-up connections that aren't online:
|
||||
NSMutableDictionary* theDict = [NSMutableDictionary dictionary];
|
||||
[self performSelectorOnMainThread: @selector(putFeedURLIntoDictionary:) withObject: theDict waitUntilDone: YES]; // Get feed URL on main thread, it's not safe to call elsewhere.
|
||||
|
||||
const char *hostname = [[[theDict objectForKey: @"feedURL"] host] cStringUsingEncoding: NSUTF8StringEncoding];
|
||||
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, hostname);
|
||||
Boolean reachabilityResult = NO;
|
||||
// If the feed's using a file:// URL, we won't be able to use reachability.
|
||||
if (reachability != NULL) {
|
||||
SCNetworkReachabilityGetFlags(reachability, &flags);
|
||||
CFRelease(reachability);
|
||||
}
|
||||
|
||||
if( reachabilityResult )
|
||||
{
|
||||
BOOL reachable = (flags & kSCNetworkFlagsReachable) == kSCNetworkFlagsReachable;
|
||||
BOOL automatic = (flags & kSCNetworkFlagsConnectionAutomatic) == kSCNetworkFlagsConnectionAutomatic;
|
||||
BOOL local = (flags & kSCNetworkFlagsIsLocalAddress) == kSCNetworkFlagsIsLocalAddress;
|
||||
|
||||
//NSLog(@"reachable = %s, automatic = %s, local = %s", (reachable?"YES":"NO"), (automatic?"YES":"NO"), (local?"YES":"NO"));
|
||||
|
||||
if( !(reachable || automatic || local) )
|
||||
isNetworkReachable = NO;
|
||||
}
|
||||
|
||||
// If the network's not reachable, we pass a nil driver into checkForUpdatesWithDriver, which will then reschedule the next update so we try again later.
|
||||
[self performSelectorOnMainThread: @selector(checkForUpdatesWithDriver:) withObject: isNetworkReachable ? inDriver : nil waitUntilDone: NO];
|
||||
|
||||
[pool release];
|
||||
NS_HANDLER
|
||||
SULog(@"UNCAUGHT EXCEPTION IN UPDATE CHECK TIMER: %@",[localException reason]);
|
||||
// Don't propagate the exception beyond here. In Carbon apps that would trash the stack.
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
|
||||
|
||||
- (void)checkForUpdatesInBackground
|
||||
{
|
||||
[self checkForUpdatesWithDriver:[[[([self automaticallyUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class]) alloc] initWithUpdater:self] autorelease]];
|
||||
// Background update checks should only happen if we have a network connection.
|
||||
// Wouldn't want to annoy users on dial-up by establishing a connection every
|
||||
// hour or so:
|
||||
SUUpdateDriver * theUpdateDriver = [[[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class]) alloc] initWithUpdater:self] autorelease];
|
||||
|
||||
[NSThread detachNewThreadSelector: @selector(checkForUpdatesInBgReachabilityCheckWithDriver:) toTarget: self withObject: theUpdateDriver];
|
||||
}
|
||||
|
||||
- (IBAction)checkForUpdates:sender
|
||||
|
||||
- (BOOL)mayUpdateAndRestart
|
||||
{
|
||||
return( !delegate || ![delegate respondsToSelector: @selector(updaterShouldRelaunchApplication:)] || [delegate updaterShouldRelaunchApplication: self] );
|
||||
}
|
||||
|
||||
- (IBAction)checkForUpdates: (id)sender
|
||||
{
|
||||
if (driver && [driver isInterruptible])
|
||||
[driver abortUpdate];
|
||||
|
||||
[self checkForUpdatesWithDriver:[[[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self] autorelease]];
|
||||
}
|
||||
|
||||
@@ -179,32 +318,56 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)d
|
||||
{
|
||||
if ([self updateInProgress]) { return; }
|
||||
if (checkTimer) { [checkTimer invalidate]; checkTimer = nil; }
|
||||
if (checkTimer) { [checkTimer invalidate]; self.checkTimer = nil; } // UK 2009-03-16 Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
|
||||
SUClearLog();
|
||||
SULog( @"===== %@ =====", [[NSFileManager defaultManager] displayNameAtPath: [[NSBundle mainBundle] bundlePath]] );
|
||||
|
||||
driver = [d retain];
|
||||
[driver checkForUpdatesAtURL:[self parameterizedFeedURL] host:host];
|
||||
[self willChangeValueForKey:@"lastUpdateCheckDate"];
|
||||
[host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey];
|
||||
[self didChangeValueForKey:@"lastUpdateCheckDate"];
|
||||
|
||||
if( [delegate respondsToSelector: @selector(updaterMayCheckForUpdates:)] && ![delegate updaterMayCheckForUpdates: self] )
|
||||
{
|
||||
[self scheduleNextUpdateCheck];
|
||||
return;
|
||||
}
|
||||
|
||||
driver = [d retain];
|
||||
|
||||
// If we're not given a driver at all, just schedule the next update check and bail.
|
||||
if (!driver)
|
||||
{
|
||||
[self scheduleNextUpdateCheck];
|
||||
return;
|
||||
}
|
||||
|
||||
NSURL* theFeedURL = [self parameterizedFeedURL];
|
||||
if( theFeedURL ) // Use a NIL URL to cancel quietly.
|
||||
[driver checkForUpdatesAtURL: theFeedURL host:host];
|
||||
else
|
||||
[driver abortUpdate];
|
||||
}
|
||||
|
||||
- (void)registerAsObserver
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidFinishLaunching:) name:NSApplicationDidFinishLaunchingNotification object:NSApp];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDriverDidFinish:) name:SUUpdateDriverFinishedNotification object:nil];
|
||||
// No sense observing the shared NSUserDefaultsController when we're not updating the main bundle.
|
||||
if ([host bundle] != [NSBundle mainBundle]) return;
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey] options:0 context:SUUpdaterDefaultsObservationContext];
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey] options:0 context:SUUpdaterDefaultsObservationContext];
|
||||
}
|
||||
|
||||
- (void)unregisterAsObserver
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
// Removing self as a KVO observer if no observer was registered leads to an NSException. But we don't care.
|
||||
@try
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey]];
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey]];
|
||||
}
|
||||
@catch (NSException *e) { }
|
||||
@catch (NSException *e)
|
||||
{
|
||||
NSLog(@"Sparkle Error: [SUUpdater unregisterAsObserver] called, but the updater wasn't registered as an observer.");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
||||
@@ -231,35 +394,36 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
- (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyCheckForUpdates
|
||||
{
|
||||
[host setBool:automaticallyCheckForUpdates forUserDefaultsKey:SUEnableAutomaticChecksKey];
|
||||
// Hack to support backwards compatibility with older Sparkle versions, which supported
|
||||
// disabling updates by setting the check interval to 0.
|
||||
if (automaticallyCheckForUpdates && [self updateCheckInterval] == 0)
|
||||
[self setUpdateCheckInterval:SU_DEFAULT_CHECK_INTERVAL];
|
||||
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil];
|
||||
// Provide a small delay in case multiple preferences are being updated simultaneously.
|
||||
[self performSelector:@selector(resetUpdateCycle) withObject:nil afterDelay:1];
|
||||
}
|
||||
|
||||
- (BOOL)automaticallyChecksForUpdates
|
||||
{
|
||||
// Breaking this down for readability:
|
||||
// If the user says he wants automatic update checks, let's do it.
|
||||
if ([host boolForUserDefaultsKey:SUEnableAutomaticChecksKey] == YES)
|
||||
return YES;
|
||||
// If the user hasn't said anything, but the developer says we should do it, let's do it.
|
||||
if ([host objectForUserDefaultsKey:SUEnableAutomaticChecksKey] == nil && [host boolForInfoDictionaryKey:SUEnableAutomaticChecksKey] == YES)
|
||||
return YES;
|
||||
return NO; // Otherwise, don't bother.
|
||||
// Don't automatically update when the check interval is 0, to be compatible with 1.1 settings.
|
||||
if ([self updateCheckInterval] == 0)
|
||||
return NO;
|
||||
return [host boolForKey:SUEnableAutomaticChecksKey];
|
||||
}
|
||||
|
||||
- (BOOL)automaticallyUpdates
|
||||
- (void)setAutomaticallyDownloadsUpdates:(BOOL)automaticallyUpdates
|
||||
{
|
||||
[host setBool:automaticallyUpdates forUserDefaultsKey:SUAutomaticallyUpdateKey];
|
||||
}
|
||||
|
||||
- (BOOL)automaticallyDownloadsUpdates
|
||||
{
|
||||
// If the SUAllowsAutomaticUpdatesKey exists and is set to NO, return NO.
|
||||
if ([host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] && [host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] == NO)
|
||||
return NO;
|
||||
|
||||
// If we're not using DSA signatures, we aren't going to trust any updates automatically.
|
||||
if ([host boolForInfoDictionaryKey:SUExpectsDSASignatureKey] != YES)
|
||||
return NO;
|
||||
|
||||
// If there's no setting, or it's set to no, we're not automatically updating.
|
||||
if ([host boolForUserDefaultsKey:SUAutomaticallyUpdateKey] != YES)
|
||||
return NO;
|
||||
|
||||
return YES; // Otherwise, we're good to go.
|
||||
// Otherwise, automatically downloading updates is allowed. Does the user want it?
|
||||
return [host boolForUserDefaultsKey:SUAutomaticallyUpdateKey];
|
||||
}
|
||||
|
||||
- (void)setFeedURL:(NSURL *)feedURL
|
||||
@@ -267,21 +431,50 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
[host setObject:[feedURL absoluteString] forUserDefaultsKey:SUFeedURLKey];
|
||||
}
|
||||
|
||||
- (NSURL *)feedURL
|
||||
- (NSURL *)feedURL // *** MUST BE CALLED ON MAIN THREAD ***
|
||||
{
|
||||
// A value in the user defaults overrides one in the Info.plist (so preferences panels can be created wherein users choose between beta / release feeds).
|
||||
NSString *appcastString = [host objectForUserDefaultsKey:SUFeedURLKey];
|
||||
if (!appcastString)
|
||||
appcastString = [host objectForInfoDictionaryKey:SUFeedURLKey];
|
||||
NSString *appcastString = [host objectForKey:SUFeedURLKey];
|
||||
if( [delegate respondsToSelector: @selector(feedURLStringForUpdater:)] )
|
||||
appcastString = [delegate feedURLStringForUpdater: self];
|
||||
if (!appcastString) // Can't find an appcast string!
|
||||
[NSException raise:@"SUNoFeedURL" format:@"You must specify the URL of the appcast as the SUFeedURLKey in either the Info.plist or the user defaults!"];
|
||||
[NSException raise:@"SUNoFeedURL" format:@"You must specify the URL of the appcast as the SUFeedURL key in either the Info.plist or the user defaults!"];
|
||||
NSCharacterSet* quoteSet = [NSCharacterSet characterSetWithCharactersInString: @"\"\'"]; // Some feed publishers add quotes; strip 'em.
|
||||
return [NSURL URLWithString:[appcastString stringByTrimmingCharactersInSet:quoteSet]];
|
||||
NSString* castUrlStr = [appcastString stringByTrimmingCharactersInSet:quoteSet];
|
||||
if( !castUrlStr || [castUrlStr length] == 0 )
|
||||
return nil;
|
||||
else
|
||||
return [NSURL URLWithString: castUrlStr];
|
||||
}
|
||||
|
||||
- (BOOL)_sendingSystemProfile
|
||||
- (void)setUserAgentString:(NSString *)userAgent
|
||||
{
|
||||
return ([host boolForUserDefaultsKey:SUSendProfileInfoKey] == YES);
|
||||
if (customUserAgentString == userAgent)
|
||||
return;
|
||||
|
||||
[customUserAgentString release];
|
||||
customUserAgentString = [userAgent copy];
|
||||
}
|
||||
|
||||
- (NSString *)userAgentString
|
||||
{
|
||||
if (customUserAgentString)
|
||||
return customUserAgentString;
|
||||
|
||||
NSString *version = [SPARKLE_BUNDLE objectForInfoDictionaryKey:@"CFBundleVersion"];
|
||||
NSString *userAgent = [NSString stringWithFormat:@"%@/%@ Sparkle/%@", [host name], [host displayVersion], version ? version : @"?"];
|
||||
NSData *cleanedAgent = [userAgent dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
|
||||
return [[[NSString alloc] initWithData:cleanedAgent encoding:NSASCIIStringEncoding] autorelease];
|
||||
}
|
||||
|
||||
- (void)setSendsSystemProfile:(BOOL)sendsSystemProfile
|
||||
{
|
||||
[host setBool:sendsSystemProfile forUserDefaultsKey:SUSendProfileInfoKey];
|
||||
}
|
||||
|
||||
- (BOOL)sendsSystemProfile
|
||||
{
|
||||
return [host boolForKey:SUSendProfileInfoKey];
|
||||
}
|
||||
|
||||
- (NSURL *)parameterizedFeedURL
|
||||
@@ -289,7 +482,7 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
NSURL *baseFeedURL = [self feedURL];
|
||||
|
||||
// Determine all the parameters we're attaching to the base feed URL.
|
||||
BOOL sendingSystemProfile = [self _sendingSystemProfile];
|
||||
BOOL sendingSystemProfile = [self sendsSystemProfile];
|
||||
|
||||
// Let's only send the system profiling information once per week at most, so we normalize daily-checkers vs. biweekly-checkers and the such.
|
||||
NSDate *lastSubmitDate = [host objectForUserDefaultsKey:SULastProfileSubmitDateKey];
|
||||
@@ -306,45 +499,48 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
parameters = [parameters arrayByAddingObjectsFromArray:[host systemProfile]];
|
||||
[host setObject:[NSDate date] forUserDefaultsKey:SULastProfileSubmitDateKey];
|
||||
}
|
||||
if (parameters == nil || [parameters count] == 0) { return baseFeedURL; }
|
||||
if ([parameters count] == 0) { return baseFeedURL; }
|
||||
|
||||
// Build up the parameterized URL.
|
||||
NSMutableArray *parameterStrings = [NSMutableArray array];
|
||||
NSEnumerator *profileInfoEnumerator = [parameters objectEnumerator];
|
||||
NSDictionary *currentProfileInfo;
|
||||
while ((currentProfileInfo = [profileInfoEnumerator nextObject]))
|
||||
[parameterStrings addObject:[NSString stringWithFormat:@"%@=%@", [currentProfileInfo objectForKey:@"key"], [currentProfileInfo objectForKey:@"value"]]];
|
||||
for (NSDictionary *currentProfileInfo in parameters)
|
||||
[parameterStrings addObject:[NSString stringWithFormat:@"%@=%@", [[[currentProfileInfo objectForKey:@"key"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [[[currentProfileInfo objectForKey:@"value"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
|
||||
|
||||
NSString *appcastStringWithProfile = [NSString stringWithFormat:@"%@?%@", [baseFeedURL absoluteString], [parameterStrings componentsJoinedByString:@"&"]];
|
||||
NSString *separatorCharacter = @"?";
|
||||
if ([baseFeedURL query])
|
||||
separatorCharacter = @"&"; // In case the URL is already http://foo.org/baz.xml?bat=4
|
||||
NSString *appcastStringWithProfile = [NSString stringWithFormat:@"%@%@%@", [baseFeedURL absoluteString], separatorCharacter, [parameterStrings componentsJoinedByString:@"&"]];
|
||||
|
||||
// Clean it up so it's a valid URL
|
||||
return [NSURL URLWithString:[appcastStringWithProfile stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
|
||||
return [NSURL URLWithString:appcastStringWithProfile];
|
||||
}
|
||||
|
||||
- (void)setUpdateCheckInterval:(NSTimeInterval)updateCheckInterval
|
||||
{
|
||||
[host setObject:[NSNumber numberWithDouble:updateCheckInterval] forUserDefaultsKey:SUScheduledCheckIntervalKey];
|
||||
if (updateCheckInterval == 0) // For compatibility with 1.1's settings.
|
||||
[self setAutomaticallyChecksForUpdates:NO];
|
||||
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil];
|
||||
|
||||
// Provide a small delay in case multiple preferences are being updated simultaneously.
|
||||
[self performSelector:@selector(resetUpdateCycle) withObject:nil afterDelay:1];
|
||||
}
|
||||
|
||||
- (NSTimeInterval)updateCheckInterval
|
||||
{
|
||||
NSTimeInterval checkInterval = 0;
|
||||
// Find the stored check interval. User defaults override Info.plist.
|
||||
if ([host objectForUserDefaultsKey:SUScheduledCheckIntervalKey])
|
||||
checkInterval = [[host objectForUserDefaultsKey:SUScheduledCheckIntervalKey] doubleValue];
|
||||
else if ([host objectForInfoDictionaryKey:SUScheduledCheckIntervalKey])
|
||||
checkInterval = [[host objectForInfoDictionaryKey:SUScheduledCheckIntervalKey] doubleValue];
|
||||
|
||||
if (checkInterval < SU_MIN_CHECK_INTERVAL) // This can also mean one that isn't set.
|
||||
checkInterval = SU_DEFAULT_CHECK_INTERVAL;
|
||||
return checkInterval;
|
||||
NSNumber *intervalValue = [host objectForKey:SUScheduledCheckIntervalKey];
|
||||
if (intervalValue)
|
||||
return [intervalValue doubleValue];
|
||||
else
|
||||
return SU_DEFAULT_CHECK_INTERVAL;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self unregisterAsObserver];
|
||||
[host release];
|
||||
if (checkTimer) { [checkTimer invalidate]; }
|
||||
if (checkTimer) { [checkTimer invalidate]; [checkTimer release]; self.checkTimer = nil; } // UK 2009-03-16 Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@@ -355,17 +551,11 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)setDelegate:aDelegate
|
||||
{
|
||||
delegate = aDelegate;
|
||||
}
|
||||
|
||||
- (BOOL)updateInProgress
|
||||
{
|
||||
return driver && ([driver finished] == NO);
|
||||
}
|
||||
|
||||
- delegate { return delegate; }
|
||||
- (NSBundle *)hostBundle { return [host bundle]; }
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// SUUpdater_Private.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 5/9/11.
|
||||
// Copyright 2011 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUUpdater.h"
|
||||
|
||||
@interface SUUpdater (Private)
|
||||
|
||||
- (BOOL)mayUpdateAndRestart;
|
||||
|
||||
@end
|
||||
@@ -12,7 +12,9 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUUIBasedUpdateDriver.h"
|
||||
|
||||
@interface SUUserInitiatedUpdateDriver : SUUIBasedUpdateDriver {
|
||||
@interface SUUserInitiatedUpdateDriver : SUUIBasedUpdateDriver
|
||||
{
|
||||
@private
|
||||
SUStatusController *checkingController;
|
||||
BOOL isCanceled;
|
||||
}
|
||||
|
||||
@@ -13,23 +13,6 @@
|
||||
|
||||
@implementation SUUserInitiatedUpdateDriver
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)appcastURL host:(SUHost *)aHost
|
||||
{
|
||||
checkingController = [[SUStatusController alloc] initWithHost:aHost];
|
||||
[[checkingController window] center]; // Force the checking controller to load its window.
|
||||
[checkingController beginActionWithTitle:SULocalizedString(@"Checking for updates\u2026", nil) maxProgressValue:0 statusText:nil];
|
||||
[checkingController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelCheckForUpdates:) isDefault:NO];
|
||||
[checkingController showWindow:self];
|
||||
[super checkForUpdatesAtURL:appcastURL host:aHost];
|
||||
|
||||
// For background applications, obtain focus.
|
||||
// Useful if the update check is requested from another app like System Preferences.
|
||||
if ([aHost isBackgroundApplication])
|
||||
{
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)closeCheckingWindow
|
||||
{
|
||||
if (checkingController)
|
||||
@@ -46,6 +29,23 @@
|
||||
isCanceled = YES;
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
|
||||
{
|
||||
checkingController = [[SUStatusController alloc] initWithHost:aHost];
|
||||
[[checkingController window] center]; // Force the checking controller to load its window.
|
||||
[checkingController beginActionWithTitle:SULocalizedString(@"Checking for updates...", nil) maxProgressValue:0.0 statusText:nil];
|
||||
[checkingController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelCheckForUpdates:) isDefault:NO];
|
||||
[checkingController showWindow:self];
|
||||
[super checkForUpdatesAtURL:URL host:aHost];
|
||||
|
||||
// For background applications, obtain focus.
|
||||
// Useful if the update check is requested from another app like System Preferences.
|
||||
if ([aHost isBackgroundApplication])
|
||||
{
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)ac
|
||||
{
|
||||
if (isCanceled)
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#ifndef SUVERSIONCOMPARISONPROTOCOL_H
|
||||
#define SUVERSIONCOMPARISONPROTOCOL_H
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
/*!
|
||||
@protocol
|
||||
@abstract Implement this protocol to provide version comparison facilities for Sparkle.
|
||||
@@ -20,7 +22,7 @@
|
||||
@abstract An abstract method to compare two version strings.
|
||||
@discussion Should return NSOrderedAscending if b > a, NSOrderedDescending if b < a, and NSOrderedSame if they are equivalent.
|
||||
*/
|
||||
- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB;
|
||||
- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB; // *** MAY BE CALLED ON NON-MAIN THREAD!
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// SUVersionDisplayProtocol.h
|
||||
// EyeTV
|
||||
//
|
||||
// Created by Uli Kusterer on 08.12.09.
|
||||
// Copyright 2009 Elgato Systems GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
||||
/*!
|
||||
@protocol
|
||||
@abstract Implement this protocol to apply special formatting to the two
|
||||
version numbers.
|
||||
*/
|
||||
@protocol SUVersionDisplay
|
||||
|
||||
/*!
|
||||
@method
|
||||
@abstract An abstract method to format two version strings.
|
||||
@discussion You get both so you can display important distinguishing
|
||||
information, but leave out unnecessary/confusing parts.
|
||||
*/
|
||||
-(void) formatVersion: (NSString**)inOutVersionA andVersion: (NSString**)inOutVersionB;
|
||||
|
||||
@end
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "SUWindowController.h"
|
||||
#import "SUHost.h"
|
||||
|
||||
@implementation SUWindowController
|
||||
|
||||
@@ -15,11 +16,12 @@
|
||||
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:nibName ofType:@"nib"];
|
||||
if (path == nil) // Slight hack to resolve issues with running Sparkle in debug configurations.
|
||||
{
|
||||
NSString *frameworkPath = [[host sharedFrameworksPath] stringByAppendingPathComponent:@"Sparkle.framework"];
|
||||
NSString *frameworkPath = [[[host bundle] sharedFrameworksPath] stringByAppendingPathComponent:@"Sparkle.framework"];
|
||||
NSBundle *framework = [NSBundle bundleWithPath:frameworkPath];
|
||||
path = [framework pathForResource:nibName ofType:@"nib"];
|
||||
}
|
||||
return [super initWithWindowNibPath:path owner:self];
|
||||
self = [super initWithWindowNibPath:path owner:self];
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
+4
-4
@@ -11,7 +11,7 @@
|
||||
http://you.com/app/2.0.html
|
||||
</sparkle:releaseNotesLink>
|
||||
<pubDate>Wed, 09 Jan 2006 19:20:11 +0000</pubDate>
|
||||
<enclosure url="http://you.com/app/Your Great App 2.0.zip" sparkle:version="2.0" length="1623481" type="application/octet-stream"/>
|
||||
<enclosure url="http://you.com/app/Your Great App 2.0.zip" sparkle:version="2.0" length="1623481" type="application/octet-stream" sparkle:dsaSignature="BAFJW4B6B1K1JyW30nbkBwainOzrN6EQuAh" />
|
||||
</item>
|
||||
|
||||
<item>
|
||||
@@ -20,17 +20,17 @@
|
||||
http://you.com/app/1.5.html
|
||||
</sparkle:releaseNotesLink>
|
||||
<pubDate>Wed, 01 Jan 2006 12:20:11 +0000</pubDate>
|
||||
<enclosure url="http://you.com/app/Your Great App 1.5.zip" sparkle:version="1.5" length="1472893" type="application/octet-stream"/>
|
||||
<enclosure url="http://you.com/app/Your Great App 1.5.zip" sparkle:version="1.5" length="1472893" type="application/octet-stream" sparkle:dsaSignature="234818feCa1JyW30nbkBwainOzrN6EQuAh" />
|
||||
</item>
|
||||
|
||||
<!-- Now here's an example of a version with a weird internal version number (like an SVN revision) but a human-readable external one. This version also has a DSA signature. Note that normally, if any item has a DSA signature, all of them need to. -->
|
||||
<!-- Now here's an example of a version with a weird internal version number (like an SVN revision) but a human-readable external one. -->
|
||||
<item>
|
||||
<title>Version 1.4 (5 bugs fixed; 2 new features)</title>
|
||||
<sparkle:releaseNotesLink>
|
||||
http://you.com/app/1.4.html
|
||||
</sparkle:releaseNotesLink>
|
||||
<pubDate>Wed, 25 Dec 2005 12:20:11 +0000</pubDate>
|
||||
<enclosure url="http://you.com/app/Your Great App 1.4.zip" sparkle:version="241" sparkle:shortVersionString="1.4" sparkle:dsaSignature="MC0CFBfeCa1JyW30nbkBwainOzrN6EQuAh=" length="1472349" type="application/octet-stream"/>
|
||||
<enclosure url="http://you.com/app/Your Great App 1.4.zip" sparkle:version="241" sparkle:shortVersionString="1.4" sparkle:dsaSignature="MC0CFBfeCa1JyW30nbkBwainOzrN6EQuAh=" length="1472349" type="application/octet-stream" />
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -17,5 +17,6 @@
|
||||
#import <Sparkle/SUAppcast.h>
|
||||
#import <Sparkle/SUAppcastItem.h>
|
||||
#import <Sparkle/SUVersionComparisonProtocol.h>
|
||||
#import <Sparkle/SUStandardVersionComparator.h>
|
||||
|
||||
#endif
|
||||
Binary file not shown.
+15
-1
@@ -6,11 +6,25 @@
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef NSAppKitVersionNumber10_4
|
||||
#define NSAppKitVersionNumber10_4 824
|
||||
#endif
|
||||
|
||||
#ifndef NSAppKitVersionNumber10_5
|
||||
#define NSAppKitVersionNumber10_5 949
|
||||
#endif
|
||||
|
||||
#ifndef NSAppKitVersionNumber10_6
|
||||
#define NSAppKitVersionNumber10_6 1038
|
||||
#endif
|
||||
|
||||
#ifdef __OBJC__
|
||||
|
||||
#define SPARKLE_BUNDLE [NSBundle bundleWithIdentifier:@"org.andymatuschak.Sparkle"]
|
||||
#define SULocalizedString(key,comment) NSLocalizedStringFromTableInBundle(key, @"Sparkle", SPARKLE_BUNDLE, comment)
|
||||
#define SUAbstractFail() NSAssert2(nil, @"Can't call %@ on an instance of %@; this is an abstract method!", __PRETTY_FUNCTION__, [self class]);
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUConstants.h"
|
||||
|
||||
#endif
|
||||
Loaded 100 of 359 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user