| 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 | #import <Adium/ESObjectWithProperties.h> |
---|
| 18 | |
---|
| 19 | @class AIListContact, AIListObject, AIServersideUserIconSource; |
---|
| 20 | |
---|
| 21 | typedef enum { |
---|
| 22 | AIUserIconSourceDidNotFindIcon = 0, |
---|
| 23 | AIUserIconSourceFoundIcon, |
---|
| 24 | AIUserIconSourceLookingUpIconAsynchronously |
---|
| 25 | } AIUserIconSourceQueryResult; |
---|
| 26 | |
---|
| 27 | typedef float AIUserIconPriority; |
---|
| 28 | #define AIUserIconHighestPriority 0.00 |
---|
| 29 | #define AIUserIconHighPriority 0.25 |
---|
| 30 | #define AIUserIconMediumPriority 0.50 |
---|
| 31 | #define AIUserIconLowPriority 0.75 |
---|
| 32 | #define AIUserIconLowestPriority 1.00 |
---|
| 33 | |
---|
| 34 | @protocol AIUserIconSource |
---|
| 35 | /*! |
---|
| 36 | * @brief AIUserIcons wants this source to update its user icon for an object |
---|
| 37 | * |
---|
| 38 | * Call +[AIUserIcons userIconSource:didDetermineUserIcon:asynchronously:forObject:] with the new icon, if appropriate |
---|
| 39 | * |
---|
| 40 | * @result An AIUserIconSourceQueryResult indicating the result |
---|
| 41 | */ |
---|
| 42 | - (AIUserIconSourceQueryResult)updateUserIconForObject:(AIListObject *)inObject; |
---|
| 43 | |
---|
| 44 | /*! |
---|
| 45 | * @brief The priority at which this source should be used. See the \#defines in AIUserIcons.h for posible values. |
---|
| 46 | */ |
---|
| 47 | - (AIUserIconPriority)priority; |
---|
| 48 | @end |
---|
| 49 | |
---|
| 50 | @interface AIUserIcons : NSObject { |
---|
| 51 | |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | /*! |
---|
| 55 | * @brief Register a user icon source |
---|
| 56 | */ |
---|
| 57 | + (void)registerUserIconSource:(id <AIUserIconSource>)inSource; |
---|
| 58 | |
---|
| 59 | /*! |
---|
| 60 | * @brief Get the user icon source currently providingthe icon for an object |
---|
| 61 | */ |
---|
| 62 | + (void)userIconSource:(id <AIUserIconSource>)inSource priorityDidChange:(AIUserIconPriority)newPriority fromPriority:(AIUserIconPriority)oldPriority; |
---|
| 63 | |
---|
| 64 | /*! |
---|
| 65 | * @brief Determine if a change in a given icon source would potentially change the icon of an object |
---|
| 66 | */ |
---|
| 67 | + (BOOL)userIconSource:(id <AIUserIconSource>)inSource changeWouldBeRelevantForObject:(AIListObject *)inObject; |
---|
| 68 | |
---|
| 69 | /*! |
---|
| 70 | * @brief Called by an icon source to inform us that its provided icon changed |
---|
| 71 | */ |
---|
| 72 | + (void)userIconSource:(id <AIUserIconSource>)inSource didChangeForObject:(AIListObject *)inObject; |
---|
| 73 | |
---|
| 74 | /*! |
---|
| 75 | * @brief A user icon source determined a user icon for an object |
---|
| 76 | * |
---|
| 77 | * This should be called only by a user icon source upon successful determination of a user icon |
---|
| 78 | */ |
---|
| 79 | + (void)userIconSource:(id <AIUserIconSource>)inSource didDetermineUserIcon:(NSImage *)inUserIcon asynchronously:(BOOL)wasAsynchronous forObject:(AIListObject *)inObject; |
---|
| 80 | |
---|
| 81 | /*! |
---|
| 82 | * @brief Set what user icon and source an object is currently using (regardless of what AIUserIcon would otherwise do) |
---|
| 83 | * |
---|
| 84 | * This is useful if an object knows something AIUserIcons can't. For example, AIMetaContact uses this to let AIUserIcons |
---|
| 85 | * know how it resolved iterating through its contained contacts based on their respective priorities in order to determine |
---|
| 86 | * which user icon should be used. Tracking it here prevents needless repeated lookups of data. |
---|
| 87 | */ |
---|
| 88 | + (void)setActualUserIcon:(NSImage *)userIcon andSource:(id <AIUserIconSource>)inSource forObject:(AIListObject *)inObject; |
---|
| 89 | |
---|
| 90 | /*! |
---|
| 91 | * @brief Get the user icon source currently providing the icon for an object |
---|
| 92 | */ |
---|
| 93 | + (id <AIUserIconSource>)userIconSourceForObject:(AIListObject *)inObject; |
---|
| 94 | |
---|
| 95 | /*! |
---|
| 96 | * @brief Retrieve the manually set user icon (a stored preference) for an object, if there is one |
---|
| 97 | */ |
---|
| 98 | + (NSData *)manuallySetUserIconDataForObject:(AIListObject *)inObject; |
---|
| 99 | |
---|
| 100 | /*! |
---|
| 101 | * @brief Get the user icon for an object |
---|
| 102 | * |
---|
| 103 | * If it's not already cached, the icon sources will be queried as needed. |
---|
| 104 | */ |
---|
| 105 | + (NSImage *)userIconForObject:(AIListObject *)inObject; |
---|
| 106 | |
---|
| 107 | /* |
---|
| 108 | * @brief Retrieve a user icon sized for the contact list |
---|
| 109 | * |
---|
| 110 | * @param inObject The object |
---|
| 111 | * @param size Size of the returned image. If this is the size passed to -[self setListUserIconSize:], a cache will be used. |
---|
| 112 | */ |
---|
| 113 | + (NSImage *)listUserIconForContact:(AIListObject *)inObject size:(NSSize)size; |
---|
| 114 | |
---|
| 115 | /*! |
---|
| 116 | * @brief Retrieve a user icon sized for a menu |
---|
| 117 | * |
---|
| 118 | * Returns the appropriate service icon if no user icon is found |
---|
| 119 | */ |
---|
| 120 | + (NSImage *)menuUserIconForObject:(AIListObject *)inObject; |
---|
| 121 | |
---|
| 122 | /*! |
---|
| 123 | * @brief Inform AIUserIcons a new manually-set icon data for an object |
---|
| 124 | * |
---|
| 125 | * We take responsibility (via AIManuallySetUserIconSource) for saving the data |
---|
| 126 | */ |
---|
| 127 | + (void)setManuallySetUserIconData:(NSData *)inData forObject:(AIListObject *)inObject; |
---|
| 128 | |
---|
| 129 | /*! |
---|
| 130 | * @brief Inform AIUserIcons of new serverside icon data for an object. |
---|
| 131 | * |
---|
| 132 | * This is likely called by a contact for itself or by an accont for a contact. |
---|
| 133 | */ |
---|
| 134 | + (void)setServersideIconData:(NSData *)inData forObject:(AIListObject *)inObject notify:(NotifyTiming)notify; |
---|
| 135 | |
---|
| 136 | /* |
---|
| 137 | * @brief Set the current contact list user icon size |
---|
| 138 | * This determines the size at which images are cached for listUserIconForContact:size: |
---|
| 139 | */ |
---|
| 140 | + (void)setListUserIconSize:(NSSize)inSize; |
---|
| 141 | |
---|
| 142 | /*! |
---|
| 143 | * @brief Clear the cache for a specific object |
---|
| 144 | */ |
---|
| 145 | + (void)flushCacheForObject:(AIListObject *)inContact; |
---|
| 146 | |
---|
| 147 | /*! |
---|
| 148 | * @brief Clear all caches |
---|
| 149 | */ |
---|
| 150 | + (void)flushAllCaches; |
---|
| 151 | |
---|
| 152 | @end |
---|
| 153 | |
---|
| 154 | @interface AIUserIcons (AIUserIconSource) |
---|
| 155 | + (void)userIconSource:(id <AIUserIconSource>)inSource didDetermineUserIcon:(NSImage *)inUserIcon forObject:(AIListObject *)inObject; |
---|
| 156 | @end |
---|