static int IcqOpenFile(WPARAM wParam, LPARAM lParam) { TCHAR *pszFile = (TCHAR*)lParam; /* TCHAR is specified on AssocMgr_AddNewFileTypeT() */ FILE *fp; ICQFILEINFO info; char line[4096], *sep; UNREFERENCED_PARAMETER(wParam); /* send message: [ICQ Message User] UIN=1234567 add user: (all the .uin files I've seen only have UIN= in them) [ICQ User] UIN=1234567 Email= NickName= FirstName= LastName= */ if (pszFile == NULL) return 1; /* sanity check */ fp = _tfopen(pszFile, _T("rt")); if (fp == NULL) return 1; /* open failed */ info.type = 0; while (!feof(fp)) { if (fgets(line, sizeof(line), fp) == NULL) break; TrimString(line); if (IsEmpty(line)) continue; if (line[0] == '[') { memset(&info, 0, sizeof(info)); if (!mir_strcmpi(line, "[ICQ Message User]")) info.type = ICQFILE_MESSAGEUSER; else if (!mir_strcmpi(line, "[ICQ User]")) info.type = ICQFILE_ADDUSER; continue; } if (info.type == 0) continue; sep = strchr(line, '='); if (sep == NULL) { info.type = 0; break; } /* format error */ *(sep++) = '\0'; if (!mir_strcmp("UIN", line)) mir_strncpy(info.uin, sep, sizeof(info.uin)); /* buffer safe */ else if (!mir_strcmp("Email", line)) mir_strncpy(info.email, sep, sizeof(info.email)); /* buffer safe */ else if (!mir_strcmp("NickName", line)) mir_strncpy(info.nick, sep, sizeof(info.nick)); /* buffer safe */ else if (!mir_strcmp("FirstName", line)) mir_strncpy(info.firstName, sep, sizeof(info.firstName)); /* buffer safe */ else if (!mir_strcmp("LastName", line)) mir_strncpy(info.lastName, sep, sizeof(info.lastName)); /* buffer safe */ } fclose(fp); switch (info.type) { case ICQFILE_MESSAGEUSER: MessageIcqUser(&info); return 0; case ICQFILE_ADDUSER: AddIcqUser(&info); return 0; default: return 1; /* open failed */ } }
static MenuProto* FindProtocolMenu(const char *proto) { for (int i = 0; i < cli.menuProtoCount; i++) if (cli.menuProtos[i].pMenu && !mir_strcmpi(cli.menuProtos[i].szProto, proto)) return &cli.menuProtos[i]; if (cli.menuProtoCount == 1) if (!mir_strcmpi(cli.menuProtos[0].szProto, proto)) return &cli.menuProtos[0]; return NULL; }
static int pd__index(lua_State *L) { PROTOCOLDESCRIPTOR *pd = *(PROTOCOLDESCRIPTOR**)luaL_checkudata(L, 1, MT_PROTOCOLDESCRIPTOR); const char *key = lua_tostring(L, 2); if (mir_strcmpi(key, "Name") == 0) lua_pushstring(L, ptrA(mir_utf8encode(pd->szName))); else if (mir_strcmpi(key, "Type") == 0) lua_pushinteger(L, pd->type); else lua_pushnil(L); return 1; }
SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent) { SESSION_INFO* pResult = NULL; if (prevSession == NULL && my_strstri(currSession->ptszName, pszOriginal) == currSession->ptszName) pResult = currSession; else { TCHAR* pszName = NULL; SESSION_INFO* pTemp = pci->wndList; if (currSession == prevSession) pszCurrent = pszOriginal; while (pTemp != NULL) { if (pTemp != currSession && !mir_strcmpi(pszModule, pTemp->pszModule)) { if (my_strstri(pTemp->ptszName, pszOriginal) == pTemp->ptszName) { if (prevSession != pTemp && mir_tstrcmpi(pTemp->ptszName, pszCurrent) > 0 && (!pszName || mir_tstrcmpi(pTemp->ptszName, pszName) < 0)) { pResult = pTemp; pszName = pTemp->ptszName; } } } pTemp = pTemp->next; } } return pResult; }
INT_PTR PluginCommand_GetMyAvatar(WPARAM wParam, LPARAM lParam) { TCHAR *ret = (TCHAR *)lParam; char *proto = (char *)wParam; if (ret == NULL) return -1; if (proto == NULL) { mir_tstrncpy(ret, protocols->default_avatar_file, MS_MYDETAILS_GETMYAVATAR_BUFFER_SIZE); return 0; } for (int i = 0; i < protocols->GetSize(); i++) { if (mir_strcmpi(protocols->Get(i)->name, proto) == 0) { if (!protocols->Get(i)->CanGetAvatar()) return -2; protocols->Get(i)->GetAvatar(); if (mir_tstrlen(protocols->Get(i)->avatar_file)) mir_tstrncpy(ret, protocols->Get(i)->avatar_file, MS_MYDETAILS_GETMYAVATAR_BUFFER_SIZE); else ret[0] = '\0'; return 0; } } return -1; }
INT_PTR PluginCommand_SetMyAvatarUI(WPARAM, LPARAM lParam) { char *proto = (char *)lParam; int proto_num = -1; if (proto != NULL) { int i; for (i = 0; i < protocols->GetSize(); i++) { if (mir_strcmpi(protocols->Get(i)->name, proto) == 0) { proto_num = i; break; } } if (proto_num == -1) return -1; if (!protocols->Get(i)->CanSetAvatar()) return -2; } if (proto_num == -1) protocols->SetAvatars(NULL); else protocols->Get(proto_num)->SetAvatar(NULL); return 0; }
CToxProto* CToxProto::GetContactAccount(MCONTACT hContact) { for (int i = 0; i < Accounts.getCount(); i++) if (mir_strcmpi(GetContactProto(hContact), Accounts[i]->m_szModuleName) == 0) return Accounts[i]; return NULL; }
int __cdecl CIrcProto::OnInitUserInfo(WPARAM wParam, LPARAM lParam) { MCONTACT hContact = lParam; char *szProto = GetContactProto(hContact); if (!hContact || !szProto || mir_strcmpi(szProto, m_szModuleName)) return 0; if (isChatRoom(hContact)) return 0; if (getByte(hContact, "DCC", 0) != 0) return 0; DBVARIANT dbv; if (!getTString(hContact, "Default", &dbv)) { if (IsChannel(dbv.ptszVal)) { db_free(&dbv); return 0; } db_free(&dbv); } OPTIONSDIALOGPAGE odp = { sizeof(odp) }; odp.flags = ODPF_DONTTRANSLATE; odp.pszTitle = m_szModuleName; odp.hIcon = NULL; odp.dwInitParam = (LPARAM)this; odp.hInstance = hInst; odp.position = -1900000000; odp.pfnDlgProc = UserDetailsDlgProc; odp.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO); odp.pszTitle = m_szModuleName; UserInfo_AddPage(wParam, &odp); return 0; }
static void _ExtFrames_GetFrameDBOption(EXTFRAMEWND * pExtFrm) { // Each known frame order per 1 000 000 // Each Unknown frame but absent during saving per 10 000 // Each new unknown per 100 static DWORD NextUnknownOrder=100; char szKey[100]={0}; DWORD dwOrderInDB; if (!mir_strcmpi(pExtFrm->efrm.szFrameNameID,"My Contacts")) dwOrderInDB=0xFFFFFFFF; else { _snprintf(szKey,sizeof(szKey), EXTFRAMEORDERDBPREFIX "%s",pExtFrm->efrm.szFrameNameID); dwOrderInDB=DBGetContactSettingDword(NULL,EXTFRAMEMODULE,szKey,0); if (!dwOrderInDB) { dwOrderInDB=NextUnknownOrder; NextUnknownOrder+=100; } else NextUnknownOrder = dwOrderInDB + 100; } pExtFrm->efrm.dwOrder=dwOrderInDB; }
/** * name: AddDummyItem * class: CPsTree * desc: insert an empty tree item group * param: pszGroup - utf8 encoded string of the item to add * return: index of the new item or -1 if failed to add **/ int CPsTree::AddDummyItem(LPCSTR pszGroup) { if (mir_strcmpi(pszGroup, TREE_ROOTITEM)) { CPsHdr psh; psh._hContact = _pPs->hContact; psh._pszProto = _pPs->pszProto; psh._hImages = _hImages; psh._pPages = _pItems; psh._numPages = _numItems; OPTIONSDIALOGPAGE odp = { sizeof(odp) }; odp.hInstance = ghInst; odp.flags = ODPF_TCHAR; odp.ptszTitle = mir_utf8decodeT(pszGroup); INT_PTR rc = UserInfo_AddPage((WPARAM)&psh, &odp); mir_free(odp.ptszTitle); if (!rc) { _pItems = psh._pPages; _numItems = psh._numPages; return _numItems - 1; } } return -1; }
HANDLE CSkypeProto::GetIconHandle(const char *name) { for (size_t i = 0; i < _countof(Icons); i++) if (mir_strcmpi(Icons[i].Name, name) == 0) return Icons[i].Handle; return 0; }
static int ccs__index(lua_State *L) { CCSDATA *ccs = *(CCSDATA**)luaL_checkudata(L, 1, MT_CCSDATA); const char *key = lua_tostring(L, 2); if (mir_strcmpi(key, "hContact") == 0) lua_pushinteger(L, ccs->hContact); else if (mir_strcmpi(key, "Message") == 0) { PROTORECVEVENT *pre = (PROTORECVEVENT*)ccs->lParam; lua_pushstring(L, pre->szMessage); } else lua_pushnil(L); return 1; }
static INT_PTR GetCountryByISOCode(WPARAM wParam, LPARAM) { for (int i = 0; i < SIZEOF(countries); i++) if ( mir_strcmpi((char*)wParam, countries[i].ISOcode) == 0) return (INT_PTR)countries[i].szName; return NULL; }
BOOL GetSettingBool(const char *section, const char *key, BOOL defaultValue) { char tmp[16]; if (GetPrivateProfileStringA(section, key, defaultValue ? "true" : "false", tmp, sizeof(tmp), gIniFile) == 0) return defaultValue; return mir_strcmpi(tmp, "true") == 0; }
HANDLE GetIconHandleByName(const char *name) { for (size_t i = 0; i < _countof(iconList); i++) if (mir_strcmpi(iconList[i].szName, name) == 0) return iconList[i].hIcolib; return NULL; }
int GetProtoIndex(char * szName) { if (szName) for (auto &pa : Accounts()) if (!mir_strcmpi(szName, pa->szModuleName)) return pa->iOrder; return -1; }
int CDropbox::OnContactDeleted(WPARAM hContact, LPARAM) { if (mir_strcmpi(GetContactProto(hContact), MODULE) == 0) { if (HasAccessToken()) DestroyAccessToken(); hDefaultContact = NULL; } return 0; }
MCONTACT CSkypeProto::FindContact(const char *skypename) { MCONTACT hContact = NULL; for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { ptrA cSkypename(getStringA(hContact, SKYPE_SETTINGS_ID)); if (!mir_strcmpi(skypename, cSkypename)) break; } return hContact; }
INT_PTR PluginCommand_SetMyStatusMessageUI(WPARAM wParam, LPARAM lParam) { int status = (int)wParam; char *proto_name = (char *)lParam; int proto_num = -1; Protocol *proto = NULL; if (status != 0 && (status < ID_STATUS_OFFLINE || status > ID_STATUS_OUTTOLUNCH)) return -10; if (proto_name != NULL) { for (int i = 0; i < protocols->GetSize(); i++) { proto = protocols->Get(i); if (mir_strcmpi(proto->name, proto_name) == 0) { proto_num = i; break; } } if (proto_num == -1) return -1; if (protocols->CanSetStatusMsgPerProtocol() && !proto->CanSetStatusMsg()) return -2; } else if (ServiceExists(MS_SIMPLESTATUSMSG_CHANGESTATUSMSG)) { if (status != 0) CallService(MS_SIMPLESTATUSMSG_CHANGESTATUSMSG, status, (LPARAM)proto_name); else if (proto != 0) CallService(MS_SIMPLESTATUSMSG_CHANGESTATUSMSG, proto->status, (LPARAM)proto_name); else CallService(MS_SIMPLESTATUSMSG_CHANGESTATUSMSG, protocols->GetGlobalStatus(), NULL); return 0; } // fallthrough if (proto == NULL || proto->status != ID_STATUS_OFFLINE) { if (!status_msg_dialog_open) { InterlockedExchange(&status_msg_dialog_open, 1); hwndSetStatusMsg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SETSTATUSMESSAGE), NULL, DlgProcSetStatusMessage); SendMessage(hwndSetStatusMsg, WMU_SETDATA, status, proto_num); } SetForegroundWindow(hwndSetStatusMsg); SetFocus(hwndSetStatusMsg); ShowWindow(hwndSetStatusMsg, SW_SHOW); return 0; } return -3; }
static int dbcw__index(lua_State *L) { DBCONTACTWRITESETTING *dbcw = (DBCONTACTWRITESETTING*)luaL_checkudata(L, 1, MT_DBCONTACTWRITESETTING); const char *key = luaL_checkstring(L, 2); if (mir_strcmpi(key, "Module") == 0) lua_pushstring(L, dbcw->szModule); else if (mir_strcmpi(key, "Setting") == 0) lua_pushstring(L, dbcw->szSetting); else if (mir_strcmpi(key, "Value") == 0) { switch (dbcw->value.type) { case DBVT_BYTE: lua_pushinteger(L, dbcw->value.bVal); break; case DBVT_WORD: lua_pushinteger(L, dbcw->value.wVal); break; case DBVT_DWORD: lua_pushnumber(L, dbcw->value.dVal); break; case DBVT_ASCIIZ: lua_pushstring(L, ptrA(mir_utf8encode(dbcw->value.pszVal))); break; case DBVT_UTF8: lua_pushstring(L, dbcw->value.pszVal); break; case DBVT_WCHAR: lua_pushstring(L, ptrA(mir_utf8encodeW(dbcw->value.pwszVal))); break; default: lua_pushnil(L); } } else lua_pushnil(L); return 1; }
static int dbei__index(lua_State *L) { DBEVENTINFO *dbei = (DBEVENTINFO*)luaL_checkudata(L, 1, MT_DBEVENTINFO); const char *key = luaL_checkstring(L, 2); if (mir_strcmpi(key, "Module") == 0) lua_pushstring(L, ptrA(mir_utf8encode(dbei->szModule))); else if (mir_strcmpi(key, "Timestamp") == 0) lua_pushnumber(L, dbei->timestamp); else if (mir_strcmpi(key, "Type") == 0) lua_pushinteger(L, dbei->eventType); else if (mir_strcmpi(key, "Flags") == 0) lua_pushinteger(L, dbei->flags); else if (mir_strcmpi(key, "Length") == 0) lua_pushnumber(L, dbei->cbBlob); else if (mir_strcmpi(key, "Blob") == 0) { lua_newtable(L); for (DWORD i = 0; i < dbei->cbBlob; i++) { lua_pushinteger(L, i + 1); lua_pushinteger(L, dbei->pBlob[i]); lua_settable(L, -3); } } else lua_pushnil(L); return 1; }
void CToxProto::ChatValidateContact(HWND hwndList, const std::vector<MCONTACT> &contacts, MCONTACT hContact) { bool isProtoContact = mir_strcmpi(GetContactProto(hContact), m_szModuleName) == 0; if (isProtoContact && !isChatRoom(hContact)) { if (std::find(contacts.begin(), contacts.end(), hContact) != contacts.end()) { SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hContact, 0); } return; } SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hContact, 0); }
MCONTACT CSkypeProto::FindChatRoom(const char *chatname) { MCONTACT hContact = NULL; for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if (!isChatRoom(hContact)) continue; ptrA cChatname(getStringA(hContact, "ChatRoomID")); if (!mir_strcmpi(chatname, cChatname)) break; } return hContact; }
void CSkypeOptionsMain::OnApply() { ptrA szNewSkypename(m_skypename.GetTextA()), szOldSkypename(m_proto->getStringA(SKYPE_SETTINGS_ID)); pass_ptrA szNewPassword(m_password.GetTextA()), szOldPassword(m_proto->getStringA("Password")); if (mir_strcmpi(szNewSkypename, szOldSkypename) || mir_strcmp(szNewPassword, szOldPassword)) m_proto->delSetting("TokenExpiresIn"); m_proto->setString(SKYPE_SETTINGS_ID, szNewSkypename); m_proto->setString("Password", szNewPassword); ptrT group(m_group.GetText()); if (mir_tstrlen(group) > 0 && !Clist_GroupExists(group)) Clist_CreateGroup(0, group); }
int GetProtoIndex(char * szName) { if (szName) { PROTOACCOUNT **accs = NULL; int accCount = 0; Proto_EnumAccounts(&accCount, &accs); for (int i = 0; i < accCount; i++) if (!mir_strcmpi(szName, accs[i]->szModuleName)) return accs[i]->iOrder; } return -1; }
//************************************************************************ // initializes the group objects //************************************************************************ void CContactList::InitializeGroupObjects() { UninitializeGroupObjects(); int res = 0; CContactListGroup *pGroup = NULL; HANDLE hMetaContact = NULL; char *szProto = NULL; for(MCONTACT hContact = db_find_first();hContact != NULL;hContact = db_find_next(hContact)) { tstring strGroup = GetContactGroupPath(hContact); szProto = GetContactProto(hContact); if(szProto && db_get_b(NULL,META_PROTO,"Enabled",1) && !mir_strcmpi(szProto,META_PROTO)) { tstring strName = CAppletManager::GetContactDisplayname(hContact); tstring strPath = _T(""); if(CConfig::GetBoolSetting(CLIST_USEGROUPS)) strPath += strGroup; strPath += (strPath.empty()?_T(""):_T("\\")) + strName; pGroup = CreateGroupObjectByPath(strPath); pGroup->hMetaContact = hContact; if(!strGroup.empty()) ChangeGroupObjectCounters(strGroup,1); } // If the contact has no group, continue else if(!strGroup.empty() && CConfig::GetBoolSetting(CLIST_USEGROUPS)) { pGroup = GetGroupObjectByPath(strGroup); // create the group if(!pGroup) pGroup = CreateGroupObjectByPath(strGroup); // update it's counters if(!db_mc_isSub(hContact)) ChangeGroupObjectCounters(strGroup,1); } } }
void HookOnImport(HMODULE hModule, char *lpszImpModName, PVOID lpOrigFunc, PVOID lpNewFunc) { ULONG ulSize; PIMAGE_IMPORT_DESCRIPTOR pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR) ImageDirectoryEntryToData(hModule, TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &ulSize); if (pImportDesc == NULL) return; for (; pImportDesc->Name; pImportDesc++) { char *pszModName = (char *)((PBYTE)hModule + pImportDesc->Name); if (mir_strcmpi(lpszImpModName, pszModName) != 0) continue; PIMAGE_THUNK_DATA pThunk = (PIMAGE_THUNK_DATA)((PBYTE)hModule + pImportDesc->FirstThunk); for (; pThunk->u1.Function; pThunk++) { PVOID* ppfn = (PVOID*)&pThunk->u1.Function; if (*ppfn != lpOrigFunc) continue; DWORD oldProtect; g_mod++; if (!VirtualProtect((LPVOID)ppfn, sizeof(void*), PAGE_EXECUTE_READWRITE, &oldProtect)) { if (!g_HookError) { TCHAR buf[200]; g_HookError = TRUE; mir_sntprintf(buf, SIZEOF(buf), TranslateT("VirtualProtect failed. Code %d\nTry to call the author"), GetLastError()); prevMessageBox(0, buf, TranslateT("Error"), MB_OK); } } *(PVOID*)ppfn = lpNewFunc; if (*(PVOID*)ppfn != lpNewFunc) { if (!g_HookError2) { g_HookError2 = TRUE; prevMessageBox(0, TranslateT("Hmm. Something goes wrong. I can't write into the memory.\nAnd as you can see, there are no any exception raised...\nTry to call the author"), TranslateT("Error"), MB_OK); } } } } }
int WhatsAppProto::OnChatMenu(WPARAM wParam, LPARAM lParam) { GCMENUITEMS *gcmi = (GCMENUITEMS*)lParam; if (gcmi == NULL) return 0; if (mir_strcmpi(gcmi->pszModule, m_szModuleName)) return 0; if (gcmi->Type == MENU_ON_LOG) { gcmi->nItems = _countof(sttLogListItems); gcmi->Item = sttLogListItems; } else if (gcmi->Type == MENU_ON_NICKLIST) { gcmi->nItems = _countof(sttNickListItems); gcmi->Item = sttNickListItems; } return 0; }
SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent) { if (prevSession == NULL && my_strstri(currSession->ptszName, pszOriginal) == currSession->ptszName) return currSession; TCHAR* pszName = NULL; if (currSession == prevSession) pszCurrent = pszOriginal; SESSION_INFO *pResult = NULL; for (SESSION_INFO *si = pci->wndList; si; si = si->next) if (si != currSession && !mir_strcmpi(pszModule, si->pszModule)) if (my_strstri(si->ptszName, pszOriginal) == si->ptszName) if (prevSession != si && mir_tstrcmpi(si->ptszName, pszCurrent) > 0 && (!pszName || mir_tstrcmpi(si->ptszName, pszName) < 0)) { pResult = si; pszName = si->ptszName; } return pResult; }
INT_PTR PluginCommand_SetMyAvatar(WPARAM wParam, LPARAM lParam) { char *proto = (char *)wParam; if (proto != NULL) { for (int i = 0; i < protocols->GetSize(); i++) { if (mir_strcmpi(protocols->Get(i)->name, proto) == 0) { if (!protocols->Get(i)->CanSetAvatar()) return -2; protocols->Get(i)->SetAvatar((TCHAR *)lParam); return 0; } } return -1; } protocols->SetAvatars((TCHAR *)lParam); return 0; }