From 4740e30d178c8a588f522586a817039d6be8da3b Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Sun, 11 Oct 2009 18:10:16 +0200 Subject: Update to latest libplist API. Signed-off-by: Matt Colyer [#77 state:resolved] --- dev/msyncclient.c | 45 +++++++++++++------------- src/MobileSync.c | 8 ++--- src/NotificationProxy.c | 15 +++------ src/lockdown.c | 84 +++++++++++++++++-------------------------------- 4 files changed, 60 insertions(+), 92 deletions(-) diff --git a/dev/msyncclient.c b/dev/msyncclient.c index 4b27eb7..fff4c44 100644 --- a/dev/msyncclient.c +++ b/dev/msyncclient.c @@ -37,12 +37,12 @@ static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client plist_t array = NULL; array = plist_new_array(); - plist_add_sub_string_el(array, "SDMessageSyncDataClassWithDevice"); - plist_add_sub_string_el(array, "com.apple.Contacts"); - plist_add_sub_string_el(array, "---"); - plist_add_sub_string_el(array, "2009-01-09 18:03:58 +0100"); - plist_add_sub_uint_el(array, 106); - plist_add_sub_string_el(array, "___EmptyParameterString___"); + plist_array_append_item(array, plist_new_string("SDMessageSyncDataClassWithDevice")); + plist_array_append_item(array, plist_new_string("com.apple.Contacts")); + plist_array_append_item(array, plist_new_string("---")); + plist_array_append_item(array, plist_new_string("2009-01-09 18:03:58 +0100")); + plist_array_append_item(array, plist_new_uint(106)); + plist_array_append_item(array, plist_new_string("___EmptyParameterString___")); ret = mobilesync_send(client, array); plist_free(array); @@ -59,9 +59,8 @@ static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client array = NULL; array = plist_new_array(); - plist_add_sub_string_el(array, "SDMessageGetAllRecordsFromDevice"); - plist_add_sub_string_el(array, "com.apple.Contacts"); - + plist_array_append_item(array, plist_new_string("SDMessageGetAllRecordsFromDevice")); + plist_array_append_item(array, plist_new_string("com.apple.Contacts")); ret = mobilesync_send(client, array); plist_free(array); @@ -81,8 +80,8 @@ static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client array = NULL; array = plist_new_array(); - plist_add_sub_string_el(array, "SDMessageAcknowledgeChangesFromDevice"); - plist_add_sub_string_el(array, "com.apple.Contacts"); + plist_array_append_item(array, plist_new_string("SDMessageAcknowledgeChangesFromDevice")); + plist_array_append_item(array, plist_new_string("com.apple.Contacts")); ret = mobilesync_send(client, array); plist_free(array); @@ -95,26 +94,26 @@ static mobilesync_error_t mobilesync_get_all_contacts(mobilesync_client_t client } array = plist_new_array(); - plist_add_sub_string_el(array, "DLMessagePing"); - plist_add_sub_string_el(array, "Preparing to get changes for device"); + plist_array_append_item(array, plist_new_string("DLMessagePing")); + plist_array_append_item(array, plist_new_string("Preparing to get changes for device")); ret = mobilesync_send(client, array); plist_free(array); array = NULL; array = plist_new_array(); - plist_add_sub_string_el(array, "SDMessageProcessChanges"); - plist_add_sub_string_el(array, "com.apple.Contacts"); - plist_add_sub_node(array, plist_new_dict()); - plist_add_sub_bool_el(array, 0); + plist_array_append_item(array, plist_new_string("SDMessageProcessChanges")); + plist_array_append_item(array, plist_new_string("com.apple.Contacts")); + plist_array_append_item(array, plist_new_dict()); + plist_array_append_item(array, plist_new_bool(0)); + plist_t dict = plist_new_dict(); - plist_add_sub_node(array, dict); - plist_add_sub_key_el(dict, "SyncDeviceLinkEntityNamesKey"); + plist_array_append_item(array, dict); plist_t array2 = plist_new_array(); - plist_add_sub_string_el(array2, "com.apple.contacts.Contact"); - plist_add_sub_string_el(array2, "com.apple.contacts.Group"); - plist_add_sub_key_el(dict, "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey"); - plist_add_sub_bool_el(dict, 0); + plist_dict_insert_item(dict, "SyncDeviceLinkEntityNamesKey", array2); + plist_array_append_item(array2, plist_new_string("com.apple.contacts.Contact")); + plist_array_append_item(array2, plist_new_string("com.apple.contacts.Group")); + plist_dict_insert_item(dict, "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey", plist_new_bool(0)); ret = mobilesync_send(client, array); plist_free(array); diff --git a/src/MobileSync.c b/src/MobileSync.c index 8a7d724..9e52f32 100644 --- a/src/MobileSync.c +++ b/src/MobileSync.c @@ -76,8 +76,8 @@ mobilesync_error_t mobilesync_client_new(iphone_device_t device, int dst_port, && ver_2_val == MSYNC_VERSION_INT2) { array = plist_new_array(); - plist_add_sub_string_el(array, "DLMessageVersionExchange"); - plist_add_sub_string_el(array, "DLVersionsOk"); + plist_array_append_item(array, plist_new_string("DLMessageVersionExchange")); + plist_array_append_item(array, plist_new_string("DLVersionsOk")); ret = mobilesync_send(client_loc, array); @@ -112,8 +112,8 @@ static void mobilesync_disconnect(mobilesync_client_t client) return; plist_t array = plist_new_array(); - plist_add_sub_string_el(array, "DLMessageDisconnect"); - plist_add_sub_string_el(array, "All done, thanks for the memories"); + plist_array_append_item(array, plist_new_string("DLMessageDisconnect")); + plist_array_append_item(array, plist_new_string("All done, thanks for the memories")); mobilesync_send(client, array); plist_free(array); diff --git a/src/NotificationProxy.c b/src/NotificationProxy.c index da636ab..ee2ad95 100644 --- a/src/NotificationProxy.c +++ b/src/NotificationProxy.c @@ -177,17 +177,14 @@ np_error_t np_post_notification(np_client_t client, const char *notification) np_lock(client); plist_t dict = plist_new_dict(); - plist_add_sub_key_el(dict, "Command"); - plist_add_sub_string_el(dict, "PostNotification"); - plist_add_sub_key_el(dict, "Name"); - plist_add_sub_string_el(dict, notification); + plist_dict_insert_item(dict,"Command", plist_new_string("PostNotification")); + plist_dict_insert_item(dict,"Name", plist_new_string(notification)); np_error_t res = np_plist_send(client, dict); plist_free(dict); dict = plist_new_dict(); - plist_add_sub_key_el(dict, "Command"); - plist_add_sub_string_el(dict, "Shutdown"); + plist_dict_insert_item(dict,"Command", plist_new_string("Shutdown")); res = np_plist_send(client, dict); plist_free(dict); @@ -213,10 +210,8 @@ np_error_t np_observe_notification( np_client_t client, const char *notification np_lock(client); plist_t dict = plist_new_dict(); - plist_add_sub_key_el(dict, "Command"); - plist_add_sub_string_el(dict, "ObserveNotification"); - plist_add_sub_key_el(dict, "Name"); - plist_add_sub_string_el(dict, notification); + plist_dict_insert_item(dict,"Command", plist_new_string("ObserveNotification")); + plist_dict_insert_item(dict,"Name", plist_new_string(notification)); np_error_t res = np_plist_send(client, dict); if (res != NP_E_SUCCESS) { diff --git a/src/lockdown.c b/src/lockdown.c index a05b5db..6f9c922 100644 --- a/src/lockdown.c +++ b/src/lockdown.c @@ -137,10 +137,8 @@ lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char * lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR; plist_t dict = plist_new_dict(); - plist_add_sub_key_el(dict, "Request"); - plist_add_sub_string_el(dict, "StopSession"); - plist_add_sub_key_el(dict, "SessionID"); - plist_add_sub_string_el(dict, session_id); + plist_dict_insert_item(dict,"Request", plist_new_string("StopSession")); + plist_dict_insert_item(dict,"SessionID", plist_new_string(session_id)); log_dbg_msg(DBGMASK_LOCKDOWND, "%s: called\n", __func__); @@ -365,8 +363,7 @@ lockdownd_error_t lockdownd_query_type(lockdownd_client_t client) lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR; plist_t dict = plist_new_dict(); - plist_add_sub_key_el(dict, "Request"); - plist_add_sub_string_el(dict, "QueryType"); + plist_dict_insert_item(dict,"Request", plist_new_string("QueryType")); log_dbg_msg(DBGMASK_LOCKDOWND, "%s: called\n", __func__); ret = lockdownd_send(client, dict); @@ -410,15 +407,12 @@ lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *dom /* setup request plist */ dict = plist_new_dict(); if (domain) { - plist_add_sub_key_el(dict, "Domain"); - plist_add_sub_string_el(dict, domain); + plist_dict_insert_item(dict,"Domain", plist_new_string(domain)); } if (key) { - plist_add_sub_key_el(dict, "Key"); - plist_add_sub_string_el(dict, key); + plist_dict_insert_item(dict,"Key", plist_new_string(key)); } - plist_add_sub_key_el(dict, "Request"); - plist_add_sub_string_el(dict, "GetValue"); + plist_dict_insert_item(dict,"Request", plist_new_string("GetValue")); /* send to device */ ret = lockdownd_send(client, dict); @@ -483,18 +477,13 @@ lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *dom /* setup request plist */ dict = plist_new_dict(); if (domain) { - plist_add_sub_key_el(dict, "Domain"); - plist_add_sub_string_el(dict, domain); + plist_dict_insert_item(dict,"Domain", plist_new_string(domain)); } if (key) { - plist_add_sub_key_el(dict, "Key"); - plist_add_sub_string_el(dict, key); + plist_dict_insert_item(dict,"Key", plist_new_string(key)); } - plist_add_sub_key_el(dict, "Request"); - plist_add_sub_string_el(dict, "SetValue"); - - plist_add_sub_key_el(dict, "Value"); - plist_add_sub_node(dict, value); + plist_dict_insert_item(dict,"Request", plist_new_string("SetValue")); + plist_dict_insert_item(dict,"Value", value); /* send to device */ ret = lockdownd_send(client, dict); @@ -545,15 +534,12 @@ lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char * /* setup request plist */ dict = plist_new_dict(); if (domain) { - plist_add_sub_key_el(dict, "Domain"); - plist_add_sub_string_el(dict, domain); + plist_dict_insert_item(dict,"Domain", plist_new_string(domain)); } if (key) { - plist_add_sub_key_el(dict, "Key"); - plist_add_sub_string_el(dict, key); + plist_dict_insert_item(dict,"Key", plist_new_string(key)); } - plist_add_sub_key_el(dict, "Request"); - plist_add_sub_string_el(dict, "RemoveValue"); + plist_dict_insert_item(dict,"Request", plist_new_string("RemoveValue")); /* send to device */ ret = lockdownd_send(client, dict); @@ -752,19 +738,15 @@ lockdownd_error_t lockdownd_pair(lockdownd_client_t client, char *uuid, char *ho /* Setup Pair request plist */ dict = plist_new_dict(); - plist_add_sub_key_el(dict, "PairRecord"); dict_record = plist_new_dict(); - plist_add_sub_node(dict, dict_record); - plist_add_sub_key_el(dict_record, "DeviceCertificate"); - plist_add_sub_data_el(dict_record, (const char*)device_cert.data, device_cert.size); - plist_add_sub_key_el(dict_record, "HostCertificate"); - plist_add_sub_data_el(dict_record, (const char*)host_cert.data, host_cert.size); - plist_add_sub_key_el(dict_record, "HostID"); - plist_add_sub_string_el(dict_record, host_id); - plist_add_sub_key_el(dict_record, "RootCertificate"); - plist_add_sub_data_el(dict_record, (const char*)root_cert.data, root_cert.size); - plist_add_sub_key_el(dict, "Request"); - plist_add_sub_string_el(dict, "Pair"); + plist_dict_insert_item(dict,"PairRecord", dict_record); + + plist_dict_insert_item(dict_record, "DeviceCertificate", plist_new_data((const char*)device_cert.data, device_cert.size)); + plist_dict_insert_item(dict_record, "HostCertificate", plist_new_data((const char*)host_cert.data, host_cert.size)); + plist_dict_insert_item(dict_record, "HostID", plist_new_string(host_id)); + plist_dict_insert_item(dict_record, "RootCertificate", plist_new_data((const char*)root_cert.data, root_cert.size)); + + plist_dict_insert_item(dict, "Request", plist_new_string("Pair")); /* send to iPhone */ ret = lockdownd_send(client, dict); @@ -813,8 +795,7 @@ lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client) lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR; plist_t dict = plist_new_dict(); - plist_add_sub_key_el(dict, "Request"); - plist_add_sub_string_el(dict, "EnterRecovery"); + plist_dict_insert_item(dict,"Request", plist_new_string("EnterRecovery")); log_dbg_msg(DBGMASK_LOCKDOWND, "%s: telling device to enter recovery mode\n", __func__); @@ -849,8 +830,7 @@ lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client) lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR; plist_t dict = plist_new_dict(); - plist_add_sub_key_el(dict, "Request"); - plist_add_sub_string_el(dict, "Goodbye"); + plist_dict_insert_item(dict,"Request", plist_new_string("Goodbye")); log_dbg_msg(DBGMASK_LOCKDOWND, "%s: called\n", __func__); @@ -1028,10 +1008,8 @@ lockdownd_error_t lockdownd_start_ssl_session(lockdownd_client_t client, const c /* Setup DevicePublicKey request plist */ dict = plist_new_dict(); - plist_add_sub_key_el(dict, "HostID"); - plist_add_sub_string_el(dict, HostID); - plist_add_sub_key_el(dict, "Request"); - plist_add_sub_string_el(dict, "StartSession"); + plist_dict_insert_item(dict,"HostID", plist_new_string(HostID)); + plist_dict_insert_item(dict,"Request", plist_new_string("StartSession")); ret = lockdownd_send(client, dict); plist_free(dict); @@ -1062,10 +1040,8 @@ lockdownd_error_t lockdownd_start_ssl_session(lockdownd_client_t client, const c /* start session again */ plist_free(dict); dict = plist_new_dict(); - plist_add_sub_key_el(dict, "HostID"); - plist_add_sub_string_el(dict, HostID); - plist_add_sub_key_el(dict, "Request"); - plist_add_sub_string_el(dict, "StartSession"); + plist_dict_insert_item(dict,"HostID", plist_new_string(HostID)); + plist_dict_insert_item(dict,"Request", plist_new_string("StartSession")); ret = lockdownd_send(client, dict); plist_free(dict); @@ -1263,10 +1239,8 @@ lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char host_id = NULL; dict = plist_new_dict(); - plist_add_sub_key_el(dict, "Request"); - plist_add_sub_string_el(dict, "StartService"); - plist_add_sub_key_el(dict, "Service"); - plist_add_sub_string_el(dict, service); + plist_dict_insert_item(dict,"Request", plist_new_string("StartService")); + plist_dict_insert_item(dict,"Service", plist_new_string(service)); /* send to iPhone */ ret = lockdownd_send(client, dict); -- cgit v1.1-32-gdbae