diff options
Diffstat (limited to 'protocols/MSN/src/msn_chat.cpp')
-rw-r--r-- | protocols/MSN/src/msn_chat.cpp | 330 |
1 files changed, 148 insertions, 182 deletions
diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp index 04b17072d5..fb90187f21 100644 --- a/protocols/MSN/src/msn_chat.cpp +++ b/protocols/MSN/src/msn_chat.cpp @@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. MCONTACT CMsnProto::MSN_GetChatInernalHandle(MCONTACT hContact)
{
MCONTACT result = hContact;
- if ( isChatRoom(hContact)) {
+ if (isChatRoom(hContact)) {
DBVARIANT dbv;
if (getString(hContact, "ChatRoomID", &dbv) == 0) {
result = (MCONTACT)(-atol(dbv.pszVal));
@@ -96,8 +96,7 @@ void CMsnProto::MSN_ChatStart(ThreadData* info) gce.time = time(NULL);
gce.bIsMe = FALSE;
- for (int j=0; j < info->mJoinedContactsWLID.getCount(); j++)
- {
+ for (int j = 0; j < info->mJoinedContactsWLID.getCount(); j++) {
MCONTACT hContact = MSN_HContactFromEmail(info->mJoinedContactsWLID[j]);
TCHAR *wlid = mir_a2t(info->mJoinedContactsWLID[j]);
@@ -120,10 +119,8 @@ void CMsnProto::MSN_KillChatSession(const TCHAR* id) static void ChatInviteUser(ThreadData* info, const char* email)
{
- if (info->mJoinedContactsWLID.getCount())
- {
- for (int j=0; j < info->mJoinedContactsWLID.getCount(); j++)
- {
+ if (info->mJoinedContactsWLID.getCount()) {
+ for (int j = 0; j < info->mJoinedContactsWLID.getCount(); j++) {
if (_stricmp(info->mJoinedContactsWLID[j], email) == 0)
return;
}
@@ -138,27 +135,21 @@ static void ChatInviteSend(HANDLE hItem, HWND hwndList, STRLIST &str, CMsnProto if (hItem == NULL)
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);
- while (hItem)
- {
- if (IsHContactGroup(hItem))
- {
+ while (hItem) {
+ if (IsHContactGroup(hItem)) {
HANDLE hItemT = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
if (hItemT) ChatInviteSend(hItemT, hwndList, str, ppro);
}
- else
- {
+ else {
int chk = SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0);
- if (chk)
- {
- if (IsHContactInfo(hItem))
- {
+ if (chk) {
+ if (IsHContactInfo(hItem)) {
TCHAR buf[128] = _T("");
SendMessage(hwndList, CLM_GETITEMTEXT, (WPARAM)hItem, (LPARAM)buf);
if (buf[0]) str.insert(mir_t2a(buf));
}
- else
- {
+ else {
MsnContact *msc = ppro->Lists_Get((MCONTACT)hItem);
if (msc) str.insertn(msc->email);
}
@@ -180,8 +171,7 @@ static void ChatPrepare(MCONTACT hItem, HWND hwndList, CMsnProto* ppro) if (hItem == NULL)
hItem = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);
- while (hItem)
- {
+ while (hItem) {
MCONTACT hItemN = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);
if (IsHContactGroup(hItem)) {
@@ -193,22 +183,21 @@ static void ChatPrepare(MCONTACT hItem, HWND hwndList, CMsnProto* ppro) ChatValidateContact(hItem, hwndList, ppro);
hItem = hItemN;
- }
+ }
}
INT_PTR CALLBACK DlgInviteToChat(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
InviteChatParam *param = (InviteChatParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
param = (InviteChatParam*)lParam;
-// WindowSetIcon(hwndDlg, "msn");
+ // WindowSetIcon(hwndDlg, "msn");
break;
case WM_CLOSE:
@@ -216,89 +205,78 @@ INT_PTR CALLBACK DlgInviteToChat(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l break;
case WM_NCDESTROY:
-// WindowFreeIcon(hwndDlg);
+ // WindowFreeIcon(hwndDlg);
delete param;
break;
case WM_NOTIFY:
- {
- NMCLISTCONTROL* nmc = (NMCLISTCONTROL*)lParam;
- if (nmc->hdr.idFrom == IDC_CCLIST)
+ NMCLISTCONTROL* nmc;
{
- switch (nmc->hdr.code)
- {
- case CLN_NEWCONTACT:
- if (param && (nmc->flags & (CLNF_ISGROUP | CLNF_ISINFO)) == 0)
- ChatValidateContact((MCONTACT)nmc->hItem, nmc->hdr.hwndFrom, param->ppro);
- break;
-
- case CLN_LISTREBUILT:
- if (param)
- ChatPrepare(NULL, nmc->hdr.hwndFrom, param->ppro);
- break;
+ nmc = (NMCLISTCONTROL*)lParam;
+ if (nmc->hdr.idFrom == IDC_CCLIST) {
+ switch (nmc->hdr.code) {
+ case CLN_NEWCONTACT:
+ if (param && (nmc->flags & (CLNF_ISGROUP | CLNF_ISINFO)) == 0)
+ ChatValidateContact((MCONTACT)nmc->hItem, nmc->hdr.hwndFrom, param->ppro);
+ break;
+
+ case CLN_LISTREBUILT:
+ if (param)
+ ChatPrepare(NULL, nmc->hdr.hwndFrom, param->ppro);
+ break;
+ }
}
}
- }
- break;
+ break;
case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDC_ADDSCR:
- if (param->ppro->msnLoggedIn)
- {
- TCHAR email[MSN_MAX_EMAIL_LEN];
- GetDlgItemText(hwndDlg, IDC_EDITSCR, email, SIZEOF(email));
+ switch (LOWORD(wParam)) {
+ case IDC_ADDSCR:
+ if (param->ppro->msnLoggedIn) {
+ TCHAR email[MSN_MAX_EMAIL_LEN];
+ GetDlgItemText(hwndDlg, IDC_EDITSCR, email, SIZEOF(email));
+
+ CLCINFOITEM cii = { 0 };
+ cii.cbSize = sizeof(cii);
+ cii.flags = CLCIIF_CHECKBOX | CLCIIF_BELOWCONTACTS;
+ cii.pszText = _tcslwr(email);
+
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
+ SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_SETCHECKMARK, (LPARAM)hItem, 1);
+ }
+ break;
- CLCINFOITEM cii = {0};
- cii.cbSize = sizeof(cii);
- cii.flags = CLCIIF_CHECKBOX | CLCIIF_BELOWCONTACTS;
- cii.pszText = _tcslwr(email);
+ case IDCANCEL:
+ EndDialog(hwndDlg, IDCANCEL);
+ break;
- HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
- SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_SETCHECKMARK, (LPARAM)hItem, 1);
- }
- break;
-
- case IDOK:
- {
- char tEmail[MSN_MAX_EMAIL_LEN] = "";
- ThreadData *info = NULL;
- if (param->id)
- info = param->ppro->MSN_GetThreadByChatId(param->id);
- else if (param->hContact)
- {
- if (!param->ppro->MSN_IsMeByContact(param->hContact, tEmail))
- info = param->ppro->MSN_GetThreadByContact(tEmail);
- }
-
- HWND hwndList = GetDlgItem(hwndDlg, IDC_CCLIST);
- STRLIST *cont = new STRLIST;
- ChatInviteSend(NULL, hwndList, *cont, param->ppro);
-
- if (info)
- {
- for (int i = 0; i < cont->getCount(); ++i)
- ChatInviteUser(info, (*cont)[i]);
- delete cont;
- }
- else
- {
- if (tEmail[0]) cont->insertn(tEmail);
- param->ppro->MsgQueue_Add("chat", 'X', NULL, 0, NULL, 0, cont);
- if (param->ppro->msnLoggedIn)
- param->ppro->msnNsThread->sendPacket("XFR", "SB");
- }
- }
+ case IDOK:
+ char tEmail[MSN_MAX_EMAIL_LEN]; tEmail[0] = 0;
+ ThreadData *info = NULL;
+ if (param->id)
+ info = param->ppro->MSN_GetThreadByChatId(param->id);
+ else if (param->hContact) {
+ if (!param->ppro->MSN_IsMeByContact(param->hContact, tEmail))
+ info = param->ppro->MSN_GetThreadByContact(tEmail);
+ }
- EndDialog(hwndDlg, IDOK);
- break;
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_CCLIST);
+ STRLIST *cont = new STRLIST;
+ ChatInviteSend(NULL, hwndList, *cont, param->ppro);
- case IDCANCEL:
- EndDialog(hwndDlg, IDCANCEL);
- break;
+ if (info) {
+ for (int i = 0; i < cont->getCount(); ++i)
+ ChatInviteUser(info, (*cont)[i]);
+ delete cont;
}
+ else {
+ if (tEmail[0]) cont->insertn(tEmail);
+ param->ppro->MsgQueue_Add("chat", 'X', NULL, 0, NULL, 0, cont);
+ if (param->ppro->msnLoggedIn)
+ param->ppro->msnNsThread->sendPacket("XFR", "SB");
+ }
+
+ EndDialog(hwndDlg, IDOK);
}
break;
}
@@ -313,109 +291,101 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) if (_stricmp(gch->pDest->pszModule, m_szModuleName)) return 0;
- switch (gch->pDest->iType)
- {
- case GC_SESSION_TERMINATE:
+ switch (gch->pDest->iType) {
+ case GC_SESSION_TERMINATE:
{
- ThreadData* thread = MSN_GetThreadByChatId(gch->pDest->ptszID);
+ ThreadData* thread = MSN_GetThreadByChatId(gch->pDest->ptszID);
if (thread != NULL)
thread->sendTerminate();
- break;
}
+ break;
- case GC_USER_MESSAGE:
- if (gch->ptszText && gch->ptszText[0])
- {
- ThreadData* thread = MSN_GetThreadByChatId(gch->pDest->ptszID);
- if (thread)
- {
- TCHAR* pszMsg = UnEscapeChatTags(NEWTSTR_ALLOCA(gch->ptszText));
- rtrimt(pszMsg); // remove the ending linebreak
- thread->sendMessage('N', NULL, NETID_MSN, UTF8(pszMsg), 0);
-
- DBVARIANT dbv;
- int bError = getTString("Nick", &dbv);
-
- GCDEST gcd = { m_szModuleName, gch->pDest->ptszID, GC_EVENT_MESSAGE };
- GCEVENT gce = { sizeof(gce), &gcd };
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszNick = bError ? _T("") : dbv.ptszVal;
- gce.ptszUID = mir_a2t(MyOptions.szEmail);
- gce.time = time(NULL);
- gce.ptszText = gch->ptszText;
- gce.bIsMe = TRUE;
- CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
-
- mir_free((void*)gce.ptszUID);
- if (!bError)
- db_free(&dbv);
- }
+ case GC_USER_MESSAGE:
+ if (gch->ptszText && gch->ptszText[0]) {
+ ThreadData* thread = MSN_GetThreadByChatId(gch->pDest->ptszID);
+ if (thread) {
+ TCHAR* pszMsg = UnEscapeChatTags(NEWTSTR_ALLOCA(gch->ptszText));
+ rtrimt(pszMsg); // remove the ending linebreak
+ thread->sendMessage('N', NULL, NETID_MSN, UTF8(pszMsg), 0);
+
+ DBVARIANT dbv;
+ int bError = getTString("Nick", &dbv);
+
+ GCDEST gcd = { m_szModuleName, gch->pDest->ptszID, GC_EVENT_MESSAGE };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.ptszNick = bError ? _T("") : dbv.ptszVal;
+ gce.ptszUID = mir_a2t(MyOptions.szEmail);
+ gce.time = time(NULL);
+ gce.ptszText = gch->ptszText;
+ gce.bIsMe = TRUE;
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
+
+ mir_free((void*)gce.ptszUID);
+ if (!bError)
+ db_free(&dbv);
}
- break;
+ }
+ break;
+
+ case GC_USER_CHANMGR:
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, DlgInviteToChat,
+ LPARAM(new InviteChatParam(gch->pDest->ptszID, NULL, this)));
+ break;
+
+ case GC_USER_PRIVMESS:
+ {
+ char *email = mir_t2a(gch->ptszUID);
+ MCONTACT hContact = MSN_HContactFromEmail(email);
+ CallService(MS_MSG_SENDMESSAGE, hContact, 0);
+ mir_free(email);
+ break;
+ }
- case GC_USER_CHANMGR:
+ case GC_USER_LOGMENU:
+ switch (gch->dwData) {
+ case 10:
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, DlgInviteToChat,
LPARAM(new InviteChatParam(gch->pDest->ptszID, NULL, this)));
break;
- case GC_USER_PRIVMESS:
- {
- char *email = mir_t2a(gch->ptszUID);
- MCONTACT hContact = MSN_HContactFromEmail(email);
- CallService(MS_MSG_SENDMESSAGE, hContact, 0);
- mir_free(email);
+ case 20:
+ MSN_KillChatSession(gch->pDest->ptszID);
break;
}
+ break;
- case GC_USER_LOGMENU:
- switch(gch->dwData)
- {
- case 10:
- DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, DlgInviteToChat,
- LPARAM(new InviteChatParam(gch->pDest->ptszID, NULL, this)));
- break;
-
- case 20:
- MSN_KillChatSession(gch->pDest->ptszID);
- break;
- }
- break;
-
- case GC_USER_NICKLISTMENU:
- {
- char *email = mir_t2a(gch->ptszUID);
- MCONTACT hContact = MSN_HContactFromEmail(email);
- mir_free(email);
+ case GC_USER_NICKLISTMENU:
+ MCONTACT hContact = MSN_HContactFromEmail(_T2A(gch->ptszUID));
- switch(gch->dwData)
- {
- case 10:
- CallService(MS_USERINFO_SHOWDIALOG, hContact, 0);
- break;
+ switch (gch->dwData) {
+ case 10:
+ CallService(MS_USERINFO_SHOWDIALOG, hContact, 0);
+ break;
- case 20:
- CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact, 0);
- break;
+ case 20:
+ CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact, 0);
+ break;
- case 110:
- MSN_KillChatSession(gch->pDest->ptszID);
- break;
- }
+ case 110:
+ MSN_KillChatSession(gch->pDest->ptszID);
break;
}
-/* haven't implemented in chat.dll
- case GC_USER_TYPNOTIFY:
- {
+ break;
+
+ /* haven't implemented in chat.dll
+ case GC_USER_TYPNOTIFY:
+ {
int chatID = atoi(p);
ThreadData* thread = MSN_GetThreadByContact((HANDLE)-chatID);
for (int j=0; j < thread->mJoinedCount; j++)
{
- if ((long)thread->mJoinedContacts[j] > 0)
- CallService(MS_PROTO_SELFISTYPING, (WPARAM) thread->mJoinedContacts[j], (LPARAM) PROTOTYPE_SELFTYPING_ON);
+ if ((long)thread->mJoinedContacts[j] > 0)
+ CallService(MS_PROTO_SELFISTYPING, (WPARAM) thread->mJoinedContacts[j], (LPARAM) PROTOTYPE_SELFTYPING_ON);
}
break;
- }
-*/
+ }
+ */
}
return 0;
@@ -423,12 +393,11 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) int CMsnProto::MSN_GCMenuHook(WPARAM, LPARAM lParam)
{
- GCMENUITEMS *gcmi= (GCMENUITEMS*) lParam;
+ GCMENUITEMS *gcmi = (GCMENUITEMS*)lParam;
if (gcmi == NULL || _stricmp(gcmi->pszModule, m_szModuleName)) return 0;
- if (gcmi->Type == MENU_ON_LOG)
- {
+ if (gcmi->Type == MENU_ON_LOG) {
static const struct gc_item Items[] =
{
{ LPGENT("&Invite user..."), 10, MENU_ITEM, FALSE },
@@ -437,11 +406,9 @@ int CMsnProto::MSN_GCMenuHook(WPARAM, LPARAM lParam) gcmi->nItems = SIZEOF(Items);
gcmi->Item = (gc_item*)Items;
}
- else if (gcmi->Type == MENU_ON_NICKLIST)
- {
- char* email = mir_t2a(gcmi->pszUID);
- if (!_stricmp(MyOptions.szEmail, email))
- {
+ else if (gcmi->Type == MENU_ON_NICKLIST) {
+ char *email = mir_t2a(gcmi->pszUID);
+ if (!_stricmp(MyOptions.szEmail, email)) {
static const struct gc_item Items[] =
{
{ LPGENT("User &details"), 10, MENU_ITEM, FALSE },
@@ -452,8 +419,7 @@ int CMsnProto::MSN_GCMenuHook(WPARAM, LPARAM lParam) gcmi->nItems = SIZEOF(Items);
gcmi->Item = (gc_item*)Items;
}
- else
- {
+ else {
static const struct gc_item Items[] =
{
{ LPGENT("User &details"), 10, MENU_ITEM, FALSE },
|