Mir

Merge lp:~mir-team/mir/public-cookie-api into lp:mir

Proposed by Brandon Schaefer
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3269
Proposed branch: lp:~mir-team/mir/public-cookie-api
Merge into: lp:mir
Diff against target: 4380 lines (+1209/-588)
103 files modified
3rd_party/CMakeLists.txt (+1/-0)
3rd_party/android-input/android/frameworks/base/include/androidfw/Input.h (+8/-6)
3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h (+4/-4)
3rd_party/android-input/android/frameworks/base/services/input/Input.cpp (+6/-6)
3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp (+10/-10)
debian/control (+2/-2)
debian/libmircookie2.install (+1/-1)
include/client/mir/events/event_builders.h (+21/-3)
include/client/mir_toolkit/events/event.h (+2/-0)
include/client/mir_toolkit/events/input/input_event.h (+18/-1)
include/client/mir_toolkit/mir_client_library.h (+1/-0)
include/client/mir_toolkit/mir_cookie.h (+71/-0)
include/client/mir_toolkit/mir_surface.h (+9/-0)
include/cookie/mir/cookie/authority.h (+57/-50)
include/cookie/mir/cookie/cookie.h (+57/-0)
include/server/mir/server.h (+4/-4)
include/server/mir/shell/abstract_shell.h (+1/-1)
include/server/mir/shell/shell.h (+1/-1)
include/server/mir/shell/shell_wrapper.h (+1/-1)
src/client/CMakeLists.txt (+3/-1)
src/client/events/event_builders.cpp (+62/-13)
src/client/input/android/android_input_lexicon.cpp (+7/-3)
src/client/input/input_event.cpp (+97/-1)
src/client/mir_cookie.cpp (+49/-0)
src/client/mir_cookie.h (+40/-0)
src/client/mir_surface.cpp (+5/-5)
src/client/mir_surface.h (+1/-2)
src/client/mir_surface_api.cpp (+2/-3)
src/client/rpc/mir_display_server.cpp (+1/-1)
src/client/rpc/mir_display_server.h (+1/-1)
src/client/symbols.map (+7/-0)
src/cookie/CMakeLists.txt (+5/-3)
src/cookie/authority.cpp (+97/-32)
src/cookie/format.h (+35/-0)
src/cookie/hmac_cookie.cpp (+53/-0)
src/cookie/hmac_cookie.h (+51/-0)
src/cookie/symbols.map (+5/-5)
src/include/common/mir/events/event_private.h (+4/-4)
src/include/common/mir/protobuf/display_server.h (+1/-1)
src/include/cookie/mir/cookie/blob.h (+19/-30)
src/include/server/mir/default_server_configuration.h (+3/-3)
src/include/server/mir/frontend/security_check_failed.h (+0/-34)
src/include/server/mir/frontend/shell.h (+1/-1)
src/include/server/mir/frontend/template_protobuf_message_processor.h (+2/-2)
src/include/server/mir/server_configuration.h (+2/-2)
src/protobuf/mir_protobuf.proto (+1/-2)
src/server/CMakeLists.txt (+1/-0)
src/server/default_server_configuration.cpp (+5/-5)
src/server/frontend/CMakeLists.txt (+0/-1)
src/server/frontend/default_configuration.cpp (+1/-1)
src/server/frontend/default_ipc_factory.cpp (+4/-4)
src/server/frontend/default_ipc_factory.h (+3/-3)
src/server/frontend/protobuf_message_processor.cpp (+4/-4)
src/server/frontend/security_check_failed.cpp (+0/-24)
src/server/frontend/session_mediator.cpp (+10/-10)
src/server/frontend/session_mediator.h (+4/-4)
src/server/frontend/shell_wrapper.cpp (+2/-2)
src/server/frontend/shell_wrapper.h (+1/-1)
src/server/input/android/input_sender.cpp (+3/-3)
src/server/input/default_configuration.cpp (+3/-3)
src/server/input/default_event_builder.cpp (+18/-11)
src/server/input/default_event_builder.h (+3/-3)
src/server/input/default_input_device_hub.cpp (+6/-6)
src/server/input/default_input_device_hub.h (+4/-4)
src/server/input/key_repeat_dispatcher.cpp (+7/-4)
src/server/input/key_repeat_dispatcher.h (+3/-3)
src/server/input/surface_input_dispatcher.cpp (+1/-2)
src/server/input/validator.cpp (+1/-1)
src/server/server.cpp (+2/-2)
src/server/shell/abstract_shell.cpp (+1/-1)
src/server/shell/frontend_shell.cpp (+2/-2)
src/server/shell/frontend_shell.h (+1/-1)
src/server/shell/shell_wrapper.cpp (+2/-2)
src/server/symbols.map (+6/-6)
tests/acceptance-tests/test_client_cookie.cpp (+72/-47)
tests/acceptance-tests/test_client_input.cpp (+1/-1)
tests/acceptance-tests/test_surface_modifications.cpp (+3/-4)
tests/acceptance-tests/test_surface_placement.cpp (+1/-2)
tests/acceptance-tests/test_surface_raise.cpp (+83/-54)
tests/acceptance-tests/test_surface_specification.cpp (+3/-4)
tests/include/mir/test/doubles/mock_shell.h (+1/-1)
tests/include/mir/test/doubles/stub_display_server.h (+1/-1)
tests/integration-tests/CMakeLists.txt (+1/-0)
tests/integration-tests/input/test_single_seat_setup.cpp (+3/-3)
tests/mir_test_doubles/CMakeLists.txt (+1/-0)
tests/unit-tests/CMakeLists.txt (+1/-0)
tests/unit-tests/client/input/test_android_input_receiver.cpp (+2/-2)
tests/unit-tests/client/input/test_xkb_mapper.cpp (+1/-2)
tests/unit-tests/frontend/test_event_sender.cpp (+1/-2)
tests/unit-tests/frontend/test_session_mediator.cpp (+10/-11)
tests/unit-tests/input/android/test_android_input_lexicon.cpp (+7/-10)
tests/unit-tests/input/android/test_android_input_sender.cpp (+8/-13)
tests/unit-tests/input/evdev/test_libinput_device.cpp (+3/-3)
tests/unit-tests/input/test_default_input_device_hub.cpp (+3/-3)
tests/unit-tests/input/test_event_builders.cpp (+7/-12)
tests/unit-tests/input/test_event_filter_chain_dispatcher.cpp (+1/-1)
tests/unit-tests/input/test_key_repeat_dispatcher.cpp (+5/-5)
tests/unit-tests/input/test_surface_input_dispatcher.cpp (+10/-10)
tests/unit-tests/input/test_validator.cpp (+1/-1)
tests/unit-tests/input/test_x11_platform.cpp (+2/-2)
tests/unit-tests/scene/test_abstract_shell.cpp (+4/-4)
tests/unit-tests/scene/test_surface.cpp (+2/-2)
tests/unit-tests/test_mir_cookie.cpp (+44/-36)
To merge this branch: bzr merge lp:~mir-team/mir/public-cookie-api
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Abstain
Mir CI Bot continuous-integration Approve
Andreas Pokorny (community) Approve
Alexandros Frantzis (community) Needs Fixing
Alberto Aguirre (community) Approve
Chris Halse Rogers Approve
Daniel van Vugt Abstain
Kevin DuBois (community) Approve
Review via email: mp+282279@code.launchpad.net

Commit message

Re-add support for get a MirCookie as well as Raising a surface with a MirCookie.

The MirCookie structure is now opaque.

Description of the change

Re-add support for get a MirCookie as well as Raising a surface with a MirCookie.

The MirCookie structure is now opaque.

Different APIs we have considered:
https://pastebin.canonical.com/147720/

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Should the mir_input_event_get_cookie use MirCookie* or just a uint8_t* (or char*?)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3243
https://mir-jenkins.ubuntu.com/job/mir-ci/31/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/31/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/31/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

> Should the mir_input_event_get_cookie use MirCookie* or just a uint8_t* (or
> char*?)

my vote is MirCookie*

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

After ROAF and I talking for a bit we settled on void* since we are send a stream of *unknown* bytes. Since not just the mac is being sent, so is the timestamp

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3244
https://mir-jenkins.ubuntu.com/job/mir-ci/45/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/45/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/45/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

The Story Of The Void*:
Brandon and I had a *long* back and forth about client API wrt MirCookie, ranging from having a MirCookie type that can be converted into a MirBlob, to essentially duplicating MirBlob's API against a MirCookie, to a non-opaque struct MirCookie { size_t length, void* data };

Neither of us were particularly happy with any of them.

The void* API here is (a) transparent - it's clear to everyone that they've just got a blob of data, (b) quick to implement, and (c) is minimally constraining for future, better, implementations with better APIs.

General comment: I'm pretty sure you don't need reinterpret_cast<> to go between void* and MirCookie*; static_cast<MirCookie*> should be sufficient. (Wheras you *do* need to reinterpret_cast between uint8_t* and uint64_t*)

42 + * \params[in] ev The input event
43 + * \params[in] cookie An allocated void* with exactly cookie_size bytes
44 + * \params[in] size The size of the MirCookie
45 + */
46 +void mir_input_event_copy_cookie(MirInputEvent const* ev, void* cookie, size_t size);

Two things: do we need to pass size in here? We're only going to assert that it's exactly mir_input_event_get_cookie_size(), right?

And: If we do keep the size, you need to update the comment; no MirCookie here ☺.

Also a couple of inline comments.

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3245
https://mir-jenkins.ubuntu.com/job/mir-ci/46/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/46/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/46/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3246
https://mir-jenkins.ubuntu.com/job/mir-ci/47/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/47/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/47/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

not too flummoxed about use of void*, especially if you & Chris gave it more thought than I had behind my comment. Some other things that I'm not too flummoxed about (esp given that (as I understand) this is needed in short order)

+ auto const* pev = mir_input_event_get_pointer_event(ev);
no need for * (a few other places)

+ // FIXME Moveing to 160bits soon
typo

+ void* cookie = malloc(size);
would be a bit better to use a RAII type in allocation for this test (and would eliminate the need for a destructor too)

768: std::mutex mutex;
A bit strange to have the mutex be public, and require locking it before accessing some members. Would be better encapsulated to have functions on the object to do that.

review: Approve
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> not too flummoxed about use of void*, especially if you & Chris gave it more
> thought than I had behind my comment. Some other things that I'm not too
> flummoxed about (esp given that (as I understand) this is needed in short
> order)
>
> + auto const* pev = mir_input_event_get_pointer_event(ev);
> no need for * (a few other places)

I was mainly doing that so you can see its a pointer (I like seeing types sometimes), but yeah auto captures that :). Fixed.

>
> + // FIXME Moveing to 160bits soon
> typo
>

Opps. Fixed.

> + void* cookie = malloc(size);
> would be a bit better to use a RAII type in allocation for this test (and
> would eliminate the need for a destructor too)
Yes! I attempted it but ran into issue when I was using the MirCookie* since the size was not known (should have just written my own destructor for the shared_ptr to cast and delete[].) Fixed.

>
> 768: std::mutex mutex;
> A bit strange to have the mutex be public, and require locking it before
> accessing some members. Would be better encapsulated to have functions on the
> object to do that.

Agreed, and it looks much cleaner :). Fixed.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

There's stuff I'm concerned about, but I'm out of time today to review properly - will get to it first thing tomorrow.

review: Abstain
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

(pushing coming in a few :)

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

void* is an incomplete type, soo to put it into a shared/unique ptr fails on a static_assert. I suppose for testing i could just cast it to a uint8_t, since its in bytes... or just leave it with a malloc/free :)

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3247
https://mir-jenkins.ubuntu.com/job/mir-ci/58/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/58/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/58/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3249
https://mir-jenkins.ubuntu.com/job/mir-ci/59/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/59/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/59/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Bunch of locking issues still in the tests; marked inline.

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3250
https://mir-jenkins.ubuntu.com/job/mir-ci/60/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/60/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/60/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3251
https://mir-jenkins.ubuntu.com/job/mir-ci/61/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/61/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/61/rebuild

review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Different APIs we have considered:
https://pastebin.canonical.com/147720/

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3250
http://jenkins.qa.ubuntu.com/job/mir-ci/6025/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5541
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4448
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5497
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/281
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/349
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/349/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/349
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/349/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5494
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5494/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7964
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26690
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/277
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/277/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/135
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26691

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6025/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

566 + void handle_input_event(MirInputEvent const* iev)
567 + {
568 + std::lock_guard<std::mutex> lk(mutex);
569 + if (mir_input_event_has_cookie(iev))
570 + {
571 + auto const size = mir_input_event_get_cookie_size(iev);
572 + std::vector<uint8_t> cookie(size);
573 +
574 + mir_input_event_copy_cookie(iev, cookie.data());
575 + out_cookies.push_back(cookie);
576 + }
577 +
578 + event_count++;
579 + }
580 +
581 + size_t get_event_count() const
582 + {
583 + std::lock_guard<std::mutex> lk(mutex);
584 + return event_count;
585 + }
586 +
587 + size_t cookie_size() const
588 + {
589 + std::lock_guard<std::mutex> lk(mutex);
590 + return out_cookies.size();
591 + }
592 +
593 + std::vector<uint8_t> back_cookie() const
594 + {
595 + std::lock_guard<std::mutex> lk(mutex);
596 + return out_cookies.back();
597 + }
598 +
599 + bool cookies_empty() const
600 + {
601 + std::lock_guard<std::mutex> lk(mutex);
602 + return out_cookies.empty();
603 + }

While not blocking, this seems to be a bit of a faff for the testcase vs just directly locking the mutex when necessary :).

Otherwise, I'm OK, pending possible API changes :)

review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3252
https://mir-jenkins.ubuntu.com/job/mir-ci/63/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/63/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/63/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3253
https://mir-jenkins.ubuntu.com/job/mir-ci/64/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/64/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/64/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3252
http://jenkins.qa.ubuntu.com/job/mir-ci/6027/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5543
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4450
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5499
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/283
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/351
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/351/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/351
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/351/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5496
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5496/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7966
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26694
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/279
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/279/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/137
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26695

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6027/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Oh, whoops! Missed one thing, sorry.

This would appear to be a libmircookie ABI break, so should be accompanied by a SONAME bump.

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3254
https://mir-jenkins.ubuntu.com/job/mir-ci/65/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/65/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/65/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3253
http://jenkins.qa.ubuntu.com/job/mir-ci/6028/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5544
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4451
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5500
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/284
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/352
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/352/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/352
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/352/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5497
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5497/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7967
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26696
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/280
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/280/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/138
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26697

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6028/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

+ typedef struct MirCookie MirCookie;

Not needed (at the moment at least), and also may conflict with mir::cookie::MirCookie.

- virtual MirCookie timestamp_to_cookie(uint64_t const& timestamp) = 0;

A *Cookie*Factory that doesn't create cookies seems strange.

Needs discussion/fixing

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3255
https://mir-jenkins.ubuntu.com/job/mir-ci/66/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/66/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/66/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+// FIXME Remove me when we are no longer returning 8 byte MACS
+// We assert that what we return is 8 bytes, so lets test for that for now!
+TEST(MirCookieFactory, assert_8_bytes_for_mac)
+{
+ std::vector<uint8_t> secret{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde, 0x01 };
+ auto factory = mir::cookie::CookieFactory::create_from_secret(secret);
+ uint64_t mock_timestamp{0x322322322332};
+ auto mac = factory->timestamp_to_mac(mock_timestamp);
+
+ EXPECT_EQ(mac.size(), sizeof(uint64_t));
+}

sizeof(uint64_t) is not a synonym for 8 - although platforms with 16bit characters are of little interest to us.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Nits to fix and questions:

CookieFactory looks less and less like a "factory" interface. Would "CookieAuthority" be a better name?

~~~~

+ virtual bool attest_timestamp(MirCookie const* cookie) = 0;

This is the only place in the interface MirCookie is mentioned. Should we simply lose this function and require the user to call the other overload?

~~~~

+void mir_input_event_copy_cookie(MirInputEvent const* ev, void* cookie);

I'm always cautions of APIs that take a target buffer and no buffer size - while not bulletproof the latter is at least a reminder to the user to obtain the size.

~~~~

+void mir_surface_raise_with_cookie(MirSurface* surface, void const* cookie);

By using void* we loose the type safety that we have with other Mir APIs. Can you provide some justification for this design choice? E.g. will this function be primarily for clients that obtained the cookie from a non-Mir API?

~~~~

- * Copyright © 2015 Canonical Ltd.
+ * Copyright © 2016 Canonical Ltd.

Don't remove the 2015 copyright claim. (I know these headers are legally unnecessary and PITA, but let's try to do it right.)

~~~~

+ /* No mac == no size! */
+ return 0;

It should be a precondition that there's a MAC. I.e. the function should begin with something like:

    mir::require(mir_input_event_has_cookie(ev));

~~~~

+#include "mir/cookie.h"
#include "mir/cookie_factory.h"

The first include of the source file should be the corresponding header (to ensure it compiles by itself).

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3255
http://jenkins.qa.ubuntu.com/job/mir-ci/6030/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5547
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4454
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5503
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/285
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/354
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/354/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/354
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/354/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5500
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5500/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7969
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26699
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/281
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/281/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/139
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26703

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6030/rebuild

review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> +// FIXME Remove me when we are no longer returning 8 byte MACS
> +// We assert that what we return is 8 bytes, so lets test for that for now!
> +TEST(MirCookieFactory, assert_8_bytes_for_mac)
> +{
> + std::vector<uint8_t> secret{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde,
> 0x01 };
> + auto factory = mir::cookie::CookieFactory::create_from_secret(secret);
> + uint64_t mock_timestamp{0x322322322332};
> + auto mac = factory->timestamp_to_mac(mock_timestamp);
> +
> + EXPECT_EQ(mac.size(), sizeof(uint64_t));
> +}
>
> sizeof(uint64_t) is not a synonym for 8 - although platforms with 16bit
> characters are of little interest to us.

Hmm should I just not assert this then? Since really all im assert is that our mac == sizeof(uint64_t). So possibly I should just change the name.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> Nits to fix and questions:
>
> CookieFactory looks less and less like a "factory" interface. Would
> "CookieAuthority" be a better name?
>
> ~~~~

Agreed.

>
> + virtual bool attest_timestamp(MirCookie const* cookie) = 0;
>
> This is the only place in the interface MirCookie is mentioned. Should we
> simply lose this function and require the user to call the other overload?
>
> ~~~~

The reason for keeping this, is theres no way to de construct a MirCookie in the public. So once the content hub gets a mir cookie it wont know how to *attest* it.

>
> +void mir_input_event_copy_cookie(MirInputEvent const* ev, void* cookie);
>
> I'm always cautions of APIs that take a target buffer and no buffer size -
> while not bulletproof the latter is at least a reminder to the user to obtain
> the size.
>
> ~~~~

Thats sounds quite reasonable to me.
>
> +void mir_surface_raise_with_cookie(MirSurface* surface, void const* cookie);
>
> By using void* we loose the type safety that we have with other Mir APIs. Can
> you provide some justification for this design choice? E.g. will this
> function be primarily for clients that obtained the cookie from a non-Mir API?
>
> ~~~~

I agree, and will be switching to a MirCookie* for both the copy and these functions since void* and MirCookie* will both be incomplete types.

>
> - * Copyright © 2015 Canonical Ltd.
> + * Copyright © 2016 Canonical Ltd.
>
> Don't remove the 2015 copyright claim. (I know these headers are legally
> unnecessary and PITA, but let's try to do it right.)
>
> ~~~~

Opps. Yeah Ill fix those!

>
> + /* No mac == no size! */
> + return 0;
>
> It should be a precondition that there's a MAC. I.e. the function should begin
> with something like:
>
> mir::require(mir_input_event_has_cookie(ev));
>
> ~~~~

This is true, if we have a function that tells you if an event has a cookie we better require it to actually have one when attempting to construct it!.

>
> +#include "mir/cookie.h"
> #include "mir/cookie_factory.h"
>
> The first include of the source file should be the corresponding header (to
> ensure it compiles by itself).

Will fix!

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> + typedef struct MirCookie MirCookie;
>
> Not needed (at the moment at least), and also may conflict with
> mir::cookie::MirCookie.

Opps thought I removed all thoses... Had an idea at one point that I think made it into a file :)
>
> - virtual MirCookie timestamp_to_cookie(uint64_t const& timestamp) = 0;
>
> A *Cookie*Factory that doesn't create cookies seems strange.
>
> Needs discussion/fixing

Right it doesnt create any MirCookies but it creates what a cookie is. With alans comment, changing the name to:
CookieAuthority

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> > sizeof(uint64_t) is not a synonym for 8 - although platforms with 16bit
> > characters are of little interest to us.
>
> Hmm should I just not assert this then? Since really all im assert is that our
> mac == sizeof(uint64_t). So possibly I should just change the name.

On reflection, if unit8_t exists we're safe to assume 8 bit chars. (And if it doesn't we don't compile.)

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> > + virtual bool attest_timestamp(MirCookie const* cookie) = 0;
> >
> > This is the only place in the interface MirCookie is mentioned. Should we
> > simply lose this function and require the user to call the other overload?
> >
> > ~~~~
>
> The reason for keeping this, is theres no way to de construct a MirCookie in
> the public. So once the content hub gets a mir cookie it wont know how to
> *attest* it.

are you conflating ::MirCookie and mir::cookie::MirCookie?

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> > > + virtual bool attest_timestamp(MirCookie const* cookie) = 0;
> > >
> > > This is the only place in the interface MirCookie is mentioned. Should we
> > > simply lose this function and require the user to call the other overload?
> > >
> > > ~~~~
> >
> > The reason for keeping this, is theres no way to de construct a MirCookie in
> > the public. So once the content hub gets a mir cookie it wont know how to
> > *attest* it.
>
> are you conflating ::MirCookie and mir::cookie::MirCookie?

Well only mir::cookie::MirCookie should be used? The attest_timestamp is in the mir::cookie namespace. Not sure if they are different and being combined? I Could be wrong :)

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Though there will be an issue... if i move from a void* to a MirCookie* in the public API... not sure how to combine a MirCookie* into a mir::cookie::MirCookie*? Just cast it? I would like a MirCookie* vs void* :)

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3258
https://mir-jenkins.ubuntu.com/job/mir-ci/69/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/69/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/69/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Some concerns addressed. Abstaining until I have time to review again.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3259
https://mir-jenkins.ubuntu.com/job/mir-ci/71/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/71/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/71/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3259
http://jenkins.qa.ubuntu.com/job/mir-ci/6034/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5555
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4462
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5511
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/287
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/358
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/358/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/358
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/358/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5508
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5508/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7973
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26718
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/283
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/283/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/140
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26720

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6034/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+/*
+ *
+ * \params[in] ev The input event
+ * \params[in] cookie An allocated void* with exactly cookie_size bytes
+ * \params[in] size The size of the allocated void*
+ */
+void mir_input_event_copy_cookie(MirInputEvent const* ev, MirCookie* cookie, size_t size);

When comments and code disagree, both are likely wrong.

While I'm not sure I fully understand the intended usage I suspect that have two scenarios:

1. Getting a MirCookie from an event.
2. Converting a MirCookie to and from a chunk of memory.

In neither of these does it make sense for a user to supply allocate and supply a pointer to an incomplete type.

How about:

MirCookie* mir_input_event_get_cookie(MirInputEvent const* ev);

and either:

MirCookie* mir_blob_to_mir_cookie(MirBlob* blob);
MirBlob* mir_blob_from_mir_cookie(MirCookie* cookie);

Or:

size_t mir_cookie_get_buffer_size(MirCookie* cookie);
void mir_cookie_to_buffer(MirCookie* cookie, void* buffer, size_t size);
MirCookie* mir_cookie_from_buffer(void const* buffer, size_t size);

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

[Just comment]

It (still) seems odd that CookieAuthority deals with both MirCookies and with pairs of timestamp and MAC. Surely a /cookie/ authority should deal with Cookies? Would it not make more sense as:

auto make_cookie(Timestamp t) -> unique_ptr<MirCookie>

auto authenticated_timestamp(MirCookie const& c) -> Timestamp

Having clients aware of the MAC seems like a leaky abstraction

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3261
https://mir-jenkins.ubuntu.com/job/mir-ci/89/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/89/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/89/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3262
https://mir-jenkins.ubuntu.com/job/mir-ci/91/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/90/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/91/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3263
https://mir-jenkins.ubuntu.com/job/mir-ci/92/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/92/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/92/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3264
https://mir-jenkins.ubuntu.com/job/mir-ci/93/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/93/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/93/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3265
https://mir-jenkins.ubuntu.com/job/mir-ci/95/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/95/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/95/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3266
https://mir-jenkins.ubuntu.com/job/mir-ci/96/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/96/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/96/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

394 +/* Returns an allocated MirCookie that you must release with mir_cookie_release
394 + *
395 + * \params[in] ev The input event
396 + * \return An allocated and ref'ed cookie
397 + */

There's no need to say “allocated” or “ref'ed” here.

394 +/* Returns the MirCookie associated with this input event.
394 + *
395 + * \params[in] ev The input event
396 + * \return A reference to the MirCookie associated with this input event.
397 + * This must be released with a call to mir_cookie_release().
398 + */

Likewise:
415 +/* Turns the user copyed buffer back into a MirCookie, which must be
416 + * released with mir_cookie_release
417 + *
418 + * \params[in] buffer The buffer used to get a MirCookie back
419 + * \return A newely allocated MirCookie
420 + */
421 +MirCookie const* mir_cookie_from_buffer(void const* buffer);

should maybe be:
415 +/* Create a MirCookie from a serialised representation.
417 + *
418 + * \params[in] buffer The buffer containing a serialised MirCookie.
418 + * The buffer may be freed immediately after this call.
419 + * \return A reference to a MirCookie.
418 + * This must be released with a call to mir_cookie_release().
420 + */
421 +MirCookie const* mir_cookie_from_buffer(void const* buffer);

This can never return NULL, right?

Actually: we should probably pass in the length of the buffer here and return NULL if it doesn't match what we expect. Clients will get this passed in from other sources, and it'll courteous to tell them if it's easy to detect that it's wrong.

443 +* \param [in] cookie The void* from the input event that you want to raise the window from.
Ba baw!

1143 + mir_surface_raise_with_cookie;
1144 + mir_input_event_has_cookie;
1145 + mir_cookie_get_size;
1146 + mir_input_event_get_cookie;
1147 + mir_cookie_copy_to_buffer;
1148 + mir_cookie_from_buffer;
1149 + mir_cookie_release;

These should be in MIR_CLIENT_unreleased, not MIR_CLIENT_DETAIL (which is pseudo-private implementation details).

+ if (raw_cookie.size() < cookie_size_from_format(mir::cookie::Format::HMAC_SHA_1_8))

Should be !=, right?

Why did you move mir::SecurityCheckFailed?

2029 + auto const& cookie_ptr = cookie_authority->unmarshall_cookie(cookie_bytes);

I'm surprised this passed valgrind? unmarshall_cookie() returns a std::unique_ptr<>, that you take a *reference* to, and then the std::unique_ptr<> gets *destroyed* at the end of the statement.

Likewise in a bunch of other places. Why doesn't this blow up?

A: http://herbsutter.com/2008/01/01/gotw-88-a-candidate-for-the-most-important-const/. I wonder why people think C++ is needlessly arcane‽.

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3267
https://mir-jenkins.ubuntu.com/job/mir-ci/104/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/104/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/104/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3267
https://mir-jenkins.ubuntu.com/job/mir-ci/106/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/106/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/106/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

First pass - cosmetic stuff

+/* Returns an allocated MirCookie that you must release with mir_cookie_release
+ *
+ * \params[in] ev The input event
+ * \return An allocated and ref'ed cookie
+ */
+MirCookie const* mir_input_event_get_cookie(MirInputEvent const* ev);

1. The /precondition/ that the event has a cookie is missing.

2. "An allocated and ref'ed cookie" is implementation detail the user isn't interested in.

~~~~

+ * \return The size needed to allocate a buffer
+ */
+size_t mir_cookie_get_size(MirCookie const* cookie);

While allocation is likely what the client will do, surely this is just the size of buffer needed by mir_cookie_copy_to_buffer().

~~~~

+ * \params[in] buffer The allocated buffer to copy the MirCookie into
+ * \params[in] size The size of the allocated buffer
+ */
+void mir_cookie_copy_to_buffer(MirCookie const* cookie, void* buffer, size_t size);

%s/allocated //

~~~~

+MirCookie const* mir_cookie_from_buffer(void const* buffer);

I think it would be useful validation for the buffer size to be supplied and checked. While not bulletproof the it is a reminder to the user that size matters.

~~~~

+* \param [in] cookie The void* from the input event that you want to raise the window from.
+*/
+void mir_surface_raise_with_cookie(MirSurface* surface, MirCookie const* cookie);

The comment and the code disagree

~~~~

+ HMAC_SHA_1_8

Is there a reason for the non standard naming style? https://unity.ubuntu.com/mir/cppguide/index.html?showone=Enumerator_Names#Enumerator_Names

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3270
https://mir-jenkins.ubuntu.com/job/mir-ci/110/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/110/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/110/rebuild

review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

From what I've been hearing, I think the terms "cookie" and "marshalling" are over-abstracting the situation. It's better to use more concrete nouns and verbs so the reader more easily understands what's going on. But this is not a review.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3271
https://mir-jenkins.ubuntu.com/job/mir-ci/113/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/113/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/113/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3272
https://mir-jenkins.ubuntu.com/job/mir-ci/114/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/114/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/114/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3273
https://mir-jenkins.ubuntu.com/job/mir-ci/116/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/116/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/116/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3272
http://jenkins.qa.ubuntu.com/job/mir-ci/6093/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5633
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4540
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5589
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/311
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/417
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/417/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/417
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/417/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5586
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5586/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8029
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26885
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/307
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/307/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/163
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26892

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6093/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Ok, I think. Two inline nonblocking doc comments.

review: Approve
Revision history for this message
Alberto Aguirre (albaguirre) wrote :
Download full text (7.0 KiB)

Mostly cosmetic things.

mir::cookie::Array => mir::cookie::Blob

Comment suggestions
---
+
386 +/* Tells if the MirInputEvent has a MirCookie
387 + *
388 + * \params[in] ev The input event
389 + * \return True if the input event has a MirCookie
390 + */

change to:

+
386 +/* Query if an input event contains a cookie
387 + *
388 + * \params[in] ev The input event
389 + * \return True if the input event contains a cookie
390 + */

---

---
/* Returns the MirCookie associated with this input event.
 *
 * \pre The input event must have a MirCookie
 * \params[in] ev The input event
 * \return A reference to the MirCookie associated with this input event
 * This must be released with a call to mir_cookie_release()
 */

 change to:

/* Returns the cookie associated with an input event.
 *
 * \pre The input event must have a MirCookie
 * \params[in] ev An input event
 * \return The cookie associated with the given input event
 * The cookie must be released by calling mir_cookie_release
 */
---

/* The size of the buffer needed to serialize this MirCookie
 *
 * \params[in] cookie The MirCookie
 * \return The size needed for a buffer
 */
size_t mir_cookie_get_size(MirCookie const* cookie);

change to:

/* Queries the size needed to serialize a given cookie
 *
 * \params[in] cookie A cookie instance
 * \return The size of the serialized representation of the given cookie
 */
size_t mir_cookie_size(MirCookie const* cookie);
---

---
/* Copy the MirCookie into an allocated buffer
 *
 * \pre The size must be equal to mir_cookie_get_size
 * \params[in] cookie The MirCookie
 * \params[in] buffer The allocated buffer to copy the MirCookie into
 * \params[in] size The size of the allocated buffer
 */

 change to:

/* Serializes a cookie into the given buffer
 *
 * \pre The size must be equal to mir_cookie_get_size
 * \params[in] cookie A cookie instance
 * \params[in] buffer A buffer which is filled with the serialized representation
                      of the given cookie
 * \params[in] size The size of the given buffer
 */
void mir_cookie_copy_to_buffer(MirCookie const* cookie, void* buffer, size_t size);

To be consistent with mir_cookie_from_buffer
mir_cookie_copy_to_buffer => mir_cookie_to_buffer

---
/* Create a MirCookie from a serialised representation
 *
 * \pre The size must be equal to mir_cookie_get_size
 * \params[in] buffer The buffer containing a serialised MirCookie.
 * The buffer may be freed immediately after this call.
 * \return A reference to a MirCookie.
 * This must be released with a call to mir_cookie_release().
 */
MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size);

change to:

/* Create a cookie from a serialized representation
 *
 * \pre The size must be equal to mir_cookie_get_size
 * \params[in] buffer The buffer containing a serialized cookie.
 * The buffer may be freed immediately after this call.
 * \return A MirCookie instance. The instance must be re...

Read more...

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+#include "mir/cookie_array.h"

Seeing this caused me to notice an existing issue:

It really ought reflect the "namespace == directory" convention used elsewhere: #include "mir/cookie/array.h"

Not sure if we should fix, or just live with it as "mir/cookie_factory.h" is pre-existing.

review: Needs Information
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Oops on the last one I meant:

---
void mir_cookie_copy_to_buffer(MirCookie const* cookie, void* buffer, size_t size)
{
    mir::require(size == mir::cookie::array_size);
    memcpy(buffer, cookie, size);
}
---

With a client side MirCookie class suggested above would just become:
void mir_cookie_copy_to_buffer(MirCookie const* cookie, void* buffer, size_t size)
{
    return cookie->copy_to(buffer, size);
}

and mir_cookie_release turns into:

+void mir_cookie_release(MirCookie const* cookie)
{
    delete cookie;
}

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3273
http://jenkins.qa.ubuntu.com/job/mir-ci/6100/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5644
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4551
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5600
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/318
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/424
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/424/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/424
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/424/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5597
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5597/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8038
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26908
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/314
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/314/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/170
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26918

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6100/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3276
https://mir-jenkins.ubuntu.com/job/mir-ci/125/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/125/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/125/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3277
https://mir-jenkins.ubuntu.com/job/mir-ci/126/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/126/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/126/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3278
https://mir-jenkins.ubuntu.com/job/mir-ci/127/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/127/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/127/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3279
https://mir-jenkins.ubuntu.com/job/mir-ci/128/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/128/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/128/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

LGTM.

review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3281
https://mir-jenkins.ubuntu.com/job/mir-ci/130/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/130/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/130/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3285
https://mir-jenkins.ubuntu.com/job/mir-ci/132/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/131/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/132/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+/* Queries the size needed to serialize a given cookie
+ *
+ * \params[in] cookie A cookie instance
+ * \return The size of the serialized representation of the given cookie
+ */
+size_t mir_cookie_size(MirCookie const* cookie);

Would mir_cookie_buffer_size() be a clearer name?

~~~~

+/* Create a cookie from a serialized representation
+ *
+ * \pre The size must be equal to mir_cookie_size
+ * \params[in] buffer The buffer containing a serialized cookie.
+ * The buffer may be freed immediately after this call.
+ * \return A MirCookie instance. The instance must be released
+ with a call to mir_cookie_release.
+ */
+MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size);

The precondition is impossible for the client to check - mir_cookie_size() takes a parameter that isn't (in the general case) available to the client.

Perhaps we should drop the cookie parameter from mir_cookie_size()? Or do we expect different cookies to have different sizes?

~~~~

+class Cookie
+{
+public:
+ virtual ~Cookie() = default;
+
+ /**
+ * Returns the timestamp that the cookie is built with
+ *
+ * \return The timestamp
+ */
+ virtual uint64_t timestamp() const = 0;
+
+ /**
+ * Converts the cookie into a stream of bytes.
+ *
+ * \return The stream of bytes formatted
+ */
+ virtual std::vector<uint8_t> serialize() const = 0;
+};

interfaces should delete CopyAssign

~~~~

