forked from korseby/TriTag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FFSupport.m
89 lines (74 loc) · 3.43 KB
/
FFSupport.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* FFSupport.m
*
* Created by Patrick Gleichmann on Fri May 16 2003.
* Copyright (c) 2003-2004 FEEDFACE.com. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//RCS_ID("$Id: FFSupport.m 209 2004-07-13 14:18:21Z ravemax $")
#import "FFSupport.h"
static NSString* VersionListURL = @"http://www.feedface.com/projects/versionlist.xml";
@implementation FFSupport
+ (void)updatesCheckForProject:(NSString*)project {
NSDictionary* versionList;
// Fetch project version xml file
versionList = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:VersionListURL]];
if (versionList == nil)
NSRunAlertPanel(@"Network problems", @"Failed to fetch the project version list", @"OK", nil, nil);
else {
NSString* bundleVersion, *siteVersion;
NSDictionary* projDict;
// Extract versions
bundleVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
projDict = [versionList objectForKey:project];
if (projDict == nil)
NSRunAlertPanel(@"Error in the project version list", @"Please contact us", @"OK", nil, nil);
else {
siteVersion = [projDict objectForKey:@"Version"];
// Compare versions
if ([bundleVersion isEqualToString:siteVersion])
NSRunInformationalAlertPanel(@"Your version is up to date", @"Thanks for the check anyway", @"OK", nil, nil);
else {
int ret = NSRunInformationalAlertPanel(@"New version available", [NSString stringWithFormat:@"Version %@ was released (%@).\nWant to download now ?", siteVersion, [projDict objectForKey:@"Date"]], @"Download", @"Cancel", nil);
if (ret == NSOKButton)
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[projDict objectForKey:@"File"]]];
}
}
}
}
+ (void)sendFeedbackToMailaddress:(NSString*)mailTo {
NSString* subj;
NSMutableString* esubj;
NSDictionary* idict;
NSURL* mu;
// Get the subject
subj = [[[NSBundle mainBundle] localizedInfoDictionary] objectForKey:@"CFBundleShortVersionString"];
if ((subj == nil) || ([subj length] == 0)) {
idict = [[NSBundle mainBundle] infoDictionary];
subj = [NSString stringWithFormat:@"%@ %@",
[idict objectForKey:@"CFBundleExecutable"], [idict objectForKey:@"CFBundleVersion"]];
}
// Escape string (stringByAddingPercentEscapesUsingEncoding: does this but only available in 10.3)
esubj = [NSMutableString stringWithString:subj];
[esubj replaceOccurrencesOfString:@" " withString:@"%20" options:0 range:NSMakeRange(0, [esubj length])];
// Open mail agent
mu = [NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@?subject=%@:", mailTo, esubj]];
if (![[NSWorkspace sharedWorkspace] openURL:mu])
NSRunAlertPanel(@"Failed to open the mail agent",
[NSString stringWithFormat:@"Mail address: %@\nPlease add '%@' to the subject.",
mailTo, subj], @"OK", nil, nil);
}
@end