Expose ios import over the FFI, and note it in the changelog

This commit is contained in:
Thom Chiovoloni 2019-04-24 14:19:10 -07:00
Родитель 00c48e0e36
Коммит 46bc8d7249
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 31F01AEBD799934A
4 изменённых файлов: 40 добавлений и 0 удалений

Просмотреть файл

@ -9,6 +9,13 @@
### What's new
- iOS only: Logins store has a new (static) `numOpenConnections` function, which can be used to detect leaks. ([#1070](https://github.com/mozilla/application-services/pull/1070))
## Places
### What's New
- iOS only: PlacesApi can now migrate bookmark data from a `browser.db` database
via the `migrateBookmarksFromBrowserDb` function.
([#1078](https://github.com/mozilla/application-services/pull/1078))
# v0.27.1 (_2019-04-26_)

Просмотреть файл

@ -80,6 +80,21 @@ pub extern "C" fn places_connection_new(
Ok(CONNECTIONS.insert(api.open_connection(conn_type)?))
})
}
#[no_mangle]
pub extern "C" fn places_bookmarks_import_from_ios(
api_handle: u64,
db_path: FfiStr<'_>,
error: &mut ExternError,
) {
log::debug!("places_bookmarks_import_from_ios");
APIS.call_with_result(error, api_handle, |api| -> places::Result<_> {
// TODO: accept file URLs directly for consistency with `places_api_new`.
let url = url::Url::from_file_path(db_path.as_str())
.map_err(|_| places::error::ErrorKind::IllegalDatabasePath(db_path.as_str().into()))?;
places::import::import_ios_bookmarks(api, url)?;
Ok(())
})
}
// Best effort, ignores failure.
#[no_mangle]

Просмотреть файл

@ -73,6 +73,21 @@ public class PlacesAPI {
}
}
/**
* Migrate bookmarks tables from a `browser.db` database.
*
* This is (mostly) a noop if there's nothing in the `bookmarksLocal` table,
* which should be the case for most sync users. For these users, they're
* better off repopulating things by syncing.
*/
open func migrateBookmarksFromBrowserDb(path: String) throws {
try queue.sync {
try PlacesError.unwrap { error in
places_bookmarks_import_from_ios(handle, path, error)
}
}
}
/**
* Open a new reader connection.
*

Просмотреть файл

@ -69,6 +69,9 @@ char *_Nullable places_match_url(PlacesConnectionHandle handle,
const char *_Nonnull search,
PlacesRustError *_Nonnull out_err);
void places_bookmarks_import_from_ios(PlacesAPIHandle handle,
const char *_Nonnull db_path,
PlacesRustError *_Nonnull out_err);
// XXX we should move this to protobufs rather than port it to swift.
// char *_Nullable places_get_visited(PlacesConnectionHandle handle,