summaryrefslogtreecommitdiff
path: root/src/hub/users.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/hub/users.h')
-rw-r--r--src/hub/users.h36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/hub/users.h b/src/hub/users.h
index 44e8aee..f5ff63c 100644
--- a/src/hub/users.h
+++ b/src/hub/users.h
@@ -94,13 +94,11 @@ typedef struct {
__KHASH_TYPE(userlist, hub_user_t *, char);
-__KHASH_TYPE(ulistsid, hub_user_t *, char);
typedef struct {
dbo_hubu_properties_t props;
kh_userlist_t *list;
- kh_ulistsid_t *sids; /* Only includes "online" users */
char idsalt[32];
ev_timer sweep;
/* A value that alternates at every sweep period. It is used for comparison
@@ -117,31 +115,30 @@ typedef struct {
uint64_t oldsharesize;
uint16_t changes[HUBU_FIELDNUM];
int changenum;
- bool self;
- bool oldonline;
} hub_user_update_t;
int64_t hub_users_genid(hub_t *h, const char *data, int len);
+hub_user_t *hub_user_new(bool adc);
-void hub_user_ref(hub_t *h, hub_user_t *u);
+void hub_user_ref(hub_user_t *u);
void hub_user_unref(hub_t *h, hub_user_t *u);
-/* Call with id = -1 if the user isn't online or its id isn't known */
-void hub_user_update_init(hub_t *h, hub_user_update_t *d, int64_t id);
-
-
-/* Should be called after a field has been modified. Fields that do not have a
- * hub_user_field_t type do not require this notification. The 'online' flag,
- * while part of the flags, does not need it, either. */
+/* Functions to perform a user info update, to be performed by a protocol
+ * handler.
+ * Fields that do not have a hub_user_field_t type may be modified without
+ * requiring a call to hub_user_update_field(). The following fields may NOT
+ * be modified:
+ * online, ref, delmark, id
+ * When adding a new user, first create an object with hub_user_new(), set its
+ * id, and then perform the update as if it is an old user.
+ * Note that the hub_user_t object may be freed in hub_user_update_done(), so
+ * don't keep the pointer around.
+ */
+void hub_user_update_init(hub_t *h, hub_user_update_t *d, hub_user_t *user);
void hub_user_update_field(hub_user_update_t *d, hub_user_field_t field);
-
-void hub_user_update_abort(hub_user_update_t *d);
-
-/* Returns false if it was unable to generate an ID for this user (i.e. no CID
- * was given). */
-bool hub_user_update_done(hub_user_update_t *d);
+void hub_user_update_done(hub_user_update_t *d, bool newuser);
/* Called when a user has left the hub or when we've disconnected. Returns
@@ -149,9 +146,6 @@ bool hub_user_update_done(hub_user_update_t *d);
bool hub_user_left(hub_t *h, int64_t id, int64_t initiator, const char *message);
-/* Returns -1 when the user hasn't been found */
-int64_t hub_users_bysid(hub_t *h, adc_sid_t sid);
-
/* Returns NULL if there's no user online with that ID */
hub_user_t *hub_users_get(hub_t *h, int64_t id);