// File: "TclABUtils.h"
//                        Created: 2003-12-05 10:05:19
//              Last modification: 2009-03-11 10:43:21
// Author: Bernard Desgraupes
// e-mail: <bdesgraupes@users.sourceforge.net>
// 
// (c) Copyright: Bernard Desgraupes, 2003-2009
//         All rights reserved.
// This software is free software with BSD licence.


#ifndef _TCLABUTILS_H
#define _TCLABUTILS_H


// Enumerated values to designate the type of records
enum {	
	rec_undefined = -1,
	rec_group = 0,
	rec_person
};



// Function prototypes
// ===================

int		TclAB_TypeFromRecord(ABAddressBookRef ab, ABRecordRef inRecord);

bool	TclAB_MakeValueRefFromTclObj(Tcl_Interp *interp, 
						Tcl_Obj * inValue, 
						ABPropertyType inPropType,
						CFTypeRef * outValue);

bool	TclAB_MakeDictRefFromTclObj(Tcl_Interp *interp, 
						Tcl_Obj * inValue, 
						ABPropertyType inPropType,
						CFTypeRef * outValue);

bool	TclAB_MakeMultiValueFromTclObj(Tcl_Interp *interp, 
						Tcl_Obj * inValue, 
						ABPropertyType inPropType,
						CFTypeRef * outValue);

bool	TclAB_MakeSearchRefFromTcl(Tcl_Interp *interp, 
						Tcl_Obj * inValue, 
						ABPropertyType inPropType,
						CFStringRef * outLabel,
						CFStringRef * outKey,
						CFTypeRef * outValue);

void	TclAB_SetResultWithArrayOfRecords(Tcl_Interp *interp, 
						CFArrayRef allSubGroups, 
						Boolean onlyID, 
						int inRecordType);

bool	TclAB_CheckItem(Tcl_Interp *interp, 
						ABAddressBookRef ab, 
						Tcl_Obj * inUID, 
						CONST84 char * inWhich,
						int inRecordType, 
						ABRecordRef * outItemRef);

bool	TclAB_RecordFromUID(Tcl_Interp *interp, 
						ABAddressBookRef ab, 
						CFStringRef inUID, 
						ABRecordRef * outRecordRef);

bool	TclAB_CheckMultiValueProperty(ABAddressBookRef ab, 
						CFStringRef inPropertyRef,
						int inRecordType);


CFMutableStringRef	TclAB_CFStringNormalize(CFStringRef theString, CFStringNormalizationForm theForm);

CFStringRef			TclAB_TclObjToCFString(Tcl_Obj * inObj);

Tcl_Obj *			TclAB_CFStringToTclObj(CFStringRef strRef);


#endif  // _TCLABUTILS_H