示例#1
0
kern_return_t test_apple_AFCOperationCreateGetConnectionInfo(struct am_device *apple, CFTypeRef *response) {
	kern_return_t apple_return = kAMDUndefinedError;
	kern_return_t result = AMDeviceConnect(apple);
	if (SDM_MD_CallSuccessful(result)) {
		result = AMDeviceStartSession(apple);
		if (SDM_MD_CallSuccessful(result)) {
			service_conn_t test_apple_afc_conn;
			result = AMDeviceStartService(apple, CFSTR(AMSVC_AFC), &test_apple_afc_conn, NULL);
			if (SDM_MD_CallSuccessful(result)) {
				struct afc_connection *afc = NULL;
				result = AFCConnectionOpen(test_apple_afc_conn, 0, &afc);
				if (afc) {
					afc_operation conn_info = AFCOperationCreateGetConnectionInfo(kCFAllocatorDefault, NULL);
					result = AFCConnectionProcessOperation(afc, conn_info, 0);
					if (SDM_MD_CallSuccessful(result)) {
						CFTypeRef test = AFCOperationGetResultObject(conn_info);
						if (test) {
							*response = test;
							apple_return = kAMDSuccess;
						}
					}
					AFCConnectionClose(afc);
				}
			}
			AMDeviceStopSession(apple);
		}
		AMDeviceDisconnect(apple);
	}
	return apple_return;
}
示例#2
0
kern_return_t test_apple_AFCConnectionCreate(struct am_device *apple) {
	kern_return_t apple_return = kAMDUndefinedError;
	kern_return_t result = AMDeviceConnect(apple);
	if (SDM_MD_CallSuccessful(result)) {
		result = AMDeviceStartSession(apple);
		if (SDM_MD_CallSuccessful(result)) {
			service_conn_t test_apple_afc_conn;
			result = AMDeviceStartService(apple, CFSTR(AMSVC_AFC), &test_apple_afc_conn, NULL);
			if (SDM_MD_CallSuccessful(result)) {
				struct afc_connection *afc = NULL;
				result = AFCConnectionOpen(test_apple_afc_conn, 0, &afc);
				if (afc) {
					apple_return = kAMDSuccess;
					AFCConnectionClose(afc);
				}
			}
			AMDeviceStopSession(apple);
		}
		AMDeviceDisconnect(apple);
	}
	return apple_return;
}
示例#3
0
void upload_file(AMDeviceRef device) {
    service_conn_t houseFd = start_house_arrest_service(device);

    afc_file_ref file_ref;

    afc_connection afc_conn;
    afc_connection* afc_conn_p = &afc_conn;
    AFCConnectionOpen(houseFd, 0, &afc_conn_p);

    //        read_dir(houseFd, NULL, "/");

    if (!target_filename)
    {
        target_filename = get_filename_from_path(doc_file_path);
    }
    char *target_path = malloc(sizeof("/Documents/") + strlen(target_filename) + 1);
    strcat(target_path, "/Documents/");
    strcat(target_path, target_filename);

    size_t file_size;
    void* file_content = read_file_to_memory(doc_file_path, &file_size);

    if (!file_content)
    {
        PRINT("Could not open file: %s\n", doc_file_path);
        exit(-1);
    }

    assert(AFCFileRefOpen(afc_conn_p, target_path, 3, &file_ref) == 0);
    assert(AFCFileRefWrite(afc_conn_p, file_ref, file_content, file_size) == 0);
    assert(AFCFileRefClose(afc_conn_p, file_ref) == 0);
    assert(AFCConnectionClose(afc_conn_p) == 0);

    free(target_path);
    free(file_content);
}
 static int ConnectionClose(AFCCommConnection* Connection)
 {
     return AFCConnectionClose(Connection);
 }