00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef DCCACHE_H
00023 #define DCCACHE_H
00024
00025 #include <libicq2000/Cache.h>
00026
00027 #include <sigc++/signal_system.h>
00028
00029 using SigC::Signal1;
00030
00031 namespace ICQ2000 {
00032
00033
00034
00035
00036
00037
00038
00039
00040 class DCCache : public Cache<int, DirectClient*> {
00041 public:
00042 DCCache() { }
00043 ~DCCache()
00044 {
00045 removeAll();
00046 }
00047
00048 void removeItem(const DCCache::literator& l) {
00049 delete ((*l).getValue());
00050 Cache<int, DirectClient*>::removeItem(l);
00051 }
00052
00053 void expireItem(const DCCache::literator& l) {
00054 expired.emit( (*l).getValue() );
00055 Cache<int, DirectClient*>::expireItem(l);
00056
00057
00058
00059 }
00060
00061 void removeContact(const ContactRef& c) {
00062 literator curr = m_list.begin();
00063 literator next = curr;
00064 while ( curr != m_list.end() ) {
00065 DirectClient *dc = (*curr).getValue();
00066 ++next;
00067 if ( dc->getContact().get() != NULL
00068
00069
00070
00071
00072
00073 && dc->getContact()->getUIN() == c->getUIN() ) {
00074 removeItem(curr);
00075 }
00076 curr = next;
00077 }
00078 }
00079
00080 DirectClient* getByContact(const ContactRef& c)
00081 {
00082
00083 literator curr = m_list.begin();
00084 while ( curr != m_list.end() ) {
00085 DirectClient *dc = (*curr).getValue();
00086 if ( dc->getContact().get() != NULL
00087
00088
00089
00090
00091
00092 && dc->getContact()->getUIN() == c->getUIN() )
00093 return dc;
00094
00095 ++curr;
00096 }
00097
00098 return NULL;
00099 }
00100
00101 void clearoutMessagesPoll() {
00102 literator curr = m_list.begin();
00103 while ( curr != m_list.end() ) {
00104 DirectClient *dc = (*curr).getValue();
00105 dc->clearoutMessagesPoll();
00106 ++curr;
00107 }
00108 }
00109
00110 Signal1<void,DirectClient*> expired;
00111 };
00112
00113 }
00114
00115 #endif