forked from H2CO3/libipodimport
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.m
More file actions
executable file
·45 lines (37 loc) · 1.23 KB
/
client.m
File metadata and controls
executable file
·45 lines (37 loc) · 1.23 KB
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
/*
* client.m
* libipodimport
*
* iPod library import support library
* Created by Arpad Goretity on 24/09/2012.
*
* Licensed under the 3-clause BSD License
* (See LICENSE for furhter information)
*/
#include <Foundation/Foundation.h>
#include <AppSupport/CPDistributedMessagingCenter.h>
#include "ipodimport.h"
static id shared = nil;
@implementation IPIPodImporter
+ (IPIPodImporter *)sharedInstance
{
if (shared == nil) {
shared = [[self alloc] init];
}
return shared;
}
- (void)importFileAtPath:(NSString *)path withMetadata:(NSDictionary *)metadata
{
// Copy over the file since the iPod library subsystem deletes it (!) after importing
NSString *fileName = [path lastPathComponent];
NSString *tempPath = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
[[NSFileManager defaultManager] copyItemAtPath:path toPath:tempPath error:NULL];
// Set up the context information
NSMutableDictionary *info = [metadata mutableCopy];
[info setObject:tempPath forKey:kIPIKeyPath];
// And actually call the server
CPDistributedMessagingCenter *center = [CPDistributedMessagingCenter centerNamed:@"org.h2co3.ipodimport"];
[center sendMessageName:@"org.h2co3.ipodimport.exec" userInfo:info];
[info release];
}
@end