-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose offline conference peers in API #1266
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 12 files at r1.
Reviewable status: 0 of 1 approvals obtained (waiting on @zugz)
toxcore/group.h, line 248 at r1 (raw file):
int del_groupchat(Group_Chats *g_c, uint32_t groupnumber); /* Copy the public key of (frozen) peernumber who is in groupnumber to pk.
Took me quite some time to understand the meaning of (frozen)
in conjunction with the function parameter, maybe add an explanation for this concept? Or maybe switch to (frozen/peer) number
? maybe there are even better ways to name this.
toxcore/group.c, line 1090 at r1 (raw file):
Group_Peer *list = frozen ? g->frozen : g->group; uint32_t num = frozen ? g->numfrozen : g->numpeers;
both can be const
toxcore/group.c, line 1115 at r1 (raw file):
Group_Peer *list = frozen ? g->frozen : g->group; uint32_t num = frozen ? g->numfrozen : g->numpeers;
same
toxcore/group.c, line 1144 at r1 (raw file):
Group_Peer *list = frozen ? g->frozen : g->group; uint32_t num = frozen ? g->numfrozen : g->numpeers;
same
toxcore/group.c, line 1168 at r1 (raw file):
uint64_t *last_active) { Group_c *g = get_group_c(g_c, groupnumber);
const?
toxcore/group.c, line 1201 at r1 (raw file):
} uint32_t num = frozen ? g->numfrozen : g->numpeers;
const
toxcore/group.c, line 1640 at r1 (raw file):
bool group_leave(const Group_Chats *g_c, uint32_t groupnumber) { Group_c *g = get_group_c(g_c, groupnumber);
const
toxcore/tox.c, line 1536 at r1 (raw file):
{ Messenger *m = tox->m; group_leave(m->conferences_object, conference_number);
check return value? if check not needed, why do we have a return value at all?
toxcore/tox.c, line 1650 at r1 (raw file):
{ const Messenger *m = tox->m; int ret = group_number_peers(m->conferences_object, conference_number, true);
const? (similar cases down here)
toxcore/tox.api.h, line 2324 at r1 (raw file):
} namespace offline_peer {
I'm a bit torn on the naming here, on one hand we call offline
peers frozen
internally but not externally which is a bit inconsistent, on the other hand frozen
is not very descriptive for developers not familiar with Tox. What are your thoughts here?
Just to be 100% sure, this doesn't mean that after saving a running Tox instance all group numbers are invalid, right? Asking because qTox saves the *.tox on some actions but doesn't invalidate the group numbers. |
* Thursday, 2018-11-29 at 06:35 -0800 - sudden6 <[email protected]>:
> So after save and load, the group numbers will be sequential.
Just to be 100% sure, this doesn't mean that after saving a running Tox
instance all group numbers are invalid, right? Asking because qTox
saves the *.tox on some actions but doesn't invalidate the group
numbers.
That's fine. It's only on loading the saved data, which is necessarily
in a new tox instance, that the group numbers will change.
|
Codecov Report
@@ Coverage Diff @@
## master #1266 +/- ##
========================================
- Coverage 83.3% 83.1% -0.3%
========================================
Files 82 82
Lines 14869 14928 +59
========================================
+ Hits 12394 12407 +13
- Misses 2475 2521 +46
Continue to review full report at Codecov.
|
ok, that answers my questions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 approvals obtained (waiting on @sudden6)
toxcore/group.h, line 248 at r1 (raw file):
Previously, sudden6 wrote…
Took me quite some time to understand the meaning of
(frozen)
in conjunction with the function parameter, maybe add an explanation for this concept? Or maybe switch to(frozen/peer) number
? maybe there are even better ways to name this.
How about "(possibly frozen) peernumber"?
toxcore/group.c, line 1090 at r1 (raw file):
Previously, sudden6 wrote…
both can be const
done
toxcore/group.c, line 1115 at r1 (raw file):
Previously, sudden6 wrote…
same
Done.
toxcore/group.c, line 1144 at r1 (raw file):
Previously, sudden6 wrote…
same
Done.
toxcore/group.c, line 1168 at r1 (raw file):
Previously, sudden6 wrote…
const?
Made it a TODO, since it's more appropriate for a separate PR.
toxcore/group.c, line 1201 at r1 (raw file):
Previously, sudden6 wrote…
const
Done.
toxcore/group.c, line 1640 at r1 (raw file):
Previously, sudden6 wrote…
const
as above
toxcore/tox.c, line 1536 at r1 (raw file):
Previously, sudden6 wrote…
check return value? if check not needed, why do we have a return value at all?
if we get an error here, we also get an error in del_groupchat on the next line. Checking both would make the code harder to read. So I think it's best to leave it as is. It still makes sense to have group_leave return bool, for consistency and because we might want to check it in some context in the future.
toxcore/tox.c, line 1650 at r1 (raw file):
Previously, sudden6 wrote…
const? (similar cases down here)
Again, made it a TODO
toxcore/tox.api.h, line 2324 at r1 (raw file):
Previously, sudden6 wrote…
I'm a bit torn on the naming here, on one hand we call
offline
peersfrozen
internally but not externally which is a bit inconsistent, on the other handfrozen
is not very descriptive for developers not familiar with Tox. What are your thoughts here?
My thinking was that "offline" would be clearer to users of the library, but "frozen" is more descriptive of what's actually going on internally. So I kept "frozen" for tox-internal use, but made in "offline" in the API. If you really think it's too confusing, we could use "offline" everywhere. But in the context of the groups internals, this sounds like it should be about connections going down, which it isn't, and more generally there's the risk of confusion with the entirely separate concept of friend_connections being offline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 12 files at r1, 1 of 4 files at r2.
Reviewable status: 0 of 1 approvals obtained (waiting on @zugz)
toxcore/group.h, line 248 at r1 (raw file):
Previously, zugz (zugz) wrote…
How about "(possibly frozen) peernumber"?
now I'm unsure how this API works exactly, if frozen
is false, it will only return online peers, if frozen
is true it will return online and frozen or frozen only?
toxcore/tox.c, line 1536 at r1 (raw file):
Previously, zugz (zugz) wrote…
if we get an error here, we also get an error in del_groupchat on the next line. Checking both would make the code harder to read. So I think it's best to leave it as is. It still makes sense to have group_leave return bool, for consistency and because we might want to check it in some context in the future.
after a quick glance I could not find another use of group_leave
maybe merge it into `del_groupchat´ to avoid this problem and simplify the code?
toxcore/tox.api.h, line 2324 at r1 (raw file):
Previously, zugz (zugz) wrote…
My thinking was that "offline" would be clearer to users of the library, but "frozen" is more descriptive of what's actually going on internally. So I kept "frozen" for tox-internal use, but made in "offline" in the API. If you really think it's too confusing, we could use "offline" everywhere. But in the context of the groups internals, this sounds like it should be about connections going down, which it isn't, and more generally there's the risk of confusion with the entirely separate concept of friend_connections being offline.
After sleeping a few nights over this, I fully agree with your PoV. Externally it would be pretty confusing for user of the library to talk about frozen
peers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 12 files at r1.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @zugz)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 approvals obtained (waiting on @sudden6)
toxcore/group.h, line 248 at r1 (raw file):
Previously, sudden6 wrote…
now I'm unsure how this API works exactly, if
frozen
is false, it will only return online peers, iffrozen
is true it will return online and frozen or frozen only?
Frozen only. How about "(frozen, if frozen is true) peernumber"? I hope that's clear?
toxcore/tox.c, line 1536 at r1 (raw file):
Previously, sudden6 wrote…
after a quick glance I could not find another use of
group_leave
maybe merge it into `del_groupchat´ to avoid this problem and simplify the code?
It's used elsewhere too in #1267.
toxcore/group.h, line 248 at r1 (raw file): Previously, zugz (zugz) wrote…
yeah, that's pretty clear |
toxcore/tox.c, line 1536 at r1 (raw file): Previously, zugz (zugz) wrote…
Also there it's immediately followed by a call to |
* Sunday, 2018-12-02 at 01:12 -0800 - sudden6 <[email protected]>:
___
*[toxcore/tox.c, line 1536 at r1](https://reviewable.io/reviews/toktok/c-toxcore/1266#-LSUsFZr7ZFUZznBrUbr:-LSiBA0f4UqgCGmm9H6Y:b-9i49jt) ([raw file](https://github.com/toktok/c-toxcore/blob/4052ebfd11deea5ae5e3af131f089860386766d4/toxcore/tox.c#L1536)):*
<details><summary><i>Previously, zugz (zugz) wrote…</i></summary><blockquote>
It's used elsewhere too in #1267.
</blockquote></details>
Also there it's immediately followed by a call to `del_groupchat`
Yes, but to combine them you'd need to pass a bool to del_groupchat,
which doesn't seem right. Deleting is deleting, leaving is something
separate. Right?
|
* Sunday, 2018-12-02 at 01:31 -0800 - zugz <[email protected]>:
* Sunday, 2018-12-02 at 01:12 -0800 - sudden6 ***@***.***>:
>___
>*[toxcore/tox.c, line 1536 at r1](https://reviewable.io/reviews/toktok/c-toxcore/1266#-LSUsFZr7ZFUZznBrUbr:-LSiBA0f4UqgCGmm9H6Y:b-9i49jt) ([raw file](https://github.com/toktok/c-toxcore/blob/4052ebfd11deea5ae5e3af131f089860386766d4/toxcore/tox.c#L1536)):*
><details><summary><i>Previously, zugz (zugz) wrote…</i></summary><blockquote>
>
>It's used elsewhere too in #1267.
></blockquote></details>
>
>Also there it's immediately followed by a call to `del_groupchat`
Yes, but to combine them you'd need to pass a bool to del_groupchat,
which doesn't seem right. Deleting is deleting, leaving is something
separate. Right?
On second thoughts, you're right. Doing it all in one function does
indeed seem neatest. I've just pushed a commit doing it.
(P.S. sorry to have broken out of reviewables... feel free to revert
back to it)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r3.
Reviewable status: 0 of 1 approvals obtained
012ca95
to
155bfd1
Compare
2117bd8
to
388942d
Compare
toxcore/tox.api.h
Outdated
/** | ||
* Error codes for peer info queries. | ||
*/ | ||
error for query { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error for peer.query can be reused (I hope that there is a syntax for that that works).
(based on #1156)
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)