Skip to content

Commit

Permalink
增加好友分组和好友备注功能;修正其他一些bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyuanlong committed Sep 17, 2018
1 parent eeb381e commit be74fad
Show file tree
Hide file tree
Showing 646 changed files with 1,622 additions and 1,194 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ iUpdateAuto.exe
flamingoclient/Source/Debug/
flamingoclient/iAutoUpdate/debug/
flamingoclient/Bin/Flamingo.exe
flamingoclient/Bin/Log/
flamingoclient/Bin/CatchScreen.exe

flamingoclient/Bin/Logs/

# Compiled Static libraries
*.lai
Expand Down
Empty file.
Empty file.
Empty file.
4 changes: 2 additions & 2 deletions flamingoclient/Bin/config/flamingo.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[server]
server=120.55.94.78
server=192.168.14.129
port=20000
fileserver=120.55.94.78
fileport=20001
Expand All @@ -12,7 +12,7 @@ heartbeatinterval=0
enablereconnect=1
reconnectinterval=5000
[app]
clearexpirelog=1
clearexpirelog=0
loglevel=0
[ui]
apptitle=Flamingo中文版
Expand Down
Binary file added flamingoclient/Bin/update/CatchScreen.zip
Binary file not shown.
Binary file added flamingoclient/Bin/update/Flamingo.zip
Binary file not shown.
Binary file added flamingoclient/Bin/update/Flamingo/Flamingo.exe
Binary file not shown.
3 changes: 3 additions & 0 deletions flamingoclient/Bin/update/update.version~
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<version>1.0.1000</version>
<1>主程序|Flamingo|1000</1>
<2>抓屏程序|CatchScreen|1000</2>
3 changes: 3 additions & 0 deletions flamingoclient/Bin/update/update2 - 副本.version
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<version>1.0.10</version>
<1>主程序|Flamingo|1.0.10</1>
<2>抓屏程序|CatchScreen|1.0.10</2>
1 change: 1 addition & 0 deletions flamingoclient/Source/FindFriendDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ void CFindFriendDlg::OnAddFriend(UINT uNotifyCode, int nID, CWindow wndCtl)
long nRelationType = 0;
if(m_pFMGClient->m_UserMgr.IsSelf(strAccountToAdd))
nRelationType = 1;
//注意调试版在账号后面加上了userid,所以导致可以加已经是好友的用户为好友,这不是bug;Release版不存在这个问题
else if(m_pFMGClient->m_UserMgr.IsFriend(strAccountToAdd))
nRelationType = 2;

Expand Down
109 changes: 60 additions & 49 deletions flamingoclient/Source/FlamingoClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Startup.h"
#include "File2.h"
#include "Path.h"
#include "../net/Msg.h"
#include <sstream>

CFlamingoClient& CFlamingoClient::GetInstance()
Expand Down Expand Up @@ -241,63 +242,58 @@ bool CFlamingoClient::AddNewTeam(PCTSTR pszNewTeamName)
{
if (pszNewTeamName == NULL || pszNewTeamName[0] == NULL)
return false;
/* 组装以后的格式
[
{
"teamindex": 0,
"teamname": "My Friends",
"members": [
{
"userid": 4,
"markname": ""
},
{
"userid": 124,
"markname": ""
}
]
},
{
"teamindex": 1,
"teamname": "My Classmates", //新分组
"members": []
}
]
*/

//TODO: 先判断是否离线
CAddTeamInfoRequest* pRequest = new CAddTeamInfoRequest();
pRequest->m_opType = updateteaminfo_operation_add;
pRequest->m_strNewTeamName = pszNewTeamName;

std::wostringstream osTeamInfo;
osTeamInfo << _T("[");
for (size_t i = 0; i < m_UserMgr.m_BuddyList.m_arrBuddyTeamInfo.size(); ++i)
{
osTeamInfo << _T("{\"teamindex\":") << i
<< _T(", \"teamname\": \"") << m_UserMgr.m_BuddyList.m_arrBuddyTeamInfo[i]->m_strName
<< _T("\", \"members\":[");
for (size_t j = 0; j < m_UserMgr.m_BuddyList.m_arrBuddyTeamInfo[i]->m_arrBuddyInfo.size(); ++j)
{
osTeamInfo << _T("{\"userid\":") << m_UserMgr.m_BuddyList.m_arrBuddyTeamInfo[i]->m_arrBuddyInfo[j]->m_uUserID << _T(", \"markname\":\"\"}");
//最后一个结尾不加逗号
if (j != m_UserMgr.m_BuddyList.m_arrBuddyTeamInfo[i]->m_arrBuddyInfo.size() - 1)
osTeamInfo << _T(",");
}
m_SendMsgThread.AddItem(pRequest);

osTeamInfo << _T("]}");
//最后一个结尾不加逗号
if (i != m_UserMgr.m_BuddyList.m_arrBuddyTeamInfo.size() - 1)
osTeamInfo << _T(",");
}
return true;
}

