+2005-07-13 Helge Hess <helge.hess@opengroupware.org>
+
+ * v4.5.48
+
+ * NGVCard.m: added some convenience methods to access the preferred
+ email, tel and adr
+
+ * NGVCardOrg.m: added a convenience method to access the first orgunit
+
2005-07-05 Marcus Mueller <znek@mulle-kybernetik.com>
* NSCalendarDate+ICal.m: fixed 'gmtcalfmt' which removed seconds from
*/
@class NSString, NSArray, NSDictionary;
-@class NGVCardStrArrayValue, NGVCardOrg, NGVCardName;
+@class NGVCardStrArrayValue, NGVCardOrg, NGVCardName, NGVCardSimpleValue;
+@class NGVCardPhone, NGVCardAddress;
@interface NGVCard : NSObject
{
- (void)setX:(NSDictionary *)_dict;
- (NSDictionary *)x;
+/* convenience */
+
+- (NGVCardSimpleValue *)preferredEMail;
+- (NGVCardPhone *)preferredTel;
+- (NGVCardAddress *)preferredAdr;
+
@end
#endif /* __NGiCal_NGVCard_H__ */
return self->x;
}
+/* convenience */
+
+- (id)preferredValueInArray:(NSArray *)_values {
+ unsigned i, count;
+
+ if ((count = [_values count]) == 0)
+ return nil;
+ if (count == 1)
+ return [_values objectAtIndex:0];
+
+ /* scan for preferred value */
+ for (i = 0; i < count; i++) {
+#warning COMPLETE ME
+ }
+
+ /* just take first in sequence */
+ return [_values objectAtIndex:0];
+}
+
+- (NGVCardSimpleValue *)preferredEMail {
+ return [self preferredValueInArray:self->email];
+}
+- (NGVCardPhone *)preferredTel {
+ return [self preferredValueInArray:self->tel];
+}
+- (NGVCardAddress *)preferredAdr {
+ return [self preferredValueInArray:self->adr];
+}
+
/* description */
- (void)appendAttributesToDescription:(NSMutableString *)_ms {
- (NSString *)orgnam;
- (NSArray *)orgunits;
+/* convenience */
+
+- (NSString *)orgunit; /* returns the first orgunit when available */
+
/* values */
- (NSDictionary *)asDictionary;
return self->orgunits;
}
+- (NSString *)orgunit {
+ return [self->orgunits count] > 0 ? [self->orgunits objectAtIndex:0] : nil;
+}
+
/* fake being an array */
- (id)objectAtIndex:(unsigned)_idx {