From a01e122eb5f84cf7fb2b704ae91556e6f6e4f6ef Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Tue, 18 Nov 2014 18:53:15 +0000 Subject: SkypeClassic -Minor cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@11014 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeClassic/src/alogon.cpp | 9 +- protocols/SkypeClassic/src/contacts.cpp | 84 ++-- protocols/SkypeClassic/src/gchat.cpp | 124 +++--- protocols/SkypeClassic/src/skype.cpp | 583 ++++++++++++---------------- protocols/SkypeClassic/src/skype.h | 4 - protocols/SkypeClassic/src/skypeapi.cpp | 5 +- protocols/SkypeClassic/src/skypeopt.cpp | 45 +-- protocols/SkypeClassic/src/skypeprofile.cpp | 4 +- protocols/SkypeClassic/src/skypeprofile.h | 3 - protocols/SkypeClassic/src/skypesvc.cpp | 18 +- 10 files changed, 355 insertions(+), 524 deletions(-) diff --git a/protocols/SkypeClassic/src/alogon.cpp b/protocols/SkypeClassic/src/alogon.cpp index 8002d495fc..6fc21d2cce 100644 --- a/protocols/SkypeClassic/src/alogon.cpp +++ b/protocols/SkypeClassic/src/alogon.cpp @@ -36,15 +36,12 @@ static HWND findWindow(HWND parent, const TCHAR* childClassName) return wnd; } -static BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) +static BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) { DWORD dwPID; - const TCHAR *lpszClassName; - - GetWindowThreadProcessId(hWnd,&dwPID); if (lParam != 0 && dwPID != (DWORD)lParam) return TRUE; - lpszClassName = getClassName(hWnd); + const TCHAR *lpszClassName = getClassName(hWnd); if(_tcscmp(lpszClassName, _T("tSkMainForm.UnicodeClass")) == 0 || _tcscmp(lpszClassName, _T("TLoginForm.UnicodeClass")) == 0) { @@ -106,7 +103,7 @@ DWORD WINAPI setUserNamePasswordThread(LPVOID lpDummy) return 0; WaitForSingleObject(SkypeReady, 5000); - EnumWindows (EnumWindowsProc, dwPid); + EnumWindows(EnumWindowsProc, dwPid); ReleaseMutex(mutex); CloseHandle(mutex); diff --git a/protocols/SkypeClassic/src/contacts.cpp b/protocols/SkypeClassic/src/contacts.cpp index 3c986d3826..6950d91f54 100644 --- a/protocols/SkypeClassic/src/contacts.cpp +++ b/protocols/SkypeClassic/src/contacts.cpp @@ -8,12 +8,7 @@ #include "pthread.h" #include "gchat.h" -#pragma warning (push) -#pragma warning (disable: 4100) // unreferenced formal parameter #include -#pragma warning (pop) - -#pragma warning (disable: 4706) // assignment within conditional expression // Imported Globals extern HINSTANCE hInst; @@ -21,7 +16,7 @@ extern BOOL bSkypeOut, bIsImoproxy; extern char protocol, g_szProtoName[]; // Handles -static HANDLE hMenuCallItem, hMenuCallHangup, hMenuSkypeOutCallItem, hMenuHoldCallItem, hMenuFileTransferItem, hMenuChatInitItem, hMenuBlockContactItem; +static HGENMENU hMenuCallItem, hMenuCallHangup, hMenuSkypeOutCallItem, hMenuHoldCallItem, hMenuFileTransferItem, hMenuChatInitItem, hMenuBlockContactItem; // Check if alpha blending icons are supported // Seems to be not neccessary @@ -163,13 +158,10 @@ CLISTMENUITEM BlockContactItem(void) { return mi; } -HANDLE add_contextmenu(MCONTACT hContact) { - CLISTMENUITEM mi; - - UNREFERENCED_PARAMETER(hContact); - - mi = CallItem(); +HANDLE add_contextmenu(MCONTACT) { + CLISTMENUITEM mi = CallItem(); hMenuCallItem = Menu_AddContactMenuItem(&mi); + mi = HupItem(); hMenuCallHangup = Menu_AddContactMenuItem(&mi); @@ -215,28 +207,27 @@ HANDLE add_mainmenu(void) { } -int __cdecl PrebuildContactMenu(WPARAM wParam, LPARAM lParam) { - DBVARIANT dbv; - CLISTMENUITEM mi; - char *szProto; - BOOL callAvailable = FALSE; - BOOL hangupAvailable = FALSE; - - UNREFERENCED_PARAMETER(lParam); - - if (!(szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0))) return 0; +int __cdecl PrebuildContactMenu(WPARAM wParam, LPARAM) { + MCONTACT hContact = (MCONTACT) wParam; + char *szProto = GetContactProto(hContact); + if (!szProto) + return 0; // Clear hold-Item in case it exists + CLISTMENUITEM mi; mi = HoldCallItem(); mi.flags |= CMIM_ALL; - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)(HANDLE)hMenuHoldCallItem, (LPARAM)&mi); + Menu_ModifyItem(hMenuHoldCallItem, &mi); + DBVARIANT dbv; + BOOL callAvailable = FALSE; + BOOL hangupAvailable = FALSE; if (!strcmp(szProto, SKYPE_PROTONAME)) { - if (!db_get((MCONTACT)wParam, SKYPE_PROTONAME, "CallId", &dbv)) { - if (db_get_b((MCONTACT)wParam, SKYPE_PROTONAME, "OnHold", 0)) + if (!db_get(hContact, SKYPE_PROTONAME, "CallId", &dbv)) { + if (db_get_b(hContact, SKYPE_PROTONAME, "OnHold", 0)) mi = ResumeCallItem(); else mi = HoldCallItem(); mi.flags = CMIM_ALL; - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)(HANDLE)hMenuHoldCallItem, (LPARAM)&mi); + Menu_ModifyItem(hMenuHoldCallItem, &mi); callAvailable = FALSE; hangupAvailable = TRUE; @@ -245,63 +236,63 @@ int __cdecl PrebuildContactMenu(WPARAM wParam, LPARAM lParam) { } else { callAvailable = TRUE; hangupAvailable = FALSE; } - if (db_get_b((MCONTACT)wParam, SKYPE_PROTONAME, "ChatRoom", 0) != 0) { + if (db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) != 0) { callAvailable = FALSE; hangupAvailable = FALSE; } mi = CallItem(); mi.flags |= CMIM_ALL | (!callAvailable ? CMIF_HIDDEN : 0); - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)(HANDLE)hMenuCallItem, (LPARAM)&mi); + Menu_ModifyItem(hMenuCallItem, &mi); mi = HupItem(); mi.flags |= CMIM_ALL | (!hangupAvailable ? CMIF_HIDDEN : 0); - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)(HANDLE)hMenuCallHangup, (LPARAM)&mi); + Menu_ModifyItem(hMenuCallHangup, &mi); // Clear SkypeOut menu in case it exists mi = SkypeOutCallItem(); mi.flags |= CMIM_ALL; - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)(HANDLE)hMenuSkypeOutCallItem, (LPARAM)&mi); + Menu_ModifyItem(hMenuSkypeOutCallItem, &mi); // File sending and groupchat-creation works starting with protocol version 5 if (protocol >= 5) { mi = FileTransferItem(); - if (db_get_b((MCONTACT)wParam, SKYPE_PROTONAME, "ChatRoom", 0) == 0) + if (db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) == 0) mi.flags ^= CMIF_HIDDEN; mi.flags |= CMIM_FLAGS; - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)(HANDLE)hMenuFileTransferItem, (LPARAM)&mi); + Menu_ModifyItem(hMenuFileTransferItem, &mi); } if (protocol >= 5 || bIsImoproxy) { mi = ChatInitItem(); if (db_get_b(NULL, SKYPE_PROTONAME, "UseGroupchat", 0) && - db_get_b((MCONTACT)wParam, SKYPE_PROTONAME, "ChatRoom", 0) == 0) + db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) == 0) mi.flags ^= CMIF_HIDDEN; mi.flags |= CMIM_FLAGS; - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)(HANDLE)hMenuChatInitItem, (LPARAM)&mi); + Menu_ModifyItem(hMenuChatInitItem, &mi); mi = BlockContactItem(); mi.flags ^= CMIF_HIDDEN; mi.flags |= CMIM_FLAGS | CMIM_NAME; - if (db_get_b((MCONTACT)wParam, SKYPE_PROTONAME, "IsBlocked", 0) == 1) + if (db_get_b(hContact, SKYPE_PROTONAME, "IsBlocked", 0) == 1) mi.ptszName = LPGENT("Unblock contact"); - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)(HANDLE)hMenuBlockContactItem, (LPARAM)&mi); + Menu_ModifyItem(hMenuBlockContactItem, &mi); } } else if (bSkypeOut) { - if (!db_get((MCONTACT)wParam, SKYPE_PROTONAME, "CallId", &dbv)) { + if (!db_get(hContact, SKYPE_PROTONAME, "CallId", &dbv)) { mi = SkypeOutHupItem(); db_free(&dbv); } else { mi = SkypeOutCallItem(); - if (!db_get((MCONTACT)wParam, "UserInfo", "MyPhone0", &dbv)) { + if (!db_get(hContact, "UserInfo", "MyPhone0", &dbv)) { db_free(&dbv); mi.flags = 0; } } mi.flags |= CMIM_ALL; - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)(HANDLE)hMenuSkypeOutCallItem, (LPARAM)&mi); + Menu_ModifyItem(hMenuSkypeOutCallItem, &mi); } return 0; @@ -327,10 +318,9 @@ MCONTACT find_contact(char *name) DBVARIANT dbv; // already on list? - for (MCONTACT hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) + for (MCONTACT hContact = db_find_first(SKYPE_PROTONAME); hContact != NULL; hContact = db_find_next(hContact,SKYPE_PROTONAME)) { - char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0); - if (szProto != NULL && !strcmp(szProto, SKYPE_PROTONAME) && db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) == 0) + if (db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) == 0) { if (db_get_s(hContact, SKYPE_PROTONAME, SKYPE_NAME, &dbv)) continue; tCompareResult = strcmp(dbv.pszVal, name); @@ -348,10 +338,9 @@ MCONTACT find_contactT(TCHAR *name) DBVARIANT dbv; // already on list? - for (MCONTACT hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) + for (MCONTACT hContact = db_find_first(SKYPE_PROTONAME); hContact != NULL; hContact = db_find_next(hContact,SKYPE_PROTONAME)) { - char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0); - if (szProto != NULL && !strcmp(szProto, SKYPE_PROTONAME) && db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) == 0) + if (db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) == 0) { if (db_get_ts(hContact, SKYPE_PROTONAME, SKYPE_NAME, &dbv)) continue; tCompareResult = _tcscmp(dbv.ptszVal, name); @@ -366,10 +355,9 @@ MCONTACT find_contactT(TCHAR *name) MCONTACT add_contact(char *name, DWORD flags) { - MCONTACT hContact; - // already on list? - if (hContact = find_contact(name)) { + MCONTACT hContact = find_contact(name); + if (hContact) { if (!(flags & PALF_TEMPORARY) && db_get_b(hContact, "CList", "NotOnList", 1)) { db_unset(hContact, "CList", "NotOnList"); db_unset(hContact, "CList", "Hidden"); diff --git a/protocols/SkypeClassic/src/gchat.cpp b/protocols/SkypeClassic/src/gchat.cpp index da5615dd5d..5b357768a3 100644 --- a/protocols/SkypeClassic/src/gchat.cpp +++ b/protocols/SkypeClassic/src/gchat.cpp @@ -6,13 +6,10 @@ #include "utf8.h" #include "pthread.h" -#pragma warning (push) -#pragma warning (disable: 4100) // unreferenced formal parameter #include #include #include #include -#pragma warning (pop) #ifndef DWLP_USER #define DWLP_USER DWL_USER @@ -111,16 +108,16 @@ gchat_contact *GetChatContact(gchat_contacts *gc, const TCHAR *who) { */ static int AddChatContact(gchat_contacts *gc, char *who, TCHAR *pszRole) { - int i = -2; - MCONTACT hContact; - CONTACTINFO ci = {0}; - TCHAR *twho; - LOG (("AddChatContact %s", who)); - if (!(twho = make_nonutf_tchar_string((const unsigned char*)who))) + TCHAR *twho = make_nonutf_tchar_string((const unsigned char*)who); + if (!twho) return -2; - if ((i=ExistsChatContact(gc, twho))>=0) return i; - hContact=find_contact(who); + + int i = ExistsChatContact(gc, twho); + if (i >= 0) + return i; + + MCONTACT hContact = find_contact(who); GCDEST gcd = { SKYPE_PROTONAME, gc->szChatName, GC_EVENT_JOIN }; GCEVENT gce = { sizeof(gce), &gcd }; @@ -128,13 +125,16 @@ static int AddChatContact(gchat_contacts *gc, char *who, TCHAR *pszRole) gce.dwFlags = GCEF_ADDTOLOG; gce.ptszStatus = pszRole ? pszRole : _T("USER"); + CONTACTINFO ci = {0}; ci.cbSize = sizeof(ci); ci.szProto = SKYPE_PROTONAME; ci.dwFlag = CNF_DISPLAY | CNF_TCHAR; ci.hContact = hContact; - if (hContact && !CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) gce.ptszNick=ci.pszVal; - else gce.ptszNick=twho; + if (hContact && !CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) + gce.ptszNick=ci.pszVal; + else + gce.ptszNick=twho; gce.ptszUID=twho; if (!CallService(MS_GC_EVENT, 0, (LPARAM)&gce)) { @@ -166,21 +166,15 @@ void RemChatContact(gchat_contacts *gc, const TCHAR *who) { } MCONTACT find_chat(LPCTSTR chatname) { - char *szProto; - int tCompareResult; - MCONTACT hContact; - DBVARIANT dbv; - - for (hContact=db_find_first();hContact != NULL;hContact=db_find_next(hContact)) { - szProto = (char*)CallService( MS_PROTO_GETCONTACTBASEPROTO, hContact, 0 ); - if (szProto!=NULL && !strcmp(szProto, SKYPE_PROTONAME) && - db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0)==1) + for (MCONTACT hContact=db_find_first(SKYPE_PROTONAME);hContact != NULL;hContact=db_find_next(hContact,SKYPE_PROTONAME)) { + if (db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0)==1) { + DBVARIANT dbv; if (db_get_ts(hContact, SKYPE_PROTONAME, "ChatRoomID", &dbv)) continue; - tCompareResult = _tcscmp(dbv.ptszVal, chatname); + int tCompareResult = _tcscmp(dbv.ptszVal, chatname); db_free(&dbv); - if (tCompareResult) continue; - return hContact; // already there, return handle + if (!tCompareResult) + return hContact; // already there, return handle } } return NULL; @@ -188,21 +182,16 @@ MCONTACT find_chat(LPCTSTR chatname) { #ifdef _UNICODE MCONTACT find_chatA(char *chatname) { - char *szProto; - int tCompareResult; - MCONTACT hContact; - DBVARIANT dbv; - - for (hContact=db_find_first();hContact != NULL;hContact=db_find_next(hContact)) { - szProto = (char*)CallService( MS_PROTO_GETCONTACTBASEPROTO, hContact, 0 ); - if (szProto!=NULL && !strcmp(szProto, SKYPE_PROTONAME) && - db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0)==1) + for (MCONTACT hContact=db_find_first(SKYPE_PROTONAME);hContact != NULL;hContact=db_find_next(hContact,SKYPE_PROTONAME)) { + if (db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0)==1) { - if (db_get_s(hContact, SKYPE_PROTONAME, "ChatRoomID", &dbv)) continue; - tCompareResult = strcmp(dbv.pszVal, chatname); - db_free(&dbv); - if (tCompareResult) continue; - return hContact; // already there, return handle + DBVARIANT dbv; + if (!db_get_s(hContact, SKYPE_PROTONAME, "ChatRoomID", &dbv)) { + int tCompareResult = strcmp(dbv.pszVal, chatname); + db_free(&dbv); + if (!tCompareResult) + return hContact; // already there, return handle + } } } return NULL; @@ -484,25 +473,25 @@ void KillChatSession(GCDEST *gcd) void InviteUser(const TCHAR *szChatId) { + if (!szChatId) + return; + + gchat_contacts *gc=GetChat(szChatId); + if (!gc) + return; + + // add the heading HMENU tMenu = CreatePopupMenu(); - MCONTACT hContact = db_find_first(), hInvitedUser; + AppendMenu(tMenu, MF_STRING|MF_GRAYED|MF_DISABLED, 0, TranslateT("&Invite user...")); + AppendMenu(tMenu, MF_SEPARATOR, 1, NULL); + DBVARIANT dbv; - HWND tWindow; POINT pt; - gchat_contacts *gc; int j; - if (!szChatId || !(gc=GetChat(szChatId))) return; - - // add the heading - AppendMenu(tMenu, MF_STRING|MF_GRAYED|MF_DISABLED, (UINT_PTR)0, TranslateT("&Invite user...")); - AppendMenu(tMenu, MF_SEPARATOR, (UINT_PTR)1, NULL); - // generate a list of contact - while (hContact) { - char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact,0 ); - if (szProto && !strcmp(SKYPE_PROTONAME, szProto) && - !db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) && + for (MCONTACT hContact = db_find_first(SKYPE_PROTONAME);hContact;hContact = db_find_next(hContact,SKYPE_PROTONAME)) { + if (!db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) && db_get_w(hContact, SKYPE_PROTONAME, "Status", ID_STATUS_OFFLINE)!=ID_STATUS_OFFLINE) { BOOL alreadyInSession = FALSE; @@ -516,13 +505,13 @@ void InviteUser(const TCHAR *szChatId) AppendMenu(tMenu, MF_STRING, (UINT_PTR)hContact, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR)); } - hContact = db_find_next(hContact); + } - tWindow = CreateWindow(_T("EDIT"),_T(""),0,1,1,1,1,NULL,NULL,hInst,NULL); + HWND tWindow = CreateWindow(_T("EDIT"),_T(""),0,1,1,1,1,NULL,NULL,hInst,NULL); GetCursorPos (&pt); - hInvitedUser = (MCONTACT)TrackPopupMenu(tMenu, TPM_NONOTIFY | TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD, pt.x, pt.y, 0, tWindow, NULL); + MCONTACT hInvitedUser = (MCONTACT)TrackPopupMenu(tMenu, TPM_NONOTIFY | TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD, pt.x, pt.y, 0, tWindow, NULL); DestroyMenu(tMenu); DestroyWindow(tWindow); @@ -535,11 +524,10 @@ void InviteUser(const TCHAR *szChatId) static void KickUser (MCONTACT hContact, GCHOOK *gch) { - char *ptr; - EnterCriticalSection(&m_GCMutex); if (SkypeSend ("ALTER CHAT "STR" KICK "STR, gch->pDest->ptszID, gch->ptszUID)!=-1) { - if (ptr=SkypeRcv("ALTER CHAT KICK", 2000)) { + char *ptr = SkypeRcv("ALTER CHAT KICK", 2000); + if (ptr) { if (strncmp(ptr, "ERROR", 5)) { GCDEST gcd = { SKYPE_PROTONAME, gch->pDest->ptszID, GC_EVENT_KICK }; GCEVENT gce = { sizeof(gce), &gcd }; @@ -603,12 +591,10 @@ void SetChatTopic(const TCHAR *szChatId, TCHAR *szTopic, BOOL bSet) } -int GCEventHook(WPARAM wParam,LPARAM lParam) { +int GCEventHook(WPARAM,LPARAM lParam) { GCHOOK *gch = (GCHOOK*) lParam; gchat_contacts *gc = GetChat(gch->pDest->ptszID); - UNREFERENCED_PARAMETER(wParam); - if(gch) { if (!_stricmp(gch->pDest->pszModule, SKYPE_PROTONAME)) { @@ -739,7 +725,7 @@ int GCEventHook(WPARAM wParam,LPARAM lParam) { return 0; } -int __cdecl GCMenuHook(WPARAM wParam,LPARAM lParam) { +int __cdecl GCMenuHook(WPARAM,LPARAM lParam) { GCMENUITEMS *gcmi= (GCMENUITEMS*) lParam; DBVARIANT dbv; TCHAR* szInvite = TranslateT("&Invite user..."); @@ -765,8 +751,6 @@ int __cdecl GCMenuHook(WPARAM wParam,LPARAM lParam) { {NULL, 30, MENU_ITEM, FALSE} }; - UNREFERENCED_PARAMETER(wParam); - Item_log[0].pszDesc = szInvite; Item_log[1].pszDesc = szTopic; Item_log[2].pszDesc = szLeave; @@ -825,13 +809,11 @@ int __cdecl GCMenuHook(WPARAM wParam,LPARAM lParam) { return 0; } -INT_PTR GCOnLeaveChat(WPARAM wParam,LPARAM lParam) +INT_PTR GCOnLeaveChat(WPARAM wParam,LPARAM) { MCONTACT hContact = (MCONTACT)wParam; DBVARIANT dbv; - UNREFERENCED_PARAMETER(lParam); - if (db_get_ts(hContact, SKYPE_PROTONAME, "ChatRoomID", &dbv) == 0) { GCDEST gcd = { SKYPE_PROTONAME, dbv.ptszVal, GC_EVENT_CONTROL }; @@ -841,13 +823,11 @@ INT_PTR GCOnLeaveChat(WPARAM wParam,LPARAM lParam) return 0; } -INT_PTR GCOnJoinChat(WPARAM wParam,LPARAM lParam) +INT_PTR GCOnJoinChat(WPARAM wParam,LPARAM) { MCONTACT hContact = (MCONTACT)wParam; DBVARIANT dbv; - UNREFERENCED_PARAMETER(lParam); - if (db_get_s(hContact, SKYPE_PROTONAME, "ChatRoomID", &dbv) == 0) { ChatStart (dbv.pszVal, FALSE); @@ -863,10 +843,8 @@ void GCInit(void) void GCExit(void) { - int i; - DeleteCriticalSection (&m_GCMutex); - for (i=0;i= 5) SkypeSend("MINIMIZE"); - if (hContact = GetCallerContact(szSkypeMsg)) { + MCONTACT hContact = GetCallerContact(szSkypeMsg); + if (hContact) { // Make sure that an answering thread is not already in progress so that we don't get // the 'Incoming call' event twice if (!db_get_s(hContact, SKYPE_PROTONAME, "CallId", &dbv)) { @@ -1537,9 +1501,9 @@ void RingThread(char *szSkypeMsg) { if (!strncmp(ptr, "INCOMING", 8)) { if (!hContact) { - char *szHandle; + char *szHandle = GetCallerHandle(szSkypeMsg); - if (szHandle = GetCallerHandle(szSkypeMsg)) { + if (szHandle) { if (!(hContact = add_contact(szHandle, PALF_TEMPORARY))) { free(szHandle); goto l_exitRT; @@ -1552,7 +1516,7 @@ void RingThread(char *szSkypeMsg) { else goto l_exitRT; } } - + dbei.cbSize = sizeof(dbei); dbei.eventType = EVENTTYPE_CALL; dbei.szModule = SKYPE_PROTONAME; @@ -1561,16 +1525,13 @@ void RingThread(char *szSkypeMsg) { dbei.cbBlob = (int)strlen((const char*)dbei.pBlob) + 1; if (!strncmp(ptr, "INCOMING", 8)) { - CLISTEVENT cle = { 0 }; - char toolTip[256]; - + TCHAR *lpzContactName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR); if (PopupServiceExists) { BOOL showPopup, popupWindowColor; unsigned int popupBackColor, popupTextColor; int popupTimeSec; POPUPDATAT InCallPopup; - TCHAR * lpzContactName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR); popupTimeSec = db_get_dw(NULL, SKYPE_PROTONAME, "popupTimeSec", 4); popupTextColor = db_get_dw(NULL, SKYPE_PROTONAME, "popupTextColor", GetSysColor(COLOR_WINDOWTEXT)); @@ -1583,25 +1544,28 @@ void RingThread(char *szSkypeMsg) { InCallPopup.colorBack = !popupWindowColor ? popupBackColor : GetSysColor(COLOR_BTNFACE); InCallPopup.colorText = !popupWindowColor ? popupTextColor : GetSysColor(COLOR_WINDOWTEXT); InCallPopup.iSeconds = popupTimeSec; - InCallPopup.PluginWindowProc = (WNDPROC)InCallPopUpProc; + InCallPopup.PluginWindowProc = InCallPopUpProc; InCallPopup.PluginData = (void *)1; - lstrcpy(InCallPopup.lptzText, TranslateT("Incoming Skype Call")); + lstrcpyn(InCallPopup.lptzText, TranslateT("Incoming Skype Call"), MAX_SECONDLINE); - lstrcpy(InCallPopup.lptzContactName, lpzContactName); + lstrcpyn(InCallPopup.lptzContactName, lpzContactName, MAX_CONTACTNAME); if (showPopup) CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&InCallPopup, 0); } + + CLISTEVENT cle = { 0 }; cle.cbSize = sizeof(cle); cle.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_CALL)); cle.pszService = SKYPE_ANSWERCALL; dbei.flags = DBEF_READ; cle.hContact = hContact; cle.hDbEvent = db_event_add(hContact, &dbei); - _snprintf(toolTip, sizeof(toolTip), Translate("Incoming call from %s"), (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, 0)); - cle.pszTooltip = toolTip; + TCHAR toolTip[256]; + mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Incoming call from %s"), lpzContactName); + cle.ptszTooltip = toolTip; CallServiceSync(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); } else @@ -1676,14 +1640,13 @@ void EndCallThread(char *szSkypeMsg) { } void HoldCallThread(char *szSkypeMsg) { - MCONTACT hContact; - LOG(("HoldCallThread started")); if (!szSkypeMsg) { LOG(("HoldCallThread terminated.")); return; } - if (hContact = GetCallerContact(szSkypeMsg)) { + MCONTACT hContact = GetCallerContact(szSkypeMsg); + if (hContact) { db_set_b(hContact, SKYPE_PROTONAME, "OnHold", 1); } free(szSkypeMsg); @@ -1691,14 +1654,13 @@ void HoldCallThread(char *szSkypeMsg) { } void ResumeCallThread(char *szSkypeMsg) { - MCONTACT hContact; - LOG(("ResumeCallThread started")); if (!szSkypeMsg) { LOG(("ResumeCallThread terminated.")); return; } - if (hContact = GetCallerContact(szSkypeMsg)) { + MCONTACT hContact = GetCallerContact(szSkypeMsg); + if (hContact) { db_unset(hContact, SKYPE_PROTONAME, "OnHold"); } free(szSkypeMsg); @@ -1712,7 +1674,7 @@ int SetUserStatus(void) { return 0; } -void LaunchSkypeAndSetStatusThread(void *newStatus) { +void LaunchSkypeAndSetStatusThread(void *) { /* if (!db_get_b(NULL, SKYPE_PROTONAME, "UnloadOnOffline", 0)) { logoff_contacts(); @@ -1722,8 +1684,6 @@ void LaunchSkypeAndSetStatusThread(void *newStatus) { int oldStatus = SkypeStatus; static BOOL bLaunching = FALSE; - UNREFERENCED_PARAMETER(newStatus); - if (bLaunching) return; bLaunching = TRUE; LOG(("LaunchSkypeAndSetStatusThread started.")); @@ -1911,124 +1871,116 @@ LRESULT APIENTRY WndProc(HWND hWndDlg, UINT message, UINT wParam, LONG lParam) if (nm = strtok_r(NULL, " ", &nextoken)) { db_set_utf(hContact, SKYPE_PROTONAME, "FirstName", nm); - if (!(nm = strtok_r(NULL, "", &nextoken))) db_unset(hContact, SKYPE_PROTONAME, "LastName"); + if (!(nm = strtok_r(NULL, "", &nextoken))) + db_unset(hContact, SKYPE_PROTONAME, "LastName"); else db_set_utf(hContact, SKYPE_PROTONAME, "LastName", nm); } } - else - if (!strcmp(ptr, "BIRTHDAY")) { - unsigned int y, m, d; - if (sscanf(ptr + 9, "%04d%02d%02d", &y, &m, &d) == 3) { - db_set_w(hContact, SKYPE_PROTONAME, "BirthYear", (WORD)y); - db_set_b(hContact, SKYPE_PROTONAME, "BirthMonth", (BYTE)m); - db_set_b(hContact, SKYPE_PROTONAME, "BirthDay", (BYTE)d); - } - else { - db_unset(hContact, SKYPE_PROTONAME, "BirthYear"); - db_unset(hContact, SKYPE_PROTONAME, "BirthMonth"); - db_unset(hContact, SKYPE_PROTONAME, "BirthDay"); - } + else if (!strcmp(ptr, "BIRTHDAY")) { + unsigned int y, m, d; + if (sscanf(ptr + 9, "%04d%02d%02d", &y, &m, &d) == 3) { + db_set_w(hContact, SKYPE_PROTONAME, "BirthYear", (WORD)y); + db_set_b(hContact, SKYPE_PROTONAME, "BirthMonth", (BYTE)m); + db_set_b(hContact, SKYPE_PROTONAME, "BirthDay", (BYTE)d); } - else - if (!strcmp(ptr, "COUNTRY")) { - if (ptr[8]) { - struct CountryListEntry *countries; - int countryCount, i; - - CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&countryCount, (LPARAM)&countries); - for (i = 0; i < countryCount; i++) { - if (countries[i].id == 0 || countries[i].id == 0xFFFF) continue; - if (!_stricmp(countries[i].szName, ptr + 8)) - { - db_set_w(hContact, SKYPE_PROTONAME, "Country", (BYTE)countries[i].id); - break; - } - } + else { + db_unset(hContact, SKYPE_PROTONAME, "BirthYear"); + db_unset(hContact, SKYPE_PROTONAME, "BirthMonth"); + db_unset(hContact, SKYPE_PROTONAME, "BirthDay"); + } + } + else if (!strcmp(ptr, "COUNTRY")) { + if (ptr[8]) { + struct CountryListEntry *countries; + int countryCount; + CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&countryCount, (LPARAM)&countries); + for (int i = 0; i < countryCount; i++) { + if (countries[i].id == 0 || countries[i].id == 0xFFFF) continue; + if (!_stricmp(countries[i].szName, ptr + 8)) + { + db_set_w(hContact, SKYPE_PROTONAME, "Country", (BYTE)countries[i].id); + break; } - else db_unset(hContact, SKYPE_PROTONAME, "Country"); + } + } + else db_unset(hContact, SKYPE_PROTONAME, "Country"); + } + else if (!strcmp(ptr, "SEX")) { + if (ptr[4]) { + BYTE sex = 0; + if (!_stricmp(ptr + 4, "MALE")) sex = 0x4D; + if (!_stricmp(ptr + 4, "FEMALE")) sex = 0x46; + if (sex) db_set_b(hContact, SKYPE_PROTONAME, "Gender", sex); + } + else db_unset(hContact, SKYPE_PROTONAME, "Gender"); + } + else if (!strcmp(ptr, "MOOD_TEXT")) { + LOG(("WndProc MOOD_TEXT")); + db_set_utf(hContact, "CList", "StatusMsg", ptr + 10); + } + else if (!strcmp(ptr, "TIMEZONE")){ + time_t temp; + struct tm tms; + int value = atoi(ptr + 9), tz; + + LOG(("WndProc: TIMEZONE %s", nick)); + + if (value && !db_get_b(NULL, SKYPE_PROTONAME, "IgnoreTimeZones", 0)) { + temp = SkypeTime(NULL); + tms = *localtime(&temp); + //memcpy(&tms,localtime(&temp), sizeof(tm)); + //tms = localtime(&temp) + tz = (value >= 86400) ? (256 - ((2 * (atoi(ptr + 9) - 86400)) / 3600)) : ((-2 * (atoi(ptr + 9) - 86400)) / 3600); + if (tms.tm_isdst == 1 && db_get_b(NULL, SKYPE_PROTONAME, "UseTimeZonePatch", 0)) + { + LOG(("WndProc: Using the TimeZonePatch")); + db_set_b(hContact, "UserInfo", "Timezone", (BYTE)(tz + 2)); } else - if (!strcmp(ptr, "SEX")) { - if (ptr[4]) { - BYTE sex = 0; - if (!_stricmp(ptr + 4, "MALE")) sex = 0x4D; - if (!_stricmp(ptr + 4, "FEMALE")) sex = 0x46; - if (sex) db_set_b(hContact, SKYPE_PROTONAME, "Gender", sex); - } - else db_unset(hContact, SKYPE_PROTONAME, "Gender"); - } + { + LOG(("WndProc: Not using the TimeZonePatch")); + db_set_b(hContact, "UserInfo", "Timezone", (BYTE)(tz + 0)); + } + } + else { + LOG(("WndProc: Deleting the TimeZone in UserInfo Section")); + db_unset(hContact, "UserInfo", "Timezone"); + } + } + else if (!strcmp(ptr, "IS_VIDEO_CAPABLE")){ + if (!_stricmp(ptr + 17, "True")) + db_set_s(hContact, SKYPE_PROTONAME, "MirVer", "Skype 2.0"); + else + db_set_s(hContact, SKYPE_PROTONAME, "MirVer", "Skype"); + } + else if (!strcmp(ptr, "ISBLOCKED")){ + if (!_stricmp(ptr + 10, "True")) + db_set_b(hContact, SKYPE_PROTONAME, "IsBlocked", 1); + else + db_unset(hContact, SKYPE_PROTONAME, "IsBlocked"); + } + else if (!strcmp(ptr, "RICH_MOOD_TEXT")) { + db_set_s(hContact, SKYPE_PROTONAME, "MirVer", "Skype 3.0"); + } + else if (!strcmp(ptr, "DISPLAYNAME")) { + // Skype Bug? -> If nickname isn't customised in the Skype-App, this won't return anything :-( + if (ptr[12]) + db_set_utf(hContact, SKYPE_PROTONAME, "Nick", ptr + 12); + } + else + { + // Other proerties that can be directly assigned to a DB-Value + for (int i = 0; i < sizeof(m_settings) / sizeof(m_settings[0]); i++) { + if (!strcmp(ptr, m_settings[i].SkypeSetting)) { + char *pszProp = ptr + strlen(m_settings[i].SkypeSetting) + 1; + if (*pszProp) + db_set_utf(hContact, SKYPE_PROTONAME, m_settings[i].MirandaSetting, pszProp); else - if (!strcmp(ptr, "MOOD_TEXT")){ - - LOG(("WndProc MOOD_TEXT")); - db_set_utf(hContact, "CList", "StatusMsg", ptr + 10); - } - else - if (!strcmp(ptr, "TIMEZONE")){ - time_t temp; - struct tm tms; - int value = atoi(ptr + 9), tz; - - LOG(("WndProc: TIMEZONE %s", nick)); - - if (value && !db_get_b(NULL, SKYPE_PROTONAME, "IgnoreTimeZones", 0)) { - temp = SkypeTime(NULL); - tms = *localtime(&temp); - //memcpy(&tms,localtime(&temp), sizeof(tm)); - //tms = localtime(&temp) - tz = (value >= 86400) ? (256 - ((2 * (atoi(ptr + 9) - 86400)) / 3600)) : ((-2 * (atoi(ptr + 9) - 86400)) / 3600); - if (tms.tm_isdst == 1 && db_get_b(NULL, SKYPE_PROTONAME, "UseTimeZonePatch", 0)) - { - LOG(("WndProc: Using the TimeZonePatch")); - db_set_b(hContact, "UserInfo", "Timezone", (BYTE)(tz + 2)); - } - else - { - LOG(("WndProc: Not using the TimeZonePatch")); - db_set_b(hContact, "UserInfo", "Timezone", (BYTE)(tz + 0)); - } - } - else { - LOG(("WndProc: Deleting the TimeZone in UserInfo Section")); - db_unset(hContact, "UserInfo", "Timezone"); - } - } else - if (!strcmp(ptr, "IS_VIDEO_CAPABLE")){ - if (!_stricmp(ptr + 17, "True")) - db_set_s(hContact, SKYPE_PROTONAME, "MirVer", "Skype 2.0"); - else - db_set_s(hContact, SKYPE_PROTONAME, "MirVer", "Skype"); - } else - if (!strcmp(ptr, "ISBLOCKED")){ - if (!_stricmp(ptr + 10, "True")) - db_set_b(hContact, SKYPE_PROTONAME, "IsBlocked", 1); - else - db_unset(hContact, SKYPE_PROTONAME, "IsBlocked"); - } else - if (!strcmp(ptr, "RICH_MOOD_TEXT")) { - db_set_s(hContact, SKYPE_PROTONAME, "MirVer", "Skype 3.0"); - } else - if (!strcmp(ptr, "DISPLAYNAME")) { - // Skype Bug? -> If nickname isn't customised in the Skype-App, this won't return anything :-( - if (ptr[12]) - db_set_utf(hContact, SKYPE_PROTONAME, "Nick", ptr + 12); - } - else // Other proerties that can be directly assigned to a DB-Value - { - int i; - char *pszProp; - - for (i = 0; i < sizeof(m_settings) / sizeof(m_settings[0]); i++) { - if (!strcmp(ptr, m_settings[i].SkypeSetting)) { - pszProp = ptr + strlen(m_settings[i].SkypeSetting) + 1; - if (*pszProp) - db_set_utf(hContact, SKYPE_PROTONAME, m_settings[i].MirandaSetting, pszProp); - else - db_unset(hContact, SKYPE_PROTONAME, m_settings[i].MirandaSetting); - } - } - } + db_unset(hContact, SKYPE_PROTONAME, m_settings[i].MirandaSetting); + } + } + } } else { // BUDDYSTATUS: flag = 0; @@ -2289,8 +2241,6 @@ INT_PTR SkypeSetStatus(WPARAM wParam, LPARAM lParam) int oldStatus, iRet; BOOL UseCustomCommand, UnloadOnOffline; - UNREFERENCED_PARAMETER(lParam); - if (MirandaShuttingDown) return 0; LOG(("SkypeSetStatus enter")); UseCustomCommand = db_get_b(NULL, SKYPE_PROTONAME, "UseCustomCommand", 0); @@ -2358,22 +2308,20 @@ void __stdcall SendBroadcast(MCONTACT hContact, int type, int result, HANDLE hPr CallService(MS_PROTO_BROADCASTACK, 0, (LPARAM)&ack); } -static void __cdecl SkypeGetAwayMessageThread(void *hContact) +static void __cdecl SkypeGetAwayMessageThread(void *param) { + MCONTACT hContact = (MCONTACT) param; DBVARIANT dbv; - if (!db_get_ts((MCONTACT)hContact, "CList", "StatusMsg", &dbv)) { - SendBroadcast((MCONTACT)hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal); + if (!db_get_ts(hContact, "CList", "StatusMsg", &dbv)) { + SendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal); db_free(&dbv); } - else SendBroadcast((MCONTACT)hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)0); + else SendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, 0); } -INT_PTR SkypeGetAwayMessage(WPARAM wParam, LPARAM lParam) +INT_PTR SkypeGetAwayMessage(WPARAM, LPARAM lParam) { - CCSDATA* ccs = (CCSDATA*)lParam; - - UNREFERENCED_PARAMETER(wParam); - + CCSDATA *ccs = (CCSDATA*)lParam; pthread_create(SkypeGetAwayMessageThread, (void*)ccs->hContact); return 1; } @@ -2420,11 +2368,9 @@ static int GetFileHash(char* filename) static int _GetFileSize(char* filename) { HANDLE hFile = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); - int size; - if (hFile == INVALID_HANDLE_VALUE) return 0; - size = GetFileSize(hFile, NULL); + int size = GetFileSize(hFile, NULL); CloseHandle(hFile); return size; } @@ -2437,22 +2383,22 @@ static int _GetFileSize(char* filename) void RetrieveUserAvatar(void *param) { MCONTACT hContact = (MCONTACT)param; - HANDLE file; - PROTO_AVATAR_INFORMATION AI = { 0 }; - ACKDATA ack = { 0 }; - DBVARIANT dbv; - char AvatarFile[MAX_PATH + 1], AvatarTmpFile[MAX_PATH + 10], *ptr, *pszTempFile; - if (hContact == NULL) return; + HANDLE file; + DBVARIANT dbv; + char AvatarFile[MAX_PATH + 1], AvatarTmpFile[MAX_PATH + 10], *pszTempFile; + // Mount default ack + ACKDATA ack = { 0 }; ack.cbSize = sizeof(ACKDATA); ack.szModule = SKYPE_PROTONAME; ack.hContact = hContact; ack.type = ACKTYPE_AVATAR; ack.result = ACKRESULT_FAILED; + PROTO_AVATAR_INFORMATION AI = { 0 }; AI.cbSize = sizeof(AI); AI.hContact = hContact; @@ -2474,7 +2420,8 @@ void RetrieveUserAvatar(void *param) if (file != INVALID_HANDLE_VALUE) { CloseHandle(file); - if (ptr = SkypeGet("USER", dbv.pszVal, AvatarTmpFile)) + char *ptr = SkypeGet("USER", dbv.pszVal, AvatarTmpFile); + if (ptr) { if (strncmp(ptr, "ERROR", 5) && GetFileAttributesA(pszTempFile) != INVALID_FILE_ATTRIBUTES) @@ -2524,7 +2471,7 @@ INT_PTR SkypeGetAvatarInfo(WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; - PROTO_AVATAR_INFORMATION* AI = (PROTO_AVATAR_INFORMATION*)lParam; + PROTO_AVATAR_INFORMATION *AI = (PROTO_AVATAR_INFORMATION*)lParam; if (AI->hContact == NULL) // User { if (!db_get_s(NULL, SKYPE_PROTONAME, "AvatarFile", &dbv)) @@ -2538,7 +2485,6 @@ INT_PTR SkypeGetAvatarInfo(WPARAM wParam, LPARAM lParam) } else // Contact { - DBVARIANT dbv; char AvatarFile[MAX_PATH + 1]; if (protocol < 7 && !bIsImoproxy) @@ -2624,18 +2570,12 @@ INT_PTR SkypeGetAvatarCaps(WPARAM wParam, LPARAM lParam) } -INT_PTR SkypeGetStatus(WPARAM wParam, LPARAM lParam) { - UNREFERENCED_PARAMETER(wParam); - UNREFERENCED_PARAMETER(lParam); - +INT_PTR SkypeGetStatus(WPARAM, LPARAM) { return SkypeStatus; } -INT_PTR SkypeGetInfo(WPARAM wParam, LPARAM lParam) { +INT_PTR SkypeGetInfo(WPARAM, LPARAM lParam) { CCSDATA *ccs = (CCSDATA *)lParam; - - UNREFERENCED_PARAMETER(wParam); - pthread_create(GetInfoThread, (void*)ccs->hContact); return 0; } @@ -2649,27 +2589,24 @@ INT_PTR SkypeAddToList(WPARAM wParam, LPARAM lParam) { return (INT_PTR)add_contact(_T2A(psr->nick), (DWORD)wParam); } -INT_PTR SkypeBasicSearch(WPARAM wParam, LPARAM lParam) { - UNREFERENCED_PARAMETER(wParam); - +INT_PTR SkypeBasicSearch(WPARAM, LPARAM lParam) { LOG(("SkypeBasicSearch %s", (char *)lParam)); if (!SkypeInitialized) return 0; return (hSearchThread = pthread_create((pThreadFunc)BasicSearchThread, _strdup((char *)lParam))); } void MessageSendWatchThread(void *a) { - char *str, *err; - msgsendwt_arg *arg = (msgsendwt_arg*)a; LOG(("MessageSendWatchThread started.")); - str = SkypeRcvMsg(arg->szId, SkypeTime(NULL) - 1, arg->hContact, db_get_dw(NULL, "SRMsg", "MessageTimeout", TIMEOUT_MSGSEND)); + char *str = SkypeRcvMsg(arg->szId, SkypeTime(NULL) - 1, arg->hContact, db_get_dw(NULL, "SRMsg", "MessageTimeout", TIMEOUT_MSGSEND)); InterlockedDecrement(&sendwatchers); if (str) { if (!db_get_b(arg->hContact, SKYPE_PROTONAME, "ChatRoom", 0)) { - if (err = GetSkypeErrorMsg(str)) { + char *err = GetSkypeErrorMsg(str); + if (err) { ProtoBroadcastAck(SKYPE_PROTONAME, arg->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)1, (LPARAM)Translate(err)); free(err); free(str); @@ -2685,7 +2622,7 @@ void MessageSendWatchThread(void *a) { free(arg); } -INT_PTR SkypeSendMessage(WPARAM wParam, LPARAM lParam) { +INT_PTR SkypeSendMessage(WPARAM, LPARAM lParam) { CCSDATA *ccs = (CCSDATA *)lParam; DBVARIANT dbv; BOOL sendok = TRUE; @@ -2693,8 +2630,6 @@ INT_PTR SkypeSendMessage(WPARAM wParam, LPARAM lParam) { static DWORD dwMsgNum = 0; BYTE bIsChatroom = 0 != db_get_b(ccs->hContact, SKYPE_PROTONAME, "ChatRoom", 0); - UNREFERENCED_PARAMETER(wParam); - if (bIsChatroom) { if (db_get_s(ccs->hContact, SKYPE_PROTONAME, "ChatRoomID", &dbv)) @@ -2743,14 +2678,12 @@ INT_PTR SkypeSendMessage(WPARAM wParam, LPARAM lParam) { return 0; } -INT_PTR SkypeRecvMessage(WPARAM wParam, LPARAM lParam) +INT_PTR SkypeRecvMessage(WPARAM, LPARAM lParam) { DBEVENTINFO dbei = { 0 }; CCSDATA *ccs = (CCSDATA *)lParam; PROTORECVEVENT *pre = (PROTORECVEVENT *)ccs->lParam; - UNREFERENCED_PARAMETER(wParam); - db_unset(ccs->hContact, "CList", "Hidden"); dbei.cbSize = sizeof(dbei); dbei.szModule = SKYPE_PROTONAME; @@ -2767,11 +2700,10 @@ INT_PTR SkypeRecvMessage(WPARAM wParam, LPARAM lParam) } INT_PTR SkypeUserIsTyping(WPARAM wParam, LPARAM lParam) { + if (protocol < 5 && !bIsImoproxy) return 0; + DBVARIANT dbv = { 0 }; MCONTACT hContact = (MCONTACT)wParam; - char szWhat[128]; - - if (protocol < 5 && !bIsImoproxy) return 0; if (db_get_s(hContact, SKYPE_PROTONAME, "Typing_Stream", &dbv)) { if (db_get_s(hContact, SKYPE_PROTONAME, SKYPE_NAME, &dbv) == 0) { char szCmd[256]; @@ -2787,6 +2719,7 @@ INT_PTR SkypeUserIsTyping(WPARAM wParam, LPARAM lParam) { return 0; } + char szWhat[128]; sprintf(szWhat, "ALTER APPLICATION libpurple_typing DATAGRAM %s", dbv.pszVal); SkypeSend("%s %s", szWhat, (lParam == PROTOTYPE_SELFTYPING_ON ? "PURPLE_TYPING" : "PURPLE_NOT_TYPING")); @@ -2796,29 +2729,23 @@ INT_PTR SkypeUserIsTyping(WPARAM wParam, LPARAM lParam) { } -INT_PTR SkypeSendAuthRequest(WPARAM wParam, LPARAM lParam) { +INT_PTR SkypeSendAuthRequest(WPARAM, LPARAM lParam) { CCSDATA* ccs = (CCSDATA*)lParam; DBVARIANT dbv; - int retval; - - UNREFERENCED_PARAMETER(wParam); - if (!ccs->lParam || db_get_s(ccs->hContact, SKYPE_PROTONAME, SKYPE_NAME, &dbv)) return 1; - retval = SkypeSend("SET USER %s BUDDYSTATUS 2 %s", dbv.pszVal, (char *)ccs->lParam); + int retval = SkypeSend("SET USER %s BUDDYSTATUS 2 %s", dbv.pszVal, (char *)ccs->lParam); db_free(&dbv); if (retval) return 1; else return 0; } -INT_PTR SkypeRecvAuth(WPARAM wParam, LPARAM lParam) { - DBEVENTINFO dbei = { 0 }; - CCSDATA* ccs = (CCSDATA*)lParam; - PROTORECVEVENT* pre = (PROTORECVEVENT*)ccs->lParam; - - UNREFERENCED_PARAMETER(wParam); +INT_PTR SkypeRecvAuth(WPARAM, LPARAM lParam) { + CCSDATA *ccs = (CCSDATA*)lParam; + PROTORECVEVENT *pre = (PROTORECVEVENT*)ccs->lParam; db_unset(ccs->hContact, "CList", "Hidden"); + DBEVENTINFO dbei = { 0 }; dbei.cbSize = sizeof(dbei); dbei.szModule = SKYPE_PROTONAME; dbei.timestamp = pre->timestamp; @@ -2833,10 +2760,9 @@ INT_PTR SkypeRecvAuth(WPARAM wParam, LPARAM lParam) { } char *__skypeauth(WPARAM wParam) { - DBEVENTINFO dbei = { 0 }; - if (!SkypeInitialized) return NULL; + DBEVENTINFO dbei = { 0 }; dbei.cbSize = sizeof(dbei); if (((dbei.cbBlob = db_event_getBlobSize((HANDLE)wParam)) == -1 || !(dbei.pBlob = (unsigned char*)malloc(dbei.cbBlob)))) @@ -2854,12 +2780,9 @@ char *__skypeauth(WPARAM wParam) { return (char *)dbei.pBlob; } -INT_PTR SkypeAuthAllow(WPARAM wParam, LPARAM lParam) { - char *pBlob; - - UNREFERENCED_PARAMETER(lParam); - - if (pBlob = __skypeauth(wParam)) +INT_PTR SkypeAuthAllow(WPARAM wParam, LPARAM) { + char *pBlob = __skypeauth(wParam); + if (pBlob) { int retval = SkypeSend("SET USER %s ISAUTHORIZED TRUE", pBlob + sizeof(DWORD) + sizeof(HANDLE)); free(pBlob); @@ -2868,12 +2791,9 @@ INT_PTR SkypeAuthAllow(WPARAM wParam, LPARAM lParam) { return 1; } -INT_PTR SkypeAuthDeny(WPARAM wParam, LPARAM lParam) { - char *pBlob; - - UNREFERENCED_PARAMETER(lParam); - - if (pBlob = __skypeauth(wParam)) +INT_PTR SkypeAuthDeny(WPARAM wParam, LPARAM) { + char *pBlob = __skypeauth(wParam); + if (pBlob) { int retval = SkypeSend("SET USER %s ISAUTHORIZED FALSE", pBlob + sizeof(DWORD) + sizeof(HANDLE)); free(pBlob); @@ -2883,12 +2803,9 @@ INT_PTR SkypeAuthDeny(WPARAM wParam, LPARAM lParam) { } -INT_PTR SkypeAddToListByEvent(WPARAM wParam, LPARAM lParam) { - char *pBlob; - - UNREFERENCED_PARAMETER(lParam); - - if (pBlob = __skypeauth(wParam)) +INT_PTR SkypeAddToListByEvent(WPARAM wParam, LPARAM) { + char *pBlob = __skypeauth(wParam); + if (pBlob) { MCONTACT hContact = add_contact(pBlob + sizeof(DWORD) + sizeof(HANDLE), LOWORD(wParam)); free(pBlob); @@ -2897,9 +2814,7 @@ INT_PTR SkypeAddToListByEvent(WPARAM wParam, LPARAM lParam) { return 0; } -INT_PTR SkypeRegisterProxy(WPARAM wParam, LPARAM lParam) { - UNREFERENCED_PARAMETER(wParam); - +INT_PTR SkypeRegisterProxy(WPARAM, LPARAM lParam) { if (!lParam) { free(pszProxyCallout); pszProxyCallout = NULL; @@ -2910,28 +2825,22 @@ INT_PTR SkypeRegisterProxy(WPARAM wParam, LPARAM lParam) { } -void CleanupNicknames(char *dummy) { - MCONTACT hContact; - char *szProto; - DBVARIANT dbv, dbv2; - - UNREFERENCED_PARAMETER(dummy); +void CleanupNicknames(char *) { LOG(("CleanupNicknames Cleaning up...")); - for (hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) { - szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0); - if (szProto != NULL && !strcmp(szProto, SKYPE_PROTONAME) && - db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) == 0) + for (MCONTACT hContact = db_find_first(SKYPE_PROTONAME); hContact != NULL; hContact = db_find_next(hContact,SKYPE_PROTONAME)) { + if (db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) == 0) { - if (db_get_s(hContact, SKYPE_PROTONAME, SKYPE_NAME, &dbv)) continue; - if (db_get_s(hContact, SKYPE_PROTONAME, "Nick", &dbv2)) { + DBVARIANT dbv; + if (!db_get_s(hContact, SKYPE_PROTONAME, SKYPE_NAME, &dbv)) { + DBVARIANT dbv2; + if (!db_get_s(hContact, SKYPE_PROTONAME, "Nick", &dbv2)) { + db_unset(hContact, SKYPE_PROTONAME, "Nick"); + GetInfoThread((void*)hContact); + db_free(&dbv2); + } db_free(&dbv); - continue; } - db_unset(hContact, SKYPE_PROTONAME, "Nick"); - GetInfoThread((void*)hContact); - db_free(&dbv); - db_free(&dbv2); } } OUTPUT(_T("Cleanup finished.")); @@ -2960,18 +2869,12 @@ int __stdcall EnterBitmapFileName(char* szDest) return ERROR_SUCCESS; } -int MirandaExit(WPARAM wParam, LPARAM lParam) { - UNREFERENCED_PARAMETER(wParam); - UNREFERENCED_PARAMETER(lParam); - +int MirandaExit(WPARAM, LPARAM) { MirandaShuttingDown = TRUE; return 0; } -int OkToExit(WPARAM wParam, LPARAM lParam) { - UNREFERENCED_PARAMETER(wParam); - UNREFERENCED_PARAMETER(lParam); - +int OkToExit(WPARAM, LPARAM) { // logoff_contacts(); MirandaShuttingDown = TRUE; @@ -3011,12 +2914,11 @@ int EnumOldPluginName(const char *szSetting, LPARAM lParam) // 0 --> No int AnySkypeusers(void) { - MCONTACT hContact; DBVARIANT dbv; int tCompareResult; // already on list? - for (hContact = db_find_first(); + for (MCONTACT hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) { @@ -3082,14 +2984,12 @@ db_set_b(NULL, SKYPE_PROTONAME, "UpgradeDone", (BYTE)1); return; }*/ -void __cdecl MsgPump(char *dummy) +void __cdecl MsgPump(char *) { MSG msg; WNDCLASS WndClass; - UNREFERENCED_PARAMETER(dummy); - // Create window class WndClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; WndClass.lpfnWndProc = (WNDPROC)WndProc; @@ -3142,20 +3042,14 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirVers extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MUUID_SKYPE_CALL, MIID_LAST }; -extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD/* fdwReason*/, LPVOID /*lpvReserved*/) { - UNREFERENCED_PARAMETER(fdwReason); - UNREFERENCED_PARAMETER(lpvReserved); - hInst = hinstDLL; return TRUE; } -int PreShutdown(WPARAM wParam, LPARAM lParam) { - UNREFERENCED_PARAMETER(wParam); - UNREFERENCED_PARAMETER(lParam); - +int PreShutdown(WPARAM, LPARAM) { PostThreadMessage(msgPumpThreadId, WM_QUIT, 0, 0); return 0; } @@ -3165,7 +3059,6 @@ extern "C" int __declspec(dllexport) Load(void) DWORD Buffsize; HKEY MyKey; BOOL SkypeInstalled; - BOOL UseCustomCommand; WSADATA wsaData; mir_getLP(&pluginInfo); @@ -3216,7 +3109,7 @@ extern "C" int __declspec(dllexport) Load(void) // Check if Skype is installed SkypeInstalled = TRUE; - UseCustomCommand = (BYTE)db_get_b(NULL, SKYPE_PROTONAME, "UseCustomCommand", 0); + BOOL UseCustomCommand = (BYTE)db_get_b(NULL, SKYPE_PROTONAME, "UseCustomCommand", 0); UseSockets = (BOOL)db_get_b(NULL, SKYPE_PROTONAME, "UseSkype2Socket", 0); if (!UseSockets && !UseCustomCommand) diff --git a/protocols/SkypeClassic/src/skype.h b/protocols/SkypeClassic/src/skype.h index 7e066ddf1a..b6c929875b 100644 --- a/protocols/SkypeClassic/src/skype.h +++ b/protocols/SkypeClassic/src/skype.h @@ -23,8 +23,6 @@ #include "version.h" #include "util.h" -#pragma warning (push) -#pragma warning (disable: 4100) // unreferenced formal parameter // Miranda Includes #include @@ -46,8 +44,6 @@ #include #include -#pragma warning (pop) - // MyDetails defines // wParam=NULL diff --git a/protocols/SkypeClassic/src/skypeapi.cpp b/protocols/SkypeClassic/src/skypeapi.cpp index 09a5fdb6bc..c85b3831ef 100644 --- a/protocols/SkypeClassic/src/skypeapi.cpp +++ b/protocols/SkypeClassic/src/skypeapi.cpp @@ -13,14 +13,11 @@ #include "alogon.h" #include "msgq.h" #include -#pragma warning (push) -#pragma warning (disable: 4100) // unreferenced formal parameter + #include #include -#pragma warning (push) #include -#pragma warning (disable: 4706) // assignment within conditional expression // Imported Globals extern HWND hSkypeWnd, g_hWnd; diff --git a/protocols/SkypeClassic/src/skypeopt.cpp b/protocols/SkypeClassic/src/skypeopt.cpp index 16b421cdb4..0f2f89a298 100644 --- a/protocols/SkypeClassic/src/skypeopt.cpp +++ b/protocols/SkypeClassic/src/skypeopt.cpp @@ -48,11 +48,9 @@ static HBITMAP hAvatar = NULL; extern BOOL PopupServiceExists; extern BOOL (WINAPI *MyEnableThemeDialogTexture)(HANDLE, DWORD); -int RegisterOptions(WPARAM wParam, LPARAM lParam) { +int RegisterOptions(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp; - UNREFERENCED_PARAMETER(lParam); - ZeroMemory(&odp, sizeof(odp)); odp.cbSize = sizeof(odp); odp.hInstance = hInst; @@ -265,11 +263,9 @@ INT_PTR CALLBACK OptPopupDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar return 0; } -INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM, LPARAM lParam) { static int iInit = TRUE; - - UNREFERENCED_PARAMETER(wParam); switch(msg) { @@ -513,10 +509,8 @@ INT_PTR CALLBACK OptionsAdvancedDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, return 0; } -static int CALLBACK BrowseCallbackProc(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData) +static int CALLBACK BrowseCallbackProc(HWND hWnd, UINT uMsg, LPARAM, LPARAM lpData) { - UNREFERENCED_PARAMETER(lParam); - switch (uMsg) { case BFFM_INITIALIZED: @@ -681,7 +675,6 @@ INT_PTR CALLBACK OptionsDefaultDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L case IDC_BROWSECMDL: { OPENFILENAMEA ofn={0}; - BOOL gofnResult; char szFileName[MAX_PATH]; char szAbsolutePath[MAX_PATH]; @@ -697,7 +690,8 @@ INT_PTR CALLBACK OptionsDefaultDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L TranslateMirandaRelativePathToAbsolute(szFileName, szAbsolutePath, FALSE); strcpy (szFileName, szAbsolutePath); - if (!(gofnResult = GetOpenFileNameA(&ofn)) && CommDlgExtendedError() == FNERR_INVALIDFILENAME){ + BOOL gofnResult = GetOpenFileNameA(&ofn); + if (!gofnResult && CommDlgExtendedError() == FNERR_INVALIDFILENAME){ strcpy(szFileName, ".\\Skype.exe"); TranslateMirandaRelativePathToAbsolute(szFileName, szAbsolutePath, FALSE); strcpy (szFileName, szAbsolutePath); @@ -711,22 +705,21 @@ INT_PTR CALLBACK OptionsDefaultDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L } case IDC_BROWSEDP: { - BROWSEINFOA bi={0}; - LPITEMIDLIST pidl; - char szFileName[MAX_PATH]; - char szAbsolutePath[MAX_PATH]; + char szFileName[MAX_PATH], szAbsolutePath[MAX_PATH]; GetDlgItemTextA (hwndDlg, IDC_DATAPATH, szFileName, MAX_PATH); TranslateMirandaRelativePathToAbsolute(szFileName, szAbsolutePath, FALSE); + BROWSEINFOA bi={0}; bi.hwndOwner = hwndDlg; - bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_SHAREABLE | BIF_NEWDIALOGSTYLE | BIF_NONEWFOLDERBUTTON; - bi.lpfn = BrowseCallbackProc; - bi.lParam = (LPARAM)szAbsolutePath; - - if ( (pidl = SHBrowseForFolderA (&bi)) ) { - if (SHGetPathFromIDListA (pidl, szFileName)) - SetDlgItemTextA (hwndDlg, IDC_DATAPATH, szFileName); + bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_SHAREABLE | BIF_NEWDIALOGSTYLE | BIF_NONEWFOLDERBUTTON; + bi.lpfn = BrowseCallbackProc; + bi.lParam = (LPARAM)szAbsolutePath; + + LPITEMIDLIST pidl = SHBrowseForFolderA(&bi); + if (pidl) { + if (SHGetPathFromIDListA(pidl, szFileName)) + SetDlgItemTextA(hwndDlg, IDC_DATAPATH, szFileName); CoTaskMemFree (pidl); } break; @@ -788,12 +781,10 @@ int OnDetailsInit( WPARAM wParam, LPARAM lParam ) * For setting the skype avatar * */ -INT_PTR CALLBACK AvatarDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK AvatarDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM) { static RECT r; - UNREFERENCED_PARAMETER(lParam); - switch ( msg ) { case WM_INITDIALOG: TranslateDialogDefault( hwndDlg ); @@ -854,12 +845,10 @@ INT_PTR CALLBACK AvatarDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa * For setting the skype infos * */ -INT_PTR CALLBACK DetailsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK DetailsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM) { static int sexM = 0,sexF = 0, sex; - UNREFERENCED_PARAMETER(lParam); - switch ( msg ) { case WM_INITDIALOG: TranslateDialogDefault( hwndDlg ); diff --git a/protocols/SkypeClassic/src/skypeprofile.cpp b/protocols/SkypeClassic/src/skypeprofile.cpp index 168dbfa97c..51faa34b55 100644 --- a/protocols/SkypeClassic/src/skypeprofile.cpp +++ b/protocols/SkypeClassic/src/skypeprofile.cpp @@ -22,12 +22,12 @@ void SkypeProfile_Save(SkypeProfile *pstProf) void SkypeProfile_Load(SkypeProfile *pstProf) { - DBVARIANT dbv; - pstProf->Sex = (BYTE)db_get_b(NULL, SKYPE_PROTONAME, "Gender", 0); pstProf->Birthday.wYear = (WORD)db_get_w(NULL, SKYPE_PROTONAME, "BirthYear", 1900); pstProf->Birthday.wMonth = (WORD)db_get_b(NULL, SKYPE_PROTONAME, "BirthMonth", 01); pstProf->Birthday.wDay = (WORD)db_get_b(NULL, SKYPE_PROTONAME, "BirthDay", 01); + + DBVARIANT dbv; if(!db_get_ts(NULL,SKYPE_PROTONAME,"Nick",&dbv)) { _tcsncpy (pstProf->FullName, dbv.ptszVal, sizeof(pstProf->FullName)/sizeof(TCHAR)); diff --git a/protocols/SkypeClassic/src/skypeprofile.h b/protocols/SkypeClassic/src/skypeprofile.h index 5902f865c3..f53d3c0e44 100644 --- a/protocols/SkypeClassic/src/skypeprofile.h +++ b/protocols/SkypeClassic/src/skypeprofile.h @@ -7,12 +7,9 @@ #include "resource.h" #include "skype.h" -#pragma warning (push) -#pragma warning (disable: 4100) // unreferenced formal parameter // Miranda database access #include #include -#pragma warning (pop) typedef struct { diff --git a/protocols/SkypeClassic/src/skypesvc.cpp b/protocols/SkypeClassic/src/skypesvc.cpp index f8ad3aa44f..b7ed84be4d 100644 --- a/protocols/SkypeClassic/src/skypesvc.cpp +++ b/protocols/SkypeClassic/src/skypesvc.cpp @@ -88,8 +88,8 @@ void HookEvents(void) //HookEvent(ME_CLIST_DOUBLECLICKED, ClistDblClick); HookEvent(ME_OPT_INITIALISE, RegisterOptions); HookEvent(ME_DB_CONTACT_ADDED,HookContactAdded); - HookEvent( ME_DB_CONTACT_DELETED, HookContactDeleted ); - HookEvent( ME_SYSTEM_MODULESLOADED, OnModulesLoaded); + HookEvent(ME_DB_CONTACT_DELETED, HookContactDeleted ); + HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); HookEvent(ME_SYSTEM_OKTOEXIT, MirandaExit); HookEvent(ME_SYSTEM_PRESHUTDOWN, OkToExit); } @@ -98,15 +98,13 @@ void HookEventsLoaded(void) { // We cannot check for the TTB-service before this event gets fired... :-/ HookEvent(ME_TTB_MODULELOADED, CreateTopToolbarButton); - HookEvent( ME_USERINFO_INITIALISE, OnDetailsInit ); + HookEvent(ME_USERINFO_INITIALISE, OnDetailsInit ); } -INT_PTR SkypeGetCaps(WPARAM wParam, LPARAM lParam) +INT_PTR SkypeGetCaps(WPARAM wParam, LPARAM) { int ret = 0; - UNREFERENCED_PARAMETER(lParam); - switch (wParam) { case PFLAGNUM_1: ret = PF1_BASICSEARCH | PF1_IM | PF1_MODEMSG | PF1_SEARCHBYEMAIL; // | PF1_AUTHREQ; @@ -155,17 +153,15 @@ INT_PTR SkypeGetName(WPARAM wParam, LPARAM lParam) } -INT_PTR SkypeLoadIcon(WPARAM wParam,LPARAM lParam) +INT_PTR SkypeLoadIcon(WPARAM wParam,LPARAM) { UINT id; - UNREFERENCED_PARAMETER(lParam); - switch(wParam&0xFFFF) { case PLI_PROTOCOL: id=IDI_SKYPE; break; // IDI_MAIN is the main icon for the protocol - default: return (int)(HICON)NULL; + default: return 0; } - return (int)LoadImage(hInst,MAKEINTRESOURCE(id),IMAGE_ICON,GetSystemMetrics(wParam&PLIF_SMALL?SM_CXSMICON:SM_CXICON),GetSystemMetrics(wParam&PLIF_SMALL?SM_CYSMICON:SM_CYICON),0); + return (INT_PTR)LoadImage(hInst,MAKEINTRESOURCE(id),IMAGE_ICON,GetSystemMetrics(wParam&PLIF_SMALL?SM_CXSMICON:SM_CXICON),GetSystemMetrics(wParam&PLIF_SMALL?SM_CYSMICON:SM_CYICON),0); } INT_PTR SkypeGetAvatar(WPARAM wParam,LPARAM lParam) -- cgit v1.2.3