- void raise_surface_with_timestamp(
+ void raise_surface(

Is this API break necessary? It will break downstreams. (And is how it motivated by the purpose of this MP?)

~~~~

inline mir::cookie::Blob const& getCookie() const { return mCookie; }

so getCookie() returns a blob? Confusing! "getCookieAsBlob()"?

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Non-blocking questions and comments:

mev::make_event(MirInputDeviceId(android_event->getDeviceId()),
                                    kev->getEventTime(),
- kev->getMac(),
+ {std::begin(cookie), std::end(cookie)},
mia::mir_keyboard_action_from_android(kev->getAction(), kev->getRepeatCount()),
                                    kev->getKeyCode(),
kev->getScanCode(),

Why do we need to create a "std::vector<uint8_t>" temporary from a blob (called "cookie"!)? What stops make_event taking a blob const&?

~~~~

+ MirCookie() = delete;

What advantage is there for disabling default construction?

~~~~

+#include "cookie.h"

We usually write the full path in public headers. Vis:

#include "mir/cookie/cookie.h"

~~~~

+ * \return A unique_ptr Authority

I don't think it useful to mention unique_ptr in the doc comment. (And you don't do it consistently.)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3279
http://jenkins.qa.ubuntu.com/job/mir-ci/6108/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5658
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4565
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5614
    FAILURE: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/323/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/432
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/432/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/432
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/432/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5611
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5611/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8049
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26943
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/319
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/319/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/175/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26958

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6108/rebuild

review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> +/* Queries the size needed to serialize a given cookie
> + *
> + * \params[in] cookie A cookie instance
> + * \return The size of the serialized representation of the given
> cookie
> + */
> +size_t mir_cookie_size(MirCookie const* cookie);
>
> Would mir_cookie_buffer_size() be a clearer name?
>
> ~~~~

Yes it would. Changing.

>
> +/* Create a cookie from a serialized representation
> + *
> + * \pre The size must be equal to mir_cookie_size
> + * \params[in] buffer The buffer containing a serialized cookie.
> + * The buffer may be freed immediately after this call.
> + * \return A MirCookie instance. The instance must be released
> + with a call to mir_cookie_release.
> + */
> +MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size);
>
> The precondition is impossible for the client to check - mir_cookie_size()
> takes a parameter that isn't (in the general case) available to the client.
>
> Perhaps we should drop the cookie parameter from mir_cookie_size()? Or do we
> expect different cookies to have different sizes?
>
> ~~~~

While atm the cookie size is consistent, the cookie size is dependent on the cookie authority implementation.

As far as the size, the size for the buffer *must* be mir_cookie_size() and it *must* get that size to allocate said buffer. The only way they could have gotten an allocated buffer, would be by querying the size. So I would think its up to the user to pass the size_t size around which MUST be equal to the mir_cookie_size at one point.

>
> +class Cookie
> +{
> +public:
> + virtual ~Cookie() = default;
> +
> + /**
> + * Returns the timestamp that the cookie is built with
> + *
> + * \return The timestamp
> + */
> + virtual uint64_t timestamp() const = 0;
> +
> + /**
> + * Converts the cookie into a stream of bytes.
> + *
> + * \return The stream of bytes formatted
> + */
> + virtual std::vector<uint8_t> serialize() const = 0;
> +};
>
> interfaces should delete CopyAssign
>
> ~~~~

Reasonable, Changing.

>
> - void raise_surface_with_timestamp(
> + void raise_surface(
>
> Is this API break necessary? It will break downstreams. (And is how it
> motivated by the purpose of this MP?)
>
> ~~~~

This API is new, (was removed from the API before the 0.18 release). So just trying to get the correct name for it.
>
> inline mir::cookie::Blob const& getCookie() const { return mCookie; }
>
> so getCookie() returns a blob? Confusing! "getCookieAsBlob()"?

Very confusing, and yes Ill go through and rename that.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> Non-blocking questions and comments:
>
> mev::make_event(MirInputDeviceId(android_event->getDeviceId()),
> kev->getEventTime(),
> - kev->getMac(),
> + {std::begin(cookie), std::end(cookie)},
> mia::mir_keyboard_action_from_android(kev->getAction(),
> kev->getRepeatCount()),
> kev->getKeyCode(),
> kev->getScanCode(),
>
> Why do we need to create a "std::vector<uint8_t>" temporary from a blob
> (called "cookie"!)? What stops make_event taking a blob const&?
>
> ~~~~
>

Since blob const& is a std::array<uint8_t, 17> and the event_builder.h is c++ public API. Since its a public API I move back to std::array so we dont depend on a fix size for the cookie.
> + MirCookie() = delete;
>
> What advantage is there for disabling default construction?
>
>
> ~~~~
>
> +#include "cookie.h"
>
> We usually write the full path in public headers. Vis:
>
> #include "mir/cookie/cookie.h"
>
> ~~~~

Makes sesne, and reads better. Changing.

>
> + * \return A unique_ptr Authority
>
> I don't think it useful to mention unique_ptr in the doc comment. (And you
> don't do it consistently.)

Changing.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> MirCookie() = delete;
> What advantage is there for disabling default construction?

Mainly to force the creation of only valid MirCookies. So if we ever get one we know it must have been created through one of its explicit CTOR.

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

From what I see at the ClientCookies fixture. The test body does not wait for the client surface to be exposed and focused. So there is a chance that the SurfaceInputDispatcher does not forward the event to the client. I.e. you could cut some code out of the TestClientInput fixture. CI does not seem to affected by that problem, so you might as well do that some time after the release.

Is there a reason why you do not throw SecurityCheckErrors with BOOST_THROW_EXCEPTION?

review: Needs Information
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3286
https://mir-jenkins.ubuntu.com/job/mir-ci/136/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/136/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/136/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size)
+{
+ if (size != mir::cookie::default_blob_size)
+ return NULL;
+
+ return new MirCookie(buffer, size);
+}

While it is extremely unlikely for operator new() (or any of the other code currently invoked here) to throw I think we should trap exceptions and not allow them to propagate from a C API.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Is there a reason why you do not throw SecurityCheckErrors with
> BOOST_THROW_EXCEPTION?

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> > Is there a reason why you do not throw SecurityCheckErrors with
> > BOOST_THROW_EXCEPTION?

Rats! the code changed while I was reading it.

review: Abstain
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> +MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size)
> +{
> + if (size != mir::cookie::default_blob_size)
> + return NULL;
> +
> + return new MirCookie(buffer, size);
> +}
>
> While it is extremely unlikely for operator new() (or any of the other code
> currently invoked here) to throw I think we should trap exceptions and not
> allow them to propagate from a C API.

Fixed!

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3287
https://mir-jenkins.ubuntu.com/job/mir-ci/137/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/137/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/137/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I've looked at this code too many times today to approve it. I'm not seeing what is there anymore.

review: Abstain
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3289
https://mir-jenkins.ubuntu.com/job/mir-ci/138/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/138/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/138/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

A first pass:

+ static std::unique_ptr<Authority> create_saving(Secret& save_secret);

The name 'create_saving' is not very clear.

+ std::copy_n(std::begin(cookie), cookie.size(), std::begin(kev.cookie));

The code as written could overflow the kev.cookie array.

+#include "../mir_cookie.h"

We generally try to avoid pulling headers from parent directories (but it's not a dealbreaker, and it seems we are doing it more on the client side).

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3290
https://mir-jenkins.ubuntu.com/job/mir-ci/139/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/139/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/139/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3291
https://mir-jenkins.ubuntu.com/job/mir-ci/141/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/141/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/141/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3285
http://jenkins.qa.ubuntu.com/job/mir-ci/6111/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5662
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4569
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5618
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/326
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/435
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/435/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/435
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/435/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5615
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5615/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8053
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26968
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/322
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/322/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/178
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26976

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6111/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3292
https://mir-jenkins.ubuntu.com/job/mir-ci/142/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/142/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/142/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3293
https://mir-jenkins.ubuntu.com/job/mir-ci/143/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/143/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/143/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3294
https://mir-jenkins.ubuntu.com/job/mir-ci/144/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/144/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/144/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3296
https://mir-jenkins.ubuntu.com/job/mir-ci/145/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/145/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/145/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3296
http://jenkins.qa.ubuntu.com/job/mir-ci/6117/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5672
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4579
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5628
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/329
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/441
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/441/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/441
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/441/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5625
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5625/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8060
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26990
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/325
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/325/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/181
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26991

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6117/rebuild

review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

ok you resolved everything i saw in this or the upcoming MP

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

@"* I guess gcc 4.* assume const for auto = make_unique<..> which causes issues when attempting to return a derived class to a base class. You cannot return a const unique_ptr since it cannot be std::moved"

I guess you're wrong: that would make auto support implausibly broken.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+ * NULL will be returned if the buffer and size dont describe

s/dont/don't/

~~~~

+ * Construction function used to create a Authority. The secret size must be

s/a Authority/an Authority/

~~~~

+ // TODO Soon to be removed!
+ static std::unique_ptr<Authority> create_saving(Secret& save_secret);

Why?

~~~~

 /// Sets an override functor for creating the cookie factory.

s/factory/authority/

~~~~

+ mir::cookie::Blob copy_vector_to_cookie_blob(std::vector<uint8_t> const& vector)

It's local to the TU, so I wouldn't block, but I'd reserve "copy" for functions that take a target. I'd call it something like "as_blob".

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

This introduces a number of FIXME/TODO comments, without it being clear when or why they will addressed.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> This introduces a number of FIXME/TODO comments, without it being clear when
> or why they will addressed.

All removed in this branch:
https://code.launchpad.net/~mir-team/mir/160-bit-finally/+merge/283751

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> @"* I guess gcc 4.* assume const for auto = make_unique<..> which causes
> issues when attempting to return a derived class to a base class. You cannot
> return a const unique_ptr since it cannot be std::moved"
>
> I guess you're wrong: that would make auto support implausibly broken.

Re looking at the compiler error... just looks like problem with implicit conversions? Not sure how removing the auto fixed it for me now though :(
https://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4576/console

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> + * NULL will be returned if the buffer and size dont describe
>
> s/dont/don't/
>
> ~~~~
Fixing

>
> + * Construction function used to create a Authority. The secret size must be
>
> s/a Authority/an Authority/
>
> ~~~~
Fixing

>
> + // TODO Soon to be removed!
> + static std::unique_ptr<Authority> create_saving(Secret& save_secret);
>
> Why?
>
> ~~~~
Hmm that fixme shouldnt be there anymore? The reason was because we were going to create a lazy creation method for the secret. So we didnt depend on it on boot. Which ill be making a branch soon for that even though we've a work around in USC for the moment.
>
> /// Sets an override functor for creating the cookie factory.
>
> s/factory/authority/
>
> ~~~~
Fixing.
>
> + mir::cookie::Blob copy_vector_to_cookie_blob(std::vector<uint8_t> const&
> vector)
>
> It's local to the TU, so I wouldn't block, but I'd reserve "copy" for
> functions that take a target. I'd call it something like "as_blob".

Sounds good, fixing!

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

>+ // TODO Soon to be removed!
>+ static std::unique_ptr<Authority> create_saving(Secret& save_secret);
>
>Why?

Opps its a TODO, and yeah removed that this branch no need to have that TODO, and ill be address it very soon!

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3297
https://mir-jenkins.ubuntu.com/job/mir-ci/151/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/151/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/151/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3297
http://jenkins.qa.ubuntu.com/job/mir-ci/6123/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5678
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4585
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5634
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/332
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/447
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/447/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/447
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/447/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5631
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5631/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8066
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/27011
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/328
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/328/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/184
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/27017

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6123/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Doc fixes have been applied.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

^-Network hiccup

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '3rd_party/CMakeLists.txt'
--- 3rd_party/CMakeLists.txt 2016-01-20 23:59:18 +0000
+++ 3rd_party/CMakeLists.txt 2016-01-25 13:42:04 +0000
@@ -11,6 +11,7 @@
11set(MIR_INPUT_ANDROID_COMPILE_FLAGS ${MIR_INPUT_ANDROID_COMPILE_FLAGS}11set(MIR_INPUT_ANDROID_COMPILE_FLAGS ${MIR_INPUT_ANDROID_COMPILE_FLAGS}
12 PARENT_SCOPE)12 PARENT_SCOPE)
1313
14include_directories(${PROJECT_SOURCE_DIR}/src/include/cookie)
14include_directories(${PROJECT_SOURCE_DIR}/src/include/common)15include_directories(${PROJECT_SOURCE_DIR}/src/include/common)
15include_directories(${PROJECT_SOURCE_DIR}/src/include/platform)16include_directories(${PROJECT_SOURCE_DIR}/src/include/platform)
16include_directories(${CMAKE_CURRENT_SOURCE_DIR}/android-deps)17include_directories(${CMAKE_CURRENT_SOURCE_DIR}/android-deps)
1718
=== modified file '3rd_party/android-input/android/frameworks/base/include/androidfw/Input.h'
--- 3rd_party/android-input/android/frameworks/base/include/androidfw/Input.h 2016-01-20 23:59:18 +0000
+++ 3rd_party/android-input/android/frameworks/base/include/androidfw/Input.h 2016-01-25 13:42:04 +0000
@@ -31,6 +31,8 @@
3131
32#include <chrono>32#include <chrono>
3333
34#include "mir/cookie/blob.h"
35
34#ifdef HAVE_ANDROID_OS36#ifdef HAVE_ANDROID_OS
35class SkMatrix;37class SkMatrix;
36#endif38#endif
@@ -276,7 +278,7 @@
276278
277 inline int32_t getRepeatCount() const { return mRepeatCount; }279 inline int32_t getRepeatCount() const { return mRepeatCount; }
278280
279 inline uint64_t getMac() const { return mMac; }281 inline mir::cookie::Blob const& getCookieAsBlob() const { return mCookieBlob; }
280282
281 inline std::chrono::nanoseconds getDownTime() const { return mDownTime; }283 inline std::chrono::nanoseconds getDownTime() const { return mDownTime; }
282284
@@ -299,7 +301,7 @@
299 int32_t scanCode,301 int32_t scanCode,
300 int32_t metaState,302 int32_t metaState,
301 int32_t repeatCount,303 int32_t repeatCount,
302 uint64_t mac,304 mir::cookie::Blob const& cookie,
303 std::chrono::nanoseconds downTime,305 std::chrono::nanoseconds downTime,
304 std::chrono::nanoseconds eventTime);306 std::chrono::nanoseconds eventTime);
305 void initialize(const KeyEvent& from);307 void initialize(const KeyEvent& from);
@@ -311,7 +313,7 @@
311 int32_t mScanCode;313 int32_t mScanCode;
312 int32_t mMetaState;314 int32_t mMetaState;
313 int32_t mRepeatCount;315 int32_t mRepeatCount;
314 uint64_t mMac;316 mir::cookie::Blob mCookieBlob;
315 std::chrono::nanoseconds mDownTime;317 std::chrono::nanoseconds mDownTime;
316 std::chrono::nanoseconds mEventTime;318 std::chrono::nanoseconds mEventTime;
317};319};
@@ -358,7 +360,7 @@
358360
359 inline float getYPrecision() const { return mYPrecision; }361 inline float getYPrecision() const { return mYPrecision; }
360362
361 inline uint64_t getMac() const { return mMac; }363 inline mir::cookie::Blob const& getCookieAsBlob() const { return mCookieBlob; }
362364
363 inline std::chrono::nanoseconds getDownTime() const { return mDownTime; }365 inline std::chrono::nanoseconds getDownTime() const { return mDownTime; }
364366
@@ -513,7 +515,7 @@
513 float yOffset,515 float yOffset,
514 float xPrecision,516 float xPrecision,
515 float yPrecision,517 float yPrecision,
516 uint64_t mac,518 mir::cookie::Blob const& cookie,
517 std::chrono::nanoseconds downTime,519 std::chrono::nanoseconds downTime,
518 std::chrono::nanoseconds eventTime,520 std::chrono::nanoseconds eventTime,
519 size_t pointerCount,521 size_t pointerCount,
@@ -561,7 +563,7 @@
561 float mYOffset;563 float mYOffset;
562 float mXPrecision;564 float mXPrecision;
563 float mYPrecision;565 float mYPrecision;
564 uint64_t mMac;566 mir::cookie::Blob mCookieBlob;
565 std::chrono::nanoseconds mDownTime;567 std::chrono::nanoseconds mDownTime;
566 Vector<PointerProperties> mPointerProperties;568 Vector<PointerProperties> mPointerProperties;
567 Vector<std::chrono::nanoseconds> mSampleEventTimes;569 Vector<std::chrono::nanoseconds> mSampleEventTimes;
568570
=== modified file '3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h'
--- 3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h 2016-01-20 23:59:18 +0000
+++ 3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h 2016-01-25 13:42:04 +0000
@@ -62,7 +62,7 @@
62 struct Key {62 struct Key {
63 uint32_t seq;63 uint32_t seq;
64 int64_t eventTime;64 int64_t eventTime;
65 uint64_t mac;65 mir::cookie::Blob cookieBlob;
66 int32_t deviceId;66 int32_t deviceId;
67 int32_t source;67 int32_t source;
68 int32_t action;68 int32_t action;
@@ -81,7 +81,7 @@
81 struct Motion {81 struct Motion {
82 uint32_t seq;82 uint32_t seq;
83 int64_t eventTime;83 int64_t eventTime;
84 uint64_t mac;84 mir::cookie::Blob cookieBlob;
85 int32_t deviceId;85 int32_t deviceId;
86 int32_t source;86 int32_t source;
87 int32_t action;87 int32_t action;
@@ -212,7 +212,7 @@
212 int32_t scanCode,212 int32_t scanCode,
213 int32_t metaState,213 int32_t metaState,
214 int32_t repeatCount,214 int32_t repeatCount,
215 uint64_t mac,215 mir::cookie::Blob const& cookieBlob,
216 std::chrono::nanoseconds downTime,216 std::chrono::nanoseconds downTime,
217 std::chrono::nanoseconds eventTime);217 std::chrono::nanoseconds eventTime);
218218
@@ -237,7 +237,7 @@
237 float yOffset,237 float yOffset,
238 float xPrecision,238 float xPrecision,
239 float yPrecision,239 float yPrecision,
240 uint64_t mac,240 mir::cookie::Blob const& cookieBlob,
241 std::chrono::nanoseconds downTime,241 std::chrono::nanoseconds downTime,
242 std::chrono::nanoseconds eventTime,242 std::chrono::nanoseconds eventTime,
243 size_t pointerCount,243 size_t pointerCount,
244244
=== modified file '3rd_party/android-input/android/frameworks/base/services/input/Input.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/Input.cpp 2016-01-20 23:59:18 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/Input.cpp 2016-01-25 13:42:04 +0000
@@ -127,7 +127,7 @@
127 int32_t scanCode,127 int32_t scanCode,
128 int32_t metaState,128 int32_t metaState,
129 int32_t repeatCount,129 int32_t repeatCount,
130 uint64_t mac,130 mir::cookie::Blob const& cookieBlob,
131 std::chrono::nanoseconds downTime,131 std::chrono::nanoseconds downTime,
132 std::chrono::nanoseconds eventTime) {132 std::chrono::nanoseconds eventTime) {
133 InputEvent::initialize(deviceId, source);133 InputEvent::initialize(deviceId, source);
@@ -137,7 +137,7 @@
137 mScanCode = scanCode;137 mScanCode = scanCode;
138 mMetaState = metaState;138 mMetaState = metaState;
139 mRepeatCount = repeatCount;139 mRepeatCount = repeatCount;
140 mMac = mac;140 mCookieBlob = cookieBlob;
141 mDownTime = downTime;141 mDownTime = downTime;
142 mEventTime = eventTime;142 mEventTime = eventTime;
143}143}
@@ -150,7 +150,7 @@
150 mScanCode = from.mScanCode;150 mScanCode = from.mScanCode;
151 mMetaState = from.mMetaState;151 mMetaState = from.mMetaState;
152 mRepeatCount = from.mRepeatCount;152 mRepeatCount = from.mRepeatCount;
153 mMac = from.mMac;153 mCookieBlob = from.mCookieBlob;
154 mDownTime = from.mDownTime;154 mDownTime = from.mDownTime;
155 mEventTime = from.mEventTime;155 mEventTime = from.mEventTime;
156}156}
@@ -294,7 +294,7 @@
294 float yOffset,294 float yOffset,
295 float xPrecision,295 float xPrecision,
296 float yPrecision,296 float yPrecision,
297 uint64_t mac,297 mir::cookie::Blob const& cookieBlob,
298 std::chrono::nanoseconds downTime,298 std::chrono::nanoseconds downTime,
299 std::chrono::nanoseconds eventTime,299 std::chrono::nanoseconds eventTime,
300 size_t pointerCount,300 size_t pointerCount,
@@ -310,7 +310,7 @@
310 mYOffset = yOffset;310 mYOffset = yOffset;
311 mXPrecision = xPrecision;311 mXPrecision = xPrecision;
312 mYPrecision = yPrecision;312 mYPrecision = yPrecision;
313 mMac = mac;313 mCookieBlob = cookieBlob;
314 mDownTime = downTime;314 mDownTime = downTime;
315 mPointerProperties.clear();315 mPointerProperties.clear();
316 mPointerProperties.appendArray(pointerProperties, pointerCount);316 mPointerProperties.appendArray(pointerProperties, pointerCount);
@@ -330,7 +330,7 @@
330 mYOffset = other->mYOffset;330 mYOffset = other->mYOffset;
331 mXPrecision = other->mXPrecision;331 mXPrecision = other->mXPrecision;
332 mYPrecision = other->mYPrecision;332 mYPrecision = other->mYPrecision;
333 mMac = other->mMac;333 mCookieBlob = other->mCookieBlob;
334 mDownTime = other->mDownTime;334 mDownTime = other->mDownTime;
335 mPointerProperties = other->mPointerProperties;335 mPointerProperties = other->mPointerProperties;
336336
337337
=== modified file '3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp 2016-01-20 23:59:18 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp 2016-01-25 13:42:04 +0000
@@ -236,16 +236,16 @@
236 int32_t scanCode,236 int32_t scanCode,
237 int32_t metaState,237 int32_t metaState,
238 int32_t repeatCount,238 int32_t repeatCount,
239 uint64_t mac,239 mir::cookie::Blob const& cookieBlob,
240 std::chrono::nanoseconds downTime,240 std::chrono::nanoseconds downTime,
241 std::chrono::nanoseconds eventTime) {241 std::chrono::nanoseconds eventTime) {
242#if DEBUG_TRANSPORT_ACTIONS242#if DEBUG_TRANSPORT_ACTIONS
243 ALOGD("channel '%s' publisher ~ publishKeyEvent: seq=%u, deviceId=%d, source=0x%x, "243 ALOGD("channel '%s' publisher ~ publishKeyEvent: seq=%u, deviceId=%d, source=0x%x, "
244 "action=0x%x, flags=0x%x, keyCode=%d, scanCode=%d, metaState=0x%x, repeatCount=%d,"244 "action=0x%x, flags=0x%x, keyCode=%d, scanCode=%d, metaState=0x%x, repeatCount=%d,"
245 "mac=%lu, downTime=%lld, eventTime=%lld",245 "downTime=%lld, eventTime=%lld",
246 c_str(mChannel->getName()), seq,246 c_str(mChannel->getName()), seq,
247 deviceId, source, action, flags, keyCode, scanCode, metaState, repeatCount,247 deviceId, source, action, flags, keyCode, scanCode, metaState, repeatCount,
248 mac, downTime, eventTime);248 downTime, eventTime);
249#endif249#endif
250250
251 if (!seq) {251 if (!seq) {
@@ -264,7 +264,7 @@
264 msg.body.key.scanCode = scanCode;264 msg.body.key.scanCode = scanCode;
265 msg.body.key.metaState = metaState;265 msg.body.key.metaState = metaState;
266 msg.body.key.repeatCount = repeatCount;266 msg.body.key.repeatCount = repeatCount;
267 msg.body.key.mac = mac;267 msg.body.key.cookieBlob = cookieBlob;
268 msg.body.key.downTime = downTime.count();268 msg.body.key.downTime = downTime.count();
269 msg.body.key.eventTime = eventTime.count();269 msg.body.key.eventTime = eventTime.count();
270 return mChannel->sendMessage(&msg);270 return mChannel->sendMessage(&msg);
@@ -283,7 +283,7 @@
283 float yOffset,283 float yOffset,
284 float xPrecision,284 float xPrecision,
285 float yPrecision,285 float yPrecision,
286 uint64_t mac,286 mir::cookie::Blob const& cookieBlob,
287 std::chrono::nanoseconds downTime,287 std::chrono::nanoseconds downTime,
288 std::chrono::nanoseconds eventTime,288 std::chrono::nanoseconds eventTime,
289 size_t pointerCount,289 size_t pointerCount,
@@ -293,11 +293,11 @@
293 ALOGD("channel '%s' publisher ~ publishMotionEvent: seq=%u, deviceId=%d, source=0x%x, "293 ALOGD("channel '%s' publisher ~ publishMotionEvent: seq=%u, deviceId=%d, source=0x%x, "
294 "action=0x%x, flags=0x%x, edgeFlags=0x%x, metaState=0x%x, buttonState=0x%x, "294 "action=0x%x, flags=0x%x, edgeFlags=0x%x, metaState=0x%x, buttonState=0x%x, "
295 "xOffset=%f, yOffset=%f, "295 "xOffset=%f, yOffset=%f, "
296 "xPrecision=%f, yPrecision=%f, mac=%lu, "296 "xPrecision=%f, yPrecision=%f,"
297 "downTime=%lld, eventTime=%lld, pointerCount=%d",297 "downTime=%lld, eventTime=%lld, pointerCount=%d",
298 c_str(mChannel->getName()), seq,298 c_str(mChannel->getName()), seq,
299 deviceId, source, action, flags, edgeFlags, metaState, buttonState,299 deviceId, source, action, flags, edgeFlags, metaState, buttonState,
300 xOffset, yOffset, xPrecision, yPrecision, mac, downTime, eventTime, pointerCount);300 xOffset, yOffset, xPrecision, yPrecision, downTime, eventTime, pointerCount);
301#endif301#endif
302302
303 if (!seq) {303 if (!seq) {
@@ -325,7 +325,7 @@
325 msg.body.motion.yOffset = yOffset;325 msg.body.motion.yOffset = yOffset;
326 msg.body.motion.xPrecision = xPrecision;326 msg.body.motion.xPrecision = xPrecision;
327 msg.body.motion.yPrecision = yPrecision;327 msg.body.motion.yPrecision = yPrecision;
328 msg.body.motion.mac = mac;328 msg.body.motion.cookieBlob = cookieBlob;
329 msg.body.motion.downTime = downTime.count();329 msg.body.motion.downTime = downTime.count();
330 msg.body.motion.eventTime = eventTime.count();330 msg.body.motion.eventTime = eventTime.count();
331 msg.body.motion.pointerCount = pointerCount;331 msg.body.motion.pointerCount = pointerCount;
@@ -882,7 +882,7 @@
882 msg->body.key.scanCode,882 msg->body.key.scanCode,
883 msg->body.key.metaState,883 msg->body.key.metaState,
884 msg->body.key.repeatCount,884 msg->body.key.repeatCount,
885 msg->body.key.mac,885 msg->body.key.cookieBlob,
886 std::chrono::nanoseconds(msg->body.key.downTime),886 std::chrono::nanoseconds(msg->body.key.downTime),
887 std::chrono::nanoseconds(msg->body.key.eventTime));887 std::chrono::nanoseconds(msg->body.key.eventTime));
888}888}
@@ -908,7 +908,7 @@
908 msg->body.motion.yOffset,908 msg->body.motion.yOffset,
909 msg->body.motion.xPrecision,909 msg->body.motion.xPrecision,
910 msg->body.motion.yPrecision,910 msg->body.motion.yPrecision,
911 msg->body.motion.mac,911 msg->body.motion.cookieBlob,
912 std::chrono::nanoseconds(msg->body.motion.downTime),912 std::chrono::nanoseconds(msg->body.motion.downTime),
913 std::chrono::nanoseconds(msg->body.motion.eventTime),913 std::chrono::nanoseconds(msg->body.motion.eventTime),
914 pointerCount,914 pointerCount,
915915
=== modified file 'debian/control'
--- debian/control 2016-01-21 23:54:16 +0000
+++ debian/control 2016-01-25 13:42:04 +0000
@@ -420,7 +420,7 @@
420 This package depends on a full set of graphics drivers for running Mir on top420 This package depends on a full set of graphics drivers for running Mir on top
421 of an existing Android driver stack.421 of an existing Android driver stack.
422422
423Package: libmircookie1423Package: libmircookie2
424Section: libs424Section: libs
425Architecture: any425Architecture: any
426Multi-Arch: same426Multi-Arch: same
@@ -439,7 +439,7 @@
439Architecture: any439Architecture: any
440Multi-Arch: same440Multi-Arch: same
441Pre-Depends: ${misc:Pre-Depends}441Pre-Depends: ${misc:Pre-Depends}
442Depends: libmircookie1 (= ${binary:Version}),442Depends: libmircookie2 (= ${binary:Version}),
443 ${misc:Depends},443 ${misc:Depends},
444Description: Produce and verify spoof-resistant timestamps - development headers444Description: Produce and verify spoof-resistant timestamps - development headers
445 libmircookie provides a simple mechanism for a group of cooperating processes445 libmircookie provides a simple mechanism for a group of cooperating processes
446446
=== renamed file 'debian/libmircookie1.install' => 'debian/libmircookie2.install'
--- debian/libmircookie1.install 2015-09-08 21:22:41 +0000
+++ debian/libmircookie2.install 2016-01-25 13:42:04 +0000
@@ -1,1 +1,1 @@
1/usr/lib/*/libmircookie.so.11/usr/lib/*/libmircookie.so.2
22
=== modified file 'include/client/mir/events/event_builders.h'
--- include/client/mir/events/event_builders.h 2016-01-23 03:16:06 +0000
+++ include/client/mir/events/event_builders.h 2016-01-25 13:42:04 +0000
@@ -28,6 +28,7 @@
28#include <memory>28#include <memory>
29#include <functional>29#include <functional>
30#include <chrono>30#include <chrono>
31#include <vector>
3132
32namespace mir33namespace mir
33{34{
@@ -58,13 +59,18 @@
5859
59// Key event60// Key event
60EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,61EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
61 uint64_t mac, MirKeyboardAction action, xkb_keysym_t key_code,62 std::vector<uint8_t> const& cookie, MirKeyboardAction action, xkb_keysym_t key_code,
62 int scan_code, MirInputEventModifiers modifiers);63 int scan_code, MirInputEventModifiers modifiers);
6364
64void set_modifier(MirEvent& event, MirInputEventModifiers modifiers);65void set_modifier(MirEvent& event, MirInputEventModifiers modifiers);
65void set_cursor_position(MirEvent& event, mir::geometry::Point const& pos);66void set_cursor_position(MirEvent& event, mir::geometry::Point const& pos);
66void set_button_state(MirEvent& event, MirPointerButtons button_state);67void set_button_state(MirEvent& event, MirPointerButtons button_state);
6768
69// Deprecated version with uint64_t mac
70EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
71 uint64_t mac, MirKeyboardAction action, xkb_keysym_t key_code,
72 int scan_code, MirInputEventModifiers modifiers) __attribute__ ((deprecated));
73
68// Deprecated version without mac74// Deprecated version without mac
69EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,75EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
70 MirKeyboardAction action, xkb_keysym_t key_code,76 MirKeyboardAction action, xkb_keysym_t key_code,
@@ -72,7 +78,11 @@
7278
73// Touch event79// Touch event
74EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,80EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
75 uint64_t mac, MirInputEventModifiers modifiers);81 std::vector<uint8_t> const& mac, MirInputEventModifiers modifiers);
82
83// Deprecated version with uint64_t mac
84EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
85 uint64_t mac, MirInputEventModifiers modifiers) __attribute__ ((deprecated));
7686
77// Deprecated version without mac87// Deprecated version without mac
78EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,88EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
@@ -98,12 +108,20 @@
98 float hscroll_value, float vscroll_value) __attribute__ ((deprecated));108 float hscroll_value, float vscroll_value) __attribute__ ((deprecated));
99109
100EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,110EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
101 uint64_t mac, MirInputEventModifiers modifiers, MirPointerAction action,111 std::vector<uint8_t> const& mac, MirInputEventModifiers modifiers, MirPointerAction action,
102 MirPointerButtons buttons_pressed,112 MirPointerButtons buttons_pressed,
103 float x_axis_value, float y_axis_value,113 float x_axis_value, float y_axis_value,
104 float hscroll_value, float vscroll_value,114 float hscroll_value, float vscroll_value,
105 float relative_x_value, float relative_y_value);115 float relative_x_value, float relative_y_value);
106116
117// Deprecated version with uint64_t mac
118EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
119 uint64_t mac, MirInputEventModifiers modifiers, MirPointerAction action,
120 MirPointerButtons buttons_pressed,
121 float x_axis_value, float y_axis_value,
122 float hscroll_value, float vscroll_value,
123 float relative_x_value, float relative_y_value) __attribute__ ((deprecated));
124
107// Deprecated version without mac125// Deprecated version without mac
108EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,126EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
109 MirInputEventModifiers modifiers, MirPointerAction action,127 MirInputEventModifiers modifiers, MirPointerAction action,
110128
=== modified file 'include/client/mir_toolkit/events/event.h'
--- include/client/mir_toolkit/events/event.h 2016-01-22 19:03:16 +0000
+++ include/client/mir_toolkit/events/event.h 2016-01-25 13:42:04 +0000
@@ -58,6 +58,8 @@
58typedef struct MirInputConfigurationEvent MirInputConfigurationEvent;58typedef struct MirInputConfigurationEvent MirInputConfigurationEvent;
59typedef struct MirSurfaceOutputEvent MirSurfaceOutputEvent;59typedef struct MirSurfaceOutputEvent MirSurfaceOutputEvent;
6060
61typedef struct MirCookie MirCookie;
62
61typedef union MirEvent MirEvent;63typedef union MirEvent MirEvent;
6264
63#ifdef __cplusplus65#ifdef __cplusplus
6466
=== modified file 'include/client/mir_toolkit/events/input/input_event.h'
--- include/client/mir_toolkit/events/input/input_event.h 2016-01-20 23:59:18 +0000
+++ include/client/mir_toolkit/events/input/input_event.h 2016-01-25 13:42:04 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2014 Canonical Ltd.2 * Copyright © 2014-2016 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,5 * under the terms of the GNU Lesser General Public License version 3,
@@ -22,6 +22,7 @@
22#include "mir_toolkit/events/event.h"22#include "mir_toolkit/events/event.h"
2323
24#include <stdint.h>24#include <stdint.h>
25#include <stdbool.h>
2526
26#ifdef __cplusplus27#ifdef __cplusplus
27/**28/**
@@ -132,6 +133,22 @@
132 */133 */
133MirPointerEvent const* mir_input_event_get_pointer_event(MirInputEvent const* ev);134MirPointerEvent const* mir_input_event_get_pointer_event(MirInputEvent const* ev);
134135
136/* Query if an input event contains a cookie
137 *
138 * \params[in] ev The input event
139 * \return True if the input event contains a cookie
140 */
141bool mir_input_event_has_cookie(MirInputEvent const* ev);
142
143/* Returns the cookie associated with an input event.
144 *
145 * \pre The input event must have a MirCookie
146 * \params[in] ev An input event
147 * \return The cookie associated with the given input event
148 * The cookie must be released by calling mir_cookie_release
149 */
150MirCookie const* mir_input_event_get_cookie(MirInputEvent const* ev);
151
135#ifdef __cplusplus152#ifdef __cplusplus
136}153}
137/**@}*/154/**@}*/
138155
=== modified file 'include/client/mir_toolkit/mir_client_library.h'
--- include/client/mir_toolkit/mir_client_library.h 2015-04-28 07:54:10 +0000
+++ include/client/mir_toolkit/mir_client_library.h 2016-01-25 13:42:04 +0000
@@ -25,5 +25,6 @@
25#include <mir_toolkit/version.h>25#include <mir_toolkit/version.h>
26#include <mir_toolkit/mir_platform_message.h>26#include <mir_toolkit/mir_platform_message.h>
27#include <mir_toolkit/cursors.h>27#include <mir_toolkit/cursors.h>
28#include <mir_toolkit/mir_cookie.h>
2829
29#endif /* MIR_CLIENT_LIBRARY_H */30#endif /* MIR_CLIENT_LIBRARY_H */
3031
=== added file 'include/client/mir_toolkit/mir_cookie.h'
--- include/client/mir_toolkit/mir_cookie.h 1970-01-01 00:00:00 +0000
+++ include/client/mir_toolkit/mir_cookie.h 2016-01-25 13:42:04 +0000
@@ -0,0 +1,71 @@
1/*
2* Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
17 */
18
19#ifndef MIR_TOOLKIT_MIR_COOKIE_H_
20#define MIR_TOOLKIT_MIR_COOKIE_H_
21
22#include <stdint.h>
23
24#ifdef __cplusplus
25/**
26 * \addtogroup mir_toolkit
27 * @{
28 */
29extern "C" {
30#endif
31
32/* Queries the size needed to serialize a given cookie
33 *
34 * \params[in] cookie A cookie instance
35 * \return The size of the serialized representation of the given cookie
36 */
37size_t mir_cookie_buffer_size(MirCookie const* cookie);
38
39/* Serializes a cookie into the given buffer
40 *
41 * \pre The size must be equal to mir_cookie_size
42 * \params[in] cookie A cookie instance
43 * \params[in] buffer A buffer which is filled with the serialized representation
44 of the given cookie
45 * \params[in] size The size of the given buffer
46 */
47void mir_cookie_to_buffer(MirCookie const* cookie, void* buffer, size_t size);
48
49/* Create a cookie from a serialized representation
50 *
51 * \params[in] buffer The buffer containing a serialized cookie.
52 * The buffer may be freed immediately after this call.
53 * \return A MirCookie instance. The instance must be released
54 * with a call to mir_cookie_release.
55 * NULL will be returned if the buffer and size don't describe
56 * the contents of a MirCookie.
57 */
58MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size);
59
60/* Release the MirCookie
61 *
62 * \params[in] cookie The cookie to release
63 */
64void mir_cookie_release(MirCookie const* cookie);
65
66#ifdef __cplusplus
67}
68/**@}*/
69#endif
70
71#endif // MIR_TOOLKIT_MIR_COOKIE_H_
072
=== modified file 'include/client/mir_toolkit/mir_surface.h'
--- include/client/mir_toolkit/mir_surface.h 2016-01-20 23:59:18 +0000
+++ include/client/mir_toolkit/mir_surface.h 2016-01-25 13:42:04 +0000
@@ -756,6 +756,15 @@
756 */756 */
757MirPersistentId* mir_persistent_id_from_string(char const* string_representation);757MirPersistentId* mir_persistent_id_from_string(char const* string_representation);
758758
759/*
760* Attempts to raise the surface to the front.
761*
762* \param [in] surface The surface to raise
763* \param [in] cookie A cookie instance obtained from an input event.
764* An invalid cookie will terminate the client connection.
765*/
766void mir_surface_raise(MirSurface* surface, MirCookie const* cookie);
767
759#ifdef __cplusplus768#ifdef __cplusplus
760}769}
761/**@}*/770/**@}*/
762771
=== added directory 'include/cookie/mir/cookie'
=== renamed file 'include/cookie/mir/cookie_factory.h' => 'include/cookie/mir/cookie/authority.h'
--- include/cookie/mir/cookie_factory.h 2016-01-20 23:59:18 +0000
+++ include/cookie/mir/cookie/authority.h 2016-01-25 13:42:04 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2015 Canonical Ltd.2 * Copyright © 2015-2016 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -14,22 +14,29 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 * Brandon Schaefer <brandon.schaefer@canonical.com>
17 */18 */
1819
19#ifndef MIR_COOKIE_COOKIE_FACTORY_H_20#ifndef MIR_COOKIE_AUTHORITY_H_
20#define MIR_COOKIE_COOKIE_FACTORY_H_21#define MIR_COOKIE_AUTHORITY_H_
21
22#include "mir_toolkit/cookie.h"
2322
24#include <memory>23#include <memory>
24#include <stdexcept>
25#include <vector>25#include <vector>
2626
27#include "mir/cookie/cookie.h"
28
27namespace mir29namespace mir
28{30{
29namespace cookie31namespace cookie
30{32{
31using Secret = std::vector<uint8_t>;33using Secret = std::vector<uint8_t>;
3234
35struct SecurityCheckError : std::runtime_error
36{
37 SecurityCheckError();
38};
39
33/**40/**
34 * \brief A source of moderately-difficult-to-spoof cookies.41 * \brief A source of moderately-difficult-to-spoof cookies.
35 *42 *
@@ -41,7 +48,7 @@
41 * to attempt to bypass focus stealing prevention.48 * to attempt to bypass focus stealing prevention.
42 *49 *
43 */50 */
44class CookieFactory51class Authority
45{52{
46public:53public:
47 /**54 /**
@@ -54,60 +61,60 @@
54 static size_t optimal_secret_size();61 static size_t optimal_secret_size();
5562
56 /**63 /**
57 * Construction function used to create a CookieFactory. The secret size must be64 * Construction function used to create an Authority. The secret size must be
58 * no less then minimum_secret_size otherwise an exception will be thrown65 * no less then minimum_secret_size otherwise an exception will be thrown
59 *66 *
60 * \param [in] secret A filled in secret used to set the key for the hash function67 * \param [in] secret A secret used to set the key for the hash function
61 * \return A unique_ptr CookieFactory68 * \return An Authority
62 */69 */
63 static std::unique_ptr<CookieFactory> create_from_secret(Secret const& secret);70 static std::unique_ptr<Authority> create_from(Secret const& secret);
6471
65 /**72 /**
66 * Construction function used to create a CookieFactory as well as a secret.73 * Construction function used to create an Authority as well as a secret.
67 *74 *
68 * \param [out] save_secret The secret that was created.75 * \param [out] save_secret The secret that was created.
69 * \return A unique_ptr CookieFactory76 * \return An Authority
70 */77 */
71 static std::unique_ptr<CookieFactory> create_saving_secret(Secret& save_secret);78 static std::unique_ptr<Authority> create_saving(Secret& save_secret);
7279
73 /**80 /**
74 * Construction function used to create a CookieFactory and a secret which it keeps internally.81 * Construction function used to create an Authority and a secret which it keeps internally.
75 *82 *
76 * \return A unique_ptr CookieFactory83 * \return An Authority
77 */84 */
78 static std::unique_ptr<CookieFactory> create_keeping_secret();85 static std::unique_ptr<Authority> create();
7986
80 CookieFactory(CookieFactory const& factory) = delete;87 Authority(Authority const& authority) = delete;
81 CookieFactory& operator=(CookieFactory const& factory) = delete;88 Authority& operator=(Authority const& authority) = delete;
82 virtual ~CookieFactory() noexcept = default;89 virtual ~Authority() noexcept = default;
8390
84 /**91 /**
85 * Turns a timestamp into a MAC and returns a MirCookie.92 * Creates a cookie from a timestamp.
86 *93 *
87 * \param [in] timestamp The timestamp94 * \param [in] timestamp A timestamp
88 * \return MirCookie with the stored MAC and timestamp95 * \return A cookie instance
89 */96 */
90 virtual MirCookie timestamp_to_cookie(uint64_t const& timestamp) = 0;97 virtual std::unique_ptr<Cookie> make_cookie(uint64_t const& timestamp) = 0;
9198
92 /**99 /**
93 * Checks that a MirCookie is a valid MirCookie.100 * Creates a cookie from a serialized representation
94 *101 *
95 * \param [in] cookie A created MirCookie102 * \param [in] blob A blob of bytes representing a serialized cookie
96 * \return True when the MirCookie is valid, False when the MirCookie is not valid103 * \return A cookie instance
97 */104 */
98 virtual bool attest_timestamp(MirCookie const& cookie) = 0;105 virtual std::unique_ptr<Cookie> make_cookie(std::vector<uint8_t> const& raw_cookie) = 0;
99106
100 /**107 /**
101 * Absolute minimum size of secret key the CookieFactory will accept.108 * Absolute minimum size of secret key the Authority will accept.
102 *109 *
103 * Code should be using optimum_secret_size(); this minimum size is provided110 * Code should be using optimum_secret_size(); this minimum size is provided
104 * as a user convenience to guard against catastrophically bad initialisation.111 * as a user convenience to guard against catastrophically bad initialisation.
105 */112 */
106 static unsigned const minimum_secret_size = 8;113 static unsigned const minimum_secret_size = 8;
107protected:114protected:
108 CookieFactory() = default;115 Authority() = default;
109};116};
110117
111}118}
112}119}
113#endif // MIR_COOKIE_COOKIE_FACTORY_H_120#endif // MIR_COOKIE_COOKIE_AUTHORITY_H_
114121
=== added file 'include/cookie/mir/cookie/cookie.h'
--- include/cookie/mir/cookie/cookie.h 1970-01-01 00:00:00 +0000
+++ include/cookie/mir/cookie/cookie.h 2016-01-25 13:42:04 +0000
@@ -0,0 +1,57 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
17 */
18
19#ifndef MIR_COOKIE_COOKIE_H_
20#define MIR_COOKIE_COOKIE_H_
21
22#include <stdint.h>
23#include <vector>
24
25namespace mir
26{
27namespace cookie
28{
29
30class Cookie
31{
32public:
33 Cookie() = default;
34 virtual ~Cookie() = default;
35
36 Cookie(Cookie const& cookie) = delete;
37 Cookie& operator=(Cookie const& cookie) = delete;
38
39 /**
40 * Returns the timestamp that the cookie is built with
41 *
42 * \return The timestamp
43 */
44 virtual uint64_t timestamp() const = 0;
45
46 /**
47 * Converts the cookie into a stream of bytes.
48 *
49 * \return The stream of bytes formatted
50 */
51 virtual std::vector<uint8_t> serialize() const = 0;
52};
53
54}
55}
56
57#endif // MIR_COOKIE_COOKIE_H_
058
=== removed directory 'include/cookie/mir_toolkit'
=== modified file 'include/server/mir/server.h'
--- include/server/mir/server.h 2016-01-20 23:59:18 +0000
+++ include/server/mir/server.h 2016-01-25 13:42:04 +0000
@@ -37,7 +37,7 @@
37namespace cookie37namespace cookie
38{38{
39using Secret = std::vector<uint8_t>;39using Secret = std::vector<uint8_t>;
40class CookieFactory;40class Authority;
41}41}
42namespace shell42namespace shell
43{43{
@@ -86,11 +86,11 @@
86 /// This must remain valid while apply_settings() and run() are called.86 /// This must remain valid while apply_settings() and run() are called.
87 void set_command_line(int argc, char const* argv[]);87 void set_command_line(int argc, char const* argv[]);
8888
89 /// Sets an override functor for creating the cookie factory.89 /// Sets an override functor for creating the cookie authority.
90 /// A secret can be saved and any process this secret is shared90 /// A secret can be saved and any process this secret is shared
91 /// with can verify Mir-generated cookies, or produce their own.91 /// with can verify Mir-generated cookies, or produce their own.
92 void override_the_cookie_factory(92 void override_the_cookie_authority(
93 std::function<std::shared_ptr<cookie::CookieFactory>()> const& cookie_factory_builder);93 std::function<std::shared_ptr<cookie::Authority>()> const& cookie_authority_builder);
9494
95 /// Applies any configuration options, hooks, or custom implementations.95 /// Applies any configuration options, hooks, or custom implementations.
96 /// Must be called before calling run() or accessing any mir subsystems.96 /// Must be called before calling run() or accessing any mir subsystems.
9797
=== modified file 'include/server/mir/shell/abstract_shell.h'
--- include/server/mir/shell/abstract_shell.h 2016-01-20 23:59:18 +0000
+++ include/server/mir/shell/abstract_shell.h 2016-01-25 13:42:04 +0000
@@ -71,7 +71,7 @@
71 std::shared_ptr<scene::Surface> const& surface,71 std::shared_ptr<scene::Surface> const& surface,
72 MirSurfaceAttrib attrib) override;72 MirSurfaceAttrib attrib) override;
7373
74 void raise_surface_with_timestamp(74 void raise_surface(
75 std::shared_ptr<scene::Session> const& session,75 std::shared_ptr<scene::Session> const& session,
76 std::shared_ptr<scene::Surface> const& surface,76 std::shared_ptr<scene::Surface> const& surface,
77 uint64_t timestamp) override;77 uint64_t timestamp) override;
7878
=== modified file 'include/server/mir/shell/shell.h'
--- include/server/mir/shell/shell.h 2016-01-20 23:59:18 +0000
+++ include/server/mir/shell/shell.h 2016-01-25 13:42:04 +0000
@@ -95,7 +95,7 @@
95 std::shared_ptr<scene::Surface> const& surface,95 std::shared_ptr<scene::Surface> const& surface,
96 MirSurfaceAttrib attrib) = 0;96 MirSurfaceAttrib attrib) = 0;
9797
98 virtual void raise_surface_with_timestamp(98 virtual void raise_surface(
99 std::shared_ptr<scene::Session> const& session,99 std::shared_ptr<scene::Session> const& session,
100 std::shared_ptr<scene::Surface> const& surface,100 std::shared_ptr<scene::Surface> const& surface,
101 uint64_t timestamp) = 0;101 uint64_t timestamp) = 0;
102102
=== modified file 'include/server/mir/shell/shell_wrapper.h'
--- include/server/mir/shell/shell_wrapper.h 2016-01-20 23:59:18 +0000
+++ include/server/mir/shell/shell_wrapper.h 2016-01-25 13:42:04 +0000
@@ -80,7 +80,7 @@
80 std::shared_ptr<scene::Surface> const& surface,80 std::shared_ptr<scene::Surface> const& surface,
81 MirSurfaceAttrib attrib) override;81 MirSurfaceAttrib attrib) override;
8282
83 void raise_surface_with_timestamp(83 void raise_surface(
84 std::shared_ptr<scene::Session> const& session,84 std::shared_ptr<scene::Session> const& session,
85 std::shared_ptr<scene::Surface> const& surface,85 std::shared_ptr<scene::Surface> const& surface,
86 uint64_t timestamp) override;86 uint64_t timestamp) override;
8787
=== modified file 'src/client/CMakeLists.txt'
--- src/client/CMakeLists.txt 2016-01-22 03:09:31 +0000
+++ src/client/CMakeLists.txt 2016-01-25 13:42:04 +0000
@@ -20,9 +20,9 @@
20include_directories(20include_directories(
21 ${PROTOBUF_INCLUDE_DIRS}21 ${PROTOBUF_INCLUDE_DIRS}
22 ${CMAKE_CURRENT_BINARY_DIR}22 ${CMAKE_CURRENT_BINARY_DIR}
23 ${PROJECT_SOURCE_DIR}/include/cookie
24 ${PROJECT_SOURCE_DIR}/include/client23 ${PROJECT_SOURCE_DIR}/include/client
25 ${PROJECT_SOURCE_DIR}/src/include/client24 ${PROJECT_SOURCE_DIR}/src/include/client
25 ${PROJECT_SOURCE_DIR}/src/include/cookie
26 ${DRM_INCLUDE_DIRS}26 ${DRM_INCLUDE_DIRS}
27)27)
2828
@@ -49,6 +49,7 @@
49 event.cpp49 event.cpp
50 event_printer.cpp50 event_printer.cpp
51 mir_blob.cpp51 mir_blob.cpp
52 mir_cookie.cpp
52 mir_connection.cpp53 mir_connection.cpp
53 mir_connection_api.cpp54 mir_connection_api.cpp
54 mir_wait_handle.cpp55 mir_wait_handle.cpp
@@ -95,6 +96,7 @@
95set(LINKS96set(LINKS
96 mircommon97 mircommon
97 mirprotobuf98 mirprotobuf
99 mircookie
98100
99 ${XKBCOMMON_LIBRARIES}101 ${XKBCOMMON_LIBRARIES}
100)102)
101103
=== modified file 'src/client/events/event_builders.cpp'
--- src/client/events/event_builders.cpp 2016-01-23 03:16:06 +0000
+++ src/client/events/event_builders.cpp 2016-01-25 13:42:04 +0000
@@ -24,11 +24,14 @@
2424
25#include "mir/events/event_builders.h"25#include "mir/events/event_builders.h"
26#include "mir/events/event_private.h"26#include "mir/events/event_private.h"
27#include "mir/cookie/blob.h"
27#include "mir/input/xkb_mapper.h"28#include "mir/input/xkb_mapper.h"
2829
29#include <string.h>30#include <string.h>
3031
31#include <boost/throw_exception.hpp>32#include <boost/throw_exception.hpp>
33
34#include <algorithm>
32#include <stdexcept>35#include <stdexcept>
3336
34namespace mi = mir::input;37namespace mi = mir::input;
@@ -36,6 +39,25 @@
36namespace mev = mir::events;39namespace mev = mir::events;
37namespace geom = mir::geometry;40namespace geom = mir::geometry;
3841
42namespace
43{
44 mir::cookie::Blob vector_to_cookie_as_blob(std::vector<uint8_t> const& vector)
45 {
46 mir::cookie::Blob blob{{}};
47
48 if (vector.size() > blob.size())
49 {
50 throw std::runtime_error("Vector size " + std::to_string(vector.size()) +
51 " is larger then array size: " +
52 std::to_string(blob.size()));
53 }
54
55 std::copy_n(vector.begin(), vector.size(), blob.begin());
56
57 return blob;
58 }
59}
60
39mir::EventUPtr mev::make_event(mf::SurfaceId const& surface_id, MirOrientation orientation)61mir::EventUPtr mev::make_event(mf::SurfaceId const& surface_id, MirOrientation orientation)
40{62{
41 auto e = make_empty_event();63 auto e = make_empty_event();
@@ -137,7 +159,7 @@
137}159}
138160
139mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,161mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
140 uint64_t mac, MirKeyboardAction action, xkb_keysym_t key_code,162 std::vector<uint8_t> const& cookie, MirKeyboardAction action, xkb_keysym_t key_code,
141 int scan_code, MirInputEventModifiers modifiers)163 int scan_code, MirInputEventModifiers modifiers)
142{164{
143 auto e = make_empty_event();165 auto e = make_empty_event();
@@ -147,7 +169,7 @@
147 kev.device_id = device_id;169 kev.device_id = device_id;
148 kev.source_id = AINPUT_SOURCE_KEYBOARD;170 kev.source_id = AINPUT_SOURCE_KEYBOARD;
149 kev.event_time = timestamp;171 kev.event_time = timestamp;
150 kev.mac = mac;172 kev.cookie = vector_to_cookie_as_blob(cookie);
151 kev.action = action;173 kev.action = action;
152 kev.key_code = key_code;174 kev.key_code = key_code;
153 kev.scan_code = scan_code;175 kev.scan_code = scan_code;
@@ -156,7 +178,6 @@
156 return e;178 return e;
157}179}
158180
159
160void mev::set_modifier(MirEvent& event, MirInputEventModifiers modifiers)181void mev::set_modifier(MirEvent& event, MirInputEventModifiers modifiers)
161{182{
162 switch(event.type)183 switch(event.type)
@@ -199,16 +220,24 @@
199 event.motion.buttons = button_state;220 event.motion.buttons = button_state;
200}221}
201222
223// Deprecated version with uint64_t mac
224mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
225 uint64_t /*mac*/, MirKeyboardAction action, xkb_keysym_t key_code,
226 int scan_code, MirInputEventModifiers modifiers)
227{
228 return make_event(device_id, timestamp, std::vector<uint8_t>{}, action, key_code, scan_code, modifiers);
229}
230
202// Deprecated version without mac231// Deprecated version without mac
203mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,232mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
204 MirKeyboardAction action, xkb_keysym_t key_code,233 MirKeyboardAction action, xkb_keysym_t key_code,
205 int scan_code, MirInputEventModifiers modifiers)234 int scan_code, MirInputEventModifiers modifiers)
206{235{
207 return make_event(device_id, timestamp, 0, action, key_code, scan_code, modifiers);236 return make_event(device_id, timestamp, std::vector<uint8_t>{}, action, key_code, scan_code, modifiers);
208}237}
209238
210mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,239mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
211 uint64_t mac, MirInputEventModifiers modifiers)240 std::vector<uint8_t> const& cookie, MirInputEventModifiers modifiers)
212{241{
213 auto e = make_empty_event();242 auto e = make_empty_event();
214243
@@ -216,18 +245,25 @@
216 auto& mev = e->motion;245 auto& mev = e->motion;
217 mev.device_id = device_id;246 mev.device_id = device_id;
218 mev.event_time = timestamp;247 mev.event_time = timestamp;
219 mev.mac = mac;248 mev.cookie = vector_to_cookie_as_blob(cookie);
220 mev.modifiers = modifiers;249 mev.modifiers = modifiers;
221 mev.source_id = AINPUT_SOURCE_TOUCHSCREEN;250 mev.source_id = AINPUT_SOURCE_TOUCHSCREEN;
222251
223 return e;252 return e;
224}253}
225254
255// Deprecated version with uint64_t mac
256mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
257 uint64_t /*mac*/, MirInputEventModifiers modifiers)
258{
259 return make_event(device_id, timestamp, std::vector<uint8_t>{}, modifiers);
260}
261
226// Deprecated version without mac262// Deprecated version without mac
227mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,263mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
228 MirInputEventModifiers modifiers)264 MirInputEventModifiers modifiers)
229{265{
230 return make_event(device_id, timestamp, 0, modifiers);266 return make_event(device_id, timestamp, std::vector<uint8_t>{}, modifiers);
231}267}
232268
233void mev::add_touch(MirEvent &event, MirTouchId touch_id, MirTouchAction action,269void mev::add_touch(MirEvent &event, MirTouchId touch_id, MirTouchAction action,
@@ -248,7 +284,7 @@
248}284}
249285
250mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,286mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
251 uint64_t mac, MirInputEventModifiers modifiers, MirPointerAction action,287 std::vector<uint8_t> const& cookie, MirInputEventModifiers modifiers, MirPointerAction action,
252 MirPointerButtons buttons_pressed, 288 MirPointerButtons buttons_pressed,
253 float x_axis_value, float y_axis_value,289 float x_axis_value, float y_axis_value,
254 float hscroll_value, float vscroll_value,290 float hscroll_value, float vscroll_value,
@@ -260,7 +296,7 @@
260 auto& mev = e->motion;296 auto& mev = e->motion;
261 mev.device_id = device_id;297 mev.device_id = device_id;
262 mev.event_time = timestamp;298 mev.event_time = timestamp;
263 mev.mac = mac;299 mev.cookie = vector_to_cookie_as_blob(cookie);
264 mev.modifiers = modifiers;300 mev.modifiers = modifiers;
265 mev.source_id = AINPUT_SOURCE_MOUSE;301 mev.source_id = AINPUT_SOURCE_MOUSE;
266 mev.buttons = buttons_pressed;302 mev.buttons = buttons_pressed;
@@ -278,6 +314,19 @@
278 return e;314 return e;
279}315}
280316
317// Deprecated version with uint64_t mac
318mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
319 uint64_t /*mac*/, MirInputEventModifiers modifiers, MirPointerAction action,
320 MirPointerButtons buttons_pressed,
321 float x_axis_value, float y_axis_value,
322 float hscroll_value, float vscroll_value,
323 float relative_x_value, float relative_y_value)
324{
325 return make_event(device_id, timestamp, std::vector<uint8_t>{}, modifiers, action,
326 buttons_pressed, x_axis_value, y_axis_value, hscroll_value,
327 vscroll_value, relative_x_value, relative_y_value);
328}
329
281// Deprecated version without mac330// Deprecated version without mac
282mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,331mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
283 MirInputEventModifiers modifiers, MirPointerAction action,332 MirInputEventModifiers modifiers, MirPointerAction action,
@@ -286,19 +335,19 @@
286 float hscroll_value, float vscroll_value,335 float hscroll_value, float vscroll_value,
287 float relative_x_value, float relative_y_value)336 float relative_x_value, float relative_y_value)
288{337{
289 return make_event(device_id, timestamp, 0, modifiers, action,338 return make_event(device_id, timestamp, std::vector<uint8_t>{}, modifiers, action,
290 buttons_pressed, x_axis_value, y_axis_value, hscroll_value,339 buttons_pressed, x_axis_value, y_axis_value, hscroll_value,
291 vscroll_value, relative_x_value, relative_y_value);340 vscroll_value, relative_x_value, relative_y_value);
292}341}
293342
294// Deprecated version without relative axis343// Deprecated version without relative axis
295mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,344mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
296 uint64_t mac, MirInputEventModifiers modifiers, MirPointerAction action,345 uint64_t /*mac*/, MirInputEventModifiers modifiers, MirPointerAction action,
297 MirPointerButtons buttons_pressed, 346 MirPointerButtons buttons_pressed,
298 float x_axis_value, float y_axis_value,347 float x_axis_value, float y_axis_value,
299 float hscroll_value, float vscroll_value)348 float hscroll_value, float vscroll_value)
300{349{
301 return make_event(device_id, timestamp, mac, modifiers, action, buttons_pressed,350 return make_event(device_id, timestamp, std::vector<uint8_t>{}, modifiers, action, buttons_pressed,
302 x_axis_value, y_axis_value, hscroll_value, vscroll_value, 0, 0);351 x_axis_value, y_axis_value, hscroll_value, vscroll_value, 0, 0);
303}352}
304353
@@ -309,7 +358,7 @@
309 float x_axis_value, float y_axis_value,358 float x_axis_value, float y_axis_value,
310 float hscroll_value, float vscroll_value)359 float hscroll_value, float vscroll_value)
311{360{
312 return make_event(device_id, timestamp, 0, modifiers, action, buttons_pressed,361 return make_event(device_id, timestamp, std::vector<uint8_t>{}, modifiers, action, buttons_pressed,
313 x_axis_value, y_axis_value, hscroll_value, vscroll_value, 0, 0);362 x_axis_value, y_axis_value, hscroll_value, vscroll_value, 0, 0);
314}363}
315364
316365
=== modified file 'src/client/input/android/android_input_lexicon.cpp'
--- src/client/input/android/android_input_lexicon.cpp 2016-01-20 23:59:18 +0000
+++ src/client/input/android/android_input_lexicon.cpp 2016-01-25 13:42:04 +0000
@@ -20,6 +20,7 @@
20#include "mir/input/android/android_input_lexicon.h"20#include "mir/input/android/android_input_lexicon.h"
21#include "mir/input/android/event_conversion_helpers.h"21#include "mir/input/android/event_conversion_helpers.h"
22#include "mir/events/event_builders.h"22#include "mir/events/event_builders.h"
23#include "mir/cookie/blob.h"
2324
24#include <androidfw/Input.h>25#include <androidfw/Input.h>
2526
@@ -38,9 +39,10 @@
38 case AINPUT_EVENT_TYPE_KEY:39 case AINPUT_EVENT_TYPE_KEY:
39 {40 {
40 auto kev = static_cast<const droidinput::KeyEvent*>(android_event);41 auto kev = static_cast<const droidinput::KeyEvent*>(android_event);
42 auto const cookie = kev->getCookieAsBlob();
41 return mev::make_event(MirInputDeviceId(android_event->getDeviceId()),43 return mev::make_event(MirInputDeviceId(android_event->getDeviceId()),
42 kev->getEventTime(),44 kev->getEventTime(),
43 kev->getMac(),45 {std::begin(cookie), std::end(cookie)},
44 mia::mir_keyboard_action_from_android(kev->getAction(), kev->getRepeatCount()),46 mia::mir_keyboard_action_from_android(kev->getAction(), kev->getRepeatCount()),
45 kev->getKeyCode(),47 kev->getKeyCode(),
46 kev->getScanCode(),48 kev->getScanCode(),
@@ -51,9 +53,10 @@
51 if (mia::android_source_id_is_pointer_device(android_event->getSource()))53 if (mia::android_source_id_is_pointer_device(android_event->getSource()))
52 {54 {
53 auto mev = static_cast<const droidinput::MotionEvent*>(android_event);55 auto mev = static_cast<const droidinput::MotionEvent*>(android_event);
56 auto const cookie = mev->getCookieAsBlob();
54 return mev::make_event(MirInputDeviceId(android_event->getDeviceId()),57 return mev::make_event(MirInputDeviceId(android_event->getDeviceId()),
55 mev->getEventTime(),58 mev->getEventTime(),
56 mev->getMac(),59 {std::begin(cookie), std::end(cookie)},
57 mia::mir_modifiers_from_android(mev->getMetaState()),60 mia::mir_modifiers_from_android(mev->getMetaState()),
58 mia::mir_pointer_action_from_masked_android(mev->getAction() & AMOTION_EVENT_ACTION_MASK),61 mia::mir_pointer_action_from_masked_android(mev->getAction() & AMOTION_EVENT_ACTION_MASK),
59 mia::mir_pointer_buttons_from_android(mev->getButtonState()),62 mia::mir_pointer_buttons_from_android(mev->getButtonState()),
@@ -66,9 +69,10 @@
66 else69 else
67 {70 {
68 auto mev = static_cast<const droidinput::MotionEvent*>(android_event);71 auto mev = static_cast<const droidinput::MotionEvent*>(android_event);
72 auto const cookie = mev->getCookieAsBlob();
69 auto ev = mev::make_event(MirInputDeviceId(android_event->getDeviceId()),73 auto ev = mev::make_event(MirInputDeviceId(android_event->getDeviceId()),
70 mev->getEventTime(),74 mev->getEventTime(),
71 mev->getMac(),75 {std::begin(cookie), std::end(cookie)},
72 mia::mir_modifiers_from_android(mev->getMetaState()));76 mia::mir_modifiers_from_android(mev->getMetaState()));
73 auto action = mev->getAction();77 auto action = mev->getAction();
74 size_t index_with_action = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;78 size_t index_with_action = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
7579
=== modified file 'src/client/input/input_event.cpp'
--- src/client/input/input_event.cpp 2016-01-20 23:59:18 +0000
+++ src/client/input/input_event.cpp 2016-01-25 13:42:04 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2014 Canonical Ltd.2 * Copyright © 2014-2016 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,5 * under the terms of the GNU Lesser General Public License version 3,
@@ -18,9 +18,16 @@
1818
19#define MIR_LOG_COMPONENT "input-event-access"19#define MIR_LOG_COMPONENT "input-event-access"
2020
21#include "mir/cookie/cookie.h"
21#include "mir/event_type_to_string.h"22#include "mir/event_type_to_string.h"
22#include "mir/events/event_private.h"23#include "mir/events/event_private.h"
23#include "mir/log.h"24#include "mir/log.h"
25#include "mir/require.h"
26#include "mir_toolkit/mir_cookie.h"
27
28#include "../mir_cookie.h"
29
30#include <string.h>
2431
25namespace ml = mir::logging;32namespace ml = mir::logging;
2633
@@ -395,3 +402,92 @@
395 abort();402 abort();
396 }403 }
397}404}
405
406bool mir_input_event_has_cookie(MirInputEvent const* ev)
407{
408 switch (mir_input_event_get_type(ev))
409 {
410 case mir_input_event_type_key:
411 return true;
412 case mir_input_event_type_pointer:
413 {
414 auto const pev = mir_input_event_get_pointer_event(ev);
415 auto const pev_action = mir_pointer_event_action(pev);
416 return (pev_action == mir_pointer_action_button_up ||
417 pev_action == mir_pointer_action_button_down);
418 }
419 case mir_input_event_type_touch:
420 {
421 auto const tev = mir_input_event_get_touch_event(ev);
422 auto const point_count = mir_touch_event_point_count(tev);
423 for (size_t i = 0; i < point_count; i++)
424 {
425 auto const tev_action = mir_touch_event_action(tev, i);
426 if (tev_action == mir_touch_action_up ||
427 tev_action == mir_touch_action_down)
428 {
429 return true;
430 }
431 }
432 break;
433 }
434 }
435
436 return false;
437}
438
439size_t mir_cookie_buffer_size(MirCookie const* cookie) try
440{
441 return cookie->size();
442} catch (...)
443{
444 abort();
445}
446
447MirCookie const* mir_input_event_get_cookie(MirInputEvent const* iev) try
448{
449 auto const ev = old_ev_from_new(iev);
450
451 switch (ev->type)
452 {
453 case mir_event_type_motion:
454 return new MirCookie(ev->motion.cookie);
455 case mir_event_type_key:
456 return new MirCookie(ev->key.cookie);
457 default:
458 {
459 mir::log_critical("expected a key or motion events, type was: " + mir::event_type_to_string(ev->type));
460 abort();
461 }
462 }
463} catch (...)
464{
465 abort();
466}
467
468void mir_cookie_to_buffer(MirCookie const* cookie, void* buffer, size_t size) try
469{
470 return cookie->copy_to(buffer, size);
471} catch (...)
472{
473 abort();
474}
475
476MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size) try
477{
478 if (size != mir::cookie::default_blob_size)
479 return NULL;
480
481 return new MirCookie(buffer, size);
482} catch (...)
483{
484 abort();
485}
486
487void mir_cookie_release(MirCookie const* cookie) try
488{
489 delete cookie;
490} catch (...)
491{
492 abort();
493}
398494
=== added file 'src/client/mir_cookie.cpp'
--- src/client/mir_cookie.cpp 1970-01-01 00:00:00 +0000
+++ src/client/mir_cookie.cpp 2016-01-25 13:42:04 +0000
@@ -0,0 +1,49 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
17 */
18
19#include "mir_cookie.h"
20
21#include "mir/require.h"
22
23#include <string.h>
24
25MirCookie::MirCookie(void const* buffer, size_t size)
26{
27 memcpy(blob_.data(), buffer, size);
28}
29
30MirCookie::MirCookie(mir::cookie::Blob const& blob) :
31 blob_(blob)
32{
33}
34
35void MirCookie::copy_to(void* buffer, size_t size) const
36{
37 mir::require(size == blob_.size());
38 memcpy(buffer, blob_.data(), size);
39}
40
41size_t MirCookie::size() const
42{
43 return blob_.size();
44}
45
46mir::cookie::Blob MirCookie::blob() const
47{
48 return blob_;
49}
050
=== added file 'src/client/mir_cookie.h'
--- src/client/mir_cookie.h 1970-01-01 00:00:00 +0000
+++ src/client/mir_cookie.h 2016-01-25 13:42:04 +0000
@@ -0,0 +1,40 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
17 */
18
19
20#ifndef MIR_CLIENT_MIR_COOKIE_H_
21#define MIR_CLIENT_MIR_COOKIE_H_
22
23#include "mir/cookie/blob.h"
24
25class MirCookie
26{
27public:
28 explicit MirCookie(void const* buffer, size_t size);
29 explicit MirCookie(mir::cookie::Blob const& blob);
30
31 void copy_to(void* buffer, size_t size) const;
32 size_t size() const;
33
34 mir::cookie::Blob blob() const;
35
36private:
37 mir::cookie::Blob blob_;
38};
39
40#endif // MIR_CLIENT_MIR_COOKIE_H_
041
=== modified file 'src/client/mir_surface.cpp'
--- src/client/mir_surface.cpp 2016-01-23 03:16:06 +0000
+++ src/client/mir_surface.cpp 2016-01-25 13:42:04 +0000
@@ -29,7 +29,8 @@
29#include "mir/dispatch/threaded_dispatcher.h"29#include "mir/dispatch/threaded_dispatcher.h"
30#include "mir/input/input_platform.h"30#include "mir/input/input_platform.h"
31#include "mir/input/xkb_mapper.h"31#include "mir/input/xkb_mapper.h"
32#include "mir_toolkit/cookie.h"32#include "mir/cookie/cookie.h"
33#include "mir_cookie.h"
3334
34#include <cassert>35#include <cassert>
35#include <unistd.h>36#include <unistd.h>
@@ -485,7 +486,7 @@
485 return configure(mir_surface_attrib_preferred_orientation, mode);486 return configure(mir_surface_attrib_preferred_orientation, mode);
486}487}
487488
488void MirSurface::raise_surface_with_cookie(MirCookie const& cookie)489void MirSurface::raise_surface(MirCookie const* cookie)
489{490{
490 mp::RaiseRequest raise_request;491 mp::RaiseRequest raise_request;
491492
@@ -494,10 +495,9 @@
494495
495 auto const event_cookie = raise_request.mutable_cookie();496 auto const event_cookie = raise_request.mutable_cookie();
496497
497 event_cookie->set_timestamp(cookie.timestamp);498 event_cookie->set_cookie(cookie->blob().data(), cookie->size());
498 event_cookie->set_mac(cookie.mac);
499499
500 server->raise_surface_with_cookie(500 server->raise_surface(
501 &raise_request,501 &raise_request,
502 void_response.get(),502 void_response.get(),
503 google::protobuf::NewCallback(google::protobuf::DoNothing));503 google::protobuf::NewCallback(google::protobuf::DoNothing));
504504
=== modified file 'src/client/mir_surface.h'
--- src/client/mir_surface.h 2016-01-20 23:59:18 +0000
+++ src/client/mir_surface.h 2016-01-25 13:42:04 +0000
@@ -31,7 +31,6 @@
31#include "mir_toolkit/common.h"31#include "mir_toolkit/common.h"
32#include "mir_toolkit/mir_client_library.h"32#include "mir_toolkit/mir_client_library.h"
33#include "mir/graphics/native_buffer.h"33#include "mir/graphics/native_buffer.h"
34#include "mir/cookie_factory.h"
3534
36#include <memory>35#include <memory>
37#include <functional>36#include <functional>
@@ -175,7 +174,7 @@
175 MirOrientation get_orientation() const;174 MirOrientation get_orientation() const;
176 MirWaitHandle* set_preferred_orientation(MirOrientationMode mode);175 MirWaitHandle* set_preferred_orientation(MirOrientationMode mode);
177176
178 void raise_surface_with_cookie(MirCookie const& cookie);177 void raise_surface(MirCookie const* cookie);
179178
180 MirWaitHandle* configure_cursor(MirCursorConfiguration const* cursor);179 MirWaitHandle* configure_cursor(MirCursorConfiguration const* cursor);
181180
182181
=== modified file 'src/client/mir_surface_api.cpp'
--- src/client/mir_surface_api.cpp 2016-01-20 23:59:18 +0000
+++ src/client/mir_surface_api.cpp 2016-01-25 13:42:04 +0000
@@ -20,7 +20,6 @@
2020
21#include "mir_toolkit/mir_surface.h"21#include "mir_toolkit/mir_surface.h"
22#include "mir_toolkit/mir_wait.h"22#include "mir_toolkit/mir_wait.h"
23#include "mir_toolkit/cookie.h"
24#include "mir/require.h"23#include "mir/require.h"
2524
26#include "mir_connection.h"25#include "mir_connection.h"
@@ -486,13 +485,13 @@
486 return result;485 return result;
487}486}
488487
489void mir_surface_raise_with_cookie(MirSurface* surf, MirCookie const cookie)488void mir_surface_raise(MirSurface* surf, MirCookie const* cookie)
490{489{
491 mir::require(mir_surface_is_valid(surf));490 mir::require(mir_surface_is_valid(surf));
492491
493 try492 try
494 {493 {
495 surf->raise_surface_with_cookie(cookie);494 surf->raise_surface(cookie);
496 }495 }
497 catch (std::exception const& ex)496 catch (std::exception const& ex)
498 {497 {
499498
=== modified file 'src/client/rpc/mir_display_server.cpp'
--- src/client/rpc/mir_display_server.cpp 2016-01-20 23:59:18 +0000
+++ src/client/rpc/mir_display_server.cpp 2016-01-25 13:42:04 +0000
@@ -210,7 +210,7 @@
210{210{
211 channel->call_method(std::string(__func__), request, response, done);211 channel->call_method(std::string(__func__), request, response, done);
212}212}
213void mclr::DisplayServer::raise_surface_with_cookie(213void mclr::DisplayServer::raise_surface(
214 mir::protobuf::RaiseRequest const* request,214 mir::protobuf::RaiseRequest const* request,
215 mir::protobuf::Void* response,215 mir::protobuf::Void* response,
216 google::protobuf::Closure* done)216 google::protobuf::Closure* done)
217217
=== modified file 'src/client/rpc/mir_display_server.h'
--- src/client/rpc/mir_display_server.h 2016-01-20 23:59:18 +0000
+++ src/client/rpc/mir_display_server.h 2016-01-25 13:42:04 +0000
@@ -139,7 +139,7 @@
139 mir::protobuf::StreamConfiguration const* request,139 mir::protobuf::StreamConfiguration const* request,
140 mir::protobuf::Void* response,140 mir::protobuf::Void* response,
141 google::protobuf::Closure* done) override;141 google::protobuf::Closure* done) override;
142 void raise_surface_with_cookie(142 void raise_surface(
143 mir::protobuf::RaiseRequest const* request,143 mir::protobuf::RaiseRequest const* request,
144 mir::protobuf::Void* response,144 mir::protobuf::Void* response,
145 google::protobuf::Closure* done) override;145 google::protobuf::Closure* done) override;
146146
=== modified file 'src/client/symbols.map'
--- src/client/symbols.map 2016-01-23 03:16:06 +0000
+++ src/client/symbols.map 2016-01-25 13:42:04 +0000
@@ -210,6 +210,13 @@
210MIR_CLIENT_unreleased {210MIR_CLIENT_unreleased {
211 global:211 global:
212 mir_connection_get_graphics_module;212 mir_connection_get_graphics_module;
213 mir_surface_raise;
214 mir_input_event_has_cookie;
215 mir_cookie_buffer_size;
216 mir_input_event_get_cookie;
217 mir_cookie_to_buffer;
218 mir_cookie_from_buffer;
219 mir_cookie_release;
213 mir_keymap_event_get_keymap_buffer;220 mir_keymap_event_get_keymap_buffer;
214 mir_keymap_event_get_device_id;221 mir_keymap_event_get_device_id;
215 local:222 local:
216223
=== modified file 'src/cookie/CMakeLists.txt'
--- src/cookie/CMakeLists.txt 2016-01-22 03:09:31 +0000
+++ src/cookie/CMakeLists.txt 2016-01-25 13:42:04 +0000
@@ -12,17 +12,19 @@
12)12)
1313
14include_directories(14include_directories(
15 ${PROJECT_SOURCE_DIR}/src/include/cookie
15 ${PROJECT_SOURCE_DIR}/include/cookie16 ${PROJECT_SOURCE_DIR}/include/cookie
16 ${NETTLE_INCLUDE_DIRS}17 ${NETTLE_INCLUDE_DIRS}
17)18)
1819
19set(MIRCOOKIE_ABI 1)20set(MIRCOOKIE_ABI 2)
20set(symbol_map ${CMAKE_SOURCE_DIR}/src/cookie/symbols.map)21set(symbol_map ${CMAKE_SOURCE_DIR}/src/cookie/symbols.map)
2122
22mir_add_library_with_symbols(mircookie SHARED23mir_add_library_with_symbols(mircookie SHARED
2324
24 ${symbol_map}25 ${symbol_map}
25 cookie_factory.cpp26 authority.cpp
27 hmac_cookie.cpp
26)28)
2729
28set_target_properties(mircookie30set_target_properties(mircookie
@@ -41,7 +43,7 @@
41 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})43 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
4244
43install(45install(
44 DIRECTORY ${CMAKE_SOURCE_DIR}/include/cookie/mir ${CMAKE_SOURCE_DIR}/include/cookie/mir_toolkit46 DIRECTORY ${CMAKE_SOURCE_DIR}/include/cookie/mir
45 DESTINATION "include/mircookie"47 DESTINATION "include/mircookie"
46)48)
4749
4850
=== renamed file 'src/cookie/cookie_factory.cpp' => 'src/cookie/authority.cpp'
--- src/cookie/cookie_factory.cpp 2016-01-20 23:59:18 +0000
+++ src/cookie/authority.cpp 2016-01-25 13:42:04 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2015 Canonical Ltd.2 * Copyright © 2015-2016 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -14,9 +14,13 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 * Brandon Schaefer <brandon.schaefer@canonical.com>
17 */18 */
1819
19#include "mir/cookie_factory.h"20#include "mir/cookie/authority.h"
21#include "mir/cookie/blob.h"
22#include "hmac_cookie.h"
23#include "format.h"
2024
21#include <algorithm>25#include <algorithm>
22#include <random>26#include <random>
@@ -29,6 +33,7 @@
29#include <sys/stat.h>33#include <sys/stat.h>
30#include <fcntl.h>34#include <fcntl.h>
31#include <sys/select.h>35#include <sys/select.h>
36#include <string.h>
3237
33#include <boost/throw_exception.hpp>38#include <boost/throw_exception.hpp>
3439
@@ -37,6 +42,19 @@
37std::string const random_device_path{"/dev/random"};42std::string const random_device_path{"/dev/random"};
38std::string const urandom_device_path{"/dev/urandom"};43std::string const urandom_device_path{"/dev/urandom"};
39int const wait_seconds{30};44int const wait_seconds{30};
45
46size_t cookie_size_from_format(mir::cookie::Format const& format)
47{
48 switch (format)
49 {
50 case mir::cookie::Format::hmac_sha_1_8:
51 return mir::cookie::default_blob_size;
52 default:
53 break;
54 }
55
56 return 0;
57}
40}58}
4159
42static mir::cookie::Secret get_random_data(unsigned size)60static mir::cookie::Secret get_random_data(unsigned size)
@@ -94,10 +112,15 @@
94 return buffer;112 return buffer;
95}113}
96114
97class CookieFactoryNettle : public mir::cookie::CookieFactory115mir::cookie::SecurityCheckError::SecurityCheckError() :
116 runtime_error("Invalid Cookie")
117{
118}
119
120class AuthorityNettle : public mir::cookie::Authority
98{121{
99public:122public:
100 CookieFactoryNettle(mir::cookie::Secret const& secret)123 AuthorityNettle(mir::cookie::Secret const& secret)
101 {124 {
102 if (secret.size() < minimum_secret_size)125 if (secret.size() < minimum_secret_size)
103 BOOST_THROW_EXCEPTION(std::logic_error("Secret size " + std::to_string(secret.size()) + " is to small, require " +126 BOOST_THROW_EXCEPTION(std::logic_error("Secret size " + std::to_string(secret.size()) + " is to small, require " +
@@ -106,41 +129,83 @@
106 hmac_sha1_set_key(&ctx, secret.size(), secret.data());129 hmac_sha1_set_key(&ctx, secret.size(), secret.data());
107 }130 }
108131
109 virtual ~CookieFactoryNettle() noexcept = default;132 virtual ~AuthorityNettle() noexcept = default;
110133
111 MirCookie timestamp_to_cookie(uint64_t const& timestamp) override134
112 {135 std::unique_ptr<mir::cookie::Cookie> make_cookie(uint64_t const& timestamp) override
113 MirCookie cookie { timestamp, 0 };136 {
114 calculate_mac(cookie);137 return std::make_unique<mir::cookie::HMACCookie>(timestamp, calculate_cookie(timestamp), mir::cookie::Format::hmac_sha_1_8);
138 }
139
140 std::unique_ptr<mir::cookie::Cookie> make_cookie(std::vector<uint8_t> const& raw_cookie) override
141 {
142 /*
143 SHA_1 Format:
144 1 byte = FORMAT
145 8 btyes = TIMESTAMP
146 8 BYTES = MAC
147 */
148
149 if (raw_cookie.size() != cookie_size_from_format(mir::cookie::Format::hmac_sha_1_8))
150 {
151 BOOST_THROW_EXCEPTION(mir::cookie::SecurityCheckError());
152 }
153
154 mir::cookie::Format format = static_cast<mir::cookie::Format>(raw_cookie[0]);
155 if (format != mir::cookie::Format::hmac_sha_1_8)
156 {
157 BOOST_THROW_EXCEPTION(mir::cookie::SecurityCheckError());
158 }
159
160 uint64_t timestamp = 0;
161
162 auto ptr = raw_cookie.data();
163 ptr++;
164
165 memcpy(&timestamp, ptr, 8);
166 ptr += sizeof(timestamp);
167
168 // FIXME Soon to be 20 bytes
169 std::vector<uint8_t> mac(8);
170 memcpy(mac.data(), ptr, mac.size());
171
172 std::unique_ptr<mir::cookie::Cookie> cookie =
173 std::make_unique<mir::cookie::HMACCookie>(timestamp, mac, mir::cookie::Format::hmac_sha_1_8);
174
175 if (!verify_cookie(timestamp, cookie))
176 {
177 BOOST_THROW_EXCEPTION(mir::cookie::SecurityCheckError());
178 }
179
115 return cookie;180 return cookie;
116 }181 }
117182
118 bool attest_timestamp(MirCookie const& cookie) override
119 {
120 return verify_mac(cookie);
121 }
122
123private:183private:
124 void calculate_mac(MirCookie& cookie)184 std::vector<uint8_t> calculate_cookie(uint64_t const& timestamp)
125 {185 {
126 hmac_sha1_update(&ctx, sizeof(cookie.timestamp), reinterpret_cast<uint8_t*>(&cookie.timestamp));186 // FIXME Soon to change to 160bits, for now uint64_t
127 hmac_sha1_digest(&ctx, sizeof(cookie.mac), reinterpret_cast<uint8_t*>(&cookie.mac));187 std::vector<uint8_t> mac(sizeof(uint64_t));
188 hmac_sha1_update(&ctx, sizeof(timestamp), reinterpret_cast<uint8_t const*>(&timestamp));
189 hmac_sha1_digest(&ctx, sizeof(uint64_t), reinterpret_cast<uint8_t*>(mac.data()));
190
191 return mac;
128 }192 }
129193
130 bool verify_mac(MirCookie const& cookie)194 bool verify_cookie(uint64_t const& timestamp, std::unique_ptr<mir::cookie::Cookie> const& cookie)
131 {195 {
132 decltype(cookie.mac) calculated_mac;196 auto const calculated_cookie = make_cookie(timestamp);
133 uint8_t* message = reinterpret_cast<uint8_t*>(const_cast<decltype(cookie.timestamp)*>(&cookie.timestamp));197
134 hmac_sha1_update(&ctx, sizeof(cookie.timestamp), message);198 auto const this_stream = cookie->serialize();
135 hmac_sha1_digest(&ctx, sizeof(calculated_mac), reinterpret_cast<uint8_t*>(&calculated_mac));199 auto const other_stream = calculated_cookie->serialize();
136200
137 return calculated_mac == cookie.mac;201 // FIXME Need to do a constant memcmp here!
202 return std::equal(std::begin(this_stream), std::end(this_stream), std::begin(other_stream));
138 }203 }
139204
140 struct hmac_sha1_ctx ctx;205 struct hmac_sha1_ctx ctx;
141};206};
142207
143size_t mir::cookie::CookieFactory::optimal_secret_size()208size_t mir::cookie::Authority::optimal_secret_size()
144{209{
145 // Secret keys smaller than this are internally zero-extended to this size.210 // Secret keys smaller than this are internally zero-extended to this size.
146 // Secret keys larger than this are internally hashed to this size.211 // Secret keys larger than this are internally hashed to this size.
@@ -148,19 +213,19 @@
148 return hmac_sha1_block_size;213 return hmac_sha1_block_size;
149}214}
150215
151std::unique_ptr<mir::cookie::CookieFactory> mir::cookie::CookieFactory::create_from_secret(mir::cookie::Secret const& secret)216std::unique_ptr<mir::cookie::Authority> mir::cookie::Authority::create_from(mir::cookie::Secret const& secret)
152{217{
153 return std::make_unique<CookieFactoryNettle>(secret);218 return std::make_unique<AuthorityNettle>(secret);
154}219}
155220
156std::unique_ptr<mir::cookie::CookieFactory> mir::cookie::CookieFactory::create_saving_secret(mir::cookie::Secret& save_secret)221std::unique_ptr<mir::cookie::Authority> mir::cookie::Authority::create_saving(mir::cookie::Secret& save_secret)
157{222{
158 save_secret = get_random_data(optimal_secret_size());223 save_secret = get_random_data(optimal_secret_size());
159 return std::make_unique<CookieFactoryNettle>(save_secret);224 return std::make_unique<AuthorityNettle>(save_secret);
160}225}
161226
162std::unique_ptr<mir::cookie::CookieFactory> mir::cookie::CookieFactory::create_keeping_secret()227std::unique_ptr<mir::cookie::Authority> mir::cookie::Authority::create()
163{228{
164 auto secret = get_random_data(optimal_secret_size());229 auto secret = get_random_data(optimal_secret_size());
165 return std::make_unique<CookieFactoryNettle>(secret);230 return std::make_unique<AuthorityNettle>(secret);
166}231}
167232
=== added file 'src/cookie/format.h'
--- src/cookie/format.h 1970-01-01 00:00:00 +0000
+++ src/cookie/format.h 2016-01-25 13:42:04 +0000
@@ -0,0 +1,35 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
17 */
18
19#ifndef MIR_COOKIE_COOKIE_FORMAT_H_
20#define MIR_COOKIE_COOKIE_FORMAT_H_
21
22#include <stdint.h>
23
24namespace mir
25{
26namespace cookie
27{
28enum class Format : uint8_t
29{
30 hmac_sha_1_8,
31};
32}
33}
34
35#endif // MIR_COOKIE_COOKIE_FORMAT_H_
036
=== added file 'src/cookie/hmac_cookie.cpp'
--- src/cookie/hmac_cookie.cpp 1970-01-01 00:00:00 +0000
+++ src/cookie/hmac_cookie.cpp 2016-01-25 13:42:04 +0000
@@ -0,0 +1,53 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
17 */
18
19#include "hmac_cookie.h"
20
21#include <string.h>
22
23mir::cookie::HMACCookie::HMACCookie(uint64_t const& timestamp,
24 std::vector<uint8_t> const& mac,
25 mir::cookie::Format const& format) :
26 timestamp_(timestamp),
27 mac_(mac),
28 format_(format)
29{
30}
31
32uint64_t mir::cookie::HMACCookie::timestamp() const
33{
34 return timestamp_;
35}
36
37std::vector<uint8_t> mir::cookie::HMACCookie::serialize() const
38{
39 std::vector<uint8_t> serialized_cookie(sizeof(format_) + sizeof(timestamp_) + mac_.size());
40
41 auto cookie_ptr = serialized_cookie.data();
42
43 cookie_ptr[0] = static_cast<uint8_t>(format_);
44 cookie_ptr += sizeof(format_);
45
46 auto timestamp_ptr = reinterpret_cast<uint8_t const*>(&timestamp_);
47 memcpy(cookie_ptr, timestamp_ptr, sizeof(timestamp_));
48 cookie_ptr += sizeof(timestamp_);
49
50 memcpy(cookie_ptr, mac_.data(), mac_.size());
51
52 return serialized_cookie;
53}
054
=== added file 'src/cookie/hmac_cookie.h'
--- src/cookie/hmac_cookie.h 1970-01-01 00:00:00 +0000
+++ src/cookie/hmac_cookie.h 2016-01-25 13:42:04 +0000
@@ -0,0 +1,51 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
17 */
18
19#ifndef MIR_COOKIE_HMAC_COOKIE_H_
20#define MIR_COOKIE_HMAC_COOKIE_H_
21
22#include "mir/cookie/cookie.h"
23#include "format.h"
24
25namespace mir
26{
27namespace cookie
28{
29
30class HMACCookie : public mir::cookie::Cookie
31{
32public:
33 HMACCookie() = delete;
34
35 explicit HMACCookie(uint64_t const& timestamp,
36 std::vector<uint8_t> const& mac,
37 mir::cookie::Format const& format);
38
39 uint64_t timestamp() const override;
40 std::vector<uint8_t> serialize() const override;
41
42private:
43 uint64_t timestamp_;
44 std::vector<uint8_t> mac_;
45 mir::cookie::Format format_;
46};
47
48}
49}
50
51#endif // MIR_COOKIE_HMAC_COOKIE_H_
052
=== modified file 'src/cookie/symbols.map'
--- src/cookie/symbols.map 2016-01-20 23:59:18 +0000
+++ src/cookie/symbols.map 2016-01-25 13:42:04 +0000
@@ -1,10 +1,10 @@
1MIR_COOKIE_1 {1MIR_COOKIE_2 {
2 global:2 global:
3 extern "C++" {3 extern "C++" {
4 mir::cookie::CookieFactory::optimal_secret_size*;4 mir::cookie::Authority::optimal_secret_size*;
5 mir::cookie::CookieFactory::create_from_secret*;5 mir::cookie::Authority::create_from*;
6 mir::cookie::CookieFactory::create_saving_secret*;6 mir::cookie::Authority::create_saving*;
7 mir::cookie::CookieFactory::create_keeping_secret*;7 mir::cookie::Authority::create*;
8 };8 };
9 local: *;9 local: *;
10};10};
1111
=== modified file 'src/include/common/mir/events/event_private.h'
--- src/include/common/mir/events/event_private.h 2016-01-23 03:16:06 +0000
+++ src/include/common/mir/events/event_private.h 2016-01-25 13:42:04 +0000
@@ -29,10 +29,10 @@
29#include <stdint.h>29#include <stdint.h>
30#include "mir_toolkit/event.h"30#include "mir_toolkit/event.h"
31#include "mir_toolkit/common.h"31#include "mir_toolkit/common.h"
32#include "mir/cookie/blob.h"
3233
33#include <xkbcommon/xkbcommon.h>34#include <xkbcommon/xkbcommon.h>
34#include <chrono>35#include <array>
35
36#include <chrono>36#include <chrono>
3737
38#ifdef __cplusplus38#ifdef __cplusplus
@@ -61,7 +61,7 @@
61 int32_t scan_code;61 int32_t scan_code;
6262
63 std::chrono::nanoseconds event_time;63 std::chrono::nanoseconds event_time;
64 uint64_t mac;64 mir::cookie::Blob cookie;
65};65};
6666
67typedef struct67typedef struct
@@ -99,7 +99,7 @@
9999
100 MirPointerButtons buttons;100 MirPointerButtons buttons;
101 std::chrono::nanoseconds event_time;101 std::chrono::nanoseconds event_time;
102 uint64_t mac;102 mir::cookie::Blob cookie;
103103
104 size_t pointer_count;104 size_t pointer_count;
105 MirMotionPointer pointer_coordinates[MIR_INPUT_EVENT_MAX_POINTER_COUNT];105 MirMotionPointer pointer_coordinates[MIR_INPUT_EVENT_MAX_POINTER_COUNT];
106106
=== modified file 'src/include/common/mir/protobuf/display_server.h'
--- src/include/common/mir/protobuf/display_server.h 2016-01-20 23:59:18 +0000
+++ src/include/common/mir/protobuf/display_server.h 2016-01-25 13:42:04 +0000
@@ -135,7 +135,7 @@
135 mir::protobuf::StreamConfiguration const* request,135 mir::protobuf::StreamConfiguration const* request,
136 mir::protobuf::Void* response,136 mir::protobuf::Void* response,
137 google::protobuf::Closure* done) = 0;137 google::protobuf::Closure* done) = 0;
138 virtual void raise_surface_with_cookie(138 virtual void raise_surface(
139 mir::protobuf::RaiseRequest const* request,139 mir::protobuf::RaiseRequest const* request,
140 mir::protobuf::Void* response,140 mir::protobuf::Void* response,
141 google::protobuf::Closure* done) = 0;141 google::protobuf::Closure* done) = 0;
142142
=== added directory 'src/include/cookie'
=== added directory 'src/include/cookie/mir'
=== added directory 'src/include/cookie/mir/cookie'
=== renamed file 'include/cookie/mir_toolkit/cookie.h' => 'src/include/cookie/mir/cookie/blob.h'
--- include/cookie/mir_toolkit/cookie.h 2015-09-17 08:57:46 +0000
+++ src/include/cookie/mir/cookie/blob.h 2016-01-25 13:42:04 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2015 Canonical Ltd.2 * Copyright © 2015-2016 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -13,32 +13,21 @@
13 * You should have received a copy of the GNU General Public License13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>16 * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
17 */17 */
1818
19#ifndef MIR_TOOLKIT_COOKIE_FACTORY_H_19#ifndef MIR_COOKIE_BLOB_H_
20#define MIR_TOOLKIT_COOKIE_FACTORY_H_20#define MIR_COOKIE_BLOB_H_
2121
22#include <stdint.h>22#include <array>
2323
24/**24namespace mir
25 * \addtogroup mir_toolkit25{
26 * @{26namespace cookie
27 */27{
28/* This is C code. Not C++. */28size_t const default_blob_size = 17;
29#ifdef __cplusplus29using Blob = std::array<uint8_t, default_blob_size>;
30extern "C" {30}
31#endif31}
3232
33typedef struct MirCookie33#endif // MIR_COOKIE_BLOB_H_
34{
35 uint64_t timestamp;
36 uint64_t mac;
37} MirCookie;
38
39#ifdef __cplusplus
40}
41#endif
42/**@}*/
43
44#endif // MIR_TOOLKIT_COOKIE_FACTORY_H_
4534
=== modified file 'src/include/server/mir/default_server_configuration.h'
--- src/include/server/mir/default_server_configuration.h 2016-01-20 23:59:18 +0000
+++ src/include/server/mir/default_server_configuration.h 2016-01-25 13:42:04 +0000
@@ -33,7 +33,7 @@
3333
34namespace cookie34namespace cookie
35{35{
36class CookieFactory;36class Authority;
37}37}
38namespace dispatch38namespace dispatch
39{39{
@@ -170,7 +170,7 @@
170 std::shared_ptr<graphics::Platform> the_graphics_platform() override;170 std::shared_ptr<graphics::Platform> the_graphics_platform() override;
171 std::shared_ptr<input::InputDispatcher> the_input_dispatcher() override;171 std::shared_ptr<input::InputDispatcher> the_input_dispatcher() override;
172 std::shared_ptr<EmergencyCleanup> the_emergency_cleanup() override;172 std::shared_ptr<EmergencyCleanup> the_emergency_cleanup() override;
173 std::shared_ptr<cookie::CookieFactory> the_cookie_factory() override;173 std::shared_ptr<cookie::Authority> the_cookie_authority() override;
174 /**174 /**
175 * Function to call when a "fatal" error occurs. This implementation allows175 * Function to call when a "fatal" error occurs. This implementation allows
176 * the default strategy to be overridden by --on-fatal-error-abort to force a176 * the default strategy to be overridden by --on-fatal-error-abort to force a
@@ -416,7 +416,7 @@
416 CachedPtr<shell::Shell> shell;416 CachedPtr<shell::Shell> shell;
417 CachedPtr<shell::ShellReport> shell_report;417 CachedPtr<shell::ShellReport> shell_report;
418 CachedPtr<scene::ApplicationNotRespondingDetector> application_not_responding_detector;418 CachedPtr<scene::ApplicationNotRespondingDetector> application_not_responding_detector;
419 CachedPtr<cookie::CookieFactory> cookie_factory;419 CachedPtr<cookie::Authority> cookie_authority;
420420
421private:421private:
422 std::shared_ptr<options::Configuration> const configuration_options;422 std::shared_ptr<options::Configuration> const configuration_options;
423423
=== removed file 'src/include/server/mir/frontend/security_check_failed.h'
--- src/include/server/mir/frontend/security_check_failed.h 2015-10-30 17:24:29 +0000
+++ src/include/server/mir/frontend/security_check_failed.h 1970-01-01 00:00:00 +0000
@@ -1,34 +0,0 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
17 */
18
19#ifndef MIR_SECURITY_CHECK_FAILED_H_
20#define MIR_SECURITY_CHECK_FAILED_H_
21
22#include <stdexcept>
23
24namespace mir
25{
26
27struct SecurityCheckFailed : std::runtime_error
28{
29 SecurityCheckFailed();
30};
31
32}
33
34#endif /* MIR_SECURITY_CHECK_FAILED_H_ */
350
=== modified file 'src/include/server/mir/frontend/shell.h'
--- src/include/server/mir/frontend/shell.h 2016-01-20 23:59:18 +0000
+++ src/include/server/mir/frontend/shell.h 2016-01-25 13:42:04 +0000
@@ -82,7 +82,7 @@
82 SurfaceId surface_id,82 SurfaceId surface_id,
83 MirSurfaceAttrib attrib) = 0;83 MirSurfaceAttrib attrib) = 0;
8484
85 virtual void raise_surface_with_timestamp(85 virtual void raise_surface(
86 std::shared_ptr<Session> const& session,86 std::shared_ptr<Session> const& session,
87 SurfaceId surface_id,87 SurfaceId surface_id,
88 uint64_t timestamp) = 0;88 uint64_t timestamp) = 0;
8989
=== modified file 'src/include/server/mir/frontend/template_protobuf_message_processor.h'
--- src/include/server/mir/frontend/template_protobuf_message_processor.h 2016-01-20 23:59:18 +0000
+++ src/include/server/mir/frontend/template_protobuf_message_processor.h 2016-01-25 13:42:04 +0000
@@ -21,7 +21,7 @@
21#define MIR_FRONTEND_TEMPLATE_PROTOBUF_MESSAGE_PROCESSOR_H_21#define MIR_FRONTEND_TEMPLATE_PROTOBUF_MESSAGE_PROCESSOR_H_
2222
23#include "mir/frontend/message_processor.h"23#include "mir/frontend/message_processor.h"
24#include "mir/frontend/security_check_failed.h"24#include "mir/cookie/authority.h"
2525
26#include <google/protobuf/stubs/common.h>26#include <google/protobuf/stubs/common.h>
27#include <boost/exception/diagnostic_information.hpp>27#include <boost/exception/diagnostic_information.hpp>
@@ -76,7 +76,7 @@
76 &result_message,76 &result_message,
77 callback.get());77 callback.get());
78 }78 }
79 catch (mir::SecurityCheckFailed const& /*err*/)79 catch (mir::cookie::SecurityCheckError const& /*err*/)
80 {80 {
81 throw;81 throw;
82 }82 }
8383
=== modified file 'src/include/server/mir/server_configuration.h'
--- src/include/server/mir/server_configuration.h 2016-01-20 23:59:18 +0000
+++ src/include/server/mir/server_configuration.h 2016-01-25 13:42:04 +0000
@@ -24,7 +24,7 @@
24{24{
25namespace cookie25namespace cookie
26{26{
27class CookieFactory;27class Authority;
28}28}
29namespace compositor29namespace compositor
30{30{
@@ -79,7 +79,7 @@
79 virtual std::shared_ptr<DisplayChanger> the_display_changer() = 0;79 virtual std::shared_ptr<DisplayChanger> the_display_changer() = 0;
80 virtual std::shared_ptr<graphics::Platform> the_graphics_platform() = 0;80 virtual std::shared_ptr<graphics::Platform> the_graphics_platform() = 0;
81 virtual std::shared_ptr<EmergencyCleanup> the_emergency_cleanup() = 0;81 virtual std::shared_ptr<EmergencyCleanup> the_emergency_cleanup() = 0;
82 virtual std::shared_ptr<cookie::CookieFactory> the_cookie_factory() = 0;82 virtual std::shared_ptr<cookie::Authority> the_cookie_authority() = 0;
83 virtual auto the_fatal_error_strategy() -> void (*)(char const* reason, ...) = 0;83 virtual auto the_fatal_error_strategy() -> void (*)(char const* reason, ...) = 0;
84 virtual std::shared_ptr<scene::ApplicationNotRespondingDetector> the_application_not_responding_detector() = 0;84 virtual std::shared_ptr<scene::ApplicationNotRespondingDetector> the_application_not_responding_detector() = 0;
8585
8686
=== modified file 'src/protobuf/mir_protobuf.proto'
--- src/protobuf/mir_protobuf.proto 2016-01-20 23:59:18 +0000
+++ src/protobuf/mir_protobuf.proto 2016-01-25 13:42:04 +0000
@@ -343,8 +343,7 @@
343}343}
344344
345message Cookie {345message Cookie {
346 required uint64 timestamp = 1;346 required bytes cookie = 1;
347 required uint64 mac = 2;
348}347}
349348
350message RaiseRequest {349message RaiseRequest {
351350
=== modified file 'src/server/CMakeLists.txt'
--- src/server/CMakeLists.txt 2016-01-22 03:09:31 +0000
+++ src/server/CMakeLists.txt 2016-01-25 13:42:04 +0000
@@ -14,6 +14,7 @@
14 ${PROJECT_SOURCE_DIR}/src/include/client14 ${PROJECT_SOURCE_DIR}/src/include/client
15 ${PROJECT_SOURCE_DIR}/src/include/server15 ${PROJECT_SOURCE_DIR}/src/include/server
16 ${PROJECT_SOURCE_DIR}/include/cookie16 ${PROJECT_SOURCE_DIR}/include/cookie
17 ${PROJECT_SOURCE_DIR}/src/include/cookie
17 ${GLIB_INCLUDE_DIRS}18 ${GLIB_INCLUDE_DIRS}
18)19)
19add_definitions(-DMIR_SERVER_INPUT_PLATFORM_VERSION="${MIR_SERVER_INPUT_PLATFORM_VERSION}")20add_definitions(-DMIR_SERVER_INPUT_PLATFORM_VERSION="${MIR_SERVER_INPUT_PLATFORM_VERSION}")
2021
=== modified file 'src/server/default_server_configuration.cpp'
--- src/server/default_server_configuration.cpp 2016-01-20 23:59:18 +0000
+++ src/server/default_server_configuration.cpp 2016-01-25 13:42:04 +0000
@@ -24,7 +24,7 @@
24#include "mir/default_server_status_listener.h"24#include "mir/default_server_status_listener.h"
25#include "mir/emergency_cleanup.h"25#include "mir/emergency_cleanup.h"
26#include "mir/default_configuration.h"26#include "mir/default_configuration.h"
27#include "mir/cookie_factory.h"27#include "mir/cookie/authority.h"
2828
29#include "mir/logging/dumb_console_logger.h"29#include "mir/logging/dumb_console_logger.h"
30#include "mir/options/program_option.h"30#include "mir/options/program_option.h"
@@ -186,15 +186,15 @@
186 });186 });
187}187}
188188
189std::shared_ptr<mir::cookie::CookieFactory> mir::DefaultServerConfiguration::the_cookie_factory()189std::shared_ptr<mir::cookie::Authority> mir::DefaultServerConfiguration::the_cookie_authority()
190{190{
191 return cookie_factory(191 return cookie_authority(
192 []()192 []()
193 {193 {
194 static_assert(secret_size >= mir::cookie::CookieFactory::minimum_secret_size,194 static_assert(secret_size >= mir::cookie::Authority::minimum_secret_size,
195 "Secret size is smaller then the minimum secret size");195 "Secret size is smaller then the minimum secret size");
196196
197 return mir::cookie::CookieFactory::create_keeping_secret();197 return mir::cookie::Authority::create();
198 });198 });
199}199}
200200
201201
=== modified file 'src/server/frontend/CMakeLists.txt'
--- src/server/frontend/CMakeLists.txt 2016-01-20 23:59:18 +0000
+++ src/server/frontend/CMakeLists.txt 2016-01-25 13:42:04 +0000
@@ -28,7 +28,6 @@
28 reordering_message_sender.cpp28 reordering_message_sender.cpp
29 reordering_message_sender.h29 reordering_message_sender.h
30 event_sink_factory.h30 event_sink_factory.h
31 security_check_failed.cpp
32)31)
3332
34add_library(33add_library(
3534
=== modified file 'src/server/frontend/default_configuration.cpp'
--- src/server/frontend/default_configuration.cpp 2016-01-20 23:59:18 +0000
+++ src/server/frontend/default_configuration.cpp 2016-01-25 13:42:04 +0000
@@ -163,5 +163,5 @@
163 the_cursor_images(),163 the_cursor_images(),
164 the_coordinate_translator(),164 the_coordinate_translator(),
165 the_application_not_responding_detector(),165 the_application_not_responding_detector(),
166 the_cookie_factory());166 the_cookie_authority());
167}167}
168168
=== modified file 'src/server/frontend/default_ipc_factory.cpp'
--- src/server/frontend/default_ipc_factory.cpp 2016-01-20 23:59:18 +0000
+++ src/server/frontend/default_ipc_factory.cpp 2016-01-25 13:42:04 +0000
@@ -26,7 +26,7 @@
26#include "mir/frontend/session_authorizer.h"26#include "mir/frontend/session_authorizer.h"
27#include "mir/frontend/event_sink.h"27#include "mir/frontend/event_sink.h"
28#include "mir/graphics/graphic_buffer_allocator.h"28#include "mir/graphics/graphic_buffer_allocator.h"
29#include "mir/cookie_factory.h"29#include "mir/cookie/authority.h"
3030
31namespace mf = mir::frontend;31namespace mf = mir::frontend;
32namespace mg = mir::graphics;32namespace mg = mir::graphics;
@@ -44,7 +44,7 @@
44 std::shared_ptr<mi::CursorImages> const& cursor_images,44 std::shared_ptr<mi::CursorImages> const& cursor_images,
45 std::shared_ptr<scene::CoordinateTranslator> const& translator,45 std::shared_ptr<scene::CoordinateTranslator> const& translator,
46 std::shared_ptr<scene::ApplicationNotRespondingDetector> const& anr_detector,46 std::shared_ptr<scene::ApplicationNotRespondingDetector> const& anr_detector,
47 std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory) :47 std::shared_ptr<mir::cookie::Authority> const& cookie_authority) :
48 shell(shell),48 shell(shell),
49 no_prompt_shell(std::make_shared<NoPromptShell>(shell)),49 no_prompt_shell(std::make_shared<NoPromptShell>(shell)),
50 sm_report(sm_report),50 sm_report(sm_report),
@@ -57,7 +57,7 @@
57 cursor_images(cursor_images),57 cursor_images(cursor_images),
58 translator{translator},58 translator{translator},
59 anr_detector{anr_detector},59 anr_detector{anr_detector},
60 cookie_factory(cookie_factory)60 cookie_authority(cookie_authority)
61{61{
62}62}
6363
@@ -132,5 +132,5 @@
132 cursor_images,132 cursor_images,
133 translator,133 translator,
134 anr_detector,134 anr_detector,
135 cookie_factory);135 cookie_authority);
136}136}
137137
=== modified file 'src/server/frontend/default_ipc_factory.h'
--- src/server/frontend/default_ipc_factory.h 2016-01-20 23:59:18 +0000
+++ src/server/frontend/default_ipc_factory.h 2016-01-25 13:42:04 +0000
@@ -25,7 +25,7 @@
25{25{
26namespace cookie26namespace cookie
27{27{
28class CookieFactory;28class Authority;
29}29}
30namespace graphics30namespace graphics
31{31{
@@ -66,7 +66,7 @@
66 std::shared_ptr<input::CursorImages> const& cursor_images,66 std::shared_ptr<input::CursorImages> const& cursor_images,
67 std::shared_ptr<scene::CoordinateTranslator> const& translator,67 std::shared_ptr<scene::CoordinateTranslator> const& translator,
68 std::shared_ptr<scene::ApplicationNotRespondingDetector> const& anr_detector,68 std::shared_ptr<scene::ApplicationNotRespondingDetector> const& anr_detector,
69 std::shared_ptr<cookie::CookieFactory> const& cookie_factory);69 std::shared_ptr<cookie::Authority> const& cookie_authority);
7070
71 std::shared_ptr<detail::DisplayServer> make_ipc_server(71 std::shared_ptr<detail::DisplayServer> make_ipc_server(
72 SessionCredentials const &creds,72 SessionCredentials const &creds,
@@ -101,7 +101,7 @@
101 std::shared_ptr<input::CursorImages> const cursor_images;101 std::shared_ptr<input::CursorImages> const cursor_images;
102 std::shared_ptr<scene::CoordinateTranslator> const translator;102 std::shared_ptr<scene::CoordinateTranslator> const translator;
103 std::shared_ptr<scene::ApplicationNotRespondingDetector> const anr_detector;103 std::shared_ptr<scene::ApplicationNotRespondingDetector> const anr_detector;
104 std::shared_ptr<cookie::CookieFactory> const cookie_factory;104 std::shared_ptr<cookie::Authority> const cookie_authority;
105};105};
106}106}
107}107}
108108
=== modified file 'src/server/frontend/protobuf_message_processor.cpp'
--- src/server/frontend/protobuf_message_processor.cpp 2016-01-20 23:59:18 +0000
+++ src/server/frontend/protobuf_message_processor.cpp 2016-01-25 13:42:04 +0000
@@ -18,7 +18,7 @@
1818
19#include "display_server.h"19#include "display_server.h"
20#include "protobuf_message_processor.h"20#include "protobuf_message_processor.h"
21#include "mir/frontend/security_check_failed.h"21#include "mir/cookie/authority.h"
22#include "mir/frontend/message_processor_report.h"22#include "mir/frontend/message_processor_report.h"
23#include "mir/frontend/protobuf_message_sender.h"23#include "mir/frontend/protobuf_message_sender.h"
24#include "mir/frontend/template_protobuf_message_processor.h"24#include "mir/frontend/template_protobuf_message_processor.h"
@@ -136,7 +136,7 @@
136 result_message.get(),136 result_message.get(),
137 callback);137 callback);
138 }138 }
139 catch (mir::SecurityCheckFailed const& /*err*/)139 catch (mir::cookie::SecurityCheckError const& /*err*/)
140 {140 {
141 throw;141 throw;
142 }142 }
@@ -315,9 +315,9 @@
315 {315 {
316 invoke(this, display_server.get(), &DisplayServer::configure_buffer_stream, invocation);316 invoke(this, display_server.get(), &DisplayServer::configure_buffer_stream, invocation);
317 }317 }
318 else if ("raise_surface_with_cookie" == invocation.method_name())318 else if ("raise_surface" == invocation.method_name())
319 {319 {
320 invoke(this, display_server.get(), &DisplayServer::raise_surface_with_cookie, invocation);320 invoke(this, display_server.get(), &DisplayServer::raise_surface, invocation);
321 }321 }
322 else if ("translate_surface_to_screen" == invocation.method_name())322 else if ("translate_surface_to_screen" == invocation.method_name())
323 {323 {
324324
=== removed file 'src/server/frontend/security_check_failed.cpp'
--- src/server/frontend/security_check_failed.cpp 2015-10-30 17:24:29 +0000
+++ src/server/frontend/security_check_failed.cpp 1970-01-01 00:00:00 +0000
@@ -1,24 +0,0 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
17 */
18
19#include "mir/frontend/security_check_failed.h"
20
21mir::SecurityCheckFailed::SecurityCheckFailed() :
22 runtime_error("Invalid MirCookie")
23{
24}
250
=== modified file 'src/server/frontend/session_mediator.cpp'
--- src/server/frontend/session_mediator.cpp 2016-01-20 23:59:18 +0000
+++ src/server/frontend/session_mediator.cpp 2016-01-25 13:42:04 +0000
@@ -46,10 +46,9 @@
46#include "mir/frontend/screencast.h"46#include "mir/frontend/screencast.h"
47#include "mir/frontend/prompt_session.h"47#include "mir/frontend/prompt_session.h"
48#include "mir/frontend/buffer_stream.h"48#include "mir/frontend/buffer_stream.h"
49#include "mir/frontend/security_check_failed.h"
50#include "mir/scene/prompt_session_creation_parameters.h"49#include "mir/scene/prompt_session_creation_parameters.h"
51#include "mir/fd.h"50#include "mir/fd.h"
52#include "mir/cookie_factory.h"51#include "mir/cookie/authority.h"
53#include "mir/module_properties.h"52#include "mir/module_properties.h"
5453
55#include "mir/geometry/rectangles.h"54#include "mir/geometry/rectangles.h"
@@ -90,7 +89,7 @@
90 std::shared_ptr<mi::CursorImages> const& cursor_images,89 std::shared_ptr<mi::CursorImages> const& cursor_images,
91 std::shared_ptr<scene::CoordinateTranslator> const& translator,90 std::shared_ptr<scene::CoordinateTranslator> const& translator,
92 std::shared_ptr<scene::ApplicationNotRespondingDetector> const& anr_detector,91 std::shared_ptr<scene::ApplicationNotRespondingDetector> const& anr_detector,
93 std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory) :92 std::shared_ptr<mir::cookie::Authority> const& cookie_authority) :
94 client_pid_(0),93 client_pid_(0),
95 shell(shell),94 shell(shell),
96 ipc_operations(ipc_operations),95 ipc_operations(ipc_operations),
@@ -106,7 +105,7 @@
106 cursor_images(cursor_images),105 cursor_images(cursor_images),
107 translator{translator},106 translator{translator},
108 anr_detector{anr_detector},107 anr_detector{anr_detector},
109 cookie_factory(cookie_factory),108 cookie_authority(cookie_authority),
110 buffer_stream_tracker{static_cast<size_t>(client_buffer_cache_size)}109 buffer_stream_tracker{static_cast<size_t>(client_buffer_cache_size)}
111{110{
112}111}
@@ -1022,7 +1021,7 @@
1022 done->Run();1021 done->Run();
1023}1022}
10241023
1025void mf::SessionMediator::raise_surface_with_cookie(1024void mf::SessionMediator::raise_surface(
1026 mir::protobuf::RaiseRequest const* request,1025 mir::protobuf::RaiseRequest const* request,
1027 mir::protobuf::Void*,1026 mir::protobuf::Void*,
1028 google::protobuf::Closure* done)1027 google::protobuf::Closure* done)
@@ -1034,11 +1033,12 @@
1034 auto const cookie = request->cookie();1033 auto const cookie = request->cookie();
1035 auto const surface_id = request->surface_id();1034 auto const surface_id = request->surface_id();
10361035
1037 MirCookie const mir_cookie = {cookie.timestamp(), cookie.mac()};1036 auto cookie_string = cookie.cookie();
1038 if (!cookie_factory->attest_timestamp(mir_cookie))1037
1039 throw mir::SecurityCheckFailed();1038 std::vector<uint8_t> cookie_bytes(cookie_string.begin(), cookie_string.end());
10401039 auto const cookie_ptr = cookie_authority->make_cookie(cookie_bytes);
1041 shell->raise_surface_with_timestamp(session, mf::SurfaceId{surface_id.value()}, cookie.timestamp());1040
1041 shell->raise_surface(session, mf::SurfaceId{surface_id.value()}, cookie_ptr->timestamp());
10421042
1043 done->Run();1043 done->Run();
1044}1044}
10451045
=== modified file 'src/server/frontend/session_mediator.h'
--- src/server/frontend/session_mediator.h 2016-01-20 23:59:18 +0000
+++ src/server/frontend/session_mediator.h 2016-01-25 13:42:04 +0000
@@ -40,7 +40,7 @@
40{40{
41namespace cookie41namespace cookie
42{42{
43class CookieFactory;43class Authority;
44}44}
45namespace graphics45namespace graphics
46{46{
@@ -105,7 +105,7 @@
105 std::shared_ptr<input::CursorImages> const& cursor_images,105 std::shared_ptr<input::CursorImages> const& cursor_images,
106 std::shared_ptr<scene::CoordinateTranslator> const& translator,106 std::shared_ptr<scene::CoordinateTranslator> const& translator,
107 std::shared_ptr<scene::ApplicationNotRespondingDetector> const& anr_detector,107 std::shared_ptr<scene::ApplicationNotRespondingDetector> const& anr_detector,
108 std::shared_ptr<cookie::CookieFactory> const& cookie_factory);108 std::shared_ptr<cookie::Authority> const& cookie_authority);
109109
110 ~SessionMediator() noexcept;110 ~SessionMediator() noexcept;
111111
@@ -215,7 +215,7 @@
215 mir::protobuf::StreamConfiguration const* request,215 mir::protobuf::StreamConfiguration const* request,
216 mir::protobuf::Void*,216 mir::protobuf::Void*,
217 google::protobuf::Closure* done) override;217 google::protobuf::Closure* done) override;
218 void raise_surface_with_cookie(218 void raise_surface(
219 mir::protobuf::RaiseRequest const* request,219 mir::protobuf::RaiseRequest const* request,
220 mir::protobuf::Void*,220 mir::protobuf::Void*,
221 google::protobuf::Closure* done) override;221 google::protobuf::Closure* done) override;
@@ -259,7 +259,7 @@
259 std::shared_ptr<input::CursorImages> const cursor_images;259 std::shared_ptr<input::CursorImages> const cursor_images;
260 std::shared_ptr<scene::CoordinateTranslator> const translator;260 std::shared_ptr<scene::CoordinateTranslator> const translator;
261 std::shared_ptr<scene::ApplicationNotRespondingDetector> const anr_detector;261 std::shared_ptr<scene::ApplicationNotRespondingDetector> const anr_detector;
262 std::shared_ptr<cookie::CookieFactory> const cookie_factory;262 std::shared_ptr<cookie::Authority> const cookie_authority;
263263
264 BufferStreamTracker buffer_stream_tracker;264 BufferStreamTracker buffer_stream_tracker;
265265
266266
=== modified file 'src/server/frontend/shell_wrapper.cpp'
--- src/server/frontend/shell_wrapper.cpp 2016-01-20 23:59:18 +0000
+++ src/server/frontend/shell_wrapper.cpp 2016-01-25 13:42:04 +0000
@@ -99,10 +99,10 @@
99 return wrapped->get_surface_attribute(session, surface_id, attrib);99 return wrapped->get_surface_attribute(session, surface_id, attrib);
100}100}
101101
102void mf::ShellWrapper::raise_surface_with_timestamp(102void mf::ShellWrapper::raise_surface(
103 std::shared_ptr<Session> const& session,103 std::shared_ptr<Session> const& session,
104 SurfaceId surface_id,104 SurfaceId surface_id,
105 uint64_t timestamp)105 uint64_t timestamp)
106{106{
107 wrapped->raise_surface_with_timestamp(session, surface_id, timestamp);107 wrapped->raise_surface(session, surface_id, timestamp);
108}108}
109109
=== modified file 'src/server/frontend/shell_wrapper.h'
--- src/server/frontend/shell_wrapper.h 2016-01-20 23:59:18 +0000
+++ src/server/frontend/shell_wrapper.h 2016-01-25 13:42:04 +0000
@@ -75,7 +75,7 @@
75 SurfaceId surface_id,75 SurfaceId surface_id,
76 MirSurfaceAttrib attrib) override;76 MirSurfaceAttrib attrib) override;
7777
78 void raise_surface_with_timestamp(78 void raise_surface(
79 std::shared_ptr<Session> const& session,79 std::shared_ptr<Session> const& session,
80 SurfaceId surface_id,80 SurfaceId surface_id,
81 uint64_t timestamp) override;81 uint64_t timestamp) override;
8282
=== modified file 'src/server/input/android/input_sender.cpp'
--- src/server/input/android/input_sender.cpp 2016-01-20 23:59:18 +0000
+++ src/server/input/android/input_sender.cpp 2016-01-25 13:42:04 +0000
@@ -247,7 +247,7 @@
247 mir_keyboard_event_scan_code(key_event),247 mir_keyboard_event_scan_code(key_event),
248 mia::android_modifiers_from_mir(mir_keyboard_event_modifiers(key_event)),248 mia::android_modifiers_from_mir(mir_keyboard_event_modifiers(key_event)),
249 repeat_count,249 repeat_count,
250 event.key.mac,250 event.key.cookie,
251 event_time,251 event_time,
252 event_time);252 event_time);
253}253}
@@ -324,7 +324,7 @@
324 ret = publisher.publishMotionEvent(seq, mir_input_event_get_device_id(input_event), AINPUT_SOURCE_TOUCHSCREEN,324 ret = publisher.publishMotionEvent(seq, mir_input_event_get_device_id(input_event), AINPUT_SOURCE_TOUCHSCREEN,
325 state_change.android_action, flags, edge_flags,325 state_change.android_action, flags, edge_flags,
326 mia::android_modifiers_from_mir(mir_touch_event_modifiers(touch)),326 mia::android_modifiers_from_mir(mir_touch_event_modifiers(touch)),
327 button_state, x_offset, y_offset, x_precision, y_precision, event.motion.mac,327 button_state, x_offset, y_offset, x_precision, y_precision, event.motion.cookie,
328 event_time, event_time, contacts_in_event, properties, coords);328 event_time, event_time, contacts_in_event, properties, coords);
329 }329 }
330330
@@ -361,7 +361,7 @@
361 mia::android_pointer_action_from_mir(mir_pointer_event_action(pointer), mir_pointer_event_buttons(pointer)),361 mia::android_pointer_action_from_mir(mir_pointer_event_action(pointer), mir_pointer_event_buttons(pointer)),
362 flags, edge_flags, mia::android_modifiers_from_mir(mir_pointer_event_modifiers(pointer)),362 flags, edge_flags, mia::android_modifiers_from_mir(mir_pointer_event_modifiers(pointer)),
363 mia::android_pointer_buttons_from_mir(mir_pointer_event_buttons(pointer)), x_offset, y_offset, x_precision,363 mia::android_pointer_buttons_from_mir(mir_pointer_event_buttons(pointer)), x_offset, y_offset, x_precision,
364 y_precision, event.motion.mac, event_time, event_time, 1, &pointer_properties, &pointer_coord);364 y_precision, event.motion.cookie, event_time, event_time, 1, &pointer_properties, &pointer_coord);
365}365}
366366
367367
368368
=== modified file 'src/server/input/default_configuration.cpp'
--- src/server/input/default_configuration.cpp 2016-01-20 23:59:18 +0000
+++ src/server/input/default_configuration.cpp 2016-01-25 13:42:04 +0000
@@ -147,7 +147,7 @@
147 auto enable_repeat = options->get<bool>(options::enable_key_repeat_opt);147 auto enable_repeat = options->get<bool>(options::enable_key_repeat_opt);
148148
149 return std::make_shared<mi::KeyRepeatDispatcher>(149 return std::make_shared<mi::KeyRepeatDispatcher>(
150 the_event_filter_chain_dispatcher(), the_main_loop(), the_cookie_factory(),150 the_event_filter_chain_dispatcher(), the_main_loop(), the_cookie_authority(),
151 enable_repeat, key_repeat_timeout, key_repeat_delay);151 enable_repeat, key_repeat_timeout, key_repeat_delay);
152 });152 });
153}153}
@@ -278,7 +278,7 @@
278 the_touch_visualizer(),278 the_touch_visualizer(),
279 the_cursor_listener(),279 the_cursor_listener(),
280 the_input_region(),280 the_input_region(),
281 the_cookie_factory());281 the_cookie_authority());
282 });282 });
283}283}
284284
@@ -293,6 +293,6 @@
293 the_touch_visualizer(),293 the_touch_visualizer(),
294 the_cursor_listener(),294 the_cursor_listener(),
295 the_input_region(),295 the_input_region(),
296 the_cookie_factory());296 the_cookie_authority());
297 });297 });
298}298}
299299
=== modified file 'src/server/input/default_event_builder.cpp'
--- src/server/input/default_event_builder.cpp 2016-01-20 23:59:18 +0000
+++ src/server/input/default_event_builder.cpp 2016-01-25 13:42:04 +0000
@@ -19,29 +19,31 @@
1919
20#include "default_event_builder.h"20#include "default_event_builder.h"
21#include "mir/events/event_builders.h"21#include "mir/events/event_builders.h"
22#include "mir/cookie_factory.h"22#include "mir/cookie/authority.h"
23#include "mir/events/event_private.h"23#include "mir/events/event_private.h"
2424
25#include <algorithm>
26
25namespace me = mir::events;27namespace me = mir::events;
26namespace mi = mir::input;28namespace mi = mir::input;
2729
28mi::DefaultEventBuilder::DefaultEventBuilder(MirInputDeviceId device_id,30mi::DefaultEventBuilder::DefaultEventBuilder(MirInputDeviceId device_id,
29 std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory)31 std::shared_ptr<mir::cookie::Authority> const& cookie_authority)
30 : device_id(device_id),32 : device_id(device_id),
31 cookie_factory(cookie_factory)33 cookie_authority(cookie_authority)
32{34{
33}35}
3436
35mir::EventUPtr mi::DefaultEventBuilder::key_event(Timestamp timestamp, MirKeyboardAction action, xkb_keysym_t key_code,37mir::EventUPtr mi::DefaultEventBuilder::key_event(Timestamp timestamp, MirKeyboardAction action, xkb_keysym_t key_code,
36 int scan_code)38 int scan_code)
37{39{
38 uint64_t mac = cookie_factory->timestamp_to_cookie(timestamp.count()).mac;40 auto const cookie = cookie_authority->make_cookie(timestamp.count());
39 return me::make_event(device_id, timestamp, mac, action, key_code, scan_code, mir_input_event_modifier_none);41 return me::make_event(device_id, timestamp, cookie->serialize(), action, key_code, scan_code, mir_input_event_modifier_none);
40}42}
4143
42mir::EventUPtr mi::DefaultEventBuilder::touch_event(Timestamp timestamp)44mir::EventUPtr mi::DefaultEventBuilder::touch_event(Timestamp timestamp)
43{45{
44 return me::make_event(device_id, timestamp, 0, mir_input_event_modifier_none);46 return me::make_event(device_id, timestamp, std::vector<uint8_t>{}, mir_input_event_modifier_none);
45}47}
4648
47void mi::DefaultEventBuilder::add_touch(MirEvent& event, MirTouchId touch_id, MirTouchAction action,49void mi::DefaultEventBuilder::add_touch(MirEvent& event, MirTouchId touch_id, MirTouchAction action,
@@ -51,8 +53,9 @@
51{53{
52 if (action == mir_touch_action_up || action == mir_touch_action_down)54 if (action == mir_touch_action_up || action == mir_touch_action_down)
53 {55 {
54 auto cookie = cookie_factory->timestamp_to_cookie(event.motion.event_time.count());56 auto const cookie = cookie_authority->make_cookie(event.motion.event_time.count());
55 event.motion.mac = cookie.mac;57 auto const serialized_cookie = cookie->serialize();
58 std::copy_n(std::begin(serialized_cookie), event.motion.cookie.size(), std::begin(event.motion.cookie));
56 }59 }
5760
58 me::add_touch(event, touch_id, action, tooltype, x_axis_value, y_axis_value, pressure_value, touch_major_value,61 me::add_touch(event, touch_id, action, tooltype, x_axis_value, y_axis_value, pressure_value, touch_major_value,
@@ -65,10 +68,14 @@
65{68{
66 const float x_axis_value = 0;69 const float x_axis_value = 0;
67 const float y_axis_value = 0;70 const float y_axis_value = 0;
68 uint64_t mac = 0;71 std::vector<uint8_t> vec_cookie{};
72 // FIXME Moving to 160bits soon
69 if (action == mir_pointer_action_button_up || action == mir_pointer_action_button_down)73 if (action == mir_pointer_action_button_up || action == mir_pointer_action_button_down)
70 mac = cookie_factory->timestamp_to_cookie(timestamp.count()).mac;74 {
71 return me::make_event(device_id, timestamp, mac, mir_input_event_modifier_none, action, buttons_pressed, x_axis_value, y_axis_value,75 auto const cookie = cookie_authority->make_cookie(timestamp.count());
76 vec_cookie = cookie->serialize();
77 }
78 return me::make_event(device_id, timestamp, vec_cookie, mir_input_event_modifier_none, action, buttons_pressed, x_axis_value, y_axis_value,
72 hscroll_value, vscroll_value, relative_x_value, relative_y_value);79 hscroll_value, vscroll_value, relative_x_value, relative_y_value);
73}80}
7481
7582
=== modified file 'src/server/input/default_event_builder.h'
--- src/server/input/default_event_builder.h 2016-01-20 23:59:18 +0000
+++ src/server/input/default_event_builder.h 2016-01-25 13:42:04 +0000
@@ -27,7 +27,7 @@
27{27{
28namespace cookie28namespace cookie
29{29{
30class CookieFactory;30class Authority;
31}31}
32namespace input32namespace input
33{33{
@@ -35,7 +35,7 @@
35{35{
36public:36public:
37 explicit DefaultEventBuilder(MirInputDeviceId device_id,37 explicit DefaultEventBuilder(MirInputDeviceId device_id,
38 std::shared_ptr<cookie::CookieFactory> const& cookie_factory);38 std::shared_ptr<cookie::Authority> const& cookie_authority);
3939
40 EventUPtr key_event(Timestamp timestamp, MirKeyboardAction action, xkb_keysym_t key_code, int scan_code) override;40 EventUPtr key_event(Timestamp timestamp, MirKeyboardAction action, xkb_keysym_t key_code, int scan_code) override;
4141
@@ -52,7 +52,7 @@
5252
53private:53private:
54 MirInputDeviceId const device_id;54 MirInputDeviceId const device_id;
55 std::shared_ptr<cookie::CookieFactory> const cookie_factory;55 std::shared_ptr<cookie::Authority> const cookie_authority;
56};56};
57}57}
58}58}
5959
=== modified file 'src/server/input/default_input_device_hub.cpp'
--- src/server/input/default_input_device_hub.cpp 2016-01-20 23:59:18 +0000
+++ src/server/input/default_input_device_hub.cpp 2016-01-25 13:42:04 +0000
@@ -29,7 +29,7 @@
29#include "mir/dispatch/multiplexing_dispatchable.h"29#include "mir/dispatch/multiplexing_dispatchable.h"
30#include "mir/dispatch/action_queue.h"30#include "mir/dispatch/action_queue.h"
31#include "mir/server_action_queue.h"31#include "mir/server_action_queue.h"
32#include "mir/cookie_factory.h"32#include "mir/cookie/authority.h"
33#define MIR_LOG_COMPONENT "Input"33#define MIR_LOG_COMPONENT "Input"
34#include "mir/log.h"34#include "mir/log.h"
3535
@@ -49,13 +49,13 @@
49 std::shared_ptr<TouchVisualizer> const& touch_visualizer,49 std::shared_ptr<TouchVisualizer> const& touch_visualizer,
50 std::shared_ptr<CursorListener> const& cursor_listener,50 std::shared_ptr<CursorListener> const& cursor_listener,
51 std::shared_ptr<InputRegion> const& input_region,51 std::shared_ptr<InputRegion> const& input_region,
52 std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory)52 std::shared_ptr<mir::cookie::Authority> const& cookie_authority)
53 : input_dispatcher(input_dispatcher),53 : input_dispatcher(input_dispatcher),
54 input_dispatchable{input_multiplexer},54 input_dispatchable{input_multiplexer},
55 observer_queue(observer_queue),55 observer_queue(observer_queue),
56 device_queue(std::make_shared<dispatch::ActionQueue>()),56 device_queue(std::make_shared<dispatch::ActionQueue>()),
57 input_region(input_region),57 input_region(input_region),
58 cookie_factory(cookie_factory),58 cookie_authority(cookie_authority),
59 seat(touch_visualizer, cursor_listener, input_region),59 seat(touch_visualizer, cursor_listener, input_region),
60 device_id_generator{0}60 device_id_generator{0}
61{61{
@@ -78,7 +78,7 @@
78 {78 {
79 // send input device info to observer loop..79 // send input device info to observer loop..
80 devices.push_back(std::make_unique<RegisteredDevice>(80 devices.push_back(std::make_unique<RegisteredDevice>(
81 device, create_new_device_id(), input_dispatcher, input_dispatchable, cookie_factory, this, &seat));81 device, create_new_device_id(), input_dispatcher, input_dispatchable, cookie_authority, this, &seat));
8282
83 auto const& dev = devices.back();83 auto const& dev = devices.back();
84 seat.add_device(dev->id());84 seat.add_device(dev->id());
@@ -142,10 +142,10 @@
142 MirInputDeviceId device_id,142 MirInputDeviceId device_id,
143 std::shared_ptr<InputDispatcher> const& dispatcher,143 std::shared_ptr<InputDispatcher> const& dispatcher,
144 std::shared_ptr<dispatch::MultiplexingDispatchable> const& multiplexer,144 std::shared_ptr<dispatch::MultiplexingDispatchable> const& multiplexer,
145 std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory,145 std::shared_ptr<mir::cookie::Authority> const& cookie_authority,
146 DefaultInputDeviceHub* hub,146 DefaultInputDeviceHub* hub,
147 Seat* seat)147 Seat* seat)
148 : device_id(device_id), builder(device_id, cookie_factory), device(dev), dispatcher(dispatcher),148 : device_id(device_id), builder(device_id, cookie_authority), device(dev), dispatcher(dispatcher),
149 multiplexer(multiplexer), hub(hub), seat(seat)149 multiplexer(multiplexer), hub(hub), seat(seat)
150{150{
151}151}
152152
=== modified file 'src/server/input/default_input_device_hub.h'
--- src/server/input/default_input_device_hub.h 2016-01-20 23:59:18 +0000
+++ src/server/input/default_input_device_hub.h 2016-01-25 13:42:04 +0000
@@ -38,7 +38,7 @@
38class ServerActionQueue;38class ServerActionQueue;
39namespace cookie39namespace cookie
40{40{
41class CookieFactory;41class Authority;
42}42}
43namespace dispatch43namespace dispatch
44{44{
@@ -65,7 +65,7 @@
65 std::shared_ptr<TouchVisualizer> const& touch_visualizer,65 std::shared_ptr<TouchVisualizer> const& touch_visualizer,
66 std::shared_ptr<CursorListener> const& cursor_listener,66 std::shared_ptr<CursorListener> const& cursor_listener,
67 std::shared_ptr<InputRegion> const& input_region,67 std::shared_ptr<InputRegion> const& input_region,
68 std::shared_ptr<cookie::CookieFactory> const& cookie_factory);68 std::shared_ptr<cookie::Authority> const& cookie_authority);
6969
70 // InputDeviceRegistry - calls from mi::Platform70 // InputDeviceRegistry - calls from mi::Platform
71 void add_device(std::shared_ptr<InputDevice> const& device) override;71 void add_device(std::shared_ptr<InputDevice> const& device) override;
@@ -85,7 +85,7 @@
85 std::shared_ptr<ServerActionQueue> const observer_queue;85 std::shared_ptr<ServerActionQueue> const observer_queue;
86 std::shared_ptr<dispatch::ActionQueue> const device_queue;86 std::shared_ptr<dispatch::ActionQueue> const device_queue;
87 std::shared_ptr<InputRegion> const input_region;87 std::shared_ptr<InputRegion> const input_region;
88 std::shared_ptr<cookie::CookieFactory> const cookie_factory;88 std::shared_ptr<cookie::Authority> const cookie_authority;
89 Seat seat;89 Seat seat;
9090
91 struct RegisteredDevice : public InputSink91 struct RegisteredDevice : public InputSink
@@ -95,7 +95,7 @@
95 MirInputDeviceId dev_id,95 MirInputDeviceId dev_id,
96 std::shared_ptr<InputDispatcher> const& dispatcher,96 std::shared_ptr<InputDispatcher> const& dispatcher,
97 std::shared_ptr<dispatch::MultiplexingDispatchable> const& multiplexer,97 std::shared_ptr<dispatch::MultiplexingDispatchable> const& multiplexer,
98 std::shared_ptr<cookie::CookieFactory> const& cookie_factory,98 std::shared_ptr<cookie::Authority> const& cookie_authority,
99 DefaultInputDeviceHub* hub,99 DefaultInputDeviceHub* hub,
100 Seat* seat);100 Seat* seat);
101 void handle_input(MirEvent& event) override;101 void handle_input(MirEvent& event) override;
102102
=== modified file 'src/server/input/key_repeat_dispatcher.cpp'
--- src/server/input/key_repeat_dispatcher.cpp 2016-01-20 23:59:18 +0000
+++ src/server/input/key_repeat_dispatcher.cpp 2016-01-25 13:42:04 +0000
@@ -21,10 +21,11 @@
21#include "mir/time/alarm_factory.h"21#include "mir/time/alarm_factory.h"
22#include "mir/time/alarm.h"22#include "mir/time/alarm.h"
23#include "mir/events/event_private.h"23#include "mir/events/event_private.h"
24#include "mir/cookie_factory.h"24#include "mir/cookie/authority.h"
2525
26#include <boost/throw_exception.hpp>26#include <boost/throw_exception.hpp>
2727
28#include <algorithm>
28#include <stdexcept>29#include <stdexcept>
29#include <string.h>30#include <string.h>
3031
@@ -33,13 +34,13 @@
33mi::KeyRepeatDispatcher::KeyRepeatDispatcher(34mi::KeyRepeatDispatcher::KeyRepeatDispatcher(
34 std::shared_ptr<mi::InputDispatcher> const& next_dispatcher,35 std::shared_ptr<mi::InputDispatcher> const& next_dispatcher,
35 std::shared_ptr<mir::time::AlarmFactory> const& factory,36 std::shared_ptr<mir::time::AlarmFactory> const& factory,
36 std::shared_ptr<mir::cookie::CookieFactory> const& cookie_factory,37 std::shared_ptr<mir::cookie::Authority> const& cookie_authority,
37 bool repeat_enabled,38 bool repeat_enabled,
38 std::chrono::milliseconds repeat_timeout,39 std::chrono::milliseconds repeat_timeout,
39 std::chrono::milliseconds repeat_delay)40 std::chrono::milliseconds repeat_delay)
40 : next_dispatcher(next_dispatcher),41 : next_dispatcher(next_dispatcher),
41 alarm_factory(factory),42 alarm_factory(factory),
42 cookie_factory(cookie_factory),43 cookie_authority(cookie_authority),
43 repeat_enabled(repeat_enabled),44 repeat_enabled(repeat_enabled),
44 repeat_timeout(repeat_timeout),45 repeat_timeout(repeat_timeout),
45 repeat_delay(repeat_delay)46 repeat_delay(repeat_delay)
@@ -119,7 +120,9 @@
119 std::lock_guard<std::mutex> lg(repeat_state_mutex);120 std::lock_guard<std::mutex> lg(repeat_state_mutex);
120121
121 ev.key.event_time = std::chrono::steady_clock::now().time_since_epoch();122 ev.key.event_time = std::chrono::steady_clock::now().time_since_epoch();
122 ev.key.mac = cookie_factory->timestamp_to_cookie(ev.key.event_time.count()).mac;123 auto const cookie = cookie_authority->make_cookie(ev.key.event_time.count());
124 auto const serialized_cookie = cookie->serialize();
125 std::copy_n(std::begin(serialized_cookie), ev.key.cookie.size(), std::begin(ev.key.cookie));
123 next_dispatcher->dispatch(ev);126 next_dispatcher->dispatch(ev);
124127
125 capture_alarm->reschedule_in(repeat_delay);128 capture_alarm->reschedule_in(repeat_delay);
126129
=== modified file 'src/server/input/key_repeat_dispatcher.h'
--- src/server/input/key_repeat_dispatcher.h 2016-01-20 23:59:18 +0000
+++ src/server/input/key_repeat_dispatcher.h 2016-01-25 13:42:04 +0000
@@ -30,7 +30,7 @@
30{30{
31namespace cookie31namespace cookie
32{32{
33class CookieFactory;33class Authority;
34}34}
35namespace time35namespace time
36{36{
@@ -45,7 +45,7 @@
45public:45public:
46 KeyRepeatDispatcher(std::shared_ptr<InputDispatcher> const& next_dispatcher,46 KeyRepeatDispatcher(std::shared_ptr<InputDispatcher> const& next_dispatcher,
47 std::shared_ptr<time::AlarmFactory> const& factory,47 std::shared_ptr<time::AlarmFactory> const& factory,
48 std::shared_ptr<cookie::CookieFactory> const& cookie_factory,48 std::shared_ptr<cookie::Authority> const& cookie_authority,
49 bool repeat_enabled,49 bool repeat_enabled,
50 std::chrono::milliseconds repeat_timeout, /* timeout before sending first repeat */50 std::chrono::milliseconds repeat_timeout, /* timeout before sending first repeat */
51 std::chrono::milliseconds repeat_delay /* delay between repeated keys */);51 std::chrono::milliseconds repeat_delay /* delay between repeated keys */);
@@ -60,7 +60,7 @@
6060
61 std::shared_ptr<InputDispatcher> const next_dispatcher;61 std::shared_ptr<InputDispatcher> const next_dispatcher;
62 std::shared_ptr<time::AlarmFactory> const alarm_factory;62 std::shared_ptr<time::AlarmFactory> const alarm_factory;
63 std::shared_ptr<cookie::CookieFactory> const cookie_factory;63 std::shared_ptr<cookie::Authority> const cookie_authority;
64 bool const repeat_enabled;64 bool const repeat_enabled;
65 std::chrono::milliseconds repeat_timeout;65 std::chrono::milliseconds repeat_timeout;
66 std::chrono::milliseconds repeat_delay;66 std::chrono::milliseconds repeat_delay;
6767
=== modified file 'src/server/input/surface_input_dispatcher.cpp'
--- src/server/input/surface_input_dispatcher.cpp 2016-01-20 23:59:18 +0000
+++ src/server/input/surface_input_dispatcher.cpp 2016-01-25 13:42:04 +0000
@@ -24,7 +24,6 @@
24#include "mir/scene/surface.h"24#include "mir/scene/surface.h"
25#include "mir/events/event_builders.h"25#include "mir/events/event_builders.h"
26#include "mir/events/event_private.h"26#include "mir/events/event_private.h"
27#include "mir/cookie_factory.h"
2827
29#include <string.h>28#include <string.h>
3029
@@ -221,7 +220,7 @@
221 220
222 deliver(surface, &*mev::make_event(mir_input_event_get_device_id(iev),221 deliver(surface, &*mev::make_event(mir_input_event_get_device_id(iev),
223 std::chrono::nanoseconds(mir_input_event_get_event_time(iev)),222 std::chrono::nanoseconds(mir_input_event_get_event_time(iev)),
224 0, // FIXME Revet cookie API, fix incoming for 0.19223 std::vector<uint8_t>{},
225 mir_pointer_event_modifiers(pev),224 mir_pointer_event_modifiers(pev),
226 action, mir_pointer_event_buttons(pev),225 action, mir_pointer_event_buttons(pev),
227 mir_pointer_event_axis_value(pev,mir_pointer_axis_x),226 mir_pointer_event_axis_value(pev,mir_pointer_axis_x),
228227
=== modified file 'src/server/input/validator.cpp'
--- src/server/input/validator.cpp 2016-01-20 23:59:18 +0000
+++ src/server/input/validator.cpp 2016-01-25 13:42:04 +0000
@@ -244,7 +244,7 @@
244 MirTouchEvent const* last_ev = nullptr;244 MirTouchEvent const* last_ev = nullptr;
245 auto default_ev = mev::make_event(id,245 auto default_ev = mev::make_event(id,
246 std::chrono::high_resolution_clock::now().time_since_epoch(),246 std::chrono::high_resolution_clock::now().time_since_epoch(),
247 0, /* No need for a mac, since there's no pointer count for a default event */247 std::vector<uint8_t>{}, /* No need for a mac, since there's no pointer count for a default event */
248 mir_input_event_modifier_none); 248 mir_input_event_modifier_none);
249249
250 if (it == last_event_by_device.end())250 if (it == last_event_by_device.end())
251251
=== modified file 'src/server/server.cpp'
--- src/server/server.cpp 2016-01-20 23:59:18 +0000
+++ src/server/server.cpp 2016-01-25 13:42:04 +0000
@@ -31,7 +31,7 @@
31#include "mir/main_loop.h"31#include "mir/main_loop.h"
32#include "mir/report_exception.h"32#include "mir/report_exception.h"
33#include "mir/run_mir.h"33#include "mir/run_mir.h"
34#include "mir/cookie_factory.h"34#include "mir/cookie/authority.h"
3535
36// TODO these are used to frig a stub renderer when running headless36// TODO these are used to frig a stub renderer when running headless
37#include "mir/compositor/renderer.h"37#include "mir/compositor/renderer.h"
@@ -67,7 +67,7 @@
67 MACRO(session_mediator_report)\67 MACRO(session_mediator_report)\
68 MACRO(shell)\68 MACRO(shell)\
69 MACRO(application_not_responding_detector)\69 MACRO(application_not_responding_detector)\
70 MACRO(cookie_factory)\70 MACRO(cookie_authority)\
71 MACRO(coordinate_translator)71 MACRO(coordinate_translator)
7272
73#define FOREACH_ACCESSOR(MACRO)\73#define FOREACH_ACCESSOR(MACRO)\
7474
=== modified file 'src/server/shell/abstract_shell.cpp'
--- src/server/shell/abstract_shell.cpp 2016-01-20 23:59:18 +0000
+++ src/server/shell/abstract_shell.cpp 2016-01-25 13:42:04 +0000
@@ -164,7 +164,7 @@
164 return surface->query(attrib);164 return surface->query(attrib);
165}165}
166166
167void msh::AbstractShell::raise_surface_with_timestamp(167void msh::AbstractShell::raise_surface(
168 std::shared_ptr<ms::Session> const& session,168 std::shared_ptr<ms::Session> const& session,
169 std::shared_ptr<ms::Surface> const& surface,169 std::shared_ptr<ms::Surface> const& surface,
170 uint64_t timestamp)170 uint64_t timestamp)
171171
=== modified file 'src/server/shell/frontend_shell.cpp'
--- src/server/shell/frontend_shell.cpp 2016-01-20 23:59:18 +0000
+++ src/server/shell/frontend_shell.cpp 2016-01-25 13:42:04 +0000
@@ -148,12 +148,12 @@
148 return wrapped->get_surface_attribute(surface, attrib);148 return wrapped->get_surface_attribute(surface, attrib);
149}149}
150150
151void msh::FrontendShell::raise_surface_with_timestamp(151void msh::FrontendShell::raise_surface(
152 std::shared_ptr<mf::Session> const& session,152 std::shared_ptr<mf::Session> const& session,
153 mf::SurfaceId surface_id,153 mf::SurfaceId surface_id,
154 uint64_t timestamp)154 uint64_t timestamp)
155{155{
156 auto const scene_session = std::dynamic_pointer_cast<ms::Session>(session);156 auto const scene_session = std::dynamic_pointer_cast<ms::Session>(session);
157 auto const surface = scene_session->surface(surface_id);157 auto const surface = scene_session->surface(surface_id);
158 wrapped->raise_surface_with_timestamp(scene_session, surface, timestamp);158 wrapped->raise_surface(scene_session, surface, timestamp);
159}159}
160160
=== modified file 'src/server/shell/frontend_shell.h'
--- src/server/shell/frontend_shell.h 2016-01-20 23:59:18 +0000
+++ src/server/shell/frontend_shell.h 2016-01-25 13:42:04 +0000
@@ -87,7 +87,7 @@
87 mf::SurfaceId surface_id,87 mf::SurfaceId surface_id,
88 MirSurfaceAttrib attrib) override;88 MirSurfaceAttrib attrib) override;
8989
90 void raise_surface_with_timestamp(90 void raise_surface(
91 std::shared_ptr<mf::Session> const& session,91 std::shared_ptr<mf::Session> const& session,
92 mf::SurfaceId surface_id,92 mf::SurfaceId surface_id,
93 uint64_t timestamp) override;93 uint64_t timestamp) override;
9494
=== modified file 'src/server/shell/shell_wrapper.cpp'
--- src/server/shell/shell_wrapper.cpp 2016-01-20 23:59:18 +0000
+++ src/server/shell/shell_wrapper.cpp 2016-01-25 13:42:04 +0000
@@ -112,12 +112,12 @@
112 return wrapped->get_surface_attribute(surface, attrib);112 return wrapped->get_surface_attribute(surface, attrib);
113}113}
114114
115void msh::ShellWrapper::raise_surface_with_timestamp(115void msh::ShellWrapper::raise_surface(
116 std::shared_ptr<ms::Session> const& session,116 std::shared_ptr<ms::Session> const& session,
117 std::shared_ptr<ms::Surface> const& surface,117 std::shared_ptr<ms::Surface> const& surface,
118 uint64_t timestamp)118 uint64_t timestamp)
119{119{
120 wrapped->raise_surface_with_timestamp(session, surface, timestamp);120 wrapped->raise_surface(session, surface, timestamp);
121}121}
122122
123void msh::ShellWrapper::add_display(geometry::Rectangle const& area)123void msh::ShellWrapper::add_display(geometry::Rectangle const& area)
124124
=== modified file 'src/server/symbols.map'
--- src/server/symbols.map 2016-01-20 23:59:18 +0000
+++ src/server/symbols.map 2016-01-25 13:42:04 +0000
@@ -165,7 +165,7 @@
165 mir::Server::open_prompt_socket*;165 mir::Server::open_prompt_socket*;
166 mir::Server::override_the_application_not_responding_detector*;166 mir::Server::override_the_application_not_responding_detector*;
167 mir::Server::override_the_compositor*;167 mir::Server::override_the_compositor*;
168 mir::Server::override_the_cookie_factory*;168 mir::Server::override_the_cookie_authority*;
169 mir::Server::override_the_coordinate_translator*;169 mir::Server::override_the_coordinate_translator*;
170 mir::Server::override_the_cursor_images*;170 mir::Server::override_the_cursor_images*;
171 mir::Server::override_the_display_buffer_compositor_factory*;171 mir::Server::override_the_display_buffer_compositor_factory*;
@@ -240,7 +240,7 @@
240 mir::shell::AbstractShell::modify_surface*;240 mir::shell::AbstractShell::modify_surface*;
241 mir::shell::AbstractShell::open_session*;241 mir::shell::AbstractShell::open_session*;
242 mir::shell::AbstractShell::raise*;242 mir::shell::AbstractShell::raise*;
243 mir::shell::AbstractShell::raise_surface_with_timestamp*;243 mir::shell::AbstractShell::raise_surface*;
244 mir::shell::AbstractShell::remove_display*;244 mir::shell::AbstractShell::remove_display*;
245 mir::shell::AbstractShell::set_focus_to*;245 mir::shell::AbstractShell::set_focus_to*;
246 mir::shell::AbstractShell::set_surface_attribute*;246 mir::shell::AbstractShell::set_surface_attribute*;
@@ -282,7 +282,7 @@
282 mir::shell::ShellWrapper::modify_surface*;282 mir::shell::ShellWrapper::modify_surface*;
283 mir::shell::ShellWrapper::open_session*;283 mir::shell::ShellWrapper::open_session*;
284 mir::shell::ShellWrapper::raise*;284 mir::shell::ShellWrapper::raise*;
285 mir::shell::ShellWrapper::raise_surface_with_timestamp*;285 mir::shell::ShellWrapper::raise_surface*;
286 mir::shell::ShellWrapper::remove_display*;286 mir::shell::ShellWrapper::remove_display*;
287 mir::shell::ShellWrapper::set_focus_to*;287 mir::shell::ShellWrapper::set_focus_to*;
288 mir::shell::ShellWrapper::set_surface_attribute*;288 mir::shell::ShellWrapper::set_surface_attribute*;
@@ -395,7 +395,7 @@
395 non-virtual?thunk?to?mir::shell::AbstractShell::modify_surface*;395 non-virtual?thunk?to?mir::shell::AbstractShell::modify_surface*;
396 non-virtual?thunk?to?mir::shell::AbstractShell::open_session*;396 non-virtual?thunk?to?mir::shell::AbstractShell::open_session*;
397 non-virtual?thunk?to?mir::shell::AbstractShell::raise*;397 non-virtual?thunk?to?mir::shell::AbstractShell::raise*;
398 non-virtual?thunk?to?mir::shell::AbstractShell::raise_surface_with_timestamp*;398 non-virtual?thunk?to?mir::shell::AbstractShell::raise_surface*;
399 non-virtual?thunk?to?mir::shell::AbstractShell::remove_display*;399 non-virtual?thunk?to?mir::shell::AbstractShell::remove_display*;
400 non-virtual?thunk?to?mir::shell::AbstractShell::set_focus_to*;400 non-virtual?thunk?to?mir::shell::AbstractShell::set_focus_to*;
401 non-virtual?thunk?to?mir::shell::AbstractShell::set_surface_attribute*;401 non-virtual?thunk?to?mir::shell::AbstractShell::set_surface_attribute*;
@@ -422,7 +422,7 @@
422 non-virtual?thunk?to?mir::shell::ShellWrapper::modify_surface*;422 non-virtual?thunk?to?mir::shell::ShellWrapper::modify_surface*;
423 non-virtual?thunk?to?mir::shell::ShellWrapper::open_session*;423 non-virtual?thunk?to?mir::shell::ShellWrapper::open_session*;
424 non-virtual?thunk?to?mir::shell::ShellWrapper::raise*;424 non-virtual?thunk?to?mir::shell::ShellWrapper::raise*;
425 non-virtual?thunk?to?mir::shell::ShellWrapper::raise_surface_with_timestamp*;425 non-virtual?thunk?to?mir::shell::ShellWrapper::raise_surface*;
426 non-virtual?thunk?to?mir::shell::ShellWrapper::remove_display*;426 non-virtual?thunk?to?mir::shell::ShellWrapper::remove_display*;
427 non-virtual?thunk?to?mir::shell::ShellWrapper::set_focus_to*;427 non-virtual?thunk?to?mir::shell::ShellWrapper::set_focus_to*;
428 non-virtual?thunk?to?mir::shell::ShellWrapper::set_surface_attribute*;428 non-virtual?thunk?to?mir::shell::ShellWrapper::set_surface_attribute*;
@@ -677,7 +677,7 @@
677 mir::DefaultServerConfiguration::the_buffer_stream_factory*;677 mir::DefaultServerConfiguration::the_buffer_stream_factory*;
678 mir::DefaultServerConfiguration::the_clock*;678 mir::DefaultServerConfiguration::the_clock*;
679 mir::DefaultServerConfiguration::the_composite_event_filter*;679 mir::DefaultServerConfiguration::the_composite_event_filter*;
680 mir::DefaultServerConfiguration::the_cookie_factory*;680 mir::DefaultServerConfiguration::the_cookie_authority*;
681 mir::DefaultServerConfiguration::the_event_filter_chain_dispatcher*;681 mir::DefaultServerConfiguration::the_event_filter_chain_dispatcher*;
682 mir::DefaultServerConfiguration::the_surface_input_dispatcher;682 mir::DefaultServerConfiguration::the_surface_input_dispatcher;
683 mir::DefaultServerConfiguration::the_compositor*;683 mir::DefaultServerConfiguration::the_compositor*;
684684
=== modified file 'tests/acceptance-tests/test_client_cookie.cpp'
--- tests/acceptance-tests/test_client_cookie.cpp 2016-01-20 23:59:18 +0000
+++ tests/acceptance-tests/test_client_cookie.cpp 2016-01-25 13:42:04 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2015 Canonical Ltd.2 * Copyright © 2015-2016 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -23,12 +23,14 @@
23#include "mir_test_framework/stub_server_platform_factory.h"23#include "mir_test_framework/stub_server_platform_factory.h"
24#include "mir_test_framework/connected_client_with_a_surface.h"24#include "mir_test_framework/connected_client_with_a_surface.h"
25#include "mir/test/spin_wait.h"25#include "mir/test/spin_wait.h"
26#include "mir/cookie_factory.h"26#include "mir/cookie/authority.h"
2727
28#include "boost/throw_exception.hpp"28#include "boost/throw_exception.hpp"
2929
30#include <linux/input.h>30#include <linux/input.h>
3131
32#include <mutex>
33
32namespace mtf = mir_test_framework;34namespace mtf = mir_test_framework;
33namespace mt = mir::test;35namespace mt = mir::test;
34namespace mi = mir::input;36namespace mi = mir::input;
@@ -45,8 +47,8 @@
45public:47public:
46 ClientCookies()48 ClientCookies()
47 {49 {
48 server.override_the_cookie_factory([this] ()50 server.override_the_cookie_authority([this] ()
49 { return mir::cookie::CookieFactory::create_saving_secret(cookie_secret); });51 { return mir::cookie::Authority::create_saving(cookie_secret); });
50 }52 }
5153
52 void SetUp() override54 void SetUp() override
@@ -63,9 +65,6 @@
63 mir_buffer_stream_swap_buffers_sync(mir_surface_get_buffer_stream(surface));65 mir_buffer_stream_swap_buffers_sync(mir_surface_get_buffer_stream(surface));
64 }66 }
6567
66 std::vector<uint8_t> cookie_secret;
67 std::vector<MirCookie> out_cookies;
68
69 std::unique_ptr<mtf::FakeInputDevice> fake_keyboard{68 std::unique_ptr<mtf::FakeInputDevice> fake_keyboard{
70 mtf::add_fake_input_device(mi::InputDeviceInfo{"keyboard", "keyboard-uid" , mi::DeviceCapability::keyboard})69 mtf::add_fake_input_device(mi::InputDeviceInfo{"keyboard", "keyboard-uid" , mi::DeviceCapability::keyboard})
71 };70 };
@@ -76,21 +75,49 @@
76 mtf::add_fake_input_device(mi::InputDeviceInfo{75 mtf::add_fake_input_device(mi::InputDeviceInfo{
77 "touch screen", "touch-screen-uid", mi::DeviceCapability::touchscreen | mi::DeviceCapability::multitouch})76 "touch screen", "touch-screen-uid", mi::DeviceCapability::touchscreen | mi::DeviceCapability::multitouch})
78 };77 };
78
79 std::vector<std::vector<uint8_t>> out_cookies;
80 std::vector<uint8_t> cookie_secret;
81 size_t event_count{0};
82 mutable std::mutex mutex;
79};83};
8084
81namespace85namespace
82{86{
83// FIXME Removing the public API calls for the mir cookie, fix coming in 0.1987
84void cookie_capturing_callback(MirSurface*, MirEvent const* /*ev*/, void* /*ctx*/)88void cookie_capturing_callback(MirSurface*, MirEvent const* ev, void* ctx)
85{89{
90 auto const event_type = mir_event_get_type(ev);
91 auto client_cookie = static_cast<ClientCookies*>(ctx);
92
93 if (event_type == mir_event_type_input)
94 {
95 auto const* iev = mir_event_get_input_event(ev);
96
97 std::lock_guard<std::mutex> lk(client_cookie->mutex);
98 if (mir_input_event_has_cookie(iev))
99 {
100 auto cookie = mir_input_event_get_cookie(iev);
101 size_t size = mir_cookie_buffer_size(cookie);
102
103 std::vector<uint8_t> cookie_bytes(size);
104 mir_cookie_to_buffer(cookie, cookie_bytes.data(), size);
105
106 mir_cookie_release(cookie);
107 client_cookie->out_cookies.push_back(cookie_bytes);
108 }
109
110 client_cookie->event_count++;
111 }
86}112}
87113
88bool wait_for_n_events(size_t n, std::vector<MirCookie>& cookies)114bool wait_for_n_events(size_t n, ClientCookies* client_cookie)
89{115{
90 bool all_events = mt::spin_wait_for_condition_or_timeout(116 bool all_events = mt::spin_wait_for_condition_or_timeout(
91 [&n, &cookies]117 [&n, &client_cookie]
92 {118 {
93 return cookies.size() >= n;119 std::lock_guard<std::mutex> lk(client_cookie->mutex);
120 return client_cookie->event_count >= n;
94 },121 },
95 std::chrono::seconds{max_wait});122 std::chrono::seconds{max_wait});
96123
@@ -99,41 +126,52 @@
99}126}
100}127}
101128
102// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19129TEST_F(ClientCookies, keyboard_events_have_cookies)
103TEST_F(ClientCookies, DISABLED_keyboard_events_have_attestable_cookies)
104{130{
105 fake_keyboard->emit_event(mis::a_key_down_event().of_scancode(KEY_M));131 fake_keyboard->emit_event(mis::a_key_down_event().of_scancode(KEY_M));
106 if (wait_for_n_events(1, out_cookies))132
133 int events = 1;
134 if (wait_for_n_events(events, this))
107 {135 {
108 auto factory = mir::cookie::CookieFactory::create_from_secret(cookie_secret);136 std::lock_guard<std::mutex> lk(mutex);
109 EXPECT_TRUE(factory->attest_timestamp(out_cookies.back()));137
138 ASSERT_FALSE(out_cookies.empty());
139 auto authority = mir::cookie::Authority::create_from(cookie_secret);
140
141 EXPECT_NO_THROW(authority->make_cookie(out_cookies.back()));
110 }142 }
111}143}
112144
113// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19145TEST_F(ClientCookies, pointer_motion_events_do_not_have_cookies)
114TEST_F(ClientCookies, DISABLED_pointer_motion_events_do_not_have_attestable_cookies)
115{146{
147 // with movement generates 2 events
116 fake_pointer->emit_event(mis::a_pointer_event().with_movement(1, 1));148 fake_pointer->emit_event(mis::a_pointer_event().with_movement(1, 1));
117 if (wait_for_n_events(1, out_cookies))149
150 int events = 2;
151 if (wait_for_n_events(events, this))
118 {152 {
119 auto factory = mir::cookie::CookieFactory::create_from_secret(cookie_secret);153 std::lock_guard<std::mutex> lk(mutex);
120 EXPECT_FALSE(factory->attest_timestamp(out_cookies.back()));154 EXPECT_EQ(event_count, events);
155 EXPECT_TRUE(out_cookies.empty());
121 }156 }
122}157}
123158
124TEST_F(ClientCookies, DISABLED_pointer_click_events_have_attestable_cookies)159TEST_F(ClientCookies, pointer_click_events_have_cookies)
125{160{
126 fake_pointer->emit_event(mis::a_button_down_event().of_button(BTN_LEFT).with_action(mis::EventAction::Down));161 fake_pointer->emit_event(mis::a_button_down_event().of_button(BTN_LEFT).with_action(mis::EventAction::Down));
127 fake_pointer->emit_event(mis::a_button_up_event().of_button(BTN_LEFT));162 fake_pointer->emit_event(mis::a_button_up_event().of_button(BTN_LEFT));
128 if (wait_for_n_events(2, out_cookies))163
164 int events = 2;
165 if (wait_for_n_events(events, this))
129 {166 {
130 auto factory = mir::cookie::CookieFactory::create_from_secret(cookie_secret);167 std::lock_guard<std::mutex> lk(mutex);
131 EXPECT_TRUE(factory->attest_timestamp(out_cookies.back()));168 ASSERT_FALSE(out_cookies.empty());
169 auto authority = mir::cookie::Authority::create_from(cookie_secret);
170 EXPECT_NO_THROW(authority->make_cookie(out_cookies.back()));
132 }171 }
133}172}
134173
135// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19174TEST_F(ClientCookies, touch_motion_events_do_not_have_cookies)
136TEST_F(ClientCookies, DISABLED_touch_motion_events_do_not_have_attestable_cookies)
137{175{
138 fake_touch_screen->emit_event(176 fake_touch_screen->emit_event(
139 mis::a_touch_event()177 mis::a_touch_event()
@@ -146,24 +184,11 @@
146 .at_position({1, 1})184 .at_position({1, 1})
147 );185 );
148186
149 if (wait_for_n_events(2, out_cookies))187 int events = 1;
150 {188 if (wait_for_n_events(events, this))
151 auto factory = mir::cookie::CookieFactory::create_from_secret(cookie_secret);189 {
152 EXPECT_FALSE(factory->attest_timestamp(out_cookies.back()));190 std::lock_guard<std::mutex> lk(mutex);
153 }191 EXPECT_GE(event_count, events);
154}192 EXPECT_EQ(out_cookies.size(), 1);
155
156// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19
157TEST_F(ClientCookies, DISABLED_touch_click_events_have_attestable_cookies)
158{
159 fake_touch_screen->emit_event(
160 mis::a_touch_event()
161 .at_position({0, 0})
162 );
163
164 if (wait_for_n_events(1, out_cookies))
165 {
166 auto factory = mir::cookie::CookieFactory::create_from_secret(cookie_secret);
167 EXPECT_TRUE(factory->attest_timestamp(out_cookies.back()));
168 }193 }
169}194}
170195
=== modified file 'tests/acceptance-tests/test_client_input.cpp'
--- tests/acceptance-tests/test_client_input.cpp 2016-01-23 03:16:06 +0000
+++ tests/acceptance-tests/test_client_input.cpp 2016-01-25 13:42:04 +0000
@@ -587,7 +587,7 @@
587 EXPECT_CALL(first_client, handle_input(mt::KeyDownEvent()))587 EXPECT_CALL(first_client, handle_input(mt::KeyDownEvent()))
588 .WillOnce(mt::WakeUp(&first_client.all_events_received));588 .WillOnce(mt::WakeUp(&first_client.all_events_received));
589589
590 auto key_event = mir::events::make_event(MirInputDeviceId{0}, 0ns, 0, mir_keyboard_action_down, 0, KEY_M,590 auto key_event = mir::events::make_event(MirInputDeviceId{0}, 0ns, std::vector<uint8_t>{}, mir_keyboard_action_down, 0, KEY_M,
591 mir_input_event_modifier_none);591 mir_input_event_modifier_none);
592592
593 server.the_shell()->focused_surface()->consume(key_event.get());593 server.the_shell()->focused_surface()->consume(key_event.get());
594594
=== modified file 'tests/acceptance-tests/test_surface_modifications.cpp'
--- tests/acceptance-tests/test_surface_modifications.cpp 2016-01-20 23:59:18 +0000
+++ tests/acceptance-tests/test_surface_modifications.cpp 2016-01-25 13:42:04 +0000
@@ -83,11 +83,10 @@
83 auto const hscroll_value = 0.0;83 auto const hscroll_value = 0.0;
84 auto const vscroll_value = 0.0;84 auto const vscroll_value = 0.0;
85 auto const action = mir_pointer_action_button_down;85 auto const action = mir_pointer_action_button_down;
86 auto const mac = 0;
87 auto const relative_x_value = 0.0;86 auto const relative_x_value = 0.0;
88 auto const relative_y_value = 0.0;87 auto const relative_y_value = 0.0;
8988
90 auto const click_event = mev::make_event(device_id, timestamp, mac, modifiers,89 auto const click_event = mev::make_event(device_id, timestamp, cookie, modifiers,
91 action, mir_pointer_button_tertiary, x_axis_value, y_axis_value,90 action, mir_pointer_button_tertiary, x_axis_value, y_axis_value,
92 hscroll_value, vscroll_value, relative_x_value, relative_y_value);91 hscroll_value, vscroll_value, relative_x_value, relative_y_value);
9392
@@ -103,11 +102,10 @@
103 auto const hscroll_value = 0.0;102 auto const hscroll_value = 0.0;
104 auto const vscroll_value = 0.0;103 auto const vscroll_value = 0.0;
105 auto const action = mir_pointer_action_motion;104 auto const action = mir_pointer_action_motion;
106 auto const mac = 0;
107 auto const relative_x_value = 0.0;105 auto const relative_x_value = 0.0;
108 auto const relative_y_value = 0.0;106 auto const relative_y_value = 0.0;
109107
110 auto const drag_event = mev::make_event(device_id, timestamp, mac, modifiers,108 auto const drag_event = mev::make_event(device_id, timestamp, cookie, modifiers,
111 action, mir_pointer_button_tertiary, x_axis_value, y_axis_value,109 action, mir_pointer_button_tertiary, x_axis_value, y_axis_value,
112 hscroll_value, vscroll_value, relative_x_value, relative_y_value);110 hscroll_value, vscroll_value, relative_x_value, relative_y_value);
113111
@@ -146,6 +144,7 @@
146 std::chrono::nanoseconds const timestamp = std::chrono::nanoseconds(39);144 std::chrono::nanoseconds const timestamp = std::chrono::nanoseconds(39);
147 NiceMock<MockSurfaceObserver> surface_observer;145 NiceMock<MockSurfaceObserver> surface_observer;
148 std::weak_ptr<ms::Surface> shell_surface;146 std::weak_ptr<ms::Surface> shell_surface;
147 std::vector<uint8_t> cookie;
149};148};
150149
151MATCHER_P(WidthEq, value, "")150MATCHER_P(WidthEq, value, "")
152151
=== modified file 'tests/acceptance-tests/test_surface_placement.cpp'
--- tests/acceptance-tests/test_surface_placement.cpp 2016-01-20 23:59:18 +0000
+++ tests/acceptance-tests/test_surface_placement.cpp 2016-01-25 13:42:04 +0000
@@ -127,12 +127,11 @@
127 auto const hscroll_value = 0.0;127 auto const hscroll_value = 0.0;
128 auto const vscroll_value = 0.0;128 auto const vscroll_value = 0.0;
129 auto const action = mir_pointer_action_button_down;129 auto const action = mir_pointer_action_button_down;
130 auto const mac = 0;
131 auto const relative_x_value = 0.0;130 auto const relative_x_value = 0.0;
132 auto const relative_y_value = 0.0;131 auto const relative_y_value = 0.0;
133132
134133
135 auto const click_event = mev::make_event(device_id, std::chrono::nanoseconds(1), mac, modifiers,134 auto const click_event = mev::make_event(device_id, std::chrono::nanoseconds(1), std::vector<uint8_t>{}, modifiers,
136 action, depressed_buttons, x_axis_value, y_axis_value, hscroll_value,135 action, depressed_buttons, x_axis_value, y_axis_value, hscroll_value,
137 vscroll_value, relative_x_value, relative_y_value);136 vscroll_value, relative_x_value, relative_y_value);
138137
139138
=== modified file 'tests/acceptance-tests/test_surface_raise.cpp'
--- tests/acceptance-tests/test_surface_raise.cpp 2015-11-30 21:08:18 +0000
+++ tests/acceptance-tests/test_surface_raise.cpp 2016-01-25 13:42:04 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2015 Canonical Ltd.2 * Copyright © 2015-2016 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -24,7 +24,7 @@
24#include "mir_test_framework/any_surface.h"24#include "mir_test_framework/any_surface.h"
25#include "mir/test/wait_condition.h"25#include "mir/test/wait_condition.h"
26#include "mir/test/spin_wait.h"26#include "mir/test/spin_wait.h"
27#include "mir/cookie_factory.h"27#include "mir/cookie/authority.h"
2828
29#include "mir_toolkit/mir_client_library.h"29#include "mir_toolkit/mir_client_library.h"
3030
@@ -33,6 +33,8 @@
33#include <gtest/gtest.h>33#include <gtest/gtest.h>
34#include <gmock/gmock.h>34#include <gmock/gmock.h>
3535
36#include <mutex>
37
36namespace mtf = mir_test_framework;38namespace mtf = mir_test_framework;
37namespace mt = mir::test;39namespace mt = mir::test;
38namespace mi = mir::input;40namespace mi = mir::input;
@@ -42,7 +44,6 @@
42{44{
43std::chrono::seconds const max_wait{4};45std::chrono::seconds const max_wait{4};
44void cookie_capturing_callback(MirSurface* surface, MirEvent const* ev, void* ctx);46void cookie_capturing_callback(MirSurface* surface, MirEvent const* ev, void* ctx);
45void lifecycle_changed(MirConnection* /* connection */, MirLifecycleState state, void* ctx);
46}47}
4748
48struct RaiseSurfaces : mtf::ConnectedClientHeadlessServer49struct RaiseSurfaces : mtf::ConnectedClientHeadlessServer
@@ -77,17 +78,14 @@
77 std::chrono::seconds{max_wait});78 std::chrono::seconds{max_wait});
7879
79 EXPECT_TRUE(surface_fullscreen);80 EXPECT_TRUE(surface_fullscreen);
80
81 mir_connection_set_lifecycle_event_callback(connection, lifecycle_changed, this);
82 }81 }
8382
84 MirSurface* surface1;83 MirSurface* surface1;
85 MirSurface* surface2;84 MirSurface* surface2;
8685
87 std::vector<MirCookie> key_cookies;86 std::vector<std::vector<uint8_t>> out_cookies;
88 std::vector<MirCookie> pointer_cookies;87 size_t event_count{0};
8988 mutable std::mutex mutex;
90 MirLifecycleState lifecycle_state{mir_lifecycle_state_resumed};
9189
92 std::unique_ptr<mtf::FakeInputDevice> fake_keyboard{90 std::unique_ptr<mtf::FakeInputDevice> fake_keyboard{
93 mtf::add_fake_input_device(mi::InputDeviceInfo{"keyboard", "keyboard-uid", mi::DeviceCapability::keyboard})91 mtf::add_fake_input_device(mi::InputDeviceInfo{"keyboard", "keyboard-uid", mi::DeviceCapability::keyboard})
@@ -99,23 +97,41 @@
9997
100namespace98namespace
101{99{
102// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19100
103void cookie_capturing_callback(MirSurface* /*surface*/, MirEvent const* /*ev*/, void* /*ctx*/)101void cookie_capturing_callback(MirSurface* /*surface*/, MirEvent const* ev, void* ctx)
104{102{
105}103 auto const event_type = mir_event_get_type(ev);
106104 auto raise_surfaces = static_cast<RaiseSurfaces*>(ctx);
107void lifecycle_changed(MirConnection* /*connection*/, MirLifecycleState state, void* ctx)105
108{106 if (event_type == mir_event_type_input)
109 auto client = reinterpret_cast<RaiseSurfaces*>(ctx);107 {
110 client->lifecycle_state = state;108 auto const* iev = mir_event_get_input_event(ev);
111}109
112110 std::lock_guard<std::mutex> lk(raise_surfaces->mutex);
113bool wait_for_n_events(size_t n, std::vector<MirCookie>& cookies)111 if (mir_input_event_has_cookie(iev))
112 {
113 auto cookie = mir_input_event_get_cookie(iev);
114 size_t size = mir_cookie_buffer_size(cookie);
115
116 std::vector<uint8_t> cookie_bytes(size);
117 mir_cookie_to_buffer(cookie, cookie_bytes.data(), size);
118
119 mir_cookie_release(cookie);
120
121 raise_surfaces->out_cookies.push_back(cookie_bytes);
122 }
123
124 raise_surfaces->event_count++;
125 }
126}
127
128bool wait_for_n_events(size_t n, RaiseSurfaces const* raise_surfaces)
114{129{
115 bool all_events = mt::spin_wait_for_condition_or_timeout(130 bool all_events = mt::spin_wait_for_condition_or_timeout(
116 [&n, &cookies]131 [&n, &raise_surfaces]
117 {132 {
118 return cookies.size() >= n;133 std::lock_guard<std::mutex> lk(raise_surfaces->mutex);
134 return raise_surfaces->event_count >= n;
119 },135 },
120 std::chrono::seconds{max_wait});136 std::chrono::seconds{max_wait});
121137
@@ -123,30 +139,55 @@
123 return all_events;139 return all_events;
124}140}
125141
126}142bool attempt_focus(MirSurface* surface, MirCookie const* cookie)
127143{
128// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19144 mir_surface_raise(surface, cookie);
129TEST_F(RaiseSurfaces, DISABLED_key_event_with_cookie)145 bool surface_becomes_focused = mt::spin_wait_for_condition_or_timeout(
146 [&surface]
147 {
148 return mir_surface_get_focus(surface) == mir_surface_focused;
149 },
150 std::chrono::seconds{max_wait});
151
152 return surface_becomes_focused;
153}
154
155}
156
157TEST_F(RaiseSurfaces, key_event_with_cookie)
130{158{
131 fake_keyboard->emit_event(mis::a_key_down_event().of_scancode(KEY_M));159 fake_keyboard->emit_event(mis::a_key_down_event().of_scancode(KEY_M));
132 if (wait_for_n_events(1, key_cookies))160
161 int events = 1;
162 if (wait_for_n_events(events, this))
133 {163 {
164 std::lock_guard<std::mutex> lk(mutex);
165 ASSERT_FALSE(out_cookies.empty());
134 EXPECT_EQ(mir_surface_get_focus(surface2), mir_surface_focused);166 EXPECT_EQ(mir_surface_get_focus(surface2), mir_surface_focused);
135 // EXPECT_TRUE attempt_focus surface2 key_cookies.back()167
168 MirCookie const* cookie = mir_cookie_from_buffer(out_cookies.back().data(), out_cookies.back().size());
169 attempt_focus(surface2, cookie);
170
171 mir_cookie_release(cookie);
136 }172 }
137}173}
138174
139// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19175TEST_F(RaiseSurfaces, older_timestamp_does_not_focus)
140TEST_F(RaiseSurfaces, DISABLED_older_timestamp_does_not_focus)
141{176{
142 fake_keyboard->emit_event(mis::a_key_down_event().of_scancode(KEY_M));177 fake_keyboard->emit_event(mis::a_key_down_event().of_scancode(KEY_M));
143 fake_keyboard->emit_event(mis::a_key_up_event().of_scancode(KEY_M));178 fake_keyboard->emit_event(mis::a_key_up_event().of_scancode(KEY_M));
144 if (wait_for_n_events(2, key_cookies))179
180 int events = 2;
181 if (wait_for_n_events(events, this))
145 {182 {
146 EXPECT_TRUE(key_cookies.front().timestamp < key_cookies.back().timestamp);183 std::lock_guard<std::mutex> lk(mutex);
184 ASSERT_FALSE(out_cookies.empty());
147 EXPECT_EQ(mir_surface_get_focus(surface2), mir_surface_focused);185 EXPECT_EQ(mir_surface_get_focus(surface2), mir_surface_focused);
148186
149 // mir_surface_raise_with_cookie187 MirCookie const* cookie = mir_cookie_from_buffer(out_cookies.front().data(), out_cookies.front().size());
188 mir_surface_raise(surface1, cookie);
189
190 mir_cookie_release(cookie);
150191
151 // Need to wait for this call to actually go through192 // Need to wait for this call to actually go through
152 std::this_thread::sleep_for(std::chrono::milliseconds{1000});193 std::this_thread::sleep_for(std::chrono::milliseconds{1000});
@@ -154,33 +195,21 @@
154 }195 }
155}196}
156197
157// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19198TEST_F(RaiseSurfaces, motion_events_dont_prevent_raise)
158TEST_F(RaiseSurfaces, DISABLED_motion_events_dont_prevent_raise)
159{199{
160 fake_keyboard->emit_event(mis::a_key_down_event().of_scancode(KEY_M));200 fake_keyboard->emit_event(mis::a_key_down_event().of_scancode(KEY_M));
161 fake_keyboard->emit_event(mis::a_key_up_event().of_scancode(KEY_M));201 fake_keyboard->emit_event(mis::a_key_up_event().of_scancode(KEY_M));
162 if (wait_for_n_events(2, key_cookies))202 if (wait_for_n_events(2, this))
163 {203 {
164 fake_pointer->emit_event(mis::a_pointer_event().with_movement(1, 1));204 fake_pointer->emit_event(mis::a_pointer_event().with_movement(1, 1));
165 if (wait_for_n_events(1, pointer_cookies))205 if (wait_for_n_events(1, this))
166 {206 {
207 std::lock_guard<std::mutex> lk(mutex);
208 ASSERT_FALSE(out_cookies.empty());
167 EXPECT_EQ(mir_surface_get_focus(surface2), mir_surface_focused);209 EXPECT_EQ(mir_surface_get_focus(surface2), mir_surface_focused);
168 // EXPECT_TRUE attempt_focus surface1 key_cookies.back()210 MirCookie const* cookie = mir_cookie_from_buffer(out_cookies.back().data(), out_cookies.back().size());
211 EXPECT_TRUE(attempt_focus(surface1, cookie));
212 mir_cookie_release(cookie);
169 }213 }
170 }214 }
171}215}
172
173// FIXME Removing the public API calls for the mir cookie, fix coming in 0.19
174TEST_F(RaiseSurfaces, DISABLED_client_connection_close_invalid_cookie)
175{
176 // mir_surface_raise_with_cookie
177
178 bool connection_close = mt::spin_wait_for_condition_or_timeout(
179 [this]
180 {
181 return lifecycle_state == mir_lifecycle_connection_lost;
182 },
183 std::chrono::seconds{max_wait});
184
185 EXPECT_TRUE(connection_close);
186}
187216
=== modified file 'tests/acceptance-tests/test_surface_specification.cpp'
--- tests/acceptance-tests/test_surface_specification.cpp 2016-01-20 23:59:18 +0000
+++ tests/acceptance-tests/test_surface_specification.cpp 2016-01-25 13:42:04 +0000
@@ -116,11 +116,10 @@
116 auto const hscroll_value = 0.0;116 auto const hscroll_value = 0.0;
117 auto const vscroll_value = 0.0;117 auto const vscroll_value = 0.0;
118 auto const action = mir_pointer_action_button_down;118 auto const action = mir_pointer_action_button_down;
119 auto const mac = 0;
120 auto const relative_x_value = 0.0;119 auto const relative_x_value = 0.0;
121 auto const relative_y_value = 0.0;120 auto const relative_y_value = 0.0;
122121
123 auto const click_event = mev::make_event(device_id, timestamp, mac, modifiers,122 auto const click_event = mev::make_event(device_id, timestamp, cookie, modifiers,
124 action, mir_pointer_button_tertiary,123 action, mir_pointer_button_tertiary,
125 x_axis_value, y_axis_value,124 x_axis_value, y_axis_value,
126 hscroll_value, vscroll_value,125 hscroll_value, vscroll_value,
@@ -138,11 +137,10 @@
138 auto const hscroll_value = 0.0;137 auto const hscroll_value = 0.0;
139 auto const vscroll_value = 0.0;138 auto const vscroll_value = 0.0;
140 auto const action = mir_pointer_action_motion;139 auto const action = mir_pointer_action_motion;
141 auto const mac = 0;
142 auto const relative_x_value = 0.0;140 auto const relative_x_value = 0.0;
143 auto const relative_y_value = 0.0;141 auto const relative_y_value = 0.0;
144142
145 auto const drag_event = mev::make_event(device_id, timestamp, mac, modifiers,143 auto const drag_event = mev::make_event(device_id, timestamp, cookie, modifiers,
146 action, mir_pointer_button_tertiary,144 action, mir_pointer_button_tertiary,
147 x_axis_value, y_axis_value,145 x_axis_value, y_axis_value,
148 hscroll_value, vscroll_value,146 hscroll_value, vscroll_value,
@@ -172,6 +170,7 @@
172private:170private:
173 std::shared_ptr<mtd::WrapShellToTrackLatestSurface> shell;171 std::shared_ptr<mtd::WrapShellToTrackLatestSurface> shell;
174 mt::Signal signal_change;172 mt::Signal signal_change;
173 std::vector<uint8_t> cookie;
175174
176 void init_pixel_format()175 void init_pixel_format()
177 {176 {
178177
=== modified file 'tests/include/mir/test/doubles/mock_shell.h'
--- tests/include/mir/test/doubles/mock_shell.h 2016-01-20 23:59:18 +0000
+++ tests/include/mir/test/doubles/mock_shell.h 2016-01-25 13:42:04 +0000
@@ -70,7 +70,7 @@
70 MOCK_METHOD3(get_surface_attribute, int(std::shared_ptr<frontend::Session> const& session,70 MOCK_METHOD3(get_surface_attribute, int(std::shared_ptr<frontend::Session> const& session,
71 frontend::SurfaceId surface_id, MirSurfaceAttrib attrib));71 frontend::SurfaceId surface_id, MirSurfaceAttrib attrib));
7272
73 MOCK_METHOD3(raise_surface_with_timestamp, void(std::shared_ptr<frontend::Session> const& session,73 MOCK_METHOD3(raise_surface, void(std::shared_ptr<frontend::Session> const& session,
74 frontend::SurfaceId surface_id, uint64_t timestamp));74 frontend::SurfaceId surface_id, uint64_t timestamp));
75};75};
7676
7777
=== modified file 'tests/include/mir/test/doubles/stub_display_server.h'
--- tests/include/mir/test/doubles/stub_display_server.h 2016-01-20 23:59:18 +0000
+++ tests/include/mir/test/doubles/stub_display_server.h 2016-01-25 13:42:04 +0000
@@ -134,7 +134,7 @@
134 mir::protobuf::StreamConfiguration const* /*request*/,134 mir::protobuf::StreamConfiguration const* /*request*/,
135 mir::protobuf::Void* /*response*/,135 mir::protobuf::Void* /*response*/,
136 google::protobuf::Closure* /*done*/) {}136 google::protobuf::Closure* /*done*/) {}
137 void raise_surface_with_cookie(137 void raise_surface(
138 mir::protobuf::RaiseRequest const* /*request*/,138 mir::protobuf::RaiseRequest const* /*request*/,
139 mir::protobuf::Void* /*response*/,139 mir::protobuf::Void* /*response*/,
140 google::protobuf::Closure* /*done*/) {}140 google::protobuf::Closure* /*done*/) {}
141141
=== modified file 'tests/integration-tests/CMakeLists.txt'
--- tests/integration-tests/CMakeLists.txt 2016-01-20 23:59:18 +0000
+++ tests/integration-tests/CMakeLists.txt 2016-01-25 13:42:04 +0000
@@ -6,6 +6,7 @@
6 ${CMAKE_CURRENT_BINARY_DIR}6 ${CMAKE_CURRENT_BINARY_DIR}
7 ${PROJECT_SOURCE_DIR}/include/cookie7 ${PROJECT_SOURCE_DIR}/include/cookie
8 ${PROJECT_SOURCE_DIR}/src/include/platform8 ${PROJECT_SOURCE_DIR}/src/include/platform
9 ${PROJECT_SOURCE_DIR}/src/include/cookie
9 ${PROJECT_SOURCE_DIR}/src/include/common10 ${PROJECT_SOURCE_DIR}/src/include/common
10 ${PROJECT_SOURCE_DIR}/src/include/server11 ${PROJECT_SOURCE_DIR}/src/include/server
11 ${PROJECT_SOURCE_DIR}/src/include/client12 ${PROJECT_SOURCE_DIR}/src/include/client
1213
=== modified file 'tests/integration-tests/input/test_single_seat_setup.cpp'
--- tests/integration-tests/input/test_single_seat_setup.cpp 2016-01-11 10:23:20 +0000
+++ tests/integration-tests/input/test_single_seat_setup.cpp 2016-01-25 13:42:04 +0000
@@ -27,7 +27,7 @@
27#include "mir/test/fake_shared.h"27#include "mir/test/fake_shared.h"
2828
29#include "mir/dispatch/multiplexing_dispatchable.h"29#include "mir/dispatch/multiplexing_dispatchable.h"
30#include "mir/cookie_factory.h"30#include "mir/cookie/authority.h"
3131
32#include "mir/input/cursor_listener.h"32#include "mir/input/cursor_listener.h"
33#include "mir/input/device.h"33#include "mir/input/device.h"
@@ -67,13 +67,13 @@
67 mtd::TriggeredMainLoop observer_loop;67 mtd::TriggeredMainLoop observer_loop;
68 NiceMock<mtd::MockInputDispatcher> mock_dispatcher;68 NiceMock<mtd::MockInputDispatcher> mock_dispatcher;
69 NiceMock<mtd::MockInputRegion> mock_region;69 NiceMock<mtd::MockInputRegion> mock_region;
70 std::shared_ptr<mir::cookie::CookieFactory> cookie_factory = mir::cookie::CookieFactory::create_keeping_secret();70 std::shared_ptr<mir::cookie::Authority> cookie_authority = mir::cookie::Authority::create();
71 NiceMock<MockCursorListener> mock_cursor_listener;71 NiceMock<MockCursorListener> mock_cursor_listener;
72 NiceMock<MockTouchVisualizer> mock_visualizer;72 NiceMock<MockTouchVisualizer> mock_visualizer;
73 mir::dispatch::MultiplexingDispatchable multiplexer;73 mir::dispatch::MultiplexingDispatchable multiplexer;
74 mi::DefaultInputDeviceHub hub{mt::fake_shared(mock_dispatcher), mt::fake_shared(multiplexer),74 mi::DefaultInputDeviceHub hub{mt::fake_shared(mock_dispatcher), mt::fake_shared(multiplexer),
75 mt::fake_shared(observer_loop), mt::fake_shared(mock_visualizer),75 mt::fake_shared(observer_loop), mt::fake_shared(mock_visualizer),
76 mt::fake_shared(mock_cursor_listener), mt::fake_shared(mock_region), cookie_factory};76 mt::fake_shared(mock_cursor_listener), mt::fake_shared(mock_region), cookie_authority};
77 NiceMock<mtd::MockInputDeviceObserver> mock_observer;77 NiceMock<mtd::MockInputDeviceObserver> mock_observer;
78 NiceMock<mtd::MockInputDevice> device{"device","dev-1", mi::DeviceCapability::unknown};78 NiceMock<mtd::MockInputDevice> device{"device","dev-1", mi::DeviceCapability::unknown};
79 NiceMock<mtd::MockInputDevice> another_device{"another_device","dev-2", mi::DeviceCapability::keyboard};79 NiceMock<mtd::MockInputDevice> another_device{"another_device","dev-2", mi::DeviceCapability::keyboard};
8080
=== modified file 'tests/mir_test_doubles/CMakeLists.txt'
--- tests/mir_test_doubles/CMakeLists.txt 2016-01-20 23:59:18 +0000
+++ tests/mir_test_doubles/CMakeLists.txt 2016-01-25 13:42:04 +0000
@@ -4,6 +4,7 @@
4 ${PROJECT_SOURCE_DIR}/src/include/common4 ${PROJECT_SOURCE_DIR}/src/include/common
5 ${PROJECT_SOURCE_DIR}/src/include/server5 ${PROJECT_SOURCE_DIR}/src/include/server
6 ${PROJECT_SOURCE_DIR}/src/include/client6 ${PROJECT_SOURCE_DIR}/src/include/client
7 ${PROJECT_SOURCE_DIR}/src/include/cookie
78
8 ${Boost_INCLUDE_DIRS}9 ${Boost_INCLUDE_DIRS}
9 ${CMAKE_SOURCE_DIR}10 ${CMAKE_SOURCE_DIR}
1011
=== modified file 'tests/unit-tests/CMakeLists.txt'
--- tests/unit-tests/CMakeLists.txt 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/CMakeLists.txt 2016-01-25 13:42:04 +0000
@@ -26,6 +26,7 @@
26 ${UMOCKDEV_INCLUDE_DIRS}26 ${UMOCKDEV_INCLUDE_DIRS}
2727
28 ${PROJECT_SOURCE_DIR}/include/cookie28 ${PROJECT_SOURCE_DIR}/include/cookie
29 ${PROJECT_SOURCE_DIR}/src/include/cookie
29 ${PROJECT_SOURCE_DIR}/src/include/platform30 ${PROJECT_SOURCE_DIR}/src/include/platform
30 ${PROJECT_SOURCE_DIR}/src/include/server31 ${PROJECT_SOURCE_DIR}/src/include/server
31 ${PROJECT_SOURCE_DIR}/src/include/client32 ${PROJECT_SOURCE_DIR}/src/include/client
3233
=== modified file 'tests/unit-tests/client/input/test_android_input_receiver.cpp'
--- tests/unit-tests/client/input/test_android_input_receiver.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/client/input/test_android_input_receiver.cpp 2016-01-25 13:42:04 +0000
@@ -69,7 +69,7 @@
69 testing_key_event_scan_code,69 testing_key_event_scan_code,
70 0 /* meta_state */,70 0 /* meta_state */,
71 0 /* repeat_count */,71 0 /* repeat_count */,
72 0 /* mac */,72 {{}} /* mac */,
73 std::chrono::nanoseconds(0) /* down_time */,73 std::chrono::nanoseconds(0) /* down_time */,
74 std::chrono::nanoseconds(0) /* event_time */);74 std::chrono::nanoseconds(0) /* event_time */);
75 }75 }
@@ -96,7 +96,7 @@
96 0 /* y_offset */,96 0 /* y_offset */,
97 0 /* x_precision */,97 0 /* x_precision */,
98 0 /* y_precision */,98 0 /* y_precision */,
99 0 /* mac */,99 {{}} /* mac */,
100 std::chrono::nanoseconds(0) /* down_time */,100 std::chrono::nanoseconds(0) /* down_time */,
101 t,101 t,
102 default_pointer_count,102 default_pointer_count,
103103
=== modified file 'tests/unit-tests/client/input/test_xkb_mapper.cpp'
--- tests/unit-tests/client/input/test_xkb_mapper.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/client/input/test_xkb_mapper.cpp 2016-01-25 13:42:04 +0000
@@ -35,8 +35,7 @@
3535
36static int map_key(mircv::XKBMapper &mapper, MirKeyboardAction action, int scan_code)36static int map_key(mircv::XKBMapper &mapper, MirKeyboardAction action, int scan_code)
37{37{
38 auto mac = 0;38 auto ev = mev::make_event(MirInputDeviceId(0), std::chrono::nanoseconds(0), std::vector<uint8_t>{}, action,
39 auto ev = mev::make_event(MirInputDeviceId(0), std::chrono::nanoseconds(0), mac, action,
40 0, scan_code, mir_input_event_modifier_none);39 0, scan_code, mir_input_event_modifier_none);
4140
42 mapper.update_state_and_map_event(*ev);41 mapper.update_state_and_map_event(*ev);
4342
=== modified file 'tests/unit-tests/frontend/test_event_sender.cpp'
--- tests/unit-tests/frontend/test_event_sender.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/frontend/test_event_sender.cpp 2016-01-25 13:42:04 +0000
@@ -168,8 +168,7 @@
168{168{
169 using namespace testing;169 using namespace testing;
170170
171 auto mac = 0;171 auto ev = mev::make_event(MirInputDeviceId(), std::chrono::nanoseconds(0), std::vector<uint8_t>{}, MirKeyboardAction(),
172 auto ev = mev::make_event(MirInputDeviceId(), std::chrono::nanoseconds(0), mac, MirKeyboardAction(),
173 0, 0, MirInputEventModifiers());172 0, 0, MirInputEventModifiers());
174173
175 EXPECT_CALL(mock_msg_sender, send(_, _, _))174 EXPECT_CALL(mock_msg_sender, send(_, _, _))
176175
=== modified file 'tests/unit-tests/frontend/test_session_mediator.cpp'
--- tests/unit-tests/frontend/test_session_mediator.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/frontend/test_session_mediator.cpp 2016-01-25 13:42:04 +0000
@@ -59,8 +59,7 @@
59#include "mir/test/signal.h"59#include "mir/test/signal.h"
60#include "mir/frontend/connector.h"60#include "mir/frontend/connector.h"
61#include "mir/frontend/event_sink.h"61#include "mir/frontend/event_sink.h"
62#include "mir/frontend/security_check_failed.h"62#include "mir/cookie/authority.h"
63#include "mir/cookie_factory.h"
64#include "mir_protobuf.pb.h"63#include "mir_protobuf.pb.h"
65#include "mir_protobuf_wire.pb.h"64#include "mir_protobuf_wire.pb.h"
6665
@@ -232,7 +231,7 @@
232 std::make_shared<mtd::NullMessageSender>(),231 std::make_shared<mtd::NullMessageSender>(),
233 resource_cache, stub_screencast, &connector, nullptr, nullptr,232 resource_cache, stub_screencast, &connector, nullptr, nullptr,
234 std::make_shared<mtd::NullANRDetector>(),233 std::make_shared<mtd::NullANRDetector>(),
235 mir::cookie::CookieFactory::create_keeping_secret()}234 mir::cookie::Authority::create()}
236 {235 {
237 using namespace ::testing;236 using namespace ::testing;
238237
@@ -257,7 +256,7 @@
257 resource_cache, std::make_shared<mtd::NullScreencast>(),256 resource_cache, std::make_shared<mtd::NullScreencast>(),
258 nullptr, nullptr, nullptr,257 nullptr, nullptr, nullptr,
259 std::make_shared<mtd::NullANRDetector>(),258 std::make_shared<mtd::NullANRDetector>(),
260 mir::cookie::CookieFactory::create_keeping_secret());259 mir::cookie::Authority::create());
261 }260 }
262261
263 MockConnector connector;262 MockConnector connector;
@@ -311,7 +310,7 @@
311 std::make_shared<mtd::NullMessageSender>(),310 std::make_shared<mtd::NullMessageSender>(),
312 resource_cache, stub_screencast, context, nullptr, nullptr,311 resource_cache, stub_screencast, context, nullptr, nullptr,
313 std::make_shared<mtd::NullANRDetector>(),312 std::make_shared<mtd::NullANRDetector>(),
314 mir::cookie::CookieFactory::create_keeping_secret()};313 mir::cookie::Authority::create()};
315314
316 EXPECT_THAT(connects_handled_count, Eq(0));315 EXPECT_THAT(connects_handled_count, Eq(0));
317316
@@ -855,7 +854,7 @@
855 std::make_shared<mtd::NullMessageSender>(),854 std::make_shared<mtd::NullMessageSender>(),
856 mt::fake_shared(mock_cache), stub_screencast, &connector, nullptr, nullptr,855 mt::fake_shared(mock_cache), stub_screencast, &connector, nullptr, nullptr,
857 std::make_shared<mtd::NullANRDetector>(),856 std::make_shared<mtd::NullANRDetector>(),
858 mir::cookie::CookieFactory::create_keeping_secret()};857 mir::cookie::Authority::create()};
859858
860 mediator.connect(&connect_parameters, &connection, null_callback.get());859 mediator.connect(&connect_parameters, &connection, null_callback.get());
861 mediator.create_surface(&surface_parameters, &surface_response, null_callback.get());860 mediator.create_surface(&surface_parameters, &surface_response, null_callback.get());
@@ -969,7 +968,7 @@
969 nullptr,968 nullptr,
970 nullptr,969 nullptr,
971 std::make_shared<mtd::NullANRDetector>(),970 std::make_shared<mtd::NullANRDetector>(),
972 mir::cookie::CookieFactory::create_keeping_secret()};971 mir::cookie::Authority::create()};
973972
974 mp::Void null;973 mp::Void null;
975 mp::BufferRequest request;974 mp::BufferRequest request;
@@ -1060,7 +1059,7 @@
1060 std::make_shared<mtd::NullMessageSender>(),1059 std::make_shared<mtd::NullMessageSender>(),
1061 resource_cache, stub_screencast, nullptr, nullptr, nullptr,1060 resource_cache, stub_screencast, nullptr, nullptr, nullptr,
1062 std::make_shared<mtd::NullANRDetector>(),1061 std::make_shared<mtd::NullANRDetector>(),
1063 mir::cookie::CookieFactory::create_keeping_secret()};1062 mir::cookie::Authority::create()};
10641063
1065 mp::Void null;1064 mp::Void null;
1066 mp::BufferRequest request;1065 mp::BufferRequest request;
@@ -1204,7 +1203,7 @@
1204 mock_sender,1203 mock_sender,
1205 resource_cache, stub_screencast, nullptr, nullptr, nullptr,1204 resource_cache, stub_screencast, nullptr, nullptr, nullptr,
1206 std::make_shared<mtd::NullANRDetector>(),1205 std::make_shared<mtd::NullANRDetector>(),
1207 mir::cookie::CookieFactory::create_keeping_secret()};1206 mir::cookie::Authority::create()};
12081207
1209 ON_CALL(*shell, create_surface( _, _, _))1208 ON_CALL(*shell, create_surface( _, _, _))
1210 .WillByDefault(1209 .WillByDefault(
@@ -1308,6 +1307,6 @@
1308 mediator.connect(&connect_parameters, &connection, null_callback.get());1307 mediator.connect(&connect_parameters, &connection, null_callback.get());
13091308
1310 EXPECT_THROW({1309 EXPECT_THROW({
1311 mediator.raise_surface_with_cookie(&raise_request, &void_response, null_callback.get());1310 mediator.raise_surface(&raise_request, &void_response, null_callback.get());
1312 }, mir::SecurityCheckFailed);1311 }, mir::cookie::SecurityCheckError);
1313}1312}
13141313
=== modified file 'tests/unit-tests/input/android/test_android_input_lexicon.cpp'
--- tests/unit-tests/input/android/test_android_input_lexicon.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/input/android/test_android_input_lexicon.cpp 2016-01-25 13:42:04 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19#include "mir/input/android/android_input_lexicon.h"19#include "mir/input/android/android_input_lexicon.h"
20#include "mir/cookie/blob.h"
2021
21#include <androidfw/Input.h>22#include <androidfw/Input.h>
2223
@@ -39,13 +40,13 @@
39 const int32_t scan_code = 6;40 const int32_t scan_code = 6;
40 const int32_t meta_state = AMETA_ALT_ON;41 const int32_t meta_state = AMETA_ALT_ON;
41 const int32_t repeat_count = 0;42 const int32_t repeat_count = 0;
42 const uint64_t mac = 11;43 const mir::cookie::Blob cookie{{14}};
43 auto const down_time = std::chrono::nanoseconds(9);44 auto const down_time = std::chrono::nanoseconds(9);
44 auto const event_time = std::chrono::nanoseconds(10);45 auto const event_time = std::chrono::nanoseconds(10);
4546
46 android_key_ev->initialize(device_id, source_id, action, flags, key_code,47 android_key_ev->initialize(device_id, source_id, action, flags, key_code,
47 scan_code, meta_state, repeat_count,48 scan_code, meta_state, repeat_count,
48 mac, down_time, event_time);49 cookie, down_time, event_time);
4950
50 auto mir_ev = mia::Lexicon::translate(android_key_ev);51 auto mir_ev = mia::Lexicon::translate(android_key_ev);
5152
@@ -62,8 +63,6 @@
62 EXPECT_EQ(key_code, mir_keyboard_event_key_code(kev));63 EXPECT_EQ(key_code, mir_keyboard_event_key_code(kev));
63 EXPECT_EQ(scan_code, mir_keyboard_event_scan_code(kev));64 EXPECT_EQ(scan_code, mir_keyboard_event_scan_code(kev));
6465
65 // FIXME Test the mac value once the public API has landed in 0.19
66
67 delete android_key_ev;66 delete android_key_ev;
68}67}
6968
@@ -84,7 +83,7 @@
84 const float y_offset = 9;83 const float y_offset = 9;
85 const float x_precision = 10;84 const float x_precision = 10;
86 const float y_precision = 11;85 const float y_precision = 11;
87 const uint64_t mac = 14;86 const mir::cookie::Blob cookie{{14}};
88 auto const down_time = std::chrono::nanoseconds(12);87 auto const down_time = std::chrono::nanoseconds(12);
89 auto const event_time = std::chrono::nanoseconds(13);88 auto const event_time = std::chrono::nanoseconds(13);
90 const size_t pointer_count = 1;89 const size_t pointer_count = 1;
@@ -115,7 +114,7 @@
115114
116 android_motion_ev->initialize(device_id, source_id, action, flags, edge_flags,115 android_motion_ev->initialize(device_id, source_id, action, flags, edge_flags,
117 meta_state, button_state, x_offset, y_offset,116 meta_state, button_state, x_offset, y_offset,
118 x_precision, y_precision, mac, down_time,117 x_precision, y_precision, cookie, down_time,
119 event_time, pointer_count, &pointer_properties, &pointer_coords);118 event_time, pointer_count, &pointer_properties, &pointer_coords);
120119
121 auto mir_ev = mia::Lexicon::translate(android_motion_ev);120 auto mir_ev = mia::Lexicon::translate(android_motion_ev);
@@ -130,7 +129,6 @@
130129
131 auto tev = mir_input_event_get_touch_event(iev);130 auto tev = mir_input_event_get_touch_event(iev);
132 EXPECT_EQ(pointer_count, mir_touch_event_point_count(tev));131 EXPECT_EQ(pointer_count, mir_touch_event_point_count(tev));
133 // FIXME Test the mac value once the public API has landed in 0.19
134 132
135 EXPECT_EQ(pointer_id, mir_touch_event_id(tev, 0));133 EXPECT_EQ(pointer_id, mir_touch_event_id(tev, 0));
136 // Notice these two coordinates are offset by x/y offset134 // Notice these two coordinates are offset by x/y offset
@@ -161,7 +159,7 @@
161 const float y_offset = 9;159 const float y_offset = 9;
162 const float x_precision = 10;160 const float x_precision = 10;
163 const float y_precision = 11;161 const float y_precision = 11;
164 const uint64_t mac = 14;162 const mir::cookie::Blob cookie{{14}};
165 const std::chrono::nanoseconds down_time = std::chrono::nanoseconds(12);163 const std::chrono::nanoseconds down_time = std::chrono::nanoseconds(12);
166 const std::chrono::nanoseconds event_time = std::chrono::nanoseconds(13);164 const std::chrono::nanoseconds event_time = std::chrono::nanoseconds(13);
167 const size_t pointer_count = 2;165 const size_t pointer_count = 2;
@@ -203,7 +201,7 @@
203 android_motion_ev->initialize(device_id, source_id, action, flags,201 android_motion_ev->initialize(device_id, source_id, action, flags,
204 edge_flags, meta_state, 0,202 edge_flags, meta_state, 0,
205 x_offset, y_offset, x_precision, y_precision,203 x_offset, y_offset, x_precision, y_precision,
206 mac, down_time, event_time, pointer_count,204 cookie, down_time, event_time, pointer_count,
207 pointer_properties, pointer_coords);205 pointer_properties, pointer_coords);
208206
209 auto mir_ev = mia::Lexicon::translate(android_motion_ev);207 auto mir_ev = mia::Lexicon::translate(android_motion_ev);
@@ -218,7 +216,6 @@
218216
219 auto tev = mir_input_event_get_touch_event(iev);217 auto tev = mir_input_event_get_touch_event(iev);
220 EXPECT_EQ(pointer_count, mir_touch_event_point_count(tev));218 EXPECT_EQ(pointer_count, mir_touch_event_point_count(tev));
221 // FIXME Test the mac value once the public API has landed in 0.19
222219
223 for (unsigned i = 0; i < pointer_count; i++)220 for (unsigned i = 0; i < pointer_count; i++)
224 {221 {
225222
=== modified file 'tests/unit-tests/input/android/test_android_input_sender.cpp'
--- tests/unit-tests/input/android/test_android_input_sender.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/input/android/test_android_input_sender.cpp 2016-01-25 13:42:04 +0000
@@ -31,11 +31,13 @@
31#include "mir/test/fake_shared.h"31#include "mir/test/fake_shared.h"
32#include "mir/test/event_matchers.h"32#include "mir/test/event_matchers.h"
3333
34
34#include "androidfw/Input.h"35#include "androidfw/Input.h"
35#include "androidfw/InputTransport.h"36#include "androidfw/InputTransport.h"
3637
37#include "mir/input/input_report.h"38#include "mir/input/input_report.h"
38#include "mir/cookie_factory.h"39#include "mir/cookie/authority.h"
40#include "mir/cookie/blob.h"
3941
40#include <gtest/gtest.h>42#include <gtest/gtest.h>
41#include <gmock/gmock.h>43#include <gmock/gmock.h>
@@ -89,15 +91,6 @@
8991
90 std::shared_ptr<ms::Observer> observer;92 std::shared_ptr<ms::Observer> observer;
91};93};
92
93class StubCookieFactory : public mir::cookie::CookieFactory
94{
95public:
96 MirCookie timestamp_to_cookie(uint64_t const&) override { return {0, 0};}
97 bool attest_timestamp(MirCookie const&) override {return true;}
98 StubCookieFactory() = default;
99};
100
101}94}
10295
103class AndroidInputSender : public ::testing::Test96class AndroidInputSender : public ::testing::Test
@@ -113,11 +106,13 @@
113 float const minor = 4;106 float const minor = 4;
114 float const size = 8;107 float const size = 8;
115 mir::geometry::Displacement const movement{10, -10};108 mir::geometry::Displacement const movement{10, -10};
116 StubCookieFactory cookie_factory;109 std::shared_ptr<mir::cookie::Authority> const cookie_authority;
117 mi::DefaultEventBuilder builder{MirInputDeviceId(), mt::fake_shared(cookie_factory)};110 mi::DefaultEventBuilder builder;
118111
119 AndroidInputSender()112 AndroidInputSender()
120 : key_event(builder.key_event(std::chrono::nanoseconds(1), mir_keyboard_action_down, 7, test_scan_code)),113 : cookie_authority(mir::cookie::Authority::create_from({0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88})),
114 builder(MirInputDeviceId(), cookie_authority),
115 key_event(builder.key_event(std::chrono::nanoseconds(1), mir_keyboard_action_down, 7, test_scan_code)),
121 motion_event(builder.touch_event(std::chrono::nanoseconds(-1))),116 motion_event(builder.touch_event(std::chrono::nanoseconds(-1))),
122 pointer_event(builder.pointer_event(std::chrono::nanoseconds(123), mir_pointer_action_motion,117 pointer_event(builder.pointer_event(std::chrono::nanoseconds(123), mir_pointer_action_motion,
123 mir_pointer_button_primary, 0.0f, 0.0f,118 mir_pointer_button_primary, 0.0f, 0.0f,
124119
=== modified file 'tests/unit-tests/input/evdev/test_libinput_device.cpp'
--- tests/unit-tests/input/evdev/test_libinput_device.cpp 2016-01-21 22:09:00 +0000
+++ tests/unit-tests/input/evdev/test_libinput_device.cpp 2016-01-25 13:42:04 +0000
@@ -31,7 +31,7 @@
31#include "mir/test/doubles/mock_libinput.h"31#include "mir/test/doubles/mock_libinput.h"
32#include "mir/test/gmock_fixes.h"32#include "mir/test/gmock_fixes.h"
33#include "mir/udev/wrapper.h"33#include "mir/udev/wrapper.h"
34#include "mir/cookie_factory.h"34#include "mir/cookie/authority.h"
35#include "mir_test_framework/udev_environment.h"35#include "mir_test_framework/udev_environment.h"
3636
37#include <gmock/gmock.h>37#include <gmock/gmock.h>
@@ -74,8 +74,8 @@
7474
75struct MockEventBuilder : mi::EventBuilder75struct MockEventBuilder : mi::EventBuilder
76{76{
77 std::shared_ptr<mir::cookie::CookieFactory> const cookie_factory = mir::cookie::CookieFactory::create_keeping_secret();77 std::shared_ptr<mir::cookie::Authority> const cookie_authority = mir::cookie::Authority::create();
78 mi::DefaultEventBuilder builder{MirInputDeviceId{3}, cookie_factory};78 mi::DefaultEventBuilder builder{MirInputDeviceId{3}, cookie_authority};
79 MockEventBuilder()79 MockEventBuilder()
80 {80 {
81 ON_CALL(*this, key_event(_,_,_,_))81 ON_CALL(*this, key_event(_,_,_,_))
8282
=== modified file 'tests/unit-tests/input/test_default_input_device_hub.cpp'
--- tests/unit-tests/input/test_default_input_device_hub.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/input/test_default_input_device_hub.cpp 2016-01-25 13:42:04 +0000
@@ -28,11 +28,11 @@
28#include "mir/test/event_matchers.h"28#include "mir/test/event_matchers.h"
29#include "mir/test/fake_shared.h"29#include "mir/test/fake_shared.h"
3030
31#include "mir/cookie_factory.h"
32#include "mir/dispatch/action_queue.h"31#include "mir/dispatch/action_queue.h"
33#include "mir/dispatch/multiplexing_dispatchable.h"32#include "mir/dispatch/multiplexing_dispatchable.h"
34#include "mir/events/event_builders.h"33#include "mir/events/event_builders.h"
35#include "mir/input/cursor_listener.h"34#include "mir/input/cursor_listener.h"
35#include "mir/cookie/authority.h"
36#include "mir/input/device.h"36#include "mir/input/device.h"
37#include "mir/input/input_device.h"37#include "mir/input/input_device.h"
3838
@@ -54,13 +54,13 @@
54 mtd::TriggeredMainLoop observer_loop;54 mtd::TriggeredMainLoop observer_loop;
55 Nice<mtd::MockInputDispatcher> mock_dispatcher;55 Nice<mtd::MockInputDispatcher> mock_dispatcher;
56 Nice<mtd::MockInputRegion> mock_region;56 Nice<mtd::MockInputRegion> mock_region;
57 std::shared_ptr<mir::cookie::CookieFactory> cookie_factory = mir::cookie::CookieFactory::create_keeping_secret();57 std::shared_ptr<mir::cookie::Authority> cookie_authority = mir::cookie::Authority::create();
58 mtd::StubCursorListener stub_cursor_listener;58 mtd::StubCursorListener stub_cursor_listener;
59 mtd::StubTouchVisualizer stub_visualizer;59 mtd::StubTouchVisualizer stub_visualizer;
60 mir::dispatch::MultiplexingDispatchable multiplexer;60 mir::dispatch::MultiplexingDispatchable multiplexer;
61 mi::DefaultInputDeviceHub hub{mt::fake_shared(mock_dispatcher), mt::fake_shared(multiplexer),61 mi::DefaultInputDeviceHub hub{mt::fake_shared(mock_dispatcher), mt::fake_shared(multiplexer),
62 mt::fake_shared(observer_loop), mt::fake_shared(stub_visualizer),62 mt::fake_shared(observer_loop), mt::fake_shared(stub_visualizer),
63 mt::fake_shared(stub_cursor_listener), mt::fake_shared(mock_region), cookie_factory};63 mt::fake_shared(stub_cursor_listener), mt::fake_shared(mock_region), cookie_authority};
64 Nice<mtd::MockInputDeviceObserver> mock_observer;64 Nice<mtd::MockInputDeviceObserver> mock_observer;
65 Nice<mtd::MockInputDevice> device{"device","dev-1", mi::DeviceCapability::unknown};65 Nice<mtd::MockInputDevice> device{"device","dev-1", mi::DeviceCapability::unknown};
66 Nice<mtd::MockInputDevice> another_device{"another_device","dev-2", mi::DeviceCapability::keyboard};66 Nice<mtd::MockInputDevice> another_device{"another_device","dev-2", mi::DeviceCapability::keyboard};
6767
=== modified file 'tests/unit-tests/input/test_event_builders.cpp'
--- tests/unit-tests/input/test_event_builders.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/input/test_event_builders.cpp 2016-01-25 13:42:04 +0000
@@ -29,7 +29,7 @@
29{29{
30 MirInputDeviceId const device_id = 7;30 MirInputDeviceId const device_id = 7;
31 std::chrono::nanoseconds const timestamp = std::chrono::nanoseconds(39);31 std::chrono::nanoseconds const timestamp = std::chrono::nanoseconds(39);
32 uint64_t const mac = 12;32 std::vector<uint8_t> const cookie{};
33 MirInputEventModifiers const modifiers = mir_input_event_modifier_meta;33 MirInputEventModifiers const modifiers = mir_input_event_modifier_meta;
34};34};
35}35}
@@ -41,7 +41,7 @@
41 int const scan_code = 17;41 int const scan_code = 17;
4242
43 auto ev = mev::make_event(device_id, timestamp,43 auto ev = mev::make_event(device_id, timestamp,
44 mac, action, key_code, scan_code, modifiers);44 cookie, action, key_code, scan_code, modifiers);
45 auto e = ev.get();45 auto e = ev.get();
4646
47 EXPECT_EQ(mir_event_type_input, mir_event_get_type(e));47 EXPECT_EQ(mir_event_type_input, mir_event_get_type(e));
@@ -52,7 +52,6 @@
52 EXPECT_EQ(key_code, mir_keyboard_event_key_code(kev));52 EXPECT_EQ(key_code, mir_keyboard_event_key_code(kev));
53 EXPECT_EQ(scan_code, mir_keyboard_event_scan_code(kev));53 EXPECT_EQ(scan_code, mir_keyboard_event_scan_code(kev));
54 EXPECT_EQ(modifiers, mir_keyboard_event_modifiers(kev));54 EXPECT_EQ(modifiers, mir_keyboard_event_modifiers(kev));
55 // FIXME Test the mac value once the public API has landed in 0.19
56}55}
5756
58TEST_F(InputEventBuilder, makes_valid_touch_event)57TEST_F(InputEventBuilder, makes_valid_touch_event)
@@ -69,7 +68,7 @@
69 float size_values[] = {4, 9, 6};68 float size_values[] = {4, 9, 6};
7069
71 auto ev = mev::make_event(device_id, timestamp,70 auto ev = mev::make_event(device_id, timestamp,
72 mac, modifiers);71 cookie, modifiers);
73 for (unsigned i = 0; i < touch_count; i++)72 for (unsigned i = 0; i < touch_count; i++)
74 {73 {
75 mev::add_touch(*ev, touch_ids[i], actions[i], tooltypes[i], x_axis_values[i], y_axis_values[i],74 mev::add_touch(*ev, touch_ids[i], actions[i], tooltypes[i], x_axis_values[i], y_axis_values[i],
@@ -83,7 +82,6 @@
83 auto tev = mir_input_event_get_touch_event(ie);82 auto tev = mir_input_event_get_touch_event(ie);
84 EXPECT_EQ(modifiers, mir_touch_event_modifiers(tev));83 EXPECT_EQ(modifiers, mir_touch_event_modifiers(tev));
85 EXPECT_EQ(touch_count, mir_touch_event_point_count(tev));84 EXPECT_EQ(touch_count, mir_touch_event_point_count(tev));
86 // FIXME Test the mac value once the public API has landed in 0.19
8785
88 for (unsigned i = 0; i < touch_count; i++)86 for (unsigned i = 0; i < touch_count; i++)
89 {87 {
@@ -106,7 +104,7 @@
106 float x_axis_value = 3.9, y_axis_value = 7.4, hscroll_value = .9, vscroll_value = .3;104 float x_axis_value = 3.9, y_axis_value = 7.4, hscroll_value = .9, vscroll_value = .3;
107 auto const relative_x_value = 0.0;105 auto const relative_x_value = 0.0;
108 auto const relative_y_value = 0.0;106 auto const relative_y_value = 0.0;
109 auto ev = mev::make_event(device_id, timestamp, mac, modifiers, 107 auto ev = mev::make_event(device_id, timestamp, cookie, modifiers,
110 action, depressed_buttons, x_axis_value, y_axis_value,108 action, depressed_buttons, x_axis_value, y_axis_value,
111 hscroll_value, vscroll_value, relative_x_value, relative_y_value);109 hscroll_value, vscroll_value, relative_x_value, relative_y_value);
112 auto e = ev.get();110 auto e = ev.get();
@@ -117,7 +115,6 @@
117 auto pev = mir_input_event_get_pointer_event(ie);115 auto pev = mir_input_event_get_pointer_event(ie);
118 EXPECT_EQ(modifiers, mir_pointer_event_modifiers(pev));116 EXPECT_EQ(modifiers, mir_pointer_event_modifiers(pev));
119 EXPECT_EQ(action, mir_pointer_event_action(pev));117 EXPECT_EQ(action, mir_pointer_event_action(pev));
120 // FIXME Test the mac value once the public API has landed in 0.19
121 EXPECT_TRUE(mir_pointer_event_button_state(pev, mir_pointer_button_back));118 EXPECT_TRUE(mir_pointer_event_button_state(pev, mir_pointer_button_back));
122 EXPECT_TRUE(mir_pointer_event_button_state(pev, mir_pointer_button_tertiary));119 EXPECT_TRUE(mir_pointer_event_button_state(pev, mir_pointer_button_tertiary));
123 EXPECT_FALSE(mir_pointer_event_button_state(pev, mir_pointer_button_primary));120 EXPECT_FALSE(mir_pointer_event_button_state(pev, mir_pointer_button_primary));
@@ -136,7 +133,7 @@
136{133{
137 MirTouchAction action = mir_touch_action_down;134 MirTouchAction action = mir_touch_action_down;
138135
139 auto ev = mev::make_event(device_id, timestamp, mac, modifiers);136 auto ev = mev::make_event(device_id, timestamp, cookie, modifiers);
140 mev::add_touch(*ev, 0, action, mir_touch_tooltype_finger, 0, 0, 0, 0, 0, 0);137 mev::add_touch(*ev, 0, action, mir_touch_tooltype_finger, 0, 0, 0, 0, 0, 0);
141 auto e = ev.get();138 auto e = ev.get();
142139
@@ -152,7 +149,7 @@
152{149{
153 MirTouchAction action = mir_touch_action_up;150 MirTouchAction action = mir_touch_action_up;
154151
155 auto ev = mev::make_event(device_id, timestamp, mac, modifiers);152 auto ev = mev::make_event(device_id, timestamp, cookie, modifiers);
156 mev::add_touch(*ev, 0, action, mir_touch_tooltype_finger, 0, 0, 0, 0, 0, 0);153 mev::add_touch(*ev, 0, action, mir_touch_tooltype_finger, 0, 0, 0, 0, 0, 0);
157 auto e = ev.get();154 auto e = ev.get();
158155
@@ -162,7 +159,6 @@
162 auto tev = mir_input_event_get_touch_event(ie);159 auto tev = mir_input_event_get_touch_event(ie);
163160
164 EXPECT_EQ(action, mir_touch_event_action(tev, 0));161 EXPECT_EQ(action, mir_touch_event_action(tev, 0));
165 // FIXME Test the mac value once the public API has landed in 0.19
166}162}
167163
168TEST_F(InputEventBuilder, map_to_hover_if_no_button_pressed)164TEST_F(InputEventBuilder, map_to_hover_if_no_button_pressed)
@@ -171,7 +167,7 @@
171 auto const relative_x_value = 0.0;167 auto const relative_x_value = 0.0;
172 auto const relative_y_value = 0.0;168 auto const relative_y_value = 0.0;
173 MirPointerAction action = mir_pointer_action_motion;169 MirPointerAction action = mir_pointer_action_motion;
174 auto ev = mev::make_event(device_id, timestamp, mac, modifiers,170 auto ev = mev::make_event(device_id, timestamp, cookie, modifiers,
175 action, 0, x_axis_value, y_axis_value,171 action, 0, x_axis_value, y_axis_value,
176 hscroll_value, vscroll_value, relative_x_value, relative_y_value);172 hscroll_value, vscroll_value, relative_x_value, relative_y_value);
177 auto e = ev.get();173 auto e = ev.get();
@@ -181,5 +177,4 @@
181 auto pev = mir_input_event_get_pointer_event(ie);177 auto pev = mir_input_event_get_pointer_event(ie);
182 EXPECT_EQ(modifiers, mir_pointer_event_modifiers(pev));178 EXPECT_EQ(modifiers, mir_pointer_event_modifiers(pev));
183 EXPECT_EQ(action, mir_pointer_event_action(pev));179 EXPECT_EQ(action, mir_pointer_event_action(pev));
184 // FIXME Test the mac value once the public API has landed in 0.19
185}180}
186181
=== modified file 'tests/unit-tests/input/test_event_filter_chain_dispatcher.cpp'
--- tests/unit-tests/input/test_event_filter_chain_dispatcher.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/input/test_event_filter_chain_dispatcher.cpp 2016-01-25 13:42:04 +0000
@@ -43,7 +43,7 @@
43struct EventFilterChainDispatcher : public ::testing::Test43struct EventFilterChainDispatcher : public ::testing::Test
44{44{
45 mir::EventUPtr const event = mir::events::make_event(MirInputDeviceId(),45 mir::EventUPtr const event = mir::events::make_event(MirInputDeviceId(),
46 std::chrono::nanoseconds(0), 0, MirKeyboardAction(),46 std::chrono::nanoseconds(0), std::vector<uint8_t>{}, MirKeyboardAction(),
47 xkb_keysym_t(), 0, MirInputEventModifiers());47 xkb_keysym_t(), 0, MirInputEventModifiers());
48};48};
49}49}
5050
=== modified file 'tests/unit-tests/input/test_key_repeat_dispatcher.cpp'
--- tests/unit-tests/input/test_key_repeat_dispatcher.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/input/test_key_repeat_dispatcher.cpp 2016-01-25 13:42:04 +0000
@@ -22,7 +22,7 @@
22#include "mir/events/event_builders.h"22#include "mir/events/event_builders.h"
23#include "mir/time/alarm.h"23#include "mir/time/alarm.h"
24#include "mir/time/alarm_factory.h"24#include "mir/time/alarm_factory.h"
25#include "mir/cookie_factory.h"25#include "mir/cookie/authority.h"
2626
27#include "mir/test/event_matchers.h"27#include "mir/test/event_matchers.h"
28#include "mir/test/doubles/mock_input_dispatcher.h"28#include "mir/test/doubles/mock_input_dispatcher.h"
@@ -62,12 +62,12 @@
62struct KeyRepeatDispatcher : public testing::Test62struct KeyRepeatDispatcher : public testing::Test
63{63{
64 KeyRepeatDispatcher()64 KeyRepeatDispatcher()
65 : dispatcher(mock_next_dispatcher, mock_alarm_factory, cookie_factory, true, repeat_time, repeat_delay)65 : dispatcher(mock_next_dispatcher, mock_alarm_factory, cookie_authority, true, repeat_time, repeat_delay)
66 {66 {
67 }67 }
68 std::shared_ptr<mtd::MockInputDispatcher> mock_next_dispatcher = std::make_shared<mtd::MockInputDispatcher>();68 std::shared_ptr<mtd::MockInputDispatcher> mock_next_dispatcher = std::make_shared<mtd::MockInputDispatcher>();
69 std::shared_ptr<MockAlarmFactory> mock_alarm_factory = std::make_shared<MockAlarmFactory>();69 std::shared_ptr<MockAlarmFactory> mock_alarm_factory = std::make_shared<MockAlarmFactory>();
70 std::shared_ptr<mir::cookie::CookieFactory> cookie_factory = mir::cookie::CookieFactory::create_keeping_secret();70 std::shared_ptr<mir::cookie::Authority> cookie_authority = mir::cookie::Authority::create();
71 std::chrono::milliseconds const repeat_time{2};71 std::chrono::milliseconds const repeat_time{2};
72 std::chrono::milliseconds const repeat_delay{1};72 std::chrono::milliseconds const repeat_delay{1};
73 mi::KeyRepeatDispatcher dispatcher;73 mi::KeyRepeatDispatcher dispatcher;
@@ -90,11 +90,11 @@
90{90{
91mir::EventUPtr a_key_down_event()91mir::EventUPtr a_key_down_event()
92{92{
93 return mev::make_event(0, std::chrono::nanoseconds(0), 0, mir_keyboard_action_down, 0, 0, mir_input_event_modifier_alt);93 return mev::make_event(0, std::chrono::nanoseconds(0), std::vector<uint8_t>{}, mir_keyboard_action_down, 0, 0, mir_input_event_modifier_alt);
94}94}
95mir::EventUPtr a_key_up_event()95mir::EventUPtr a_key_up_event()
96{96{
97 return mev::make_event(0, std::chrono::nanoseconds(0), 0, mir_keyboard_action_up, 0, 0, mir_input_event_modifier_alt);97 return mev::make_event(0, std::chrono::nanoseconds(0), std::vector<uint8_t>{}, mir_keyboard_action_up, 0, 0, mir_input_event_modifier_alt);
98}98}
99}99}
100100
101101
=== modified file 'tests/unit-tests/input/test_surface_input_dispatcher.cpp'
--- tests/unit-tests/input/test_surface_input_dispatcher.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/input/test_surface_input_dispatcher.cpp 2016-01-25 13:42:04 +0000
@@ -138,12 +138,12 @@
138 }138 }
139 mir::EventUPtr press(int scan_code = 7)139 mir::EventUPtr press(int scan_code = 7)
140 {140 {
141 return mev::make_event(id, std::chrono::nanoseconds(0), 0,141 return mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{},
142 mir_keyboard_action_down, 0, scan_code, mir_input_event_modifier_alt);142 mir_keyboard_action_down, 0, scan_code, mir_input_event_modifier_alt);
143 }143 }
144 mir::EventUPtr release(int scan_code = 7)144 mir::EventUPtr release(int scan_code = 7)
145 {145 {
146 return mev::make_event(id, std::chrono::nanoseconds(0), 0,146 return mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{},
147 mir_keyboard_action_up, 0, scan_code, mir_input_event_modifier_alt);147 mir_keyboard_action_up, 0, scan_code, mir_input_event_modifier_alt);
148 }148 }
149 MirInputDeviceId const id;149 MirInputDeviceId const id;
@@ -159,7 +159,7 @@
159159
160 mir::EventUPtr move_to(geom::Point const& location)160 mir::EventUPtr move_to(geom::Point const& location)
161 {161 {
162 return mev::make_event(id, std::chrono::nanoseconds(0), 0,162 return mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{},
163 0, mir_pointer_action_motion, buttons,163 0, mir_pointer_action_motion, buttons,
164 location.x.as_int(), location.y.as_int(),164 location.x.as_int(), location.y.as_int(),
165 0, 0, 0, 0);165 0, 0, 0, 0);
@@ -168,7 +168,7 @@
168 {168 {
169 buttons &= ~button;169 buttons &= ~button;
170170
171 return mev::make_event(id, std::chrono::nanoseconds(0), 0,171 return mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{},
172 0, mir_pointer_action_button_up, buttons,172 0, mir_pointer_action_button_up, buttons,
173 location.x.as_int(), location.y.as_int(),173 location.x.as_int(), location.y.as_int(),
174 0, 0, 0, 0);174 0, 0, 0, 0);
@@ -177,7 +177,7 @@
177 {177 {
178 buttons |= button;178 buttons |= button;
179 179
180 return mev::make_event(id, std::chrono::nanoseconds(0), 0,180 return mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{},
181 0, mir_pointer_action_button_down, buttons,181 0, mir_pointer_action_button_down, buttons,
182 location.x.as_int(), location.y.as_int(),182 location.x.as_int(), location.y.as_int(),
183 0, 0, 0, 0);183 0, 0, 0, 0);
@@ -196,7 +196,7 @@
196 196
197 mir::EventUPtr move_to(geom::Point const& point)197 mir::EventUPtr move_to(geom::Point const& point)
198 {198 {
199 auto ev = mev::make_event(id, std::chrono::nanoseconds(0), 0, 0);199 auto ev = mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{}, 0);
200 mev::add_touch(*ev, 0, mir_touch_action_change,200 mev::add_touch(*ev, 0, mir_touch_action_change,
201 mir_touch_tooltype_finger, point.x.as_int(), point.y.as_int(),201 mir_touch_tooltype_finger, point.x.as_int(), point.y.as_int(),
202 touched ? 1.0 : 0.0,202 touched ? 1.0 : 0.0,
@@ -209,7 +209,7 @@
209 {209 {
210 touched = true;210 touched = true;
211 211
212 auto ev = mev::make_event(id, std::chrono::nanoseconds(0), 0, 0);212 auto ev = mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{}, 0);
213 mev::add_touch(*ev, 0, mir_touch_action_down,213 mev::add_touch(*ev, 0, mir_touch_action_down,
214 mir_touch_tooltype_finger, point.x.as_int(), point.y.as_int(),214 mir_touch_tooltype_finger, point.x.as_int(), point.y.as_int(),
215 1.0, 1.0, 1.0, 1.0);215 1.0, 1.0, 1.0, 1.0);
@@ -219,7 +219,7 @@
219 {219 {
220 touched = true;220 touched = true;
221221
222 auto ev = mev::make_event(id, std::chrono::nanoseconds(0), 0, 0);222 auto ev = mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{}, 0);
223 mev::add_touch(*ev, 0, mir_touch_action_down,223 mev::add_touch(*ev, 0, mir_touch_action_down,
224 mir_touch_tooltype_finger, point1.x.as_int(), point1.y.as_int(),224 mir_touch_tooltype_finger, point1.x.as_int(), point1.y.as_int(),
225 1.0, 1.0, 1.0, 1.0);225 1.0, 1.0, 1.0, 1.0);
@@ -232,7 +232,7 @@
232 {232 {
233 touched = false;233 touched = false;
234 234
235 auto ev = mev::make_event(id, std::chrono::nanoseconds(0), 0, 0);235 auto ev = mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{}, 0);
236 mev::add_touch(*ev, 0, mir_touch_action_up,236 mev::add_touch(*ev, 0, mir_touch_action_up,
237 mir_touch_tooltype_finger, point.x.as_int(), point.y.as_int(),237 mir_touch_tooltype_finger, point.x.as_int(), point.y.as_int(),
238 0.0, 0.0, 0.0, 0.0);238 0.0, 0.0, 0.0, 0.0);
@@ -242,7 +242,7 @@
242 {242 {
243 touched = false;243 touched = false;
244244
245 auto ev = mev::make_event(id, std::chrono::nanoseconds(0), 0, 0);245 auto ev = mev::make_event(id, std::chrono::nanoseconds(0), std::vector<uint8_t>{}, 0);
246 mev::add_touch(*ev, 0, mir_touch_action_up,246 mev::add_touch(*ev, 0, mir_touch_action_up,
247 mir_touch_tooltype_finger, point1.x.as_int(), point1.y.as_int(),247 mir_touch_tooltype_finger, point1.x.as_int(), point1.y.as_int(),
248 1.0, 1.0, 1.0, 1.0);248 1.0, 1.0, 1.0, 1.0);
249249
=== modified file 'tests/unit-tests/input/test_validator.cpp'
--- tests/unit-tests/input/test_validator.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/input/test_validator.cpp 2016-01-25 13:42:04 +0000
@@ -67,7 +67,7 @@
67mir::EventUPtr make_touch(MirTouchId id, MirTouchAction action)67mir::EventUPtr make_touch(MirTouchId id, MirTouchAction action)
68{68{
69 auto ev = mev::make_event(MirInputDeviceId(0), std::chrono::nanoseconds(0),69 auto ev = mev::make_event(MirInputDeviceId(0), std::chrono::nanoseconds(0),
70 0, mir_input_event_modifier_none);70 std::vector<uint8_t>{}, mir_input_event_modifier_none);
71 add_another_touch(ev, id, action);71 add_another_touch(ev, id, action);
72 return ev;72 return ev;
73}73}
7474
=== modified file 'tests/unit-tests/input/test_x11_platform.cpp'
--- tests/unit-tests/input/test_x11_platform.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/input/test_x11_platform.cpp 2016-01-25 13:42:04 +0000
@@ -32,7 +32,7 @@
32#include "mir/test/doubles/mock_x11.h"32#include "mir/test/doubles/mock_x11.h"
33#include "mir/test/doubles/mock_x11.h"33#include "mir/test/doubles/mock_x11.h"
34#include "mir/test/fake_shared.h"34#include "mir/test/fake_shared.h"
35#include "mir/cookie_factory.h"35#include "mir/cookie/authority.h"
36#include "mir/test/event_matchers.h"36#include "mir/test/event_matchers.h"
3737
38namespace md = mir::dispatch;38namespace md = mir::dispatch;
@@ -51,7 +51,7 @@
51 NiceMock<mtd::MockInputSink> mock_keyboard_sink;51 NiceMock<mtd::MockInputSink> mock_keyboard_sink;
52 NiceMock<mtd::MockX11> mock_x11;52 NiceMock<mtd::MockX11> mock_x11;
53 NiceMock<mtd::MockInputDeviceRegistry> mock_registry;53 NiceMock<mtd::MockInputDeviceRegistry> mock_registry;
54 mir::input::DefaultEventBuilder builder{0, mir::cookie::CookieFactory::create_keeping_secret()};54 mir::input::DefaultEventBuilder builder{0, mir::cookie::Authority::create()};
5555
56 mir::input::X::XInputPlatform x11_platform{56 mir::input::X::XInputPlatform x11_platform{
57 mt::fake_shared(mock_registry),57 mt::fake_shared(mock_registry),
5858
=== modified file 'tests/unit-tests/scene/test_abstract_shell.cpp'
--- tests/unit-tests/scene/test_abstract_shell.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/scene/test_abstract_shell.cpp 2016-01-25 13:42:04 +0000
@@ -144,7 +144,7 @@
144 }144 }
145145
146 std::chrono::nanoseconds const event_timestamp = std::chrono::nanoseconds(0);146 std::chrono::nanoseconds const event_timestamp = std::chrono::nanoseconds(0);
147 uint64_t const mac = 0;147 std::vector<uint8_t> const cookie;
148};148};
149}149}
150150
@@ -286,7 +286,7 @@
286 auto const event = mir::events::make_event(286 auto const event = mir::events::make_event(
287 mir_input_event_type_key,287 mir_input_event_type_key,
288 event_timestamp,288 event_timestamp,
289 mac,289 cookie,
290 action,290 action,
291 key_code,291 key_code,
292 scan_code,292 scan_code,
@@ -307,7 +307,7 @@
307 auto const event = mir::events::make_event(307 auto const event = mir::events::make_event(
308 mir_input_event_type_touch,308 mir_input_event_type_touch,
309 event_timestamp,309 event_timestamp,
310 mac,310 cookie,
311 modifiers);311 modifiers);
312312
313 EXPECT_CALL(*wm, handle_touch_event(_))313 EXPECT_CALL(*wm, handle_touch_event(_))
@@ -333,7 +333,7 @@
333 auto const event = mir::events::make_event(333 auto const event = mir::events::make_event(
334 mir_input_event_type_pointer,334 mir_input_event_type_pointer,
335 event_timestamp,335 event_timestamp,
336 mac,336 cookie,
337 modifiers,337 modifiers,
338 action,338 action,
339 buttons_pressed,339 buttons_pressed,
340340
=== modified file 'tests/unit-tests/scene/test_surface.cpp'
--- tests/unit-tests/scene/test_surface.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/scene/test_surface.cpp 2016-01-25 13:42:04 +0000
@@ -407,9 +407,9 @@
407 std::shared_ptr<mg::CursorImage>(),407 std::shared_ptr<mg::CursorImage>(),
408 report);408 report);
409409
410 auto key_event = mev::make_event(MirInputDeviceId(0), std::chrono::nanoseconds(0), 0,410 auto key_event = mev::make_event(MirInputDeviceId(0), std::chrono::nanoseconds(0), std::vector<uint8_t>{},
411 mir_keyboard_action_down, 0, 0, mir_input_event_modifier_none);411 mir_keyboard_action_down, 0, 0, mir_input_event_modifier_none);
412 auto touch_event = mev::make_event(MirInputDeviceId(0), std::chrono::nanoseconds(0), 0,412 auto touch_event = mev::make_event(MirInputDeviceId(0), std::chrono::nanoseconds(0), std::vector<uint8_t>{},
413 mir_input_event_modifier_none);413 mir_input_event_modifier_none);
414 mev::add_touch(*touch_event, 0, mir_touch_action_down, mir_touch_tooltype_finger, 0, 0,414 mev::add_touch(*touch_event, 0, mir_touch_action_down, mir_touch_tooltype_finger, 0, 0,
415 0, 0, 0, 0);415 0, 0, 0, 0);
416416
=== modified file 'tests/unit-tests/test_mir_cookie.cpp'
--- tests/unit-tests/test_mir_cookie.cpp 2016-01-20 23:59:18 +0000
+++ tests/unit-tests/test_mir_cookie.cpp 2016-01-25 13:42:04 +0000
@@ -16,94 +16,102 @@
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */17 */
1818
19#include "mir/cookie_factory.h"19#include "mir/cookie/authority.h"
20#include "mir/cookie/cookie.h"
2021
21#include <gtest/gtest.h>22#include <gtest/gtest.h>
22#include <gmock/gmock.h>23#include <gmock/gmock.h>
2324
24TEST(MirCookieFactory, attests_real_timestamp)25TEST(MirCookieAuthority, attests_real_timestamp)
25{26{
26 std::vector<uint8_t> secret{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde, 0x01 };27 std::vector<uint8_t> secret{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde, 0x01 };
27 auto factory = mir::cookie::CookieFactory::create_from_secret(secret);28 auto authority = mir::cookie::Authority::create_from(secret);
2829
29 uint64_t mock_timestamp{0x322322322332};30 uint64_t mock_timestamp{0x322322322332};
3031
31 auto cookie = factory->timestamp_to_cookie(mock_timestamp);32 auto cookie = authority->make_cookie(mock_timestamp);
3233 EXPECT_NO_THROW({
33 EXPECT_TRUE(factory->attest_timestamp(cookie));34 authority->make_cookie(cookie->serialize());
35 });
34}36}
3537
36TEST(MirCookieFactory, doesnt_attest_faked_timestamp)38TEST(MirCookieAuthority, doesnt_attest_faked_mac)
37{39{
38 std::vector<uint8_t> secret{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde, 0x01 };40 std::vector<uint8_t> secret{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde, 0x01 };
39 auto factory = mir::cookie::CookieFactory::create_from_secret(secret);41 auto authority = mir::cookie::Authority::create_from(secret);
4042
41 MirCookie bad_client_no_biscuit{ 0x33221100, 0x33221100 };43 std::vector<uint8_t> cookie{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde, 0x01 };
4244
43 EXPECT_FALSE(factory->attest_timestamp(bad_client_no_biscuit));45 EXPECT_THROW({
46 authority->make_cookie(cookie);
47 }, mir::cookie::SecurityCheckError);
44}48}
4549
46TEST(MirCookieFactory, timestamp_trusted_with_different_secret_doesnt_attest)50TEST(MirCookieAuthority, timestamp_trusted_with_different_secret_doesnt_attest)
47{51{
48 std::vector<uint8_t> alice{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde, 0x01 };52 std::vector<uint8_t> alice{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde, 0x01 };
49 std::vector<uint8_t> bob{ 0x01, 0x02, 0x44, 0xd8, 0xee, 0x0f, 0xde, 0x01 };53 std::vector<uint8_t> bob{ 0x01, 0x02, 0x44, 0xd8, 0xee, 0x0f, 0xde, 0x01 };
5054
51 auto alices_factory = mir::cookie::CookieFactory::create_from_secret(alice);55 auto alices_authority = mir::cookie::Authority::create_from(alice);
52 auto bobs_factory = mir::cookie::CookieFactory::create_from_secret(bob);56 auto bobs_authority = mir::cookie::Authority::create_from(bob);
5357
54 uint64_t mock_timestamp{0x01020304};58 uint64_t mock_timestamp{0x01020304};
5559
56 auto alices_cookie = alices_factory->timestamp_to_cookie(mock_timestamp);60 EXPECT_THROW({
57 auto bobs_cookie = bobs_factory->timestamp_to_cookie(mock_timestamp);61 auto alices_cookie = alices_authority->make_cookie(mock_timestamp);
62 auto bobs_cookie = bobs_authority->make_cookie(mock_timestamp);
5863
59 EXPECT_FALSE(alices_factory->attest_timestamp(bobs_cookie));64 alices_authority->make_cookie(bobs_cookie->serialize());
60 EXPECT_FALSE(bobs_factory->attest_timestamp(alices_cookie));65 bobs_authority->make_cookie(alices_cookie->serialize());
66 }, mir::cookie::SecurityCheckError);
61}67}
6268
63TEST(MirCookieFactory, throw_when_secret_size_to_small)69TEST(MirCookieAuthority, throw_when_secret_size_to_small)
64{70{
65 std::vector<uint8_t> bob(mir::cookie::CookieFactory::minimum_secret_size - 1);71 std::vector<uint8_t> bob(mir::cookie::Authority::minimum_secret_size - 1);
66 EXPECT_THROW({72 EXPECT_THROW({
67 auto factory = mir::cookie::CookieFactory::create_from_secret(bob);73 auto authority = mir::cookie::Authority::create_from(bob);
68 }, std::logic_error);74 }, std::logic_error);
69}75}
7076
71TEST(MirCookieFactory, saves_a_secret)77TEST(MirCookieAuthority, saves_a_secret)
72{78{
73 using namespace testing;79 using namespace testing;
74 std::vector<uint8_t> secret;80 std::vector<uint8_t> secret;
7581
76 mir::cookie::CookieFactory::create_saving_secret(secret);82 mir::cookie::Authority::create_saving(secret);
7783
78 EXPECT_THAT(secret.size(), Ge(mir::cookie::CookieFactory::minimum_secret_size));84 EXPECT_THAT(secret.size(), Ge(mir::cookie::Authority::minimum_secret_size));
79}85}
8086
81TEST(MirCookieFactory, timestamp_trusted_with_saved_secret_does_attest)87TEST(MirCookieAuthority, timestamp_trusted_with_saved_secret_does_attest)
82{88{
83 uint64_t timestamp = 23;89 uint64_t timestamp = 23;
84 std::vector<uint8_t> secret;90 std::vector<uint8_t> secret;
8591
86 auto source_factory = mir::cookie::CookieFactory::create_saving_secret(secret);92 auto source_authority = mir::cookie::Authority::create_saving(secret);
87 auto sink_factory = mir::cookie::CookieFactory::create_from_secret(secret);93 auto sink_authority = mir::cookie::Authority::create_from(secret);
88 auto cookie = source_factory->timestamp_to_cookie(timestamp);94 auto cookie = source_authority->make_cookie(timestamp);
8995
90 EXPECT_TRUE(sink_factory->attest_timestamp(cookie));96 EXPECT_NO_THROW({
97 sink_authority->make_cookie(cookie->serialize());
98 });
91}99}
92100
93TEST(MirCookieFactory, internally_generated_secret_has_optimum_size)101TEST(MirCookieAuthority, internally_generated_secret_has_optimum_size)
94{102{
95 using namespace testing;103 using namespace testing;
96 std::vector<uint8_t> secret;104 std::vector<uint8_t> secret;
97105
98 mir::cookie::CookieFactory::create_saving_secret(secret);106 mir::cookie::Authority::create_saving(secret);
99107
100 EXPECT_THAT(secret.size(), Eq(mir::cookie::CookieFactory::optimal_secret_size()));108 EXPECT_THAT(secret.size(), Eq(mir::cookie::Authority::optimal_secret_size()));
101}109}
102110
103TEST(MirCookieFactory, optimal_secret_size_is_larger_than_minimum_size)111TEST(MirCookieAuthority, optimal_secret_size_is_larger_than_minimum_size)
104{112{
105 using namespace testing;113 using namespace testing;
106114
107 EXPECT_THAT(mir::cookie::CookieFactory::optimal_secret_size(),115 EXPECT_THAT(mir::cookie::Authority::optimal_secret_size(),
108 Ge(mir::cookie::CookieFactory::minimum_secret_size));116 Ge(mir::cookie::Authority::minimum_secret_size));
109}117}

Subscribers

People subscribed via source and target branches