File indexing completed on 2024-04-21 04:04:43
0001 /* 0002 * jabbercontactpool.h 0003 * 0004 * Copyright (c) 2004 by Till Gerken <till@tantalo.net> 0005 * 0006 * Kopete (c) by the Kopete developers <kopete-devel@kde.org> 0007 * 0008 * ************************************************************************* 0009 * * * 0010 * * This program is free software; you can redistribute it and/or modify * 0011 * * it under the terms of the GNU General Public License as published by * 0012 * * the Free Software Foundation; either either version 2 0013 of the License, or (at your option) any later version.of the License, or * 0014 * * (at your option) any later version. * 0015 * * * 0016 * ************************************************************************* 0017 */ 0018 0019 #ifndef JABBERCONTACTPOOL_H 0020 #define JABBERCONTACTPOOL_H 0021 0022 #include <QObject> 0023 #include <QList> 0024 #include <im.h> 0025 0026 class JabberContactPoolItem; 0027 class JabberBaseContact; 0028 class JabberContact; 0029 class JabberAccount; 0030 0031 /** 0032 * @author Till Gerken <till@tantalo.net> 0033 */ 0034 class JabberContactPool : public QObject 0035 { 0036 0037 Q_OBJECT 0038 0039 public: 0040 /** 0041 * Default constructor 0042 */ 0043 JabberContactPool ( JabberAccount *account ); 0044 0045 /** 0046 * Default destructor 0047 */ 0048 ~JabberContactPool(); 0049 0050 /** 0051 * Add a contact to the pool 0052 */ 0053 JabberBaseContact *addContact ( const XMPP::RosterItem &contact, bool dirty = true ); 0054 JabberBaseContact *addGroupContact ( const XMPP::RosterItem &contact, bool roomContact, bool dirty = true ); 0055 0056 /** 0057 * Remove a contact from the pool 0058 */ 0059 void removeContact ( const XMPP::Jid &jid ); 0060 0061 /** 0062 * Remove all contacts from the pool 0063 */ 0064 void clear (); 0065 0066 /** 0067 * Sets the "dirty" flag for a certain contact 0068 */ 0069 void setDirty ( const XMPP::Jid &jid, bool dirty ); 0070 0071 /** 0072 * Remove all dirty elements from the pool 0073 * (used after connecting to delete removed items from the roster) 0074 */ 0075 void cleanUp (); 0076 0077 /** 0078 * Find an exact match in the pool by full JID. 0079 */ 0080 JabberBaseContact *findExactMatch ( const XMPP::Jid &jid ); 0081 0082 /** 0083 * Find a relevant recipient for a given JID. 0084 * This will match user@domain for a given user@domain/resource, 0085 * but NOT user@domain/resource for a given user@domain. 0086 */ 0087 JabberBaseContact *findRelevantRecipient ( const XMPP::Jid &jid ); 0088 0089 /** 0090 * Find relevant sources for a given JID. 0091 * This will match user@domain/resource for a given user@domain. 0092 */ 0093 QList<JabberBaseContact*> findRelevantSources ( const XMPP::Jid &jid ); 0094 0095 private slots: 0096 void slotContactDestroyed ( JabberBaseContact *contact ); 0097 0098 private: 0099 JabberContactPoolItem *findPoolItem ( const XMPP::RosterItem &contact ); 0100 0101 QList<JabberContactPoolItem*> mPool; 0102 JabberAccount *mAccount; 0103 0104 }; 0105 0106 class JabberContactPoolItem : QObject 0107 { 0108 Q_OBJECT 0109 public: 0110 JabberContactPoolItem ( JabberBaseContact *contact ); 0111 ~JabberContactPoolItem (); 0112 0113 void setDirty ( bool dirty ); 0114 bool dirty (); 0115 JabberBaseContact *contact (); 0116 0117 private: 0118 bool mDirty; 0119 JabberBaseContact *mContact; 0120 }; 0121 0122 #endif