summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Aaron Burghardt2014-03-27 10:07:09 -0400
committerGravatar Aaron Burghardt2014-03-27 21:40:43 -0400
commit2342dc5b4ef148b993fbe3816f3facdef8365546 (patch)
tree69f812d91b2fc07db0fad5dcba6c80d2f8b6849e /src
parentee82e861a8c942b5013accd7589cf898d1f97167 (diff)
downloadlibimobiledevice-2342dc5b4ef148b993fbe3816f3facdef8365546.tar.gz
libimobiledevice-2342dc5b4ef148b993fbe3816f3facdef8365546.tar.bz2
Moved Doxygen comments from source files to public headers.
Conflicts: include/libimobiledevice/afc.h
Diffstat (limited to 'src')
-rw-r--r--src/afc.c212
-rw-r--r--src/diagnostics_relay.c86
-rw-r--r--src/file_relay.c98
-rw-r--r--src/heartbeat.c67
-rw-r--r--src/house_arrest.c107
-rw-r--r--src/idevice.c132
-rw-r--r--src/installation_proxy.c232
-rw-r--r--src/lockdown.c279
-rw-r--r--src/misagent.c75
-rw-r--r--src/mobile_image_mounter.c93
-rw-r--r--src/mobilebackup.c157
-rw-r--r--src/mobilebackup2.c134
-rw-r--r--src/mobilesync.c228
-rw-r--r--src/notification_proxy.c83
-rw-r--r--src/restore.c101
-rw-r--r--src/sbservices.c94
-rw-r--r--src/screenshotr.c51
-rw-r--r--src/service.c97
-rw-r--r--src/syslog_relay.c87
-rw-r--r--src/webinspector.c67
20 files changed, 2 insertions, 2478 deletions
diff --git a/src/afc.c b/src/afc.c
index dd75558..b5203f1 100644
--- a/src/afc.c
+++ b/src/afc.c
@@ -95,18 +95,6 @@ afc_error_t afc_client_new_with_service_client(service_client_t service_client,
95 return AFC_E_SUCCESS; 95 return AFC_E_SUCCESS;
96} 96}
97 97
98/**
99 * Makes a connection to the AFC service on the device.
100 *
101 * @param device The device to connect to.
102 * @param service The service descriptor returned by lockdownd_start_service.
103 * @param client Pointer that will be set to a newly allocated afc_client_t
104 * upon successful return.
105 *
106 * @return AFC_E_SUCCESS on success, AFC_E_INVALID_ARG if device or service is
107 * invalid, AFC_E_MUX_ERROR if the connection cannot be established,
108 * or AFC_E_NO_MEM if there is a memory allocation problem.
109 */
110afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t * client) 98afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t * client)
111{ 99{
112 if (!device || !service || service->port == 0) 100 if (!device || !service || service->port == 0)
@@ -126,19 +114,6 @@ afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t serv
126 return err; 114 return err;
127} 115}
128 116
129/**
130 * Starts a new AFC service on the specified device and connects to it.
131 *
132 * @param device The device to connect to.
133 * @param client Pointer that will point to a newly allocated
134 * afc_client_t upon successful return. Must be freed using
135 * afc_client_free() after use.
136 * @param label The label to use for communication. Usually the program name.
137 * Pass NULL to disable sending the label in requests to lockdownd.
138 *
139 * @return AFC_E_SUCCESS on success, or an AFC_E_* error
140 * code otherwise.
141 */
142afc_error_t afc_client_start_service(idevice_t device, afc_client_t * client, const char* label) 117afc_error_t afc_client_start_service(idevice_t device, afc_client_t * client, const char* label)
143{ 118{
144 afc_error_t err = AFC_E_UNKNOWN_ERROR; 119 afc_error_t err = AFC_E_UNKNOWN_ERROR;
@@ -146,12 +121,6 @@ afc_error_t afc_client_start_service(idevice_t device, afc_client_t * client, co
146 return err; 121 return err;
147} 122}
148 123
149/**
150 * Frees up an AFC client. If the connection was created by the
151 * client itself, the connection will be closed.
152 *
153 * @param client The client to free.
154 */
155afc_error_t afc_client_free(afc_client_t client) 124afc_error_t afc_client_free(afc_client_t client)
156{ 125{
157 if (!client || !client->afc_packet) 126 if (!client || !client->afc_packet)
@@ -432,16 +401,6 @@ static char **make_strings_list(char *tokens, uint32_t length)
432 return list; 401 return list;
433} 402}
434 403
435/**
436 * Gets a directory listing of the directory requested.
437 *
438 * @param client The client to get a directory listing from.
439 * @param dir The directory to list. (must be a fully-qualified path)
440 * @param list A char list of files in that directory, terminated by an empty
441 * string or NULL if there was an error.
442 *
443 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
444 */
445afc_error_t afc_read_directory(afc_client_t client, const char *dir, char ***list) 404afc_error_t afc_read_directory(afc_client_t client, const char *dir, char ***list)
446{ 405{
447 uint32_t bytes = 0; 406 uint32_t bytes = 0;
@@ -478,17 +437,6 @@ afc_error_t afc_read_directory(afc_client_t client, const char *dir, char ***lis
478 return ret; 437 return ret;
479} 438}
480 439
481/**
482 * Get device information for a connected client. The device information
483 * returned is the device model as well as the free space, the total capacity
484 * and blocksize on the accessed disk partition.
485 *
486 * @param client The client to get device info for.
487 * @param infos A char ** list of parameters as given by AFC or NULL if there
488 * was an error.
489 *
490 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
491 */
492afc_error_t afc_get_device_info(afc_client_t client, char ***infos) 440afc_error_t afc_get_device_info(afc_client_t client, char ***infos)
493{ 441{
494 uint32_t bytes = 0; 442 uint32_t bytes = 0;
@@ -526,17 +474,6 @@ afc_error_t afc_get_device_info(afc_client_t client, char ***infos)
526 return ret; 474 return ret;
527} 475}
528 476
529/**
530 * Get a specific key of the device info list for a client connection.
531 * Known key values are: Model, FSTotalBytes, FSFreeBytes and FSBlockSize.
532 * This is a helper function for afc_get_device_info().
533 *
534 * @param client The client to get device info for.
535 * @param key The key to get the value of.
536 * @param value The value for the key if successful or NULL otherwise.
537 *
538 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
539 */
540afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char **value) 477afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char **value)
541{ 478{
542 afc_error_t ret = AFC_E_INTERNAL_ERROR; 479 afc_error_t ret = AFC_E_INTERNAL_ERROR;
@@ -564,14 +501,6 @@ afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char *
564 return ret; 501 return ret;
565} 502}
566 503
567/**
568 * Deletes a file or directory.
569 *
570 * @param client The client to use.
571 * @param path The path to delete. (must be a fully-qualified path)
572 *
573 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
574 */
575afc_error_t afc_remove_path(afc_client_t client, const char *path) 504afc_error_t afc_remove_path(afc_client_t client, const char *path)
576{ 505{
577 uint32_t bytes = 0; 506 uint32_t bytes = 0;
@@ -600,15 +529,6 @@ afc_error_t afc_remove_path(afc_client_t client, const char *path)
600 return ret; 529 return ret;
601} 530}
602 531
603/**
604 * Renames a file or directory on the device.
605 *
606 * @param client The client to have rename.
607 * @param from The name to rename from. (must be a fully-qualified path)
608 * @param to The new name. (must also be a fully-qualified path)
609 *
610 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
611 */
612afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to) 532afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to)
613{ 533{
614 char *buffer = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32_t))); 534 char *buffer = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32_t)));
@@ -638,15 +558,6 @@ afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *t
638 return ret; 558 return ret;
639} 559}
640 560
641/**
642 * Creates a directory on the device.
643 *
644 * @param client The client to use to make a directory.
645 * @param dir The directory's path. (must be a fully-qualified path, I assume
646 * all other mkdir restrictions apply as well)
647 *
648 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
649 */
650afc_error_t afc_make_directory(afc_client_t client, const char *dir) 561afc_error_t afc_make_directory(afc_client_t client, const char *dir)
651{ 562{
652 uint32_t bytes = 0; 563 uint32_t bytes = 0;
@@ -671,17 +582,6 @@ afc_error_t afc_make_directory(afc_client_t client, const char *dir)
671 return ret; 582 return ret;
672} 583}
673 584
674/**
675 * Gets information about a specific file.
676 *
677 * @param client The client to use to get the information of the file.
678 * @param path The fully-qualified path to the file.
679 * @param infolist Pointer to a buffer that will be filled with a NULL-terminated
680 * list of strings with the file information.
681 * Set to NULL before calling this function.
682 *
683 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
684 */
685afc_error_t afc_get_file_info(afc_client_t client, const char *path, char ***infolist) 585afc_error_t afc_get_file_info(afc_client_t client, const char *path, char ***infolist)
686{ 586{
687 char *received = NULL; 587 char *received = NULL;
@@ -712,19 +612,6 @@ afc_error_t afc_get_file_info(afc_client_t client, const char *path, char ***inf
712 return ret; 612 return ret;
713} 613}
714 614
715/**
716 * Opens a file on the device.
717 *
718 * @param client The client to use to open the file.
719 * @param filename The file to open. (must be a fully-qualified path)
720 * @param file_mode The mode to use to open the file. Can be AFC_FILE_READ or
721 * AFC_FILE_WRITE; the former lets you read and write,
722 * however, and the second one will *create* the file,
723 * destroying anything previously there.
724 * @param handle Pointer to a uint64_t that will hold the handle of the file
725 *
726 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
727 */
728idevice_error_t 615idevice_error_t
729afc_file_open(afc_client_t client, const char *filename, 616afc_file_open(afc_client_t client, const char *filename,
730 afc_file_mode_t file_mode, uint64_t *handle) 617 afc_file_mode_t file_mode, uint64_t *handle)
@@ -772,17 +659,6 @@ afc_file_open(afc_client_t client, const char *filename,
772 return ret; 659 return ret;
773} 660}
774 661
775/**
776 * Attempts to the read the given number of bytes from the given file.
777 *
778 * @param client The relevant AFC client
779 * @param handle File handle of a previously opened file
780 * @param data The pointer to the memory region to store the read data
781 * @param length The number of bytes to read
782 * @param bytes_read The number of bytes actually read.
783 *
784 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
785 */
786idevice_error_t 662idevice_error_t
787afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read) 663afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read)
788{ 664{
@@ -837,17 +713,6 @@ afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length,
837 return ret; 713 return ret;
838} 714}
839 715
840/**
841 * Writes a given number of bytes to a file.
842 *
843 * @param client The client to use to write to the file.
844 * @param handle File handle of previously opened file.
845 * @param data The data to write to the file.
846 * @param length How much data to write.
847 * @param bytes_written The number of bytes actually written to the file.
848 *
849 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
850 */
851idevice_error_t 716idevice_error_t
852afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written) 717afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written)
853{ 718{
@@ -881,12 +746,6 @@ afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t
881 return ret; 746 return ret;
882} 747}
883 748
884/**
885 * Closes a file on the device.
886 *
887 * @param client The client to close the file with.
888 * @param handle File handle of a previously opened file.
889 */
890afc_error_t afc_file_close(afc_client_t client, uint64_t handle) 749afc_error_t afc_file_close(afc_client_t client, uint64_t handle)
891{ 750{
892 uint32_t bytes = 0; 751 uint32_t bytes = 0;
@@ -915,18 +774,6 @@ afc_error_t afc_file_close(afc_client_t client, uint64_t handle)
915 return ret; 774 return ret;
916} 775}
917 776
918/**
919 * Locks or unlocks a file on the device.
920 *
921 * makes use of flock on the device, see
922 * http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/flock.2.html
923 *
924 * @param client The client to lock the file with.
925 * @param handle File handle of a previously opened file.
926 * @param operation the lock or unlock operation to perform, this is one of
927 * AFC_LOCK_SH (shared lock), AFC_LOCK_EX (exclusive lock),
928 * or AFC_LOCK_UN (unlock).
929 */
930afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation) 777afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation)
931{ 778{
932 uint32_t bytes = 0; 779 uint32_t bytes = 0;
@@ -961,16 +808,6 @@ afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t op
961 return ret; 808 return ret;
962} 809}
963 810
964/**
965 * Seeks to a given position of a pre-opened file on the device.
966 *
967 * @param client The client to use to seek to the position.
968 * @param handle File handle of a previously opened.
969 * @param offset Seek offset.
970 * @param whence Seeking direction, one of SEEK_SET, SEEK_CUR, or SEEK_END.
971 *
972 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
973 */
974afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence) 811afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence)
975{ 812{
976 uint32_t bytes = 0; 813 uint32_t bytes = 0;
@@ -1004,15 +841,6 @@ afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset,
1004 return ret; 841 return ret;
1005} 842}
1006 843
1007/**
1008 * Returns current position in a pre-opened file on the device.
1009 *
1010 * @param client The client to use.
1011 * @param handle File handle of a previously opened file.
1012 * @param position Position in bytes of indicator
1013 *
1014 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
1015 */
1016afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position) 844afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position)
1017{ 845{
1018 char *buffer = (char *) malloc(sizeof(char) * 8); 846 char *buffer = (char *) malloc(sizeof(char) * 8);
@@ -1047,18 +875,6 @@ afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *positi
1047 return ret; 875 return ret;
1048} 876}
1049 877
1050/**
1051 * Sets the size of a file on the device.
1052 *
1053 * @param client The client to use to set the file size.
1054 * @param handle File handle of a previously opened file.
1055 * @param newsize The size to set the file to.
1056 *
1057 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
1058 *
1059 * @note This function is more akin to ftruncate than truncate, and truncate
1060 * calls would have to open the file before calling this, sadly.
1061 */
1062afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize) 878afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize)
1063{ 879{
1064 uint32_t bytes = 0; 880 uint32_t bytes = 0;
@@ -1090,15 +906,6 @@ afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t new
1090 return ret; 906 return ret;
1091} 907}
1092 908
1093/**
1094 * Sets the size of a file on the device without prior opening it.
1095 *
1096 * @param client The client to use to set the file size.
1097 * @param path The path of the file to be truncated.
1098 * @param newsize The size to set the file to.
1099 *
1100 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
1101 */
1102afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize) 909afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize)
1103{ 910{
1104 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); 911 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8));
@@ -1129,16 +936,6 @@ afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize
1129 return ret; 936 return ret;
1130} 937}
1131 938
1132/**
1133 * Creates a hard link or symbolic link on the device.
1134 *
1135 * @param client The client to use for making a link
1136 * @param linktype 1 = hard link, 2 = symlink
1137 * @param target The file to be linked.
1138 * @param linkname The name of link.
1139 *
1140 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
1141 */
1142afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname) 939afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname)
1143{ 940{
1144 char *buffer = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8)); 941 char *buffer = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8));
@@ -1173,15 +970,6 @@ afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const c
1173 return ret; 970 return ret;
1174} 971}
1175 972
1176/**
1177 * Sets the modification time of a file on the device.
1178 *
1179 * @param client The client to use to set the file size.
1180 * @param path Path of the file for which the modification time should be set.
1181 * @param mtime The modification time to set in nanoseconds since epoch.
1182 *
1183 * @return AFC_E_SUCCESS on success or an AFC_E_* error value.
1184 */
1185afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime) 973afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime)
1186{ 974{
1187 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); 975 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8));
diff --git a/src/diagnostics_relay.c b/src/diagnostics_relay.c
index de3781c..cc9c645 100644
--- a/src/diagnostics_relay.c
+++ b/src/diagnostics_relay.c
@@ -69,18 +69,6 @@ static int diagnostics_relay_check_result(plist_t dict)
69 return ret; 69 return ret;
70} 70}
71 71
72/**
73 * Connects to the diagnostics_relay service on the specified device.
74 *
75 * @param device The device to connect to.
76 * @param service The service descriptor returned by lockdownd_start_service.
77 * @param client Reference that will point to a newly allocated
78 * diagnostics_relay_client_t upon successful return.
79 *
80 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
81 * DIAGNOSTICS_RELAY_E_INVALID_ARG when one of the parameters is invalid,
82 * or DIAGNOSTICS_RELAY_E_MUX_ERROR when the connection failed.
83 */
84diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client) 72diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client)
85{ 73{
86 if (!device || !service || service->port == 0 || !client || *client) { 74 if (!device || !service || service->port == 0 || !client || *client) {
@@ -101,19 +89,6 @@ diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdow
101 return DIAGNOSTICS_RELAY_E_SUCCESS; 89 return DIAGNOSTICS_RELAY_E_SUCCESS;
102} 90}
103 91
104/**
105 * Starts a new diagnostics_relay service on the specified device and connects to it.
106 *
107 * @param device The device to connect to.
108 * @param client Pointer that will point to a newly allocated
109 * diagnostics_relay_client_t upon successful return. Must be freed using
110 * diagnostics_relay_client_free() after use.
111 * @param label The label to use for communication. Usually the program name.
112 * Pass NULL to disable sending the label in requests to lockdownd.
113 *
114 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success, or an DIAGNOSTICS_RELAY_E_* error
115 * code otherwise.
116 */
117diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t device, diagnostics_relay_client_t * client, const char* label) 92diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t device, diagnostics_relay_client_t * client, const char* label)
118{ 93{
119 diagnostics_relay_error_t err = DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR; 94 diagnostics_relay_error_t err = DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR;
@@ -121,17 +96,6 @@ diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t devic
121 return err; 96 return err;
122} 97}
123 98
124/**
125 * Disconnects a diagnostics_relay client from the device and frees up the
126 * diagnostics_relay client data.
127 *
128 * @param client The diagnostics_relay client to disconnect and free.
129 *
130 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
131 * DIAGNOSTICS_RELAY_E_INVALID_ARG when one of client or client->parent
132 * is invalid, or DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR when the was an
133 * error freeing the parent property_list_service client.
134 */
135diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client_t client) 99diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client_t client)
136{ 100{
137 if (!client) 101 if (!client)
@@ -198,16 +162,6 @@ static diagnostics_relay_error_t diagnostics_relay_send(diagnostics_relay_client
198 return ret; 162 return ret;
199} 163}
200 164
201/**
202 * Sends the Goodbye request signaling the end of communication.
203 *
204 * @param client The diagnostics_relay client
205 *
206 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
207 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
208 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
209 * request
210 */
211diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client) 165diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client)
212{ 166{
213 if (!client) 167 if (!client)
@@ -242,16 +196,6 @@ diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t c
242 return ret; 196 return ret;
243} 197}
244 198
245/**
246 * Puts the device into deep sleep mode and disconnects from host.
247 *
248 * @param client The diagnostics_relay client
249 *
250 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
251 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
252 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
253 * request
254 */
255diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client) 199diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client)
256{ 200{
257 if (!client) 201 if (!client)
@@ -328,41 +272,11 @@ static diagnostics_relay_error_t internal_diagnostics_relay_action(diagnostics_r
328 return ret; 272 return ret;
329} 273}
330 274
331/**
332 * Restart the device and optionally show a user notification.
333 *
334 * @param client The diagnostics_relay client
335 * @param flags A binary flag combination of
336 * DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT to wait until
337 * diagnostics_relay_client_free() disconnects before execution and
338 * DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL to show a "FAIL" dialog
339 * or DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS to show an "OK" dialog
340 *
341 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
342 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
343 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
344 * request
345 */
346diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, int flags) 275diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, int flags)
347{ 276{
348 return internal_diagnostics_relay_action(client, "Restart", flags); 277 return internal_diagnostics_relay_action(client, "Restart", flags);
349} 278}
350 279
351/**
352 * Shutdown of the device and optionally show a user notification.
353 *
354 * @param client The diagnostics_relay client
355 * @param flags A binary flag combination of
356 * DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT to wait until
357 * diagnostics_relay_client_free() disconnects before execution and
358 * DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL to show a "FAIL" dialog
359 * or DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS to show an "OK" dialog
360 *
361 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
362 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
363 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
364 * request
365 */
366diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, int flags) 280diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, int flags)
367{ 281{
368 return internal_diagnostics_relay_action(client, "Shutdown", flags); 282 return internal_diagnostics_relay_action(client, "Shutdown", flags);
diff --git a/src/file_relay.c b/src/file_relay.c
index fb802a8..3d1eb12 100644
--- a/src/file_relay.c
+++ b/src/file_relay.c
@@ -24,18 +24,6 @@
24#include "property_list_service.h" 24#include "property_list_service.h"
25#include "common/debug.h" 25#include "common/debug.h"
26 26
27/**
28 * Connects to the file_relay service on the specified device.
29 *
30 * @param device The device to connect to.
31 * @param service The service descriptor returned by lockdownd_start_service.
32 * @param client Reference that will point to a newly allocated
33 * file_relay_client_t upon successful return.
34 *
35 * @return FILE_RELAY_E_SUCCESS on success,
36 * FILE_RELAY_E_INVALID_ARG when one of the parameters is invalid,
37 * or FILE_RELAY_E_MUX_ERROR when the connection failed.
38 */
39file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client) 27file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client)
40{ 28{
41 if (!device || !service || service->port == 0 || !client || *client) { 29 if (!device || !service || service->port == 0 || !client || *client) {
@@ -56,19 +44,6 @@ file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_des
56 return FILE_RELAY_E_SUCCESS; 44 return FILE_RELAY_E_SUCCESS;
57} 45}
58 46
59/**
60 * Starts a new file_relay service on the specified device and connects to it.
61 *
62 * @param device The device to connect to.
63 * @param client Pointer that will point to a newly allocated
64 * file_relay_client_t upon successful return. Must be freed using
65 * file_relay_client_free() after use.
66 * @param label The label to use for communication. Usually the program name.
67 * Pass NULL to disable sending the label in requests to lockdownd.
68 *
69 * @return FILE_RELAY_E_SUCCESS on success, or an FILE_RELAY_E_* error
70 * code otherwise.
71 */
72file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_client_t * client, const char* label) 47file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_client_t * client, const char* label)
73{ 48{
74 file_relay_error_t err = FILE_RELAY_E_UNKNOWN_ERROR; 49 file_relay_error_t err = FILE_RELAY_E_UNKNOWN_ERROR;
@@ -76,17 +51,6 @@ file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_
76 return err; 51 return err;
77} 52}
78 53
79/**
80 * Disconnects a file_relay client from the device and frees up the file_relay
81 * client data.
82 *
83 * @param client The file_relay client to disconnect and free.
84 *
85 * @return FILE_RELAY_E_SUCCESS on success,
86 * FILE_RELAY_E_INVALID_ARG when one of client or client->parent
87 * is invalid, or FILE_RELAY_E_UNKNOWN_ERROR when the was an error
88 * freeing the parent property_list_service client.
89 */
90file_relay_error_t file_relay_client_free(file_relay_client_t client) 54file_relay_error_t file_relay_client_free(file_relay_client_t client)
91{ 55{
92 if (!client) 56 if (!client)
@@ -98,37 +62,6 @@ file_relay_error_t file_relay_client_free(file_relay_client_t client)
98 return FILE_RELAY_E_SUCCESS; 62 return FILE_RELAY_E_SUCCESS;
99} 63}
100 64
101/**
102 * Request data for the given sources.
103 *
104 * @param client The connected file_relay client.
105 * @param sources A NULL-terminated list of sources to retrieve.
106 * Valid sources are:
107 * - AppleSupport
108 * - Network
109 * - VPN
110 * - WiFi
111 * - UserDatabases
112 * - CrashReporter
113 * - tmp
114 * - SystemConfiguration
115 * @param connection The connection that has to be used for receiving the
116 * data using idevice_connection_receive(). The connection will be closed
117 * automatically by the device, but use file_relay_client_free() to clean
118 * up properly.
119 * @param timeout Maximum time in milliseconds to wait for data.
120 *
121 * @note WARNING: Don't call this function without reading the data afterwards.
122 * A directory mobile_file_relay.XXXX used for creating the archive will
123 * remain in the /tmp directory otherwise.
124 *
125 * @return FILE_RELAY_E_SUCCESS on succes, FILE_RELAY_E_INVALID_ARG when one or
126 * more parameters are invalid, FILE_RELAY_E_MUX_ERROR if a communication
127 * error occurs, FILE_RELAY_E_PLIST_ERROR when the received result is NULL
128 * or is not a valid plist, FILE_RELAY_E_INVALID_SOURCE if one or more
129 * sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available
130 * for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise.
131 */
132file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout) 65file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout)
133{ 66{
134 if (!client || !client->parent || !sources || !sources[0]) { 67 if (!client || !client->parent || !sources || !sources[0]) {
@@ -218,37 +151,6 @@ leave:
218 return err; 151 return err;
219} 152}
220 153
221/**
222 * Request data for the given sources. Calls file_relay_request_sources_timeout() with
223 * a timeout of 60000 milliseconds (60 seconds).
224 *
225 * @param client The connected file_relay client.
226 * @param sources A NULL-terminated list of sources to retrieve.
227 * Valid sources are:
228 * - AppleSupport
229 * - Network
230 * - VPN
231 * - WiFi
232 * - UserDatabases
233 * - CrashReporter
234 * - tmp
235 * - SystemConfiguration
236 * @param connection The connection that has to be used for receiving the
237 * data using idevice_connection_receive(). The connection will be closed
238 * automatically by the device, but use file_relay_client_free() to clean
239 * up properly.
240 *
241 * @note WARNING: Don't call this function without reading the data afterwards.
242 * A directory mobile_file_relay.XXXX used for creating the archive will
243 * remain in the /tmp directory otherwise.
244 *
245 * @return FILE_RELAY_E_SUCCESS on succes, FILE_RELAY_E_INVALID_ARG when one or
246 * more parameters are invalid, FILE_RELAY_E_MUX_ERROR if a communication
247 * error occurs, FILE_RELAY_E_PLIST_ERROR when the received result is NULL
248 * or is not a valid plist, FILE_RELAY_E_INVALID_SOURCE if one or more
249 * sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available
250 * for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise.
251 */
252file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection) 154file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection)
253{ 155{
254 return file_relay_request_sources_timeout(client, sources, connection, 60000); 156 return file_relay_request_sources_timeout(client, sources, connection, 60000);
diff --git a/src/heartbeat.c b/src/heartbeat.c
index e03b44e..7654dd0 100644
--- a/src/heartbeat.c
+++ b/src/heartbeat.c
@@ -58,18 +58,6 @@ static heartbeat_error_t heartbeat_error(property_list_service_error_t err)
58 return HEARTBEAT_E_UNKNOWN_ERROR; 58 return HEARTBEAT_E_UNKNOWN_ERROR;
59} 59}
60 60
61/**
62 * Connects to the heartbeat service on the specified device.
63 *
64 * @param device The device to connect to.
65 * @param service The service descriptor returned by lockdownd_start_service.
66 * @param client Pointer that will point to a newly allocated
67 * heartbeat_client_t upon successful return. Must be freed using
68 * heartbeat_client_free() after use.
69 *
70 * @return HEARTBEAT_E_SUCCESS on success, HEARTBEAT_E_INVALID_ARG when
71 * client is NULL, or an HEARTBEAT_E_* error code otherwise.
72 */
73heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descriptor_t service, heartbeat_client_t * client) 61heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descriptor_t service, heartbeat_client_t * client)
74{ 62{
75 *client = NULL; 63 *client = NULL;
@@ -97,19 +85,6 @@ heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descr
97 return 0; 85 return 0;
98} 86}
99 87
100/**
101 * Starts a new heartbeat service on the specified device and connects to it.
102 *
103 * @param device The device to connect to.
104 * @param client Pointer that will point to a newly allocated
105 * heartbeat_client_t upon successful return. Must be freed using
106 * heartbeat_client_free() after use.
107 * @param label The label to use for communication. Usually the program name.
108 * Pass NULL to disable sending the label in requests to lockdownd.
109 *
110 * @return HEARTBEAT_E_SUCCESS on success, or an HEARTBEAT_E_* error
111 * code otherwise.
112 */
113heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_client_t * client, const char* label) 88heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_client_t * client, const char* label)
114{ 89{
115 heartbeat_error_t err = HEARTBEAT_E_UNKNOWN_ERROR; 90 heartbeat_error_t err = HEARTBEAT_E_UNKNOWN_ERROR;
@@ -117,15 +92,6 @@ heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_cli
117 return err; 92 return err;
118} 93}
119 94
120/**
121 * Disconnects a heartbeat client from the device and frees up the
122 * heartbeat client data.
123 *
124 * @param client The heartbeat client to disconnect and free.
125 *
126 * @return HEARTBEAT_E_SUCCESS on success, HEARTBEAT_E_INVALID_ARG when
127 * client is NULL, or an HEARTBEAT_E_* error code otherwise.
128 */
129heartbeat_error_t heartbeat_client_free(heartbeat_client_t client) 95heartbeat_error_t heartbeat_client_free(heartbeat_client_t client)
130{ 96{
131 if (!client) 97 if (!client)
@@ -137,15 +103,6 @@ heartbeat_error_t heartbeat_client_free(heartbeat_client_t client)
137 return err; 103 return err;
138} 104}
139 105
140/**
141 * Sends a plist to the service.
142 *
143 * @param client The heartbeat client
144 * @param plist The plist to send
145 *
146 * @return HEARTBEAT_E_SUCCESS on success,
147 * HEARTBEAT_E_INVALID_ARG when client or plist is NULL
148 */
149heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist) 106heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist)
150{ 107{
151 heartbeat_error_t res = HEARTBEAT_E_UNKNOWN_ERROR; 108 heartbeat_error_t res = HEARTBEAT_E_UNKNOWN_ERROR;
@@ -161,35 +118,11 @@ heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist)
161 return res; 118 return res;
162} 119}
163 120
164/**
165 * Receives a plist from the service.
166 *
167 * @param client The heartbeat client
168 * @param plist The plist to store the received data
169 *
170 * @return HEARTBEAT_E_SUCCESS on success,
171 * HEARTBEAT_E_INVALID_ARG when client or plist is NULL
172 */
173heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist) 121heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist)
174{ 122{
175 return heartbeat_receive_with_timeout(client, plist, 1000); 123 return heartbeat_receive_with_timeout(client, plist, 1000);
176} 124}
177 125
178/**
179 * Receives a plist using the given heartbeat client.
180 *
181 * @param client The heartbeat client to use for receiving
182 * @param plist pointer to a plist_t that will point to the received plist
183 * upon successful return
184 * @param timeout Maximum time in milliseconds to wait for data.
185 *
186 * @return HEARTBEAT_E_SUCCESS on success,
187 * HEARTBEAT_E_INVALID_ARG when client or *plist is NULL,
188 * HEARTBEAT_E_PLIST_ERROR when the received data cannot be
189 * converted to a plist, HEARTBEAT_E_MUX_ERROR when a
190 * communication error occurs, or HEARTBEAT_E_UNKNOWN_ERROR
191 * when an unspecified error occurs.
192 */
193heartbeat_error_t heartbeat_receive_with_timeout(heartbeat_client_t client, plist_t * plist, uint32_t timeout_ms) 126heartbeat_error_t heartbeat_receive_with_timeout(heartbeat_client_t client, plist_t * plist, uint32_t timeout_ms)
194{ 127{
195 heartbeat_error_t res = HEARTBEAT_E_UNKNOWN_ERROR; 128 heartbeat_error_t res = HEARTBEAT_E_UNKNOWN_ERROR;
diff --git a/src/house_arrest.c b/src/house_arrest.c
index 9aaad34..4158368 100644
--- a/src/house_arrest.c
+++ b/src/house_arrest.c
@@ -55,17 +55,6 @@ static house_arrest_error_t house_arrest_error(property_list_service_error_t err
55 return HOUSE_ARREST_E_UNKNOWN_ERROR; 55 return HOUSE_ARREST_E_UNKNOWN_ERROR;
56} 56}
57 57
58/**
59 * Connects to the house_arrest service on the specified device.
60 *
61 * @param device The device to connect to.
62 * @param service The service descriptor returned by lockdownd_start_service.
63 * @param client Pointer that will point to a newly allocated
64 * housearrest_client_t upon successful return.
65 *
66 * @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when
67 * client is NULL, or an HOUSE_ARREST_E_* error code otherwise.
68 */
69house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client) 58house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client)
70{ 59{
71 property_list_service_client_t plistclient = NULL; 60 property_list_service_client_t plistclient = NULL;
@@ -82,19 +71,6 @@ house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service
82 return HOUSE_ARREST_E_SUCCESS; 71 return HOUSE_ARREST_E_SUCCESS;
83} 72}
84 73
85/**
86 * Starts a new house_arrest service on the specified device and connects to it.
87 *
88 * @param device The device to connect to.
89 * @param client Pointer that will point to a newly allocated
90 * house_arrest_client_t upon successful return. Must be freed using
91 * house_arrest_client_free() after use.
92 * @param label The label to use for communication. Usually the program name.
93 * Pass NULL to disable sending the label in requests to lockdownd.
94 *
95 * @return HOUSE_ARREST_E_SUCCESS on success, or an HOUSE_ARREST_E_* error
96 * code otherwise.
97 */
98house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_arrest_client_t * client, const char* label) 74house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_arrest_client_t * client, const char* label)
99{ 75{
100 house_arrest_error_t err = HOUSE_ARREST_E_UNKNOWN_ERROR; 76 house_arrest_error_t err = HOUSE_ARREST_E_UNKNOWN_ERROR;
@@ -102,20 +78,6 @@ house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_a
102 return err; 78 return err;
103} 79}
104 80
105/**
106 * Disconnects an house_arrest client from the device and frees up the
107 * house_arrest client data.
108 *
109 * @note After using afc_client_new_from_house_arrest_client(), make sure
110 * you call afc_client_free() before calling this function to ensure
111 * a proper cleanup. Do not call this function if you still need to
112 * perform AFC operations since it will close the connection.
113 *
114 * @param client The house_arrest client to disconnect and free.
115 *
116 * @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when
117 * client is NULL, or an HOUSE_ARREST_E_* error code otherwise.
118 */
119house_arrest_error_t house_arrest_client_free(house_arrest_client_t client) 81house_arrest_error_t house_arrest_client_free(house_arrest_client_t client)
120{ 82{
121 if (!client) 83 if (!client)
@@ -131,23 +93,6 @@ house_arrest_error_t house_arrest_client_free(house_arrest_client_t client)
131 return err; 93 return err;
132} 94}
133 95
134/**
135 * Sends a generic request to the connected house_arrest service.
136 *
137 * @param client The house_arrest client to use.
138 * @param dict The request to send as a plist of type PLIST_DICT.
139 *
140 * @note If this function returns HOUSE_ARREST_E_SUCCESS it does not mean
141 * that the request was successful. To check for success or failure you
142 * need to call house_arrest_get_result().
143 * @see house_arrest_get_result
144 *
145 * @return HOUSE_ARREST_E_SUCCESS if the request was successfully sent,
146 * HOUSE_ARREST_E_INVALID_ARG if client or dict is invalid,
147 * HOUSE_ARREST_E_PLIST_ERROR if dict is not a plist of type PLIST_DICT,
148 * HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode,
149 * or HOUSE_ARREST_E_CONN_FAILED if a connection error occured.
150 */
151house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist_t dict) 96house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist_t dict)
152{ 97{
153 if (!client || !client->parent || !dict) 98 if (!client || !client->parent || !dict)
@@ -164,25 +109,6 @@ house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, pli
164 return res; 109 return res;
165} 110}
166 111
167/**
168 * Send a command to the connected house_arrest service.
169 * Calls house_arrest_send_request() internally.
170 *
171 * @param client The house_arrest client to use.
172 * @param command The command to send. Currently, only VendContainer and
173 * VendDocuments are known.
174 * @param appid The application identifier to pass along with the .
175 *
176 * @note If this function returns HOUSE_ARREST_E_SUCCESS it does not mean
177 * that the command was successful. To check for success or failure you
178 * need to call house_arrest_get_result().
179 * @see house_arrest_get_result
180 *
181 * @return HOUSE_ARREST_E_SUCCESS if the command was successfully sent,
182 * HOUSE_ARREST_E_INVALID_ARG if client, command, or appid is invalid,
183 * HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode,
184 * or HOUSE_ARREST_E_CONN_FAILED if a connection error occured.
185 */
186house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, const char *command, const char *appid) 112house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, const char *command, const char *appid)
187{ 113{
188 if (!client || !client->parent || !command || !appid) 114 if (!client || !client->parent || !command || !appid)
@@ -203,20 +129,6 @@ house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, con
203 return res; 129 return res;
204} 130}
205 131
206/**
207 * Retrieves the result of a previously sent house_arrest_request_* request.
208 *
209 * @param client The house_arrest client to use
210 * @param dict Pointer that will be set to a plist containing the result to
211 * the last performed operation. It holds a key 'Status' with the value
212 * 'Complete' on success or a key 'Error' with an error description as
213 * value. The caller is responsible for freeing the returned plist.
214 *
215 * @return HOUSE_ARREST_E_SUCCESS if a result plist was retrieved,
216 * HOUSE_ARREST_E_INVALID_ARG if client is invalid,
217 * HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode,
218 * or HOUSE_ARREST_E_CONN_FAILED if a connection error occured.
219 */
220house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist_t *dict) 132house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist_t *dict)
221{ 133{
222 if (!client || !client->parent) 134 if (!client || !client->parent)
@@ -235,25 +147,6 @@ house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist
235 return res; 147 return res;
236} 148}
237 149
238/**
239 * Creates an AFC client using the given house_arrest client's connection
240 * allowing file access to a specific application directory requested by
241 * functions like house_arrest_request_vendor_documents().
242 *
243 * @param client The house_arrest client to use.
244 * @param afc_client Pointer that will be set to a newly allocated afc_client_t
245 * upon successful return.
246 *
247 * @note After calling this function the house_arrest client will go in an
248 * AFC mode that will only allow calling house_arrest_client_free().
249 * Only call house_arrest_client_free() if all AFC operations have
250 * completed since it will close the connection.
251 *
252 * @return AFC_E_SUCCESS if the afc client was successfully created,
253 * AFC_E_INVALID_ARG if client is invalid or was already used to create
254 * an afc client, or an AFC_E_* error code returned by
255 * afc_client_new_with_service_client().
256 */
257afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client) 150afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client)
258{ 151{
259 if (!client || !client->parent || (client->mode == HOUSE_ARREST_CLIENT_MODE_AFC)) { 152 if (!client || !client->parent || (client->mode == HOUSE_ARREST_CLIENT_MODE_AFC)) {
diff --git a/src/idevice.c b/src/idevice.c
index 0577815..eed02fc 100644
--- a/src/idevice.c
+++ b/src/idevice.c
@@ -142,16 +142,6 @@ static void usbmux_event_cb(const usbmuxd_event_t *event, void *user_data)
142 } 142 }
143} 143}
144 144
145/**
146 * Register a callback function that will be called when device add/remove
147 * events occur.
148 *
149 * @param callback Callback function to call.
150 * @param user_data Application-specific data passed as parameter
151 * to the registered callback function.
152 *
153 * @return IDEVICE_E_SUCCESS on success or an error value when an error occured.
154 */
155idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data) 145idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data)
156{ 146{
157 event_cb = callback; 147 event_cb = callback;
@@ -164,12 +154,6 @@ idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_
164 return IDEVICE_E_SUCCESS; 154 return IDEVICE_E_SUCCESS;
165} 155}
166 156
167/**
168 * Release the event callback function that has been registered with
169 * idevice_event_subscribe().
170 *
171 * @return IDEVICE_E_SUCCESS on success or an error value when an error occured.
172 */
173idevice_error_t idevice_event_unsubscribe() 157idevice_error_t idevice_event_unsubscribe()
174{ 158{
175 event_cb = NULL; 159 event_cb = NULL;
@@ -181,15 +165,6 @@ idevice_error_t idevice_event_unsubscribe()
181 return IDEVICE_E_SUCCESS; 165 return IDEVICE_E_SUCCESS;
182} 166}
183 167
184/**
185 * Get a list of currently available devices.
186 *
187 * @param devices List of udids of devices that are currently available.
188 * This list is terminated by a NULL pointer.
189 * @param count Number of devices found.
190 *
191 * @return IDEVICE_E_SUCCESS on success or an error value when an error occured.
192 */
193idevice_error_t idevice_get_device_list(char ***devices, int *count) 168idevice_error_t idevice_get_device_list(char ***devices, int *count)
194{ 169{
195 usbmuxd_device_info_t *dev_list; 170 usbmuxd_device_info_t *dev_list;
@@ -220,13 +195,6 @@ idevice_error_t idevice_get_device_list(char ***devices, int *count)
220 return IDEVICE_E_SUCCESS; 195 return IDEVICE_E_SUCCESS;
221} 196}
222 197
223/**
224 * Free a list of device udids.
225 *
226 * @param devices List of udids to free.
227 *
228 * @return Always returnes IDEVICE_E_SUCCESS.
229 */
230idevice_error_t idevice_device_list_free(char **devices) 198idevice_error_t idevice_device_list_free(char **devices)
231{ 199{
232 if (devices) { 200 if (devices) {
@@ -240,19 +208,6 @@ idevice_error_t idevice_device_list_free(char **devices)
240 return IDEVICE_E_SUCCESS; 208 return IDEVICE_E_SUCCESS;
241} 209}
242 210
243/**
244 * Creates an idevice_t structure for the device specified by udid,
245 * if the device is available.
246 *
247 * @note The resulting idevice_t structure has to be freed with
248 * idevice_free() if it is no longer used.
249 *
250 * @param device Upon calling this function, a pointer to a location of type
251 * idevice_t. On successful return, this location will be populated.
252 * @param udid The UDID to match.
253 *
254 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
255 */
256idevice_error_t idevice_new(idevice_t * device, const char *udid) 211idevice_error_t idevice_new(idevice_t * device, const char *udid)
257{ 212{
258 usbmuxd_device_info_t muxdev; 213 usbmuxd_device_info_t muxdev;
@@ -270,13 +225,6 @@ idevice_error_t idevice_new(idevice_t * device, const char *udid)
270 return IDEVICE_E_NO_DEVICE; 225 return IDEVICE_E_NO_DEVICE;
271} 226}
272 227
273/**
274 * Cleans up an idevice structure, then frees the structure itself.
275 * This is a library-level function; deals directly with the device to tear
276 * down relations, but otherwise is mostly internal.
277 *
278 * @param device idevice_t to free.
279 */
280idevice_error_t idevice_free(idevice_t device) 228idevice_error_t idevice_free(idevice_t device)
281{ 229{
282 if (!device) 230 if (!device)
@@ -297,16 +245,6 @@ idevice_error_t idevice_free(idevice_t device)
297 return ret; 245 return ret;
298} 246}
299 247
300/**
301 * Set up a connection to the given device.
302 *
303 * @param device The device to connect to.
304 * @param port The destination port to connect to.
305 * @param connection Pointer to an idevice_connection_t that will be filled
306 * with the necessary data of the connection.
307 *
308 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
309 */
310idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection) 248idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection)
311{ 249{
312 if (!device) { 250 if (!device) {
@@ -333,13 +271,6 @@ idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connect
333 return IDEVICE_E_UNKNOWN_ERROR; 271 return IDEVICE_E_UNKNOWN_ERROR;
334} 272}
335 273
336/**
337 * Disconnect from the device and clean up the connection structure.
338 *
339 * @param connection The connection to close.
340 *
341 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
342 */
343idevice_error_t idevice_disconnect(idevice_connection_t connection) 274idevice_error_t idevice_disconnect(idevice_connection_t connection)
344{ 275{
345 if (!connection) { 276 if (!connection) {
@@ -390,17 +321,6 @@ static idevice_error_t internal_connection_send(idevice_connection_t connection,
390 321
391} 322}
392 323
393/**
394 * Send data to a device via the given connection.
395 *
396 * @param connection The connection to send data over.
397 * @param data Buffer with data to send.
398 * @param len Size of the buffer to send.
399 * @param sent_bytes Pointer to an uint32_t that will be filled
400 * with the number of bytes actually sent.
401 *
402 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
403 */
404idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes) 324idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes)
405{ 325{
406 if (!connection || !data || (connection->ssl_data && !connection->ssl_data->session)) { 326 if (!connection || !data || (connection->ssl_data && !connection->ssl_data->session)) {
@@ -447,21 +367,6 @@ static idevice_error_t internal_connection_receive_timeout(idevice_connection_t
447 return IDEVICE_E_UNKNOWN_ERROR; 367 return IDEVICE_E_UNKNOWN_ERROR;
448} 368}
449 369
450/**
451 * Receive data from a device via the given connection.
452 * This function will return after the given timeout even if no data has been
453 * received.
454 *
455 * @param connection The connection to receive data from.
456 * @param data Buffer that will be filled with the received data.
457 * This buffer has to be large enough to hold len bytes.
458 * @param len Buffer size or number of bytes to receive.
459 * @param recv_bytes Number of bytes actually received.
460 * @param timeout Timeout in milliseconds after which this function should
461 * return even if no data has been received.
462 *
463 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
464 */
465idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout) 370idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout)
466{ 371{
467 if (!connection || (connection->ssl_data && !connection->ssl_data->session)) { 372 if (!connection || (connection->ssl_data && !connection->ssl_data->session)) {
@@ -516,19 +421,6 @@ static idevice_error_t internal_connection_receive(idevice_connection_t connecti
516 return IDEVICE_E_UNKNOWN_ERROR; 421 return IDEVICE_E_UNKNOWN_ERROR;
517} 422}
518 423
519/**
520 * Receive data from a device via the given connection.
521 * This function is like idevice_connection_receive_timeout, but with a
522 * predefined reasonable timeout.
523 *
524 * @param connection The connection to receive data from.
525 * @param data Buffer that will be filled with the received data.
526 * This buffer has to be large enough to hold len bytes.
527 * @param len Buffer size or number of bytes to receive.
528 * @param recv_bytes Number of bytes actually received.
529 *
530 * @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
531 */
532idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes) 424idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes)
533{ 425{
534 if (!connection || (connection->ssl_data && !connection->ssl_data->session)) { 426 if (!connection || (connection->ssl_data && !connection->ssl_data->session)) {
@@ -552,9 +444,6 @@ idevice_error_t idevice_connection_receive(idevice_connection_t connection, char
552 return internal_connection_receive(connection, data, len, recv_bytes); 444 return internal_connection_receive(connection, data, len, recv_bytes);
553} 445}
554 446
555/**
556 * Gets the handle of the device. Depends on the connection type.
557 */
558idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle) 447idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle)
559{ 448{
560 if (!device) 449 if (!device)
@@ -569,9 +458,6 @@ idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle)
569 return IDEVICE_E_UNKNOWN_ERROR; 458 return IDEVICE_E_UNKNOWN_ERROR;
570} 459}
571 460
572/**
573 * Gets the unique id for the device.
574 */
575idevice_error_t idevice_get_udid(idevice_t device, char **udid) 461idevice_error_t idevice_get_udid(idevice_t device, char **udid)
576{ 462{
577 if (!device || !udid) 463 if (!device || !udid)
@@ -741,15 +627,6 @@ static int internal_cert_callback(gnutls_session_t session, const gnutls_datum_t
741} 627}
742#endif 628#endif
743 629
744/**
745 * Enables SSL for the given connection.
746 *
747 * @param connection The connection to enable SSL for.
748 *
749 * @return IDEVICE_E_SUCCESS on success, IDEVICE_E_INVALID_ARG when connection
750 * is NULL or connection->ssl_data is non-NULL, or IDEVICE_E_SSL_ERROR when
751 * SSL initialization, setup, or handshake fails.
752 */
753idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection) 630idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection)
754{ 631{
755 if (!connection || connection->ssl_data) 632 if (!connection || connection->ssl_data)
@@ -888,15 +765,6 @@ idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection)
888 return ret; 765 return ret;
889} 766}
890 767
891/**
892 * Disable SSL for the given connection.
893 *
894 * @param connection The connection to disable SSL for.
895 *
896 * @return IDEVICE_E_SUCCESS on success, IDEVICE_E_INVALID_ARG when connection
897 * is NULL. This function also returns IDEVICE_E_SUCCESS when SSL is not
898 * enabled and does no further error checking on cleanup.
899 */
900idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection) 768idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection)
901{ 769{
902 if (!connection) 770 if (!connection)
diff --git a/src/installation_proxy.c b/src/installation_proxy.c
index 109df10..e3a8103 100644
--- a/src/installation_proxy.c
+++ b/src/installation_proxy.c
@@ -86,17 +86,6 @@ static instproxy_error_t instproxy_error(property_list_service_error_t err)
86 return INSTPROXY_E_UNKNOWN_ERROR; 86 return INSTPROXY_E_UNKNOWN_ERROR;
87} 87}
88 88
89/**
90 * Connects to the installation_proxy service on the specified device.
91 *
92 * @param device The device to connect to
93 * @param service The service descriptor returned by lockdownd_start_service.
94 * @param client Pointer that will be set to a newly allocated
95 * instproxy_client_t upon successful return.
96 *
97 * @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error value
98 * when an error occured.
99 */
100instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, instproxy_client_t *client) 89instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, instproxy_client_t *client)
101{ 90{
102 property_list_service_client_t plistclient = NULL; 91 property_list_service_client_t plistclient = NULL;
@@ -114,19 +103,6 @@ instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descr
114 return INSTPROXY_E_SUCCESS; 103 return INSTPROXY_E_SUCCESS;
115} 104}
116 105
117/**
118 * Starts a new installation_proxy service on the specified device and connects to it.
119 *
120 * @param device The device to connect to.
121 * @param client Pointer that will point to a newly allocated
122 * instproxy_client_t upon successful return. Must be freed using
123 * instproxy_client_free() after use.
124 * @param label The label to use for communication. Usually the program name.
125 * Pass NULL to disable sending the label in requests to lockdownd.
126 *
127 * @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error
128 * code otherwise.
129 */
130instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_client_t * client, const char* label) 106instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_client_t * client, const char* label)
131{ 107{
132 instproxy_error_t err = INSTPROXY_E_UNKNOWN_ERROR; 108 instproxy_error_t err = INSTPROXY_E_UNKNOWN_ERROR;
@@ -134,15 +110,6 @@ instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_cli
134 return err; 110 return err;
135} 111}
136 112
137/**
138 * Disconnects an installation_proxy client from the device and frees up the
139 * installation_proxy client data.
140 *
141 * @param client The installation_proxy client to disconnect and free.
142 *
143 * @return INSTPROXY_E_SUCCESS on success
144 * or INSTPROXY_E_INVALID_ARG if client is NULL.
145 */
146instproxy_error_t instproxy_client_free(instproxy_client_t client) 113instproxy_error_t instproxy_client_free(instproxy_client_t client)
147{ 114{
148 if (!client) 115 if (!client)
@@ -195,20 +162,6 @@ static instproxy_error_t instproxy_send_command(instproxy_client_t client, const
195 return err; 162 return err;
196} 163}
197 164
198/**
199 * List installed applications. This function runs synchronously.
200 *
201 * @param client The connected installation_proxy client
202 * @param client_options The client options to use, as PLIST_DICT, or NULL.
203 * Valid client options include:
204 * "ApplicationType" -> "User"
205 * "ApplicationType" -> "System"
206 * @param result Pointer that will be set to a plist that will hold an array
207 * of PLIST_DICT holding information about the applications found.
208 *
209 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
210 * an error occured.
211 */
212instproxy_error_t instproxy_browse(instproxy_client_t client, plist_t client_options, plist_t *result) 165instproxy_error_t instproxy_browse(instproxy_client_t client, plist_t client_options, plist_t *result)
213{ 166{
214 if (!client || !client->parent || !result) 167 if (!client || !client->parent || !result)
@@ -461,85 +414,16 @@ static instproxy_error_t instproxy_install_or_upgrade(instproxy_client_t client,
461 return instproxy_create_status_updater(client, status_cb, command, user_data); 414 return instproxy_create_status_updater(client, status_cb, command, user_data);
462} 415}
463 416
464/**
465 * Install an application on the device.
466 *
467 * @param client The connected installation_proxy client
468 * @param pkg_path Path of the installation package (inside the AFC jail)
469 * @param client_options The client options to use, as PLIST_DICT, or NULL.
470 * Valid options include:
471 * "iTunesMetadata" -> PLIST_DATA
472 * "ApplicationSINF" -> PLIST_DATA
473 * "PackageType" -> "Developer"
474 * If PackageType -> Developer is specified, then pkg_path points to
475 * an .app directory instead of an install package.
476 * @param status_cb Callback function for progress and status information. If
477 * NULL is passed, this function will run synchronously.
478 * @param user_data Callback data passed to status_cb.
479 *
480 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
481 * an error occured.
482 *
483 * @note If a callback function is given (async mode), this function returns
484 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
485 * created successfully; any error occuring during the operation has to be
486 * handled inside the specified callback function.
487 */
488instproxy_error_t instproxy_install(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data) 417instproxy_error_t instproxy_install(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
489{ 418{
490 return instproxy_install_or_upgrade(client, pkg_path, client_options, status_cb, "Install", user_data); 419 return instproxy_install_or_upgrade(client, pkg_path, client_options, status_cb, "Install", user_data);
491} 420}
492 421
493/**
494 * Upgrade an application on the device. This function is nearly the same as
495 * instproxy_install; the difference is that the installation progress on the
496 * device is faster if the application is already installed.
497 *
498 * @param client The connected installation_proxy client
499 * @param pkg_path Path of the installation package (inside the AFC jail)
500 * @param client_options The client options to use, as PLIST_DICT, or NULL.
501 * Valid options include:
502 * "iTunesMetadata" -> PLIST_DATA
503 * "ApplicationSINF" -> PLIST_DATA
504 * "PackageType" -> "Developer"
505 * If PackageType -> Developer is specified, then pkg_path points to
506 * an .app directory instead of an install package.
507 * @param status_cb Callback function for progress and status information. If
508 * NULL is passed, this function will run synchronously.
509 * @param user_data Callback data passed to status_cb.
510 *
511 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
512 * an error occured.
513 *
514 * @note If a callback function is given (async mode), this function returns
515 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
516 * created successfully; any error occuring during the operation has to be
517 * handled inside the specified callback function.
518 */
519instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data) 422instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
520{ 423{
521 return instproxy_install_or_upgrade(client, pkg_path, client_options, status_cb, "Upgrade", user_data); 424 return instproxy_install_or_upgrade(client, pkg_path, client_options, status_cb, "Upgrade", user_data);
522} 425}
523 426
524/**
525 * Uninstall an application from the device.
526 *
527 * @param client The connected installation proxy client
528 * @param appid ApplicationIdentifier of the app to uninstall
529 * @param client_options The client options to use, as PLIST_DICT, or NULL.
530 * Currently there are no known client options, so pass NULL here.
531 * @param status_cb Callback function for progress and status information. If
532 * NULL is passed, this function will run synchronously.
533 * @param user_data Callback data passed to status_cb.
534 *
535 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
536 * an error occured.
537 *
538 * @note If a callback function is given (async mode), this function returns
539 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
540 * created successfully; any error occuring during the operation has to be
541 * handled inside the specified callback function.
542 */
543instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data) 427instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
544{ 428{
545 if (!client || !client->parent || !appid) { 429 if (!client || !client->parent || !appid) {
@@ -564,20 +448,6 @@ instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *app
564 return instproxy_create_status_updater(client, status_cb, "Uninstall", user_data); 448 return instproxy_create_status_updater(client, status_cb, "Uninstall", user_data);
565} 449}
566 450
567/**
568 * List archived applications. This function runs synchronously.
569 *
570 * @see instproxy_archive
571 *
572 * @param client The connected installation_proxy client
573 * @param client_options The client options to use, as PLIST_DICT, or NULL.
574 * Currently there are no known client options, so pass NULL here.
575 * @param result Pointer that will be set to a plist containing a PLIST_DICT
576 * holding information about the archived applications found.
577 *
578 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
579 * an error occured.
580 */
581instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t client_options, plist_t *result) 451instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t client_options, plist_t *result)
582{ 452{
583 if (!client || !client->parent || !result) 453 if (!client || !client->parent || !result)
@@ -604,30 +474,6 @@ leave_unlock:
604 return res; 474 return res;
605} 475}
606 476
607/**
608 * Archive an application on the device.
609 * This function tells the device to make an archive of the specified
610 * application. This results in the device creating a ZIP archive in the
611 * 'ApplicationArchives' directory and uninstalling the application.
612 *
613 * @param client The connected installation proxy client
614 * @param appid ApplicationIdentifier of the app to archive.
615 * @param client_options The client options to use, as PLIST_DICT, or NULL.
616 * Valid options include:
617 * "SkipUninstall" -> Boolean
618 * "ArchiveType" -> "ApplicationOnly"
619 * @param status_cb Callback function for progress and status information. If
620 * NULL is passed, this function will run synchronously.
621 * @param user_data Callback data passed to status_cb.
622 *
623 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
624 * an error occured.
625 *
626 * @note If a callback function is given (async mode), this function returns
627 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
628 * created successfully; any error occuring during the operation has to be
629 * handled inside the specified callback function.
630 */
631instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data) 477instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
632{ 478{
633 if (!client || !client->parent || !appid) 479 if (!client || !client->parent || !appid)
@@ -648,27 +494,6 @@ instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid
648 return instproxy_create_status_updater(client, status_cb, "Archive", user_data); 494 return instproxy_create_status_updater(client, status_cb, "Archive", user_data);
649} 495}
650 496
651/**
652 * Restore a previously archived application on the device.
653 * This function is the counterpart to instproxy_archive.
654 * @see instproxy_archive
655 *
656 * @param client The connected installation proxy client
657 * @param appid ApplicationIdentifier of the app to restore.
658 * @param client_options The client options to use, as PLIST_DICT, or NULL.
659 * Currently there are no known client options, so pass NULL here.
660 * @param status_cb Callback function for progress and status information. If
661 * NULL is passed, this function will run synchronously.
662 * @param user_data Callback data passed to status_cb.
663 *
664 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
665 * an error occured.
666 *
667 * @note If a callback function is given (async mode), this function returns
668 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
669 * created successfully; any error occuring during the operation has to be
670 * handled inside the specified callback function.
671 */
672instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data) 497instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
673{ 498{
674 if (!client || !client->parent || !appid) 499 if (!client || !client->parent || !appid)
@@ -689,27 +514,6 @@ instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid
689 return instproxy_create_status_updater(client, status_cb, "Restore", user_data); 514 return instproxy_create_status_updater(client, status_cb, "Restore", user_data);
690} 515}
691 516
692/**
693 * Removes a previously archived application from the device.
694 * This function removes the ZIP archive from the 'ApplicationArchives'
695 * directory.
696 *
697 * @param client The connected installation proxy client
698 * @param appid ApplicationIdentifier of the archived app to remove.
699 * @param client_options The client options to use, as PLIST_DICT, or NULL.
700 * Currently there are no known client options, so passing NULL is fine.
701 * @param status_cb Callback function for progress and status information. If
702 * NULL is passed, this function will run synchronously.
703 * @param user_data Callback data passed to status_cb.
704 *
705 * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
706 * an error occured.
707 *
708 * @note If a callback function is given (async mode), this function returns
709 * INSTPROXY_E_SUCCESS immediately if the status updater thread has been
710 * created successfully; any error occuring during the operation has to be
711 * handled inside the specified callback function.
712 */
713instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data) 517instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data)
714{ 518{
715 if (!client || !client->parent || !appid) 519 if (!client || !client->parent || !appid)
@@ -730,26 +534,11 @@ instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char
730 return instproxy_create_status_updater(client, status_cb, "RemoveArchive", user_data); 534 return instproxy_create_status_updater(client, status_cb, "RemoveArchive", user_data);
731} 535}
732 536
733/**
734 * Create a new client_options plist.
735 *
736 * @return A new plist_t of type PLIST_DICT.
737 */
738plist_t instproxy_client_options_new() 537plist_t instproxy_client_options_new()
739{ 538{
740 return plist_new_dict(); 539 return plist_new_dict();
741} 540}
742 541
743/**
744 * Add one or more new key:value pairs to the given client_options.
745 *
746 * @param client_options The client options to modify.
747 * @param ... KEY, VALUE, [KEY, VALUE], NULL
748 *
749 * @note The keys and values passed are expected to be strings, except for the
750 * keys "ApplicationSINF", "iTunesMetadata", "ReturnAttributes" which are
751 * expecting a plist_t node as value and "SkipUninstall" expects int.
752 */
753void instproxy_client_options_add(plist_t client_options, ...) 542void instproxy_client_options_add(plist_t client_options, ...)
754{ 543{
755 if (!client_options) 544 if (!client_options)
@@ -783,12 +572,6 @@ void instproxy_client_options_add(plist_t client_options, ...)
783 va_end(args); 572 va_end(args);
784} 573}
785 574
786/**
787 * Free client_options plist.
788 *
789 * @param client_options The client options plist to free. Does nothing if NULL
790 * is passed.
791 */
792void instproxy_client_options_free(plist_t client_options) 575void instproxy_client_options_free(plist_t client_options)
793{ 576{
794 if (client_options) { 577 if (client_options) {
@@ -796,21 +579,6 @@ void instproxy_client_options_free(plist_t client_options)
796 } 579 }
797} 580}
798 581
799/**
800 * Query the device for the path of an application.
801 *
802 * @param client The connected installation proxy client.
803 * @param appid ApplicationIdentifier of app to retrieve the path for.
804 * @param path Pointer to store the device path for the application
805 * which is set to NULL if it could not be determined.
806 *
807 * @return INSTPROXY_E_SUCCESS on success, INSTPROXY_E_OP_FAILED if
808 * the path could not be determined or an INSTPROXY_E_* error
809 * value if an error occured.
810 *
811 * @note This implementation browses all applications and matches the
812 * right entry by the application identifier.
813 */
814instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* appid, char** path) 582instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* appid, char** path)
815{ 583{
816 if (!client || !client->parent || !appid) 584 if (!client || !client->parent || !appid)
diff --git a/src/lockdown.c b/src/lockdown.c
index 9b579e8..cf03e0f 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -154,16 +154,6 @@ static void plist_dict_add_label(plist_t plist, const char *label)
154 } 154 }
155} 155}
156 156
157/**
158 * Closes the lockdownd session by sending the StopSession request.
159 *
160 * @see lockdownd_start_session
161 *
162 * @param client The lockdown client
163 * @param session_id The id of a running session
164 *
165 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
166 */
167lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *session_id) 157lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *session_id)
168{ 158{
169 if (!client) 159 if (!client)
@@ -247,14 +237,6 @@ static lockdownd_error_t lockdownd_client_free_simple(lockdownd_client_t client)
247 return ret; 237 return ret;
248} 238}
249 239
250/**
251 * Closes the lockdownd client session if one is running and frees up the
252 * lockdownd_client struct.
253 *
254 * @param client The lockdown client
255 *
256 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
257 */
258lockdownd_error_t lockdownd_client_free(lockdownd_client_t client) 240lockdownd_error_t lockdownd_client_free(lockdownd_client_t client)
259{ 241{
260 if (!client) 242 if (!client)
@@ -271,13 +253,6 @@ lockdownd_error_t lockdownd_client_free(lockdownd_client_t client)
271 return ret; 253 return ret;
272} 254}
273 255
274/**
275 * Sets the label to send for requests to lockdownd.
276 *
277 * @param client The lockdown client
278 * @param label The label to set or NULL to disable sending a label
279 *
280 */
281void lockdownd_client_set_label(lockdownd_client_t client, const char *label) 256void lockdownd_client_set_label(lockdownd_client_t client, const char *label)
282{ 257{
283 if (client) { 258 if (client) {
@@ -288,15 +263,6 @@ void lockdownd_client_set_label(lockdownd_client_t client, const char *label)
288 } 263 }
289} 264}
290 265
291/**
292 * Receives a plist from lockdownd.
293 *
294 * @param client The lockdownd client
295 * @param plist The plist to store the received data
296 *
297 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client or
298 * plist is NULL
299 */
300lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist) 266lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist)
301{ 267{
302 if (!client || !plist || (plist && *plist)) 268 if (!client || !plist || (plist && *plist))
@@ -315,18 +281,6 @@ lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist)
315 return ret; 281 return ret;
316} 282}
317 283
318/**
319 * Sends a plist to lockdownd.
320 *
321 * @note This function is low-level and should only be used if you need to send
322 * a new type of message.
323 *
324 * @param client The lockdownd client
325 * @param plist The plist to send
326 *
327 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client or
328 * plist is NULL
329 */
330lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist) 284lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist)
331{ 285{
332 if (!client || !plist) 286 if (!client || !plist)
@@ -342,15 +296,6 @@ lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist)
342 return ret; 296 return ret;
343} 297}
344 298
345/**
346 * Query the type of the service daemon. Depending on whether the device is
347 * queried in normal mode or restore mode, different types will be returned.
348 *
349 * @param client The lockdownd client
350 * @param type The type returned by the service daemon. Pass NULL to ignore.
351 *
352 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
353 */
354lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type) 299lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type)
355{ 300{
356 if (!client) 301 if (!client)
@@ -396,16 +341,6 @@ lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type)
396 return ret; 341 return ret;
397} 342}
398 343
399/**
400 * Retrieves a preferences plist using an optional domain and/or key name.
401 *
402 * @param client An initialized lockdownd client.
403 * @param domain The domain to query on or NULL for global domain
404 * @param key The key name to request or NULL to query for all keys
405 * @param value A plist node representing the result value node
406 *
407 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
408 */
409lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value) 344lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value)
410{ 345{
411 if (!client) 346 if (!client)
@@ -461,17 +396,6 @@ lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *dom
461 return ret; 396 return ret;
462} 397}
463 398
464/**
465 * Sets a preferences value using a plist and optional by domain and/or key name.
466 *
467 * @param client an initialized lockdownd client.
468 * @param domain the domain to query on or NULL for global domain
469 * @param key the key name to set the value or NULL to set a value dict plist
470 * @param value a plist node of any node type representing the value to set
471 *
472 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client or
473 * value is NULL
474 */
475lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value) 399lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value)
476{ 400{
477 if (!client || !value) 401 if (!client || !value)
@@ -520,17 +444,6 @@ lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *dom
520 return ret; 444 return ret;
521} 445}
522 446
523/**
524 * Removes a preference node by domain and/or key name.
525 *
526 * @note: Use with caution as this could remove vital information on the device
527 *
528 * @param client An initialized lockdownd client.
529 * @param domain The domain to query on or NULL for global domain
530 * @param key The key name to remove or NULL remove all keys for the current domain
531 *
532 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
533 */
534lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key) 447lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key)
535{ 448{
536 if (!client) 449 if (!client)
@@ -578,15 +491,6 @@ lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *
578 return ret; 491 return ret;
579} 492}
580 493
581/**
582 * Returns the unique id of the device from lockdownd.
583 *
584 * @param client An initialized lockdownd client.
585 * @param udid Holds the unique id of the device. The caller is responsible
586 * for freeing the memory.
587 *
588 * @return LOCKDOWN_E_SUCCESS on success
589 */
590lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t client, char **udid) 494lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t client, char **udid)
591{ 495{
592 lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR; 496 lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR;
@@ -633,15 +537,6 @@ static lockdownd_error_t lockdownd_get_device_public_key_as_key_data(lockdownd_c
633 return ret; 537 return ret;
634} 538}
635 539
636/**
637 * Retrieves the name of the device from lockdownd set by the user.
638 *
639 * @param client An initialized lockdownd client.
640 * @param device_name Holds the name of the device. The caller is
641 * responsible for freeing the memory.
642 *
643 * @return LOCKDOWN_E_SUCCESS on success
644 */
645lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name) 540lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name)
646{ 541{
647 lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR; 542 lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR;
@@ -659,21 +554,6 @@ lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **de
659 return ret; 554 return ret;
660} 555}
661 556
662/**
663 * Creates a new lockdownd client for the device.
664 *
665 * @note This function does not pair with the device or start a session. This
666 * has to be done manually by the caller after the client is created.
667 * The device disconnects automatically if the lockdown connection idles
668 * for more than 10 seconds. Make sure to call lockdownd_client_free() as soon
669 * as the connection is no longer needed.
670 *
671 * @param device The device to create a lockdownd client for
672 * @param client The pointer to the location of the new lockdownd_client
673 * @param label The label to use for communication. Usually the program name.
674 *
675 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
676 */
677lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, const char *label) 557lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, const char *label)
678{ 558{
679 if (!client) 559 if (!client)
@@ -707,23 +587,6 @@ lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *cli
707 return LOCKDOWN_E_SUCCESS; 587 return LOCKDOWN_E_SUCCESS;
708} 588}
709 589
710/**
711 * Creates a new lockdownd client for the device and starts initial handshake.
712 * The handshake consists out of query_type, validate_pair, pair and
713 * start_session calls. It uses the internal pairing record management.
714 *
715 * @note The device disconnects automatically if the lockdown connection idles
716 * for more than 10 seconds. Make sure to call lockdownd_client_free() as soon
717 * as the connection is no longer needed.
718 *
719 * @param device The device to create a lockdownd client for
720 * @param client The pointer to the location of the new lockdownd_client
721 * @param label The label to use for communication. Usually the program name.
722 * Pass NULL to disable sending the label in requests to lockdownd.
723 *
724 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
725 * LOCKDOWN_E_INVALID_CONF if configuration data is wrong
726 */
727lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label) 590lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label)
728{ 591{
729 if (!client) 592 if (!client)
@@ -1091,73 +954,21 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_
1091 return ret; 954 return ret;
1092} 955}
1093 956
1094/**
1095 * Pairs the device using the supplied pair record.
1096 *
1097 * @param client The lockdown client to pair with.
1098 * @param pair_record The pair record to use for pairing. If NULL is passed, then
1099 * the pair records from the current machine are used. New records will be
1100 * generated automatically when pairing is done for the first time.
1101 *
1102 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
1103 * LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong,
1104 * LOCKDOWN_E_PAIRING_FAILED if the pairing failed,
1105 * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
1106 * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
1107 */
1108lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) 957lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record)
1109{ 958{
1110 return lockdownd_do_pair(client, pair_record, "Pair"); 959 return lockdownd_do_pair(client, pair_record, "Pair");
1111} 960}
1112 961
1113/**
1114 * Validates if the device is paired with the given HostID. If succeeded them
1115 * specified host will become trusted host of the device indicated by the
1116 * lockdownd preference named TrustedHostAttached. Otherwise the host must because
1117 * paired using lockdownd_pair() first.
1118 *
1119 * @param client The lockdown client to pair with.
1120 * @param pair_record The pair record to validate pairing with. If NULL is
1121 * passed, then the pair record is read from the internal pairing record
1122 * management.
1123 *
1124 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
1125 * LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong,
1126 * LOCKDOWN_E_PAIRING_FAILED if the pairing failed,
1127 * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
1128 * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
1129 */
1130lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) 962lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record)
1131{ 963{
1132 return lockdownd_do_pair(client, pair_record, "ValidatePair"); 964 return lockdownd_do_pair(client, pair_record, "ValidatePair");
1133} 965}
1134 966
1135/**
1136 * Unpairs the device with the given HostID and removes the pairing records
1137 * from the device and host if the internal pairing record management is used.
1138 *
1139 * @param client The lockdown client to pair with.
1140 * @param pair_record The pair record to use for unpair. If NULL is passed, then
1141 * the pair records from the current machine are used.
1142 *
1143 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
1144 * LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong,
1145 * LOCKDOWN_E_PAIRING_FAILED if the pairing failed,
1146 * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
1147 * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
1148 */
1149lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record) 967lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record)
1150{ 968{
1151 return lockdownd_do_pair(client, pair_record, "Unpair"); 969 return lockdownd_do_pair(client, pair_record, "Unpair");
1152} 970}
1153 971
1154/**
1155 * Tells the device to immediately enter recovery mode.
1156 *
1157 * @param client The lockdown client
1158 *
1159 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
1160 */
1161lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client) 972lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client)
1162{ 973{
1163 if (!client) 974 if (!client)
@@ -1186,15 +997,6 @@ lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client)
1186 return ret; 997 return ret;
1187} 998}
1188 999
1189/**
1190 * Sends the Goodbye request to lockdownd signaling the end of communication.
1191 *
1192 * @param client The lockdown client
1193 *
1194 * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client
1195 * is NULL, LOCKDOWN_E_PLIST_ERROR if the device did not acknowledge the
1196 * request
1197 */
1198lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client) 1000lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client)
1199{ 1001{
1200 if (!client) 1002 if (!client)
@@ -1228,19 +1030,6 @@ lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client)
1228 return ret; 1030 return ret;
1229} 1031}
1230 1032
1231/**
1232 * Opens a session with lockdownd and switches to SSL mode if device wants it.
1233 *
1234 * @param client The lockdownd client
1235 * @param host_id The HostID of the computer
1236 * @param session_id The new session_id of the created session
1237 * @param ssl_enabled Whether SSL communication is used in the session
1238 *
1239 * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when a client
1240 * or host_id is NULL, LOCKDOWN_E_PLIST_ERROR if the response plist had errors,
1241 * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the supplied HostID,
1242 * LOCKDOWN_E_SSL_ERROR if enabling SSL communication failed
1243 */
1244lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled) 1033lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled)
1245{ 1034{
1246 lockdownd_error_t ret = LOCKDOWN_E_SUCCESS; 1035 lockdownd_error_t ret = LOCKDOWN_E_SUCCESS;
@@ -1345,18 +1134,6 @@ lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char
1345 return ret; 1134 return ret;
1346} 1135}
1347 1136
1348/**
1349 * Requests to start a service and retrieve it's port on success.
1350 *
1351 * @param client The lockdownd client
1352 * @param identifier The identifier of the service to start
1353 * @param descriptor The service descriptor on success or NULL on failure
1354
1355 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG if a parameter
1356 * is NULL, LOCKDOWN_E_INVALID_SERVICE if the requested service is not known
1357 * by the device, LOCKDOWN_E_START_SERVICE_FAILED if the service could not because
1358 * started by the device
1359 */
1360lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service) 1137lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service)
1361{ 1138{
1362 if (!client || !identifier || !service) 1139 if (!client || !identifier || !service)
@@ -1442,24 +1219,7 @@ lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char
1442 return ret; 1219 return ret;
1443} 1220}
1444 1221
1445/** 1222lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record)
1446 * Activates the device. Only works within an open session.
1447 * The ActivationRecord plist dictionary must be obtained using the
1448 * activation protocol requesting from Apple's https webservice.
1449 *
1450 * @see http://iphone-docs.org/doku.php?id=docs:protocols:activation
1451 *
1452 * @param client The lockdown client
1453 * @param activation_record The activation record plist dictionary
1454 *
1455 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client or
1456 * activation_record is NULL, LOCKDOWN_E_NO_RUNNING_SESSION if no session is
1457 * open, LOCKDOWN_E_PLIST_ERROR if the received plist is broken,
1458 * LOCKDOWN_E_ACTIVATION_FAILED if the activation failed,
1459 * LOCKDOWN_E_INVALID_ACTIVATION_RECORD if the device reports that the
1460 * activation_record is invalid
1461 */
1462lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record)
1463{ 1223{
1464 if (!client) 1224 if (!client)
1465 return LOCKDOWN_E_INVALID_ARG; 1225 return LOCKDOWN_E_INVALID_ARG;
@@ -1510,16 +1270,6 @@ lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activati
1510 return ret; 1270 return ret;
1511} 1271}
1512 1272
1513/**
1514 * Deactivates the device, returning it to the locked “Activate with iTunes”
1515 * screen.
1516 *
1517 * @param client The lockdown client
1518 *
1519 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
1520 * LOCKDOWN_E_NO_RUNNING_SESSION if no session is open,
1521 * LOCKDOWN_E_PLIST_ERROR if the received plist is broken
1522 */
1523lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client) 1273lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client)
1524{ 1274{
1525 if (!client) 1275 if (!client)
@@ -1567,19 +1317,6 @@ static void str_remove_spaces(char *source)
1567 *dest = 0; 1317 *dest = 0;
1568} 1318}
1569 1319
1570/**
1571 * Calculates and returns the data classes the device supports from lockdownd.
1572 *
1573 * @param client An initialized lockdownd client.
1574 * @param classes A pointer to store an array of class names. The caller is responsible
1575 * for freeing the memory which can be done using mobilesync_data_classes_free().
1576 * @param count The number of items in the classes array.
1577 *
1578 * @return LOCKDOWN_E_SUCCESS on success,
1579 * LOCKDOWN_E_INVALID_ARG when client is NULL,
1580 * LOCKDOWN_E_NO_RUNNING_SESSION if no session is open,
1581 * LOCKDOWN_E_PLIST_ERROR if the received plist is broken
1582 */
1583lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, char ***classes, int *count) 1320lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, char ***classes, int *count)
1584{ 1321{
1585 if (!client) 1322 if (!client)
@@ -1634,13 +1371,6 @@ lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, cha
1634} 1371}
1635 1372
1636 1373
1637/**
1638 * Frees memory of an allocated array of data classes as returned by lockdownd_get_sync_data_classes()
1639 *
1640 * @param classes An array of class names to free.
1641 *
1642 * @return LOCKDOWN_E_SUCCESS on success
1643 */
1644lockdownd_error_t lockdownd_data_classes_free(char **classes) 1374lockdownd_error_t lockdownd_data_classes_free(char **classes)
1645{ 1375{
1646 if (classes) { 1376 if (classes) {
@@ -1653,13 +1383,6 @@ lockdownd_error_t lockdownd_data_classes_free(char **classes)
1653 return LOCKDOWN_E_SUCCESS; 1383 return LOCKDOWN_E_SUCCESS;
1654} 1384}
1655 1385
1656/**
1657 * Frees memory of a service descriptor as returned by lockdownd_start_service()
1658 *
1659 * @param sevice A service descriptor instance to free.
1660 *
1661 * @return LOCKDOWN_E_SUCCESS on success
1662 */
1663lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service) 1386lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service)
1664{ 1387{
1665 if (service) 1388 if (service)
diff --git a/src/misagent.c b/src/misagent.c
index 6edbadd..96dddba 100644
--- a/src/misagent.c
+++ b/src/misagent.c
@@ -87,17 +87,6 @@ static misagent_error_t misagent_check_result(plist_t response, int* status_code
87 } 87 }
88} 88}
89 89
90/**
91 * Connects to the misagent service on the specified device.
92 *
93 * @param device The device to connect to.
94 * @param service The service descriptor returned by lockdownd_start_service.
95 * @param client Pointer that will point to a newly allocated
96 * misagent_client_t upon successful return.
97 *
98 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
99 * client is NULL, or an MISAGENT_E_* error code otherwise.
100 */
101misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client) 90misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client)
102{ 91{
103 property_list_service_client_t plistclient = NULL; 92 property_list_service_client_t plistclient = NULL;
@@ -114,19 +103,6 @@ misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descrip
114 return MISAGENT_E_SUCCESS; 103 return MISAGENT_E_SUCCESS;
115} 104}
116 105
117/**
118 * Starts a new misagent service on the specified device and connects to it.
119 *
120 * @param device The device to connect to.
121 * @param client Pointer that will point to a newly allocated
122 * misagent_client_t upon successful return. Must be freed using
123 * misagent_client_free() after use.
124 * @param label The label to use for communication. Usually the program name.
125 * Pass NULL to disable sending the label in requests to lockdownd.
126 *
127 * @return MISAGENT_E_SUCCESS on success, or an MISAGENT_E_* error
128 * code otherwise.
129 */
130misagent_error_t misagent_client_start_service(idevice_t device, misagent_client_t * client, const char* label) 106misagent_error_t misagent_client_start_service(idevice_t device, misagent_client_t * client, const char* label)
131{ 107{
132 misagent_error_t err = MISAGENT_E_UNKNOWN_ERROR; 108 misagent_error_t err = MISAGENT_E_UNKNOWN_ERROR;
@@ -134,15 +110,6 @@ misagent_error_t misagent_client_start_service(idevice_t device, misagent_client
134 return err; 110 return err;
135} 111}
136 112
137/**
138 * Disconnects an misagent client from the device and frees up the
139 * misagent client data.
140 *
141 * @param client The misagent client to disconnect and free.
142 *
143 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
144 * client is NULL, or an MISAGENT_E_* error code otherwise.
145 */
146misagent_error_t misagent_client_free(misagent_client_t client) 113misagent_error_t misagent_client_free(misagent_client_t client)
147{ 114{
148 if (!client) 115 if (!client)
@@ -158,16 +125,6 @@ misagent_error_t misagent_client_free(misagent_client_t client)
158 return err; 125 return err;
159} 126}
160 127
161/**
162 * Installs the given provisioning profile. Only works with valid profiles.
163 *
164 * @param client The connected misagent to use for installation
165 * @param profile The valid provisioning profile to install. This has to be
166 * passed as a PLIST_DATA, otherwise the function will fail.
167 *
168 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
169 * client is invalid, or an MISAGENT_E_* error code otherwise.
170 */
171misagent_error_t misagent_install(misagent_client_t client, plist_t profile) 128misagent_error_t misagent_install(misagent_client_t client, plist_t profile)
172{ 129{
173 if (!client || !client->parent || !profile || (plist_get_node_type(profile) != PLIST_DATA)) 130 if (!client || !client->parent || !profile || (plist_get_node_type(profile) != PLIST_DATA))
@@ -205,20 +162,6 @@ misagent_error_t misagent_install(misagent_client_t client, plist_t profile)
205 return res; 162 return res;
206} 163}
207 164
208/**
209 * Retrieves an array of all installed provisioning profiles.
210 *
211 * @param client The connected misagent to use.
212 * @param profiles Pointer to a plist_t that will be set to a PLIST_ARRAY
213 * if the function is successful.
214 *
215 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
216 * client is invalid, or an MISAGENT_E_* error code otherwise.
217 *
218 * @note If no provisioning profiles are installed on the device, this function
219 * still returns MISAGENT_E_SUCCESS and profiles will just point to an
220 * empty array.
221 */
222misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles) 165misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles)
223{ 166{
224 if (!client || !client->parent || !profiles) 167 if (!client || !client->parent || !profiles)
@@ -259,17 +202,6 @@ misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles)
259 202
260} 203}
261 204
262/**
263 * Removes a given provisioning profile.
264 *
265 * @param client The connected misagent to use.
266 * @param profileID Identifier of the provisioning profile to remove.
267 * This is a UUID that can be obtained from the provisioning profile data.
268 * @see misagent_copy
269 *
270 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
271 * client is invalid, or an MISAGENT_E_* error code otherwise.
272 */
273misagent_error_t misagent_remove(misagent_client_t client, const char* profileID) 205misagent_error_t misagent_remove(misagent_client_t client, const char* profileID)
274{ 206{
275 if (!client || !client->parent || !profileID) 207 if (!client || !client->parent || !profileID)
@@ -307,13 +239,6 @@ misagent_error_t misagent_remove(misagent_client_t client, const char* profileID
307 return res; 239 return res;
308} 240}
309 241
310/**
311 * Retrieves the status code from the last operation.
312 *
313 * @param client The misagent to use.
314 *
315 * @return -1 if client is invalid, or the status code from the last operation
316 */
317int misagent_get_status_code(misagent_client_t client) 242int misagent_get_status_code(misagent_client_t client)
318{ 243{
319 if (!client) { 244 if (!client) {
diff --git a/src/mobile_image_mounter.c b/src/mobile_image_mounter.c
index 4b2818d..7133b8b 100644
--- a/src/mobile_image_mounter.c
+++ b/src/mobile_image_mounter.c
@@ -75,19 +75,6 @@ static mobile_image_mounter_error_t mobile_image_mounter_error(property_list_ser
75 return MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR; 75 return MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR;
76} 76}
77 77
78/**
79 * Connects to the mobile_image_mounter service on the specified device.
80 *
81 * @param device The device to connect to.
82 * @param service The service descriptor returned by lockdownd_start_service.
83 * @param client Pointer that will be set to a newly allocated
84 * mobile_image_mounter_client_t upon successful return.
85 *
86 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
87 * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if device is NULL,
88 * or MOBILE_IMAGE_MOUNTER_E_CONN_FAILED if the connection to the
89 * device could not be established.
90 */
91mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client) 78mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client)
92{ 79{
93 property_list_service_client_t plistclient = NULL; 80 property_list_service_client_t plistclient = NULL;
@@ -105,19 +92,6 @@ mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdown
105 return MOBILE_IMAGE_MOUNTER_E_SUCCESS; 92 return MOBILE_IMAGE_MOUNTER_E_SUCCESS;
106} 93}
107 94
108/**
109 * Starts a new mobile_image_mounter service on the specified device and connects to it.
110 *
111 * @param device The device to connect to.
112 * @param client Pointer that will point to a newly allocated
113 * mobile_image_mounter_t upon successful return. Must be freed using
114 * mobile_image_mounter_free() after use.
115 * @param label The label to use for communication. Usually the program name.
116 * Pass NULL to disable sending the label in requests to lockdownd.
117 *
118 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success, or an MOBILE_IMAGE_MOUNTER_E_* error
119 * code otherwise.
120 */
121mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device, mobile_image_mounter_client_t * client, const char* label) 95mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device, mobile_image_mounter_client_t * client, const char* label)
122{ 96{
123 mobile_image_mounter_error_t err = MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR; 97 mobile_image_mounter_error_t err = MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR;
@@ -125,15 +99,6 @@ mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device
125 return err; 99 return err;
126} 100}
127 101
128/**
129 * Disconnects a mobile_image_mounter client from the device and frees up the
130 * mobile_image_mounter client data.
131 *
132 * @param client The mobile_image_mounter client to disconnect and free.
133 *
134 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
135 * or MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if client is NULL.
136 */
137mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client) 102mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client)
138{ 103{
139 if (!client) 104 if (!client)
@@ -147,19 +112,6 @@ mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_clie
147 return MOBILE_IMAGE_MOUNTER_E_SUCCESS; 112 return MOBILE_IMAGE_MOUNTER_E_SUCCESS;
148} 113}
149 114
150/**
151 * Tells if the image of ImageType is already mounted.
152 *
153 * @param client The client use
154 * @param image_type The type of the image to look up
155 * @param result Pointer to a plist that will receive the result of the
156 * operation.
157 *
158 * @note This function may return MOBILE_IMAGE_MOUNTER_E_SUCCESS even if the
159 * operation has failed. Check the resulting plist for further information.
160 *
161 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success, or an error code on error
162 */
163mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result) 115mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result)
164{ 116{
165 if (!client || !image_type || !result) { 117 if (!client || !image_type || !result) {
@@ -189,19 +141,6 @@ leave_unlock:
189 return res; 141 return res;
190} 142}
191 143
192/**
193 * Uploads an image to the device.
194 *
195 * @param client The connected mobile_image_mounter client.
196 * @param image_type Type of image that is being uploaded.
197 * @param image_size Total size of the image.
198 * @param upload_cb Callback function that gets the data chunks for uploading
199 * the image.
200 * @param userdata User defined data for the upload callback function.
201 *
202 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on succes, or a
203 * MOBILE_IMAGE_MOUNTER_E_* error code otherwise.
204 */
205mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata) 144mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata)
206{ 145{
207 if (!client || !image_type || (image_size == 0) || !upload_cb) { 146 if (!client || !image_type || (image_size == 0) || !upload_cb) {
@@ -311,27 +250,6 @@ leave_unlock:
311 250
312} 251}
313 252
314/**
315 * Mounts an image on the device.
316 *
317 * @param client The connected mobile_image_mounter client.
318 * @param image_path The absolute path of the image to mount. The image must
319 * be present before calling this function.
320 * @param image_signature Pointer to a buffer holding the images' signature
321 * @param signature_length Length of the signature image_signature points to
322 * @param image_type Type of image to mount
323 * @param result Pointer to a plist that will receive the result of the
324 * operation.
325 *
326 * @note This function may return MOBILE_IMAGE_MOUNTER_E_SUCCESS even if the
327 * operation has failed. Check the resulting plist for further information.
328 * Note that there is no unmounting function. The mount persists until the
329 * device is rebooted.
330 *
331 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
332 * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if on ore more parameters are
333 * invalid, or another error code otherwise.
334 */
335mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *image_signature, uint16_t signature_length, const char *image_type, plist_t *result) 253mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *image_signature, uint16_t signature_length, const char *image_type, plist_t *result)
336{ 254{
337 if (!client || !image_path || !image_signature || (signature_length == 0) || !image_type || !result) { 255 if (!client || !image_path || !image_signature || (signature_length == 0) || !image_type || !result) {
@@ -363,17 +281,6 @@ leave_unlock:
363 return res; 281 return res;
364} 282}
365 283
366/**
367 * Hangs up the connection to the mobile_image_mounter service.
368 * This functions has to be called before freeing up a mobile_image_mounter
369 * instance. If not, errors appear in the device's syslog.
370 *
371 * @param client The client to hang up
372 *
373 * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
374 * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if client is invalid,
375 * or another error code otherwise.
376 */
377mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client) 284mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client)
378{ 285{
379 if (!client) { 286 if (!client) {
diff --git a/src/mobilebackup.c b/src/mobilebackup.c
index 66e590a..7107d12 100644
--- a/src/mobilebackup.c
+++ b/src/mobilebackup.c
@@ -60,18 +60,6 @@ static mobilebackup_error_t mobilebackup_error(device_link_service_error_t err)
60 return MOBILEBACKUP_E_UNKNOWN_ERROR; 60 return MOBILEBACKUP_E_UNKNOWN_ERROR;
61} 61}
62 62
63/**
64 * Connects to the mobilebackup service on the specified device.
65 *
66 * @param device The device to connect to.
67 * @param service The service descriptor returned by lockdownd_start_service.
68 * @param client Pointer that will be set to a newly allocated
69 * mobilebackup_client_t upon successful return.
70 *
71 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID ARG if one
72 * or more parameters are invalid, or DEVICE_LINK_SERVICE_E_BAD_VERSION if
73 * the mobilebackup version on the device is newer.
74 */
75mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup_client_t * client) 63mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup_client_t * client)
76{ 64{
77 if (!device || !service || service->port == 0 || !client || *client) 65 if (!device || !service || service->port == 0 || !client || *client)
@@ -99,19 +87,6 @@ mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service
99 return ret; 87 return ret;
100} 88}
101 89
102/**
103 * Starts a new mobilebackup service on the specified device and connects to it.
104 *
105 * @param device The device to connect to.
106 * @param client Pointer that will point to a newly allocated
107 * mobilebackup_client_t upon successful return. Must be freed using
108 * mobilebackup_client_free() after use.
109 * @param label The label to use for communication. Usually the program name.
110 * Pass NULL to disable sending the label in requests to lockdownd.
111 *
112 * @return MOBILEBACKUP_E_SUCCESS on success, or an MOBILEBACKUP_E_* error
113 * code otherwise.
114 */
115mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobilebackup_client_t * client, const char* label) 90mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobilebackup_client_t * client, const char* label)
116{ 91{
117 mobilebackup_error_t err = MOBILEBACKUP_E_UNKNOWN_ERROR; 92 mobilebackup_error_t err = MOBILEBACKUP_E_UNKNOWN_ERROR;
@@ -119,15 +94,6 @@ mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobileb
119 return err; 94 return err;
120} 95}
121 96
122/**
123 * Disconnects a mobilebackup client from the device and frees up the
124 * mobilebackup client data.
125 *
126 * @param client The mobilebackup client to disconnect and free.
127 *
128 * @return MOBILEBACKUP_E_SUCCESS on success, or MOBILEBACKUP_E_INVALID_ARG
129 * if client is NULL.
130 */
131mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client) 97mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client)
132{ 98{
133 if (!client) 99 if (!client)
@@ -141,14 +107,6 @@ mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client)
141 return err; 107 return err;
142} 108}
143 109
144/**
145 * Polls the device for mobilebackup data.
146 *
147 * @param client The mobilebackup client
148 * @param plist A pointer to the location where the plist should be stored
149 *
150 * @return an error code
151 */
152mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t * plist) 110mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t * plist)
153{ 111{
154 if (!client) 112 if (!client)
@@ -157,17 +115,6 @@ mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t
157 return ret; 115 return ret;
158} 116}
159 117
160/**
161 * Sends mobilebackup data to the device
162 *
163 * @note This function is low-level and should only be used if you need to send
164 * a new type of message.
165 *
166 * @param client The mobilebackup client
167 * @param plist The location of the plist to send
168 *
169 * @return an error code
170 */
171mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t plist) 118mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t plist)
172{ 119{
173 if (!client || !plist) 120 if (!client || !plist)
@@ -285,23 +232,6 @@ leave:
285 return err; 232 return err;
286} 233}
287 234
288/**
289 * Request a backup from the connected device.
290 *
291 * @param client The connected MobileBackup client to use.
292 * @param backup_manifest The backup manifest, a plist_t of type PLIST_DICT
293 * containing the backup state of the last backup. For a first-time backup
294 * set this parameter to NULL.
295 * @param base_path The base path on the device to use for the backup
296 * operation, usually "/".
297 * @param proto_version A string denoting the version of the backup protocol
298 * to use. Latest known version is "1.6"
299 *
300 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
301 * one of the parameters is invalid, MOBILEBACKUP_E_PLIST_ERROR if
302 * backup_manifest is not of type PLIST_DICT, MOBILEBACKUP_E_MUX_ERROR
303 * if a communication error occurs, MOBILEBACKUP_E_REPLY_NOT_OK
304 */
305mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, plist_t backup_manifest, const char *base_path, const char *proto_version) 235mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, plist_t backup_manifest, const char *base_path, const char *proto_version)
306{ 236{
307 if (!client || !client->parent || !base_path || !proto_version) 237 if (!client || !client->parent || !base_path || !proto_version)
@@ -362,41 +292,11 @@ leave:
362 return err; 292 return err;
363} 293}
364 294
365/**
366 * Sends a confirmation to the device that a backup file has been received.
367 *
368 * @param client The connected MobileBackup client to use.
369 *
370 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
371 * client is invalid, or MOBILEBACKUP_E_MUX_ERROR if a communication error
372 * occurs.
373 */
374mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_t client) 295mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_t client)
375{ 296{
376 return mobilebackup_send_message(client, "kBackupMessageBackupFileReceived", NULL); 297 return mobilebackup_send_message(client, "kBackupMessageBackupFileReceived", NULL);
377} 298}
378 299
379/**
380 * Request that a backup should be restored to the connected device.
381 *
382 * @param client The connected MobileBackup client to use.
383 * @param backup_manifest The backup manifest, a plist_t of type PLIST_DICT
384 * containing the backup state to be restored.
385 * @param flags Flags to send with the request. Currently this is a combination
386 * of the following mobilebackup_flags_t:
387 * MB_RESTORE_NOTIFY_SPRINGBOARD - let SpringBoard show a 'Restore' screen
388 * MB_RESTORE_PRESERVE_SETTINGS - do not overwrite any settings
389 * MB_RESTORE_PRESERVE_CAMERA_ROLL - preserve the photos of the camera roll
390 * @param proto_version A string denoting the version of the backup protocol
391 * to use. Latest known version is "1.6". Ideally this value should be
392 * extracted from the given manifest plist.
393 *
394 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
395 * one of the parameters is invalid, MOBILEBACKUP_E_PLIST_ERROR if
396 * backup_manifest is not of type PLIST_DICT, MOBILEBACKUP_E_MUX_ERROR
397 * if a communication error occurs, or MOBILEBACKUP_E_REPLY_NOT_OK
398 * if the device did not accept the request.
399 */
400mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, plist_t backup_manifest, mobilebackup_flags_t flags, const char *proto_version) 300mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, plist_t backup_manifest, mobilebackup_flags_t flags, const char *proto_version)
401{ 301{
402 if (!client || !client->parent || !backup_manifest || !proto_version) 302 if (!client || !client->parent || !backup_manifest || !proto_version)
@@ -451,63 +351,16 @@ leave:
451 return err; 351 return err;
452} 352}
453 353
454/**
455 * Receive a confirmation from the device that it successfully received
456 * a restore file.
457 *
458 * @param client The connected MobileBackup client to use.
459 * @param result Pointer to a plist_t that will be set to the received plist
460 * for further processing. The caller has to free it using plist_free().
461 * Note that it will be set to NULL if the operation itself fails due to
462 * a communication or plist error.
463 * If this parameter is NULL, it will be ignored.
464 *
465 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
466 * client is invalid, MOBILEBACKUP_E_REPLY_NOT_OK if the expected
467 * 'BackupMessageRestoreFileReceived' message could not be received,
468 * MOBILEBACKUP_E_PLIST_ERROR if the received message is not a valid backup
469 * message plist, or MOBILEBACKUP_E_MUX_ERROR if a communication error
470 * occurs.
471 */
472mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_client_t client, plist_t *result) 354mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_client_t client, plist_t *result)
473{ 355{
474 return mobilebackup_receive_message(client, "BackupMessageRestoreFileReceived", result); 356 return mobilebackup_receive_message(client, "BackupMessageRestoreFileReceived", result);
475} 357}
476 358
477/**
478 * Receive a confirmation from the device that it successfully received
479 * application data file.
480 *
481 * @param client The connected MobileBackup client to use.
482 * @param result Pointer to a plist_t that will be set to the received plist
483 * for further processing. The caller has to free it using plist_free().
484 * Note that it will be set to NULL if the operation itself fails due to
485 * a communication or plist error.
486 * If this parameter is NULL, it will be ignored.
487 *
488 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
489 * client is invalid, MOBILEBACKUP_E_REPLY_NOT_OK if the expected
490 * 'BackupMessageRestoreApplicationReceived' message could not be received,
491 * MOBILEBACKUP_E_PLIST_ERROR if the received message is not a valid backup
492 * message plist, or MOBILEBACKUP_E_MUX_ERROR if a communication error
493 * occurs.
494 */
495mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebackup_client_t client, plist_t *result) 359mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebackup_client_t client, plist_t *result)
496{ 360{
497 return mobilebackup_receive_message(client, "BackupMessageRestoreApplicationReceived", result); 361 return mobilebackup_receive_message(client, "BackupMessageRestoreApplicationReceived", result);
498} 362}
499 363
500/**
501 * Tells the device that the restore process is complete and waits for the
502 * device to close the connection. After that, the device should reboot.
503 *
504 * @param client The connected MobileBackup client to use.
505 *
506 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
507 * client is invalid, MOBILEBACKUP_E_PLIST_ERROR if the received disconnect
508 * message plist is invalid, or MOBILEBACKUP_E_MUX_ERROR if a communication
509 * error occurs.
510 */
511mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client) 364mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client)
512{ 365{
513 mobilebackup_error_t err = mobilebackup_send_message(client, "BackupMessageRestoreComplete", NULL); 366 mobilebackup_error_t err = mobilebackup_send_message(client, "BackupMessageRestoreComplete", NULL);
@@ -553,16 +406,6 @@ mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t cl
553 return err; 406 return err;
554} 407}
555 408
556/**
557 * Sends a backup error message to the device.
558 *
559 * @param client The connected MobileBackup client to use.
560 * @param reason A string describing the reason for the error message.
561 *
562 * @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
563 * one of the parameters is invalid, or MOBILEBACKUP_E_MUX_ERROR if a
564 * communication error occurs.
565 */
566mobilebackup_error_t mobilebackup_send_error(mobilebackup_client_t client, const char *reason) 409mobilebackup_error_t mobilebackup_send_error(mobilebackup_client_t client, const char *reason)
567{ 410{
568 if (!client || !client->parent || !reason) 411 if (!client || !client->parent || !reason)
diff --git a/src/mobilebackup2.c b/src/mobilebackup2.c
index 09b156d..41fe5d3 100644
--- a/src/mobilebackup2.c
+++ b/src/mobilebackup2.c
@@ -61,18 +61,6 @@ static mobilebackup2_error_t mobilebackup2_error(device_link_service_error_t err
61 return MOBILEBACKUP2_E_UNKNOWN_ERROR; 61 return MOBILEBACKUP2_E_UNKNOWN_ERROR;
62} 62}
63 63
64/**
65 * Connects to the mobilebackup2 service on the specified device.
66 *
67 * @param device The device to connect to.
68 * @param service The service descriptor returned by lockdownd_start_service.
69 * @param client Pointer that will be set to a newly allocated
70 * mobilebackup2_client_t upon successful return.
71 *
72 * @return MOBILEBACKUP2_E_SUCCESS on success, MOBILEBACKUP2_E_INVALID ARG
73 * if one or more parameter is invalid, or MOBILEBACKUP2_E_BAD_VERSION
74 * if the mobilebackup2 version on the device is newer.
75 */
76mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t service, 64mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t service,
77 mobilebackup2_client_t * client) 65 mobilebackup2_client_t * client)
78{ 66{
@@ -101,19 +89,6 @@ mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_servi
101 return ret; 89 return ret;
102} 90}
103 91
104/**
105 * Starts a new mobilebackup2 service on the specified device and connects to it.
106 *
107 * @param device The device to connect to.
108 * @param client Pointer that will point to a newly allocated
109 * mobilebackup2_client_t upon successful return. Must be freed using
110 * mobilebackup2_client_free() after use.
111 * @param label The label to use for communication. Usually the program name.
112 * Pass NULL to disable sending the label in requests to lockdownd.
113 *
114 * @return MOBILEBACKUP2_E_SUCCESS on success, or an MOBILEBACKUP2_E_* error
115 * code otherwise.
116 */
117mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobilebackup2_client_t * client, const char* label) 92mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobilebackup2_client_t * client, const char* label)
118{ 93{
119 mobilebackup2_error_t err = MOBILEBACKUP2_E_UNKNOWN_ERROR; 94 mobilebackup2_error_t err = MOBILEBACKUP2_E_UNKNOWN_ERROR;
@@ -121,15 +96,6 @@ mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobil
121 return err; 96 return err;
122} 97}
123 98
124/**
125 * Disconnects a mobilebackup2 client from the device and frees up the
126 * mobilebackup2 client data.
127 *
128 * @param client The mobilebackup2 client to disconnect and free.
129 *
130 * @return MOBILEBACKUP2_E_SUCCESS on success, or MOBILEBACKUP2_E_INVALID_ARG
131 * if client is NULL.
132 */
133mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client) 99mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client)
134{ 100{
135 if (!client) 101 if (!client)
@@ -143,18 +109,6 @@ mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client)
143 return err; 109 return err;
144} 110}
145 111
146/**
147 * Sends a backup message plist.
148 *
149 * @param client The connected MobileBackup client to use.
150 * @param message The message to send. This will be inserted into the request
151 * plist as value for MessageName. If this parameter is NULL,
152 * the plist passed in the options parameter will be sent directly.
153 * @param options Additional options as PLIST_DICT to add to the request.
154 * The MessageName key with the value passed in the message parameter
155 * will be inserted into this plist before sending it. This parameter
156 * can be NULL if message is not NULL.
157 */
158mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client, const char *message, plist_t options) 112mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client, const char *message, plist_t options)
159{ 113{
160 if (!client || !client->parent || (!message && !options)) 114 if (!client || !client->parent || (!message && !options))
@@ -253,45 +207,11 @@ leave:
253 return err; 207 return err;
254} 208}
255 209
256/**
257 * Receives a DL* message plist from the device.
258 * This function is a wrapper around device_link_service_receive_message.
259 *
260 * @param client The connected MobileBackup client to use.
261 * @param msg_plist Pointer to a plist that will be set to the contents of the
262 * message plist upon successful return.
263 * @param dlmessage A pointer that will be set to a newly allocated char*
264 * containing the DL* string from the given plist. It is up to the caller
265 * to free the allocated memory. If this parameter is NULL
266 * it will be ignored.
267 *
268 * @return MOBILEBACKUP2_E_SUCCESS if a DL* message was received,
269 * MOBILEBACKUP2_E_INVALID_ARG if client or message is invalid,
270 * MOBILEBACKUP2_E_PLIST_ERROR if the received plist is invalid
271 * or is not a DL* message plist, or MOBILEBACKUP2_E_MUX_ERROR if
272 * receiving from the device failed.
273 */
274mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t client, plist_t *msg_plist, char **dlmessage) 210mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t client, plist_t *msg_plist, char **dlmessage)
275{ 211{
276 return mobilebackup2_error(device_link_service_receive_message(client->parent, msg_plist, dlmessage)); 212 return mobilebackup2_error(device_link_service_receive_message(client->parent, msg_plist, dlmessage));
277} 213}
278 214
279/**
280 * Send binary data to the device.
281 *
282 * @note This function returns MOBILEBACKUP2_E_SUCCESS even if less than the
283 * requested length has been sent. The fourth parameter is required and
284 * must be checked to ensure if the whole data has been sent.
285 *
286 * @param client The MobileBackup client to send to.
287 * @param data Pointer to the data to send
288 * @param length Number of bytes to send
289 * @param bytes Number of bytes actually sent
290 *
291 * @return MOBILEBACKUP2_E_SUCCESS if any data was successfully sent,
292 * MOBILEBACKUP2_E_INVALID_ARG if one of the parameters is invalid,
293 * or MOBILEBACKUP2_E_MUX_ERROR if sending of the data failed.
294 */
295mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, const char *data, uint32_t length, uint32_t *bytes) 215mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, const char *data, uint32_t length, uint32_t *bytes)
296{ 216{
297 if (!client || !client->parent || !data || (length == 0) || !bytes) 217 if (!client || !client->parent || !data || (length == 0) || !bytes)
@@ -318,24 +238,6 @@ mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, cons
318 } 238 }
319} 239}
320 240
321/**
322 * Receive binary from the device.
323 *
324 * @note This function returns MOBILEBACKUP2_E_SUCCESS even if no data
325 * has been received (unless a communication error occured).
326 * The fourth parameter is required and must be checked to know how
327 * many bytes were actually received.
328 *
329 * @param client The MobileBackup client to receive from.
330 * @param data Pointer to a buffer that will be filled with the received data.
331 * @param length Number of bytes to receive. The data buffer needs to be large
332 * enough to store this amount of data.
333 * @paran bytes Number of bytes actually received.
334 *
335 * @return MOBILEBACKUP2_E_SUCCESS if any or no data was received,
336 * MOBILEBACKUP2_E_INVALID_ARG if one of the parameters is invalid,
337 * or MOBILEBACKUP2_E_MUX_ERROR if receiving the data failed.
338 */
339mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes) 241mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes)
340{ 242{
341 if (!client || !client->parent || !data || (length == 0) || !bytes) 243 if (!client || !client->parent || !data || (length == 0) || !bytes)
@@ -363,17 +265,6 @@ mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, c
363 } 265 }
364} 266}
365 267
366/**
367 * Performs the mobilebackup2 protocol version exchange.
368 *
369 * @param client The MobileBackup client to use.
370 * @param local_versions An array of supported versions to send to the remote.
371 * @param count The number of items in local_versions.
372 * @param remote_version Holds the protocol version of the remote on success.
373 *
374 * @return MOBILEBACKUP2_E_SUCCESS on success, or a MOBILEBACKUP2_E_* error
375 * code otherwise.
376 */
377mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version) 268mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version)
378{ 269{
379 int i; 270 int i;
@@ -432,19 +323,6 @@ leave:
432 return err; 323 return err;
433} 324}
434 325
435/**
436 * Send a request to the connected mobilebackup2 service.
437 *
438 * @param client
439 * @param request The request to send to the backup service.
440 * Currently, this is one of "Backup", "Restore", "Info", or "List".
441 * @param target_identifier UDID of the target device.
442 * @param source_identifier UDID of backup data?
443 * @param options Additional options in a plist of type PLIST_DICT.
444 *
445 * @return MOBILEBACKUP2_E_SUCCESS if the request was successfully sent,
446 * or a MOBILEBACKUP2_E_* error value otherwise.
447 */
448mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options) 326mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options)
449{ 327{
450 if (!client || !client->parent || !request || !target_identifier) 328 if (!client || !client->parent || !request || !target_identifier)
@@ -476,18 +354,6 @@ mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client,
476 return err; 354 return err;
477} 355}
478 356
479/**
480 * Sends a DLMessageStatusResponse to the device.
481 *
482 * @param client The MobileBackup client to use.
483 * @param status_code The status code to send.
484 * @param status1 A status message to send. Can be NULL if not required.
485 * @param status2 An additional status plist to attach to the response.
486 * Can be NULL if not required.
487 *
488 * @return MOBILEBACKUP2_E_SUCCESS on success, MOBILEBACKUP2_E_INVALID_ARG
489 * if client is invalid, or another MOBILEBACKUP2_E_* otherwise.
490 */
491mobilebackup2_error_t mobilebackup2_send_status_response(mobilebackup2_client_t client, int status_code, const char *status1, plist_t status2) 357mobilebackup2_error_t mobilebackup2_send_status_response(mobilebackup2_client_t client, int status_code, const char *status1, plist_t status2)
492{ 358{
493 if (!client || !client->parent) 359 if (!client || !client->parent)
diff --git a/src/mobilesync.c b/src/mobilesync.c
index fd64e63..f0fc4b2 100644
--- a/src/mobilesync.c
+++ b/src/mobilesync.c
@@ -65,19 +65,6 @@ static mobilesync_error_t mobilesync_error(device_link_service_error_t err)
65 return MOBILESYNC_E_UNKNOWN_ERROR; 65 return MOBILESYNC_E_UNKNOWN_ERROR;
66} 66}
67 67
68/**
69 * Connects to the mobilesync service on the specified device.
70 *
71 * @param device The device to connect to.
72 * @param service The service descriptor returned by lockdownd_start_service.
73 * @param client Pointer that will be set to a newly allocated
74 * #mobilesync_client_t upon successful return.
75 *
76 * @retval MOBILESYNC_E_SUCCESS on success
77 * @retval MOBILESYNC_E_INVALID_ARG if one or more parameters are invalid
78 * @retval DEVICE_LINK_SERVICE_E_BAD_VERSION if the mobilesync version on
79 * the device is newer.
80 */
81mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service, 68mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service,
82 mobilesync_client_t * client) 69 mobilesync_client_t * client)
83{ 70{
@@ -108,19 +95,6 @@ mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_des
108 return ret; 95 return ret;
109} 96}
110 97
111/**
112 * Starts a new mobilesync service on the specified device and connects to it.
113 *
114 * @param device The device to connect to.
115 * @param client Pointer that will point to a newly allocated
116 * mobilesync_client_t upon successful return. Must be freed using
117 * mobilesync_client_free() after use.
118 * @param label The label to use for communication. Usually the program name.
119 * Pass NULL to disable sending the label in requests to lockdownd.
120 *
121 * @return MOBILESYNC_E_SUCCESS on success, or an MOBILESYNC_E_* error
122 * code otherwise.
123 */
124mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t * client, const char* label) 98mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t * client, const char* label)
125{ 99{
126 mobilesync_error_t err = MOBILESYNC_E_UNKNOWN_ERROR; 100 mobilesync_error_t err = MOBILESYNC_E_UNKNOWN_ERROR;
@@ -128,15 +102,6 @@ mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_
128 return err; 102 return err;
129} 103}
130 104
131/**
132 * Disconnects a mobilesync client from the device and frees up the
133 * mobilesync client data.
134 *
135 * @param client The mobilesync client to disconnect and free.
136 *
137 * @retval MOBILESYNC_E_SUCCESS on success
138 * @retval MOBILESYNC_E_INVALID_ARG if \a client is NULL.
139 */
140mobilesync_error_t mobilesync_client_free(mobilesync_client_t client) 105mobilesync_error_t mobilesync_client_free(mobilesync_client_t client)
141{ 106{
142 if (!client) 107 if (!client)
@@ -147,14 +112,6 @@ mobilesync_error_t mobilesync_client_free(mobilesync_client_t client)
147 return err; 112 return err;
148} 113}
149 114
150/**
151 * Polls the device for mobilesync data.
152 *
153 * @param client The mobilesync client
154 * @param plist A pointer to the location where the plist should be stored
155 *
156 * @return an error code
157 */
158mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t * plist) 115mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t * plist)
159{ 116{
160 if (!client) 117 if (!client)
@@ -163,17 +120,6 @@ mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t * plis
163 return ret; 120 return ret;
164} 121}
165 122
166/**
167 * Sends mobilesync data to the device
168 *
169 * @note This function is low-level and should only be used if you need to send
170 * a new type of message.
171 *
172 * @param client The mobilesync client
173 * @param plist The location of the plist to send
174 *
175 * @return an error code
176 */
177mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist) 123mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist)
178{ 124{
179 if (!client || !plist) 125 if (!client || !plist)
@@ -181,26 +127,6 @@ mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist)
181 return mobilesync_error(device_link_service_send(client->parent, plist)); 127 return mobilesync_error(device_link_service_send(client->parent, plist));
182} 128}
183 129
184/**
185 * Requests starting synchronization of a data class with the device
186 *
187 * @param client The mobilesync client
188 * @param data_class The data class identifier to sync
189 * @param anchors The anchors required to exchange with the device. The anchors
190 * allow the device to tell if the synchronization information on the computer
191 * and device are consistent to determine what sync type is required.
192 * @param computer_data_class_version The version of the data class storage on the computer
193 * @param sync_type A pointer to store the sync type reported by the device_anchor
194 * @param device_data_class_version The version of the data class storage on the device
195 * @param error_description A pointer to store an error message if reported by the device
196 *
197 * @retval MOBILESYNC_E_SUCCESS on success
198 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
199 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
200 * @retval MOBILESYNC_E_SYNC_REFUSED if the device refused to sync
201 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
202 * sync request
203 */
204mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data_class, mobilesync_anchors_t anchors, uint64_t computer_data_class_version, mobilesync_sync_type_t *sync_type, uint64_t *device_data_class_version, char** error_description) 130mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data_class, mobilesync_anchors_t anchors, uint64_t computer_data_class_version, mobilesync_sync_type_t *sync_type, uint64_t *device_data_class_version, char** error_description)
205{ 131{
206 if (!client || client->data_class || !data_class || 132 if (!client || client->data_class || !data_class ||
@@ -327,17 +253,6 @@ mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data
327 return err; 253 return err;
328} 254}
329 255
330/**
331 * Finish a synchronization session of a data class on the device.
332 * A session must have previously been started using mobilesync_start().
333 *
334 * @param client The mobilesync client
335 *
336 * @retval MOBILESYNC_E_SUCCESS on success
337 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
338 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid
339 * form
340 */
341mobilesync_error_t mobilesync_finish(mobilesync_client_t client) 256mobilesync_error_t mobilesync_finish(mobilesync_client_t client)
342{ 257{
343 if (!client || !client->data_class) { 258 if (!client || !client->data_class) {
@@ -423,49 +338,16 @@ static mobilesync_error_t mobilesync_get_records(mobilesync_client_t client, con
423 return err; 338 return err;
424} 339}
425 340
426/**
427 * Requests to receive all records of the currently set data class from the device.
428 * The actually changes are retrieved using mobilesync_receive_changes() after this
429 * request has been successful.
430 *
431 * @param client The mobilesync client
432 *
433 * @retval MOBILESYNC_E_SUCCESS on success
434 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
435 */
436mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client) 341mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client)
437{ 342{
438 return mobilesync_get_records(client, "SDMessageGetAllRecordsFromDevice"); 343 return mobilesync_get_records(client, "SDMessageGetAllRecordsFromDevice");
439} 344}
440 345
441/**
442 * Requests to receive only changed records of the currently set data class from the device.
443 * The actually changes are retrieved using mobilesync_receive_changes() after this
444 * request has been successful.
445 *
446 * @param client The mobilesync client
447 *
448 * @retval MOBILESYNC_E_SUCCESS on success
449 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
450 */
451mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client) 346mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client)
452{ 347{
453 return mobilesync_get_records(client, "SDMessageGetChangesFromDevice"); 348 return mobilesync_get_records(client, "SDMessageGetChangesFromDevice");
454} 349}
455 350
456/**
457 * Receives changed entitites of the currently set data class from the device
458 *
459 * @param client The mobilesync client
460 * @param entities A pointer to store the changed entity records as a PLIST_DICT
461 * @param is_last_record A pointer to store a flag indicating if this submission is the last one
462 * @param actions A pointer to additional flags the device is sending or NULL to ignore
463 *
464 * @retval MOBILESYNC_E_SUCCESS on success
465 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
466 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
467 * session
468 */
469mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions) 351mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions)
470{ 352{
471 if (!client || !client->data_class) { 353 if (!client || !client->data_class) {
@@ -533,17 +415,6 @@ mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_
533 return err; 415 return err;
534} 416}
535 417
536/**
537 * Requests the device to delete all records of the current data class
538 *
539 * @note The operation must be called after starting synchronization.
540 *
541 * @param client The mobilesync client
542 *
543 * @retval MOBILESYNC_E_SUCCESS on success
544 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
545 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
546 */
547mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client) 418mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client)
548{ 419{
549 if (!client || !client->data_class) { 420 if (!client || !client->data_class) {
@@ -613,14 +484,6 @@ mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t cl
613 return err; 484 return err;
614} 485}
615 486
616/**
617 * Acknowledges to the device that the changes have been merged on the computer
618 *
619 * @param client The mobilesync client
620 *
621 * @retval MOBILESYNC_E_SUCCESS on success
622 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
623 */
624mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client) 487mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client)
625{ 488{
626 if (!client || !client->data_class) { 489 if (!client || !client->data_class) {
@@ -655,23 +518,6 @@ static plist_t create_process_changes_message(const char *data_class, plist_t en
655 return msg; 518 return msg;
656} 519}
657 520
658/**
659 * Verifies if the device is ready to receive changes from the computer.
660 * This call changes the synchronization direction so that mobilesync_send_changes()
661 * can be used to send changes to the device.
662 *
663 * @param client The mobilesync client
664 *
665 * @retval MOBILESYNC_E_SUCCESS on success
666 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
667 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
668 * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
669 * not permit this call
670 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
671 * session
672 * @retval MOBILESYNC_E_NOT_READY if the device is not ready to start
673 * receiving any changes
674 */
675mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client) 521mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client)
676{ 522{
677 if (!client || !client->data_class) { 523 if (!client || !client->data_class) {
@@ -739,20 +585,6 @@ mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_cli
739 return err; 585 return err;
740} 586}
741 587
742/**
743 * Sends changed entities of the currently set data class to the device
744 *
745 * @param client The mobilesync client
746 * @param entities The changed entity records as a PLIST_DICT
747 * @param is_last_record A flag indicating if this submission is the last one
748 * @param actions Additional actions for the device created with mobilesync_actions_new()
749 * or NULL if no actions should be passed
750 *
751 * @retval MOBILESYNC_E_SUCCESS on success
752 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid,
753 * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
754 * not permit this call
755 */
756mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions) 588mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions)
757{ 589{
758 if (!client || !client->data_class || !entities) { 590 if (!client || !client->data_class || !entities) {
@@ -781,21 +613,6 @@ mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t e
781 return err; 613 return err;
782} 614}
783 615
784/**
785 * Receives any remapped identifiers reported after the device merged submitted changes.
786 *
787 * @param client The mobilesync client
788 * @param mapping A pointer to an array plist containing a dict of identifier remappings
789 *
790 * @retval MOBILESYNC_E_SUCCESS on success
791 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
792 * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid
793 * form
794 * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
795 * not permit this call
796 * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
797 * session
798 */
799mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping) 616mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping)
800{ 617{
801 if (!client || !client->data_class) { 618 if (!client || !client->data_class) {
@@ -865,15 +682,6 @@ mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plis
865 return err; 682 return err;
866} 683}
867 684
868/**
869 * Cancels a running synchronization session with a device at any time.
870 *
871 * @param client The mobilesync client
872 * @param reason The reason to supply to the device for cancelling
873 *
874 * @retval MOBILESYNC_E_SUCCESS on success
875 * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
876 */
877mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason) 685mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason)
878{ 686{
879 if (!client || !client->data_class || !reason) { 687 if (!client || !client->data_class || !reason) {
@@ -900,15 +708,6 @@ mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* rea
900 return err; 708 return err;
901} 709}
902 710
903/**
904 * Allocates memory for a new anchors struct initialized with the passed anchors.
905 *
906 * @param device_anchor An anchor the device reported the last time or NULL
907 * if none is known yet which for instance is true on first synchronization.
908 * @param computer_anchor An arbitrary string to use as anchor for the computer.
909 *
910 * @return A new #mobilesync_anchors_t struct. Must be freed using mobilesync_anchors_free().
911 */
912mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor) 711mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor)
913{ 712{
914 mobilesync_anchors_t anchors = (mobilesync_anchors_t) malloc(sizeof(mobilesync_anchors)); 713 mobilesync_anchors_t anchors = (mobilesync_anchors_t) malloc(sizeof(mobilesync_anchors));
@@ -926,11 +725,6 @@ mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const cha
926 return anchors; 725 return anchors;
927} 726}
928 727
929/**
930 * Free memory used by anchors.
931 *
932 * @param anchors The anchors to free.
933 */
934void mobilesync_anchors_free(mobilesync_anchors_t anchors) 728void mobilesync_anchors_free(mobilesync_anchors_t anchors)
935{ 729{
936 if (anchors->device_anchor != NULL) { 730 if (anchors->device_anchor != NULL) {
@@ -945,28 +739,11 @@ void mobilesync_anchors_free(mobilesync_anchors_t anchors)
945 anchors = NULL; 739 anchors = NULL;
946} 740}
947 741
948/**
949 * Create a new actions plist to use in mobilesync_send_changes().
950 *
951 * @return A new plist_t of type PLIST_DICT.
952 */
953plist_t mobilesync_actions_new() 742plist_t mobilesync_actions_new()
954{ 743{
955 return plist_new_dict(); 744 return plist_new_dict();
956} 745}
957 746
958/**
959 * Add one or more new key:value pairs to the given actions plist.
960 *
961 * @param actions The actions to modify.
962 * @param ... KEY, VALUE, [KEY, VALUE], NULL
963 *
964 * @note The known keys so far are "SyncDeviceLinkEntityNamesKey" which expects
965 * an array of entity names, followed by a count paramter as well as
966 * "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey" which expects an
967 * integer to use as a boolean value indicating that the device should
968 * link submitted changes and report remapped identifiers.
969 */
970void mobilesync_actions_add(plist_t actions, ...) 747void mobilesync_actions_add(plist_t actions, ...)
971{ 748{
972 if (!actions) 749 if (!actions)
@@ -999,11 +776,6 @@ void mobilesync_actions_add(plist_t actions, ...)
999 va_end(args); 776 va_end(args);
1000} 777}
1001 778
1002/**
1003 * Free actions plist.
1004 *
1005 * @param actions The actions plist to free. Does nothing if NULL is passed.
1006 */
1007void mobilesync_actions_free(plist_t actions) 779void mobilesync_actions_free(plist_t actions)
1008{ 780{
1009 if (actions) { 781 if (actions) {
diff --git a/src/notification_proxy.c b/src/notification_proxy.c
index 1ccda6b..909ede4 100644
--- a/src/notification_proxy.c
+++ b/src/notification_proxy.c
@@ -86,18 +86,6 @@ static np_error_t np_error(property_list_service_error_t err)
86 return NP_E_UNKNOWN_ERROR; 86 return NP_E_UNKNOWN_ERROR;
87} 87}
88 88
89/**
90 * Connects to the notification_proxy on the specified device.
91 *
92 * @param device The device to connect to.
93 * @param service The service descriptor returned by lockdownd_start_service.
94 * @param client Pointer that will be set to a newly allocated np_client_t
95 * upon successful return.
96 *
97 * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when device is NULL,
98 * or NP_E_CONN_FAILED when the connection to the device could not be
99 * established.
100 */
101np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client) 89np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client)
102{ 90{
103 property_list_service_client_t plistclient = NULL; 91 property_list_service_client_t plistclient = NULL;
@@ -116,19 +104,6 @@ np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t servic
116 return NP_E_SUCCESS; 104 return NP_E_SUCCESS;
117} 105}
118 106
119/**
120 * Starts a new notification proxy service on the specified device and connects to it.
121 *
122 * @param device The device to connect to.
123 * @param client Pointer that will point to a newly allocated
124 * np_client_t upon successful return. Must be freed using
125 * np_client_free() after use.
126 * @param label The label to use for communication. Usually the program name.
127 * Pass NULL to disable sending the label in requests to lockdownd.
128 *
129 * @return NP_E_SUCCESS on success, or an NP_E_* error
130 * code otherwise.
131 */
132np_error_t np_client_start_service(idevice_t device, np_client_t* client, const char* label) 107np_error_t np_client_start_service(idevice_t device, np_client_t* client, const char* label)
133{ 108{
134 np_error_t err = NP_E_UNKNOWN_ERROR; 109 np_error_t err = NP_E_UNKNOWN_ERROR;
@@ -136,14 +111,6 @@ np_error_t np_client_start_service(idevice_t device, np_client_t* client, const
136 return err; 111 return err;
137} 112}
138 113
139/**
140 * Disconnects a notification_proxy client from the device and frees up the
141 * notification_proxy client data.
142 *
143 * @param client The notification_proxy client to disconnect and free.
144 *
145 * @return NP_E_SUCCESS on success, or NP_E_INVALID_ARG when client is NULL.
146 */
147np_error_t np_client_free(np_client_t client) 114np_error_t np_client_free(np_client_t client)
148{ 115{
149 if (!client) 116 if (!client)
@@ -161,14 +128,6 @@ np_error_t np_client_free(np_client_t client)
161 return NP_E_SUCCESS; 128 return NP_E_SUCCESS;
162} 129}
163 130
164/**
165 * Sends a notification to the device's notification_proxy.
166 *
167 * @param client The client to send to
168 * @param notification The notification message to send
169 *
170 * @return NP_E_SUCCESS on success, or an error returned by np_plist_send
171 */
172np_error_t np_post_notification(np_client_t client, const char *notification) 131np_error_t np_post_notification(np_client_t client, const char *notification)
173{ 132{
174 if (!client || !notification) { 133 if (!client || !notification) {
@@ -220,15 +179,6 @@ np_error_t np_post_notification(np_client_t client, const char *notification)
220 return res; 179 return res;
221} 180}
222 181
223/**
224 * Tells the device to send a notification on the specified event.
225 *
226 * @param client The client to send to
227 * @param notification The notifications that should be observed.
228 *
229 * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client or
230 * notification are NULL, or an error returned by np_plist_send.
231 */
232np_error_t np_observe_notification( np_client_t client, const char *notification ) 182np_error_t np_observe_notification( np_client_t client, const char *notification )
233{ 183{
234 if (!client || !notification) { 184 if (!client || !notification) {
@@ -250,17 +200,6 @@ np_error_t np_observe_notification( np_client_t client, const char *notification
250 return res; 200 return res;
251} 201}
252 202
253/**
254 * Tells the device to send a notification on specified events.
255 *
256 * @param client The client to send to
257 * @param notification_spec Specification of the notifications that should be
258 * observed. This is expected to be an array of const char* that MUST have a
259 * terminating NULL entry.
260 *
261 * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client is null,
262 * or an error returned by np_observe_notification.
263 */
264np_error_t np_observe_notifications(np_client_t client, const char **notification_spec) 203np_error_t np_observe_notifications(np_client_t client, const char **notification_spec)
265{ 204{
266 int i = 0; 205 int i = 0;
@@ -390,28 +329,6 @@ void* np_notifier( void* arg )
390 return NULL; 329 return NULL;
391} 330}
392 331
393/**
394 * This function allows an application to define a callback function that will
395 * be called when a notification has been received.
396 * It will start a thread that polls for notifications and calls the callback
397 * function if a notification has been received.
398 * In case of an error condition when polling for notifications - e.g. device
399 * disconnect - the thread will call the callback function with an empty
400 * notification "" and terminate itself.
401 *
402 * @param client the NP client
403 * @param notify_cb pointer to a callback function or NULL to de-register a
404 * previously set callback function.
405 * @param user_data Pointer that will be passed to the callback function as
406 * user data. If notify_cb is NULL, this parameter is ignored.
407 *
408 * @note Only one callback function can be registered at the same time;
409 * any previously set callback function will be removed automatically.
410 *
411 * @return NP_E_SUCCESS when the callback was successfully registered,
412 * NP_E_INVALID_ARG when client is NULL, or NP_E_UNKNOWN_ERROR when
413 * the callback thread could no be created.
414 */
415np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb, void *user_data ) 332np_error_t np_set_notify_callback( np_client_t client, np_notify_cb_t notify_cb, void *user_data )
416{ 333{
417 if (!client) 334 if (!client)
diff --git a/src/restore.c b/src/restore.c
index 6339270..2a025e8 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -89,14 +89,6 @@ static void plist_dict_add_label(plist_t plist, const char *label)
89 } 89 }
90} 90}
91 91
92/**
93 * Closes the restored client session if one is running and frees up the
94 * restored_client struct.
95 *
96 * @param client The restore client
97 *
98 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
99 */
100restored_error_t restored_client_free(restored_client_t client) 92restored_error_t restored_client_free(restored_client_t client)
101{ 93{
102 if (!client) 94 if (!client)
@@ -127,13 +119,6 @@ restored_error_t restored_client_free(restored_client_t client)
127 return ret; 119 return ret;
128} 120}
129 121
130/**
131 * Sets the label to send for requests to restored.
132 *
133 * @param client The restore client
134 * @param label The label to set or NULL to disable sending a label
135 *
136 */
137void restored_client_set_label(restored_client_t client, const char *label) 122void restored_client_set_label(restored_client_t client, const char *label)
138{ 123{
139 if (client) { 124 if (client) {
@@ -144,15 +129,6 @@ void restored_client_set_label(restored_client_t client, const char *label)
144 } 129 }
145} 130}
146 131
147/**
148 * Receives a plist from restored.
149 *
150 * @param client The restored client
151 * @param plist The plist to store the received data
152 *
153 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client or
154 * plist is NULL
155 */
156restored_error_t restored_receive(restored_client_t client, plist_t *plist) 132restored_error_t restored_receive(restored_client_t client, plist_t *plist)
157{ 133{
158 if (!client || !plist || (plist && *plist)) 134 if (!client || !plist || (plist && *plist))
@@ -172,18 +148,6 @@ restored_error_t restored_receive(restored_client_t client, plist_t *plist)
172 return ret; 148 return ret;
173} 149}
174 150
175/**
176 * Sends a plist to restored.
177 *
178 * @note This function is low-level and should only be used if you need to send
179 * a new type of message.
180 *
181 * @param client The restored client
182 * @param plist The plist to send
183 *
184 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client or
185 * plist is NULL
186 */
187restored_error_t restored_send(restored_client_t client, plist_t plist) 151restored_error_t restored_send(restored_client_t client, plist_t plist)
188{ 152{
189 if (!client || !plist) 153 if (!client || !plist)
@@ -199,16 +163,6 @@ restored_error_t restored_send(restored_client_t client, plist_t plist)
199 return ret; 163 return ret;
200} 164}
201 165
202/**
203 * Query the type of the service daemon. Depending on whether the device is
204 * queried in normal mode or restore mode, different types will be returned.
205 *
206 * @param client The restored client
207 * @param type The type returned by the service daemon. Pass NULL to ignore.
208 * @param version The restore protocol version. Pass NULL to ignore.
209 *
210 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
211 */
212restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version) 166restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version)
213{ 167{
214 if (!client) 168 if (!client)
@@ -268,15 +222,6 @@ restored_error_t restored_query_type(restored_client_t client, char **type, uint
268 return ret; 222 return ret;
269} 223}
270 224
271/**
272 * Queries a value from the device specified by a key.
273 *
274 * @param client An initialized restored client.
275 * @param key The key name to request
276 * @param value A plist node representing the result value node
277 *
278 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL, RESTORE_E_PLIST_ERROR if value for key can't be found
279 */
280restored_error_t restored_query_value(restored_client_t client, const char *key, plist_t *value) 225restored_error_t restored_query_value(restored_client_t client, const char *key, plist_t *value)
281{ 226{
282 if (!client || !key) 227 if (!client || !key)
@@ -319,16 +264,7 @@ restored_error_t restored_query_value(restored_client_t client, const char *key,
319 return ret; 264 return ret;
320} 265}
321 266
322/** 267restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value)
323 * Retrieves a value from information plist specified by a key.
324 *
325 * @param client An initialized restored client.
326 * @param key The key name to request or NULL to query for all keys
327 * @param value A plist node representing the result value node
328 *
329 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL, RESTORE_E_PLIST_ERROR if value for key can't be found
330 */
331restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value)
332{ 268{
333 if (!client || !value || (value && *value)) 269 if (!client || !value || (value && *value))
334 return RESTORE_E_INVALID_ARG; 270 return RESTORE_E_INVALID_ARG;
@@ -355,15 +291,6 @@ restored_error_t restored_get_value(restored_client_t client, const char *key, p
355 return ret; 291 return ret;
356} 292}
357 293
358/**
359 * Creates a new restored client for the device.
360 *
361 * @param device The device to create a restored client for
362 * @param client The pointer to the location of the new restored_client
363 * @param label The label to use for communication. Usually the program name.
364 *
365 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL
366 */
367restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label) 294restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label)
368{ 295{
369 if (!client) 296 if (!client)
@@ -405,14 +332,6 @@ restored_error_t restored_client_new(idevice_t device, restored_client_t *client
405 return ret; 332 return ret;
406} 333}
407 334
408/**
409 * Sends the Goodbye request to restored signaling the end of communication.
410 *
411 * @param client The restore client
412 *
413 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG when client is NULL,
414 * RESTORE_E_PLIST_ERROR if the device did not acknowledge the request
415 */
416restored_error_t restored_goodbye(restored_client_t client) 335restored_error_t restored_goodbye(restored_client_t client)
417{ 336{
418 if (!client) 337 if (!client)
@@ -445,16 +364,6 @@ restored_error_t restored_goodbye(restored_client_t client)
445 return ret; 364 return ret;
446} 365}
447 366
448/**
449 * Requests to start a restore and retrieve it's port on success.
450 *
451 * @param client The restored client
452 * @param options PLIST_DICT with options for the restore process or NULL
453 * @param version the restore protocol version, see restored_query_type()
454 *
455 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG if a parameter
456 * is NULL, RESTORE_E_START_RESTORE_FAILED if the request fails
457 */
458restored_error_t restored_start_restore(restored_client_t client, plist_t options, uint64_t version) 367restored_error_t restored_start_restore(restored_client_t client, plist_t options, uint64_t version)
459{ 368{
460 if (!client) 369 if (!client)
@@ -479,14 +388,6 @@ restored_error_t restored_start_restore(restored_client_t client, plist_t option
479 return ret; 388 return ret;
480} 389}
481 390
482/**
483 * Requests device to reboot.
484 *
485 * @param client The restored client
486 *
487 * @return RESTORE_E_SUCCESS on success, NP_E_INVALID_ARG if a parameter
488 * is NULL
489 */
490restored_error_t restored_reboot(restored_client_t client) 391restored_error_t restored_reboot(restored_client_t client)
491{ 392{
492 if (!client) 393 if (!client)
diff --git a/src/sbservices.c b/src/sbservices.c
index 1d043f1..ea12e35 100644
--- a/src/sbservices.c
+++ b/src/sbservices.c
@@ -76,17 +76,6 @@ static sbservices_error_t sbservices_error(property_list_service_error_t err)
76 return SBSERVICES_E_UNKNOWN_ERROR; 76 return SBSERVICES_E_UNKNOWN_ERROR;
77} 77}
78 78
79/**
80 * Connects to the springboardservices service on the specified device.
81 *
82 * @param device The device to connect to.
83 * @param service The service descriptor returned by lockdownd_start_service.
84 * @param client Pointer that will point to a newly allocated
85 * sbservices_client_t upon successful return.
86 *
87 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
88 * client is NULL, or an SBSERVICES_E_* error code otherwise.
89 */
90sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client) 79sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client)
91{ 80{
92 property_list_service_client_t plistclient = NULL; 81 property_list_service_client_t plistclient = NULL;
@@ -103,19 +92,6 @@ sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_des
103 return SBSERVICES_E_SUCCESS; 92 return SBSERVICES_E_SUCCESS;
104} 93}
105 94
106/**
107 * Starts a new sbservices service on the specified device and connects to it.
108 *
109 * @param device The device to connect to.
110 * @param client Pointer that will point to a newly allocated
111 * sbservices_client_t upon successful return. Must be freed using
112 * sbservices_client_free() after use.
113 * @param label The label to use for communication. Usually the program name.
114 * Pass NULL to disable sending the label in requests to lockdownd.
115 *
116 * @return SBSERVICES_E_SUCCESS on success, or an SBSERVICES_E_* error
117 * code otherwise.
118 */
119sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_client_t * client, const char* label) 95sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_client_t * client, const char* label)
120{ 96{
121 sbservices_error_t err = SBSERVICES_E_UNKNOWN_ERROR; 97 sbservices_error_t err = SBSERVICES_E_UNKNOWN_ERROR;
@@ -123,15 +99,6 @@ sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_
123 return err; 99 return err;
124} 100}
125 101
126/**
127 * Disconnects an sbservices client from the device and frees up the
128 * sbservices client data.
129 *
130 * @param client The sbservices client to disconnect and free.
131 *
132 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
133 * client is NULL, or an SBSERVICES_E_* error code otherwise.
134 */
135sbservices_error_t sbservices_client_free(sbservices_client_t client) 102sbservices_error_t sbservices_client_free(sbservices_client_t client)
136{ 103{
137 if (!client) 104 if (!client)
@@ -145,20 +112,6 @@ sbservices_error_t sbservices_client_free(sbservices_client_t client)
145 return err; 112 return err;
146} 113}
147 114
148/**
149 * Gets the icon state of the connected device.
150 *
151 * @param client The connected sbservices client to use.
152 * @param state Pointer that will point to a newly allocated plist containing
153 * the current icon state. It is up to the caller to free the memory.
154 * @param format_version A string to be passed as formatVersion along with
155 * the request, or NULL if no formatVersion should be passed. This is only
156 * supported since iOS 4.0 so for older firmware versions this must be set
157 * to NULL.
158 *
159 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
160 * client or state is invalid, or an SBSERVICES_E_* error code otherwise.
161 */
162sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version) 115sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version)
163{ 116{
164 if (!client || !client->parent || !state) 117 if (!client || !client->parent || !state)
@@ -199,15 +152,6 @@ leave_unlock:
199 return res; 152 return res;
200} 153}
201 154
202/**
203 * Sets the icon state of the connected device.
204 *
205 * @param client The connected sbservices client to use.
206 * @param newstate A plist containing the new iconstate.
207 *
208 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
209 * client or newstate is NULL, or an SBSERVICES_E_* error code otherwise.
210 */
211sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate) 155sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate)
212{ 156{
213 if (!client || !client->parent || !newstate) 157 if (!client || !client->parent || !newstate)
@@ -234,21 +178,6 @@ sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t
234 return res; 178 return res;
235} 179}
236 180
237/**
238 * Get the icon of the specified app as PNG data.
239 *
240 * @param client The connected sbservices client to use.
241 * @param bundleId The bundle identifier of the app to retrieve the icon for.
242 * @param pngdata Pointer that will point to a newly allocated buffer
243 * containing the PNG data upon successful return. It is up to the caller
244 * to free the memory.
245 * @param pngsize Pointer to a uint64_t that will be set to the size of the
246 * buffer pngdata points to upon successful return.
247 *
248 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
249 * client, bundleId, or pngdata are invalid, or an SBSERVICES_E_* error
250 * code otherwise.
251 */
252sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize) 181sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize)
253{ 182{
254 if (!client || !client->parent || !bundleId || !pngdata) 183 if (!client || !client->parent || !bundleId || !pngdata)
@@ -286,15 +215,6 @@ leave_unlock:
286 return res; 215 return res;
287} 216}
288 217
289/**
290 * Gets the interface orientation of the device.
291 *
292 * @param client The connected sbservices client to use.
293 * @param interface_orientation The interface orientation upon successful return.
294 *
295 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
296 * client or state is invalid, or an SBSERVICES_E_* error code otherwise.
297 */
298sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation) 218sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation)
299{ 219{
300 if (!client || !client->parent || !interface_orientation) 220 if (!client || !client->parent || !interface_orientation)
@@ -333,20 +253,6 @@ leave_unlock:
333 return res; 253 return res;
334} 254}
335 255
336/**
337 * Get the home screen wallpaper as PNG data.
338 *
339 * @param client The connected sbservices client to use.
340 * @param pngdata Pointer that will point to a newly allocated buffer
341 * containing the PNG data upon successful return. It is up to the caller
342 * to free the memory.
343 * @param pngsize Pointer to a uint64_t that will be set to the size of the
344 * buffer pngdata points to upon successful return.
345 *
346 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
347 * client or pngdata are invalid, or an SBSERVICES_E_* error
348 * code otherwise.
349 */
350sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize) 256sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize)
351{ 257{
352 if (!client || !client->parent || !pngdata) 258 if (!client || !client->parent || !pngdata)
diff --git a/src/screenshotr.c b/src/screenshotr.c
index a1b5759..e92fe9f 100644
--- a/src/screenshotr.c
+++ b/src/screenshotr.c
@@ -58,21 +58,6 @@ static screenshotr_error_t screenshotr_error(device_link_service_error_t err)
58 return SCREENSHOTR_E_UNKNOWN_ERROR; 58 return SCREENSHOTR_E_UNKNOWN_ERROR;
59} 59}
60 60
61/**
62 * Connects to the screenshotr service on the specified device.
63 *
64 * @param device The device to connect to.
65 * @param service The service descriptor returned by lockdownd_start_service.
66 * @param client Pointer that will be set to a newly allocated
67 * screenshotr_client_t upon successful return.
68 *
69 * @note This service is only available if a developer disk image has been
70 * mounted.
71 *
72 * @return SCREENSHOTR_E_SUCCESS on success, SCREENSHOTR_E_INVALID ARG if one
73 * or more parameters are invalid, or SCREENSHOTR_E_CONN_FAILED if the
74 * connection to the device could not be established.
75 */
76screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t service, 61screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t service,
77 screenshotr_client_t * client) 62 screenshotr_client_t * client)
78{ 63{
@@ -101,19 +86,6 @@ screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_d
101 return ret; 86 return ret;
102} 87}
103 88
104/**
105 * Starts a new screenshotr service on the specified device and connects to it.
106 *
107 * @param device The device to connect to.
108 * @param client Pointer that will point to a newly allocated
109 * screenshotr_client_t upon successful return. Must be freed using
110 * screenshotr_client_free() after use.
111 * @param label The label to use for communication. Usually the program name.
112 * Pass NULL to disable sending the label in requests to lockdownd.
113 *
114 * @return SCREENSHOTR_E_SUCCESS on success, or an SCREENSHOTR_E_* error
115 * code otherwise.
116 */
117screenshotr_error_t screenshotr_client_start_service(idevice_t device, screenshotr_client_t * client, const char* label) 89screenshotr_error_t screenshotr_client_start_service(idevice_t device, screenshotr_client_t * client, const char* label)
118{ 90{
119 screenshotr_error_t err = SCREENSHOTR_E_UNKNOWN_ERROR; 91 screenshotr_error_t err = SCREENSHOTR_E_UNKNOWN_ERROR;
@@ -121,15 +93,6 @@ screenshotr_error_t screenshotr_client_start_service(idevice_t device, screensho
121 return err; 93 return err;
122} 94}
123 95
124/**
125 * Disconnects a screenshotr client from the device and frees up the
126 * screenshotr client data.
127 *
128 * @param client The screenshotr client to disconnect and free.
129 *
130 * @return SCREENSHOTR_E_SUCCESS on success, or SCREENSHOTR_E_INVALID_ARG
131 * if client is NULL.
132 */
133screenshotr_error_t screenshotr_client_free(screenshotr_client_t client) 96screenshotr_error_t screenshotr_client_free(screenshotr_client_t client)
134{ 97{
135 if (!client) 98 if (!client)
@@ -140,20 +103,6 @@ screenshotr_error_t screenshotr_client_free(screenshotr_client_t client)
140 return err; 103 return err;
141} 104}
142 105
143/**
144 * Get a screen shot from the connected device.
145 *
146 * @param client The connection screenshotr service client.
147 * @param imgdata Pointer that will point to a newly allocated buffer
148 * containing TIFF image data upon successful return. It is up to the
149 * caller to free the memory.
150 * @param imgsize Pointer to a uint64_t that will be set to the size of the
151 * buffer imgdata points to upon successful return.
152 *
153 * @return SCREENSHOTR_E_SUCCESS on success, SCREENSHOTR_E_INVALID_ARG if
154 * one or more parameters are invalid, or another error code if an
155 * error occured.
156 */
157screenshotr_error_t screenshotr_take_screenshot(screenshotr_client_t client, char **imgdata, uint64_t *imgsize) 106screenshotr_error_t screenshotr_take_screenshot(screenshotr_client_t client, char **imgdata, uint64_t *imgsize)
158{ 107{
159 if (!client || !client->parent || !imgdata) 108 if (!client || !client->parent || !imgdata)
diff --git a/src/service.c b/src/service.c
index e8444b8..701c8b4 100644
--- a/src/service.c
+++ b/src/service.c
@@ -52,18 +52,6 @@ static service_error_t idevice_to_service_error(idevice_error_t err)
52 return SERVICE_E_UNKNOWN_ERROR; 52 return SERVICE_E_UNKNOWN_ERROR;
53} 53}
54 54
55/**
56 * Creates a new service for the specified service descriptor.
57 *
58 * @param device The device to connect to.
59 * @param service The service descriptor returned by lockdownd_start_service.
60 * @param client Pointer that will be set to a newly allocated
61 * service_client_t upon successful return.
62 *
63 * @return SERVICE_E_SUCCESS on success,
64 * SERVICE_E_INVALID_ARG when one of the arguments is invalid,
65 * or SERVICE_E_MUX_ERROR when connecting to the device failed.
66 */
67service_error_t service_client_new(idevice_t device, lockdownd_service_descriptor_t service, service_client_t *client) 55service_error_t service_client_new(idevice_t device, lockdownd_service_descriptor_t service, service_client_t *client)
68{ 56{
69 if (!device || !service || service->port == 0 || !client || *client) 57 if (!device || !service || service->port == 0 || !client || *client)
@@ -88,21 +76,6 @@ service_error_t service_client_new(idevice_t device, lockdownd_service_descripto
88 return SERVICE_E_SUCCESS; 76 return SERVICE_E_SUCCESS;
89} 77}
90 78
91/**
92 * Starts a new service on the specified device with given name and
93 * connects to it.
94 *
95 * @param device The device to connect to.
96 * @param service_name The name of the service to start.
97 * @param client Pointer that will point to a newly allocated service_client_t
98 * upon successful return. Must be freed using service_client_free() after
99 * use.
100 * @param label The label to use for communication. Usually the program name.
101 * Pass NULL to disable sending the label in requests to lockdownd.
102 *
103 * @return SERVICE_E_SUCCESS on success, or a SERVICE_E_* error code
104 * otherwise.
105 */
106service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int16_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int16_t *error_code) 79service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int16_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int16_t *error_code)
107{ 80{
108 *client = NULL; 81 *client = NULL;
@@ -142,15 +115,6 @@ service_error_t service_client_factory_start_service(idevice_t device, const cha
142 return (ec == SERVICE_E_SUCCESS) ? SERVICE_E_SUCCESS : SERVICE_E_START_SERVICE_ERROR; 115 return (ec == SERVICE_E_SUCCESS) ? SERVICE_E_SUCCESS : SERVICE_E_START_SERVICE_ERROR;
143} 116}
144 117
145/**
146 * Frees a service instance.
147 *
148 * @param client The service instance to free.
149 *
150 * @return SERVICE_E_SUCCESS on success,
151 * SERVICE_E_INVALID_ARG when client is invalid, or a
152 * SERVICE_E_UNKNOWN_ERROR when another error occured.
153 */
154service_error_t service_client_free(service_client_t client) 118service_error_t service_client_free(service_client_t client)
155{ 119{
156 if (!client) 120 if (!client)
@@ -164,19 +128,6 @@ service_error_t service_client_free(service_client_t client)
164 return err; 128 return err;
165} 129}
166 130
167/**
168 * Sends data using the given service client.
169 *
170 * @param client The service client to use for sending.
171 * @param data Data to send
172 * @param size Size of the data to send
173 * @param sent Number of bytes sent (can be NULL to ignore)
174 *
175 * @return SERVICE_E_SUCCESS on success,
176 * SERVICE_E_INVALID_ARG when one or more parameters are
177 * invalid, or SERVICE_E_UNKNOWN_ERROR when an unspecified
178 * error occurs.
179 */
180service_error_t service_send(service_client_t client, const char* data, uint32_t size, uint32_t *sent) 131service_error_t service_send(service_client_t client, const char* data, uint32_t size, uint32_t *sent)
181{ 132{
182 service_error_t res = SERVICE_E_UNKNOWN_ERROR; 133 service_error_t res = SERVICE_E_UNKNOWN_ERROR;
@@ -198,21 +149,6 @@ service_error_t service_send(service_client_t client, const char* data, uint32_t
198 return res; 149 return res;
199} 150}
200 151
201/**
202 * Receives data using the given service client with specified timeout.
203 *
204 * @param client The service client to use for receiving
205 * @param data Buffer that will be filled with the data received
206 * @param size Number of bytes to receive
207 * @param received Number of bytes received (can be NULL to ignore)
208 * @param timeout Maximum time in milliseconds to wait for data.
209 *
210 * @return SERVICE_E_SUCCESS on success,
211 * SERVICE_E_INVALID_ARG when one or more parameters are
212 * invalid, SERVICE_E_MUX_ERROR when a communication error
213 * occurs, or SERVICE_E_UNKNOWN_ERROR when an unspecified
214 * error occurs.
215 */
216service_error_t service_receive_with_timeout(service_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout) 152service_error_t service_receive_with_timeout(service_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout)
217{ 153{
218 service_error_t res = SERVICE_E_UNKNOWN_ERROR; 154 service_error_t res = SERVICE_E_UNKNOWN_ERROR;
@@ -233,35 +169,11 @@ service_error_t service_receive_with_timeout(service_client_t client, char* data
233 return res; 169 return res;
234} 170}
235 171
236/**
237 * Receives data using the given service client.
238 *
239 * @param client The service client to use for receiving
240 * @param data Buffer that will be filled with the data received
241 * @param size Number of bytes to receive
242 * @param received Number of bytes received (can be NULL to ignore)
243 *
244 * @return SERVICE_E_SUCCESS on success,
245 * SERVICE_E_INVALID_ARG when one or more parameters are
246 * invalid, SERVICE_E_MUX_ERROR when a communication error
247 * occurs, or SERVICE_E_UNKNOWN_ERROR when an unspecified
248 * error occurs.
249 */
250service_error_t service_receive(service_client_t client, char* data, uint32_t size, uint32_t *received) 172service_error_t service_receive(service_client_t client, char* data, uint32_t size, uint32_t *received)
251{ 173{
252 return service_receive_with_timeout(client, data, size, received, 10000); 174 return service_receive_with_timeout(client, data, size, received, 10000);
253} 175}
254 176
255/**
256 * Enable SSL for the given service client.
257 *
258 * @param client The connected service client for that SSL should be enabled.
259 *
260 * @return SERVICE_E_SUCCESS on success,
261 * SERVICE_E_INVALID_ARG if client or client->connection is
262 * NULL, SERVICE_E_SSL_ERROR when SSL could not be enabled,
263 * or SERVICE_E_UNKNOWN_ERROR otherwise.
264 */
265service_error_t service_enable_ssl(service_client_t client) 177service_error_t service_enable_ssl(service_client_t client)
266{ 178{
267 if (!client || !client->connection) 179 if (!client || !client->connection)
@@ -269,15 +181,6 @@ service_error_t service_enable_ssl(service_client_t client)
269 return idevice_to_service_error(idevice_connection_enable_ssl(client->connection)); 181 return idevice_to_service_error(idevice_connection_enable_ssl(client->connection));
270} 182}
271 183
272/**
273 * Disable SSL for the given service client.
274 *
275 * @param client The connected service client for that SSL should be disabled.
276 *
277 * @return SERVICE_E_SUCCESS on success,
278 * SERVICE_E_INVALID_ARG if client or client->connection is
279 * NULL, or SERVICE_E_UNKNOWN_ERROR otherwise.
280 */
281service_error_t service_disable_ssl(service_client_t client) 184service_error_t service_disable_ssl(service_client_t client)
282{ 185{
283 if (!client || !client->connection) 186 if (!client || !client->connection)
diff --git a/src/syslog_relay.c b/src/syslog_relay.c
index b908153..a636e6e 100644
--- a/src/syslog_relay.c
+++ b/src/syslog_relay.c
@@ -61,18 +61,6 @@ static syslog_relay_error_t syslog_relay_error(service_error_t err)
61 return SYSLOG_RELAY_E_UNKNOWN_ERROR; 61 return SYSLOG_RELAY_E_UNKNOWN_ERROR;
62} 62}
63 63
64/**
65 * Connects to the syslog_relay service on the specified device.
66 *
67 * @param device The device to connect to.
68 * @param service The service descriptor returned by lockdownd_start_service.
69 * @param client Pointer that will point to a newly allocated
70 * syslog_relay_client_t upon successful return. Must be freed using
71 * syslog_relay_client_free() after use.
72 *
73 * @return SYSLOG_RELAY_E_SUCCESS on success, SYSLOG_RELAY_E_INVALID_ARG when
74 * client is NULL, or an SYSLOG_RELAY_E_* error code otherwise.
75 */
76syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, syslog_relay_client_t * client) 64syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, syslog_relay_client_t * client)
77{ 65{
78 *client = NULL; 66 *client = NULL;
@@ -101,19 +89,6 @@ syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service
101 return 0; 89 return 0;
102} 90}
103 91
104/**
105 * Starts a new syslog_relay service on the specified device and connects to it.
106 *
107 * @param device The device to connect to.
108 * @param client Pointer that will point to a newly allocated
109 * syslog_relay_client_t upon successful return. Must be freed using
110 * syslog_relay_client_free() after use.
111 * @param label The label to use for communication. Usually the program name.
112 * Pass NULL to disable sending the label in requests to lockdownd.
113 *
114 * @return SYSLOG_RELAY_E_SUCCESS on success, or an SYSLOG_RELAY_E_* error
115 * code otherwise.
116 */
117syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_relay_client_t * client, const char* label) 92syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_relay_client_t * client, const char* label)
118{ 93{
119 syslog_relay_error_t err = SYSLOG_RELAY_E_UNKNOWN_ERROR; 94 syslog_relay_error_t err = SYSLOG_RELAY_E_UNKNOWN_ERROR;
@@ -121,15 +96,6 @@ syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_
121 return err; 96 return err;
122} 97}
123 98
124/**
125 * Disconnects a syslog_relay client from the device and frees up the
126 * syslog_relay client data.
127 *
128 * @param client The syslog_relay client to disconnect and free.
129 *
130 * @return SYSLOG_RELAY_E_SUCCESS on success, SYSLOG_RELAY_E_INVALID_ARG when
131 * client is NULL, or an SYSLOG_RELAY_E_* error code otherwise.
132 */
133syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client) 99syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client)
134{ 100{
135 if (!client) 101 if (!client)
@@ -146,38 +112,11 @@ syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client)
146 return err; 112 return err;
147} 113}
148 114
149/**
150 * Receives data from the service.
151 *
152 * @param client The syslog_relay client
153 * @param data Buffer that will be filled with the data received
154 * @param size Number of bytes to receive
155 * @param received Number of bytes received (can be NULL to ignore)
156 * @param timeout Maximum time in milliseconds to wait for data.
157 *
158 * @return SYSLOG_RELAY_E_SUCCESS on success,
159 * SYSLOG_RELAY_E_INVALID_ARG when client or plist is NULL
160 */
161syslog_relay_error_t syslog_relay_receive(syslog_relay_client_t client, char* data, uint32_t size, uint32_t *received) 115syslog_relay_error_t syslog_relay_receive(syslog_relay_client_t client, char* data, uint32_t size, uint32_t *received)
162{ 116{
163 return syslog_relay_receive_with_timeout(client, data, size, received, 1000); 117 return syslog_relay_receive_with_timeout(client, data, size, received, 1000);
164} 118}
165 119
166/**
167 * Receives data using the given syslog_relay client with specified timeout.
168 *
169 * @param client The syslog_relay client to use for receiving
170 * @param data Buffer that will be filled with the data received
171 * @param size Number of bytes to receive
172 * @param received Number of bytes received (can be NULL to ignore)
173 * @param timeout Maximum time in milliseconds to wait for data.
174 *
175 * @return SYSLOG_RELAY_E_SUCCESS on success,
176 * SYSLOG_RELAY_E_INVALID_ARG when one or more parameters are
177 * invalid, SYSLOG_RELAY_E_MUX_ERROR when a communication error
178 * occurs, or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
179 * error occurs.
180 */
181syslog_relay_error_t syslog_relay_receive_with_timeout(syslog_relay_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout) 120syslog_relay_error_t syslog_relay_receive_with_timeout(syslog_relay_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout)
182{ 121{
183 syslog_relay_error_t res = SYSLOG_RELAY_E_UNKNOWN_ERROR; 122 syslog_relay_error_t res = SYSLOG_RELAY_E_UNKNOWN_ERROR;
@@ -232,20 +171,6 @@ void *syslog_relay_worker(void *arg)
232 return NULL; 171 return NULL;
233} 172}
234 173
235/**
236 * Starts capturing the syslog of the device using a callback.
237 *
238 * Use syslog_relay_stop_capture() to stop receiving the syslog.
239 *
240 * @param client The syslog_relay client to use
241 * @param callback Callback to receive each character from the syslog.
242 * @param user_data Custom pointer passed to the callback function.
243 *
244 * @return SYSLOG_RELAY_E_SUCCESS on success,
245 * SYSLOG_RELAY_E_INVALID_ARG when one or more parameters are
246 * invalid or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
247 * error occurs or a syslog capture has already been started.
248 */
249syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data) 174syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data)
250{ 175{
251 if (!client || !callback) 176 if (!client || !callback)
@@ -273,18 +198,6 @@ syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, sy
273 return res; 198 return res;
274} 199}
275 200
276/**
277 * Stops capturing the syslog of the device.
278 *
279 * Use syslog_relay_start_capture() to start receiving the syslog.
280 *
281 * @param client The syslog_relay client to use
282 *
283 * @return SYSLOG_RELAY_E_SUCCESS on success,
284 * SYSLOG_RELAY_E_INVALID_ARG when one or more parameters are
285 * invalid or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
286 * error occurs or a syslog capture has already been started.
287 */
288syslog_relay_error_t syslog_relay_stop_capture(syslog_relay_client_t client) 201syslog_relay_error_t syslog_relay_stop_capture(syslog_relay_client_t client)
289{ 202{
290 if (client->worker) { 203 if (client->worker) {
diff --git a/src/webinspector.c b/src/webinspector.c
index 14a8bd8..31c5b2c 100644
--- a/src/webinspector.c
+++ b/src/webinspector.c
@@ -58,18 +58,6 @@ static webinspector_error_t webinspector_error(property_list_service_error_t err
58 return WEBINSPECTOR_E_UNKNOWN_ERROR; 58 return WEBINSPECTOR_E_UNKNOWN_ERROR;
59} 59}
60 60
61/**
62 * Connects to the webinspector service on the specified device.
63 *
64 * @param device The device to connect to.
65 * @param service The service descriptor returned by lockdownd_start_service.
66 * @param client Pointer that will point to a newly allocated
67 * webinspector_client_t upon successful return. Must be freed using
68 * webinspector_client_free() after use.
69 *
70 * @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when
71 * client is NULL, or an WEBINSPECTOR_E_* error code otherwise.
72 */
73webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client) 61webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client)
74{ 62{
75 *client = NULL; 63 *client = NULL;
@@ -97,19 +85,6 @@ webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service
97 return 0; 85 return 0;
98} 86}
99 87
100/**
101 * Starts a new webinspector service on the specified device and connects to it.
102 *
103 * @param device The device to connect to.
104 * @param client Pointer that will point to a newly allocated
105 * webinspector_client_t upon successful return. Must be freed using
106 * webinspector_client_free() after use.
107 * @param label The label to use for communication. Usually the program name.
108 * Pass NULL to disable sending the label in requests to lockdownd.
109 *
110 * @return WEBINSPECTOR_E_SUCCESS on success, or an WEBINSPECTOR_E_* error
111 * code otherwise.
112 */
113webinspector_error_t webinspector_client_start_service(idevice_t device, webinspector_client_t * client, const char* label) 88webinspector_error_t webinspector_client_start_service(idevice_t device, webinspector_client_t * client, const char* label)
114{ 89{
115 webinspector_error_t err = WEBINSPECTOR_E_UNKNOWN_ERROR; 90 webinspector_error_t err = WEBINSPECTOR_E_UNKNOWN_ERROR;
@@ -117,15 +92,6 @@ webinspector_error_t webinspector_client_start_service(idevice_t device, webinsp
117 return err; 92 return err;
118} 93}
119 94
120/**
121 * Disconnects a webinspector client from the device and frees up the
122 * webinspector client data.
123 *
124 * @param client The webinspector client to disconnect and free.
125 *
126 * @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when
127 * client is NULL, or an WEBINSPECTOR_E_* error code otherwise.
128 */
129webinspector_error_t webinspector_client_free(webinspector_client_t client) 95webinspector_error_t webinspector_client_free(webinspector_client_t client)
130{ 96{
131 if (!client) 97 if (!client)
@@ -137,15 +103,6 @@ webinspector_error_t webinspector_client_free(webinspector_client_t client)
137 return err; 103 return err;
138} 104}
139 105
140/**
141 * Sends a plist to the service.
142 *
143 * @param client The webinspector client
144 * @param plist The plist to send
145 *
146 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
147 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client or plist is NULL
148 */
149webinspector_error_t webinspector_send(webinspector_client_t client, plist_t plist) 106webinspector_error_t webinspector_send(webinspector_client_t client, plist_t plist)
150{ 107{
151 webinspector_error_t res = WEBINSPECTOR_E_UNKNOWN_ERROR; 108 webinspector_error_t res = WEBINSPECTOR_E_UNKNOWN_ERROR;
@@ -203,35 +160,11 @@ webinspector_error_t webinspector_send(webinspector_client_t client, plist_t pli
203 return res; 160 return res;
204} 161}
205 162
206/**
207 * Receives a plist from the service.
208 *
209 * @param client The webinspector client
210 * @param plist The plist to store the received data
211 *
212 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
213 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client or plist is NULL
214 */
215webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * plist) 163webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * plist)
216{ 164{
217 return webinspector_receive_with_timeout(client, plist, 5000); 165 return webinspector_receive_with_timeout(client, plist, 5000);
218} 166}
219 167
220/**
221 * Receives a plist using the given webinspector client.
222 *
223 * @param client The webinspector client to use for receiving
224 * @param plist pointer to a plist_t that will point to the received plist
225 * upon successful return
226 * @param timeout Maximum time in milliseconds to wait for data.
227 *
228 * @return WEBINSPECTOR_E_SUCCESS on success,
229 * WEBINSPECTOR_E_INVALID_ARG when client or *plist is NULL,
230 * WEBINSPECTOR_E_PLIST_ERROR when the received data cannot be
231 * converted to a plist, WEBINSPECTOR_E_MUX_ERROR when a
232 * communication error occurs, or WEBINSPECTOR_E_UNKNOWN_ERROR
233 * when an unspecified error occurs.
234 */
235webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist_t * plist, uint32_t timeout_ms) 168webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist_t * plist, uint32_t timeout_ms)
236{ 169{
237 webinspector_error_t res = WEBINSPECTOR_E_UNKNOWN_ERROR; 170 webinspector_error_t res = WEBINSPECTOR_E_UNKNOWN_ERROR;