-
Notifications
You must be signed in to change notification settings - Fork 1
/
XSContactView.m
60 lines (50 loc) · 2.01 KB
/
XSContactView.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
//
// XSContactView.m
// SkypeToAddressBook
//
// Created by Xavi Aracil on 17/08/10.
// Copyright 2010 xaracSoft (Xavi Aracil Diaz). All rights reserved.
//
#import "XSContactView.h"
#import "XSContact.h"
#import "AppDelegate.h"
#import <AddressBook/AddressBook.h>
@interface XSContactView()
-(void) displayAlert:(XSContact *) contact;
-(void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode
contextInfo:(void *)contextInfo;
@end
@implementation XSContactView
@synthesize editing;
-(void) removeContact:(id) sender{
XSContact *contact = self.representedObject;
if (contact.isInAddressBook) {
// display a confirmation alert
[self displayAlert:contact];
} else {
self.editing = YES;
AppDelegate *appDelegate = [[NSApplication sharedApplication] delegate];
[appDelegate showPeoplePicker:self.representedObject fromView:sender];
}
}
#pragma mark -
#pragma mark Private Methods
-(void) displayAlert:(XSContact *) contact {
NSAlert *alert = [[[NSAlert alloc] init] autorelease];
[alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK")];
[alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"Cancel")];
[alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"delete message", @"Delete message with two params"), contact.name, contact.skypeName]];
[alert setInformativeText:NSLocalizedString(@"Disconnected contacts cannot be restored.", @"Disconnected contacts cannot be restored.")];
[alert setAlertStyle:NSWarningAlertStyle];
[alert beginSheetModalForWindow:self.view.window modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil];
}
- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode
contextInfo:(void *)contextInfo {
if (returnCode == NSAlertFirstButtonReturn) {
XSContact *contact = self.representedObject;
contact.uniqueID = NULL;
// save AddressBook changes
[[ABAddressBook sharedAddressBook] save];
}
}
@end