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
00044 void removeItem(const DCCache::literator& l) {
00045 delete ((*l).getValue());
00046 Cache<int, DirectClient*>::removeItem(l);
00047 }
00048
00049 void expireItem(const DCCache::literator& l) {
00050 expired.emit( (*l).getValue() );
00051 Cache<int, DirectClient*>::expireItem(l);
00052
00053
00054
00055 }
00056
00057 void removeContact(const ContactRef& c) {
00058 literator curr = m_list.begin();
00059 literator next = curr;
00060 while ( curr != m_list.end() ) {
00061 DirectClient *dc = (*curr).getValue();
00062 ++next;
00063 if ( dc->getContact()->getUIN() == c->getUIN() ) {
00064 dc->setContact( ContactRef() );
00065 removeItem(curr);
00066 }
00067 curr = next;
00068 }
00069 }
00070
00071 DirectClient* getByContact(const ContactRef& c)
00072 {
00073
00074 literator curr = m_list.begin();
00075 while ( curr != m_list.end() ) {
00076 DirectClient *dc = (*curr).getValue();
00077 if ( dc->getContact()->getUIN() == c->getUIN() )
00078 return dc;
00079
00080 ++curr;
00081 }
00082
00083 return NULL;
00084 }
00085
00086 void clearoutMessagesPoll() {
00087 literator curr = m_list.begin();
00088 while ( curr != m_list.end() ) {
00089 DirectClient *dc = (*curr).getValue();
00090 dc->clearoutMessagesPoll();
00091 ++curr;
00092 }
00093 }
00094
00095 Signal1<void,DirectClient*> expired;
00096 };
00097
00098 }
00099
00100 #endif