Граф коммитов

106 Коммитов

Автор SHA1 Сообщение Дата
lougeniac64 cc29c6925f Removed obsolete iOS sync logic 2023-07-17 22:39:21 +00:00
Mark Hammond 9b9345bac0 Add some more commands to places-utils
* create-fake-visits will create a (possibly large) number of visits.
* delete-history will remove all history
* show-stats will show some stats for the places DB.
2023-06-27 15:14:06 +00:00
Ben Dean-Kawamura 6f74754b7a Refactored fxa-client
This was part of my work for the auth PR, but I think it's useful
separatedly.

- Updated `fxa-client` to be a single binary.
- Added a cargo alias so it can be run with `cargo fxa [args]`.

I think this makes it easier to use and also will make it easier to
expand the functionality.  It's easier to add another clap subcommand
than to add a new binary.
2023-06-27 13:17:30 +00:00
Ben Dean-Kawamura 383333b93f Reworked FirefoxAccount construction
Made `FirefoxAccount` input a single `FxaConfig` instance for all of
it's configuration.  I want to add more constructor arguments but don't
want to end up with a huge argument count.

Made the example code use the public API, not the internal module.
`FxaConfig` helps ease this transition.  The motivation for this is that
I want to move FxaClent and some other fields to the public
`FirefoxAccount` instance, which means the example code needs to start
using it.  This also results in some nice code cleanups.

Deleted the `fxa-client/migration` example, we're not really
using the migration code anymore.

Now that we're not exposing the `internal` module as pub, Rust is
noticing a lot of dead code.  For the serde JSON structs, I kept the
dead fields and added an annotation.  For the unused functions, I just
deleted them.

Created an `FxaServer` enum.  This matches how the android wrapper
handles it and I don't think we need to input arbitrary URLs here.
2023-06-20 18:46:28 +00:00
Mark Hammond 6c4c65e8ce Move sync-test to the fxa cli helper. 2023-06-14 20:27:20 +00:00
Tarik Eshaq ffb06acd44 Updates rusqlite to 0.29.0 and libsqlite to 0.26.0 2023-06-13 01:11:26 +00:00
Mark Hammond b8d3b225ee Add a debug-tools feature to sql-support.
It steals a cute function from webext-storage which can dump any
arbitrary query.

It also allows for the use of a `dbg()` sql function which can be
helpful trying to debug SQL as it is executing. The function is also
available as a no-op when the feature is not available to prevent us
accidently using it in released code.