bool CFlamingoClient::DeleteTeam(PCTSTR pszOldTeamName)
{
if (pszOldTeamName == NULL || pszOldTeamName[0] == NULL)
return false;

//新分组节点
osTeamInfo << _T(", {\"teamindex\":") << m_UserMgr.m_BuddyList.m_arrBuddyTeamInfo.size()
<< _T(", \"teamname\": \"") << pszNewTeamName
<< _T("\", \"members\":[");
//TODO: 先判断是否离线
CAddTeamInfoRequest* pRequest = new CAddTeamInfoRequest();
pRequest->m_opType = updateteaminfo_operation_delete;
pRequest->m_strOldTeamName = pszOldTeamName;

osTeamInfo << _T("]}]");
m_SendMsgThread.AddItem(pRequest);

tstring strTeamInfo = osTeamInfo.str();
return true;
}

bool CFlamingoClient::ModifyTeamName(PCTSTR pszNewTeamName, PCTSTR pszOldTeamName)
{
if (pszNewTeamName == NULL || pszNewTeamName[0] == NULL || pszOldTeamName == NULL || pszOldTeamName[0] == NULL)
return false;

//TODO: 先判断是否离线
CAddTeamInfoRequest* pRequest = new CAddTeamInfoRequest();
pRequest->m_strNewTeamInfo = strTeamInfo;
pRequest->m_opType = updateteaminfo_operation_modify;
pRequest->m_strNewTeamName = pszNewTeamName;
pRequest->m_strOldTeamName = pszOldTeamName;

m_SendMsgThread.AddItem(pRequest);

return true;
}

bool CFlamingoClient::MoveFriendToOtherTeam(UINT uUserID, PCTSTR pszOldTeamName, PCTSTR pszNewTeamName)
{
if (pszOldTeamName == NULL || pszOldTeamName[0] == NULL || pszNewTeamName == NULL || pszNewTeamName[0] == NULL)
return false;

//TODO: 先判断是否离线
CMoveFriendRequest* pRequest = new CMoveFriendRequest();
pRequest->m_nFriendID = (int)uUserID;
pRequest->m_strNewTeamName = pszNewTeamName;
pRequest->m_strOldTeamName = pszOldTeamName;

m_SendMsgThread.AddItem(pRequest);

Expand Down Expand Up @@ -435,6 +431,17 @@ void CFlamingoClient::CreateNewGroup(PCTSTR pszGroupName)
m_SendMsgThread.AddItem(pRequest);
}

void CFlamingoClient::ModifyFriendMarkName(UINT friendID, PCTSTR pszNewMarkName)
{
if (!m_bNetworkAvailable)
return;

CModifyFriendMakeNameRequest* pRequest = new CModifyFriendMakeNameRequest();
pRequest->m_uFriendID = friendID;
_tcscpy_s(pRequest->m_szNewMarkName, ARRAYSIZE(pRequest->m_szNewMarkName), pszNewMarkName);
m_SendMsgThread.AddItem(pRequest);
}

