summaryrefslogtreecommitdiffstats
path: root/src/lockdown.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2010-05-15 17:08:05 +0200
committerGravatar Martin Szulecki2010-05-15 17:08:05 +0200
commita78323c5135a33851e7056a2f2fce3c83b5acfbc (patch)
tree55357d4d900dc5e80c93880068c2346e04d2d515 /src/lockdown.c
parent21ab0f72efa67879d60174ecd8e76ad59bea43cc (diff)
downloadlibimobiledevice-a78323c5135a33851e7056a2f2fce3c83b5acfbc.tar.gz
libimobiledevice-a78323c5135a33851e7056a2f2fce3c83b5acfbc.tar.bz2
Use a more general implementation to get data classes the device supports
Some devices appear to not have anything set in com.apple.mobile.tethered_sync. Thus we use the more general com.apple.mobile.iTunes domain to query which seems to be supported on all tested devices.
Diffstat (limited to 'src/lockdown.c')
-rw-r--r--src/lockdown.c59
1 files changed, 14 insertions, 45 deletions
diff --git a/src/lockdown.c b/src/lockdown.c
index 3f03eab..ae865fb 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -1527,8 +1527,7 @@ static void str_remove_spaces(char *source)
1527} 1527}
1528 1528
1529/** 1529/**
1530 * Calculates and returns the data classes the device supports and which are 1530 * Calculates and returns the data classes the device supports from lockdownd.
1531 * enabled for synchronization from lockdownd.
1532 * 1531 *
1533 * @param client An initialized lockdownd client. 1532 * @param client An initialized lockdownd client.
1534 * @param classes A pointer to store an array of class names. The caller is responsible 1533 * @param classes A pointer to store an array of class names. The caller is responsible
@@ -1549,19 +1548,17 @@ lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, cha
1549 return LOCKDOWN_E_NO_RUNNING_SESSION; 1548 return LOCKDOWN_E_NO_RUNNING_SESSION;
1550 1549
1551 plist_t dict = NULL; 1550 plist_t dict = NULL;
1552 plist_dict_iter iter = NULL;
1553 lockdownd_error_t err = LOCKDOWN_E_UNKNOWN_ERROR; 1551 lockdownd_error_t err = LOCKDOWN_E_UNKNOWN_ERROR;
1554 1552
1555 char *key = NULL;
1556 plist_t value = NULL; 1553 plist_t value = NULL;
1557 1554
1558 char **newlist = NULL; 1555 char **newlist = NULL;
1559 int newcount = 0; 1556 char *val = NULL;
1560 1557
1561 *classes = NULL; 1558 *classes = NULL;
1562 *count = 0; 1559 *count = 0;
1563 1560
1564 err = lockdownd_get_value(client, "com.apple.mobile.tethered_sync", NULL, &dict); 1561 err = lockdownd_get_value(client, "com.apple.mobile.iTunes", "SyncDataClasses", &dict);
1565 if (err != LOCKDOWN_E_SUCCESS) { 1562 if (err != LOCKDOWN_E_SUCCESS) {
1566 if (dict) { 1563 if (dict) {
1567 plist_free(dict); 1564 plist_free(dict);
@@ -1569,54 +1566,26 @@ lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, cha
1569 return err; 1566 return err;
1570 } 1567 }
1571 1568
1572 if (plist_get_node_type(dict) != PLIST_DICT) { 1569 if (plist_get_node_type(dict) != PLIST_ARRAY) {
1573 plist_free(dict); 1570 plist_free(dict);
1574 return LOCKDOWN_E_PLIST_ERROR; 1571 return LOCKDOWN_E_PLIST_ERROR;
1575 } 1572 }
1576 1573
1577 plist_dict_new_iter(dict, &iter); 1574 while((value = plist_array_get_item(dict, *count)) != NULL) {
1578 1575 plist_get_string_val(value, &val);
1579 plist_dict_next_item(dict, iter, &key, &value); 1576 newlist = realloc(*classes, sizeof(char*) * (*count+1));
1580 while (key && value) { 1577 str_remove_spaces(val);
1581 int add_to_list = 0; 1578 asprintf(&newlist[*count], "com.apple.%s", val);
1582 plist_t disabled = NULL; 1579 free(val);
1583 1580 val = NULL;
1584 disabled = plist_dict_get_item(value, "DisableTethered");
1585
1586 if (!disabled) {
1587 add_to_list = 1;
1588 } else {
1589 if (plist_get_node_type(disabled) == PLIST_BOOLEAN) {
1590 uint8_t val = 0;
1591 plist_get_bool_val(disabled, &val);
1592 add_to_list = val > 0 ? 0 : 1;
1593 } else {
1594 uint64_t val = 0;
1595 plist_get_uint_val(disabled, &val);
1596 add_to_list = val > 0 ? 0 : 1;
1597 }
1598 }
1599
1600 if (add_to_list) {
1601 newlist = realloc(*classes, sizeof(char*) * (newcount+1));
1602 str_remove_spaces(key);
1603 asprintf(&newlist[newcount++], "com.apple.%s", key);
1604 *classes = newlist; 1581 *classes = newlist;
1605 } 1582 *count = *count+1;
1606 free(key);
1607 key = NULL;
1608 value = NULL;
1609 plist_dict_next_item(dict, iter, &key, &value);
1610 } 1583 }
1611 1584
1612 *count = newcount; 1585 newlist = realloc(*classes, sizeof(char*) * (*count+1));
1613 newlist = realloc(*classes, sizeof(char*) * (newcount+1)); 1586 newlist[*count] = NULL;
1614 newlist[newcount] = NULL;
1615 *classes = newlist; 1587 *classes = newlist;
1616 1588
1617 if (iter) {
1618 free(iter);
1619 }
1620 if (dict) { 1589 if (dict) {
1621 plist_free(dict); 1590 plist_free(dict);
1622 } 1591 }