Changeset 30 in chevmsgr


Ignore:
Timestamp:
11/30/15 20:51:27 (8 years ago)
Author:
cheese
Message:

그룹챗 완성

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/msgsrv.cpp

    r25 r30  
    115115            "("
    116116            "   id      TEXT NOT NULL,"
    117             "   friend  TEXT NOT NULL"
     117            "   friend  TEXT NOT NULL,"
     118            "   unique  (friend)"
    118119            ")";
    119120
  • trunk/msvc14/ChevMsgrClient_MFC/AddGroupChat.cpp

    r29 r30  
    4141
    4242    for (size_t iter = 0; iter < mMsgrClntDlg->idList.size(); iter++)
    43     {
    4443        mFriendListToChat.InsertString(iter, str2cstr(mMsgrClntDlg->idList[iter].id));
    45     }
    4644
    4745    return TRUE;
  • trunk/msvc14/ChevMsgrClient_MFC/ChevMsgrClient_MFCDlg.cpp

    r29 r30  
    88#include "afxdialogex.h"
    99#include <fstream>
     10#include <algorithm>
    1011
    1112#include "LoginDlg.h"
     
    214215int cb_listen(SConversation & chat)
    215216{
    216     CString cstr;
    217 
    218     if (gDlg->mFriendListBox.GetCurSel() >= 0)
    219     {
    220         gDlg->mFriendListBox.GetText(gDlg->mFriendListBox.GetCurSel(), cstr);
    221 
    222         if (cstr2str(cstr) == chat.from)
     217    int idx = -1;
     218
     219    for (idx = 0; idx < gDlg->mFriendListBox.GetCount(); idx++)
     220    {
     221        if (chat.sessid == gDlg->scl[idx].sessionId)
    223222        {
    224             gDlg->mChatListBox.InsertString(gDlg->mChatListBox.GetCount(), str2cstr("<" + chat.from + ">"));
    225             gDlg->mChatListBox.InsertString(gDlg->mChatListBox.GetCount(), str2cstr(chat.message));
    226             gDlg->mChatListBox.InsertString(gDlg->mChatListBox.GetCount(), _T(""));
    227         }
    228     }
    229 
    230     for (int iter = 0; iter < gDlg->mFriendListBox.GetCount(); iter++)
    231     {
    232         gDlg->mFriendListBox.GetText(iter, cstr);
    233 
    234         if (cstr2str(cstr) == chat.from)
    235         {
    236             gDlg->scl[iter].chatList.push_back(chat);
     223            gDlg->scl[idx].chatList.push_back(chat);
    237224            break;
    238225        }
    239226    }
    240227
     228    if (gDlg->mFriendListBox.GetCurSel() == idx)
     229    {
     230        gDlg->mChatListBox.InsertString(gDlg->mChatListBox.GetCount(), str2cstr("<" + chat.from + ">"));
     231        gDlg->mChatListBox.InsertString(gDlg->mChatListBox.GetCount(), str2cstr(chat.message));
     232        gDlg->mChatListBox.InsertString(gDlg->mChatListBox.GetCount(), _T(""));
     233    }
     234
    241235    return 0;
    242236}
     
    244238int cb_opensession(SOpenSession & opensession)
    245239{
     240    if (opensession.idList.size() == 2)
     241        return 0;
     242
     243    CString cstrIdList = _T("");
     244
     245    for (size_t iter = 0; iter < opensession.idList.size(); iter++)
     246    {
     247        if (opensession.idList[iter] != gDlg->mId)
     248        {
     249            if (cstrIdList == "")
     250                cstrIdList = str2cstr(opensession.idList[iter]);
     251            else
     252                cstrIdList = cstrIdList + "," + str2cstr(opensession.idList[iter]);
     253        }
     254    }
     255
     256    gDlg->mFriendListBox.InsertString(gDlg->mFriendListBox.GetCount(), cstrIdList);
     257
     258    Session s;
     259    s.sessionId = opensession.sessid;
     260
     261    gDlg->scl.push_back(s);
     262
    246263    return 0;
    247264}
     
    265282    {
    266283        std::vector<std::string> idList;
    267         //FIXME : ,·Î ÆĽÌÇϱâ! testÄÚµå Âü°íÇÒ°Í
    268         idList.push_back(cstr2str(receiver));
     284        std::string comma;
     285        mFriendListBox.GetText(idx, receiver);
     286        std::istringstream is(cstr2str(receiver));
     287        while (std::getline(is, comma, ','))
     288            idList.push_back(comma);
     289        std::sort(idList.begin(), idList.end());
    269290        scl[idx].sessionId = chev.getSessionID(idList);
    270291    }
     
    309330    AGCDlg.DoModal();
    310331
     332    CString cmpCstr;
     333    for (int iter = 0; iter < this->mFriendListBox.GetCount(); iter++)
     334    {
     335        this->mFriendListBox.GetText(iter, cmpCstr);
     336        if (AGCDlg.groupChat == cmpCstr)
     337            return;
     338    }
     339
    311340    mFriendListBox.InsertString(mFriendListBox.GetCount(), AGCDlg.groupChat);
    312 
    313     //FIXME : Á¤»óÀûÀ¸·Î push_back µ¿ÀÛÇÏ´ÂÁö Å×½ºÆ®
    314     // ÀÌ°Å¿¡ ÀÇÇØ OnLbnSelchangeListFriends¿¡¼­ ¾ÈÁ×´ÂÁö È®ÀÎÇϱâ
    315     Session s;
    316     scl.push_back(s);
     341    gDlg->scl.resize(gDlg->scl.size() + 1);
    317342}
    318343
     
    344369        return;
    345370   
     371    // vector out of range error
    346372    if (scl[idx].sessionId == "")
    347373        return;
Note: See TracChangeset for help on using the changeset viewer.