Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add administrative features (set/retrieve groups and ACLs, channel cr…

…eation).
  • Loading branch information...
commit bf23e9d250d476f53ce91bf7523000c6fd8daa35 1 parent 1518c08
Emilio Pavia authored June 19, 2012 mkrautz committed June 19, 2012
1  AUTHORS
@@ -5,3 +5,4 @@ Thorvald Natvig <thorvald@natvig.com>
5 5
 Mikkel Krautz <mikkel@krautz.dk>
6 6
 Stefan Hacker <dd0t@users.sourceforge.net>
7 7
 Benjamin Jemlich <pcgod@users.sourceforge.net>
  8
+TOK.TV Inc.
8  CONTRIBUTORS
... ...
@@ -0,0 +1,8 @@
  1
+// This is the official list of people who can contribute
  2
+// (and typically have contributed) code to MumbleKit.
  3
+
  4
+Benjamin Jemlich <pcgod@users.sourceforge.net>
  5
+Emilio Pavia <emilio@tok.tv>
  6
+Mikkel Krautz <mikkel@krautz.dk>
  7
+Stefan Hacker <dd0t@users.sourceforge.net>
  8
+Thorvald Natvig <thorvald@natvig.com>
42  MumbleKit.xcodeproj/project.pbxproj
@@ -126,6 +126,20 @@
126 126
 		28CC3717132EDC7300241269 /* libSpeexDSP.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 28CC3712132EDC7300241269 /* libSpeexDSP.a */; };
127 127
 		28F2FAD513E37BA000034BF2 /* MKAudioOutputUserPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 28F2FAD413E37BA000034BF2 /* MKAudioOutputUserPrivate.h */; };
128 128
 		28F2FAD613E37BA000034BF2 /* MKAudioOutputUserPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 28F2FAD413E37BA000034BF2 /* MKAudioOutputUserPrivate.h */; };
  129
+		BCD11DF2158F3FD600321E06 /* MKPermission.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD11DF1158F3FD600321E06 /* MKPermission.h */; };
  130
+		BCD11DF3158F3FD600321E06 /* MKPermission.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD11DF1158F3FD600321E06 /* MKPermission.h */; };
  131
+		BCD11DF7158F40A900321E06 /* MKAccessControl.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD11DF4158F40A900321E06 /* MKAccessControl.h */; };
  132
+		BCD11DF8158F40A900321E06 /* MKAccessControl.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD11DF4158F40A900321E06 /* MKAccessControl.h */; };
  133
+		BCD11DF9158F40A900321E06 /* MKChannelACL.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD11DF5158F40A900321E06 /* MKChannelACL.h */; };
  134
+		BCD11DFA158F40A900321E06 /* MKChannelACL.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD11DF5158F40A900321E06 /* MKChannelACL.h */; };
  135
+		BCD11DFB158F40A900321E06 /* MKChannelGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD11DF6158F40A900321E06 /* MKChannelGroup.h */; };
  136
+		BCD11DFC158F40A900321E06 /* MKChannelGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD11DF6158F40A900321E06 /* MKChannelGroup.h */; };
  137
