00001 /* 00002 * This file is part of TelepathyQt4 00003 * 00004 * Copyright (C) 2008 basysKom GmbH 00005 * Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/> 00006 * Copyright (C) 2008 Nokia Corporation 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 #ifndef TelepathyQt4_Prototype_AvatarManager_H_ 00023 #define TelepathyQt4_Prototype_AvatarManager_H_ 00024 00025 #include <QDBusObjectPath> 00026 #include <QObject> 00027 #include <QPointer> 00028 00029 #include <TelepathyQt4/Types> 00030 00031 namespace Telepathy 00032 { 00033 namespace Client 00034 { 00035 class ConnectionInterface; 00036 } 00037 } 00038 00039 namespace TpPrototype { 00040 00041 class AvatarManagerPrivate; 00042 class Connection; 00043 class Contact; 00044 class Account; 00045 00056 class AvatarManager : public QObject 00057 { 00058 Q_OBJECT 00059 00060 public: 00064 struct AvatarRequirements 00065 { 00067 QStringList mimeTypes; 00069 uint minimumWidth; 00071 uint minimumHeight; 00073 uint maximumWidth; 00075 uint maximumHeight; 00077 uint maxSize; 00079 bool isValid; 00080 }; 00081 00085 struct Avatar 00086 { 00088 QByteArray avatar; 00090 QString mimeType; 00092 QString token; 00093 }; 00094 00099 bool isValid(); 00100 00105 TpPrototype::Connection* connection(); 00106 00113 bool setAvatar( const TpPrototype::AvatarManager::Avatar& newValue ); 00114 00120 void requestAvatar(); 00121 00127 AvatarRequirements avatarRequirements(); 00128 00136 void avatarForContactList( const QList<QPointer<Contact> >& contacts ); 00137 00138 signals: 00142 void signalAvatarChanged( TpPrototype::Contact* contact ); 00143 00148 void signalOwnAvatarChanged( TpPrototype::AvatarManager::Avatar avatar ); 00149 00150 protected: 00154 AvatarManager( TpPrototype::Connection* connection, 00155 Telepathy::Client::ConnectionInterface* interface, 00156 QObject* parent = NULL ); 00157 ~AvatarManager(); 00158 00159 protected slots: 00160 void slotAvatarUpdated( uint contact, const QString& newAvatarToken ); 00161 void slotAvatarRetrieved( uint contact, const QString& token, const QByteArray& avatar, const QString& type ); 00162 00163 private: 00164 void init( TpPrototype::Connection* connection, Telepathy::Client::ConnectionInterface* interface ); 00165 00166 TpPrototype::AvatarManagerPrivate * const d; 00167 friend class Connection; 00168 friend class ConnectionPrivate; 00169 }; 00170 } 00171 00172 Q_DECLARE_METATYPE( TpPrototype::AvatarManager::Avatar ); 00173 Q_DECLARE_METATYPE( TpPrototype::AvatarManager::AvatarRequirements ); 00174 #endif