使用soui开发的mbc,只支持windows版本
w1146869587
2022-01-24 0408576e9da10015ffa9da0079b8c985113ce4b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
// MBRecentContact.cpp : implementation file
//
 
#include "stdafx.h"
#include "mbam.h"
#include "MBRecentContact.h"
 
 
// CMBRecentContact
 
CMBContactItem::CMBContactItem( )
{
    m_strSubject = _T("");
    m_strMsgDate =_T("");
    m_nUnreadCount = 0;
}
 
CMBContactItem::~CMBContactItem( )
{
}
void CMBContactItem::operator = ( const CMBContactItem &Item )
{
    m_nType        = Item.m_nType;
    m_strID        = Item.m_strID;
    m_strName    = Item.m_strName;
    m_strMsgDate        = Item.m_strMsgDate;
    m_strSubject        = Item.m_strSubject;
    m_nSortLevel    = Item.m_nSortLevel;
    m_bIsDelete        = Item.m_bIsDelete;
    m_strGener        = Item.m_strGener;
    m_strSName        = Item.m_strSName;
}
 
CMBRecentContact::CMBRecentContact()
{
    m_nLimitCount    = LIMIT_COUNT;
    m_bIsLoaded = FALSE;
    m_listContact.RemoveAll();
}
 
CMBRecentContact::~CMBRecentContact()
{
    CleanContact( );
}
 
void CMBRecentContact::CleanContact( )
{
    POSITION        pos;
    CMBContactItem        *pMember    = NULL;
 
    for ( pos = m_listContact.GetHeadPosition(); pos; )
    {
        pMember    = (CMBContactItem *)m_listContact.GetNext( pos );
        if ( pMember )
            delete    pMember;
    }
    m_listContact.RemoveAll();
    m_bIsLoaded = FALSE;
}
 
void CMBRecentContact::SetAMLogin( CString strLogin )
{
    m_strLogin = strLogin;
}
 
void CMBRecentContact::ProcessContact( )
{
    POSITION        pos, posOld;
    CMBContactItem        *pItem    = NULL;
 
    if(m_listContact.GetCount() > LIMIT_COUNT)
    {
        pos = m_listContact.FindIndex( LIMIT_COUNT + 1 );
        for ( pos; pos; )
        {    
            posOld = pos;
            pItem = (CMBContactItem*)m_listContact.GetNext( pos );
            m_listContact.RemoveAt( posOld );
            if ( pItem )
            {
                delete pItem;
                pItem = NULL;
            }
        }
    }
}
void CMBRecentContact::AddContactItem( CString strID, CString strName,
                            int nType, CString strDate, CString strSubject )
{
    if ( strID.CompareNoCase( m_strLogin ) == 0 )
        return; // Èç¹ûÊÇAMʹÓÃÕß²»ÐèÒª¼ÓÈë
 
    POSITION        pos, posOld;
    CMBContactItem    *pItem = NULL;
    CMBContactItem    *pContactItem = NULL;
    bool            bHaveFind = false;
    bool            bFlag = false;
    COleDateTime    dtCurrent= COleDateTime::GetCurrentTime();    
    CString strCurrentTime = dtCurrent.Format(_T("%Y-%m-%d %H:%M:%S"));
    pos = FindContactItem( strID, nType);
    if ( pos )
    {
        pItem = (CMBContactItem*)m_listContact.GetAt( pos );
        if ( !pItem )
            m_listContact.RemoveAt( pos );
        else
        {
            if(pItem->m_strMsgDate > strCurrentTime)
                bFlag = true;
            else if ( pItem->m_strMsgDate < strDate )
                bFlag = true;
            if (bFlag )
            {
                pItem->m_strMsgDate = strDate;
                pItem->m_strSubject = strSubject;
                bHaveFind = false;
                m_listContact.RemoveAt( pos );
 
                // ÒÆÎ»ÖÃ
                for ( pos = m_listContact.GetHeadPosition( ); pos; )
                {
                    posOld    = pos;
                    pContactItem = (CMBContactItem*)m_listContact.GetNext( pos );
 
                    if ( pContactItem->m_strMsgDate < strDate )
                    {
                        bHaveFind = true;
                        m_listContact.InsertBefore( posOld, pItem );
                        break;
                    }
                }
 
                if ( !bHaveFind )
                    m_listContact.AddTail( pItem );
            }
        }
    }
 
    if ( !pItem )
    {
        bHaveFind = false;
        for ( pos = m_listContact.GetHeadPosition( ); pos; )
        {
            posOld    = pos;
            pItem    = (CMBContactItem*)m_listContact.GetNext( pos );
 
            if ( pItem->m_strMsgDate < strDate )
            {
                pContactItem = new CMBContactItem;
                pContactItem->m_strSubject = strSubject;
                pContactItem->m_strID = strID;
                pContactItem->m_strName  = strName;
                pContactItem->m_nType  = (AMVIEWITEMTYPE)nType;
                pContactItem->m_strMsgDate       = strDate;
 
                bHaveFind = true;
                m_listContact.InsertBefore( posOld, pContactItem );
                break;
            }
        }
 
        if ( !bHaveFind )
        {
            pContactItem = new CMBContactItem;
                
            pContactItem->m_strID = strID;
            pContactItem->m_strName  = strName;
            pContactItem->m_nType  = (AMVIEWITEMTYPE)nType;
            pContactItem->m_strMsgDate       = strDate;
            pContactItem->m_strSubject = strSubject;
            m_listContact.AddTail( pContactItem );
        }
    }
}
 
POSITION CMBRecentContact::FindContactItem( CString strID, int nType )
{
    POSITION        pos, posOld;
    CMBContactItem    *pItem = NULL;
 
    int            nCount = m_listContact.GetCount();
    for ( pos = m_listContact.GetHeadPosition( ); pos; )
    {
        posOld = pos;
        pItem = (CMBContactItem*)m_listContact.GetNext( pos );
    
        if ( pItem && pItem->m_strID.CompareNoCase( strID ) == 0  && pItem->m_nType == nType)
            return posOld;
    }
 
    return NULL;
}
void CMBRecentContact::DeleteContactItem( CString strID, int nType)
{
    POSITION        pos;
    CMBContactItem    *pItem = NULL;
    CString            strSQL;    
 
    int            nCount = m_listContact.GetCount();
    pos = FindContactItem( strID, nType);
    if ( pos )
    {
        pItem = (CMBContactItem*)m_listContact.GetAt( pos );
        m_listContact.RemoveAt(pos);
        if(pItem)
            delete pItem;
        pItem = NULL;
            
    }
}
void  CMBRecentContact::SetLoaded(BOOL bIsLoaded)
{
    m_bIsLoaded = bIsLoaded;
}
BOOL  CMBRecentContact::IsLoaded()
{
    return m_bIsLoaded;
}
BOOL  CMBRecentContact::GetOldContactDate( CString &strDate)
{
    POSITION        pos;
    CMBContactItem    *pItem = NULL;
 
    if(m_listContact.GetCount() < 30)
    {
        return FALSE;
    }
    else
    {
        pos = m_listContact.GetTailPosition();
        if( !pos)
            return FALSE;
        pItem = (CMBContactItem*)m_listContact.GetAt(pos);
        if( !pItem)
            return FALSE;
        strDate = pItem->m_strMsgDate;
        return TRUE;
    }
}
 
 
// CMBRecentContact member functions