+		BCD11E09158F40FA00321E06 /* MKAccessControl.m in Sources */ = {isa = PBXBuildFile; fileRef = BCD11E06158F40FA00321E06 /* MKAccessControl.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
  138
+		BCD11E0A158F40FA00321E06 /* MKAccessControl.m in Sources */ = {isa = PBXBuildFile; fileRef = BCD11E06158F40FA00321E06 /* MKAccessControl.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
  139
+		BCD11E0B158F40FA00321E06 /* MKChannelACL.m in Sources */ = {isa = PBXBuildFile; fileRef = BCD11E07158F40FA00321E06 /* MKChannelACL.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
  140
+		BCD11E0C158F40FA00321E06 /* MKChannelACL.m in Sources */ = {isa = PBXBuildFile; fileRef = BCD11E07158F40FA00321E06 /* MKChannelACL.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
  141
+		BCD11E0D158F40FA00321E06 /* MKChannelGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = BCD11E08158F40FA00321E06 /* MKChannelGroup.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
  142
+		BCD11E0E158F40FA00321E06 /* MKChannelGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = BCD11E08158F40FA00321E06 /* MKChannelGroup.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
129 143
 /* End PBXBuildFile section */
130 144
 
131 145
 /* Begin PBXContainerItemProxy section */
@@ -396,6 +410,13 @@
396 410
 		28CC3711132EDC7300241269 /* libSpeex.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libSpeex.a; sourceTree = BUILT_PRODUCTS_DIR; };
397 411
 		28CC3712132EDC7300241269 /* libSpeexDSP.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libSpeexDSP.a; sourceTree = BUILT_PRODUCTS_DIR; };
398 412
 		28F2FAD413E37BA000034BF2 /* MKAudioOutputUserPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MKAudioOutputUserPrivate.h; path = src/MKAudioOutputUserPrivate.h; sourceTree = SOURCE_ROOT; };
  413
+		BCD11DF1158F3FD600321E06 /* MKPermission.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MKPermission.h; path = src/MumbleKit/MKPermission.h; sourceTree = SOURCE_ROOT; };
  414
+		BCD11DF4158F40A900321E06 /* MKAccessControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MKAccessControl.h; path = src/MumbleKit/MKAccessControl.h; sourceTree = SOURCE_ROOT; };
  415
+		BCD11DF5158F40A900321E06 /* MKChannelACL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MKChannelACL.h; path = src/MumbleKit/MKChannelACL.h; sourceTree = SOURCE_ROOT; };
  416
+		BCD11DF6158F40A900321E06 /* MKChannelGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MKChannelGroup.h; path = src/MumbleKit/MKChannelGroup.h; sourceTree = SOURCE_ROOT; };
  417
+		BCD11E06158F40FA00321E06 /* MKAccessControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MKAccessControl.m; path = src/MKAccessControl.m; sourceTree = SOURCE_ROOT; };
  418
+		BCD11E07158F40FA00321E06 /* MKChannelACL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MKChannelACL.m; path = src/MKChannelACL.m; sourceTree = SOURCE_ROOT; };
  419
+		BCD11E08158F40FA00321E06 /* MKChannelGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MKChannelGroup.m; path = src/MKChannelGroup.m; sourceTree = SOURCE_ROOT; };
399 420
 /* End PBXFileReference section */
400 421
 
401 422
 /* Begin PBXFrameworksBuildPhase section */
@@ -485,6 +506,7 @@
485 506
 				28CC36F8132ED92500241269 /* Mumble.pb.m */,
486 507
 				28CC36F9132ED92500241269 /* ObjectivecDescriptor.pb.m */,
487 508
 				2845A781132D9C220034D631 /* CryptState.cpp */,
  509
+				BCD11E06158F40FA00321E06 /* MKAccessControl.m */,
488 510
 				2845A782132D9C220034D631 /* MKAudio.m */,
489 511
 				2845A783132D9C220034D631 /* MKAudioInput.m */,
490 512
 				2845A784132D9C220034D631 /* MKAudioOutput.m */,
@@ -493,6 +515,8 @@
493 515
 				2845A786132D9C220034D631 /* MKAudioOutputUser.m */,
494 516
 				2845A787132D9C220034D631 /* MKCertificate.m */,
495 517
 				2845A788132D9C220034D631 /* MKChannel.m */,
  518
+				BCD11E07158F40FA00321E06 /* MKChannelACL.m */,
  519
+				BCD11E08158F40FA00321E06 /* MKChannelGroup.m */,
496 520
 				2845A789132D9C220034D631 /* MKConnection.m */,
497 521
 				2845A78A132D9C220034D631 /* MKConnectionController.m */,
498 522
 				2845A78B132D9C220034D631 /* MKCryptState_openssl.mm */,
@@ -512,11 +536,15 @@
512 536
 		2845A780132D9BF50034D631 /* Public Headers */ = {
513 537
 			isa = PBXGroup;
514 538
 			children = (
  539
+				BCD11DF4158F40A900321E06 /* MKAccessControl.h */,
515 540
 				2845A7C7132D9C520034D631 /* MKAudio.h */,
516 541
 				2845A7CC132D9C520034D631 /* MKCertificate.h */,
517 542
 				2845A7CD132D9C520034D631 /* MKChannel.h */,
  543
+				BCD11DF5158F40A900321E06 /* MKChannelACL.h */,
  544
+				BCD11DF6158F40A900321E06 /* MKChannelGroup.h */,
518 545
 				2845A7CE132D9C520034D631 /* MKConnection.h */,
519 546
 				2845A7CF132D9C520034D631 /* MKConnectionController.h */,
  547
+				BCD11DF1158F3FD600321E06 /* MKPermission.h */,
520 548
 				2845A7D3132D9C520034D631 /* MKServerModel.h */,
521 549
 				282F6B0613624187008F555B /* MKServerPinger.h */,
522 550
 				2845A7D5132D9C520034D631 /* MKServices.h */,
@@ -685,6 +713,10 @@
685 713
 				2879526914C1BDD800567430 /* MKTextMessage.h in Headers */,
686 714
 				281EADA61530EA30000793AB /* MKDistinguishedNameParser.h in Headers */,
687 715
 				28074E91158A6E5100E0A4D0 /* MKAudioOutputSidetone.h in Headers */,
  716
+				BCD11DF3158F3FD600321E06 /* MKPermission.h in Headers */,
  717
+				BCD11DF8158F40A900321E06 /* MKAccessControl.h in Headers */,
  718
+				BCD11DFA158F40A900321E06 /* MKChannelACL.h in Headers */,
  719
+				BCD11DFC158F40A900321E06 /* MKChannelGroup.h in Headers */,
688 720
 			);
689 721
 			runOnlyForDeploymentPostprocessing = 0;
690 722
 		};
@@ -717,6 +749,10 @@
717 749
 				2879526814C1BDD800567430 /* MKTextMessage.h in Headers */,
718 750
 				281EADA51530EA30000793AB /* MKDistinguishedNameParser.h in Headers */,
719 751
 				28074E90158A6E5100E0A4D0 /* MKAudioOutputSidetone.h in Headers */,
  752
+				BCD11DF2158F3FD600321E06 /* MKPermission.h in Headers */,
  753
+				BCD11DF7158F40A900321E06 /* MKAccessControl.h in Headers */,
  754
+				BCD11DF9158F40A900321E06 /* MKChannelACL.h in Headers */,
  755
+				BCD11DFB158F40A900321E06 /* MKChannelGroup.h in Headers */,
720 756
 			);
721 757
 			runOnlyForDeploymentPostprocessing = 0;
722 758
 		};
@@ -948,6 +984,9 @@
948 984
 				2879526514C1BAB900567430 /* MKTextMessage.m in Sources */,
949 985
 				281EADA81530EA30000793AB /* MKDistinguishedNameParser.m in Sources */,
950 986
 				28074E93158A6E5100E0A4D0 /* MKAudioOutputSidetone.m in Sources */,
  987
+				BCD11E0A158F40FA00321E06 /* MKAccessControl.m in Sources */,
  988
+				BCD11E0C158F40FA00321E06 /* MKChannelACL.m in Sources */,
  989
+				BCD11E0E158F40FA00321E06 /* MKChannelGroup.m in Sources */,
951 990
 			);
952 991
 			runOnlyForDeploymentPostprocessing = 0;
953 992
 		};
