[Tcladdressbook-commits] Source TclAddressBookUtils.c,1.16,1.17
Status: Alpha
Brought to you by:
bdesgraupes
|
From: Bernard D. <bde...@us...> - 2004-07-30 13:06:48
|
Update of /cvsroot/tcladdressbook/Source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3950/Source Modified Files: TclAddressBookUtils.c Log Message: TclAB_CheckMultiString() Index: TclAddressBookUtils.c =================================================================== RCS file: /cvsroot/tcladdressbook/Source/TclAddressBookUtils.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- TclAddressBookUtils.c 30 Jul 2004 11:14:46 -0000 1.16 +++ TclAddressBookUtils.c 30 Jul 2004 13:05:58 -0000 1.17 @@ -686,7 +686,44 @@ return result; } - + +/* + *---------------------------------------------------------------------- + * + * TclAB_CheckMultiString -- + * + * This function is invoked to check if property is a multi-value + * property. Used with the [addressbook identifier] command. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ +// // kABMultiArrayProperty +// // kABMultiDateProperty +// // kABMultiIntegerProperty +// // kABMultiRealProperty +// // kABMultiStringProperty + +Boolean +TclAB_CheckMultiString(ABAddressBookRef ab, CFStringRef inPropertyRef, int inRecordType) +{ + ABPropertyType thePropType; + + if (inRecordType == rec_person) { + thePropType = ABTypeOfProperty(ab, kABPersonRecordType, inPropertyRef); + } else { + thePropType = ABTypeOfProperty(ab, kABGroupRecordType, inPropertyRef); + } + + return (thePropType == kABMultiStringProperty); +} + + /* *---------------------------------------------------------------------- * @@ -1360,7 +1397,6 @@ CONST84 char * theProperty, * theUID; CFStringRef propertyRef, valueRef; ABRecordRef personRecord; -// ABPropertyType thePropType; int length, result = TCL_OK; unsigned int mvCount; @@ -1391,22 +1427,14 @@ goto DONE; } -// // Check the property type (string, date, multivalue...) -// // kABMultiArrayProperty -// // kABMultiDateProperty -// // kABMultiIntegerProperty -// // kABMultiRealProperty -// // kABMultiStringProperty - -// thePropType = ABTypeOfProperty(ab, kABPersonRecordType, propertyRef); -// if (thePropType == kABErrorInProperty) { -// Tcl_AppendStringsToObj(resultPtr, "Unknown property '", theProperty, -// "' for Person records", (char *) NULL); -// CFRelease(propertyRef); -// result = TCL_ERROR; -// goto DONE; -// } - + // Check the property's type + if ( ! TclAB_CheckMultiString(ab, propertyRef, rec_person) ) { + Tcl_AppendStringsToObj(resultPtr, "Not a multi-string list property", (char *) NULL); + CFRelease(propertyRef); + result = TCL_ERROR; + goto DONE; + } + valueRef = ABRecordCopyValue(personRecord, propertyRef); if (!valueRef) { Tcl_AppendStringsToObj(resultPtr, "Couldn't get value for '", @@ -1459,7 +1487,6 @@ CONST84 char * theProperty, * theUID, * theIndex; CFStringRef propertyRef, valueRef, identRef; ABRecordRef personRecord; -// ABPropertyType thePropType; char theString[256]; int index, length, result = TCL_OK; @@ -1493,22 +1520,15 @@ Tcl_IncrRefCount(objv[5]); theIndex = Tcl_GetStringFromObj(objv[5], &length); index = atoi(theIndex); - -// // Check the property type (string, date, multivalue...) -// // kABMultiArrayProperty -// // kABMultiDateProperty -// // kABMultiIntegerProperty -// // kABMultiRealProperty -// // kABMultiStringProperty -// thePropType = ABTypeOfProperty(ab, kABPersonRecordType, propertyRef); -// if (thePropType == kABErrorInProperty) { -// Tcl_AppendStringsToObj(resultPtr, "Unknown property '", theProperty, -// "' for Person records", (char *) NULL); -// CFRelease(propertyRef); -// result = TCL_ERROR; -// goto DONE; -// } - + + // Check the property's type + if ( ! TclAB_CheckMultiString(ab, propertyRef, rec_person) ) { + Tcl_AppendStringsToObj(resultPtr, "Not a multi-string list property", (char *) NULL); + CFRelease(propertyRef); + result = TCL_ERROR; + goto DONE; + } + valueRef = ABRecordCopyValue(personRecord, propertyRef); if (!valueRef) { Tcl_AppendStringsToObj(resultPtr, "Couldn't get value for '", theProperty, "' property", (char *) NULL); @@ -1570,7 +1590,6 @@ CONST84 char * theProperty, * theUID; CFStringRef propertyRef, valueRef, identRef; ABRecordRef personRecord; -// ABPropertyType thePropType; char theString[256]; int length, result = TCL_OK; @@ -1600,21 +1619,14 @@ goto DONE; } -// // Check the property type (string, date, multivalue...) -// // kABMultiArrayProperty -// // kABMultiDateProperty -// // kABMultiIntegerProperty -// // kABMultiRealProperty -// // kABMultiStringProperty -// thePropType = ABTypeOfProperty(ab, kABPersonRecordType, propertyRef); -// if (thePropType == kABErrorInProperty) { -// Tcl_AppendStringsToObj(resultPtr, "Unknown property '", theProperty, -// "' for Person records", (char *) NULL); -// CFRelease(propertyRef); -// result = TCL_ERROR; -// goto DONE; -// } - + // Check the property's type + if ( ! TclAB_CheckMultiString(ab, propertyRef, rec_person) ) { + Tcl_AppendStringsToObj(resultPtr, "Not a multi-string list property", (char *) NULL); + CFRelease(propertyRef); + result = TCL_ERROR; + goto DONE; + } + valueRef = ABRecordCopyValue(personRecord, propertyRef); if (!valueRef) { Tcl_AppendStringsToObj(resultPtr, "Couldn't get value for '", theProperty, "' property", (char *) NULL); @@ -1720,16 +1732,14 @@ goto DONE; } - // Check the property type (string, date, multivalue...) - thePropType = ABTypeOfProperty(ab, kABPersonRecordType, propertyRef); - if (thePropType == kABErrorInProperty) { - Tcl_AppendStringsToObj(resultPtr, "Unknown property '", theProperty, - "' for Person records", (char *) NULL); + // Check the property's type + if ( ! TclAB_CheckMultiString(ab, propertyRef, rec_person) ) { + Tcl_AppendStringsToObj(resultPtr, "Not a multi-string list property", (char *) NULL); CFRelease(propertyRef); result = TCL_ERROR; goto DONE; } - + if (objc == 7) { Tcl_IncrRefCount(objv[6]); theNewVal = Tcl_GetStringFromObj(objv[6], &length); |