2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo 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 OGo 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 OGo; 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"]))
56 self->qualifier = [[EOQualifier alloc] initWithPropertyList:tmp];
58 if ((tmp = [ud objectForKey:@"sort"])) {
59 if ((tmp = [[EOSortOrdering alloc] initWithPropertyList:tmp])) {
60 self->sortOrderings = [[NSArray alloc] initWithObjects:tmp,nil];
68 [self->sortOrderings release];
69 [self->qualifier release];
70 [self->entityName release];
76 - (void)printObject:(id)_object {
77 printf("object: %s\n", [[_object description] cString]);
80 - (int)runWithArguments:(NSArray *)_args {
84 /* begin processing */
86 args = [_args objectEnumerator];
87 [args nextObject]; // process name ...
89 while ((arg = [args nextObject])) {
90 NSAutoreleasePool *pool2;
92 if ([arg hasPrefix:@"-"]) { /* consume defaults */
97 pool2 = [[NSAutoreleasePool alloc] init];
100 EOFetchSpecification *fspec;
104 /* setup fetch specification */
106 fspec = [[[EOFetchSpecification alloc] init] autorelease];
107 [fspec setEntityName:self->entityName];
108 [fspec setQualifier:self->qualifier];
110 /* setup datasource */
112 ds = [[[iCalDataSource alloc] initWithPath:arg] autorelease];
113 [ds setFetchSpecification:fspec];
117 if ((objs = [ds fetchObjects]) == nil) {
120 NSLog(@"fetch on ical file failed: %@", arg);
123 /* process results */
126 e = [objs objectEnumerator];
127 while ((obj = [e nextObject])) {
128 [self printObject:obj];
139 int main(int argc, char **argv, char **env) {
140 NSAutoreleasePool *pool;
144 #if LIB_FOUNDATION_LIBRARY
145 [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
148 pool = [[NSAutoreleasePool alloc] init];
150 if ((tool = [[iCal3Tool alloc] init])) {
152 rc = [tool runWithArguments:[[NSProcessInfo processInfo] arguments]];