diff options
Diffstat (limited to 'src/service.c')
| -rw-r--r-- | src/service.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/service.c b/src/service.c index af37a83..738db02 100644 --- a/src/service.c +++ b/src/service.c | |||
| @@ -103,7 +103,7 @@ service_error_t service_client_new(idevice_t device, lockdownd_service_descripto | |||
| 103 | * @return SERVICE_E_SUCCESS on success, or a SERVICE_E_* error code | 103 | * @return SERVICE_E_SUCCESS on success, or a SERVICE_E_* error code |
| 104 | * otherwise. | 104 | * otherwise. |
| 105 | */ | 105 | */ |
| 106 | service_error_t service_client_start_service(idevice_t device, const char* service_name, service_client_t *client, const char* label) | 106 | service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, uint16_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), uint16_t *error_code) |
| 107 | { | 107 | { |
| 108 | *client = NULL; | 108 | *client = NULL; |
| 109 | 109 | ||
| @@ -122,18 +122,24 @@ service_error_t service_client_start_service(idevice_t device, const char* servi | |||
| 122 | return SERVICE_E_START_SERVICE_ERROR; | 122 | return SERVICE_E_START_SERVICE_ERROR; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | service_error_t res = service_client_new(device, service, client); | 125 | uint16_t ec; |
| 126 | if (res != SERVICE_E_SUCCESS) { | 126 | if (constructor_func) { |
| 127 | debug_info("Could not connect to service %s! Port: %i, error: %i", service_name, service->port, res); | 127 | ec = (uint16_t)constructor_func(device, service, client); |
| 128 | return res; | 128 | } else { |
| 129 | ec = service_client_new(device, service, (service_client_t*)client); | ||
| 130 | } | ||
| 131 | if (error_code) { | ||
| 132 | *error_code = ec; | ||
| 129 | } | 133 | } |
| 130 | 134 | ||
| 131 | if (service) { | 135 | if (ec != SERVICE_E_SUCCESS) { |
| 132 | lockdownd_service_descriptor_free(service); | 136 | debug_info("Could not connect to service %s! Port: %i, error: %i", service_name, service->port, ec); |
| 133 | service = NULL; | ||
| 134 | } | 137 | } |
| 135 | 138 | ||
| 136 | return SERVICE_E_SUCCESS; | 139 | lockdownd_service_descriptor_free(service); |
| 140 | service = NULL; | ||
| 141 | |||
| 142 | return (ec == SERVICE_E_SUCCESS) ? SERVICE_E_SUCCESS : SERVICE_E_START_SERVICE_ERROR; | ||
| 137 | } | 143 | } |
| 138 | 144 | ||
| 139 | /** | 145 | /** |
