From 9ff66262c07b74c4d9fcd2ef1a37daf720401e6a Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Tue, 30 Oct 2001 02:32:50 +0000 Subject: overload this function for modifying objectclasses too, so we can make 2001-10-29 Chris Toshok * backend/pas/pas-backend-ldap.c (add_objectclass_mod): overload this function for modifying objectclasses too, so we can make sure evolutionPerson shows up in the objectclasses of an entry if it shows up in the schema for the server. (create_card_handler): add @replace = FALSE in the call to add_objectclass_mod. (modify_card_handler): call add_objectclass_mod with @replace = TRUE. (anniversary_compare): fix typo - return "equal", not "TRUE". (birthday_compare): same. svn path=/trunk/; revision=14402 --- addressbook/backend/pas/pas-backend-ldap.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'addressbook/backend') diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c index 61144471e9..83e2b85971 100644 --- a/addressbook/backend/pas/pas-backend-ldap.c +++ b/addressbook/backend/pas/pas-backend-ldap.c @@ -750,12 +750,12 @@ build_mods_from_ecards (PASBackendLDAP *bl, ECardSimple *current, ECardSimple *n } static void -add_objectclass_mod (PASBackendLDAP *bl, GPtrArray *mod_array) +add_objectclass_mod (PASBackendLDAP *bl, GPtrArray *mod_array, gboolean modify) { LDAPMod *objectclass_mod; objectclass_mod = g_new (LDAPMod, 1); - objectclass_mod->mod_op = LDAP_MOD_ADD; + objectclass_mod->mod_op = modify ? LDAP_MOD_REPLACE : LDAP_MOD_ADD; objectclass_mod->mod_type = g_strdup ("objectClass"); objectclass_mod->mod_values = g_new (char*, bl->priv->evolutionPersonSupported ? 6 : 5); objectclass_mod->mod_values[0] = g_strdup (TOP); @@ -824,7 +824,7 @@ create_card_handler (PASBackend *backend, LDAPOp *op) g_ptr_array_remove (mod_array, NULL); /* add our objectclass(es) */ - add_objectclass_mod (bl, mod_array); + add_objectclass_mod (bl, mod_array, FALSE); /* then put the NULL back */ g_ptr_array_add (mod_array, NULL); @@ -1088,6 +1088,17 @@ modify_card_handler (PASBackend *backend, LDAPOp *op) /* build our mods */ mod_array = build_mods_from_ecards (bl, current_card, new_card, &need_new_dn); if (mod_array->len > 0) { + + /* remove the NULL at the end */ + g_ptr_array_remove (mod_array, NULL); + + /* add our objectclass(es), making sure + evolutionPerson is there if it's supported */ + add_objectclass_mod (bl, mod_array, TRUE); + + /* then put the NULL back */ + g_ptr_array_add (mod_array, NULL); + ldap_mods = (LDAPMod**)mod_array->pdata; /* actually perform the ldap modify */ @@ -1636,7 +1647,7 @@ anniversary_compare (ECardSimple *ecard1, ECardSimple *ecard2) g_free (date1); g_free (date2); - return TRUE; + return equal; } static void @@ -1703,7 +1714,7 @@ birthday_compare (ECardSimple *ecard1, ECardSimple *ecard2) g_free (date1); g_free (date2); - return TRUE; + return equal; } #define IS_RFC2254_CHAR(c) ((c) == '*' || (c) =='\\' || (c) == '(' || (c) == ')' || (c) == '\0') -- cgit v1.2.3