Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 439 lines (395 sloc) 15.474 kb
14c261e @jlipps Adding files from saucytunes
authored
1 //
2 // campfireTunesAppDelegate.m
3 // campfire-tunes
4 //
5 // Created by Jonathan Lipps on 5/17/12.
6 // Copyright 2012 __MyCompanyName__. All rights reserved.
7 //
8
9 #import "campfireTunesAppDelegate.h"
10
11 @implementation campfireTunesAppDelegate
12
13 @synthesize window;
14 @synthesize statusLabel;
15 @synthesize trackName;
16 @synthesize trackInfo;
d0da49f @jlipps Separated artist and album onto separate lines
authored
17 @synthesize trackAlbum;
14c261e @jlipps Adding files from saucytunes
authored
18 @synthesize preferences;
19 @synthesize prefsCampName;
20 @synthesize prefsAuthToken;
21 @synthesize prefsSave;
22 @synthesize prefsListBtn;
23 @synthesize prefsRooms;
24 @synthesize player;
25 @synthesize timer;
26 @synthesize playerTimer;
27 @synthesize currentName;
28 @synthesize currentAlbum;
29 @synthesize currentArtist;
30 @synthesize campfire;
31 @synthesize campfireIsAuthed;
32 @synthesize prefs;
c3a17bb @jlipps Added a PlayerApplication abstraction class so we can use both iTunes…
authored
33 @synthesize debug;
14c261e @jlipps Adding files from saucytunes
authored
34
35 - (campfireTunesAppDelegate*)init {
c3a17bb @jlipps Added a PlayerApplication abstraction class so we can use both iTunes…
authored
36 self = [super init];
14c261e @jlipps Adding files from saucytunes
authored
37 self.currentName = @"";
38 self.currentAlbum = @"";
39 self.currentArtist = @"";
875d2c0 @jlipps Updated HappyCampfire for 10.7, some new design stuff and better icon
authored
40 self.debug = NO;
14c261e @jlipps Adding files from saucytunes
authored
41 return self;
42 }
43
44 - (void)dealloc {
e8d5200 @jlipps Better memory handling and spotify ad handling
authored
45 [self.campfire release];
875d2c0 @jlipps Updated HappyCampfire for 10.7, some new design stuff and better icon
authored
46 self.currentName = nil;
47 self.currentAlbum = nil;
48 self.currentArtist = nil;
49 self.player = nil;
14c261e @jlipps Adding files from saucytunes
authored
50 [super dealloc];
51 }
52
53 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
54 // Insert code here to initialize your application
55 self.prefs = [NSUserDefaults standardUserDefaults];
56
57 if ( [self preferencesSet] ) {
58 [self doCampfireAuth];
59 [self doCampfireRoomJoin];
60 [self findPlayer];
61 } else {
62 [self updateStatus:@"Checking for preferences..."];
63 NSLog(@"No prefs set, opening prefs pane");
64 [self openPreferences];
65 }
66 }
67
68 - (BOOL)preferencesSet {
1c2aa28 @jlipps Fixed room joining/saving prefs bug
authored
69 NSLog(@"Checking preferences: campfireName: %@, campfireAuthToken: %@, campfireRoomID: %@, campfireRoomTitle: %@",
14c261e @jlipps Adding files from saucytunes
authored
70 [self.prefs stringForKey:@"campfireName"],
71 [self.prefs stringForKey:@"campfireAuthToken"],
1c2aa28 @jlipps Fixed room joining/saving prefs bug
authored
72 [self.prefs stringForKey:@"campfireRoomID"],
73 [self.prefs stringForKey:@"campfireRoomTitle"]);
14c261e @jlipps Adding files from saucytunes
authored
74 return [self.prefs stringForKey:@"campfireName"] &&
75 [self.prefs stringForKey:@"campfireAuthToken"] &&
76 [self.prefs stringForKey:@"campfireRoomID"];
77 }
78
79 - (void)openPreferences {
80 [NSApp beginSheet:self.preferences
81 modalForWindow:self.window
82 modalDelegate:self
83 didEndSelector:NULL
84 contextInfo:nil];
85 [[NSNotificationCenter defaultCenter] addObserver:self
86 selector:@selector(prefPaneFieldDidChange:)
87 name:NSControlTextDidChangeNotification
88 object:self.prefsCampName];
89 [[NSNotificationCenter defaultCenter] addObserver:self
90 selector:@selector(prefPaneFieldDidChange:)
91 name:NSControlTextDidChangeNotification
92 object:self.prefsAuthToken];
93
94 [self.prefsRooms removeAllItems];
95
96 NSString *camp = [self.prefs stringForKey:@"campfireName"];
97 NSString *token = [self.prefs stringForKey:@"campfireAuthToken"];
98 [self.prefsCampName setStringValue:camp];
99 [self.prefsAuthToken setStringValue:token];
100
101 if ([self.prefs objectForKey:@"campfireRooms"] != nil) {
102 NSLog(@"Have campfire room list in preferences");
103 [self.prefsRooms addItemsWithTitles:[self.prefs objectForKey:@"campfireRoomList"]];
104 [self.prefsRooms setEnabled:YES];
1c2aa28 @jlipps Fixed room joining/saving prefs bug
authored
105 [self.prefsRooms selectItemWithTitle:[self.prefs stringForKey:@"campfireRoomTitle"]];
14c261e @jlipps Adding files from saucytunes
authored
106 [self.prefsListBtn setEnabled:YES];
107 } else if (camp && token) {
108 NSLog(@"No rooms in prefs, but name and token are, refreshing rooms list");
109 // if we already have name and token, refresh rooms list
110 [self.prefsListBtn setEnabled:YES];
111 [self doCampfireAuth];
112 [self setRooms];
113 }
114
115 // if we already have preferences, pre-enable buttons
116 if ([self preferencesSet]) {
117 [self.prefsSave setEnabled:YES];
118 }
119 }
120
121 -(IBAction) prefsMenuItem: (id) sender {
122 [self openPreferences];
123 }
124
125 - (NSString *) getRoomIDForTitle:(NSString *)title {
126 if ( [self.prefs objectForKey:@"campfireRooms"] != nil ) {
127 NSMutableArray *rooms = [self.prefs objectForKey:@"campfireRooms"];
128 for (id room in rooms) {
129 if ( [title isEqualToString:[room objectForKey:@"name"]] ) {
1c2aa28 @jlipps Fixed room joining/saving prefs bug
authored
130 NSLog(@"ID for %@ is %@", title, [room objectForKey:@"roomID"]);
14c261e @jlipps Adding files from saucytunes
authored
131 return [room objectForKey:@"roomID"];
132 }
133 }
134 }
135 return nil;
136 }
137
138 - (void) prefPaneFieldDidChange:(NSNotification *)aNotification {
139 NSString *room = [self.prefsCampName stringValue];
140 NSString *auth = [self.prefsAuthToken stringValue];
141 NSLog(@"Checking prefs status, room is %@ and auth is %@", room, auth);
142 if (![room isEqualToString:@""] && ![auth isEqualToString:@""]) {
143 NSLog(@"Setting enabled button!");
144 [self.prefsListBtn setEnabled:YES];
145 } else {
146 [self.prefsListBtn setEnabled:NO];
147 [self.prefsSave setEnabled:NO];
148 }
149 }
150
151 - (IBAction) listRoomsPressed:(id) sender {
152 NSLog(@"Getting rooms...");
153 [self saveCampAndTokenPrefs];
154 [self doCampfireAuth];
155 [self setRooms];
156 }
157
158 - (void)setRooms {
159 [self.campfire getVisibleRoomsWithHandler:^(NSArray* rooms) {
160 NSLog(@"%@", rooms);
161 NSMutableArray *titles = [NSMutableArray array];
162 NSMutableArray *defRooms = [NSMutableArray array];
163 for (id room in rooms) {
164 [titles addObject:[room name]];
165 NSDictionary *defRoom = [NSDictionary dictionaryWithObjectsAndKeys:
166 [room name], @"name", [room roomID], @"roomID", [room topic], @"topic", nil];
167 [defRooms addObject:defRoom];
168 }
169 [self.prefs setObject:defRooms forKey:@"campfireRooms"];
170 NSLog(@"%@", titles);
171 [self.prefsRooms removeAllItems];
172 [self.prefs setObject:titles forKey:@"campfireRoomList"];
173 [self.prefsRooms addItemsWithTitles:titles];
1c2aa28 @jlipps Fixed room joining/saving prefs bug
authored
174 if ( [self.prefs stringForKey:@"campfireRoomTitle"] != nil ) {
175 [self.prefsRooms selectItemWithTitle:[self.prefs stringForKey:@"campfireRoomTitle"]];
176 }
14c261e @jlipps Adding files from saucytunes
authored
177 [self.prefsRooms setEnabled:YES];
178 [self.prefsSave setEnabled:YES];
179 }];
180 }
181
182 - (void)saveCampAndTokenPrefs {
183 NSString *camp = [self.prefsCampName stringValue];
184 NSString *auth = [self.prefsAuthToken stringValue];
185 [self.prefs setObject:camp forKey:@"campfireName"];
186 [self.prefs setObject:auth forKey:@"campfireAuthToken"];
1c2aa28 @jlipps Fixed room joining/saving prefs bug
authored
187 }
188
189 - (void)saveRoomPrefs {
190 NSString *roomID = [self getRoomIDForTitle:[self.prefsRooms titleOfSelectedItem]];
14c261e @jlipps Adding files from saucytunes
authored
191 [self.prefs setObject:roomID forKey:@"campfireRoomID"];
1c2aa28 @jlipps Fixed room joining/saving prefs bug
authored
192 [self.prefs setObject:[self.prefsRooms titleOfSelectedItem] forKey:@"campfireRoomTitle"];
14c261e @jlipps Adding files from saucytunes
authored
193 }
194
195 - (IBAction) savePreferencesPressed:(id) sender {
196 NSLog(@"Saving preferences...");
197 NSLog(@"%@", self.prefs);
1c2aa28 @jlipps Fixed room joining/saving prefs bug
authored
198 [self saveCampAndTokenPrefs];
199 [self saveRoomPrefs];
14c261e @jlipps Adding files from saucytunes
authored
200 [self closePreferences];
201 }
202
203 - (void)closePreferences {
204 [NSApp endSheet:self.preferences];
205 [self.preferences orderOut:self];
206 [self.preferences performClose:self];
207 if (!self.campfireIsAuthed) {
208 [self doCampfireAuth];
209 }
210 [self doCampfireRoomJoin];
211 [self findPlayer];
212 }
213
214 - (void)doCampfireAuth {
215 [self updateStatus:@"Joining campfire..."];
216 NSString *campfireUrl = [NSString stringWithFormat:@"https://%@.campfirenow.com",
217 [self.prefs stringForKey:@"campfireName"]];
218 NSLog(@"Initializing HappyCampfire");
219 self.campfire = [[HappyCampfire alloc] initWithCampfireURL:campfireUrl];
220 self.campfire.authToken = [self.prefs stringForKey:@"campfireAuthToken"];
221 [self updateStatus:@"Logged in to campfire"];
222 }
223
224 - (void)doCampfireRoomJoin {
225 NSLog(@"Joining campfire room %@...", [self.prefs stringForKey:@"campfireRoomID"]);
226 [self.campfire joinRoom:[self.prefs stringForKey:@"campfireRoomID"]
227 WithCompletionHandler:^(NSError *error) {
228 NSLog(@"Joined room with error: %@", error);
229 }];
230 }
231
232 - (void)findPlayer {
233 [self updateStatus:@"Finding music player..."];
3092b33 @jlipps Added spotify support
authored
234 NSLog(@"Finding music player");
c3a17bb @jlipps Added a PlayerApplication abstraction class so we can use both iTunes…
authored
235 PlayerApplication *p = [PlayerApplication getActivePlayer];
236 if ( p != nil ) {
875d2c0 @jlipps Updated HappyCampfire for 10.7, some new design stuff and better icon
authored
237 if (self.player != nil) {
238 NSLog(@"Releasing old self.player, which was %@", self.player);
239 [self.player release];
240 }
241 self.player = p;
242 [self.player retain];
243 NSLog(@"Got new player, which is %@", self.player);
3092b33 @jlipps Added spotify support
authored
244 NSString *msg = [NSString stringWithFormat:@"Found %@", [self.player name]];
a70fa42 @jlipps Playing with better memory management
authored
245 NSLog(@"%@", msg);
3092b33 @jlipps Added spotify support
authored
246 [self updateStatus:msg];
14c261e @jlipps Adding files from saucytunes
authored
247 [self.playerTimer invalidate];
248 [self startUpdateLoop];
249 } else {
875d2c0 @jlipps Updated HappyCampfire for 10.7, some new design stuff and better icon
authored
250 if( self.player != nil ) {
251 [self.player release];
252 }
c3a17bb @jlipps Added a PlayerApplication abstraction class so we can use both iTunes…
authored
253 [self updateStatus:@"Start iTunes or Spotify!"];
14c261e @jlipps Adding files from saucytunes
authored
254 if (![self.playerTimer isValid]) {
255 self.playerTimer = [NSTimer scheduledTimerWithTimeInterval:3
256 target:self
257 selector:@selector(playerTimerUpdate:)
258 userInfo:nil
259 repeats:YES];
260 }
261 }
262
263 }
264
265 - (void)playerTimerUpdate:(NSTimer *)timerObj {
266 [self findPlayer];
267 }
268
269 - (void)startUpdateLoop {
875d2c0 @jlipps Updated HappyCampfire for 10.7, some new design stuff and better icon
authored
270 NSLog(@"In startUpdateLoop, player is %@", self.player);
14c261e @jlipps Adding files from saucytunes
authored
271 [self update];
272 self.timer = [NSTimer scheduledTimerWithTimeInterval:3
273 target:self
274 selector:@selector(timerUpdate:)
275 userInfo:nil
276 repeats:YES];
277 }
278
279 - (void)timerUpdate:(NSTimer *)timerObj {
875d2c0 @jlipps Updated HappyCampfire for 10.7, some new design stuff and better icon
authored
280 NSLog(@"In timerUpdate, player is %@", self.player);
14c261e @jlipps Adding files from saucytunes
authored
281 [self update];
282 }
c12b106 @jlipps Added artwork sending support
authored
283
284 - (NSString *)_sanitizeFileNameString:(NSString *)fileName {
285 NSCharacterSet* illegalFileNameCharacters = [NSCharacterSet characterSetWithCharactersInString:@"/\\?%*|\"<>"];
286 return [[fileName componentsSeparatedByCharactersInSet:illegalFileNameCharacters] componentsJoinedByString:@""];
287 }
288
14c261e @jlipps Adding files from saucytunes
authored
289 - (void)update {
290 NSLog(@"Updating...");
875d2c0 @jlipps Updated HappyCampfire for 10.7, some new design stuff and better icon
authored
291 NSLog(@"%@", self.player);
a70fa42 @jlipps Playing with better memory management
authored
292 if ([self.player isRunning]) {
293 PlayerTrack *newTrack = [self.player currentTrack];
294 if ([newTrack name] == nil || ![self.player isPlaying]) {
14c261e @jlipps Adding files from saucytunes
authored
295 [self updateStatus:@"You need to play something!"];
296 [self clearTrackInfo];
d6d8683 @jlipps Making artwork smaller size, fixing bug in ad detection
authored
297 } else if (![newTrack isAdvertisement]) {
3092b33 @jlipps Added spotify support
authored
298 [self updateStatus:[NSString stringWithFormat:@"Connected to Campfire with %@", [self.player name]]];
14c261e @jlipps Adding files from saucytunes
authored
299 NSLog(@"Playing track: %@ from %@ by %@", [newTrack name], [newTrack album], [newTrack artist]);
c12b106 @jlipps Added artwork sending support
authored
300 BOOL albumDiff = ![self.currentAlbum isEqualToString:[newTrack album]];
af11f1d @jlipps Added logic so when you restart the app mid-song, it doesn't re-uploa…
authored
301 BOOL diff = ![self.currentName isEqualToString:[newTrack name]];
c12b106 @jlipps Added artwork sending support
authored
302 diff = diff || albumDiff;
af11f1d @jlipps Added logic so when you restart the app mid-song, it doesn't re-uploa…
authored
303 diff = diff || ![self.currentArtist isEqualToString:[newTrack artist]];
304 if (diff) {
305 NSLog(@"Track is not the same as last track this run");
14c261e @jlipps Adding files from saucytunes
authored
306 self.currentName = [NSString stringWithString:[newTrack name]];
307 self.currentAlbum = [NSString stringWithString:[newTrack album]];
308 self.currentArtist = [NSString stringWithString:[newTrack artist]];
af11f1d @jlipps Added logic so when you restart the app mid-song, it doesn't re-uploa…
authored
309 BOOL prefsDiff = YES;
c12b106 @jlipps Added artwork sending support
authored
310 BOOL prefsAlbumDiff = YES;
af11f1d @jlipps Added logic so when you restart the app mid-song, it doesn't re-uploa…
authored
311 if ([self.prefs stringForKey:@"lastSentName"] != nil) {
312 NSString *pName = [self.prefs stringForKey:@"lastSentName"];
313 NSString *pAlbum = [self.prefs stringForKey:@"lastSentAlbum"];
314 NSString *pArtist = [self.prefs stringForKey:@"lastSentArtist"];
c12b106 @jlipps Added artwork sending support
authored
315 BOOL prefsAlbumDiff = ![pAlbum isEqualToString:self.currentAlbum];
af11f1d @jlipps Added logic so when you restart the app mid-song, it doesn't re-uploa…
authored
316 prefsDiff = ![pName isEqualToString:self.currentName];
c12b106 @jlipps Added artwork sending support
authored
317 prefsDiff = prefsDiff || prefsAlbumDiff;
af11f1d @jlipps Added logic so when you restart the app mid-song, it doesn't re-uploa…
authored
318 prefsDiff = prefsDiff || ![pArtist isEqualToString:self.currentArtist];
319 }
320 if(!prefsDiff) {
321 NSLog(@"This is the same track we uploaded last time, doing nothing");
322 } else {
323 NSString *roomID = [self.prefs stringForKey:@"campfireRoomID"];
324 [self updateStatus:@"Sending track..."];
325 NSLog(@"Notifying campfire of new track");
c3a17bb @jlipps Added a PlayerApplication abstraction class so we can use both iTunes…
authored
326 NSString *campfireText = [NSString stringWithFormat:@":notes: %@ :guitar: %@ :dvd: %@%@%@",
327 self.currentName, self.currentArtist,
328 self.currentAlbum, [newTrack campfireStarEmoji],
329 [newTrack url]];
d6d8683 @jlipps Making artwork smaller size, fixing bug in ad detection
authored
330 if (self.debug) {
331 NSLog(@"Fake-sent [%@] to campfire", campfireText);
332 [self.prefs setObject:self.currentName forKey:@"lastSentName"];
333 [self.prefs setObject:self.currentAlbum forKey:@"lastSentAlbum"];
334 [self.prefs setObject:self.currentArtist forKey:@"lastSentArtist"];
c3a17bb @jlipps Added a PlayerApplication abstraction class so we can use both iTunes…
authored
335 } else {
d6d8683 @jlipps Making artwork smaller size, fixing bug in ad detection
authored
336 [self.campfire sendText:campfireText toRoom:roomID
337 completionHandler:^(HCMessage *message, NSError *error){
338 NSLog(@"Sent [%@] to campfire", message);
339 NSLog(@"Error: %@", error);
340 [self updateStatus:@"Sending track...done!"];
341 [self.prefs setObject:self.currentName forKey:@"lastSentName"];
342 [self.prefs setObject:self.currentAlbum forKey:@"lastSentAlbum"];
343 [self.prefs setObject:self.currentArtist forKey:@"lastSentArtist"];
875d2c0 @jlipps Updated HappyCampfire for 10.7, some new design stuff and better icon
authored
344 NSLog(@"Updated prefs with last artists");
d6d8683 @jlipps Making artwork smaller size, fixing bug in ad detection
authored
345 }];
346 }
347
348 if ( albumDiff && prefsAlbumDiff ) {
349 NSImage *artwork = [newTrack artwork];
350 if (artwork != nil) {
351 NSString *sArtist = [self _sanitizeFileNameString:self.currentArtist];
352 NSString *sAlbum = [self _sanitizeFileNameString:self.currentAlbum];
353 NSString *albumFileName = [NSString stringWithFormat:@"%@-%@.jpg", sArtist, sAlbum];
354 NSString *albumFullFileName = [self pathForDataFile:albumFileName];
355 [self saveArtwork:artwork withFileName:albumFileName];
875d2c0 @jlipps Updated HappyCampfire for 10.7, some new design stuff and better icon
authored
356 [self updateStatus:@"Sending artwork..."];
d6d8683 @jlipps Making artwork smaller size, fixing bug in ad detection
authored
357 if (self.debug) {
358 NSLog(@"Fake-sent album image to campfire");
875d2c0 @jlipps Updated HappyCampfire for 10.7, some new design stuff and better icon
authored
359 [self updateStatus:@"Sending artwork...done!"];
360 [self deleteArtwork:albumFileName];
c12b106 @jlipps Added artwork sending support
authored
361 } else {
d6d8683 @jlipps Making artwork smaller size, fixing bug in ad detection
authored
362 NSLog(@"Sending artwork %@ to campfire", albumFileName);
363 [self.campfire postFile:albumFullFileName toRoom:roomID
364 completionHandler:^(HCUploadFile *file, NSError *error) {
365 NSLog(@"Posted [%@] to campfire", albumFullFileName);
366 NSLog(@"Error: %@", error);
367 [self updateStatus:@"Sending artwork...done!"];
875d2c0 @jlipps Updated HappyCampfire for 10.7, some new design stuff and better icon
authored
368 [self deleteArtwork:albumFileName];
d6d8683 @jlipps Making artwork smaller size, fixing bug in ad detection
authored
369 }];
c12b106 @jlipps Added artwork sending support
authored
370 }
371 } else {
d6d8683 @jlipps Making artwork smaller size, fixing bug in ad detection
authored
372 NSLog(@"This track had no artwork, not sending any");
c12b106 @jlipps Added artwork sending support
authored
373 }
d6d8683 @jlipps Making artwork smaller size, fixing bug in ad detection
authored
374 } else {
375 NSLog(@"We already sent in artwork for this album, doing nothing");
65ab622 @jlipps Added Spotify ScriptingBridge header, also shows iTunes rating now
authored
376 }
af11f1d @jlipps Added logic so when you restart the app mid-song, it doesn't re-uploa…
authored
377 }
14c261e @jlipps Adding files from saucytunes
authored
378 NSLog(@"Current track now is: %@, %@, %@", self.currentName, self.currentAlbum, self.currentArtist);
379 } else {
af11f1d @jlipps Added logic so when you restart the app mid-song, it doesn't re-uploa…
authored
380 NSLog(@"Track is the same, doing nothing");
14c261e @jlipps Adding files from saucytunes
authored
381 }
382 [self updateTrackWithName:self.currentName withArtist:self.currentArtist withAlbum:self.currentAlbum];
d6d8683 @jlipps Making artwork smaller size, fixing bug in ad detection
authored
383 } else {
384 NSLog(@"Found advertisement, doing nothing.");
385 [self updateStatus:@"Skipping advertisement..."];
14c261e @jlipps Adding files from saucytunes
authored
386 }
387 } else {
388 [self clearTrackInfo];
389 [self.timer invalidate];
390 [self findPlayer];
391 }
392 }
393
394
395 - (void)updateStatus:(NSString *)msg {
396 [self.statusLabel setStringValue:msg];
397 }
398
399 - (void)updateTrackWithName: (NSString *)name withArtist:(NSString *)artist withAlbum:(NSString *)album {
400 [self.trackName setStringValue:name];
d0da49f @jlipps Separated artist and album onto separate lines
authored
401 [self.trackInfo setStringValue:artist];
402 [self.trackAlbum setStringValue:album];
14c261e @jlipps Adding files from saucytunes
authored
403 }
404
405 - (void)clearTrackInfo {
406 [self.trackName setStringValue:@""];
407 [self.trackInfo setStringValue:@""];
3092b33 @jlipps Added spotify support
authored
408 [self.trackAlbum setStringValue:@""];
14c261e @jlipps Adding files from saucytunes
authored
409 }
410
c12b106 @jlipps Added artwork sending support
authored
411 - (NSString *)pathForDataFile: (NSString *)fileName {
412 NSFileManager *fileManager = [NSFileManager defaultManager];
413
414 NSString *folder = @"~/Library/Application Support/CampfireTunes/";
415 folder = [folder stringByExpandingTildeInPath];
416
417 if ([fileManager fileExistsAtPath: folder] == NO) {
418 [fileManager createDirectoryAtPath: folder attributes: nil];
419 }
420
421 return [folder stringByAppendingPathComponent: fileName];
422 }
423
9405fa3 @jlipps Moving to 10.7
authored
424 - (void)saveArtwork:(NSImage *)artwork withFileName:(NSString *)fileName {
c12b106 @jlipps Added artwork sending support
authored
425 NSString *fullFileName = [self pathForDataFile:fileName];
875d2c0 @jlipps Updated HappyCampfire for 10.7, some new design stuff and better icon
authored
426 NSLog(@"Saving %@ to %@", fileName, fullFileName);
8563d76 @jlipps Upped artwork size a bit
authored
427 NSSize size = NSMakeSize(150.0, 150.0);
d6d8683 @jlipps Making artwork smaller size, fixing bug in ad detection
authored
428 [artwork saveAsJpegWithName:fullFileName andSize:size];
c12b106 @jlipps Added artwork sending support
authored
429 }
430
9405fa3 @jlipps Moving to 10.7
authored
431 - (void)deleteArtwork:(NSString *)fileName {
c12b106 @jlipps Added artwork sending support
authored
432 NSString *fullFileName = [self pathForDataFile:fileName];
433 NSFileManager *fileManager = [NSFileManager defaultManager];
875d2c0 @jlipps Updated HappyCampfire for 10.7, some new design stuff and better icon
authored
434 NSLog(@"Deleting %@ from %@", fileName, fullFileName);
435 //[fileManager removeItemAtPath:fullFileName error:nil];
c12b106 @jlipps Added artwork sending support
authored
436 }
437
14c261e @jlipps Adding files from saucytunes
authored
438 @end
Something went wrong with that request. Please try again.