Sadly this required updating the use of prettytable-rs as the old
version crashed on Apple silicon, which had a bit of a blow-on effect
on other dependencies.
2023-06-09 15:48:44 +00:00
Tarik Eshaq b9755e3766 Adds back boolean for unsubscribe 2023-05-31 15:39:52 +00:00
Tarik Eshaq d72a995d05 Cleans up errors 2023-05-31 15:39:52 +00:00
Tarik Eshaq a34eafae65 Introduces breaking changes 2023-05-31 15:39:52 +00:00
Tarik Eshaq ae2cee7bd3 Address code review comments 2023-05-31 15:39:52 +00:00
Ben Dean-Kawamura fe156a74fd Clippy fixes
Also made the `clip-support` example work again
2023-05-26 14:34:03 +00:00
Ben Dean-Kawamura 6c7d5f9b0f Use the new `EncryptorDecryptor` with autofill as well
We might as well get the extra reporting benefits.
2023-04-25 15:32:16 -04:00
Mark Hammond 6272142b2b
Remove dependency on the clipboard crate for the tabs example (#5443) 2023-03-29 11:46:40 +11:00
Mark Hammond 70bebedbec
Minor cleanups of sync engine code: (#5365)
* Consolidate the various types used for a "collection name" - now we
  use `Cow` rather than the various `&'static str`, `&str` and `String`
  used previously.
* This made it easier to clean up the `LocalCollState` state machine
  to have the `Ready` state directly provide the `CollState` due to
  a mismatch between `'static str` and `String` reprs of collections.
* No longer store the outgoing timestamp in an OutgoingChangeset - it was
  never actually used and just creates unnecessary complexity.
* OutgoingChangsets now always supply the BSOs as they are created,
  meaning less `mut` objects.
* Bonus fix to unbreak the `places-utils` example.
2023-02-08 13:50:38 +11:00
Ben Dean-Kawamura b3a573164e Clippy and check-dependency fixes 2023-01-27 15:32:17 -05:00
Tarik Eshaq b8ba517115
remove iOS bookmarks migration code (#5276)
* Removes old iOS bookmarks migration code

* Adds changelog

* Fixes cargo clippy
2023-01-04 17:53:31 -05:00
lougeniaC64 05793e9376
Exposed credit card API for iOS (#5293) 2023-01-03 15:09:55 -05:00
Mark Hammond 24098bcafd
Update rust version to 1.65.0, MSR to 1.61 (#5299) 2022-12-16 14:02:22 +11:00
Mark Hammond ba67a665dd
Update rusqlite to 0.28.0 (#5282) 2022-12-08 15:01:25 +11:00
Mark Hammond 4d858e4266
Add support for lastModified in ClientRemoteTabs (#5230) (#5273) 2022-12-04 19:08:06 +11:00
Ben Dean-Kawamura b980a615b6 Use incremental vacuum for places maintenance
Metrics from GLAM indicate the VACUUM command is taking a long time and
doesn't seem to be dropping.  After reading the docs a bit, it seems to
me that VACUUM always copies the entire database which could indeed be
slow for large DBs.

Switched to using an incremental vacuum.  This only tries to truncate N
pages (set to 2 here) at time rather than all free pages.  Also it
doesn't try to defragment the pages.

Incremental vacuum requires a PRAGMA setting and for non-empty databases
a VACUUM run.  This means that existing databases will require one full
vacuum, then future vacuums should run faster.

Also added a places-utils command to run maintenance.  I used this to
test that the incremental vacuum is ineed faster.
2022-12-01 09:48:17 -05:00
Ben Dean-Kawamura 8f9d0d365c Make places metrics more fine-grained (#5246)
Added `execute_one()` method to `ConnExt`.  I've wanted this a few times
before, but it's really nice for this new code.
2022-11-17 18:28:53 -05:00
Mark Hammond acc6fb67be
Unbitrot the sync-pass example's handling of the sync key (#5231) 2022-11-12 13:39:11 +11:00
Tarik Eshaq 0648c69d7b
Removes db files added by accident (#5211) 2022-11-02 14:33:13 -06:00
Ben Dean-Kawamura 01aeb370c3 Further reworked the places errors
- Renamed `PlacesInternalError` to `Error` because it seems more
  idiomatic
- Renamed `PlacesError` to `PlacesApiError` to make it consistent with
  the logins errors.  I considered just calling this `ApiError` but I
  thought that would be confusing for consumers since they won't always
  have the `places::` prefix before the class name.
- Removed `JsonError`, which seems like it was unusped
- Merged `InternalError` into `UnexpectedPlacesException`
- Merged `UrlTooLong` into `UrlParseFailed` for `PlacesApiError`
- Merged `InvalidBookmarkUpdate`, `CannotUpdateRoot`, `InvalidParent`
  into `InvalidBookmarkOperation` for `PlacesApiError`

Use the fielded style for `PlacesApiError` in places.udl.  Updated
`PlacesApiError` to use named fields to be compatible with this.

On swift renamed `PlacesApiError`, which was defined on top of the
normal errors to `PlacesConnectionError`.
2022-10-27 18:37:45 -04:00
Ben Dean-Kawamura 1c4093bb3d Refactored places to use the new error handling system
Replaced the error_support method with the new system that consists of:
  - `PlacesInternalError`: used internally in the crate.  This replaces
    the old `ErrorKind` enum and is the error for `Result<>`.
  - `PlacesError`: used for external errors that we return to UniFFI
    consumers.  This replaces the old `Error` enum and is the error for
    `ApiResult<>`
  - A `GetErrorHandling` impl to convert internal errors to external
    errors and report to sentry.  For now, I tried to make the sentry
    error reporting more-or-less match the old error reporting, which
    means reporting lots of internal errors.  The plan is going to be to
    check sentry and most likely turn some of those into logs rather
    than errors.

Reworked all top-level API methods to return `PlacesApiResults` and use
the `handle_error!` macro to do the error conversion/reporting.

Use `thiserror` to handle converting errors from other crates into
`PlacesInternalError`.
2022-10-20 09:05:59 -04:00
Tarik Eshaq 1094f87f24
Adds ios history migration and example (#5077)
* Adds ios history migration and example

* Exposes history migration function to iOS

* Adds changelog

* Adds basic test case for migration

* Moves timestamp computation to places

* Adds sync last timestamp
2022-09-15 15:15:06 -07:00
Mark Hammond d8503475f4
Merge sync15-traits back into sync15 via features. (#5125) 2022-09-15 11:09:04 +10:00
Mark Hammond 335bf75d09
Modernize sync15::error and other misc sync15 cleanups (#5121)
* Moves sync15::error to a simple enum in line with most other crates.
* Cleanups to Cargo.toml in sync15 and sync15-traits
* Remove old unused sync15::migrate_state
2022-09-09 08:56:30 +10:00
Mark Hammond 71cb0f6fa4
Add a 'full-sync' feature to tabs. (#5102)
If the new feature is enabled, tabs can sync - otherwise it can not.
The intention is that later there will be a "bridged-sync" feature,
and that in-practice, one or the other will be enabled - however, the
way features work, it must be possible that no features are enabled.

The new feature is not a default feature because I expect we will
want the default features to be what desktop consumes - ie, that
the default feature will be bridged-sync once that exists.

This isn't strictly required yet, but is being done now to make
future reviews of the bridged engine easier to reason about.
2022-09-01 10:52:50 +10:00
Mark Hammond 8002d1597d Fix tab example's use of sync key 2022-08-09 08:40:40 +10:00
Ben Dean-Kawamura 46c31af855 Adding history pruning (#5011)
Added parameter to `run_maintanance()` to allow applications to request a maximum DB size and
prune the database if it's bigger than that.

Added code to find the best visits to prune and delete them.
2022-07-28 17:49:25 -04:00
Ben Dean-Kawamura 72d6425836 Reworking the logins error handling (#5033)
- Use `thiserror` only to define our errors rather than a weird
  combination of `thiserror` and `error_support`
- There's now a few error enums:
  - `LoginsStorageError` is for public API errors
  - `LoginsError` is for internal errors
  - `InvalidLoginsReason` is a subtype for `LoginsError::InvalidLogin`
- Extracted the error tracking code from `impl From<LoginsError>
  for LoginsStorageError` and put it in its own methods.
- Made `LoginsError::InvalidKey` convert to
  `LoginsStorageError::CryptoError`.  I think this makes sense since
  from the app's point of view an invalid key is the same thing as
  data that can't be decrypted.  Note: that `InvalidKey` used to mean
  something different when we were using sqlcipher databases, but that's
  not applicable anymore.
- Dropped the `throw!` macro.  The error types are simple enough now
  that we can just use a return statement.
- Added note about PII
- Renamed `LoginsError::label()` to `LoginsError::group_name()`
- Updated the rest of the code to use the new API
- Removed the backtrace functionality from `sync-pass`.  I'm kind of
  doubt it was working anyways.
2022-07-13 13:56:31 +10:00
Mark Hammond ddc6a53a78
Have the tabs-sync example write a dummy tab if there's no clipboard (#4961) 2022-05-25 12:17:10 +10:00
lougeniaC64 0f8a0f3da2
Updated tabs component for iOS integration (#4905) 2022-05-24 15:19:58 -04:00
Emilio Cobos Álvarez 5ad5931c2d
Follow-up to #4933: Remove tempdir, use tempfile instead. (#4935)
tempdir is unmaintained and uses an outdated version of rand. We already
depend on tempfile.
2022-05-02 20:15:12 -07:00
Tarik Eshaq f7c5588b1e
Update rand and parking lot (#4937)
* Update rand and parking_lot.

I need this to update other Gecko dependencies.

* Update dependency_summary to account for various windows-rs crates.

I'm not sure why it wasn't failing to find the relevant licenses before,
it was likely a pre-existing issue.

* Update dependency summaries.

* Runs dependency summaries on a mac

Co-authored-by: Emilio Cobos Álvarez <emilio@crisal.io>
2022-05-02 17:18:12 -07:00
Thom Chiovoloni 81ea5fa0b2
Update tests and examples 2022-03-06 20:27:57 -08:00
Thom Chiovoloni f8f3589be3
Update everything to non-depreceated rusqlite functions 2022-03-06 20:27:49 -08:00
Thom Chiovoloni 4d3f7db7fc
Bump versions of `rusqlite`/`libsqlite3-sys` in `Cargo.toml`s 2022-03-06 20:27:06 -08:00
Mark Hammond 1f21f33061
Persist remote tabs to a sql database. (#4862) 2022-03-02 13:30:57 +11:00
Mark Hammond 30892940c1
Make tabs example work on Windows and upgrade to StructOpt (#4859) 2022-02-26 12:49:02 +11:00
Mark Hammond 862e30d43f
Remove duplicate DeviceType enum implementations. (#4397) 2022-02-23 10:09:59 +11:00
Ben Dean-Kawamura f504aa09ae Refactoring the interrupt code
- Refactored the `SqlInterruptHandle` and `SqlInterruptScope` types to
  work better with the new code.

  - Types now store an `SqlInterruptHandle` and use that to create
    `SqlInterruptScope` instances. This seems more natural than storing
    an `Arc<AtomicUsize>` and using that to create both the scope and
    handle.
  - Creating an `SqlInterruptScope` can fail if we are in shutdown mode.
    Updated the calling code to handle this error.
  - We now use `Ordering::Relaxed`.  This has less overhead compared to
    `Ordering::SeqCst` and I'm pretty sure we don't need the extra
    synchronization guarantees

- Moved the `Interrupted` and `Interuptee` types to their own modules.
  Updated the shutdown module documentation.

- Changed the `PlacesApi` sync methods to to just send `NeverInterrupts`
  to the `sync_multiple()`.  I think this is fine given that we only use
  these methods on iOS and we don't have actual interruption support
  there yet.

- Removed the `PlacesApi::new_sync_conn_interrupt_handle()` method.  If we want
  to interrupt syncing, then we should just enter shutdown mode.
2022-02-16 10:57:10 -05:00
Ben Dean-Kawamura db23ab40f6 Moving modules from sql-support to interrupt-support
The `SqlInterruptHandle` and `SqlInterruptScope` types and especially
the shutdown code feels like belongs in `interrupt-support` better than
`sql-support`.

Removed the `implement_into_ffi_by_pointer!(SqlInterruptHandle)` call.
I don't think we need that now that everything is UniFFIed.
2022-02-16 10:57:10 -05:00
Tarik Eshaq 68c10e0673
upgrades to rust 2021 [ci full] (#4822)
* upgrades to rust 2021

* Push rust minimum version to 1.57
2022-02-07 09:38:05 -08:00
Ben Dean-Kawamura 91d0bab23e Adding shutdown support to sql-support
When the user wants to shutdown the application, we should:
  - Interrupt all current `SqlInterruptScope`s
  - Interrupt all future `SqlInterruptScope`s when they're created.

The nice thing about this approach is that it didn't require invasive
changes in places to support it.  The main new requirement was we need
to have a way to get a `Weak<AsRef<SqlInterruptHandler>>` for each
database.  In order to support that, I needed to:

 - For the read/write and read-only connections: have `PlacesConnection`
   store an `SqlInterruptHandler` and implement `AsRef`.
 - For the sync connection: Added struct that wraps the
   `Mutex<PlacesDb>` and also stores a `SqlInterruptHandler` and
   implements `AsRef`.

Updated `places-utils` so that ctrl-c starts shutdown mode.
2022-02-02 10:01:30 -05:00
Sammy Khamis 73427f79a6
Places uniffication (#4770)
* initial conversion of errors for places uniffication

* Converted history metadata functions for places uniffication

* Converted kotlin history metadata functions

* Converted iOS history metadata functions

* [Places uniffication] Fix places error issues (#4687)

* remove uniffi-specific wrapper and updated error test

* Uniffi VisitObservation and apply_observation (#4689)

* uniffied VisitObservation, HistoryVisitInfo and methods using those structs

* Uniffi top frecent site info (#4711)

* Uniffi top frecent site info

* Uniffis FrecencyThresholdOption

* Uniffi Places Sync (#4714)

* uniffi places sync and sync15 functions

* Uniffi Search result and match url (#4720)

* Uniffi query autocomplete

* uniffi places_accept_result

* uniffi places_match_url

* cargo fmt

* cargo clippy

* remove accept_result from ffi crate

* Adds comment on the uniffi bug with varaint shadowing type

* Uniffi Places Interrupt methods (#4726)

* uniffi places interrupt functions

* Consolidate types (#4736)

* Updates the visit observation to use URL

* Uses VisitTransition for HistoryVisitInfo

* updates uniffi to 0.16

* Uniffied bookmarks

* switch to use uint in the apis for adding bookmarks (#4747)

* Remove the manual places FFI entirely.

* folders and separators now have non-nullable parents

* Always insert via Insertable items, and clarify separation between node types.

* Add json_tree module with all json-based types and implementation.

* Fix swift warnings re non-null parentGuid

* bookmarks: Remove public_node and introduce a fetch module

* Update swift code to make breaking changes fixes cleaner (#4766)

* rebased and added changelog entry

Co-authored-by: lougeniac64 <lougeniaC64@users.noreply.github.com>
Co-authored-by: Tarik Eshaq <teshaq@mozilla.com>
Co-authored-by: Mark Hammond <mhammond@skippinet.com.au>
2022-01-20 15:00:00 -05:00
Tarik Eshaq 36ae51e12e
Upgrade rust to 1.57 (#4723)
* upgrades rust to 1.57

* fixes clippy

* Document where to find the latest version moz-central uses

* an attempt to fix broken cargo bench

* Uses _ instead of dead_code where possible

* runs cargo update
2021-12-20 10:48:14 -07:00