2
Copyright (C) 2000-2005 SKYRIX Software AG
4
This file is part of SOPE.
6
SOPE is free software; you can redistribute it and/or modify it under
7
the terms of the GNU Lesser General Public License as published by the
8
Free Software Foundation; either version 2, or (at your option) any
11
SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14
License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with SOPE; see the file COPYING. If not, write to the
18
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22
#import <Foundation/Foundation.h>
24
@class EOQualifier, NSString, EOSortOrdering;
26
@interface iCal3Tool : NSObject
28
EOQualifier *qualifier;
30
NSArray *sortOrderings;
33
- (int)runWithArguments:(NSArray *)_args;
37
#include <NGiCal/iCalDataSource.h>
38
#include <NGiCal/iCalObject.h>
39
#include <EOControl/EOQualifier.h>
40
#include <EOControl/EOSortOrdering.h>
43
@implementation iCal3Tool
46
if ((self = [super init])) {
51
ud = [NSUserDefaults standardUserDefaults];
53
self->entityName = [[ud stringForKey:@"entity"] copy];
55
if ((tmp = [ud objectForKey:@"qualifier"]) != nil) {
56
self->qualifier = [[EOQualifier alloc] initWithPropertyList:tmp
60
if ((tmp = [ud objectForKey:@"sort"]) != nil) {
61
tmp = [[EOSortOrdering alloc] initWithPropertyList:tmp owner:nil];
63
self->sortOrderings = [[NSArray alloc] initWithObjects:&tmp count:1];
64
[tmp release]; tmp = nil;
71
[self->sortOrderings release];
72
[self->qualifier release];
73
[self->entityName release];
79
- (void)printObject:(id)_object {
80
printf("object: %s\n", [[_object description] cString]);
83
- (int)runWithArguments:(NSArray *)_args {
87
/* begin processing */
89
args = [_args objectEnumerator];
90
[args nextObject]; // process name ...
92
while ((arg = [args nextObject])) {
93
NSAutoreleasePool *pool2;
95
if ([arg hasPrefix:@"-"]) { /* consume defaults */
100
pool2 = [[NSAutoreleasePool alloc] init];
103
EOFetchSpecification *fspec;
107
/* setup fetch specification */
109
fspec = [[[EOFetchSpecification alloc] init] autorelease];
110
[fspec setEntityName:self->entityName];
111
[fspec setQualifier:self->qualifier];
113
/* setup datasource */
115
ds = [iCalDataSource alloc]; // keep gcc happy
116
ds = [[ds initWithPath:arg] autorelease];
117
[ds setFetchSpecification:fspec];
121
if ((objs = [ds fetchObjects]) == nil) {
124
NSLog(@"fetch on ical file failed: %@", arg);
127
/* process results */
130
e = [objs objectEnumerator];
131
while ((obj = [e nextObject])) {
132
[self printObject:obj];
143
int main(int argc, char **argv, char **env) {
144
NSAutoreleasePool *pool;
148
pool = [[NSAutoreleasePool alloc] init];
149
#if LIB_FOUNDATION_LIBRARY
150
[NSProcessInfo initializeWithArguments:argv count:argc environment:env];
153
if ((tool = [[iCal3Tool alloc] init])) {
155
rc = [tool runWithArguments:[[NSProcessInfo processInfo] arguments]];