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().get() != NULL
00064
00065
00066
00067
00068
00069 && dc->getContact()->getUIN() == c->getUIN() ) {
00070 removeItem(curr);
00071 }
00072 curr = next;
00073 }
00074 }
00075
00076 DirectClient* getByContact(const ContactRef& c)
00077 {
00078
00079 literator curr = m_list.begin();
00080 while ( curr != m_list.end() ) {
00081 DirectClient *dc = (*curr).getValue();
00082 if ( dc->getContact().get() != NULL
00083
00084
00085
00086
00087
00088 && dc->getContact()->getUIN() == c->getUIN() )
00089 return dc;
00090
00091 ++curr;
00092 }
00093
00094 return NULL;
00095 }
00096
00097 void clearoutMessagesPoll() {
00098 literator curr = m_list.begin();
00099 while ( curr != m_list.end() ) {
00100 DirectClient *dc = (*curr).getValue();
00101 dc->clearoutMessagesPoll();
00102 ++curr;
00103 }
00104 }
00105
00106 Signal1<void,DirectClient*> expired;
00107 };
00108
00109 }
00110
00111 #endif