@@ -978,6 +1017,9 @@
978 1017
 				2879526414C1BAB900567430 /* MKTextMessage.m in Sources */,
979 1018
 				281EADA71530EA30000793AB /* MKDistinguishedNameParser.m in Sources */,
980 1019
 				28074E92158A6E5100E0A4D0 /* MKAudioOutputSidetone.m in Sources */,
  1020
+				BCD11E09158F40FA00321E06 /* MKAccessControl.m in Sources */,
  1021
+				BCD11E0B158F40FA00321E06 /* MKChannelACL.m in Sources */,
  1022
+				BCD11E0D158F40FA00321E06 /* MKChannelGroup.m in Sources */,
981 1023
 			);
982 1024
 			runOnlyForDeploymentPostprocessing = 0;
983 1025
 		};
17  src/MKAccessControl.m
... ...
@@ -0,0 +1,17 @@
  1
+// Copyright 2012 The MumbleKit Developers. All rights reserved.
  2
+// Use of this source code is governed by a BSD-style
  3
+// license that can be found in the LICENSE file.
  4
+
  5
+#import "MKAccessControl.h"
  6
+
  7
+@implementation MKAccessControl
  8
+
  9
+@synthesize inheritACLs;
  10
+@synthesize groups;
  11
+@synthesize acls;
  12
+
  13
+- (NSString *) description {
  14
+    return [NSString stringWithFormat:@"{\n\tinheritACLs: %@\n\tgroups: %@\n\tacls: %@\n}", self.inheritACLs ? @"YES" : @"NO", self.groups, self.acls];
  15
+}
  16
+
  17
+@end
146  src/MKChannelACL.m
... ...
@@ -0,0 +1,146 @@
  1
+// Copyright 2012 The MumbleKit Developers. All rights reserved.
  2
+// Use of this source code is governed by a BSD-style
  3
+// license that can be found in the LICENSE file.
  4
+
  5
+#import "MKChannelACL.h"
  6
+
  7
+@implementation MKChannelACL
  8
+
  9
+@synthesize applyHere;
  10
+@synthesize applySubs;
  11
+@synthesize inherited;
  12
+@synthesize userID;
  13
+@synthesize group;
  14
+@synthesize grant;
  15
+@synthesize deny;
  16
+
  17
+- (BOOL) hasUserID {
  18
+    return (self.userID > -1);
  19
+}
  20
+
  21
