diff options
-rw-r--r-- | src/MKConnection.m | 5 | ||||
-rw-r--r-- | src/MKServerModel.m | 19 | ||||
-rw-r--r-- | src/MumbleKit/MKConnection.h | 6 | ||||
-rw-r--r-- | src/MumbleKit/MKServerModel.h | 26 |
4 files changed, 54 insertions, 2 deletions
diff --git a/src/MKConnection.m b/src/MKConnection.m index 46704a6..2e6e822 100644 --- a/src/MKConnection.m +++ b/src/MKConnection.m @@ -325,7 +325,7 @@ static void MKConnectionUDPCallback(CFSocketRef sock, CFSocketCallBackType type, #pragma mark - -- (void) authenticateWithUsername:(NSString *)userName password:(NSString *)password { +- (void) authenticateWithUsername:(NSString *)userName password:(NSString *)password accessTokens:(NSArray *)tokens { NSData *data; MPVersion_Builder *version = [MPVersion builder]; @@ -355,6 +355,9 @@ static void MKConnectionUDPCallback(CFSocketRef sock, CFSocketCallBackType type, if (password) { [authenticate setPassword:password]; } + if (tokens) { + [authenticate setTokensArray:tokens]; + } [authenticate addCeltVersions:MUMBLEKIT_CELT_BITSTREAM]; data = [[authenticate build] data]; [self sendMessageWithType:AuthenticateMessage data:data]; diff --git a/src/MKServerModel.m b/src/MKServerModel.m index 63d477e..c477644 100644 --- a/src/MKServerModel.m +++ b/src/MKServerModel.m @@ -130,6 +130,14 @@ [super dealloc]; } +- (NSString *) hostname { + return [_connection hostname]; +} + +- (NSInteger) port { + return [_connection port]; +} + // Remove all users from their channels. // Must be called before removing channels. - (void) removeAllUsersFromChannel:(MKChannel *)channel { @@ -747,4 +755,15 @@ [_connection sendMessageWithType:UserStateMessage data:data]; } +#pragma mark - +#pragma mark Server operations + +- (void) setAccessTokens:(NSArray *)tokens { + MPAuthenticate_Builder *authenticate = [MPAuthenticate builder]; + [authenticate setTokensArray:tokens]; + + NSData *data = [[authenticate build] data]; + [_connection sendMessageWithType:AuthenticateMessage data:data]; +} + @end diff --git a/src/MumbleKit/MKConnection.h b/src/MumbleKit/MKConnection.h index 4c67126..bf36bc4 100644 --- a/src/MumbleKit/MKConnection.h +++ b/src/MumbleKit/MKConnection.h @@ -431,8 +431,12 @@ typedef enum { * @param pass The password to authenticate with. If the specified username is that * of a registered user, the password will be treated as a user password. * Otherwise, it will be treated as a server password. + * + * @param tokens The initial set of access tokens for the user we are connecting as, in + * the form of an NSArray of NSStrings. + * This parameter may be nil if the user does not have any access tokens. */ -- (void) authenticateWithUsername:(NSString *)user password:(NSString *)pass; +- (void) authenticateWithUsername:(NSString *)user password:(NSString *)pass accessTokens:(NSArray *)tokens; ///---------------------- /// @name Message Handler diff --git a/src/MumbleKit/MKServerModel.h b/src/MumbleKit/MKServerModel.h index 2c54b48..7b89b49 100644 --- a/src/MumbleKit/MKServerModel.h +++ b/src/MumbleKit/MKServerModel.h @@ -480,6 +480,20 @@ */ - (void) removeDelegate:(id)delegate; +///------------------------- +/// @name Server Information +///------------------------- + +/** + * Returns the hostname of the server that the MKServerModel is currently connected to. + */ +- (NSString *) hostname; + +/** + * Returns the port of the server that the MKServerModel is currently connected to. + */ +- (NSInteger) port; + ///----------------------- /// @name Users operations ///----------------------- @@ -537,4 +551,16 @@ */ - (void) joinChannel:(MKChannel *)channel; +///------------------------ +/// @name Server operations +///------------------------ + +/** + * Set the list of access tokens for the currently connected user. + * + * @param tokens An NSArray of strings containing the tokens to use as access tokens for the + * connected user. + */ +- (void) setAccessTokens:(NSArray *)tokens; + @end |