summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2009-07-14 14:21:53 +0200
committerGravatar Matt Colyer2009-07-18 10:39:42 -0700
commit484ff2166a2de58dd185a05fefea47a3f8165033 (patch)
treea8b6f712399369b60999dcd81c8bdbdd36c8ce8b /src
parent5fa071717799ee2424c41b62360c7122b104fefb (diff)
downloadlibimobiledevice-484ff2166a2de58dd185a05fefea47a3f8165033.tar.gz
libimobiledevice-484ff2166a2de58dd185a05fefea47a3f8165033.tar.bz2
Cleanup mobilesync API and bindings. Move get_all_contacts() into msyncclient.
Diffstat (limited to 'src')
-rw-r--r--src/MobileSync.c125
-rw-r--r--src/MobileSync.h8
2 files changed, 15 insertions, 118 deletions
diff --git a/src/MobileSync.c b/src/MobileSync.c
index 7d6e947..b9a1cb0 100644
--- a/src/MobileSync.c
+++ b/src/MobileSync.c
@@ -29,8 +29,8 @@
#define MSYNC_VERSION_INT1 100
#define MSYNC_VERSION_INT2 100
-iphone_error_t iphone_msync_new_client(iphone_device_t device, int dst_port,
- iphone_msync_client_t * client)
+iphone_error_t mobilesync_new_client(iphone_device_t device, int dst_port,
+ mobilesync_client_t * client)
{
if (!device || dst_port == 0 || !client || *client)
return IPHONE_E_INVALID_ARG;
@@ -43,14 +43,14 @@ iphone_error_t iphone_msync_new_client(iphone_device_t device, int dst_port,
return ret;
}
- iphone_msync_client_t client_loc = (iphone_msync_client_t) malloc(sizeof(struct iphone_msync_client_int));
+ mobilesync_client_t client_loc = (mobilesync_client_t) malloc(sizeof(struct mobilesync_client_int));
client_loc->sfd = sfd;
//perform handshake
plist_t array = NULL;
//first receive version
- ret = iphone_msync_recv(client_loc, &array);
+ ret = mobilesync_recv(client_loc, &array);
plist_t msg_node = plist_find_node_by_string(array, "DLMessageVersionExchange");
plist_t ver_1 = plist_get_next_sibling(msg_node);
@@ -77,12 +77,12 @@ iphone_error_t iphone_msync_new_client(iphone_device_t device, int dst_port,
plist_add_sub_string_el(array, "DLMessageVersionExchange");
plist_add_sub_string_el(array, "DLVersionsOk");
- ret = iphone_msync_send(client_loc, array);
+ ret = mobilesync_send(client_loc, array);
plist_free(array);
array = NULL;
- ret = iphone_msync_recv(client_loc, &array);
+ ret = mobilesync_recv(client_loc, &array);
plist_t rep_node = plist_find_node_by_string(array, "DLMessageDeviceReady");
if (rep_node) {
@@ -96,12 +96,12 @@ iphone_error_t iphone_msync_new_client(iphone_device_t device, int dst_port,
}
if (IPHONE_E_SUCCESS != ret)
- iphone_msync_free_client(client_loc);
+ mobilesync_free_client(client_loc);
return ret;
}
-static void iphone_msync_stop_session(iphone_msync_client_t client)
+static void mobilesync_disconnect(mobilesync_client_t client)
{
if (!client)
return;
@@ -110,17 +110,17 @@ static void iphone_msync_stop_session(iphone_msync_client_t client)
plist_add_sub_string_el(array, "DLMessageDisconnect");
plist_add_sub_string_el(array, "All done, thanks for the memories");
- iphone_msync_send(client, array);
+ mobilesync_send(client, array);
plist_free(array);
array = NULL;
}
-iphone_error_t iphone_msync_free_client(iphone_msync_client_t client)
+iphone_error_t mobilesync_free_client(mobilesync_client_t client)
{
if (!client)
return IPHONE_E_INVALID_ARG;
- iphone_msync_stop_session(client);
+ mobilesync_disconnect(client);
return usbmuxd_disconnect(client->sfd);
}
@@ -131,7 +131,7 @@ iphone_error_t iphone_msync_free_client(iphone_msync_client_t client)
*
* @return an error code
*/
-iphone_error_t iphone_msync_recv(iphone_msync_client_t client, plist_t * plist)
+iphone_error_t mobilesync_recv(mobilesync_client_t client, plist_t * plist)
{
if (!client || !plist || (plist && *plist))
return IPHONE_E_INVALID_ARG;
@@ -177,7 +177,7 @@ iphone_error_t iphone_msync_recv(iphone_msync_client_t client, plist_t * plist)
*
* @return an error code
*/
-iphone_error_t iphone_msync_send(iphone_msync_client_t client, plist_t plist)
+iphone_error_t mobilesync_send(mobilesync_client_t client, plist_t plist)
{
if (!client || !plist)
return IPHONE_E_INVALID_ARG;
@@ -207,102 +207,3 @@ iphone_error_t iphone_msync_send(iphone_msync_client_t client, plist_t plist)
return ret;
}
-iphone_error_t iphone_msync_get_all_contacts(iphone_msync_client_t client)
-{
- if (!client)
- return IPHONE_E_INVALID_ARG;
-
- iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR;
- 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___");
-
- ret = iphone_msync_send(client, array);
- plist_free(array);
- array = NULL;
-
- ret = iphone_msync_recv(client, &array);
-
- plist_t rep_node = plist_find_node_by_string(array, "SDSyncTypeSlow");
-
- if (!rep_node)
- return ret;
-
- plist_free(array);
- array = NULL;
-
- array = plist_new_array();
- plist_add_sub_string_el(array, "SDMessageGetAllRecordsFromDevice");
- plist_add_sub_string_el(array, "com.apple.Contacts");
-
-
- ret = iphone_msync_send(client, array);
- plist_free(array);
- array = NULL;
-
- ret = iphone_msync_recv(client, &array);
-
- plist_t contact_node;
- plist_t switch_node;
-
- contact_node = plist_find_node_by_string(array, "com.apple.Contacts");
- switch_node = plist_find_node_by_string(array, "SDMessageDeviceReadyToReceiveChanges");
-
- while (NULL == switch_node) {
-
- plist_free(array);
- array = NULL;
-
- array = plist_new_array();
- plist_add_sub_string_el(array, "SDMessageAcknowledgeChangesFromDevice");
- plist_add_sub_string_el(array, "com.apple.Contacts");
-
- ret = iphone_msync_send(client, array);
- plist_free(array);
- array = NULL;
-
- ret = iphone_msync_recv(client, &array);
-
- contact_node = plist_find_node_by_string(array, "com.apple.Contacts");
- switch_node = plist_find_node_by_string(array, "SDMessageDeviceReadyToReceiveChanges");
- }
-
- array = plist_new_array();
- plist_add_sub_string_el(array, "DLMessagePing");
- plist_add_sub_string_el(array, "Preparing to get changes for device");
-
- ret = iphone_msync_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_t dict = plist_new_dict();
- plist_add_sub_node(array, dict);
- plist_add_sub_key_el(dict, "SyncDeviceLinkEntityNamesKey");
- 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);
-
- ret = iphone_msync_send(client, array);
- plist_free(array);
- array = NULL;
-
- ret = iphone_msync_recv(client, &array);
- plist_free(array);
- array = NULL;
-
-
- return ret;
-}
diff --git a/src/MobileSync.h b/src/MobileSync.h
index 495e702..5279ce0 100644
--- a/src/MobileSync.h
+++ b/src/MobileSync.h
@@ -23,16 +23,12 @@
#include "iphone.h"
#include "utils.h"
+#include "libiphone/mobilesync.h"
#include <plist/plist.h>
-
-
-struct iphone_msync_client_int {
+struct mobilesync_client_int {
int sfd;
};
-
-iphone_error_t iphone_msync_get_all_contacts(iphone_msync_client_t client);
-
#endif