+- (NSString *) description {
  22
+    NSMutableString *grantDescription = [[NSMutableString alloc] init];
  23
+    if (self.grant == MKPermissionAll) {
  24
+        [grantDescription appendString:@"All"];
  25
+    } else if (self.grant == MKPermissionNone) {
  26
+        [grantDescription appendString:@"None"];
  27
+    } else {
  28
+        if ((self.grant & MKPermissionWrite) == MKPermissionWrite) {
  29
+            [grantDescription appendString:@"Write | "];
  30
+        }
  31
+        if ((self.grant & MKPermissionTraverse) == MKPermissionTraverse) {
  32
+            [grantDescription appendString:@"Traverse | "];
  33
+        }
  34
+        if ((self.grant & MKPermissionEnter) == MKPermissionEnter) {
  35
+            [grantDescription appendString:@"Enter | "];
  36
+        }
  37
+        if ((self.grant & MKPermissionSpeak) == MKPermissionSpeak) {
  38
+            [grantDescription appendString:@"Speak | "];
  39
+        }
  40
+        if ((self.grant & MKPermissionMuteDeafen) == MKPermissionMuteDeafen) {
  41
+            [grantDescription appendString:@"MuteDeafen | "];
  42
+        }
  43
+        if ((self.grant & MKPermissionMove) == MKPermissionMove) {
  44
+            [grantDescription appendString:@"Move | "];
  45
+        }
  46
+        if ((self.grant & MKPermissionMakeChannel) == MKPermissionMakeChannel) {
  47
+            [grantDescription appendString:@"MakeChannel | "];
  48
+        }
  49
+        if ((self.grant & MKPermissionLinkChannel) == MKPermissionLinkChannel) {
  50
+            [grantDescription appendString:@"LinkChannel | "];
  51
+        }
  52
+        if ((self.grant & MKPermissionWhisper) == MKPermissionWhisper) {
  53
+            [grantDescription appendString:@"Whisper | "];
  54
+        }
  55
+        if ((self.grant & MKPermissionTextMessage) == MKPermissionTextMessage) {
  56
+            [grantDescription appendString:@"TextMessage | "];
  57
+        }
  58
+        if ((self.grant & MKPermissionMakeTempChannel) == MKPermissionMakeTempChannel) {
  59
+            [grantDescription appendString:@"MakeTempChannel | "];
  60
+        }
  61
+        if ((self.grant & MKPermissionKick) == MKPermissionKick) {
  62
+            [grantDescription appendString:@"Kick | "];
  63
+        }
  64
+        if ((self.grant & MKPermissionBan) == MKPermissionBan) {
  65
+            [grantDescription appendString:@"Ban | "];
  66
+        }
  67
+        if ((self.grant & MKPermissionRegister) == MKPermissionRegister) {
  68
+            [grantDescription appendString:@"Register | "];
  69
+        }
  70
+        if ((self.grant & MKPermissionSelfRegister) == MKPermissionSelfRegister) {
  71
+            [grantDescription appendString:@"SelfRegister | "];
  72
+        }
  73
+        
  74
+        if (grantDescription.length > 0) {
  75
+            grantDescription = [NSMutableString stringWithString:[grantDescription substringToIndex:grantDescription.length-3]];
  76
+        }
  77
+    }
  78
+    
  79
+    NSMutableString *denyDescription = [[NSMutableString alloc] init];
  80
+    if (self.deny == MKPermissionAll) {
  81
+        [denyDescription appendString:@"All"];
  82
+    } else if (self.deny == MKPermissionNone) {
  83
+        [denyDescription appendString:@"None"];
  84
+    } else {
  85
+        if ((self.deny & MKPermissionWrite) == MKPermissionWrite) {
  86
+            [denyDescription appendString:@"Write | "];
  87
+        }
  88
+        if ((self.deny & MKPermissionTraverse) == MKPermissionTraverse) {
  89
+            [denyDescription appendString:@"Traverse | "];
  90
+        }
  91
+        if ((self.deny & MKPermissionEnter) == MKPermissionEnter) {
  92
+            [denyDescription appendString:@"Enter | "];
  93
+        }
  94
+        if ((self.deny & MKPermissionSpeak) == MKPermissionSpeak) {
  95
+            [denyDescription appendString:@"Speak | "];
  96
+        }
  97
+        if ((self.deny & MKPermissionMuteDeafen) == MKPermissionMuteDeafen) {
  98
+            [denyDescription appendString:@"MuteDeafen | "];
  99
+        }
  100
+        if ((self.deny & MKPermissionMove) == MKPermissionMove) {
  101
+            [denyDescription appendString:@"Move | "];
  102
+        }
  103
+        if ((self.deny & MKPermissionMakeChannel) == MKPermissionMakeChannel) {
  104
+            [denyDescription appendString:@"MakeChannel | "];
  105
+        }
  106
+        if ((self.deny & MKPermissionLinkChannel) == MKPermissionLinkChannel) {
  107
+            [denyDescription appendString:@"LinkChannel | "];
  108
+        }
  109
+        if ((self.deny & MKPermissionWhisper) == MKPermissionWhisper) {
  110
+            [denyDescription appendString:@"Whisper | "];
  111
+        }
  112
+        if ((self.deny & MKPermissionTextMessage) == MKPermissionTextMessage) {
  113
+            [denyDescription appendString:@"TextMessage | "];
  114
+        }
  115
+        if ((self.deny & MKPermissionMakeTempChannel) == MKPermissionMakeTempChannel) {
  116
+            [denyDescription appendString:@"MakeTempChannel | "];
  117
+        }
  118
+        if ((self.deny & MKPermissionKick) == MKPermissionKick) {
  119
+            [denyDescription appendString:@"Kick | "];
  120
+        }
  121
+        if ((self.deny & MKPermissionBan) == MKPermissionBan) {
  122
+            [denyDescription appendString:@"Ban | "];
  123
+        }
  124
+        if ((self.deny & MKPermissionRegister) == MKPermissionRegister) {
  125
+            [denyDescription appendString:@"Register | "];
  126
+        }
  127
+        if ((self.deny & MKPermissionSelfRegister) == MKPermissionSelfRegister) {
  128
+            [denyDescription appendString:@"SelfRegister | "];
  129
+        }
  130
+        
  131
+        if (denyDescription.length > 0) {
  132
+            denyDescription = [NSMutableString stringWithString:[denyDescription substringToIndex:denyDescription.length-3]];
  133
+        }
  134
+    }
  135
+    
  136
+    return [NSString stringWithFormat:@"{applyHere: %@; applySubs: %@; inherited: %@; %@: %@; grant: %@; deny: %@}",
  137
+            self.applyHere ? @"YES" : @"NO",
  138
+            self.applySubs ? @"YES" : @"NO",
  139
+            self.inherited ? @"YES" : @"NO",
  140
+            self.hasUserID ? @"userID" : @"group",
  141
+            self.hasUserID ? [NSNumber numberWithInt:self.userID] : self.group,
  142
+            grantDescription,
  143
+            denyDescription];
  144
+}
  145
