adium 4491:ecf5bc9f7d89: Add a "Configure Room..." option to the...
commits at adium.im
commits at adium.im
Tue Jan 10 19:16:16 UTC 2012
details: http://hg.adium.im/adium/rev/ecf5bc9f7d89
revision: 4491:ecf5bc9f7d89
branch: AddConfigureRoomForMUCs
author: Thijs Alkemade <thijsalkemade at gmail.com>
date: Tue Jan 10 20:15:53 2012 +0100
Add a "Configure Room..." option to the MUC cog menu.
On a new branch, as this breaks string freeze.
diffs (96 lines):
diff -r 6bfad1569583 -r ecf5bc9f7d89 Plugins/Purple Service/ESPurpleJabberAccount.m
--- a/Plugins/Purple Service/ESPurpleJabberAccount.m Tue Jan 10 20:12:10 2012 +0100
+++ b/Plugins/Purple Service/ESPurpleJabberAccount.m Tue Jan 10 20:15:53 2012 +0100
@@ -48,8 +48,19 @@
- (BOOL)enableXMLConsole;
- (void)registerGateway:(NSMenuItem *)mitem;
- (void)removeGateway:(NSMenuItem *)mitem;
+
+- (void)configureRoom;
@end
+typedef enum {
+ AIUnspecifiedOperation = 1 << 0,
+ AIRequiresNoLevel = 1 << 1,
+ AIRequiresMember = 1 << 2,
+ AIRequiresAdmin = 1 << 3,
+ AIRequiresOwner = 1 << 4,
+ AIRequiresSelection = 1 << 5
+} AIXMPPOperationRequirement;
+
@implementation ESPurpleJabberAccount
- (void)initAccount
@@ -686,9 +697,72 @@
forListObject:listObject
inChat:chat];
+
+
+ [menu addItem:[NSMenuItem separatorItem]];
+
+ [menu addItemWithTitle:AILocalizedString(@"Configure Room...", nil)
+ target:self
+ action:@selector(configureRoom)
+ keyEquivalent:@""
+ tag:AIRequiresOwner];
+
return menu;
}
+- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
+{
+ AIXMPPOperationRequirement req = (AIXMPPOperationRequirement)menuItem.tag;
+ AIChat *chat = adium.interfaceController.activeChat;
+ BOOL anySelected = chat.chatContainer.messageViewController.selectedListObjects.count > 0;
+
+ AIGroupChatFlags flags = [chat flagsForContact:self];
+
+ if (((req & AIRequiresSelection) == AIRequiresSelection) && !anySelected) {
+ return FALSE;
+ }
+
+ req &= ~AIRequiresSelection;
+
+ switch (req) {
+ case AIRequiresOwner:
+ return (flags & AIGroupChatFounder) == AIGroupChatFounder;
+ break;
+
+ case AIRequiresAdmin:
+ return (flags & AIGroupChatOp) == AIGroupChatOp;
+ break;
+
+ case AIRequiresNoLevel:
+ return YES;
+ break;
+
+ default:
+ return YES;
+ break;
+ }
+}
+
+- (void)configureRoom
+{
+ AIChat *chat = adium.interfaceController.activeChat;
+ PurpleConversation *conv = convLookupFromChat(chat, self);
+
+ if (!conv) {
+ AILogWithSignature(@"Lookup of conv failed");
+ return;
+ }
+
+ JabberChat *jabber_chat = jabber_chat_find_by_conv(conv);
+
+ if (!jabber_chat) {
+ AILogWithSignature(@"Lookup of jabber chat failed");
+ return;
+ }
+
+ jabber_chat_request_room_configure(jabber_chat);
+}
+
#pragma mark Status
/*!
* @brief Return the purple status type to be used for a status
More information about the commits
mailing list