Adium

Ticket #344: blockedContactsAlpha.diff

File blockedContactsAlpha.diff, 12.9 kB (added by Kiel Gillard, 3 years ago)

Experimental patch... please let me know what you think :-)

  • Frameworks/Adium

    old new  
    4343- (void)setOnline:(BOOL)online notify:(NotifyTiming)notify silently:(BOOL)silent; 
    4444- (void)setSignonDate:(NSDate *)signonDate notify:(NotifyTiming)notify; 
    4545- (NSDate *)signonDate; 
     46- (void)setIsBlocked:(BOOL)yesOrNo; 
     47- (BOOL)isBlocked; 
    4648 
    4749- (void)setIdle:(BOOL)isIdle sinceDate:(NSDate *)idleSinceDate notify:(NotifyTiming)notify; 
    4850- (void)setServersideIconData:(NSData *)iconData notify:(NotifyTiming)notify; 
  • Frameworks/Adium

    old new  
    2626 
    2727#import <AIUtilities/AIMutableOwnerArray.h> 
    2828 
     29#define IS_BLOCKED_KEY @"isBlocked" 
     30 
    2931@implementation AIListContact 
    3032 
    3133//Init with an account 
     
    431433                                   notify:notify]; 
    432434} 
    433435 
     436/*! 
     437 * @brief Is this contact blocked? 
     438 */ 
     439- (BOOL)isBlocked 
     440{ 
     441        return [self integerStatusObjectForKey:IS_BLOCKED_KEY]; 
     442} 
     443 
     444/*! 
     445 * @brief Set if this contact is blocked 
     446 */ 
     447- (void)setIsBlocked:(BOOL)yesOrNo 
     448{ 
     449        [self setStatusObject:(yesOrNo ? [NSNumber numberWithBool:YES] : nil) 
     450                                   forKey:IS_BLOCKED_KEY  
     451                                   notify:NotifyNever]; 
     452} 
     453 
    434454#pragma mark Status 
    435455 
    436456/*! 
  • Plugins/Gaim

    old new  
    10131013                AIListContact   *contact = [self contactWithUID:sourceUID]; 
    10141014                 
    10151015                [(type == PRIVACY_PERMIT ? permittedContactsArray : deniedContactsArray) addObject:contact]; 
     1016                //contacts remember for themselves if they're blocked 
     1017                [contact setIsBlocked:(type == PRIVACY_DENY)]; 
    10161018        } 
    10171019} 
    10181020 
     
    10411043                 
    10421044                if (contact) { 
    10431045                        [(type == PRIVACY_PERMIT ? permittedContactsArray : deniedContactsArray) removeObject:contact]; 
     1046                        //contacts should remember if they're blocked 
     1047                        [contact setIsBlocked:(type == PRIVACY_PERMIT)]; 
    10441048                } 
    10451049        } 
    10461050} 
  • Adium.xcodeproj/project.pbxproj

    old new  
    11391139                9E28FDE806ADB30D0041553E /* adiumRedHighlight.png in Resources */ = {isa = PBXBuildFile; fileRef = 9E28FDE606ADB30D0041553E /* adiumRedHighlight.png */; }; 
    11401140                9E6417070613C55D006AF387 /* CBURLHandlingPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 9E6417050613C55C006AF387 /* CBURLHandlingPlugin.h */; }; 
    11411141                9E6417080613C55D006AF387 /* CBURLHandlingPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E6417060613C55C006AF387 /* CBURLHandlingPlugin.m */; }; 
     1142                9E6586AD08CD633A00FD51A9 /* KGContactBlockedPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 9E6586AB08CD633A00FD51A9 /* KGContactBlockedPlugin.h */; }; 
     1143                9E6586AE08CD633A00FD51A9 /* KGContactBlockedPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E6586AC08CD633A00FD51A9 /* KGContactBlockedPlugin.m */; }; 
    11421144                9E6A9BF70732CB500032C9F6 /* adiumOfflineHighlight.png in Resources */ = {isa = PBXBuildFile; fileRef = 9E6A9BF50732CB500032C9F6 /* adiumOfflineHighlight.png */; }; 
    11431145                9E6A9BF80732CB500032C9F6 /* adiumOffline.png in Resources */ = {isa = PBXBuildFile; fileRef = 9E6A9BF60732CB500032C9F6 /* adiumOffline.png */; }; 
    11441146                9EA125E9055B630900ECF349 /* CBGaimOscarAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = 9EA125E8055B630900ECF349 /* CBGaimOscarAccount.m */; }; 
     
    30093011                9E28FDE606ADB30D0041553E /* adiumRedHighlight.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = adiumRedHighlight.png; path = "Plugins/Status Menu Item/adiumRedHighlight.png"; sourceTree = "<group>"; }; 
    30103012                9E6417050613C55C006AF387 /* CBURLHandlingPlugin.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CBURLHandlingPlugin.h; path = "Plugins/URL Handling/CBURLHandlingPlugin.h"; sourceTree = "<group>"; }; 
    30113013                9E6417060613C55C006AF387 /* CBURLHandlingPlugin.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = CBURLHandlingPlugin.m; path = "Plugins/URL Handling/CBURLHandlingPlugin.m"; sourceTree = "<group>"; }; 
     3014                9E6586AB08CD633A00FD51A9 /* KGContactBlockedPlugin.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = KGContactBlockedPlugin.h; path = Source/KGContactBlockedPlugin.h; sourceTree = "<group>"; }; 
     3015                9E6586AC08CD633A00FD51A9 /* KGContactBlockedPlugin.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = KGContactBlockedPlugin.m; path = Source/KGContactBlockedPlugin.m; sourceTree = "<group>"; }; 
    30123016                9E6A9BF50732CB500032C9F6 /* adiumOfflineHighlight.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = adiumOfflineHighlight.png; path = "Plugins/Status Menu Item/adiumOfflineHighlight.png"; sourceTree = "<group>"; }; 
    30133017                9E6A9BF60732CB500032C9F6 /* adiumOffline.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = adiumOffline.png; path = "Plugins/Status Menu Item/adiumOffline.png"; sourceTree = "<group>"; }; 
    30143018                9E791D9405768B7A00547562 /* CBStatusMenuItemPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CBStatusMenuItemPlugin.h; path = "Plugins/Status Menu Item/CBStatusMenuItemPlugin.h"; sourceTree = "<group>"; }; 
     
    38373841                                347E7ACD07CAF98400350507 /* ESMetaContactContentsPlugin.m */, 
    38383842                                347E7AA907CAF8EE00350507 /* SAContactOnlineForPlugin.h */, 
    38393843                                347E7AA807CAF8EE00350507 /* SAContactOnlineForPlugin.m */, 
     3844                                9E6586AB08CD633A00FD51A9 /* KGContactBlockedPlugin.h */, 
     3845                                9E6586AC08CD633A00FD51A9 /* KGContactBlockedPlugin.m */, 
    38403846                        ); 
    38413847                        name = Tooltips; 
    38423848                        sourceTree = "<group>"; 
     
    64286434                                B02355A508CBE854008CDDDA /* sqliteInt.h in Headers */, 
    64296435                                B02355AF08CBE854008CDDDA /* vdbe.h in Headers */, 
    64306436                                B02355B308CBE854008CDDDA /* vdbeInt.h in Headers */, 
     6437                                9E6586AD08CD633A00FD51A9 /* KGContactBlockedPlugin.h in Headers */, 
    64316438                        ); 
    64326439                        runOnlyForDeploymentPostprocessing = 0; 
    64336440                }; 
     
    80788085                                B02355B208CBE854008CDDDA /* vdbefifo.c in Sources */, 
    80798086                                B02355B408CBE854008CDDDA /* vdbemem.c in Sources */, 
    80808087                                B02355B508CBE854008CDDDA /* where.c in Sources */, 
     8088                                9E6586AE08CD633A00FD51A9 /* KGContactBlockedPlugin.m in Sources */, 
    80818089                        ); 
    80828090                        runOnlyForDeploymentPostprocessing = 0; 
    80838091                }; 
  • Source/KGContactBlockedPlugin.h

    old new  
     1/*  
     2 * Adium is the legal property of its developers, whose names are listed in the copyright file included 
     3 * with this source distribution. 
     4 *  
     5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU 
     6 * General Public License as published by the Free Software Foundation; either version 2 of the License, 
     7 * or (at your option) any later version. 
     8 *  
     9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 
     10 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General 
     11 * Public License for more details. 
     12 *  
     13 * You should have received a copy of the GNU General Public License along with this program; if not, 
     14 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
     15 */ 
     16 
     17// 
     18//  KGContactBlockedPlugin.h 
     19//  Adium 
     20// 
     21//  Created by Kiel Gillard on 6/09/05. 
     22// 
     23 
     24#import <Adium/AIPlugin.h> 
     25 
     26@protocol AIContactListTooltipEntry; 
     27 
     28@interface KGContactBlockedPlugin : AIPlugin <AIContactListTooltipEntry> { 
     29} 
     30 
     31@end 
  • Source/KGContactBlockedPlugin.m

    old new  
     1// 
     2//  KGContactBlockedPlugin.m 
     3//  Adium 
     4// 
     5//  Created by Kiel Gillard on 6/09/05. 
     6// 
     7 
     8#import "KGContactBlockedPlugin.h" 
     9#import "AIAccountController.h" 
     10#import "AIInterfaceController.h" 
     11#import <Adium/AIListContact.h> 
     12#import <Adium/AIMetaContact.h> 
     13#import <AIUtilities/AIAttributedStringAdditions.h> 
     14 
     15@implementation KGContactBlockedPlugin 
     16/*! 
     17 * @class KGContactBlockedPlugin 
     18 * @brief Adds a "Blocked: Yes" to the tooltip bodies of blocked List/Meta contacts. 
     19 * Meta contacts have to be completely blocked. ESMetaContentsPlugin covers semi-blocked metas. 
     20 */ 
     21- (void)installPlugin 
     22{ 
     23    //Install our tooltip entry 
     24    [[adium interfaceController] registerContactListTooltipEntry:self secondaryEntry:YES]; 
     25} 
     26 
     27/*! 
     28 * @brief Tooltip entry 
     29 * 
     30 * @result An entry for the blocked label, or nil if no tooltip label and entry should be shown 
     31 */ 
     32- (NSAttributedString *)entryForObject:(AIListContact *)inObject 
     33{ 
     34        NSAttributedString *entry = nil; 
     35         
     36        //do this part for ListContacts only 
     37        if (![inObject isKindOfClass:[AIMetaContact class]] && [inObject isKindOfClass:[AIListContact class]]) { 
     38                 
     39                if ([inObject isBlocked]) { 
     40                        entry = [NSAttributedString stringWithString:AILocalizedString(@"Yes", nil)]; 
     41                } 
     42                 
     43        } else if ([inObject isKindOfClass:[AIMetaContact class]]) { 
     44                // We're only interested in metas whose list contacts are all blocked 
     45                 
     46                //do we have enough contacts in this meta? 
     47                unsigned contactCount = [[(AIMetaContact *)inObject listContacts] count]; 
     48                 
     49                if (contactCount > 1) { 
     50                        AIListContact   *currentContact = nil; 
     51                        NSEnumerator    *contactEnumerator = [(AIMetaContact *)inObject listContactsEnumerator]; 
     52                        unsigned blockedContactCount = 0; 
     53                         
     54                        //determine if all the contacts are blocked 
     55                        while ((currentContact = [contactEnumerator nextObject])) { 
     56                                if ([currentContact isBlocked]) { 
     57                                        ++blockedContactCount; 
     58                                } 
     59                        } 
     60                         
     61                        //is the entire meta blocked? 
     62                        if (blockedContactCount == contactCount) { 
     63                                entry = [NSAttributedString stringWithString:AILocalizedString(@"Yes", nil)]; 
     64                        } 
     65                } else { 
     66                        //there's only one contact in the meta, so see if it's blocked 
     67                        if ([[[(AIMetaContact *)inObject listContacts] lastObject] isBlocked]) { 
     68                                //it is blocked, therefore the entire meta is considered blocked 
     69                                entry = [NSAttributedString stringWithString:AILocalizedString(@"Yes", nil)]; 
     70                        } 
     71                } 
     72        } 
     73         
     74        return entry; 
     75} 
     76 
     77/*! 
     78 * @brief Tooltip entry 
     79 * 
     80 * @result The tooltip "Blocked" label 
     81 */ 
     82- (NSString *)labelForObject:(AIListContact *)inObject 
     83{ 
     84        NSString *label = nil; 
     85        if ([inObject isKindOfClass:[AIListContact class]] || [inObject isKindOfClass:[AIMetaContact class]]) { 
     86                label = AILocalizedString(@"Blocked", @"Tooltip entry label to show a contact as blocked"); 
     87        } 
     88         
     89        return label; 
     90} 
     91 
     92@end 
  • Source/ESMetaContactContentsPlugin.m

    old new  
    7171                        AIListContact   *contact; 
    7272                        NSEnumerator    *enumerator; 
    7373                        BOOL                    shouldAppendString = NO; 
     74                        BOOL                    appendsBlockedString = YES; 
    7475                         
     76                        //see if all the contacts in the meta are blocked 
     77                        unsigned blockedContactCount = 0; 
     78                        enumerator = [listContacts objectEnumerator]; 
     79                        while ((contact = [enumerator nextObject])) { 
     80                                if ([contact isBlocked]) { 
     81                                        ++blockedContactCount; 
     82                                } 
     83                        } 
     84                         
     85                        //is the entire meta blocked? 
     86                        if (blockedContactCount == [listContacts count]) { 
     87                                appendsBlockedString = NO; 
     88                        } 
     89 
    7590                        entry = [[NSMutableAttributedString alloc] init]; 
    7691                        entryString = [entry mutableString]; 
    7792                         
     
    101116                                } 
    102117                                 
    103118                                [entryString appendString:[contact formattedUID]]; 
     119                                if (appendsBlockedString && [contact isBlocked]) { 
     120                                        [entryString appendFormat:@" (%@)", AILocalizedString(@"Blocked", @"Tooltip entry label to show a contact as blocked")]; 
     121                                } 
    104122                                 
    105123                                serviceIcon = [[AIServiceIcons serviceIconForObject:contact type:AIServiceIconSmall direction:AIIconNormal] 
    106124                                                                        imageByScalingToSize:META_TOOLTIP_ICON_SIZE]; 
  • Resources/CoreComponents.plist

    old new  
    7979        <string>SMContactListShowBehaviorPlugin</string> 
    8080        <string>ESiTunesPlugin</string> 
    8181        <string>AIDockBadger</string> 
     82        <string>KGContactBlockedPlugin</string> 
    8283        <string>SMSQLiteLoggerPlugin</string> 
    8384</array> 
    8485</plist>