[Tcladdressbook-commits] Source TclAddressBook.c,1.27,1.28
Status: Alpha
Brought to you by:
bdesgraupes
|
From: Bernard D. <bde...@us...> - 2004-07-29 20:14:14
|
Update of /cvsroot/tcladdressbook/Source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17541/Source Modified Files: TclAddressBook.c Log Message: New setme command Index: TclAddressBook.c =================================================================== RCS file: /cvsroot/tcladdressbook/Source/TclAddressBook.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- TclAddressBook.c 29 Jul 2004 13:30:21 -0000 1.27 +++ TclAddressBook.c 29 Jul 2004 20:14:04 -0000 1.28 @@ -45,6 +45,7 @@ static int TclABCmd_Save(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], Tcl_Obj *resultPtr); static int TclABCmd_Search(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], Tcl_Obj *resultPtr); static int TclABCmd_Set(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], Tcl_Obj *resultPtr); +static int TclABCmd_SetMe(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], Tcl_Obj *resultPtr); static int TclABCmd_Type(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], Tcl_Obj *resultPtr); @@ -147,14 +148,14 @@ "add", "changed", "count", "create", "delete", "export", "getme", "groups", "identifier", "image", "import", "parents", "persons", "property", "record", "remove", "save", "search", - "set", "type", (char *) NULL + "set", "setme", "type", (char *) NULL }; enum { TCLAB_ADD, TCLAB_CHANGED, TCLAB_COUNT, TCLAB_CREATE, TCLAB_DELETE, TCLAB_EXPORT, TCLAB_GETME, TCLAB_GROUPS, TCLAB_IDENTIFIER, TCLAB_IMAGE, TCLAB_IMPORT, TCLAB_PARENTS, TCLAB_PERSONS, TCLAB_PROPERTY, TCLAB_RECORD, TCLAB_REMOVE, TCLAB_SAVE, TCLAB_SEARCH, - TCLAB_SET, TCLAB_TYPE + TCLAB_SET, TCLAB_SETME, TCLAB_TYPE }; resultPtr = Tcl_GetObjResult(interp); @@ -246,6 +247,10 @@ result = TclABCmd_Set(clientData, interp, objc, objv, resultPtr); break; + case TCLAB_SETME: + result = TclABCmd_SetMe(clientData, interp, objc, objv, resultPtr); + break; + case TCLAB_TYPE: result = TclABCmd_Type(clientData, interp, objc, objv, resultPtr); break; @@ -676,7 +681,6 @@ } - /* *---------------------------------------------------------------------- * @@ -1837,6 +1841,61 @@ /* *---------------------------------------------------------------------- * + * TclABCmd_SetMe -- + * + * This procedure is invoked to process the [addressbook setme] Tcl command. + * It sets the record that represents the logged-in user. + * + * Syntax: + * addressbook setme recordID + * + * + * Results: + * A standard Tcl result. + * + * Side effects: + * See the user documentation. + * + *---------------------------------------------------------------------- + */ + +int +TclABCmd_SetMe( + ClientData clientData, /* Not used. */ + Tcl_Interp *interp, /* Current interpreter. */ + int objc, /* Number of arguments. */ + Tcl_Obj *CONST objv[], /* Argument values. */ + Tcl_Obj *resultPtr) /* Pointer to store the result. */ +{ + ABAddressBookRef ab; + ABRecordRef theRecord; + int length; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "recordID"); + return TCL_ERROR; + } + + Tcl_ResetResult(interp); + + // Get the address book + ab = ABGetSharedAddressBook(); + + // Check if the second argument is a person and get the corresponding record + if ( !TclAB_CheckItem(interp, ab, Tcl_GetStringFromObj(objv[2], &length), "second", &theRecord, rec_person) ) { + return TCL_ERROR; + } + + ABSetMe(ab, theRecord); + + CFRelease(theRecord); + return TCL_OK; +} + + +/* + *---------------------------------------------------------------------- + * * TclABCmd_Type -- * * This procedure is invoked to process the [addressbook type] Tcl command. |