[Tcladdressbook-commits] Source TclAddressBookUtils.c,1.9,1.10
Status: Alpha
Brought to you by:
bdesgraupes
|
From: <bde...@us...> - 2003-12-16 07:37:16
|
Update of /cvsroot/tcladdressbook/Source
In directory sc8-pr-cvs1:/tmp/cvs-serv948/Source
Modified Files:
TclAddressBookUtils.c
Log Message:
[getme] and [record] return directly in resultObj
Index: TclAddressBookUtils.c
===================================================================
RCS file: /cvsroot/tcladdressbook/Source/TclAddressBookUtils.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- TclAddressBookUtils.c 14 Dec 2003 17:21:40 -0000 1.9
+++ TclAddressBookUtils.c 16 Dec 2003 07:37:12 -0000 1.10
@@ -26,9 +26,8 @@
*
* TclAB_GetAllValues --
*
- * This function is invoked to return the property/values pairs in an array.
- * The "inVar" argument must not be NULL because this is the name of the
- * variable in which the results are stored.
+ * This function is invoked to return the property/values pairs in the
+ * result object.
*
* Results:
* None.
@@ -41,21 +40,16 @@
void
TclAB_GetAllValues(Tcl_Interp *interp, ABAddressBookRef ab,
- ABRecordRef inRecord, CONST84 char * inVar,
- int inRecordType)
+ ABRecordRef inRecord, int inRecordType)
{
CFIndex theCount;
CFStringRef theValue, theProperty;
CFArrayRef allProps;
int i;
- if (inRecordType == rec_person) {
- allProps = ABCopyArrayOfPropertiesForRecordType(ab, kABPersonRecordType);
- } else {
- allProps = ABCopyArrayOfPropertiesForRecordType(ab, kABGroupRecordType);
- }
-
+ allProps = ABCopyArrayOfPropertiesForRecordType(ab, inRecordType ? kABPersonRecordType : kABGroupRecordType);
theCount = CFArrayGetCount(allProps);
+
for (i = 0; i < theCount; i++) {
// Get the property at index i
theProperty = CFArrayGetValueAtIndex(allProps, i);
@@ -70,8 +64,6 @@
}
}
CFRelease(allProps);
- // Store the result in the variable
- Tcl_SetVar2Ex(interp, inVar, NULL, Tcl_GetObjResult(interp), TCL_GLOBAL_ONLY);
}
@@ -1118,18 +1110,10 @@
// Get the address book
ab = ABGetSharedAddressBook();
-
- switch (inRecordType) {
- case rec_group:
- theItems = ABCopyArrayOfPropertiesForRecordType(ab, kABGroupRecordType);
- break;
-
- case rec_person:
- theItems = ABCopyArrayOfPropertiesForRecordType(ab, kABPersonRecordType);
- break;
- }
-
+ // Get the CFArray of properties
+ theItems = ABCopyArrayOfPropertiesForRecordType(ab, inRecordType ? kABPersonRecordType : kABGroupRecordType);
theCount = CFArrayGetCount(theItems);
+
for (i = 0; i < theCount; i++) {
// Get the record at index i
theProperty = CFArrayGetValueAtIndex(theItems,i);
@@ -1200,8 +1184,9 @@
// Create a CFArray
theArray = CFArrayCreateMutable(NULL, 0, NULL);
theProp = CFStringCreateWithCString(NULL, Tcl_GetStringFromObj(objv[4], &length), GetApplicationTextEncoding());
- // Populate the CFArray with the property pair
+ // Populate the CFArray with the property
CFArrayAppendValue(theArray, theProp);
+ CFRelease(theProp);
// Add the property to the Address Book
result = ABRemoveProperties(ab, inRecordType ? kABPersonRecordType : kABGroupRecordType, theArray);
@@ -1214,7 +1199,6 @@
}
Tcl_DecrRefCount(objv[4]);
- CFRelease(theProp);
CFRelease(theArray);
return result;
}
|