void CFlamingoClient::ResponseAddFriendApply(UINT uAccountID, UINT uCmd)
{
if(uCmd!=Agree && uCmd!=Refuse)
Expand Down Expand Up @@ -1121,6 +1128,7 @@ void CFlamingoClient::OnUpdateUserBasicInfo(UINT message, WPARAM wParam, LPARAM
CBuddyInfo* pBuddyInfo = NULL;
TCHAR szAccountName[32] = { 0 };
TCHAR szNickName[32] = { 0 };
TCHAR szMarkName[32] = { 0 };
TCHAR szSignature[256] = { 0 };
TCHAR szPhoneNumber[32] = { 0 };
TCHAR szMail[32] = { 0 };
Expand All @@ -1143,6 +1151,7 @@ void CFlamingoClient::OnUpdateUserBasicInfo(UINT message, WPARAM wParam, LPARAM
{
EncodeUtil::Utf8ToUnicode(iter2->szAccountName, szAccountName, ARRAYSIZE(szAccountName));
EncodeUtil::Utf8ToUnicode(iter2->szNickName, szNickName, ARRAYSIZE(szNickName));
EncodeUtil::Utf8ToUnicode(iter2->szMarkName, szMarkName, ARRAYSIZE(szMarkName));
EncodeUtil::Utf8ToUnicode(iter2->szSignature, szSignature, ARRAYSIZE(szSignature));
EncodeUtil::Utf8ToUnicode(iter2->szPhoneNumber, szPhoneNumber, ARRAYSIZE(szPhoneNumber));
EncodeUtil::Utf8ToUnicode(iter2->szMail, szMail, ARRAYSIZE(szMail));
Expand All @@ -1157,6 +1166,8 @@ void CFlamingoClient::OnUpdateUserBasicInfo(UINT message, WPARAM wParam, LPARAM

pBuddyInfo->m_strNickName = szNickName;

pBuddyInfo->m_strMarkName = szMarkName;

pBuddyInfo->m_strSign = szSignature;

pBuddyInfo->m_strMobile = szPhoneNumber;
Expand Down
14 changes: 9 additions & 5 deletions flamingoclient/Source/FlamingoClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ class CFlamingoClient
void GetGroupMembers(int32_t groupid); // 获取群成员
void ChangeStatus(int32_t nNewStatus); // 更改自己的登录状态

BOOL FindFriend(PCTSTR pszAccountName, long nType, HWND hReflectionWnd);// 查找好友
BOOL FindFriend(PCTSTR pszAccountName, long nType, HWND hReflectionWnd); // 查找好友
BOOL AddFriend(UINT uAccountToAdd);
void ResponseAddFriendApply(UINT uAccountID, UINT uCmd); //回应加好友请求任务
BOOL DeleteFriend(UINT uAccountID); // 删除好友

bool AddNewTeam(PCTSTR pszNewTeamName); //添加新分组
void ResponseAddFriendApply(UINT uAccountID, UINT uCmd); //回应加好友请求任务
BOOL DeleteFriend(UINT uAccountID); // 删除好友

bool AddNewTeam(PCTSTR pszNewTeamName); //添加新分组
bool DeleteTeam(PCTSTR pszOldTeamName); //删除分组
bool ModifyTeamName(PCTSTR pszNewTeamName, PCTSTR pszOldTeamName); //修改分组名称
bool MoveFriendToOtherTeam(UINT uUserID, PCTSTR pszOldTeamName, PCTSTR pszNewTeamName); //移动好友至其他分组

BOOL UpdateLogonUserInfo(PCTSTR pszNickName,
PCTSTR pszSignature,
Expand All @@ -74,6 +77,7 @@ class CFlamingoClient
void SendHeartbeatMessage();
void ModifyPassword(PCTSTR pszOldPassword, PCTSTR pszNewPassword);
void CreateNewGroup(PCTSTR pszGroupName);
void ModifyFriendMarkName(UINT friendID, PCTSTR pszNewMarkName);
void ChangeStatus(long nStatus); // 改变在线状态
void UpdateBuddyList(); // 更新好友列表
void UpdateGroupList(); // 更新群列表
Expand Down
57 changes: 15 additions & 42 deletions flamingoclient/Source/MainDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2334,12 +2334,17 @@ void CMainDlg::OnBuddyListDeleteTeam(UINT uNotifyCode, int nID, CWindow wndCtl)
return;
}

CString strTeamName = m_BuddyListCtrl.GetBuddyTeamName(nTeamIndex);
if (strTeamName == DEFAULT_TEAMNAME)
{
::MessageBox(m_hWnd, _T("默认分组不能删除!"), g_strAppTitle.c_str(), MB_ICONINFORMATION | MB_OK);
return;
}

if(IDYES != ::MessageBox(m_hWnd, _T("删除该分组以后,该组下的好友将移至默认分组中。\n确定要删除该分组吗?"), g_strAppTitle.c_str(), MB_YESNO|MB_ICONQUESTION))
return;


if(DeleteTeam(nTeamIndex))
::PostMessage(m_hWnd, FMG_MSG_UPDATE_BUDDY_LIST, 0, 0);
m_FMGClient.DeleteTeam(strTeamName);
}

void CMainDlg::OnBuddyListModifyTeamName(UINT uNotifyCode, int nID, CWindow wndCtl)
Expand Down Expand Up @@ -2376,28 +2381,26 @@ void CMainDlg::OnMoveBuddyToTeam(UINT uNotifyCode, int nID, CWindow wndCtl)
if(pTeamInfo == NULL)
return;

//从原分组中移除
CString strOldTeamName;
//获取原分组名
for(std::vector<CBuddyInfo*>::iterator iter=pTeamInfo->m_arrBuddyInfo.begin(); iter!=pTeamInfo->m_arrBuddyInfo.end(); ++iter)
{
pBuddyInfo =*iter;
if(pBuddyInfo!=NULL && pBuddyInfo->m_uUserID == uUserID)
{
pTeamInfo->m_arrBuddyInfo.erase(iter);
strOldTeamName = pTeamInfo->m_strName.c_str();
break;
}
}

//加到目标分组中
//获取目标分组名
long nTargetIndex = nID-TEAM_MENU_ITEM_BASE;
CBuddyTeamInfo* pTargetTeamInfo = m_FMGClient.m_UserMgr.m_BuddyList.GetBuddyTeamByIndex(nTargetIndex);
if(pTargetTeamInfo == NULL)
return;
CString strNewTeamName = pTargetTeamInfo->m_strName.c_str();

//改变用户所在分组索引
pBuddyInfo->m_nTeamIndex = nTargetIndex;
pTargetTeamInfo->m_arrBuddyInfo.push_back(pBuddyInfo);

::PostMessage(m_hWnd, FMG_MSG_UPDATE_BUDDY_LIST, 0, 0);
m_FMGClient.MoveFriendToOtherTeam(uUserID, strOldTeamName, strNewTeamName);
}

//右键菜单删除好友
Expand Down Expand Up @@ -2486,7 +2489,7 @@ void CMainDlg::OnMenu_ViewBuddyInfoFromRecentList(UINT uNotifyCode, int nID, CWi
::PostMessage(m_hWnd, WM_SHOW_BUDDYINFODLG, NULL, nUTalkUin);
}

void CMainDlg::OnMenu_ModifyBuddyName(UINT uNotifyCode, int nID, CWindow wndCtl)
void CMainDlg::OnMenu_ModifyBuddyMarkName(UINT uNotifyCode, int nID, CWindow wndCtl)
{
int nTeamIndex, nIndex;
m_BuddyListCtrl.GetCurSelIndex(nTeamIndex, nIndex);
Expand Down Expand Up @@ -5561,36 +5564,6 @@ void CMainDlg::ShowAddFriendConfirmDlg()
m_FMGClient.m_aryAddFriendInfo.erase(m_FMGClient.m_aryAddFriendInfo.end()-1);
}

BOOL CMainDlg::DeleteTeam(long nTeamIndex)
{
CBuddyTeamInfo* pTeamInfoToDelete = m_FMGClient.m_UserMgr.m_BuddyList.GetBuddyTeamByIndex(nTeamIndex);
if(pTeamInfoToDelete == NULL)
return FALSE;
std::vector<CBuddyTeamInfo*>::iterator iter = m_FMGClient.m_UserMgr.m_BuddyList.m_arrBuddyTeamInfo.begin();
//删除分组
for(; iter!=m_FMGClient.m_UserMgr.m_BuddyList.m_arrBuddyTeamInfo.end(); ++iter)
{
if((*iter)->m_nIndex == pTeamInfoToDelete->m_nIndex)
{
m_FMGClient.m_UserMgr.m_BuddyList.m_arrBuddyTeamInfo.erase(iter);
break;
}
}
//将分组中好友移至第一分组中
CBuddyTeamInfo* pDefaultTeamInfo = m_FMGClient.m_UserMgr.m_BuddyList.GetBuddyTeamByIndex(0);
CBuddyInfo* pBuddyInfo = NULL;
for(std::vector<CBuddyInfo*>::iterator it=pTeamInfoToDelete->m_arrBuddyInfo.begin(); it!=pTeamInfoToDelete->m_arrBuddyInfo.end(); ++it)
{
pBuddyInfo =*it;
pDefaultTeamInfo->m_arrBuddyInfo.push_back(pBuddyInfo);
}

pTeamInfoToDelete->m_arrBuddyInfo.clear();
delete pTeamInfoToDelete;

return TRUE;
}

BOOL CMainDlg::InsertTeamMenuItem(CSkinMenu& popMenu)
{
//if(popMenu.GetMenuItemCount() >= 5)
Expand Down
6 changes: 2 additions & 4 deletions flamingoclient/Source/MainDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class CMainDlg : public CDialogImpl<CMainDlg>, public CUpdateUI<CMainDlg>,
COMMAND_ID_HANDLER_EX(IDM_SENDMSGFROMRECENTLIST, OnMenu_SendBuddyMessageFromRecentList)
COMMAND_ID_HANDLER_EX(IDM_VIEWBUDDYINFO, OnMenu_ViewBuddyInfo) //查看好友资料
COMMAND_ID_HANDLER_EX(IDM_VIEWBUDDYINFO_FROMRECENTLIST, OnMenu_ViewBuddyInfoFromRecentList)
COMMAND_ID_HANDLER_EX(IDM_MODIFY_BUDDY_MARKNAME, OnMenu_ModifyBuddyName)//修改好友备注
COMMAND_ID_HANDLER_EX(IDM_MODIFY_BUDDY_MARKNAME, OnMenu_ModifyBuddyMarkName)//修改好友备注
COMMAND_ID_HANDLER_EX(IDM_DELETEFRIEND, OnMenu_DeleteFriend) //删除好友
COMMAND_ID_HANDLER_EX(IDM_CLEARRECENTLIST, OnClearAllRecentList)
COMMAND_ID_HANDLER_EX(IDM_DELETERECENTITEM, OnDeleteRecentItem);
Expand Down Expand Up @@ -270,7 +270,7 @@ class CMainDlg : public CDialogImpl<CMainDlg>, public CUpdateUI<CMainDlg>,
void OnDeleteRecentItem(UINT uNotifyCode, int nID, CWindow wndCtl);
void OnMenu_ViewBuddyInfo(UINT uNotifyCode, int nID, CWindow wndCtl); //右键菜单查看好友资料
void OnMenu_ViewBuddyInfoFromRecentList(UINT uNotifyCode, int nID, CWindow wndCtl);
void OnMenu_ModifyBuddyName(UINT uNotifyCode, int nID, CWindow wndCtl); //右键菜单修改好友备注名称
void OnMenu_ModifyBuddyMarkName(UINT uNotifyCode, int nID, CWindow wndCtl); //右键菜单修改好友备注名称

void OnMenu_SendGroupMessage(UINT uNotifyCode, int nID, CWindow wndCtl);
void OnMenu_ViewGroupInfo(UINT uNotifyCode, int nID, CWindow wndCtl);
Expand Down Expand Up @@ -385,8 +385,6 @@ class CMainDlg : public CDialogImpl<CMainDlg>, public CUpdateUI<CMainDlg>,

void ShowAddFriendConfirmDlg(); //显示加好友请求对话框

BOOL DeleteTeam(long nTeamIndex);

BOOL InsertTeamMenuItem(CSkinMenu& popMenu);

void SaveCurrentLogonUserToFile(); //将当前登录的账户保存到文件中
Expand Down
8 changes: 5 additions & 3 deletions flamingoclient/Source/ModifyMarkNameDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ void CModifyMarkNameDlg::OnOK(UINT uNotifyCode, int nID, CWindow wndCtl)
return;
}

CBuddyInfo* pBuddyInfo = m_pFMGClient->m_UserMgr.m_BuddyList.GetBuddy(m_uUserID);
if(pBuddyInfo != NULL)
pBuddyInfo->m_strMarkName = strMarkName;
//CBuddyInfo* pBuddyInfo = m_pFMGClient->m_UserMgr.m_BuddyList.GetBuddy(m_uUserID);
//if(pBuddyInfo != NULL)
// pBuddyInfo->m_strMarkName = strMarkName;

m_pFMGClient->ModifyFriendMarkName(m_uUserID, strMarkName);

EndDialog(IDOK);
}
Expand Down
2 changes: 2 additions & 0 deletions flamingoclient/Source/RecvMsgThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ BOOL CRecvMsgThread::HandleFriendListInfo(const std::string& strMsg)
//strcpy_s(pUserBasicInfo->szAccountName, ARRAYSIZE(pUserBasicInfo->szAccountName), pUserInfo[i].user);
//昵称
strcpy_s(pUserBasicInfo->szNickName, ARRAYSIZE(pUserBasicInfo->szNickName), JsonRoot["userinfo"][(UINT)i]["members"][(UINT)j]["nickname"].asString().c_str());
//备注名
strcpy_s(pUserBasicInfo->szMarkName, ARRAYSIZE(pUserBasicInfo->szMarkName), JsonRoot["userinfo"][(UINT)i]["members"][(UINT)j]["markname"].asString().c_str());
//签名
strcpy_s(pUserBasicInfo->szSignature, ARRAYSIZE(pUserBasicInfo->szSignature), JsonRoot["userinfo"][(UINT)i]["members"][(UINT)j]["signature"].asString().c_str());
//地址
Expand Down
Loading

0 comments on commit be74fad

Please sign in to comment.