Skip to content

Commit 8c96048

Browse files
committed
no crytical
1 parent bc67e8e commit 8c96048

File tree

6 files changed

+597
-264
lines changed

6 files changed

+597
-264
lines changed

RSSCue.xcodeproj/xcuserdata/dsa.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
continueAfterRunningActions = "No"
1010
isPathRelative = "1"
1111
filePath = "RSSCue/RCPreferencesController.m"
12-
timestampString = "404145294.638812"
12+
timestampString = "404155568.219929"
1313
startingColumnNumber = "9223372036854775807"
1414
endingColumnNumber = "9223372036854775807"
15-
startingLineNumber = "50"
16-
endingLineNumber = "50"
15+
startingLineNumber = "64"
16+
endingLineNumber = "64"
1717
landmarkName = "-updateInfoText"
1818
landmarkType = "5">
1919
</FileBreakpoint>

RSSCue/RCFeedsPool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
-(RCFeed *) feedForUUID:(NSString *)uuid;
1919
-(void) addFeedByUUID:(NSString*)uuid;
2020
-(void) removeFeedByUUID:(NSString*)uuid;
21-
-(void) updateFeedByUUID:(NSString*)uuid;
21+
-(void) restartFeedByUUID:(NSString*)uuid;
2222
@end

RSSCue/RCFeedsPool.m

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,28 @@ + (RCFeedsPool*)sharedPool{
2626
return _sharedPool;
2727
}
2828

29+
-(void) addFeed:(RCFeed *)feed withConfig:(NSDictionary *)config {
30+
NSTimeInterval interval=[[config objectForKey:@"interval"] doubleValue];
31+
if (interval<10) interval=10; //precaution
32+
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:interval
33+
target:self
34+
selector:@selector(runFeed:)
35+
userInfo:[NSDictionary dictionaryWithObject:feed forKey:@"feed"]
36+
repeats:YES];
37+
[_timers setObject:timer forKey:feed.uuid];
38+
NSLog(@"Feed %@ added to the schedule",feed.name);
39+
};
40+
2941
-(void) addFeedByConfig:(NSDictionary *)config {
3042
if (NO==[[config valueForKey:@"enabled"] boolValue]) {
3143
return;
3244
}
3345
NSString *uuid=[config valueForKey:@"uuid"];
3446
NSAssert(uuid!=nil, @"UUID must not be nill\n%@", config);
3547
RCFeed* feed=[[[RCFeed alloc] initWithUUID:uuid andDelegate:self] autorelease];
36-
NSLog(@"Feed %@ started",feed.name);
48+
3749
[feed run];
38-
NSTimeInterval interval=[[config objectForKey:@"interval"] doubleValue];
39-
if (interval<10) interval=10; //precaution
40-
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:interval
41-
target:self
42-
selector:@selector(runFeed:)
43-
userInfo:[NSDictionary dictionaryWithObject:feed forKey:@"feed"]
44-
repeats:YES];
45-
[_timers setObject:timer forKey:uuid];
50+
[self addFeed:feed withConfig:config];
4651
};
4752

