These are chat archives for abranson/rockpool

27th
May 2016
Andrew Branson
@abranson
May 27 2016 07:26
I see CalenderEvent is already deprecated and only used for migration. What do you think about Notification?
I was thinking it might be a good idea to keep that and maybe the others as util objects to generate the json
As there are a lot of hard-coded values for each pin type
ruff
@rufferson
May 27 2016 07:34
I think it's better to create static inline generators inserting boilerplate
after all there's not much if it, major part is inserted by Pebble::insertPin where basic validation happens. Web pin should never need it, it's only for interaction with 3d parties
and again - if we're inserting something platform specific - let platform layer insert it.
We have simple notification call also (for jskit) which makes creation of lightweight abstract notification very easy
Andrew Branson
@abranson
May 27 2016 07:39
That really expects a watchapp uuid though
ruff
@rufferson
May 27 2016 07:40
you can give that sysid uuid, just probably need to add a catch to insert predefined literal when uuid is system
Andrew Branson
@abranson
May 27 2016 07:40
might be better to move the app identification stuff to the jskit sendSimpleNotification, and make the Pebble one simpler
ruff
@rufferson
May 27 2016 07:42
I was thinking to pass it through filtering engine so that you can actually disable notifications for chatty apps. that needs certain more reliable identifier than shortName, so I've put app uuid as an source identifier
Andrew Branson
@abranson
May 27 2016 07:44
yes they need to be filtered and were before - the watchface I use sends one whenever it gets a weather update so I mute it.
but the JSKit apps call JSKitPebble::showSimpleNotificationOnPebble, which then calls Pebble::sendSimpleNotification. The appInfo calls should be in the former as they're watchapp specific
ruff
@rufferson
May 27 2016 07:47
ehm yes, you can even provide an app icon then filling in source + sourceIcon fields
Andrew Branson
@abranson
May 27 2016 07:47
in fact you're only using shortName, so that can just be an extra arg to sendSimpleNotification
yes that's a good idea
i'll do that while i'm integrating. Can the current Notification impl be dropped then? Is that the plan?
ruff
@rufferson
May 27 2016 07:48
so you want to move entire simleNotif. call to jskit? and from there just call pebble->insertPin?
Andrew Branson
@abranson
May 27 2016 07:49
no, i think the simpleNotif in Pebble is useful for non-jskit calls, such as this update notification
ruff
@rufferson
May 27 2016 07:49
yes, i've disconnected legacyNotification chain, so legacy notif. endpoint is useless now, and anyway we don't support anything below 3.0
Andrew Branson
@abranson
May 27 2016 07:49
I'm going to make that independent of the watchapp
i agree it's pointless to support 2.x for anything but upgrade
4.x is coming. Katharine has spoken about it a bit - this timeline pin stuff is crucial for it.
although merging all this into rockwork is going to be a mammoth task now. you've done too much work ;)
ruff
@rufferson
May 27 2016 07:51
ok. basically i've finished websync part. idea is to move oauth stuff to the client and then just pass token over dbus
atm i just store it in manager.ini
where it will be kept
Andrew Branson
@abranson
May 27 2016 07:51
really? so you can receive subscribed pins from pebble??
ruff
@rufferson
May 27 2016 07:51
however i still don't fully understand the logic behind token generation
those calls in jskit - they are crucial to manage subscriptions
Andrew Branson
@abranson
May 27 2016 07:52
yes, so they're not implemented yet?
ruff
@rufferson
May 27 2016 07:52
yes, if you subsribe somewhere else :)
Andrew Branson
@abranson
May 27 2016 07:52
that's most of the work done though
ruff
@rufferson
May 27 2016 07:53
yes. the way it works is that apps are actually calling jskit subscribe/unsubscribe which sends this request to pebble.com. TImelineEngine then receives these commands over the json feed
to do the job on system side
but to subscribe to something you need valid token.
Andrew Branson
@abranson
May 27 2016 07:54
so the app is receiving a json feed from pebble after login
ruff
@rufferson
May 27 2016 07:54
so f.i. pypkjs uses uuid 000....-..-..-.001. Just tried that for fun and of course got m_nam(new QNetworkAccessManager(this)),
Andrew Branson
@abranson
May 27 2016 07:54
i thought you'd get the token from oauth? or is it a different one?
ruff
@rufferson
May 27 2016 07:54
ops
{"errorCode":"TOKEN_NOT_AVAILABLE","errorMessage":"uuid is not registered","requestId":"0bed2dc1-1016-40cc-b1be-6b1358546932"}
there's whole bunch of tokens - watch token, user token, system token, timeline token...
oauth token just needed to communicate to pebble.com otherwise you're getting 401 Auth Required
Andrew Branson
@abranson
May 27 2016 07:55
yes i've seen those. so which ones are you missing?
i know the watch token comes from the watch i think. the user token is needed in the jskit - apps can query it
i'd expect it to come from pebble after login
ruff
@rufferson
May 27 2016 07:57
just need to understand how to generate a proper token. Is it just a random - but then you need to store and use for all your communications (eg. token would define starting point). or .com is expecting certain elemetns to be in that hash
Andrew Branson
@abranson
May 27 2016 07:57
could you point me to the relevant part of pypkjs?
JSKitPebble::getTimelineToken is what is needed?
ruff
@rufferson
May 27 2016 07:59
yes, actually that nested one
result = requests.get(self.runtime.runner.urls.sandbox_token % self.uuid,
headers={'Authorization': 'Bearer %s' % self.runtime.runner.oauth_token})
Andrew Branson
@abranson
May 27 2016 07:59
also JSKitPebble::getAccountToken, which is not yet connected to pebble and is randomly generated
but JSKitPebble::getWatchToken is correct I think
ruff
@rufferson
May 27 2016 08:00
here you fetch timeline token from p.com but under self.uuid,
Andrew Branson
@abranson
May 27 2016 08:01
and we need to know how to fetch these? I seem to remember that the timeline token is a combination of watch and user, in such a way that different apps can't compare tokens and match users
ruff
@rufferson
May 27 2016 08:01
eg. oauth is a necessary but not sufficient part
what should be that self.uuid ? as I've said on pypkjs it's currently set to 'uuid': '00000000-0000-0000-0000-000000000001'
but when i use that i'm getting that invalid token error %)
which makes sense bcz that uuid is apparently invalid %)
Andrew Branson
@abranson
May 27 2016 08:03
can you sniff the android app?
ruff
@rufferson
May 27 2016 08:03
errorMessage":"uuid is not registered" - how should it be registered?
Andrew Branson
@abranson
May 27 2016 08:04
maybe there's a call after auth that fetches it for the current user?
ruff
@rufferson
May 27 2016 08:04
yeah, so far it's the only way i see, unless Kath gives us some clue
Andrew Branson
@abranson
May 27 2016 08:04
unfortunately i don't have an android device i can use for sniffing
i might have to try to get one
anyway, did you order a Jolla C? :)
ruff
@rufferson
May 27 2016 08:05
i have some relict sony-ericsson which runs CM11 now. but cannot install more then 1 app bcz it has only 100MB partition free %0
Andrew Branson
@abranson
May 27 2016 08:06
i'd use my wife's old phones but she keeps accidentally smashing them
xperia z3s seem to be very easily smashed...
ruff
@rufferson
May 27 2016 08:06
no, what's that? I'm subsribed to their alerts but latest i got was i think sfos upgrade announce, and before some brave words about bright future
Andrew Branson
@abranson
May 27 2016 08:07
it's a jolla rebadging of the intex phone. only €170
but they only launched with a thousand, and they sold out in a few hours
ruff
@rufferson
May 27 2016 08:07
uhm, ok, so i missed that :)
Andrew Branson
@abranson
May 27 2016 08:07
might be more, i'll let you know if they get some
quad core, 2GB RAM, dual sim
and of course a newer kernel so the new dalvik. and no btrfs of course.
they even bothered to connect the FM receiver this time
ruff
@rufferson
May 27 2016 08:14
I don't use android compatibility, if i need android - i'd buy android :) I bought jolla mainly bcz of native apps and pure linux env :)
Andrew Branson
@abranson
May 27 2016 08:15
oh i find it useful, esp for things like whatsapp which i'd love to do without but i've got too many people to convince otherwise.
i'd love for it to be super-sandboxed though - with integrated fine permission control etc
i don't want to have to buy an android phone for the sake of one or two apps...
anyway, i'll try to find the relevant section of pypkjs and try to ask Katharine - though she's very busy with this new launch. i backed them for a Pebble 2 today too!
ruff
@rufferson
May 27 2016 08:20
I still cannot :( tried my master and amex - refuses. strang thing it doesn't even ask about delivery address, just enter card details, country and postcode. and then - network error
Andrew Branson
@abranson
May 27 2016 08:22
Katharine responded immediately. She said you get the tokens from the Locker API
"The best way to go about oauth is to show https://auth-client.getpebble.com/en_US/ in a web view and catch the redirect which has the tokens in it."

Katharine Berry, [27.05.16 10:18]
They're passed back by the locker API.

Katharine Berry, [27.05.16 10:19]
I built the first mobile-app timeline implementation in a week, and that was including figuring out how on earth the timeline should work (being the first implementer is always a good way to discover design issues). It's not really all that complex. :p

Katharine Berry, [27.05.16 10:20]
Except for the god-awful rules about when to show which notifications.

ruff
@rufferson
May 27 2016 08:24
she probably confused pin and token?
the code she points is pin notification handler, not token
that part is implemented
but locker API is deprecated?
Andrew Branson
@abranson
May 27 2016 08:26

Katharine Berry, [27.05.16 10:24]
There are a bunch of subtleties in the timeline sync, too.

Katharine Berry, [27.05.16 10:25]
Especially around handling topics.

Katharine Berry, [27.05.16 10:25]
The point where I gave up on my ORM: https://github.com/pebble/pypkjs/blob/master/pypkjs/timeline/model.py#L248-L258

the code was to show the details of notification filtering on their side
ruff
@rufferson
May 27 2016 08:27
uhm, topics in timeline (received from sync feed) is quite straight forward
Andrew Branson
@abranson
May 27 2016 08:27
she's definitely taking about tokens
ruff
@rufferson
May 27 2016 08:27
topics out of it (from jskit) - taht's tricky
second code ref is about topic mgmt - also implemented
here's locker api afaik https://api2.getpebble.com/docs
Andrew Branson
@abranson
May 27 2016 08:28
so there's nothing in the OAuth redirect?
ruff
@rufferson
May 27 2016 08:28
no, redirect is how to get oauth token, i have no probs with oauth token
but rather need to understand logic behind other tokens (watch, user, timeline, app, etc.) - are they just randomly generated uuids which require certain proper registration - or proper elements should be incorporated into it while building the uuid
Andrew Branson
@abranson
May 27 2016 08:30
the watch token always needs to be the same for your watch - it's currently generated from the watch serial number and that will do
the user and timeline tokens are given to you by pebble.com
ruff
@rufferson
May 27 2016 08:31
right, but to get timeline token you need to provide system token
ur system uuid
*or
so what's behind that?
Andrew Branson
@abranson
May 27 2016 08:31

Andrew Branson, [27.05.16 10:29]
isn't the Locker API a v2 thing?

Katharine Berry, [27.05.16 10:29]
There's a newer one!

Katharine Berry, [27.05.16 10:29]
Which is also the locker API.the user one is

the user token is always the same for the logged in user, but i think the timeline token is app-specific
which must be why there's a new locker api - to fetch it
ruff
@rufferson
May 27 2016 08:33
ok, that's probably the missing part. but seems pypkjs doesn't use it. Or it's behind that https://timeline-sync.getpebble.com/v1/tokens/sandbox/ url
Andrew Branson
@abranson
May 27 2016 08:33
it would be good to get a newer version of this: https://api2.getpebble.com/docs
she said that's the latest. it's in there somewhere...
Andrew Branson
@abranson
May 27 2016 08:38
and the old locker api was somewhere else, so the /apps stuff in there is what you want
ruff
@rufferson
May 27 2016 08:39
the one api2 or timeline-sync sandbox?
Andrew Branson
@abranson
May 27 2016 08:39
api2
ruff
@rufferson
May 27 2016 08:40
ok, let me try to play with that then
Andrew Branson
@abranson
May 27 2016 08:40
glad she's engaging a bit more, she was really quiet while she was ill
good luck, i'll let you know if any other bits of info arise
and of course you're welcome in the telegram group whenever you feel like it ;)
ruff
@rufferson
May 27 2016 10:43
Interesting, when i supply my oauth token - locker shows me apps I installed from android. That app defenition in the locker has user_token field
ruff
@rufferson
May 27 2016 10:58
also locker gives you ability to get app info by uuid (store api uses storeid only), and that app info contains storeid in addition to user_token
user token itself means we need to store additional metadata in appinfo - which is not covered by appinfo.json. What I'm leading to is that we can actually store apps by uuid (which is more preferable as to me) and just store additional info like user token, store_id, maybe somth else
Andrew Branson
@abranson
May 27 2016 12:06
that definitely sounds like the missing piece of the puzzle
ruff
@rufferson
May 27 2016 13:33
yes, getting more clear now how it works :)
$ curl -H "Authorization: Bearer <oauthToken>" https://timeline-sync.getpebble.com/v1/tokens/sandbox/650dea65-3714-4b36-b1aa-38ade58f5700
{"uuid":"650dea65-3714-4b36-b1aa-38ade58f5700","token":"SBZFXeIayoCvw18THLWKcAwCUAYUjF4B"}
this is timeline token
ruff
@rufferson
May 27 2016 13:45
and finally $ curl -T - -H "Authorization: Bearer <oauthToken>" https://api2.getpebble.com//v2/locker/650dea65-3714-4b36-b1aa-38ade58f5700 <<<""
{"application":{"id":"555a8efcae067d58f800004d","uuid":"650dea65-3714-4b36-b1aa-38ade58f5700","user_token":"UquuvM2HDEEU5G5TWYUQBBZHTW8a4eoq",...
and this is user token for new app. now having these two i can make a subscription
Andrew Branson
@abranson
May 27 2016 14:25
that's brilliant. as soon as that's in we should call that 1.0
Andrew Branson
@abranson
May 27 2016 14:58
Weirdly, the QDateTime::currentDateTimeUtc().toTime_t() causes Rockpool to hang on my phone!
if i switch it to toMSecsSinceEpoch then it's fine
i wouldn't have thought that QString arg thing could get stuck like that
ruff
@rufferson
May 27 2016 15:37
is it in notification id building section?
Andrew Branson
@abranson
May 27 2016 15:45
the Pebble::sendSimpleNotification
setting the id field in the json
ruff
@rufferson
May 27 2016 15:46
just try to #include <time.h> and put time() instead, should spare some stack %)
ruff
@rufferson
May 27 2016 18:42
Can you also ask Katharine whether timeline token persists (per user per application) or may change with a time. I.e. whether it makes sense to build a cache of them and store locally, bound to oauth token. Or they may change and storing them just makes a mess
ruff
@rufferson
May 27 2016 19:16
although never mind, we won't store them. it would be a mess if someone would want to change attached user.
ruff
@rufferson
May 27 2016 21:10
and no, redirect from OAuth login does not contain accountToken - so still need to figure out how to obtain or properly generate one.
ruff
@rufferson
May 27 2016 21:21
or... user_token=accountToken. bcz subsription api accepts both with similar results
ruff
@rufferson
May 27 2016 21:34
I mean - subscription api accepts both - user_token and timeline_token with similar results. But no, already found how to get account_token in pebble sdk.