Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /XspfManager/XspfMMainWindowController.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations) (download)
Mon Nov 2 11:55:35 2009 UTC (14 years, 5 months ago) by masaki
Original Path: XspfManager/XspfManager.m
File size: 2618 byte(s)
Initial import.

1 masaki 2 //
2     // XspfManager.m
3     // XspfManager
4     //
5     // Created by Hori,Masaki on 09/11/01.
6     // Copyright 2009 masakih. All rights reserved.
7     //
8    
9     #import "XspfManager.h"
10    
11     #import "XspfMMovieLoadRequest.h"
12    
13    
14     @implementation XspfManager
15    
16     - (void)awakeFromNib
17     {
18     channel = [[HMChannel alloc] initWithWorkerNum:1];
19     }
20    
21     - (NSInteger)registerWithURL:(NSURL *)url
22     {
23     id obj = [NSEntityDescription insertNewObjectForEntityForName:@"Xspf"
24     inManagedObjectContext:[appDelegate managedObjectContext]];
25     if(!obj) return 1;
26    
27     [obj setValue:url forKey:@"url"];
28     [obj setValue:[NSDate dateWithTimeIntervalSinceNow:0.0] forKey:@"registerDate"];
29     [obj setValue:[NSDate dateWithTimeIntervalSinceNow:0.0] forKey:@"lastUpdateDate"];
30    
31     XspfMMovieLoadRequest *request = [XspfMMovieLoadRequest requestWithObject:obj url:url];
32     [channel putRequest:request];
33    
34     return noErr;
35     }
36    
37     - (IBAction)add:(id)sender
38     {
39     NSOpenPanel *panel = [NSOpenPanel openPanel];
40    
41     [panel setAllowedFileTypes:[NSArray arrayWithObjects:@"xspf", @"com.masakih.xspf", nil]];
42     [panel setAllowsMultipleSelection:YES];
43    
44     [panel beginSheetForDirectory:nil
45     file:nil
46     types:[NSArray arrayWithObjects:@"xspf", @"com.masakih.xspf", nil]
47     modalForWindow:window
48     modalDelegate:self
49     didEndSelector:@selector(endOpenPanel:::)
50     contextInfo:NULL];
51     }
52    
53     - (void)endOpenPanel:(NSOpenPanel *)panel :(NSInteger)returnCode :(void *)context
54     {
55     if(returnCode == NSCancelButton) return;
56    
57     [panel orderOut:nil];
58    
59     NSArray *URLs = [panel URLs];
60     if([URLs count] == 0) return;
61    
62     [progressBar setUsesThreadedAnimation:YES];
63    
64     [NSApp beginSheet:progressPanel
65     modalForWindow:window
66     modalDelegate:nil
67     didEndSelector:Nil
68     contextInfo:NULL];
69     [progressBar startAnimation:self];
70     [progressMessage setStringValue:@"During register."];
71    
72     for(id URL in URLs) {
73     [self registerWithURL:URL];
74     }
75    
76     [progressBar stopAnimation:self];
77     [progressPanel orderOut:self];
78     [NSApp endSheet:progressPanel];
79     }
80    
81    
82     - (void)addItem:(id)item
83     {
84    
85     }
86    
87    
88     - (void)removeItem:(id)item
89     {
90     [self doesNotRecognizeSelector:_cmd];
91     }
92    
93     - (IBAction)test01:(id)sender
94     {
95     NSLog(@"ManagedContext - >%@", [appDelegate managedObjectContext]);
96     }
97     - (IBAction)test02:(id)sender
98     {
99     NSLog(@"Array controller -> %@", [controller arrangedObjects]);
100     }
101     - (IBAction)test03:(id)sender
102     {
103     NSFetchRequest *fetch = [[[NSFetchRequest alloc] init] autorelease];
104    
105     id moc = [appDelegate managedObjectContext];
106    
107     [fetch setEntity:[NSEntityDescription entityForName:@"Xspf" inManagedObjectContext:moc]];
108    
109     id objs = [moc executeFetchRequest:fetch error:NULL];
110     NSLog(@"Fetched -> %@", objs);
111     }
112     @end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26