* Adium is the legal property of its developers, whose names are listed in the copyright file included * with this source distribution. * This program is free software; you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details. * You should have received a copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #import "AdiumChatEvents.h" #import <Adium/AIContactAlertsControllerProtocol.h> #import <Adium/AIListContact.h> #import <Adium/AIListObject.h> #import <AIUtilities/AIImageAdditions.h> #import <Adium/AIListGroup.h> @implementation AdiumChatEvents * @brief Our parent controller loaded * Register the events we generate with the contactAlertsController. * Assumption: The contactAlertController already loaded - (void)controllerDidLoad //Register the events we generate [adium.contactAlertsController registerEventID:CONTENT_CONTACT_JOINED_CHAT inGroup:AIMessageEventHandlerGroup [adium.contactAlertsController registerEventID:CONTENT_CONTACT_LEFT_CHAT inGroup:AIMessageEventHandlerGroup [adium.contactAlertsController registerEventID:CONTENT_GROUP_CHAT_INVITE inGroup:AIMessageEventHandlerGroup * @brief A group chat added a contact - (void)chat:(AIChat *)chat addedListContact:(AIListContact *)inContact [adium.contactAlertsController generateEvent:CONTENT_CONTACT_JOINED_CHAT userInfo:[NSDictionary dictionaryWithObject:chat previouslyPerformedActionIDs:nil]; * @brief A group chat removed a contact - (void)chat:(AIChat *)chat removedListContact:(AIListContact *)inContact [adium.contactAlertsController generateEvent:CONTENT_CONTACT_LEFT_CHAT userInfo:[NSDictionary dictionaryWithObject:chat previouslyPerformedActionIDs:nil]; #pragma mark Event descriptions - (NSString *)shortDescriptionForEventID:(NSString *)eventID if ([eventID isEqualToString:CONTENT_CONTACT_JOINED_CHAT]) { description = AILocalizedString(@"Joins a group chat",nil); } else if ([eventID isEqualToString:CONTENT_CONTACT_LEFT_CHAT]) { description = AILocalizedString(@"Leaves a group chat",nil); } else if ([eventID isEqualToString:CONTENT_GROUP_CHAT_INVITE]) { description = AILocalizedString(@"Invites you to a group chat",nil); - (NSString *)globalShortDescriptionForEventID:(NSString *)eventID if ([eventID isEqualToString:CONTENT_CONTACT_JOINED_CHAT]) { description = AILocalizedString(@"Contact joins a group chat",nil); } else if ([eventID isEqualToString:CONTENT_CONTACT_LEFT_CHAT]) { description = AILocalizedString(@"Contact leaves a group chat",nil); } else if ([eventID isEqualToString:CONTENT_GROUP_CHAT_INVITE]) { description = AILocalizedString(@"Contact invites you to a group chat",nil); //Evan: This exists because old X(tras) relied upon matching the description of event IDs, and I don't feel like making //a converter for old packs. If anyone wants to fix this situation, please feel free :) - (NSString *)englishGlobalShortDescriptionForEventID:(NSString *)eventID if ([eventID isEqualToString:CONTENT_CONTACT_JOINED_CHAT]) { description = @"Contact Joins"; } else if ([eventID isEqualToString:CONTENT_CONTACT_LEFT_CHAT]) { description = @"Contact Leaves"; } else if ([eventID isEqualToString:CONTENT_GROUP_CHAT_INVITE]) { description = @"Contact Invites You to Chat"; - (NSString *)longDescriptionForEventID:(NSString *)eventID forListObject:(AIListObject *)listObject NSString *description = nil; if ([eventID isEqualToString:CONTENT_CONTACT_JOINED_CHAT]) { format = AILocalizedString(@"When %@ joins a group chat",nil); } else if ([eventID isEqualToString:CONTENT_CONTACT_LEFT_CHAT]) { format = AILocalizedString(@"When %@ leaves a group chat",nil); } else if ([eventID isEqualToString:CONTENT_GROUP_CHAT_INVITE]) { format = AILocalizedString(@"When %@ invites you to a group chat",nil); name = ([listObject isKindOfClass:[AIListGroup class]] ? [NSString stringWithFormat:AILocalizedString(@"a member of %@",nil),listObject.displayName] : description = [NSString stringWithFormat:format, name]; if ([eventID isEqualToString:CONTENT_CONTACT_JOINED_CHAT]) { description = AILocalizedString(@"When a contact joins a group chat",nil); } else if ([eventID isEqualToString:CONTENT_CONTACT_LEFT_CHAT]) { description = AILocalizedString(@"When a contact leaves a group chat",nil); } else if ([eventID isEqualToString:CONTENT_GROUP_CHAT_INVITE]) { description = AILocalizedString(@"When a contact invites you to a group chat",nil); - (NSString *)naturalLanguageDescriptionForEventID:(NSString *)eventID listObject:(AIListObject *)listObject includeSubject:(BOOL)includeSubject NSString *description = nil; NSParameterAssert([userInfo isKindOfClass:[NSDictionary class]]); chat = [(NSDictionary *)userInfo objectForKey:@"AIChat"]; if ([eventID isEqualToString:CONTENT_CONTACT_JOINED_CHAT]) { description = [NSString stringWithFormat: AILocalizedString(@"%@ joined %@","Contact joined Chat Name"), } else if ([eventID isEqualToString:CONTENT_CONTACT_LEFT_CHAT]) { description = [NSString stringWithFormat: AILocalizedString(@"%@ left %@","Contact left Chat Name"), } else if ([eventID isEqualToString:CONTENT_CONTACT_LEFT_CHAT]) { description = [NSString stringWithFormat: AILocalizedString(@"%@ left %@","Contact left Chat Name"), } else if ([eventID isEqualToString:CONTENT_CONTACT_LEFT_CHAT]) { description = [NSString stringWithFormat: AILocalizedString(@"%@ invites you to a group chat","Contact invites you to a group chat"), } else if ([eventID isEqualToString:CONTENT_GROUP_CHAT_MENTION]) { description = [NSString stringWithFormat: AILocalizedString(@"%@ mentioned you in %@","Someone mentions your name in a group chat"), if ([eventID isEqualToString:CONTENT_CONTACT_JOINED_CHAT]) { description = [NSString stringWithFormat: AILocalizedString(@"joined %@","Contact joined Chat Name"), } else if ([eventID isEqualToString:CONTENT_CONTACT_LEFT_CHAT]) { description = [NSString stringWithFormat: AILocalizedString(@"left %@","Contact left Chat Name"), } else if ([eventID isEqualToString:CONTENT_GROUP_CHAT_INVITE]) { description = [NSString stringWithFormat: AILocalizedString(@"invites you to a group chat","Contact left Chat Name"), } else if ([eventID isEqualToString:CONTENT_GROUP_CHAT_MENTION]) { description = [NSString stringWithFormat: AILocalizedString(@"you were mentioned in %@","Someone mentions your name in a group chat"), - (NSImage *)imageForEventID:(NSString *)eventID static NSImage *eventImage = nil; if (!eventImage) eventImage = [[NSImage imageNamed:@"events-message" forClass:[self class]] retain]; - (NSString *)descriptionForCombinedEventID:(NSString *)eventID forListObject:(AIListObject *)listObject withCount:(NSUInteger)count if ([eventID isEqualToString:CONTENT_CONTACT_JOINED_CHAT]) { format = AILocalizedString(@"%u contacts joined", nil); } else if ([eventID isEqualToString:CONTENT_CONTACT_LEFT_CHAT]) { format = AILocalizedString(@"%u contacts left", nil); } else if ([eventID isEqualToString:CONTENT_GROUP_CHAT_INVITE]) { format = AILocalizedString(@"%u invites to a group chat", nil); return format ? [NSString stringWithFormat:format, count] : @"";