kopete/libkopete
Kopete::AvatarManager Class Reference
#include <kopeteavatarmanager.h>
Detailed Description
Manage the avatar storage.AvatarManager is a class that manage avatar storage. It can manage the user defined avatar and avatar received from contacts.
It can also list the available avatars and filter it on the categery, like User or Contact.
Avatar Directory Layout
AvatarManager use Kopete user application directory to actually store avatars on disk.The directory is in $KDEHOME/share/apps/kopete/avatars/
Sub-directory User store user defined avatars. It keep track of each avatar change so you can go back to a previous avatar you had.
Sub-directory Contacts store avatar received from contacts. Avatars are managed by account to avoid conflict of avatars between multiple contacts having the same ID. For example, an user can have the same ID for MSN and Jabber but use a different avatar for each account.
Avatar management
Listing avatar
If you want to list only an avatar category, use Kopete::AvatarQueryJobAdding an avatar
Use the add() method to add an new avatar. For an avatar received from a contact, you should use the contactId for the name. You can either specify a image path or a QImage. AvatarManager will save the QImage on disk. When adding an avatar for Contact category, the "contact" entry need to be filled with a pointer to a Kopete::Contact instance.
Kopete::AvatarManager::AvatarEntry newEntry; newEntry.name = "A new avatar" newEntry.image = avatarImage; newEntry.contact = this; newEntry.category = Kopete::AvatarManager::Contact; Kopete::AvatarManager::self()->add(newEntry);
If the operation has failed, the resulting AvatarEntry path will be empty. The following code is a good way to test the success of add() method:
if( !resultEntry.path.isEmpty() ) { // Set avatar on server }
Removing an avatar
To remove an avatar, create a new AvatarEntry struct and pass the avatar path to the struct, it will be used to identify which avatar to remove.Then just use the remove() method.
Kopete::AvatarManager::AvatarEntry entryToRemove; entryToRemove.path = imagePath; Kopete::AvatarManager::self()->remove(entryToRemove);
Updating an avatar
Adding an avatar with the same name will update the previous avatar.
Definition at line 106 of file kopeteavatarmanager.h.
Public Types | |
| enum | AvatarCategoryType { User = 1, Contact, All = User | Contact } |
| typedef struct Kopete::AvatarManager::AvatarEntry | AvatarEntry |
Public Slots | |
| Kopete::AvatarManager::AvatarEntry | add (Kopete::AvatarManager::AvatarEntry newEntry) |
| bool | remove (Kopete::AvatarManager::AvatarEntry entryToRemove) |
Signals | |
| void | avatarAdded (Kopete::AvatarManager::AvatarEntry newEntry) |
| void | avatarRemoved (Kopete::AvatarManager::AvatarEntry entryRemoved) |
Public Member Functions | |
| ~AvatarManager () | |
Static Public Member Functions | |
| static AvatarManager * | self () |
Classes | |
| struct | AvatarEntry |
| A single entry in AvatarManager. More... | |
Member Typedef Documentation
Member Enumeration Documentation
Available avatar category.
- Enumerator:
-
User User defined avatar. Contact Avatar from a contact. All Only used to list all category.
Definition at line 113 of file kopeteavatarmanager.h.
Constructor & Destructor Documentation
| Kopete::AvatarManager::~AvatarManager | ( | ) |
Definition at line 91 of file kopeteavatarmanager.cpp.
Member Function Documentation
| AvatarManager * Kopete::AvatarManager::self | ( | ) | [static] |
Get the only instance of AvatarManager.
- Returns:
- AvatarManager single instance
Definition at line 49 of file kopeteavatarmanager.cpp.
| void Kopete::AvatarManager::avatarAdded | ( | Kopete::AvatarManager::AvatarEntry | newEntry | ) | [signal] |
An avatar was added into the storage.
Listen to this signal if you want to get notified of new avatar added to the storage. It is used to update the AvatarSelectorWidget lists.
- Parameters:
-
newEntry new avatar added into the storage.
| void Kopete::AvatarManager::avatarRemoved | ( | Kopete::AvatarManager::AvatarEntry | entryRemoved | ) | [signal] |
An avatar was removed from storage.
Listen to this signal if you want to get notified of avatar being removed from storage. It is used to update the AvatarSelectorWidget lists.
- Parameters:
-
entryRemoved avatar being remove from storage.
| Kopete::AvatarManager::AvatarEntry Kopete::AvatarManager::add | ( | Kopete::AvatarManager::AvatarEntry | newEntry | ) | [slot] |
Add an new avatar to the storage.
No need to scale the image, add() will do it for you.
- Parameters:
-
newEntry New avatar entry
- Returns:
- a new AvatarEntry struct. If the adding failed, the path is null.
Definition at line 96 of file kopeteavatarmanager.cpp.
| bool Kopete::AvatarManager::remove | ( | Kopete::AvatarManager::AvatarEntry | entryToRemove | ) | [slot] |
Remove an avatar from the storage.
- Parameters:
-
entryToRemove Avatar entry to remove
Definition at line 191 of file kopeteavatarmanager.cpp.
The documentation for this class was generated from the following files:
KDE 4.0 API Reference