diff options
Diffstat (limited to 'src/heartbeat.c')
| -rw-r--r-- | src/heartbeat.c | 33 |
1 files changed, 3 insertions, 30 deletions
diff --git a/src/heartbeat.c b/src/heartbeat.c index 817c6ad..0f8d2f3 100644 --- a/src/heartbeat.c +++ b/src/heartbeat.c | |||
| @@ -112,36 +112,9 @@ heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descr | |||
| 112 | */ | 112 | */ |
| 113 | heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_client_t * client, const char* label) | 113 | heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_client_t * client, const char* label) |
| 114 | { | 114 | { |
| 115 | *client = NULL; | 115 | heartbeat_error_t err = HEARTBEAT_E_UNKNOWN_ERROR; |
| 116 | 116 | service_client_factory_start_service(device, HEARTBEAT_SERVICE_NAME, (void**)client, label, SERVICE_CONSTRUCTOR(heartbeat_client_new), &err); | |
| 117 | lockdownd_client_t lckd = NULL; | 117 | return err; |
| 118 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(device, &lckd, label)) { | ||
| 119 | idevice_free(device); | ||
| 120 | debug_info("Could not create a lockdown client."); | ||
| 121 | return HEARTBEAT_E_UNKNOWN_ERROR; | ||
| 122 | } | ||
| 123 | |||
| 124 | lockdownd_service_descriptor_t service = NULL; | ||
| 125 | lockdownd_start_service(lckd, HEARTBEAT_SERVICE_NAME, &service); | ||
| 126 | lockdownd_client_free(lckd); | ||
| 127 | |||
| 128 | if (service->port <= 0) { | ||
| 129 | debug_info("Could not start heartbeat service!"); | ||
| 130 | return HEARTBEAT_E_UNKNOWN_ERROR; | ||
| 131 | } | ||
| 132 | |||
| 133 | heartbeat_error_t res = heartbeat_client_new(device, service, client); | ||
| 134 | if (res != HEARTBEAT_E_SUCCESS) { | ||
| 135 | debug_info("Could not connect to heartbeat! Port: %i, error: %i", service->port, res); | ||
| 136 | return res; | ||
| 137 | } | ||
| 138 | |||
| 139 | if (service) { | ||
| 140 | lockdownd_service_descriptor_free(service); | ||
| 141 | service = NULL; | ||
| 142 | } | ||
| 143 | |||
| 144 | return HEARTBEAT_E_SUCCESS; | ||
| 145 | } | 118 | } |
| 146 | 119 | ||
| 147 | /** | 120 | /** |