+
  146
+@end
27  src/MKChannelGroup.m
... ...
@@ -0,0 +1,27 @@
  1
+// Copyright 2012 The MumbleKit Developers. All rights reserved.
  2
+// Use of this source code is governed by a BSD-style
  3
+// license that can be found in the LICENSE file.
  4
+
  5
+#import "MKChannelGroup.h"
  6
+
  7
+@implementation MKChannelGroup
  8
+
  9
+@synthesize name;
  10
+@synthesize inherited;
  11
+@synthesize inherit;
  12
+@synthesize inheritable;
  13
+@synthesize members;
  14
+@synthesize excludedMembers;
  15
+@synthesize inheritedMembers;
  16
+
  17
+- (NSString *) description {
  18
+    return [NSString stringWithFormat:@"{name: %@; inherited: %@; inherit: %@; inheritable: %@; members: %@; excludedMembers: %@; inheritedMembers: %@}",
  19
+            self.name,
  20
+            self.inherited ? @"YES" : @"NO",
  21
+            self.inherit ? @"YES" : @"NO",
  22
+            self.inheritable ? @"YES" : @"NO",
  23
+            self.members,
  24
+            self.excludedMembers,
  25
+            self.inheritedMembers];
  26
+}
  27
+@end
136  src/MKServerModel.m
@@ -20,6 +20,9 @@
20 20
 
21 21
 #import "MulticastDelegate.h"
22 22
 
  23
+#import <MumbleKit/MKChannelACL.h>
  24
+#import <MumbleKit/MKChannelGroup.h>
  25
+
23 26
 // fixme(mkrautz): Refactor once 1.0's out the door.
24 27
 @interface MKAudio ()
25 28
 - (void) setSelfMuted:(BOOL)selfMuted;
@@ -399,7 +402,7 @@ - (void) connection:(MKConnection *)conn handlePermissionDeniedMessage: (MPPermi
399 402
             break;
400 403
         }
401 404
         case MPPermissionDenied_DenyTypeChannelName: {
402  
-            [_delegate serverModelChannelFullError:self];
  405
+            [_delegate serverModelChannelNameError:self];
403 406
             break;
404 407
         }
