summaryrefslogtreecommitdiff
path: root/protocols/SkypeClassic/src/gchat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/SkypeClassic/src/gchat.cpp')
-rw-r--r--protocols/SkypeClassic/src/gchat.cpp126
1 files changed, 38 insertions, 88 deletions
diff --git a/protocols/SkypeClassic/src/gchat.cpp b/protocols/SkypeClassic/src/gchat.cpp
index 3091f0f8d9..cefd1c891f 100644
--- a/protocols/SkypeClassic/src/gchat.cpp
+++ b/protocols/SkypeClassic/src/gchat.cpp
@@ -24,12 +24,6 @@
#define STR "%s"
#endif
-/* VC6 PSDK compatibility */
-#if !defined(_WIN64) && !defined(SetWindowLongPtr)
-#define SetWindowLongPtr SetWindowLong
-#define GetWindowLongPtr GetWindowLong
-#endif
-
#pragma warning (disable: 4706) // assignment within conditional expression
extern HANDLE hInitChat;
@@ -119,8 +113,6 @@ static int AddChatContact(gchat_contacts *gc, char *who, TCHAR *pszRole)
{
int i = -2;
MCONTACT hContact;
- GCDEST gcd = {0};
- GCEVENT gce = {0};
CONTACTINFO ci = {0};
TCHAR *twho;
@@ -130,15 +122,11 @@ static int AddChatContact(gchat_contacts *gc, char *who, TCHAR *pszRole)
if ((i=ExistsChatContact(gc, twho))>=0) return i;
hContact=find_contact(who);
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = gc->szChatName;
- gcd.iType = GC_EVENT_JOIN;
-
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
- gce.ptszStatus = pszRole?pszRole:_T("USER");
+ GCDEST gcd = { SKYPE_PROTONAME, gc->szChatName, GC_EVENT_JOIN };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.time = (DWORD)time(NULL);
- gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR;
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.ptszStatus = pszRole ? pszRole : _T("USER");
ci.cbSize = sizeof(ci);
ci.szProto = SKYPE_PROTONAME;
@@ -184,7 +172,7 @@ MCONTACT find_chat(LPCTSTR chatname) {
DBVARIANT dbv;
for (hContact=db_find_first();hContact != NULL;hContact=db_find_next(hContact)) {
- szProto = (char*)CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0 );
+ szProto = (char*)CallService( MS_PROTO_GETCONTACTBASEPROTO, hContact, 0 );
if (szProto!=NULL && !strcmp(szProto, SKYPE_PROTONAME) &&
db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0)==1)
{
@@ -206,7 +194,7 @@ MCONTACT find_chatA(char *chatname) {
DBVARIANT dbv;
for (hContact=db_find_first();hContact != NULL;hContact=db_find_next(hContact)) {
- szProto = (char*)CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0 );
+ szProto = (char*)CallService( MS_PROTO_GETCONTACTBASEPROTO, hContact, 0 );
if (szProto!=NULL && !strcmp(szProto, SKYPE_PROTONAME) &&
db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0)==1)
{
@@ -286,17 +274,10 @@ int __cdecl AddMembers(char *szSkypeMsg) {
}
// Quit contacts which are no longer there
if (iRet == 0 && contactmask) {
- GCDEST gcd = {0};
- GCEVENT gce = {0};
-
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = szChatId;
- gcd.iType = GC_EVENT_QUIT;
-
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
+ GCDEST gcd = { SKYPE_PROTONAME, szChatId, GC_EVENT_QUIT };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.time = (DWORD)time(NULL);
- gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR;
+ gce.dwFlags = GCEF_ADDTOLOG;
ci.cbSize = sizeof(ci);
ci.szProto = SKYPE_PROTONAME;
@@ -380,22 +361,18 @@ INT_PTR CALLBACK InputBoxDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
lParam = 1 - Create groupchat, but don't open it
0 - Default - open groupchat after init
*/
-int __cdecl ChatInit(WPARAM wParam, LPARAM lParam) {
- GCSESSION gcw = {0};
- GCEVENT gce = {0};
- GCDEST gcd = {0};
+
+int __cdecl ChatInit(WPARAM wParam, LPARAM lParam)
+{
DBVARIANT dbv, dbv2;
char *szChatName;
int iRet = -1;
- UNREFERENCED_PARAMETER(lParam);
-
if (!wParam) return -1;
- gcw.cbSize = sizeof(GCSESSION);
+ GCSESSION gcw = { sizeof(gcw) };
gcw.iType = GCW_CHATROOM;
gcw.pszModule = SKYPE_PROTONAME;
- gcw.dwFlags = GC_TCHAR;
if (!(szChatName = SkypeGet ("CHAT", (char *)wParam, "FRIENDLYNAME")) || !*szChatName)
gcw.ptszName=TranslateT("Unknown"); else {
@@ -413,13 +390,9 @@ int __cdecl ChatInit(WPARAM wParam, LPARAM lParam) {
if (!CallService(MS_GC_NEWSESSION, 0, (LPARAM)&gcw)) {
char *szChatRole;
- gce.cbSize = sizeof(GCEVENT);
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = (TCHAR*)gcw.ptszID;
- gcd.iType = GC_EVENT_ADDGROUP;
- gce.pDest = &gcd;
+ GCDEST gcd = { SKYPE_PROTONAME, gcw.ptszID, GC_EVENT_ADDGROUP };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszStatus = _T("CREATOR");
- gce.dwFlags = GC_TCHAR;
// BUG: Groupchat returns nonzero on success here in earlier versions, so we don't check
// it here
CallService(MS_GC_EVENT, 0, (LPARAM)&gce);
@@ -457,10 +430,9 @@ int __cdecl ChatInit(WPARAM wParam, LPARAM lParam) {
gce.bIsMe = TRUE;
gce.dwFlags |= GCEF_ADDTOLOG;
if (!CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce)) {
- gce.cbSize = sizeof(GCEVENT);
gcd.iType = GC_EVENT_CONTROL;
- gce.pDest = &gcd;
- if (!lParam) CallService(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce);
+ if (!lParam)
+ CallService(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce);
CallService(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce);
CallService(MS_GC_EVENT, lParam ? WINDOW_HIDDEN : WINDOW_VISIBLE, (LPARAM)&gce);
SkypeSend ("GET CHAT %s MEMBERS", (char *)wParam);
@@ -490,14 +462,11 @@ int __cdecl ChatStart(char *szChatId, BOOL bJustCreate) {
}
-void KillChatSession(GCDEST *gcd) {
- GCEVENT gce = {0};
-
+void KillChatSession(GCDEST *gcd)
+{
+ GCEVENT gce = { sizeof(gce), gcd };
EnterCriticalSection(&m_GCMutex);
LOG(("KillChatSession: Groupchatsession terminated."));
- gce.cbSize = sizeof(GCEVENT);
- gce.dwFlags = GC_TCHAR;
- gce.pDest = gcd;
gcd->iType = GC_EVENT_CONTROL;
if (SkypeSend ("ALTER CHAT "STR" LEAVE", gcd->ptszID) == 0)
{
@@ -525,7 +494,7 @@ void InviteUser(const TCHAR *szChatId)
// generate a list of contact
while (hContact) {
- char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact,0 );
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact,0 );
if (szProto && !strcmp(SKYPE_PROTONAME, szProto) &&
!db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) &&
db_get_w(hContact, SKYPE_PROTONAME, "Status", ID_STATUS_OFFLINE)!=ID_STATUS_OFFLINE)
@@ -539,7 +508,7 @@ void InviteUser(const TCHAR *szChatId)
}
if (!alreadyInSession)
AppendMenu(tMenu, MF_STRING, (UINT_PTR)hContact,
- (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR));
+ (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR));
}
hContact = db_find_next(hContact);
}
@@ -566,21 +535,13 @@ static void KickUser (MCONTACT hContact, GCHOOK *gch)
if (SkypeSend ("ALTER CHAT "STR" KICK "STR, gch->pDest->ptszID, gch->ptszUID)!=-1) {
if (ptr=SkypeRcv("ALTER CHAT KICK", 2000)) {
if (strncmp(ptr, "ERROR", 5)) {
- GCDEST gcd = {0};
- GCEVENT gce = {0};
- CONTACTINFO ci = {0};
- DBVARIANT dbv;
-
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = (TCHAR*)gch->pDest->ptszID;
- gcd.iType = GC_EVENT_KICK;
-
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
+ GCDEST gcd = { SKYPE_PROTONAME, gch->pDest->ptszID, GC_EVENT_KICK };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.time = (DWORD)time(NULL);
- gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR;
- gce.ptszUID= gch->ptszUID;
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.ptszUID = gch->ptszUID;
+ CONTACTINFO ci = {0};
ci.cbSize = sizeof(ci);
ci.szProto = SKYPE_PROTONAME;
ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
@@ -588,6 +549,7 @@ static void KickUser (MCONTACT hContact, GCHOOK *gch)
if (hContact && !CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) gce.ptszNick=ci.pszVal;
else gce.ptszNick=gce.ptszUID;
+ DBVARIANT dbv;
if (!db_get_ts(NULL, SKYPE_PROTONAME, "Nick", &dbv)) {
gce.ptszStatus = dbv.ptszVal;
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
@@ -604,20 +566,14 @@ static void KickUser (MCONTACT hContact, GCHOOK *gch)
void SetChatTopic(const TCHAR *szChatId, TCHAR *szTopic, BOOL bSet)
{
- GCDEST gcd = {0};
- GCEVENT gce = {0};
MCONTACT hContact = find_chat (szChatId);
char *szUTFTopic;
- gce.cbSize = sizeof(GCEVENT);
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.ptszID = szChatId;
- gcd.iType = GC_EVENT_TOPIC;
- gce.pDest = &gcd;
+ GCDEST gcd = { SKYPE_PROTONAME, szChatId, GC_EVENT_TOPIC };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszText = szTopic;
- gce.dwFlags = GCEF_ADDTOLOG | GC_TCHAR;
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.time = (DWORD)time (NULL);
- gce.dwFlags = GC_TCHAR;
CallService(MS_GC_EVENT, 0, (LPARAM)&gce);
gcd.iType = GC_EVENT_SETSBTEXT;
@@ -666,7 +622,7 @@ int GCEventHook(WPARAM wParam,LPARAM lParam) {
}
// Delete Chatroom from Contact list, as we don't need it anymore...?
if (hContact = find_chat(gc->szChatName))
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+ CallService(MS_DB_CONTACT_DELETE, hContact, 0);
RemChat(gc->szChatName);
break;
@@ -675,8 +631,6 @@ int GCEventHook(WPARAM wParam,LPARAM lParam) {
if(gch && gch->ptszText && _tcslen(gch->ptszText) > 0) {
DBVARIANT dbv, dbv2;
CCSDATA ccs = {0};
- GCDEST gcd = { 0 };
- GCEVENT gce = { sizeof(gce), &gcd };
TCHAR *pEnd;
// remove the ending linebreak
@@ -708,8 +662,8 @@ int GCEventHook(WPARAM wParam,LPARAM lParam) {
}
// Add our line to the chatlog
- gcd.pszModule = gch->pDest->pszModule;
- gcd.ptszID = gch->pDest->ptszID;
+ GCDEST gcd = { gch->pDest->pszModule, gch->pDest->ptszID, 0 };
+ GCEVENT gce = { sizeof(gce), &gcd };
if ( _tcsncmp(gch->ptszText, _T("/me "), 4)==0 && _tcslen(gch->ptszText)>4) {
gce.ptszText = gch->ptszText+4;
gcd.iType = GC_EVENT_ACTION;
@@ -738,7 +692,7 @@ int GCEventHook(WPARAM wParam,LPARAM lParam) {
break;
case GC_USER_PRIVMESS: {
MCONTACT hContact = find_contactT(gch->ptszUID);
- if (hContact) CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0);
+ if (hContact) CallService(MS_MSG_SENDMESSAGE, hContact, 0);
break;
}
@@ -763,8 +717,8 @@ int GCEventHook(WPARAM wParam,LPARAM lParam) {
MCONTACT hContact = find_contactT(gch->ptszUID);
switch(gch->dwData) {
- case 10:CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0); break;
- case 20:CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)hContact, 0); break;
+ case 10:CallService(MS_USERINFO_SHOWDIALOG, hContact, 0); break;
+ case 20:CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact, 0); break;
case 30: KickUser(hContact, gch); break;
case 110: KillChatSession(gch->pDest); break;
}
@@ -874,11 +828,7 @@ INT_PTR GCOnLeaveChat(WPARAM wParam,LPARAM lParam)
if (db_get_ts(hContact, SKYPE_PROTONAME, "ChatRoomID", &dbv) == 0)
{
- GCDEST gcd = {0};
-
- gcd.pszModule = SKYPE_PROTONAME;
- gcd.iType = GC_EVENT_CONTROL;
- gcd.ptszID = dbv.ptszVal;
+ GCDEST gcd = { SKYPE_PROTONAME, dbv.ptszVal, GC_EVENT_CONTROL };
KillChatSession(&gcd);
db_free(&dbv);
}