summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2020-06-08 00:43:36 +0200
committerGravatar Martin Szulecki2020-06-08 00:43:36 +0200
commit542ef4711ff6f321014e2465264159245e5f3c51 (patch)
tree7107a7de2ae5a84c0109ebe149b7104b5eb2336b
parent02c925788d44149816b2b5b307fda3eb0e11066c (diff)
downloadlibimobiledevice-542ef4711ff6f321014e2465264159245e5f3c51.tar.gz
libimobiledevice-542ef4711ff6f321014e2465264159245e5f3c51.tar.bz2
Rename "compproxy" names to "companion_proxy" in all related code
This now matches how other services are named as we try to use the lockdownd provided name or otherwise a more readable one even if it is longer.
-rw-r--r--include/libimobiledevice/companion_proxy.h152
-rw-r--r--src/companion_proxy.c182
-rw-r--r--src/companion_proxy.h2
3 files changed, 168 insertions, 168 deletions
diff --git a/include/libimobiledevice/companion_proxy.h b/include/libimobiledevice/companion_proxy.h
index aaf7661..19c88eb 100644
--- a/include/libimobiledevice/companion_proxy.h
+++ b/include/libimobiledevice/companion_proxy.h
@@ -30,109 +30,109 @@ extern "C" {
30#include <libimobiledevice/libimobiledevice.h> 30#include <libimobiledevice/libimobiledevice.h>
31#include <libimobiledevice/lockdown.h> 31#include <libimobiledevice/lockdown.h>
32 32
33#define COMPPROXY_SERVICE_NAME "com.apple.companion_proxy" 33#define COMPANION_PROXY_SERVICE_NAME "com.apple.companion_proxy"
34 34
35/** Error Codes */ 35/** Error Codes */
36typedef enum { 36typedef enum {
37 COMPPROXY_E_SUCCESS = 0, 37 COMPANION_PROXY_E_SUCCESS = 0,
38 COMPPROXY_E_INVALID_ARG = -1, 38 COMPANION_PROXY_E_INVALID_ARG = -1,
39 COMPPROXY_E_PLIST_ERROR = -2, 39 COMPANION_PROXY_E_PLIST_ERROR = -2,
40 COMPPROXY_E_MUX_ERROR = -3, 40 COMPANION_PROXY_E_MUX_ERROR = -3,
41 COMPPROXY_E_SSL_ERROR = -4, 41 COMPANION_PROXY_E_SSL_ERROR = -4,
42 COMPPROXY_E_NOT_ENOUGH_DATA = -5, 42 COMPANION_PROXY_E_NOT_ENOUGH_DATA = -5,
43 COMPPROXY_E_TIMEOUT = -6, 43 COMPANION_PROXY_E_TIMEOUT = -6,
44 COMPPROXY_E_OP_IN_PROGRESS = -7, 44 COMPANION_PROXY_E_OP_IN_PROGRESS = -7,
45 COMPPROXY_E_NO_DEVICES = -100, 45 COMPANION_PROXY_E_NO_DEVICES = -100,
46 COMPPROXY_E_UNSUPPORTED_KEY = -101, 46 COMPANION_PROXY_E_UNSUPPORTED_KEY = -101,
47 COMPPROXY_E_TIMEOUT_REPLY = -102, 47 COMPANION_PROXY_E_TIMEOUT_REPLY = -102,
48 COMPPROXY_E_UNKNOWN_ERROR = -256 48 COMPANION_PROXY_E_UNKNOWN_ERROR = -256
49} compproxy_error_t; 49} companion_proxy_error_t;
50 50
51typedef struct compproxy_client_private compproxy_client_private; 51typedef struct companion_proxy_client_private companion_proxy_client_private;
52typedef compproxy_client_private *compproxy_client_t; /**< The client handle. */ 52typedef companion_proxy_client_private *companion_proxy_client_t; /**< The client handle. */
53 53
54typedef void (*compproxy_device_event_cb_t) (plist_t event, void* userdata); 54typedef void (*companion_proxy_device_event_cb_t) (plist_t event, void* userdata);
55 55
56/** 56/**
57 * Connects to the compproxy service on the specified device. 57 * Connects to the companion_proxy service on the specified device.
58 * 58 *
59 * @param device The device to connect to. 59 * @param device The device to connect to.
60 * @param service The service descriptor returned by lockdownd_start_service. 60 * @param service The service descriptor returned by lockdownd_start_service.
61 * @param client Pointer that will point to a newly allocated 61 * @param client Pointer that will point to a newly allocated
62 * compproxy_client_t upon successful return. Must be freed using 62 * companion_proxy_client_t upon successful return. Must be freed using
63 * compproxy_client_free() after use. 63 * companion_proxy_client_free() after use.
64 * 64 *
65 * @return COMPPROXY_E_SUCCESS on success, COMPPROXY_E_INVALID_ARG when 65 * @return COMPANION_PROXY_E_SUCCESS on success, COMPANION_PROXY_E_INVALID_ARG when
66 * the arguments are invalid, or an COMPPROXY_E_* error code otherwise. 66 * the arguments are invalid, or an COMPANION_PROXY_E_* error code otherwise.
67 */ 67 */
68compproxy_error_t compproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, compproxy_client_t* client); 68companion_proxy_error_t companion_proxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, companion_proxy_client_t* client);
69 69
70/** 70/**
71 * Starts a new compproxy service on the specified device and connects to it. 71 * Starts a new companion_proxy service on the specified device and connects to it.
72 * 72 *
73 * @param device The device to connect to. 73 * @param device The device to connect to.
74 * @param client Pointer that will point to a newly allocated 74 * @param client Pointer that will point to a newly allocated
75 * compproxy_client_t upon successful return. Must be freed using 75 * companion_proxy_client_t upon successful return. Must be freed using
76 * compproxy_client_free() after use. 76 * companion_proxy_client_free() after use.
77 * @param label The label to use for communication. Usually the program name. 77 * @param label The label to use for communication. Usually the program name.
78 * Pass NULL to disable sending the label in requests to lockdownd. 78 * Pass NULL to disable sending the label in requests to lockdownd.
79 * 79 *
80 * @return COMPPROXY_E_SUCCESS on success, or an COMPPROXY_E_* error 80 * @return COMPANION_PROXY_E_SUCCESS on success, or an COMPANION_PROXY_E_* error
81 * code otherwise. 81 * code otherwise.
82 */ 82 */
83compproxy_error_t compproxy_client_start_service(idevice_t device, compproxy_client_t* client, const char* label); 83companion_proxy_error_t companion_proxy_client_start_service(idevice_t device, companion_proxy_client_t* client, const char* label);
84 84
85/** 85/**
86 * Disconnects a compproxy client from the device and frees up the 86 * Disconnects a companion_proxy client from the device and frees up the
87 * compproxy client data. 87 * companion_proxy client data.
88 * 88 *
89 * @param client The compproxy client to disconnect and free. 89 * @param client The companion_proxy client to disconnect and free.
90 * 90 *
91 * @return COMPPROXY_E_SUCCESS on success, COMPPROXY_E_INVALID_ARG when 91 * @return COMPANION_PROXY_E_SUCCESS on success, COMPANION_PROXY_E_INVALID_ARG when
92 * client is NULL, or an COMPPROXY_E_* error code otherwise. 92 * client is NULL, or an COMPANION_PROXY_E_* error code otherwise.
93 */ 93 */
94compproxy_error_t compproxy_client_free(compproxy_client_t client); 94companion_proxy_error_t companion_proxy_client_free(companion_proxy_client_t client);
95 95
96/** 96/**
97 * Sends a plist to the service. 97 * Sends a plist to the service.
98 * 98 *
99 * @param client The compproxy client 99 * @param client The companion_proxy client
100 * @param plist The plist to send 100 * @param plist The plist to send
101 * 101 *
102 * @return COMPPROXY_E_SUCCESS on success, 102 * @return COMPANION_PROXY_E_SUCCESS on success,
103 * COMPPROXY_E_INVALID_ARG when client or plist is NULL 103 * COMPANION_PROXY_E_INVALID_ARG when client or plist is NULL
104 */ 104 */
105compproxy_error_t compproxy_send(compproxy_client_t client, plist_t plist); 105companion_proxy_error_t companion_proxy_send(companion_proxy_client_t client, plist_t plist);
106 106
107/** 107/**
108 * Receives a plist from the service. 108 * Receives a plist from the service.
109 * 109 *
110 * @param client The compproxy client 110 * @param client The companion_proxy client
111 * @param plist The plist to store the received data 111 * @param plist The plist to store the received data
112 * 112 *
113 * @return COMPPROXY_E_SUCCESS on success, 113 * @return COMPANION_PROXY_E_SUCCESS on success,
114 * COMPPROXY_E_INVALID_ARG when client or plist is NULL 114 * COMPANION_PROXY_E_INVALID_ARG when client or plist is NULL
115 */ 115 */
116compproxy_error_t compproxy_receive(compproxy_client_t client, plist_t * plist); 116companion_proxy_error_t companion_proxy_receive(companion_proxy_client_t client, plist_t * plist);
117 117
118/** 118/**
119 * Retrieves a list of paired devices. 119 * Retrieves a list of paired devices.
120 * 120 *
121 * @param client The compproxy client 121 * @param client The companion_proxy client
122 * @param devices Point that will receive a PLIST_ARRAY with paired device UDIDs 122 * @param devices Point that will receive a PLIST_ARRAY with paired device UDIDs
123 * 123 *
124 * @note The device closes the connection after sending the reply. 124 * @note The device closes the connection after sending the reply.
125 * 125 *
126 * @return COMPPROXY_E_SUCCESS on success, 126 * @return COMPANION_PROXY_E_SUCCESS on success,
127 * COMPPROXY_E_NO_DEVICES if no devices are paired, 127 * COMPANION_PROXY_E_NO_DEVICES if no devices are paired,
128 * or a COMPPROXY_E_* error code otherwise. 128 * or a COMPANION_PROXY_E_* error code otherwise.
129 */ 129 */
130compproxy_error_t compproxy_get_device_registry(compproxy_client_t client, plist_t* paired_devices); 130companion_proxy_error_t companion_proxy_get_device_registry(companion_proxy_client_t client, plist_t* paired_devices);
131 131
132/** 132/**
133 * Starts listening for paired devices. 133 * Starts listening for paired devices.
134 * 134 *
135 * @param client The compproxy client 135 * @param client The companion_proxy client
136 * @param callback Callback function that will be called when a new device is detected 136 * @param callback Callback function that will be called when a new device is detected
137 * @param userdata Pointer that that will be passed to the callback function 137 * @param userdata Pointer that that will be passed to the callback function
138 * 138 *
@@ -140,66 +140,66 @@ compproxy_error_t compproxy_get_device_registry(compproxy_client_t client, plist
140 * freed internally after returning from the callback. The consumer needs 140 * freed internally after returning from the callback. The consumer needs
141 * to make a copy if required. 141 * to make a copy if required.
142 * 142 *
143 * @return COMPPROXY_E_SUCCESS on success, 143 * @return COMPANION_PROXY_E_SUCCESS on success,
144 * or a COMPPROXY_E_* error code otherwise. 144 * or a COMPANION_PROXY_E_* error code otherwise.
145 */ 145 */
146compproxy_error_t compproxy_start_listening_for_devices(compproxy_client_t client, compproxy_device_event_cb_t callback, void* userdata); 146companion_proxy_error_t companion_proxy_start_listening_for_devices(companion_proxy_client_t client, companion_proxy_device_event_cb_t callback, void* userdata);
147 147
148/** 148/**
149 * Stops listening for paired devices 149 * Stops listening for paired devices
150 * 150 *
151 * @param client The compproxy client 151 * @param client The companion_proxy client
152 * 152 *
153 * @return COMPPROXY_E_SUCCESS on success, 153 * @return COMPANION_PROXY_E_SUCCESS on success,
154 * or a COMPPROXY_E_* error code otherwise. 154 * or a COMPANION_PROXY_E_* error code otherwise.
155 */ 155 */
156compproxy_error_t compproxy_stop_listening_for_devices(compproxy_client_t client); 156companion_proxy_error_t companion_proxy_stop_listening_for_devices(companion_proxy_client_t client);
157 157
158/** 158/**
159 * Returns a value for the given key. 159 * Returns a value for the given key.
160 * 160 *
161 * @param client The compproxy client 161 * @param client The companion_proxy client
162 * @param companion_udid UDID of the (paired) watch 162 * @param companion_udid UDID of the (paired) companion device
163 * @param key The key to retrieve the value for 163 * @param key The key to retrieve the value for
164 * 164 *
165 * @note The device closes the connection after sending the reply. 165 * @note The device closes the connection after sending the reply.
166 * 166 *
167 * @return COMPPROXY_E_SUCCESS on success, 167 * @return COMPANION_PROXY_E_SUCCESS on success,
168 * COMPPROXY_E_INVALID_ARG when client or paired_devices is invalid, 168 * COMPANION_PROXY_E_INVALID_ARG when client or paired_devices is invalid,
169 * COMPPROXY_E_UNSUPPORTED_KEY if the watch doesn't support the given key, 169 * COMPANION_PROXY_E_UNSUPPORTED_KEY if the companion device doesn't support the given key,
170 * or a COMPPROXY_E_* error code otherwise. 170 * or a COMPANION_PROXY_E_* error code otherwise.
171 */ 171 */
172compproxy_error_t compproxy_get_value_from_registry(compproxy_client_t client, const char* companion_udid, const char* key, plist_t* value); 172companion_proxy_error_t companion_proxy_get_value_from_registry(companion_proxy_client_t client, const char* companion_udid, const char* key, plist_t* value);
173 173
174/** 174/**
175 * Start forwarding a service port on the watch to a port on the idevice. 175 * Start forwarding a service port on the companion device to a port on the idevice.
176 * 176 *
177 * @see compproxy_stop_forwarding_service_port 177 * @see companion_proxy_stop_forwarding_service_port
178 * 178 *
179 * @param client The compproxy client 179 * @param client The companion_proxy client
180 * @param remote_port remote port 180 * @param remote_port remote port
181 * @param service_name The name of the service that shall be forwarded 181 * @param service_name The name of the service that shall be forwarded
182 * @param forward_port Pointer that will receive the newly-assigned port accessible via USB/Network on the idevice 182 * @param forward_port Pointer that will receive the newly-assigned port accessible via USB/Network on the idevice
183 * @param options PLIST_DICT with additional options. Currently known are 183 * @param options PLIST_DICT with additional options. Currently known are
184 * IsServiceLowPriority (boolean) and PreferWifi (boolean). 184 * IsServiceLowPriority (boolean) and PreferWifi (boolean).
185 * 185 *
186 * @return COMPPROXY_E_SUCCESS on success, 186 * @return COMPANION_PROXY_E_SUCCESS on success,
187 * or a COMPPROXY_E_* error code otherwise. 187 * or a COMPANION_PROXY_E_* error code otherwise.
188 */ 188 */
189compproxy_error_t compproxy_start_forwarding_service_port(compproxy_client_t client, uint16_t remote_port, const char* service_name, uint16_t* forward_port, plist_t options); 189companion_proxy_error_t companion_proxy_start_forwarding_service_port(companion_proxy_client_t client, uint16_t remote_port, const char* service_name, uint16_t* forward_port, plist_t options);
190 190
191/** 191/**
192 * Stop forwarding a service port between watch and idevice. 192 * Stop forwarding a service port between companion device and idevice.
193 * 193 *
194 * @see compproxy_start_forwarding_service_port 194 * @see companion_proxy_start_forwarding_service_port
195 * 195 *
196 * @param client The compproxy client 196 * @param client The companion_proxy client
197 * @param remote_port remote port 197 * @param remote_port remote port
198 * 198 *
199 * @return COMPPROXY_E_SUCCESS on success, 199 * @return COMPANION_PROXY_E_SUCCESS on success,
200 * or a COMPPROXY_E_* error code otherwise. 200 * or a COMPANION_PROXY_E_* error code otherwise.
201 */ 201 */
202compproxy_error_t compproxy_stop_forwarding_service_port(compproxy_client_t client, uint16_t remote_port); 202companion_proxy_error_t companion_proxy_stop_forwarding_service_port(companion_proxy_client_t client, uint16_t remote_port);
203 203
204#ifdef __cplusplus 204#ifdef __cplusplus
205} 205}
diff --git a/src/companion_proxy.c b/src/companion_proxy.c
index edce500..f09b416 100644
--- a/src/companion_proxy.c
+++ b/src/companion_proxy.c
@@ -32,76 +32,76 @@
32#include "common/thread.h" 32#include "common/thread.h"
33 33
34/** 34/**
35 * Convert a property_list_service_error_t value to a compproxy_error_t value. 35 * Convert a property_list_service_error_t value to a companion_proxy_error_t value.
36 * Used internally to get correct error codes. 36 * Used internally to get correct error codes.
37 * 37 *
38 * @param err An property_list_service_error_t error code 38 * @param err An property_list_service_error_t error code
39 * 39 *
40 * @return A matching compproxy_error_t error code, 40 * @return A matching companion_proxy_error_t error code,
41 * COMPPROXY_E_UNKNOWN_ERROR otherwise. 41 * COMPANION_PROXY_E_UNKNOWN_ERROR otherwise.
42 */ 42 */
43static compproxy_error_t compproxy_error(property_list_service_error_t err) 43static companion_proxy_error_t companion_proxy_error(property_list_service_error_t err)
44{ 44{
45 switch (err) { 45 switch (err) {
46 case PROPERTY_LIST_SERVICE_E_SUCCESS: 46 case PROPERTY_LIST_SERVICE_E_SUCCESS:
47 return COMPPROXY_E_SUCCESS; 47 return COMPANION_PROXY_E_SUCCESS;
48 case PROPERTY_LIST_SERVICE_E_INVALID_ARG: 48 case PROPERTY_LIST_SERVICE_E_INVALID_ARG:
49 return COMPPROXY_E_INVALID_ARG; 49 return COMPANION_PROXY_E_INVALID_ARG;
50 case PROPERTY_LIST_SERVICE_E_PLIST_ERROR: 50 case PROPERTY_LIST_SERVICE_E_PLIST_ERROR:
51 return COMPPROXY_E_PLIST_ERROR; 51 return COMPANION_PROXY_E_PLIST_ERROR;
52 case PROPERTY_LIST_SERVICE_E_MUX_ERROR: 52 case PROPERTY_LIST_SERVICE_E_MUX_ERROR:
53 return COMPPROXY_E_MUX_ERROR; 53 return COMPANION_PROXY_E_MUX_ERROR;
54 case PROPERTY_LIST_SERVICE_E_SSL_ERROR: 54 case PROPERTY_LIST_SERVICE_E_SSL_ERROR:
55 return COMPPROXY_E_SSL_ERROR; 55 return COMPANION_PROXY_E_SSL_ERROR;
56 case PROPERTY_LIST_SERVICE_E_NOT_ENOUGH_DATA: 56 case PROPERTY_LIST_SERVICE_E_NOT_ENOUGH_DATA:
57 return COMPPROXY_E_NOT_ENOUGH_DATA; 57 return COMPANION_PROXY_E_NOT_ENOUGH_DATA;
58 case PROPERTY_LIST_SERVICE_E_RECEIVE_TIMEOUT: 58 case PROPERTY_LIST_SERVICE_E_RECEIVE_TIMEOUT:
59 return COMPPROXY_E_TIMEOUT; 59 return COMPANION_PROXY_E_TIMEOUT;
60 default: 60 default:
61 break; 61 break;
62 } 62 }
63 return COMPPROXY_E_UNKNOWN_ERROR; 63 return COMPANION_PROXY_E_UNKNOWN_ERROR;
64} 64}
65 65
66LIBIMOBILEDEVICE_API compproxy_error_t compproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, compproxy_client_t * client) 66LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, companion_proxy_client_t * client)
67{ 67{
68 *client = NULL; 68 *client = NULL;
69 69
70 if (!device || !service || service->port == 0 || !client || *client) { 70 if (!device || !service || service->port == 0 || !client || *client) {
71 debug_info("Incorrect parameter passed to compproxy_client_new."); 71 debug_info("Incorrect parameter passed to companion_proxy_client_new.");
72 return COMPPROXY_E_INVALID_ARG; 72 return COMPANION_PROXY_E_INVALID_ARG;
73 } 73 }
74 74
75 debug_info("Creating compproxy_client, port = %d.", service->port); 75 debug_info("Creating companion_proxy_client, port = %d.", service->port);
76 76
77 property_list_service_client_t plclient = NULL; 77 property_list_service_client_t plclient = NULL;
78 compproxy_error_t ret = compproxy_error(property_list_service_client_new(device, service, &plclient)); 78 companion_proxy_error_t ret = companion_proxy_error(property_list_service_client_new(device, service, &plclient));
79 if (ret != COMPPROXY_E_SUCCESS) { 79 if (ret != COMPANION_PROXY_E_SUCCESS) {
80 debug_info("Creating a property list client failed. Error: %i", ret); 80 debug_info("Creating a property list client failed. Error: %i", ret);
81 return ret; 81 return ret;
82 } 82 }
83 83
84 compproxy_client_t client_loc = (compproxy_client_t) malloc(sizeof(struct compproxy_client_private)); 84 companion_proxy_client_t client_loc = (companion_proxy_client_t) malloc(sizeof(struct companion_proxy_client_private));
85 client_loc->parent = plclient; 85 client_loc->parent = plclient;
86 client_loc->event_thread = THREAD_T_NULL; 86 client_loc->event_thread = THREAD_T_NULL;
87 87
88 *client = client_loc; 88 *client = client_loc;
89 89
90 debug_info("compproxy_client successfully created."); 90 debug_info("Created companion_proxy_client successfully.");
91 return COMPPROXY_E_SUCCESS; 91 return COMPANION_PROXY_E_SUCCESS;
92} 92}
93 93
94LIBIMOBILEDEVICE_API compproxy_error_t compproxy_client_start_service(idevice_t device, compproxy_client_t * client, const char* label) 94LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_client_start_service(idevice_t device, companion_proxy_client_t * client, const char* label)
95{ 95{
96 compproxy_error_t err = COMPPROXY_E_UNKNOWN_ERROR; 96 companion_proxy_error_t err = COMPANION_PROXY_E_UNKNOWN_ERROR;
97 service_client_factory_start_service(device, COMPPROXY_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(compproxy_client_new), &err); 97 service_client_factory_start_service(device, COMPANION_PROXY_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(companion_proxy_client_new), &err);
98 return err; 98 return err;
99} 99}
100 100
101LIBIMOBILEDEVICE_API compproxy_error_t compproxy_client_free(compproxy_client_t client) 101LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_client_free(companion_proxy_client_t client)
102{ 102{
103 if (!client) 103 if (!client)
104 return COMPPROXY_E_INVALID_ARG; 104 return COMPANION_PROXY_E_INVALID_ARG;
105 105
106 property_list_service_client_t parent = client->parent; 106 property_list_service_client_t parent = client->parent;
107 client->parent = NULL; 107 client->parent = NULL;
@@ -111,18 +111,18 @@ LIBIMOBILEDEVICE_API compproxy_error_t compproxy_client_free(compproxy_client_t
111 thread_free(client->event_thread); 111 thread_free(client->event_thread);
112 client->event_thread = THREAD_T_NULL; 112 client->event_thread = THREAD_T_NULL;
113 } 113 }
114 compproxy_error_t err = compproxy_error(property_list_service_client_free(parent)); 114 companion_proxy_error_t err = companion_proxy_error(property_list_service_client_free(parent));
115 free(client); 115 free(client);
116 116
117 return err; 117 return err;
118} 118}
119 119
120LIBIMOBILEDEVICE_API compproxy_error_t compproxy_send(compproxy_client_t client, plist_t plist) 120LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_send(companion_proxy_client_t client, plist_t plist)
121{ 121{
122 compproxy_error_t res = COMPPROXY_E_UNKNOWN_ERROR; 122 companion_proxy_error_t res = COMPANION_PROXY_E_UNKNOWN_ERROR;
123 123
124 res = compproxy_error(property_list_service_send_binary_plist(client->parent, plist)); 124 res = companion_proxy_error(property_list_service_send_binary_plist(client->parent, plist));
125 if (res != COMPPROXY_E_SUCCESS) { 125 if (res != COMPANION_PROXY_E_SUCCESS) {
126 debug_info("Sending plist failed with error %d", res); 126 debug_info("Sending plist failed with error %d", res);
127 return res; 127 return res;
128 } 128 }
@@ -130,53 +130,53 @@ LIBIMOBILEDEVICE_API compproxy_error_t compproxy_send(compproxy_client_t client,
130 return res; 130 return res;
131} 131}
132 132
133LIBIMOBILEDEVICE_API compproxy_error_t compproxy_receive(compproxy_client_t client, plist_t * plist) 133LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_receive(companion_proxy_client_t client, plist_t * plist)
134{ 134{
135 compproxy_error_t res = COMPPROXY_E_UNKNOWN_ERROR; 135 companion_proxy_error_t res = COMPANION_PROXY_E_UNKNOWN_ERROR;
136 plist_t outplist = NULL; 136 plist_t outplist = NULL;
137 res = compproxy_error(property_list_service_receive_plist_with_timeout(client->parent, &outplist, 10000)); 137 res = companion_proxy_error(property_list_service_receive_plist_with_timeout(client->parent, &outplist, 10000));
138 if (res != COMPPROXY_E_SUCCESS && res != COMPPROXY_E_TIMEOUT) { 138 if (res != COMPANION_PROXY_E_SUCCESS && res != COMPANION_PROXY_E_TIMEOUT) {
139 debug_info("Could not receive plist, error %d", res); 139 debug_info("Could not receive plist, error %d", res);
140 plist_free(outplist); 140 plist_free(outplist);
141 } else if (res == COMPPROXY_E_SUCCESS) { 141 } else if (res == COMPANION_PROXY_E_SUCCESS) {
142 *plist = outplist; 142 *plist = outplist;
143 } 143 }
144 return res; 144 return res;
145} 145}
146 146
147LIBIMOBILEDEVICE_API compproxy_error_t compproxy_get_device_registry(compproxy_client_t client, plist_t* paired_devices) 147LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_get_device_registry(companion_proxy_client_t client, plist_t* paired_devices)
148{ 148{
149 if (!client || !paired_devices) { 149 if (!client || !paired_devices) {
150 return COMPPROXY_E_INVALID_ARG; 150 return COMPANION_PROXY_E_INVALID_ARG;
151 } 151 }
152 152
153 plist_t dict = plist_new_dict(); 153 plist_t dict = plist_new_dict();
154 plist_dict_set_item(dict, "Command", plist_new_string("GetDeviceRegistry")); 154 plist_dict_set_item(dict, "Command", plist_new_string("GetDeviceRegistry"));
155 155
156 compproxy_error_t res = compproxy_send(client, dict); 156 companion_proxy_error_t res = companion_proxy_send(client, dict);
157 plist_free(dict); 157 plist_free(dict);
158 dict = NULL; 158 dict = NULL;
159 if (res != COMPPROXY_E_SUCCESS) { 159 if (res != COMPANION_PROXY_E_SUCCESS) {
160 return res; 160 return res;
161 } 161 }
162 162
163 res = compproxy_receive(client, &dict); 163 res = companion_proxy_receive(client, &dict);
164 if (res != COMPPROXY_E_SUCCESS) { 164 if (res != COMPANION_PROXY_E_SUCCESS) {
165 return res; 165 return res;
166 } 166 }
167 if (!dict || !PLIST_IS_DICT(dict)) { 167 if (!dict || !PLIST_IS_DICT(dict)) {
168 return COMPPROXY_E_PLIST_ERROR; 168 return COMPANION_PROXY_E_PLIST_ERROR;
169 } 169 }
170 plist_t val = plist_dict_get_item(dict, "PairedDevicesArray"); 170 plist_t val = plist_dict_get_item(dict, "PairedDevicesArray");
171 if (val) { 171 if (val) {
172 *paired_devices = plist_copy(val); 172 *paired_devices = plist_copy(val);
173 res = COMPPROXY_E_SUCCESS; 173 res = COMPANION_PROXY_E_SUCCESS;
174 } else { 174 } else {
175 res = COMPPROXY_E_UNKNOWN_ERROR; 175 res = COMPANION_PROXY_E_UNKNOWN_ERROR;
176 val = plist_dict_get_item(dict, "Error"); 176 val = plist_dict_get_item(dict, "Error");
177 if (val) { 177 if (val) {
178 if (plist_string_val_compare(val, "NoPairedWatches")) { 178 if (plist_string_val_compare(val, "NoPairedWatches")) {
179 res = COMPPROXY_E_NO_DEVICES; 179 res = COMPANION_PROXY_E_NO_DEVICES;
180 } 180 }
181 } 181 }
182 } 182 }
@@ -184,24 +184,24 @@ LIBIMOBILEDEVICE_API compproxy_error_t compproxy_get_device_registry(compproxy_c
184 return res; 184 return res;
185} 185}
186 186
187struct compproxy_cb_data { 187struct companion_proxy_cb_data {
188 compproxy_client_t client; 188 companion_proxy_client_t client;
189 compproxy_device_event_cb_t cbfunc; 189 companion_proxy_device_event_cb_t cbfunc;
190 void* user_data; 190 void* user_data;
191}; 191};
192 192
193static void* compproxy_event_thread(void* arg) 193static void* companion_proxy_event_thread(void* arg)
194{ 194{
195 struct compproxy_cb_data* data = (struct compproxy_cb_data*)arg; 195 struct companion_proxy_cb_data* data = (struct companion_proxy_cb_data*)arg;
196 compproxy_client_t client = data->client; 196 companion_proxy_client_t client = data->client;
197 compproxy_error_t res; 197 companion_proxy_error_t res;
198 198
199 plist_t command = plist_new_dict(); 199 plist_t command = plist_new_dict();
200 plist_dict_set_item(command, "Command", plist_new_string("StartListeningForDevices")); 200 plist_dict_set_item(command, "Command", plist_new_string("StartListeningForDevices"));
201 res = compproxy_send(client, command); 201 res = companion_proxy_send(client, command);
202 plist_free(command); 202 plist_free(command);
203 203
204 if (res != COMPPROXY_E_SUCCESS) { 204 if (res != COMPANION_PROXY_E_SUCCESS) {
205 free(data); 205 free(data);
206 client->event_thread = THREAD_T_NULL; 206 client->event_thread = THREAD_T_NULL;
207 return NULL; 207 return NULL;
@@ -209,8 +209,8 @@ static void* compproxy_event_thread(void* arg)
209 209
210 while (client && client->parent) { 210 while (client && client->parent) {
211 plist_t node = NULL; 211 plist_t node = NULL;
212 res = compproxy_error(property_list_service_receive_plist_with_timeout(client->parent, &node, 1000)); 212 res = companion_proxy_error(property_list_service_receive_plist_with_timeout(client->parent, &node, 1000));
213 if (res != COMPPROXY_E_SUCCESS && res != COMPPROXY_E_TIMEOUT) { 213 if (res != COMPANION_PROXY_E_SUCCESS && res != COMPANION_PROXY_E_TIMEOUT) {
214 debug_info("could not receive plist, error %d", res); 214 debug_info("could not receive plist, error %d", res);
215 break; 215 break;
216 } 216 }
@@ -227,25 +227,25 @@ static void* compproxy_event_thread(void* arg)
227 return NULL; 227 return NULL;
228} 228}
229 229
230LIBIMOBILEDEVICE_API compproxy_error_t compproxy_start_listening_for_devices(compproxy_client_t client, compproxy_device_event_cb_t callback, void* userdata) 230LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_start_listening_for_devices(companion_proxy_client_t client, companion_proxy_device_event_cb_t callback, void* userdata)
231{ 231{
232 if (!client || !client->parent || !callback) { 232 if (!client || !client->parent || !callback) {
233 return COMPPROXY_E_INVALID_ARG; 233 return COMPANION_PROXY_E_INVALID_ARG;
234 } 234 }
235 235
236 if (client->event_thread) { 236 if (client->event_thread) {
237 return COMPPROXY_E_OP_IN_PROGRESS; 237 return COMPANION_PROXY_E_OP_IN_PROGRESS;
238 } 238 }
239 239
240 compproxy_error_t res = COMPPROXY_E_UNKNOWN_ERROR; 240 companion_proxy_error_t res = COMPANION_PROXY_E_UNKNOWN_ERROR;
241 struct compproxy_cb_data *data = (struct compproxy_cb_data*)malloc(sizeof(struct compproxy_cb_data)); 241 struct companion_proxy_cb_data *data = (struct companion_proxy_cb_data*)malloc(sizeof(struct companion_proxy_cb_data));
242 if (data) { 242 if (data) {
243 data->client = client; 243 data->client = client;
244 data->cbfunc = callback; 244 data->cbfunc = callback;
245 data->user_data = userdata; 245 data->user_data = userdata;
246 246
247 if (thread_new(&client->event_thread, compproxy_event_thread, data) == 0) { 247 if (thread_new(&client->event_thread, companion_proxy_event_thread, data) == 0) {
248 res = COMPPROXY_E_SUCCESS; 248 res = COMPANION_PROXY_E_SUCCESS;
249 } else { 249 } else {
250 free(data); 250 free(data);
251 } 251 }
@@ -253,7 +253,7 @@ LIBIMOBILEDEVICE_API compproxy_error_t compproxy_start_listening_for_devices(com
253 return res; 253 return res;
254} 254}
255 255
256LIBIMOBILEDEVICE_API compproxy_error_t compproxy_stop_listening_for_devices(compproxy_client_t client) 256LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_stop_listening_for_devices(companion_proxy_client_t client)
257{ 257{
258 property_list_service_client_t parent = client->parent; 258 property_list_service_client_t parent = client->parent;
259 client->parent = NULL; 259 client->parent = NULL;
@@ -264,13 +264,13 @@ LIBIMOBILEDEVICE_API compproxy_error_t compproxy_stop_listening_for_devices(comp
264 client->event_thread = THREAD_T_NULL; 264 client->event_thread = THREAD_T_NULL;
265 } 265 }
266 client->parent = parent; 266 client->parent = parent;
267 return COMPPROXY_E_SUCCESS; 267 return COMPANION_PROXY_E_SUCCESS;
268} 268}
269 269
270LIBIMOBILEDEVICE_API compproxy_error_t compproxy_get_value_from_registry(compproxy_client_t client, const char* companion_udid, const char* key, plist_t* value) 270LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_get_value_from_registry(companion_proxy_client_t client, const char* companion_udid, const char* key, plist_t* value)
271{ 271{
272 if (!client || !companion_udid || !key || !value) { 272 if (!client || !companion_udid || !key || !value) {
273 return COMPPROXY_E_INVALID_ARG; 273 return COMPANION_PROXY_E_INVALID_ARG;
274 } 274 }
275 275
276 plist_t dict = plist_new_dict(); 276 plist_t dict = plist_new_dict();
@@ -278,32 +278,32 @@ LIBIMOBILEDEVICE_API compproxy_error_t compproxy_get_value_from_registry(comppro
278 plist_dict_set_item(dict, "GetValueGizmoUDIDKey", plist_new_string(companion_udid)); 278 plist_dict_set_item(dict, "GetValueGizmoUDIDKey", plist_new_string(companion_udid));
279 plist_dict_set_item(dict, "GetValueKeyKey", plist_new_string(key)); 279 plist_dict_set_item(dict, "GetValueKeyKey", plist_new_string(key));
280 280
281 compproxy_error_t res = compproxy_send(client, dict); 281 companion_proxy_error_t res = companion_proxy_send(client, dict);
282 plist_free(dict); 282 plist_free(dict);
283 dict = NULL; 283 dict = NULL;
284 if (res != COMPPROXY_E_SUCCESS) { 284 if (res != COMPANION_PROXY_E_SUCCESS) {
285 return res; 285 return res;
286 } 286 }
287 287
288 res = compproxy_receive(client, &dict); 288 res = companion_proxy_receive(client, &dict);
289 if (res != COMPPROXY_E_SUCCESS) { 289 if (res != COMPANION_PROXY_E_SUCCESS) {
290 return res; 290 return res;
291 } 291 }
292 if (!dict || !PLIST_IS_DICT(dict)) { 292 if (!dict || !PLIST_IS_DICT(dict)) {
293 return COMPPROXY_E_PLIST_ERROR; 293 return COMPANION_PROXY_E_PLIST_ERROR;
294 } 294 }
295 plist_t val = plist_dict_get_item(dict, "RetrievedValueDictionary"); 295 plist_t val = plist_dict_get_item(dict, "RetrievedValueDictionary");
296 if (val) { 296 if (val) {
297 *value = plist_copy(val); 297 *value = plist_copy(val);
298 res = COMPPROXY_E_SUCCESS; 298 res = COMPANION_PROXY_E_SUCCESS;
299 } else { 299 } else {
300 res = COMPPROXY_E_UNKNOWN_ERROR; 300 res = COMPANION_PROXY_E_UNKNOWN_ERROR;
301 val = plist_dict_get_item(dict, "Error"); 301 val = plist_dict_get_item(dict, "Error");
302 if (val) { 302 if (val) {
303 if (!plist_string_val_compare(val, "UnsupportedWatchKey")) { 303 if (!plist_string_val_compare(val, "UnsupportedWatchKey")) {
304 res = COMPPROXY_E_UNSUPPORTED_KEY; 304 res = COMPANION_PROXY_E_UNSUPPORTED_KEY;
305 } else if (plist_string_val_compare(val, "TimeoutReply")) { 305 } else if (plist_string_val_compare(val, "TimeoutReply")) {
306 res = COMPPROXY_E_TIMEOUT_REPLY; 306 res = COMPANION_PROXY_E_TIMEOUT_REPLY;
307 } 307 }
308 } 308 }
309 } 309 }
@@ -311,10 +311,10 @@ LIBIMOBILEDEVICE_API compproxy_error_t compproxy_get_value_from_registry(comppro
311 return res; 311 return res;
312} 312}
313 313
314LIBIMOBILEDEVICE_API compproxy_error_t compproxy_start_forwarding_service_port(compproxy_client_t client, uint16_t remote_port, const char* service_name, uint16_t* forward_port, plist_t options) 314LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_start_forwarding_service_port(companion_proxy_client_t client, uint16_t remote_port, const char* service_name, uint16_t* forward_port, plist_t options)
315{ 315{
316 if (!client) { 316 if (!client) {
317 return COMPPROXY_E_INVALID_ARG; 317 return COMPANION_PROXY_E_INVALID_ARG;
318 } 318 }
319 319
320 plist_t dict = plist_new_dict(); 320 plist_t dict = plist_new_dict();
@@ -329,15 +329,15 @@ LIBIMOBILEDEVICE_API compproxy_error_t compproxy_start_forwarding_service_port(c
329 plist_dict_merge(dict, options); 329 plist_dict_merge(dict, options);
330 } 330 }
331 331
332 compproxy_error_t res = compproxy_send(client, dict); 332 companion_proxy_error_t res = companion_proxy_send(client, dict);
333 plist_free(dict); 333 plist_free(dict);
334 dict = NULL; 334 dict = NULL;
335 if (res != COMPPROXY_E_SUCCESS) { 335 if (res != COMPANION_PROXY_E_SUCCESS) {
336 return res; 336 return res;
337 } 337 }
338 338
339 res = compproxy_receive(client, &dict); 339 res = companion_proxy_receive(client, &dict);
340 if (res != COMPPROXY_E_SUCCESS) { 340 if (res != COMPANION_PROXY_E_SUCCESS) {
341 return res; 341 return res;
342 } 342 }
343 plist_t val = plist_dict_get_item(dict, "CompanionProxyServicePort"); 343 plist_t val = plist_dict_get_item(dict, "CompanionProxyServicePort");
@@ -345,34 +345,34 @@ LIBIMOBILEDEVICE_API compproxy_error_t compproxy_start_forwarding_service_port(c
345 uint64_t u64val = 0; 345 uint64_t u64val = 0;
346 plist_get_uint_val(val, &u64val); 346 plist_get_uint_val(val, &u64val);
347 *forward_port = (uint16_t)u64val; 347 *forward_port = (uint16_t)u64val;
348 res = COMPPROXY_E_SUCCESS; 348 res = COMPANION_PROXY_E_SUCCESS;
349 } else { 349 } else {
350 res = COMPPROXY_E_UNKNOWN_ERROR; 350 res = COMPANION_PROXY_E_UNKNOWN_ERROR;
351 } 351 }
352 plist_free(dict); 352 plist_free(dict);
353 353
354 return res; 354 return res;
355} 355}
356 356
357LIBIMOBILEDEVICE_API compproxy_error_t compproxy_stop_forwarding_service_port(compproxy_client_t client, uint16_t remote_port) 357LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_stop_forwarding_service_port(companion_proxy_client_t client, uint16_t remote_port)
358{ 358{
359 if (!client) { 359 if (!client) {
360 return COMPPROXY_E_INVALID_ARG; 360 return COMPANION_PROXY_E_INVALID_ARG;
361 } 361 }
362 362
363 plist_t dict = plist_new_dict(); 363 plist_t dict = plist_new_dict();
364 plist_dict_set_item(dict, "Command", plist_new_string("StopForwardingServicePort")); 364 plist_dict_set_item(dict, "Command", plist_new_string("StopForwardingServicePort"));
365 plist_dict_set_item(dict, "GizmoRemotePortNumber", plist_new_uint(remote_port)); 365 plist_dict_set_item(dict, "GizmoRemotePortNumber", plist_new_uint(remote_port));
366 366
367 compproxy_error_t res = compproxy_send(client, dict); 367 companion_proxy_error_t res = companion_proxy_send(client, dict);
368 plist_free(dict); 368 plist_free(dict);
369 dict = NULL; 369 dict = NULL;
370 if (res != COMPPROXY_E_SUCCESS) { 370 if (res != COMPANION_PROXY_E_SUCCESS) {
371 return res; 371 return res;
372 } 372 }
373 373
374 res = compproxy_receive(client, &dict); 374 res = companion_proxy_receive(client, &dict);
375 if (res != COMPPROXY_E_SUCCESS) { 375 if (res != COMPANION_PROXY_E_SUCCESS) {
376 return res; 376 return res;
377 } 377 }
378 plist_free(dict); 378 plist_free(dict);
diff --git a/src/companion_proxy.h b/src/companion_proxy.h
index 33c4a80..0314b67 100644
--- a/src/companion_proxy.h
+++ b/src/companion_proxy.h
@@ -26,7 +26,7 @@
26#include "property_list_service.h" 26#include "property_list_service.h"
27#include "common/thread.h" 27#include "common/thread.h"
28 28
29struct compproxy_client_private { 29struct companion_proxy_client_private {
30 property_list_service_client_t parent; 30 property_list_service_client_t parent;
31 THREAD_T event_thread; 31 THREAD_T event_thread;
32}; 32};