405 408
         case MPPermissionDenied_DenyTypeTextTooLong: {
@@ -449,7 +452,65 @@ - (void) connection:(MKConnection *)conn handleTextMessageMessage: (MPTextMessag
449 452
     [_delegate serverModel:self textMessageReceived:txtMsg fromUser:sender];
450 453
 }
451 454
 
452  
-- (void) connection:(MKConnection *)conn handleACLMessage: (MPACL *)msg {
  455
+- (void) connection:(MKConnection *)conn handleACLMessage: (MPACL *)msg {    
  456
+    if (! [msg hasChannelId]) {
  457
+        return;
  458
+    }
  459
+    
  460
+    MKChannel *chan = [self channelWithId:[msg channelId]];
  461
+    
  462
+    MKAccessControl *acl = [[MKAccessControl alloc] init];
  463
+    acl.inheritACLs = msg.inheritAcls;
  464
+    acl.acls = [NSMutableArray array];
  465
+    acl.groups = [NSMutableArray array];
  466
+    
  467
+    for (MPACL_ChanACL *chanACL in msg.acls) {
  468
+        MKChannelACL *channelACL = [[MKChannelACL alloc] init];
  469
+        if (chanACL.hasUserId) {
  470
+            channelACL.userID = chanACL.userId;
  471
+            channelACL.group = nil;
  472
+        } else {
  473
+            channelACL.userID = -1;
  474
+            channelACL.group = chanACL.group;
  475
+        }
  476
+        
  477
+        channelACL.applyHere = chanACL.applyHere;
  478
+        channelACL.applySubs = chanACL.applySubs;
  479
+        channelACL.deny = chanACL.deny;
  480
+        channelACL.grant = chanACL.grant;
  481
+        channelACL.inherited = chanACL.inherited;
  482
+        
  483
+        [acl.acls addObject:channelACL];
  484
+        [channelACL release];
  485
+    }
  486
+    
  487
+    
  488
+    for (MPACL_ChanGroup *chanGroup in msg.groups) {
  489
+        MKChannelGroup *channelGroup = [[MKChannelGroup alloc] init];
  490
+        channelGroup.name = chanGroup.name;
  491
+        channelGroup.inheritable = chanGroup.inheritable;
  492
+        channelGroup.inherit = chanGroup.inherit;
  493
+        channelGroup.inherited = chanGroup.inherited;
  494
+        
  495
+        channelGroup.members = [NSMutableArray array];
  496
+        channelGroup.excludedMembers = [NSMutableArray array];
  497
+        channelGroup.inheritedMembers = [NSMutableArray array];
  498
+        
  499
+        for (NSNumber *value in chanGroup.add) {
  500
+            [channelGroup.members addObject:value];
  501
+        }
  502
+        for (NSNumber *value in chanGroup.remove) {
  503
+            [channelGroup.excludedMembers addObject:value];
  504
+        }
  505
+        for (NSNumber *value in chanGroup.inheritedMembers) {
  506
+            [channelGroup.inheritedMembers addObject:value];
  507
+        }
  508
+        
  509
+        [acl.groups addObject:channelGroup];
  510
+        [channelGroup release];
  511
+    }
  512
+    
  513
+    [_delegate serverModel:self didReceiveAccessControl:[acl autorelease] forChannel:chan];   
453 514
 }
454 515
 
455 516
 - (void) connection:(MKConnection *)conn handleQueryUsersMessage: (MPQueryUsers *)msg {
@@ -860,6 +921,77 @@ - (void) joinChannel:(MKChannel *)chan {
860 921
     [_connection sendMessageWithType:UserStateMessage data:data];
861 922
 }
862 923
 
  924
+// Create a channel
  925
+- (void) createChannelWithName:(NSString *)channelName parent:(MKChannel *)parent temporary:(BOOL)temp {
  926
+    MPChannelState_Builder *channelState = [MPChannelState builder];
  927
+    channelState.name = channelName;
  928
+    channelState.parent = parent.channelId;
  929
+    channelState.temporary = temp;
  930
+    
  931
+    NSData *data = [[channelState build] data];
  932
+    [_connection sendMessageWithType:ChannelStateMessage data:data];
  933
+}
  934
+
  935
+// Request the access control for a channel
  936
+- (void) requestAccessControlForChannel:(MKChannel *)channel {
  937
+    MPACL_Builder *mpacl = [MPACL builder];
  938
+    mpacl.channelId = channel.channelId;
  939
+    mpacl.query = YES;
  940
+    
  941
+    NSData *data = [[mpacl build] data];
  942
+    [_connection sendMessageWithType:ACLMessage data:data];
  943
+}
  944
+
  945
+// Set the access control for a channel
  946
+- (void) setAccessControl:(MKAccessControl *)accessControl forChannel:(MKChannel *)channel {
  947
+    MPACL_Builder *mpacl = [MPACL builder];
  948
+    mpacl.channelId = channel.channelId;
  949
+    mpacl.query = YES;
  950
+    mpacl.inheritAcls = accessControl.inheritACLs;
  951
+    
  952
+    NSMutableArray *aclsArray = [NSMutableArray array];
  953
+    for (MKChannelACL *channelACL in accessControl.acls) {
  954
+        if (channelACL.inherited) {
  955
+            continue;
  956
+        }
  957
+        
  958
+        MPACL_ChanACL_Builder *chanACL = [MPACL_ChanACL builder];
  959
+        chanACL.applyHere = channelACL.applyHere;
  960
+        chanACL.applySubs = channelACL.applySubs;
  961
+        chanACL.deny = channelACL.deny;
  962
+        chanACL.grant = channelACL.grant;
  963
+        
  964
+        if (channelACL.hasUserID) {
  965
+            chanACL.userId = channelACL.userID;
  966
+        } else {
  967
+            chanACL.group = channelACL.group;
  968
+        }
  969
+        
  970
+        [aclsArray addObject:[chanACL build]];
  971
+    }
  972
+    [mpacl setAclsArray:aclsArray];
  973
+    
  974
+    NSMutableArray *groupsArray = [NSMutableArray array];
  975
+    for (MKChannelGroup *channelGroup in accessControl.groups) {
  976
+        if (channelGroup.inherited) {
  977
+            continue;
  978
+        }
  979
+        
  980
+        MPACL_ChanGroup_Builder *chanGroup = [MPACL_ChanGroup builder];
  981
+        chanGroup.name = channelGroup.name;
  982
+        chanGroup.inherit = channelGroup.inherit;
  983
+        chanGroup.inheritable = channelGroup.inheritable;
  984
+        chanGroup.addArray = channelGroup.members;
  985
+        chanGroup.removeArray = channelGroup.excludedMembers;
  986
+        [groupsArray addObject:[chanGroup build]];
  987
+    }
  988
+    [mpacl setGroupsArray:groupsArray];
  989
+    
  990
+    NSData *data = [[mpacl build] data];
  991
+    
  992
+    [_connection sendMessageWithType:ACLMessage data:data];
  993
+}
  994
+
863 995
 #pragma mark -
864 996
 #pragma mark Text message operations
865 997
 
11  src/MumbleKit/MKAccessControl.h
... ...
@@ -0,0 +1,11 @@
  1
+// Copyright 2012 The MumbleKit Developers. All rights reserved.
  2
+// Use of this source code is governed by a BSD-style
  3
+// license that can be found in the LICENSE file.
  4
+
  5
+@interface MKAccessControl : NSObject
  6
+
  7
+@property (nonatomic) BOOL inheritACLs;
  8
+@property (nonatomic, strong) NSMutableArray * groups;
  9
+@property (nonatomic, strong) NSMutableArray * acls;
  10
+
  11
+@end
18  src/MumbleKit/MKChannelACL.h
... ...
@@ -0,0 +1,18 @@
  1
+// Copyright 2012 The MumbleKit Developers. All rights reserved.
  2
+// Use of this source code is governed by a BSD-style
  3
+// license that can be found in the LICENSE file.
  4
+
  5
+#import <MumbleKit/MKPermission.h>
  6
+
  7
+@interface MKChannelACL : NSObject
  8
+
  9
+@property (nonatomic) BOOL applyHere;
  10
+@property (nonatomic) BOOL applySubs;
  11
+@property (nonatomic) BOOL inherited;
  12
+@property (nonatomic) NSInteger userID;
  13
+@property (nonatomic, strong) NSString * group;
  14
+@property (nonatomic) MKPermission grant;
  15
+@property (nonatomic) MKPermission deny;
  16
+@property (nonatomic, readonly) BOOL hasUserID;
  17
+
  18
+@end
15  src/MumbleKit/MKChannelGroup.h
... ...
@@ -0,0 +1,15 @@
  1
+// Copyright 2012 The MumbleKit Developers. All rights reserved.
  2
+// Use of this source code is governed by a BSD-style
  3
+// license that can be found in the LICENSE file.
  4
+
  5
+@interface MKChannelGroup : NSObject
  6
+
  7
+@property (nonatomic, strong) NSString * name;
  8
+@property (nonatomic) BOOL inherited;
  9
+@property (nonatomic) BOOL inherit;
  10
+@property (nonatomic) BOOL inheritable;
  11
+@property (nonatomic, strong) NSMutableArray * members;
  12
+@property (nonatomic, strong) NSMutableArray * excludedMembers;
  13
+@property (nonatomic, strong) NSMutableArray * inheritedMembers;
  14
+
  15
+@end
24  src/MumbleKit/MKPermission.h
... ...
@@ -0,0 +1,24 @@
  1
+// Copyright 2010-2012 The MumbleKit Developers. All rights reserved.
  2
+// Use of this source code is governed by a BSD-style
  3
+// license that can be found in the LICENSE file.
  4
+
  5
+typedef enum {
  6
+    MKPermissionNone             = 0x00000,
  7
+    MKPermissionWrite            = 0x00001,
  8
+    MKPermissionTraverse         = 0x00002,
  9
+    MKPermissionEnter            = 0x00004,
  10
+    MKPermissionSpeak            = 0x00008,
  11
+    MKPermissionMuteDeafen       = 0x00010,
  12
+    MKPermissionMove             = 0x00020,
  13
+    MKPermissionMakeChannel      = 0x00040,
  14
+    MKPermissionLinkChannel      = 0x00080,
  15
+    MKPermissionWhisper          = 0x00100,
  16
+    MKPermissionTextMessage      = 0x00200,
  17
+    MKPermissionMakeTempChannel  = 0x00400,
  18
+    MKPermissionKick             = 0x10000,
  19
+    MKPermissionBan              = 0x20000,
  20
+    MKPermissionRegister         = 0x40000,
  21
+    MKPermissionSelfRegister     = 0x80000,
  22
+    MKPermissionAll              = 0xf07ff,
  23
+} MKPermission;
  24
+
64  src/MumbleKit/MKServerModel.h
@@ -6,29 +6,12 @@
6 6
 #import <MumbleKit/MKChannel.h>
7 7
 #import <MumbleKit/MKConnection.h>
8 8
 #import <MumbleKit/MKTextMessage.h>
  9
+#import <MumbleKit/MKPermission.h>
  10
+#import <MumbleKit/MKAccessControl.h>
9 11
 
10 12
 @class MulticastDelegate;
11 13
 @class MKServerModel;
12 14
 
13  
-typedef enum {
14  
-    MKPermissionNone             = 0x00000,
15  
-    MKPermissionWrite            = 0x00001,
16  
-    MKPermissionTraverse         = 0x00002,
17  
-    MKPermissionEnter            = 0x00004,
18  
-    MKPermissionSpeak            = 0x00008,
19  
-    MKPermissionMuteDeafen       = 0x00010,
20  
-    MKPermissionMove             = 0x00020,
21  
-    MKPermissionMakeChannel      = 0x00040,
22  
-    MKPermissionLinkChannel      = 0x00080,
23  
-    MKPermissionWhisper          = 0x00100,
24  
-    MKPermissionTextMessage      = 0x00200,
25  
-    MKPermissionMakeTempChannel  = 0x00400,
26  
-    MKPermissionKick             = 0x10000,
27  
-    MKPermissionBan              = 0x20000,
28  
-    MKPermissionRegister         = 0x40000,
29  
-    MKPermissionSelfRegister     = 0x80000,
30  
-} MKPermission;
31  
-
32 15
 /**
33 16
  * MKServerModelDelegate is the delegate of MKServerModel.
34 17
  * It is called to notify any registered delegates of events happening on the server, or
@@ -525,6 +508,14 @@ typedef enum {
525 508
 - (void) serverModelChannelFullError:(MKServerModel *)model;
526 509
 
527 510
 /**
  511
+ * Called when a channel create operation failed because the channel
  512
+ * name was invalid.
  513
+ *
  514
+ * @param  model  The MKServerModel in which this error occurred.
  515
+ */
  516
+- (void) serverModelChannelNameError:(MKServerModel *)model;
  517
+
  518
+/**
528 519
  * Called when a simple 'Permission denied.' message is sufficient to show to the user.
529 520
  * Can include a reason. This kind of permission error is also used as a fallback, if
530 521
  * the server detects that a client is using a too old version of the Mumble protocol
@@ -534,6 +525,16 @@ typedef enum {
534 525
  * @param  reason  The reason for the error. May be nil if no reason was given.
535 526
  */
536 527
 - (void) serverModel:(MKServerModel *)model permissionDeniedForReason:(NSString *)reason;
  528
+
  529
+/**
  530
+ * Called after an access control request
  531
+ *
  532
+ * @param  model            The MKServerModel in which this event originated.
  533
+ * @param  accessControl    The requested access control.
  534
+ * @param  channel          The channel to which access control refers.
  535
+ */
  536
+- (void) serverModel:(MKServerModel *)model didReceiveAccessControl:(MKAccessControl *)accessControl forChannel:(MKChannel *)channel;
  537
+
537 538
 @end
538 539
 
539 540
 /**
@@ -642,6 +643,31 @@ typedef enum {
642 643
  */
643 644
 - (void) joinChannel:(MKChannel *)channel;
644 645
 
  646
+/**
  647
+ * Create a new channel in the server the underlying MKConnection is currently
  648
+ * connected to.
  649
+ *
  650
+ * @param channelName   The name of the channel to create.
  651
+ * @param parent        The MKChannel that must contain the newly created one.
  652
+ * @param temp          Specify if the channel is temporary or not.
  653
+ */
  654
+- (void) createChannelWithName:(NSString *)channelName parent:(MKChannel *)parent temporary:(BOOL)temp;
  655
+
  656
+/**
  657
+ * Ask the underlying connection to receive the access control for the given channel.
  658
+ *
  659
+ * @param channel  The channel for which you are requesting the access control.
  660
+ */
  661
+- (void) requestAccessControlForChannel:(MKChannel *)channel;
  662
+
  663
+/**
  664
+ * Set access control for a channel.
  665
+ *
  666
+ * @param acl       The access control you want to set.
  667
+ * @param channel   The channel for which you are setting the access control.
  668
+ */
  669
+- (void) setAccessControl:(MKAccessControl *)accessControl forChannel:(MKChannel *)channel;
  670
+
645 671
 ///------------------------------
646 672
 /// @name Text message operations
647 673
 ///------------------------------

0 notes on commit bf23e9d

Please sign in to comment.
Something went wrong with that request. Please try again.