diff options
| author | 2010-01-11 21:25:45 +0100 | |
|---|---|---|
| committer | 2010-01-12 00:41:12 +0100 | |
| commit | f311ad48b52854f3c1921322d7f79b82392c2db9 (patch) | |
| tree | e754e2f392ffcfac8cda52d45f4fd3f883422317 | |
| parent | b1d1a80eb005ff5d661a8a0185566a4ebaf519d6 (diff) | |
| download | libimobiledevice-f311ad48b52854f3c1921322d7f79b82392c2db9.tar.gz libimobiledevice-f311ad48b52854f3c1921322d7f79b82392c2db9.tar.bz2 | |
SBServices: use new property_list_service
| -rw-r--r-- | src/SBServices.c | 29 | ||||
| -rw-r--r-- | src/SBServices.h | 3 |
2 files changed, 16 insertions, 16 deletions
diff --git a/src/SBServices.c b/src/SBServices.c index 1296245..2a724d1 100644 --- a/src/SBServices.c +++ b/src/SBServices.c | |||
| @@ -26,7 +26,7 @@ | |||
| 26 | #include <plist/plist.h> | 26 | #include <plist/plist.h> |
| 27 | 27 | ||
| 28 | #include "SBServices.h" | 28 | #include "SBServices.h" |
| 29 | #include "iphone.h" | 29 | #include "property_list_service.h" |
| 30 | #include "utils.h" | 30 | #include "utils.h" |
| 31 | 31 | ||
| 32 | /** Locks an sbservices client, done for thread safety stuff. | 32 | /** Locks an sbservices client, done for thread safety stuff. |
| @@ -58,14 +58,13 @@ sbservices_error_t sbservices_client_new(iphone_device_t device, int dst_port, s | |||
| 58 | if (!device) | 58 | if (!device) |
| 59 | return SBSERVICES_E_INVALID_ARG; | 59 | return SBSERVICES_E_INVALID_ARG; |
| 60 | 60 | ||
| 61 | /* Attempt connection */ | 61 | property_list_service_client_t plistclient = NULL; |
| 62 | iphone_connection_t connection = NULL; | 62 | if (property_list_service_client_new(device, dst_port, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { |
| 63 | if (iphone_device_connect(device, dst_port, &connection) != IPHONE_E_SUCCESS) { | ||
| 64 | return SBSERVICES_E_CONN_FAILED; | 63 | return SBSERVICES_E_CONN_FAILED; |
| 65 | } | 64 | } |
| 66 | 65 | ||
| 67 | sbservices_client_t client_loc = (sbservices_client_t) malloc(sizeof(struct sbservices_client_int)); | 66 | sbservices_client_t client_loc = (sbservices_client_t) malloc(sizeof(struct sbservices_client_int)); |
| 68 | client_loc->connection = connection; | 67 | client_loc->parent = plistclient; |
| 69 | client_loc->mutex = g_mutex_new(); | 68 | client_loc->mutex = g_mutex_new(); |
| 70 | 69 | ||
| 71 | *client = client_loc; | 70 | *client = client_loc; |
| @@ -77,8 +76,8 @@ sbservices_error_t sbservices_client_free(sbservices_client_t client) | |||
| 77 | if (!client) | 76 | if (!client) |
| 78 | return SBSERVICES_E_INVALID_ARG; | 77 | return SBSERVICES_E_INVALID_ARG; |
| 79 | 78 | ||
| 80 | iphone_device_disconnect(client->connection); | 79 | property_list_service_client_free(client->parent); |
| 81 | client->connection = NULL; | 80 | client->parent = NULL; |
| 82 | if (client->mutex) { | 81 | if (client->mutex) { |
| 83 | g_mutex_free(client->mutex); | 82 | g_mutex_free(client->mutex); |
| 84 | } | 83 | } |
| @@ -89,7 +88,7 @@ sbservices_error_t sbservices_client_free(sbservices_client_t client) | |||
| 89 | 88 | ||
| 90 | sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state) | 89 | sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state) |
| 91 | { | 90 | { |
| 92 | if (!client || !client->connection || !state) | 91 | if (!client || !client->parent || !state) |
| 93 | return SBSERVICES_E_INVALID_ARG; | 92 | return SBSERVICES_E_INVALID_ARG; |
| 94 | 93 | ||
| 95 | sbservices_error_t res = SBSERVICES_E_UNKNOWN_ERROR; | 94 | sbservices_error_t res = SBSERVICES_E_UNKNOWN_ERROR; |
| @@ -99,14 +98,14 @@ sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t | |||
| 99 | 98 | ||
| 100 | sbs_lock(client); | 99 | sbs_lock(client); |
| 101 | 100 | ||
| 102 | if (iphone_device_send_binary_plist(client->connection, dict) != IPHONE_E_SUCCESS) { | 101 | if (property_list_service_send_binary_plist(client->parent, dict) != PROPERTY_LIST_SERVICE_E_SUCCESS) { |
| 103 | log_debug_msg("%s: could not send plist\n", __func__); | 102 | log_debug_msg("%s: could not send plist\n", __func__); |
| 104 | goto leave_unlock; | 103 | goto leave_unlock; |
| 105 | } | 104 | } |
| 106 | plist_free(dict); | 105 | plist_free(dict); |
| 107 | dict = NULL; | 106 | dict = NULL; |
| 108 | 107 | ||
| 109 | if (iphone_device_receive_plist(client->connection, state) == IPHONE_E_SUCCESS) { | 108 | if (property_list_service_receive_plist(client->parent, state) == PROPERTY_LIST_SERVICE_E_SUCCESS) { |
| 110 | res = SBSERVICES_E_SUCCESS; | 109 | res = SBSERVICES_E_SUCCESS; |
| 111 | } else { | 110 | } else { |
| 112 | log_debug_msg("%s: could not get icon state!\n", __func__); | 111 | log_debug_msg("%s: could not get icon state!\n", __func__); |
| @@ -126,7 +125,7 @@ leave_unlock: | |||
| 126 | 125 | ||
| 127 | sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate) | 126 | sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate) |
| 128 | { | 127 | { |
| 129 | if (!client || !client->connection || !newstate) | 128 | if (!client || !client->parent || !newstate) |
| 130 | return SBSERVICES_E_INVALID_ARG; | 129 | return SBSERVICES_E_INVALID_ARG; |
| 131 | 130 | ||
| 132 | sbservices_error_t res = SBSERVICES_E_UNKNOWN_ERROR; | 131 | sbservices_error_t res = SBSERVICES_E_UNKNOWN_ERROR; |
| @@ -137,7 +136,7 @@ sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t | |||
| 137 | 136 | ||
| 138 | sbs_lock(client); | 137 | sbs_lock(client); |
| 139 | 138 | ||
| 140 | if (iphone_device_send_binary_plist(client->connection, dict) != IPHONE_E_SUCCESS) { | 139 | if (property_list_service_send_binary_plist(client->parent, dict) != IPHONE_E_SUCCESS) { |
| 141 | log_debug_msg("%s: could not send plist\n", __func__); | 140 | log_debug_msg("%s: could not send plist\n", __func__); |
| 142 | goto leave_unlock; | 141 | goto leave_unlock; |
| 143 | } | 142 | } |
| @@ -153,7 +152,7 @@ leave_unlock: | |||
| 153 | 152 | ||
| 154 | sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize) | 153 | sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize) |
| 155 | { | 154 | { |
| 156 | if (!client || !client->connection || !pngdata) | 155 | if (!client || !client->parent || !pngdata) |
| 157 | return SBSERVICES_E_INVALID_ARG; | 156 | return SBSERVICES_E_INVALID_ARG; |
| 158 | 157 | ||
| 159 | sbservices_error_t res = SBSERVICES_E_UNKNOWN_ERROR; | 158 | sbservices_error_t res = SBSERVICES_E_UNKNOWN_ERROR; |
| @@ -164,14 +163,14 @@ sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const | |||
| 164 | 163 | ||
| 165 | sbs_lock(client); | 164 | sbs_lock(client); |
| 166 | 165 | ||
| 167 | if (iphone_device_send_binary_plist(client->connection, dict) != IPHONE_E_SUCCESS) { | 166 | if (property_list_service_send_binary_plist(client->parent, dict) != PROPERTY_LIST_SERVICE_E_SUCCESS) { |
| 168 | log_debug_msg("%s: could not send plist\n", __func__); | 167 | log_debug_msg("%s: could not send plist\n", __func__); |
| 169 | goto leave_unlock; | 168 | goto leave_unlock; |
| 170 | } | 169 | } |
| 171 | plist_free(dict); | 170 | plist_free(dict); |
| 172 | 171 | ||
| 173 | dict = NULL; | 172 | dict = NULL; |
| 174 | if (iphone_device_receive_plist(client->connection, &dict) == IPHONE_E_SUCCESS) { | 173 | if (property_list_service_receive_plist(client->parent, &dict) == PROPERTY_LIST_SERVICE_E_SUCCESS) { |
| 175 | plist_t node = plist_dict_get_item(dict, "pngData"); | 174 | plist_t node = plist_dict_get_item(dict, "pngData"); |
| 176 | if (node) { | 175 | if (node) { |
| 177 | plist_get_data_val(node, pngdata, pngsize); | 176 | plist_get_data_val(node, pngdata, pngsize); |
diff --git a/src/SBServices.h b/src/SBServices.h index 8f923b9..d24828a 100644 --- a/src/SBServices.h +++ b/src/SBServices.h | |||
| @@ -24,9 +24,10 @@ | |||
| 24 | #include <glib.h> | 24 | #include <glib.h> |
| 25 | 25 | ||
| 26 | #include "libiphone/sbservices.h" | 26 | #include "libiphone/sbservices.h" |
| 27 | #include "property_list_service.h" | ||
| 27 | 28 | ||
| 28 | struct sbservices_client_int { | 29 | struct sbservices_client_int { |
| 29 | iphone_connection_t connection; | 30 | property_list_service_client_t parent; |
| 30 | GMutex *mutex; | 31 | GMutex *mutex; |
| 31 | }; | 32 | }; |
| 32 | 33 | ||
