kopete/libkopete
kopetemetacontact.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef kopetemetacontact_h__
00022 #define kopetemetacontact_h__
00023
00024 #include "kopetecontactlistelement.h"
00025
00026 #include <QtCore/QList>
00027
00028 #include <kdemacros.h>
00029 #include <kurl.h>
00030 #include "kopete_export.h"
00031
00032 #include "kopeteonlinestatus.h"
00033
00034 namespace Kopete {
00035
00036
00037 class Plugin;
00038 class Group;
00039 class Picture;
00040
00052 class KOPETE_EXPORT MetaContact : public ContactListElement
00053 {
00054 Q_OBJECT
00055
00056 Q_PROPERTY( QString displayName READ displayName WRITE setDisplayName )
00057 Q_PROPERTY( QString statusString READ statusString )
00058 Q_PROPERTY( QString statusIcon READ statusIcon )
00059 Q_PROPERTY( bool isOnline READ isOnline )
00060 Q_PROPERTY( bool isReachable READ isReachable )
00061 Q_PROPERTY( bool isTemporary READ isTemporary )
00062 Q_PROPERTY( bool canAcceptFiles READ canAcceptFiles )
00063
00064 Q_PROPERTY( QString metaContactId READ metaContactId WRITE setMetaContactId )
00065 Q_PROPERTY( bool photoSyncedWithKABC READ isPhotoSyncedWithKABC WRITE setPhotoSyncedWithKABC )
00066
00067 public:
00068 typedef QList<MetaContact *> List;
00073 enum PropertySource {
00074 SourceContact ,
00075 SourceKABC ,
00076 SourceCustom
00077 };
00078
00082 MetaContact();
00086 ~MetaContact();
00087
00094 QString metaContactId() const;
00095
00100 void setMetaContactId( const QString& newMetaContactId );
00101
00105 QList<Contact *> contacts() const;
00106
00110 QList<Group *> groups() const;
00111
00117 Contact *findContact( const QString &protocolId, const QString &accountId, const QString &contactId );
00118
00127 void setDisplayNameSource(PropertySource source);
00128
00129 void setDisplayNameSource( const QString &nameSourcePID, const QString &nameSourceAID, const QString &nameSourceCID );
00130
00139 PropertySource displayNameSource() const;
00140
00149 void setPhotoSource(PropertySource source);
00150
00151 void setPhotoSource( const QString &photoSourcePID, const QString &photoSourceAID, const QString &photoSourceCID );
00152
00161 PropertySource photoSource() const;
00162
00177 QString displayName() const;
00178
00189 KDE_DEPRECATED QImage photo() const;
00190
00198 Picture &picture() const;
00199
00210 void setDisplayName( const QString &name );
00211
00218 QString customDisplayName() const;
00219
00226 KUrl customPhoto() const;
00227
00228
00238 void setPhoto( const KUrl &url );
00239
00246 Contact *displayNameSourceContact() const;
00247
00252 void setDisplayNameSourceContact( Contact* contact );
00253
00257 Contact *photoSourceContact() const;
00258
00262 void setPhotoSourceContact( Contact* contact );
00263
00267 bool isPhotoSyncedWithKABC() const;
00268
00274 void setPhotoSyncedWithKABC(bool b);
00275
00276
00282 bool isTemporary() const;
00283
00288 void addContact( Contact *c );
00289
00298 void removeContact( Contact *c , bool deleted = false );
00299
00303 Contact *preferredContact();
00304
00309 QString statusIcon() const;
00310
00317 QString statusString() const;
00318
00324 bool isOnline() const;
00325
00330 bool canAcceptFiles() const;
00331
00337 OnlineStatus::StatusType status() const;
00338
00346 bool isReachable() const;
00347
00351 unsigned long int idleTime() const;
00352
00372 QString addressBookField( Plugin *p, const QString &app, const QString &key ) const;
00373
00383 void setAddressBookField( Plugin *p, const QString &app, const QString &key, const QString &value );
00384
00385 public slots:
00386
00401 void sendFile( const KUrl &sourceURL, const QString &altFileName = QString(),
00402 unsigned long fileSize = 0L );
00403
00407 void emitAboutToSave();
00408
00409 signals:
00414 void aboutToSave( Kopete::MetaContact *metaContact );
00415
00420 void contactIdleStateChanged( Kopete::Contact *contact );
00421
00422
00423 public slots:
00424
00428 void moveToGroup( Kopete::Group *from, Kopete::Group *to );
00429
00433 void removeFromGroup( Kopete::Group *from );
00434
00438 void addToGroup( Kopete::Group *to );
00439
00447 void setTemporary( bool b = true, Kopete::Group *group = 0L );
00448
00457 Contact *execute();
00458
00468 Contact *sendMessage();
00469
00480 Contact *startChat();
00481
00485 void slotAllPluginsLoaded();
00486
00490 void slotPluginLoaded( Kopete::Plugin *plugin );
00491
00492 signals:
00496 void onlineStatusChanged( Kopete::MetaContact *contact, Kopete::OnlineStatus::StatusType status );
00497
00505 void contactStatusChanged( Kopete::Contact *contact, const Kopete::OnlineStatus &status );
00506
00510 void displayNameChanged( const QString &oldName, const QString &newName );
00511
00515 void photoChanged();
00516
00520 void movedToGroup( Kopete::MetaContact *contact, Kopete::Group *from, Kopete::Group *to );
00521
00525 void removedFromGroup( Kopete::MetaContact *contact, Kopete::Group *group );
00526
00530 void addedToGroup( Kopete::MetaContact *contact, Kopete::Group *to );
00531
00537 void contactAdded( Kopete::Contact *c );
00538
00544 void contactRemoved( Kopete::Contact *c );
00545
00549 void persistentDataChanged( );
00550
00551 private slots:
00556 void updateOnlineStatus();
00557
00561 void slotContactStatusChanged( Kopete::Contact *c, const Kopete::OnlineStatus &status, const Kopete::OnlineStatus &oldStatus );
00562
00566 void slotPropertyChanged( Kopete::PropertyContainer *contact, const QString &key, const QVariant &oldValue, const QVariant &newValue );
00567
00572 void slotContactDestroyed( Kopete::Contact* );
00573
00577 void slotUpdateAddressBookPicture();
00578
00579 protected:
00580
00581
00582 QImage photoFromCustom() const;
00583
00584
00585
00586 private:
00587 class Private;
00588 Private *d;
00589 };
00590
00591
00592 KOPETE_EXPORT QImage photoFromContact( Kopete::Contact *c) ;
00593 KOPETE_EXPORT QImage photoFromKABC( const QString &id ) ;
00594 KOPETE_EXPORT QString nameFromContact( Kopete::Contact *c) ;
00595 KOPETE_EXPORT QString nameFromKABC( const QString &id ) ;
00596
00597 }
00598
00599
00600 #endif
00601
00602
00603