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 namespace ICQ2000 {
00030
00031
00032
00033
00034
00035
00036
00037
00038 class DCCache : public Cache<int, DirectClient*> {
00039 public:
00040 DCCache() { }
00041 ~DCCache()
00042 {
00043 removeAll();
00044 }
00045
00046 void removeItem(const DCCache::literator& l) {
00047 delete ((*l).getValue());
00048 Cache<int, DirectClient*>::removeItem(l);
00049 }
00050
00051 void expireItem(const DCCache::literator& l) {
00052 expired.emit( (*l).getValue() );
00053 Cache<int, DirectClient*>::expireItem(l);
00054
00055
00056
00057 }
00058
00059 void removeContact(const ContactRef& c) {
00060 literator curr = m_list.begin();
00061 literator next = curr;
00062 while ( curr != m_list.end() ) {
00063 DirectClient *dc = (*curr).getValue();
00064 ++next;
00065 if ( dc->getContact().get() != NULL
00066
00067
00068
00069
00070
00071 && dc->getContact()->getUIN() == c->getUIN() ) {
00072 removeItem(curr);
00073 }
00074 curr = next;
00075 }
00076 }
00077
00078 DirectClient* getByContact(const ContactRef& c)
00079 {
00080
00081 literator curr = m_list.begin();
00082 while ( curr != m_list.end() ) {
00083 DirectClient *dc = (*curr).getValue();
00084 if ( dc->getContact().get() != NULL
00085
00086
00087
00088
00089
00090 && dc->getContact()->getUIN() == c->getUIN() )
00091 return dc;
00092
00093 ++curr;
00094 }
00095
00096 return NULL;
00097 }
00098
00099 void clearoutMessagesPoll() {
00100 literator curr = m_list.begin();
00101 while ( curr != m_list.end() ) {
00102 DirectClient *dc = (*curr).getValue();
00103 dc->clearoutMessagesPoll();
00104 ++curr;
00105 }
00106 }
00107
00108 SigC::Signal1<void,DirectClient*> expired;
00109 };
00110
00111 }
00112
00113 #endif