| 83 | | if ( (!strcasecmp(iprop->name, "FirstName")) |
|---|
| 84 | | || (!strcasecmp(iprop->name, "MiddleName")) |
|---|
| 85 | | || (!strcasecmp(iprop->name, "LastName")) |
|---|
| 86 | | || (!strcasecmp(iprop->name,"Suffix")) ) |
|---|
| 87 | | { |
|---|
| 88 | | if (!oxf_name) |
|---|
| 89 | | oxf_name = osync_xmlfield_new(out_xmlformat, "Name", error); |
|---|
| 90 | | |
|---|
| 91 | | if (!strcasecmp(iprop->name, "FirstName")) |
|---|
| 92 | | osync_xmlfield_set_key_value(oxf_name, "FirstName", iprop->children->content); |
|---|
| 93 | | else if (!strcasecmp(iprop->name, "MiddleName")) |
|---|
| 94 | | osync_xmlfield_set_key_value(oxf_name, "Additional", iprop->children->content); |
|---|
| 95 | | else if (!strcasecmp(iprop->name, "LastName")) |
|---|
| 96 | | osync_xmlfield_set_key_value(oxf_name, "LastName", iprop->children->content); |
|---|
| 97 | | else if (!strcasecmp(iprop->name,"Suffix")) |
|---|
| 98 | | osync_xmlfield_set_key_value(oxf_name, "Suffix", iprop->children->content); |
|---|
| 99 | | } |
|---|
| 100 | | else if ( (!strcasecmp(iprop->name, "Company")) |
|---|
| 101 | | || (!strcasecmp(iprop->name, "Department")) |
|---|
| 102 | | || (!strcasecmp(iprop->name, "Office")) ) |
|---|
| 103 | | { |
|---|
| 104 | | if (!oxf_organisation) |
|---|
| 105 | | oxf_organisation = osync_xmlfield_new(out_xmlformat, "Organization", error); |
|---|
| 106 | | |
|---|
| 107 | | if (!strcasecmp(iprop->name, "Company")) |
|---|
| 108 | | osync_xmlfield_set_key_value(oxf_organisation, "Name", iprop->children->content); |
|---|
| 109 | | if (!strcasecmp(iprop->name, "Department")) |
|---|
| 110 | | osync_xmlfield_set_key_value(oxf_organisation, "Department", iprop->children->content); |
|---|
| 111 | | if (!strcasecmp(iprop->name, "Office")) |
|---|
| 112 | | osync_xmlfield_set_key_value(oxf_organisation, "Unit", iprop->children->content); |
|---|
| 113 | | } |
|---|
| 114 | | else if(!strcasecmp(iprop->name, "FileAs")) |
|---|
| | 79 | if (!strcasecmp(iprop->name, "FileAs")) |
|---|
| 200 | | else if ( (!strcasecmp(iprop->name, "HomeStreet")) |
|---|
| 201 | | || (!strcasecmp(iprop->name, "HomeCity")) |
|---|
| 202 | | || (!strcasecmp(iprop->name, "HomeState")) |
|---|
| 203 | | || (!strcasecmp(iprop->name,"HomeZip")) |
|---|
| 204 | | || (!strcasecmp(iprop->name,"HomeCountry")) ) |
|---|
| 205 | | { |
|---|
| 206 | | if (!oxf_homeaddress) |
|---|
| 207 | | oxf_homeaddress = osync_xmlfield_new(out_xmlformat, "Address", error); |
|---|
| 208 | | |
|---|
| 209 | | if (!strcasecmp(iprop->name, "HomeStreet")) |
|---|
| 210 | | osync_xmlfield_set_key_value(oxf_homeaddress, "Street", iprop->children->content); |
|---|
| 211 | | else if (!strcasecmp(iprop->name, "HomeCity")) |
|---|
| 212 | | osync_xmlfield_set_key_value(oxf_homeaddress, "Locality", iprop->children->content); |
|---|
| 213 | | else if (!strcasecmp(iprop->name, "HomeState")) |
|---|
| 214 | | osync_xmlfield_set_key_value(oxf_homeaddress, "Region", iprop->children->content); |
|---|
| 215 | | else if (!strcasecmp(iprop->name, "HomeZip")) |
|---|
| 216 | | osync_xmlfield_set_key_value(oxf_homeaddress, "PostalCode", iprop->children->content); |
|---|
| 217 | | else if (!strcasecmp(iprop->name,"HomeCountry")) |
|---|
| 218 | | osync_xmlfield_set_key_value(oxf_homeaddress, "Country", iprop->children->content); |
|---|
| 219 | | osync_xmlfield_set_attr(oxf_homeaddress, "Location", "Home"); |
|---|
| 220 | | } |
|---|
| 221 | | else if ( (!strcasecmp(iprop->name, "BusinessStreet")) |
|---|
| 222 | | || (!strcasecmp(iprop->name, "BusinessCity")) |
|---|
| 223 | | || (!strcasecmp(iprop->name, "BusinessState")) |
|---|
| 224 | | || (!strcasecmp(iprop->name,"BusinessZip")) |
|---|
| 225 | | || (!strcasecmp(iprop->name,"BusinessCountry")) ) |
|---|
| 226 | | { |
|---|
| 227 | | if (!oxf_workaddress) |
|---|
| 228 | | oxf_workaddress = osync_xmlfield_new(out_xmlformat, "Address", error); |
|---|
| 229 | | |
|---|
| 230 | | if (!strcasecmp(iprop->name, "BusinessStreet")) |
|---|
| 231 | | osync_xmlfield_set_key_value(oxf_workaddress, "Street", iprop->children->content); |
|---|
| 232 | | else if (!strcasecmp(iprop->name, "BusinessCity")) |
|---|
| 233 | | osync_xmlfield_set_key_value(oxf_workaddress, "Locality", iprop->children->content); |
|---|
| 234 | | else if (!strcasecmp(iprop->name, "BusinessState")) |
|---|
| 235 | | osync_xmlfield_set_key_value(oxf_workaddress, "Region", iprop->children->content); |
|---|
| 236 | | else if (!strcasecmp(iprop->name, "BusinessZip")) |
|---|
| 237 | | osync_xmlfield_set_key_value(oxf_workaddress, "PostalCode", iprop->children->content); |
|---|
| 238 | | else if (!strcasecmp(iprop->name,"BusinessCountry")) |
|---|
| 239 | | osync_xmlfield_set_key_value(oxf_workaddress, "Country", iprop->children->content); |
|---|
| 240 | | osync_xmlfield_set_attr(oxf_workaddress, "Location", "Work"); |
|---|
| 241 | | } |
|---|
| | 243 | GSList *attrs = NULL; |
|---|
| | 244 | GSList *keys = NULL; |
|---|
| | 245 | |
|---|
| | 246 | /* Name */ |
|---|
| | 247 | dual_list_append(&attrs, "LastName", &keys, "LastName"); |
|---|
| | 248 | dual_list_append(&attrs, "FirstName", &keys, "FirstName"); |
|---|
| | 249 | dual_list_append(&attrs, "MiddleName", &keys, "Additional"); |
|---|
| | 250 | dual_list_append(&attrs, "Suffix", &keys, "Suffix"); |
|---|
| | 251 | out_xmlfield = xml_attrs_to_xmlfield_keys(icur, out_xmlformat, "Name", attrs, keys, error); |
|---|
| | 252 | dual_list_clear(&attrs, &keys); |
|---|
| | 253 | |
|---|
| | 254 | /* Organization */ |
|---|
| | 255 | dual_list_append(&attrs, "Company", &keys, "Name"); |
|---|
| | 256 | dual_list_append(&attrs, "Department", &keys, "Department"); |
|---|
| | 257 | dual_list_append(&attrs, "Office", &keys, "Unit"); |
|---|
| | 258 | out_xmlfield = xml_attrs_to_xmlfield_keys(icur, out_xmlformat, "Organization", attrs, keys, error); |
|---|
| | 259 | dual_list_clear(&attrs, &keys); |
|---|
| | 260 | |
|---|
| | 261 | /* Home Address */ |
|---|
| | 262 | dual_list_append(&attrs, "HomeStreet", &keys, "Street"); |
|---|
| | 263 | dual_list_append(&attrs, "HomeCity", &keys, "Locality"); |
|---|
| | 264 | dual_list_append(&attrs, "HomeState", &keys, "Region"); |
|---|
| | 265 | dual_list_append(&attrs, "HomeZip", &keys, "PostalCode"); |
|---|
| | 266 | dual_list_append(&attrs, "HomeCountry", &keys, "Country"); |
|---|
| | 267 | out_xmlfield = xml_attrs_to_xmlfield_keys(icur, out_xmlformat, "Address", attrs, keys, error); |
|---|
| | 268 | if(out_xmlfield) |
|---|
| | 269 | osync_xmlfield_set_attr(out_xmlfield, "Location", "Home"); |
|---|
| | 270 | dual_list_clear(&attrs, &keys); |
|---|
| | 271 | |
|---|
| | 272 | /* Work Address */ |
|---|
| | 273 | dual_list_append(&attrs, "BusinessStreet", &keys, "Street"); |
|---|
| | 274 | dual_list_append(&attrs, "BusinessCity", &keys, "Locality"); |
|---|
| | 275 | dual_list_append(&attrs, "BusinessState", &keys, "Region"); |
|---|
| | 276 | dual_list_append(&attrs, "BusinessZip", &keys, "PostalCode"); |
|---|
| | 277 | dual_list_append(&attrs, "BusinessCountry", &keys, "Country"); |
|---|
| | 278 | out_xmlfield = xml_attrs_to_xmlfield_keys(icur, out_xmlformat, "Address", attrs, keys, error); |
|---|
| | 279 | if(out_xmlfield) |
|---|
| | 280 | osync_xmlfield_set_attr(out_xmlfield, "Location", "Work"); |
|---|
| | 281 | dual_list_clear(&attrs, &keys); |
|---|
| | 282 | |
|---|
| | 283 | |
|---|
| | 1400 | } |
|---|
| | 1401 | |
|---|
| | 1402 | OSyncXMLField *xml_attrs_to_xmlfield_keys(xmlNode *node, OSyncXMLFormat *out_xmlformat, const char *fieldname, GSList *attrs, GSList *keys, OSyncError **error) { |
|---|
| | 1403 | GSList *attrsptr = attrs; |
|---|
| | 1404 | GSList *keysptr = keys; |
|---|
| | 1405 | OSyncXMLField *out_xmlfield = NULL; |
|---|
| | 1406 | |
|---|
| | 1407 | while(attrsptr) { |
|---|
| | 1408 | char *attr = ((char *)(attrsptr->data)); |
|---|
| | 1409 | char *value = xmlGetProp(node, attr); |
|---|
| | 1410 | if(value) { |
|---|
| | 1411 | char *key = (char *)(keysptr->data); |
|---|
| | 1412 | if(!out_xmlfield) |
|---|
| | 1413 | out_xmlfield = osync_xmlfield_new(out_xmlformat, fieldname, error); |
|---|
| | 1414 | osync_xmlfield_set_key_value(out_xmlfield, key, value); |
|---|
| | 1415 | } |
|---|
| | 1416 | |
|---|
| | 1417 | attrsptr = g_slist_next(attrsptr); |
|---|
| | 1418 | keysptr = g_slist_next(keysptr); |
|---|
| | 1419 | } |
|---|
| | 1420 | |
|---|
| | 1421 | return out_xmlfield; |
|---|
| | 1422 | } |
|---|
| | 1423 | |
|---|
| | 1424 | void dual_list_append(GSList **list1, void *item1, GSList **list2, void *item2) { |
|---|
| | 1425 | *list1 = g_slist_append(*list1, item1); |
|---|
| | 1426 | *list2 = g_slist_append(*list2, item2); |
|---|
| | 1427 | } |
|---|
| | 1428 | |
|---|
| | 1429 | void dual_list_clear(GSList **list1, GSList **list2) { |
|---|
| | 1430 | g_slist_free(*list1); |
|---|
| | 1431 | *list1 = NULL; |
|---|
| | 1432 | g_slist_free(*list2); |
|---|
| | 1433 | *list2 = NULL; |
|---|