File: Feed.m

package info (click to toggle)
grr.app 1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 3,948 kB
  • ctags: 118
  • sloc: objc: 4,019; sh: 72; makefile: 18
file content (190 lines) | stat: -rw-r--r-- 4,327 bytes parent folder | download
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
   Grr RSS Reader
   
   Copyright (C) 2006, 2007 Guenther Noack <guenther@unix-ag.uni-kl.de>
   Copyright (C) 2009-2011  GNUstep Application Team
                            Riccardo Mottola

   This application is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation; either
   version 3 of the License, or (at your option) any later version.
 
   This application is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.
 
   You should have received a copy of the GNU General Public
   License along with this library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. 
*/

#import <RSSKit/RSSFeed+Storage.h>

#import "Feed.h"
#import "Article.h"

#ifdef GNUSTEP
#import "NSURL+Proxy.h"
#endif

#ifdef __APPLE__
#import "GNUstep.h"
#endif

// ----------------------------------------------
//    Feed Private interface.
// ----------------------------------------------

@interface Feed (Private)
-(void) beginsFetching;
@end



@implementation Feed

// ----------------------------------------------
//    Counting of unread articles
// ----------------------------------------------

-(int) unreadArticleCount
{
    int i;
    int unreadCount = 0;
    NSArray* articleArray = [[self articleSet] allObjects];
    
    for (i=0; i<[articleArray count]; i++) {
        id<Article> article = [articleArray objectAtIndex: i];
        
        if ([article isRead] == NO) {
            unreadCount ++;
        }
    }
    
    return unreadCount;
}


// ----------------------------------------------
//    Database element protocol
// ----------------------------------------------

-(NSMutableDictionary*) plistDictionary
{
    NSMutableDictionary* dict = [super plistDictionary];
    
    // The DatabaseElement protocol says there has to be a
    // isa key indicating the name of the object's class.
    [dict setObject: [[self class] description] forKey: @"isa"];
    
    // We'll also have to store our database name, if there's
    // a special one.
    if (databaseElementName != nil) {
        [dict setObject: databaseElementName forKey: @"databaseElementName"];
    }
    
    return dict;
}

-(id) initWithDictionary: (NSDictionary*) plistDictionary
{
    if ((self = [super initFromPlistDictionary: plistDictionary]) != nil) {
        ASSIGN(databaseElementName, [plistDictionary objectForKey: @"databaseElementName"]);
    }
    
    return self;
}

-(id) superElement
{
    return superElem;
}

-(void) setSuperElement: (id) superElement
{
    ASSIGN(superElem, superElement);
}

-(void) setName: (NSString*) aString
{
    ASSIGN(databaseElementName, aString);
}

-(NSString*) description
{
    if (databaseElementName != nil) {
        return databaseElementName;
    } else {
        return [super description];
    }
}


// ----------------------------------------------
//    Article Group protocol (No manual modifications allowed)
// ----------------------------------------------

-(BOOL) allowsArticleSetDrop: (NSSet*) articleSet
{
    return NO;
}

-(BOOL) dropArticleSet: (NSSet*) articleSet
{
    return NO;
}

-(BOOL) allowsArticleSetRemoval: (NSSet*) articleSet
{
    return NO;
}

-(BOOL) removeArticleSet: (NSSet*) articleSet
{
    return NO;
}


// ----------------------------------------------
//    Overridden fetching methods
// ----------------------------------------------

-(void) fetchInBackground
{
    [self beginsFetching];
    [super fetchInBackground];
}

-(enum RSSFeedError) fetch
{
    [self beginsFetching];
    return [super fetch];
}

@end


// ----------------------------------------------
//    Private methods impl
// ----------------------------------------------
@implementation Feed (Private)

// ----------------------------------------------
//    Gets executed when fetching starts
//    and applies proxy settings if possible
// ----------------------------------------------

-(void) beginsFetching
{
	// FIXME: why was this enabled only for GNUstep?
#ifdef GNUSTEP
    [feedURL applyProxySettings];
#endif
}

@end