4853
-(void) addFeedByUUID:(NSString*)uuid {
@@ -56,13 +61,17 @@ -(void) removeFeedByUUID:(NSString*)uuid{
5661
RCFeed *feed=[[[timer userInfo] objectForKey:@"feed"] retain];
5762
[timer invalidate];
5863
[_timers removeObjectForKey:uuid];
59-
NSLog(@"Feed %@ removed",feed.name);
64+
NSLog(@"Feed %@ removed from the schedule",feed.name);
6065
[feed release];
6166
};
6267

63-
-(void) updateFeedByUUID:(NSString*)uuid{
68+
-(void) restartFeedByUUID:(NSString*)uuid{
69+
RCFeed *feed=[[self feedForUUID:uuid] retain];
70+
NSDictionary * config=[NSUserDefaults configForFeedByUUID:uuid];
71+
NSAssert(config!=nil, @"Attempt to add a feed with no configuraiton, uuid=%@",uuid);
6472
[self removeFeedByUUID:uuid];
65-
[self addFeedByUUID:uuid];
73+
[self addFeed:feed withConfig:config];
74+
[feed release];
6675
}
6776

6877
-(void)launchAll{

RSSCue/RCPreferencesController.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,18 @@
1717
@property (assign) IBOutlet NSSegmentedControl *buttons;
1818
@property (assign) IBOutlet NSTextField *info;
1919
@property (assign) IBOutlet NSProgressIndicator *progress;
20+
@property (retain) NSString* login;
21+
@property (retain) NSString* password;
2022

2123
- (IBAction)addRemoveFeed:(id)sender;
2224
- (IBAction)save:(id)sender;
23-
- (void) updateInfoText;
25+
26+
- (void)controlTextDidEndEditing:(NSNotification *)aNotification;
27+
28+
@property (assign) IBOutlet NSTextField *fieldURL;
29+
@property (assign) IBOutlet NSTextField *fieldLogin;
30+
@property (assign) IBOutlet NSTextField *fieldPassword;
31+
@property (assign) IBOutlet NSStepper *stepperInterval;
32+
@property (assign) IBOutlet NSStepper *stepperMax;
2433

2534
@end

RSSCue/RCPreferencesController.m

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,27 @@
1111
#import "NSUserDefaults+FeedConfig.h"
1212

1313
@implementation RCPreferencesController
14+
@synthesize fieldURL;
15+
@synthesize fieldLogin;
16+
@synthesize fieldPassword;
17+
@synthesize stepperInterval;
18+
@synthesize stepperMax;
1419
@synthesize progress;
1520
@synthesize info;
1621

22+
@synthesize login;
23+
@synthesize password;
24+
1725
@synthesize feedsArrayController;
1826
@synthesize buttons=_buttons;
1927

2028
#pragma mark utilities
29+
- (NSDictionary *)selectedConfig{
30+
NSArray * selection=[feedsArrayController selectedObjects];
31+
NSDictionary * config=[selection count]>0?[selection objectAtIndex:0]:nil;
32+
return config;
33+
}
34+
2135
- (void) setControlsEnabled {
2236
unsigned long c=[[feedsArrayController selectedObjects] count];
2337
[self.buttons setEnabled:c>0 forSegment:1];
@@ -75,6 +89,9 @@ - (void) updateInfoText {
7589
[self.info setStringValue:[NSString stringWithFormat:@"%@\nURL: %@\nTotal number of entries: %@\nNumber of shown entries: %@\nLast fetch: %@\n%@",title,link,total,reported, lastFetchTxt,summary]];
7690
}
7791

92+
- (IBAction)restartSelectedFeed:(id)sender {
93+
}
94+
7895

7996

8097
#pragma mark Initialization
@@ -95,14 +112,21 @@ - (void)windowDidLoad
95112
}
96113
- (void) awakeFromNib {
97114
[feedsArrayController addObserver:self forKeyPath:@"selection" options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) context:nil];
115+
/*
116+
[feedsArrayController addObserver:self forKeyPath:@"selection.interval" options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) context:nil];
117+
[feedsArrayController addObserver:self forKeyPath:@"selection.url" options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) context:nil];
118+
[feedsArrayController addObserver:self forKeyPath:@"selection.enabled" options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) context:nil];*/
119+
[feedsArrayController addObserver:self forKeyPath:@"login" options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) context:nil];
120+
[feedsArrayController addObserver:self forKeyPath:@"password" options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) context:nil];
121+
98122
[self setControlsEnabled];
99123
[self updateInfoText];
100124
[[NSNotificationCenter defaultCenter] addObserver:self
101125
selector:@selector(feedUpdated:)
102126
name:@"feedUpdate" object:nil];
103127
}
104128

105-
#pragma mark Controls observers
129+
#pragma mark Controls observers & delegators
106130

107131
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
108132
if ([keyPath isEqualToString:@"selection"]){
@@ -111,6 +135,15 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
111135
}
112136
}
113137

138+
- (void)controlTextDidEndEditing:(NSNotification *)aNotification {
139+
NSTextField* f=[aNotification object];
140+
if (f==self.fieldLogin||f==self.fieldURL||f==self.fieldPassword){
141+
NSString* uuid=[[self selectedConfig] objectForKey:@"uuid"];
142+
[[RCFeedsPool sharedPool] restartFeedByUUID:uuid];
143+
}
144+
// NSLog(@"%@",[[aNotification userInfo] valueForKey:@"NSFieldEditor"] );
145+
}
146+
114147
#pragma mark *** Buttons ***
115148
- (IBAction)addRemoveFeed:(id)sender {
116149
NSInteger button=[sender selectedSegment];

0 commit comments

Comments
 (0)