source: releases/Pester/1.1a1/Source/PSSpeechAlert.m@ 579

Last change on this file since 579 was 34, checked in by Nicholas Riley, 22 years ago

Changes for Pester 1.1d1.

File size: 1.4 KB
Line 
1//
2// PSSpeechAlert.m
3// Pester
4//
5// Created by Nicholas Riley on Sat Oct 26 2002.
6// Copyright (c) 2002 __MyCompanyName__. All rights reserved.
7//
8
9#import "PSSpeechAlert.h"
10#import "PSAlarmAlertController.h"
11
12@implementation PSSpeechAlert
13
14+ (PSSpeechAlert *)alertWithVoice:(NSString *)aVoice;
15{
16 return [[[self alloc] initWithVoice: aVoice] autorelease];
17}
18
19- (id)initWithVoice:(NSString *)aVoice;
20{
21 if ( (self = [super init]) != nil) {
22 voice = aVoice;
23 }
24 return self;
25}
26
27- (void)dealloc;
28{
29 [[NSNotificationCenter defaultCenter] removeObserver: self];
30 [speaker release]; speaker = nil;
31 [voice release]; voice = nil;
32 [super dealloc];
33}
34
35- (void)_stopSpeaking:(NSNotification *)notification;
36{
37 [speaker stopSpeaking];
38 // don't release here, we'll still get the didFinishSpeaking: message as a delegate
39}
40
41- (void)triggerForAlarm:(PSAlarm *)alarm;
42{
43 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(_stopSpeaking:) name: PSAlarmAlertStopNotification object: nil];
44
45 if ( (speaker = [[SUSpeaker alloc] init]) == nil) return;
46 [speaker setDelegate: self];
47 [speaker setVoice: [[SUSpeaker voiceNames] indexOfObject: voice] + 1];
48 [speaker speakText: [alarm message]];
49
50 [self retain];
51}
52
53@end
54
55@implementation PSSpeechAlert (SUSpeakerDelegate)
56
57- (void)didFinishSpeaking:(SUSpeaker*)speaker;
58{
59 [self release];
60}
61
62@end
Note: See TracBrowser for help on using the repository browser.