Add runtime configuration to perl lib
[blerg.git] / lib / perl / Blerg-Database / lib / Blerg / Database.pm
index d71340d..e462860 100644 (file)
@@ -130,9 +130,19 @@ sub mute {
     my ($obj, $v) = @_;
     $obj->_ensure_pointer;
     if (defined $v) {
-        return Blerg::Database::_set_mute($obj->{ptr}, $v);
+        return Blerg::Database::_set_status($obj->{ptr}, $obj->BLERGSTATUS_MUTED, $v);
     } else {
-        return Blerg::Database::_get_mute($obj->{ptr});
+        return Blerg::Database::_get_status($obj->{ptr}, $obj->BLERGSTATUS_MUTED);
+    }
+}
+
+sub mention {
+    my ($obj, $v) = @_;
+    $obj->_ensure_pointer;
+    if (defined $v) {
+        return Blerg::Database::_set_status($obj->{ptr}, $obj->BLERGSTATUS_MENTIONED, $v);
+    } else {
+        return Blerg::Database::_get_status($obj->{ptr}, $obj->BLERGSTATUS_MENTIONED);
     }
 }
 
@@ -196,6 +206,8 @@ provides nicer OO wrappers around the core C library that powers Blërg!.
 
 =head1 MODULE FUNCTIONS
 
+=head2 GENERAL
+
 =over
 
 =item exists(name)
@@ -232,6 +244,70 @@ Validates that C<name> is a valid tag name.
 
 Validates that C<name> is a valid username.
 
+=item configuration()
+
+Returns a hashref containing runtime configuration information.  Contains these fields:
+
+=over
+
+=item base_path
+
+The base path to the Blërg database
+
+=item data_path
+
+The path under base_path for account data
+
+=item hash_tags_path
+
+The path under base_path for hashtag data
+
+=item ref_tags_path
+
+The path under base_path for mention data
+
+=back
+
+=back
+
+=head2 AUTHENTICATION
+
+=over
+
+=item auth_set_password(username, password)
+
+Sets the password for the given username.  Returns 1 on success, 0 otherwise.
+
+=item auth_check_password(username, password)
+
+Checks the password for the given username.  Returns 1 on successful
+authentication, 0 on failed authentication or error.
+
+=item auth_login(username, password)
+
+Authenticates and logs the user in.  Returns the authentication token if
+successful, or undef on failure or error.
+
+=item auth_logout(username, token)
+
+Logs the given user out if the token represents a valid session.  Returns 1 on
+success, or 0 on failure.  Failure can happen if the token is no longer valid
+(meaning the user has been automatically logged out), so the return status is
+probably best ignored..
+
+=item auth_check_token(username, token)
+
+Checks that the token represents a valid session for the given username.
+Returns 1 if the session is valid, 0 otherwise.  Also resets the expiration
+time of the session.
+
+=item auth_get_counter(username)
+
+Gets an opaque "counter" value for the auth information of the given username.
+This counter is changed every time the authentication information is changed,
+making it useful for protecting password changes against replay attacks.
+Returns a 32-bit integer on success, or undef on failure.
+
 =back
 
 =head1 CONSTRUCTOR
@@ -303,7 +379,7 @@ C<tag_list('@' . $obj-E<gt>{name})>.
 
 =item mute(v)
 
-When v = 1, mute the user, otherwise, unmute.
+When v = 1, mute the user, otherwise, unmute.  If v is absent, return the mute status.
 
 =item close()