void CSItemsList::loadItems(char *protoName) { char dbSetting[32]; mir_snprintf(dbSetting, "%s_ItemsCount", protoName); unsigned int itemsCount = getWord(dbSetting, DEFAULT_ITEMS_COUNT); for (unsigned int i = 1; i <= itemsCount; i++) { StatusItem* item = new StatusItem(); DBVARIANT dbv; mir_snprintf(dbSetting, "%s_Item%dIcon", protoName, i); item->m_iIcon = getByte(dbSetting, DEFAULT_ITEM_ICON); mir_snprintf(dbSetting, "%s_Item%dTitle", protoName, i); if (!getWString(dbSetting, &dbv)) { mir_wstrcpy(item->m_tszTitle, dbv.ptszVal); db_free(&dbv); } else item->m_tszTitle[0] = 0; mir_snprintf(dbSetting, "%s_Item%dMessage", protoName, i); if (!getWString(dbSetting, &dbv)) { mir_wstrcpy(item->m_tszMessage, dbv.ptszVal); db_free(&dbv); } else item->m_tszMessage[0] = 0; mir_snprintf(dbSetting, "%s_Item%dFavourite", protoName, i); item->m_bFavourite = (BOOL)getByte(dbSetting, DEFAULT_ITEM_IS_FAVOURITE); m_list->add(item); } }
LPTSTR ChangeTextLayout(LPCTSTR ptszInText, HKL hklCurLay, HKL hklToLay, BOOL TwoWay) { LPTSTR ptszOutText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t)); mir_wstrcpy(ptszOutText, ptszInText); if (hklCurLay == nullptr || hklToLay == nullptr) return ptszOutText; LPTSTR ptszKeybCur = GetLayoutString(hklCurLay); LPTSTR ptszKeybNext = GetLayoutString(hklToLay); if (ptszKeybCur == nullptr || ptszKeybNext == nullptr) return ptszOutText; for (DWORD i = 0; i < mir_wstrlen(ptszInText); i++) { BOOL Found = FALSE; for (DWORD j = 0; j < mir_wstrlen(ptszKeybCur) && !Found; j++) if (ptszKeybCur[j] == ptszInText[i]) { Found = TRUE; if (mir_wstrlen(ptszKeybNext) >= j) ptszOutText[i] = ptszKeybNext[j]; } if (TwoWay && !Found) for (DWORD j = 0; j < mir_wstrlen(ptszKeybNext) && !Found; j++) if (ptszKeybNext[j] == ptszInText[i]) { Found = TRUE; if (mir_wstrlen(ptszKeybCur) >= j) ptszOutText[i] = ptszKeybCur[j]; } } return ptszOutText; }
void CSAMWindow::checkItemValidity() { COMBOBOXEXITEM cbi = { 0 }; cbi.mask = CBEIF_IMAGE; cbi.iItem = SendDlgItemMessage(m_handle, IDC_COMBO, CB_GETCURSEL, 0, 0); SendDlgItemMessage(m_handle, IDC_COMBO, CBEM_GETITEM, 0, (LPARAM)&cbi); if (m_item->m_iIcon != cbi.iImage) m_item->m_iIcon = cbi.iImage, m_bChanged = TRUE; wchar_t tszInputMessage[EXTRASTATUS_MESSAGE_LIMIT]; GetDlgItemText(m_handle, IDC_MESSAGE, tszInputMessage, _countof(tszInputMessage)); PROTOACCOUNT *pdescr = Proto_GetAccount(m_parent->m_protoName); if (pdescr == nullptr) return; WPARAM i = SendMessage(m_hCombo, CB_GETCURSEL, 0, 0) + 1; wchar_t tszTitle[100]; CUSTOM_STATUS cs = { sizeof(cs) }; cs.flags = CSSF_MASK_NAME | CSSF_DEFAULT_NAME | CSSF_UNICODE; cs.ptszName = tszTitle; cs.wParam = &i; if (CallProtoService(pdescr->szModuleName, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cs) == 0) mir_wstrncpy(m_item->m_tszTitle, TranslateW(tszTitle), _countof(m_item->m_tszTitle)); if (mir_wstrcmp(m_item->m_tszMessage, tszInputMessage)) mir_wstrcpy(m_item->m_tszMessage, tszInputMessage), m_bChanged = true; }
BOOL CSWindow::itemPassedFilter(ListItem< StatusItem >* li) { wchar_t filter[MAX_PATH]; GetDlgItemText(m_handle, IDC_FILTER_FIELD, filter, _countof(filter)); if (mir_wstrlen(filter)) { wchar_t title[EXTRASTATUS_TITLE_LIMIT], message[EXTRASTATUS_MESSAGE_LIMIT]; mir_wstrcpy(title, li->m_item->m_tszTitle); mir_wstrcpy(message, li->m_item->m_tszMessage); if (strpos(wcslwr(title), wcslwr(filter)) == -1) if (strpos(wcslwr(message), wcslwr(filter)) == -1) return FALSE; } return TRUE; }
void useExternSequence(TCHAR *extStr) { static FLASHING_SEQUENCE Extern = {0}; TCHAR externStr[MAX_PATH+1]; mir_wstrcpy(externStr, extStr); Extern = str2FS(normalizeCustomString(externStr)); pFS = &Extern; bTemporarilyUseExtern = TRUE; }
LPTSTR ChangeTextCase(LPCTSTR ptszInText) { LPTSTR ptszOutText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t)); mir_wstrcpy(ptszOutText, ptszInText); for (DWORD i = 0; i < mir_wstrlen(ptszInText); i++) { CharUpperBuff(&ptszOutText[i], 1); if (ptszOutText[i] == ptszInText[i]) CharLowerBuff(&ptszOutText[i], 1); } return ptszOutText; }
BOOL CopyTextToClipboard(LPTSTR ptszText) { if (!OpenClipboard(nullptr)) return FALSE; EmptyClipboard(); HGLOBAL hCopy = GlobalAlloc(GMEM_MOVEABLE, (mir_wstrlen(ptszText) + 1)*sizeof(wchar_t)); mir_wstrcpy((wchar_t*)GlobalLock(hCopy), ptszText); GlobalUnlock(hCopy); SetClipboardData(CF_UNICODETEXT, hCopy); CloseClipboard(); return TRUE; }
void importCustomStatuses(CSWindow* csw, int result) { DBVARIANT dbv; char bufTitle[32], bufMessage[32], *protoName = csw->m_protoName; for (int i = 0; i < csw->m_statusCount; i++) { StatusItem* si = new StatusItem(); si->m_iIcon = i - 1; mir_snprintf(bufTitle, "XStatus%dName", i); if (!db_get_ws(NULL, protoName, bufTitle, &dbv)) { mir_wstrcpy(si->m_tszTitle, dbv.ptszVal); db_free(&dbv); } else si->m_tszTitle[0] = 0; mir_snprintf(bufMessage, "XStatus%dMsg", i); if (!db_get_ws(NULL, protoName, bufMessage, &dbv)) { mir_wstrcpy(si->m_tszMessage, dbv.ptszVal); db_free(&dbv); } else si->m_tszMessage[0] = 0; if (si->m_tszTitle[0] || si->m_tszMessage[0]) { csw->m_itemslist->m_list->add(si); csw->m_bSomethingChanged = TRUE; } else delete si; if (result == IDYES) { db_unset(NULL, protoName, bufTitle); db_unset(NULL, protoName, bufMessage); } } csw->m_listview->reinitItems(csw->m_itemslist->m_list->getListHead()); }
TCHAR *normalizeCustomString(TCHAR *customStr) { int len=0, status=0; BOOL used[4]; TCHAR strAux[MAX_PATH+1], *str; for (mir_wstrcpy(str=strAux, customStr); *str; str++) { switch (*str) { case _T('['): if (status == 0) { status = 1; customStr[len++] = *str; used[0] = used [1] = used[2] = used[3] = FALSE; } break; case _T(']'): if (status == 1) { status = 0; customStr[len++] = *str; } break; case _T('0'): case _T('1'): case _T('2'): case _T('3'): if (status == 0) customStr[len++] = *str; else if (!used[*str - _T('0')]) { customStr[len++] = *str; used[*str - _T('0')] = TRUE; } break; } } if (status == 1) customStr[len++] = _T(']'); customStr[len] = _T('\0'); return customStr; }
int ChangeLayout(HWND hTextWnd, BYTE TextOperation, BOOL CurrentWord) { HKL hklCurLay = nullptr, hklToLay = nullptr; ptrW ptszInText; CHARRANGE crSelection = { 0 }, crTemp = { 0 }; DWORD dwStartWord, dwEndWord; int i, iRes; BYTE WindowType = WTYPE_Unknown; BOOL WindowIsReadOnly, TwoWay; if (hTextWnd == nullptr) hTextWnd = GetFocus(); if (hTextWnd == nullptr) return 0; //--------------Определяем тип окна----------------- IEVIEWEVENT ieEvent = { 0 }; ieEvent.cbSize = sizeof(IEVIEWEVENT); ieEvent.iType = IEE_GET_SELECTION; if (ServiceExists(MS_HPP_EG_EVENT)) { // То же самое для History++ ieEvent.hwnd = hTextWnd; ptszInText = (wchar_t*)CallService(MS_HPP_EG_EVENT, 0, (LPARAM)&ieEvent); if (!IsBadStringPtr(ptszInText, MaxTextSize)) WindowType = WTYPE_HistoryPP; } if ((WindowType == WTYPE_Unknown) && (ServiceExists(MS_IEVIEW_EVENT))) { // Извращенное определение хэндла IEView ieEvent.hwnd = GetParent(GetParent(hTextWnd)); ptszInText = (wchar_t*)CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&ieEvent); if (!IsBadStringPtr(ptszInText, MaxTextSize)) WindowType = WTYPE_IEView; } if (WindowType == WTYPE_Unknown) { ptrW ptszTemp((LPTSTR)mir_alloc(255 * sizeof(wchar_t))); i = GetClassName(hTextWnd, ptszTemp, 255); ptszTemp[i] = 0; if (wcsstr(CharUpper(ptszTemp), L"RICHEDIT") != nullptr) { WindowType = WTYPE_RichEdit; SendMessage(hTextWnd, EM_EXGETSEL, 0, (LPARAM)&crSelection); } } if (WindowType == WTYPE_Unknown) { SendMessage(hTextWnd, EM_GETSEL, (WPARAM)&crSelection.cpMin, (LPARAM)&crSelection.cpMax); if ((SendMessage(hTextWnd, WM_GETDLGCODE, 0, 0)&(DLGC_HASSETSEL)) && (crSelection.cpMin >= 0)) WindowType = WTYPE_Edit; } // Получим текст из Рича или обычного Едита if (WindowType == WTYPE_RichEdit || WindowType == WTYPE_Edit) { dwStartWord = dwEndWord = -1; SendMessage(hTextWnd, WM_SETREDRAW, FALSE, 0); // Бэкап выделения crTemp = crSelection; // Если имеется выделенный текст, то получим его if (crSelection.cpMin != crSelection.cpMax) { if (WindowType == WTYPE_RichEdit) { EditStreamData esdData; EDITSTREAM esStream = { 0 }; esStream.dwCookie = (DWORD_PTR)&esdData; esStream.pfnCallback = EditStreamOutRtf; if (SendMessage(hTextWnd, EM_STREAMOUT, SF_TEXT | SF_UNICODE | SFF_SELECTION, (LPARAM)&esStream) > 0) ptszInText = GeTStringFromStreamData(&esdData); else { SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection); SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0); InvalidateRect(hTextWnd, nullptr, FALSE); return 1; } } if (WindowType == WTYPE_Edit) { ptrW ptszTemp((LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t))); ptszInText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t)); iRes = GetWindowText(hTextWnd, ptszTemp, MaxTextSize); if (!IsBadStringPtr(ptszInText, MaxTextSize) && (iRes > 0)) { wcsncpy(ptszInText, &ptszTemp[crSelection.cpMin], crSelection.cpMax - crSelection.cpMin); ptszInText[crSelection.cpMax - crSelection.cpMin] = 0; } else { SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection); SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0); InvalidateRect(hTextWnd, nullptr, FALSE); return 1; } } } // Если выделения нет, то получим нужный текст else { // Получаем весь текст в поле if (WindowType == WTYPE_RichEdit) { crTemp.cpMin = 0; crTemp.cpMax = -1; SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crTemp); EditStreamData esdData; EDITSTREAM esStream = { 0 }; esStream.dwCookie = (DWORD_PTR)&esdData; esStream.pfnCallback = EditStreamOutRtf; if (SendMessage(hTextWnd, EM_STREAMOUT, SF_TEXT | SF_UNICODE | SFF_SELECTION, (LPARAM)&esStream) != 0) ptszInText = GeTStringFromStreamData(&esdData); else { SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection); SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0); InvalidateRect(hTextWnd, nullptr, FALSE); return 1; } } if (WindowType == WTYPE_Edit) { ptszInText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t)); iRes = GetWindowText(hTextWnd, ptszInText, MaxTextSize); if (!IsBadStringPtr(ptszInText, MaxTextSize) && (iRes > 0)) { crTemp.cpMin = 0; crTemp.cpMax = (int)mir_wstrlen(ptszInText); } else { SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection); SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0); InvalidateRect(hTextWnd, nullptr, FALSE); return 1; } } // Получаем текущее слово if (CurrentWord) { for (dwStartWord = crSelection.cpMin; (dwStartWord > 0) && (wcschr(ptszSeparators, ptszInText[dwStartWord - 1]) == nullptr); dwStartWord--); for (dwEndWord = crSelection.cpMin; (dwEndWord < (mir_wstrlen(ptszInText))) && (wcschr(ptszSeparators, ptszInText[dwEndWord]) == nullptr); dwEndWord++); crTemp.cpMin = dwStartWord; crTemp.cpMax = dwEndWord; if (WindowType == WTYPE_RichEdit) { SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crTemp); EditStreamData esdData; EDITSTREAM esStream = { 0 }; esStream.dwCookie = (DWORD_PTR)&esdData; esStream.pfnCallback = EditStreamOutRtf; if (SendMessage(hTextWnd, EM_STREAMOUT, SF_TEXT | SF_UNICODE | SFF_SELECTION, (LPARAM)&esStream) != 0) ptszInText = GeTStringFromStreamData(&esdData); else { SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection); SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0); InvalidateRect(hTextWnd, nullptr, FALSE); return 1; } } if (WindowType == WTYPE_Edit) { ptrW ptszTemp((LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t))); wcsncpy(ptszTemp, &ptszInText[crTemp.cpMin], crTemp.cpMax - crTemp.cpMin); ptszTemp[crTemp.cpMax - crTemp.cpMin] = 0; mir_wstrcpy(ptszInText, ptszTemp); if (mir_wstrlen(ptszInText) == 0) { SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection); SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0); InvalidateRect(hTextWnd, nullptr, FALSE); return 1; } } } } } //---------------Выдаем результаты-------------------- WindowIsReadOnly = FALSE; if (WindowType == WTYPE_IEView || WindowType == WTYPE_HistoryPP) WindowIsReadOnly = TRUE; // if ((SendMessage(hTextWnd, EM_GETOPTIONS, 0, 0)&ECO_READONLY)) if (WindowType == WTYPE_RichEdit || WindowType == WTYPE_Edit) if (GetWindowLongPtr(hTextWnd, GWL_STYLE) & ES_READONLY) WindowIsReadOnly = TRUE; // Лог Иевью и ХисториПП в режиме эмуляции Иевью и поля только для чтения. if (WindowType != WTYPE_Unknown && !IsBadStringPtr(ptszInText, MaxTextSize)) if (WindowIsReadOnly) { ptrW ptszMBox((LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t))); ptszMBox[0] = 0; if (TextOperation == TOT_Layout) { hklCurLay = GetLayoutOfText(ptszInText); hklToLay = GetNextLayout(hklCurLay); TwoWay = (moOptions.TwoWay) && (bLayNum == 2); if (bLayNum == 2) ptszMBox = ChangeTextLayout(ptszInText, hklCurLay, hklToLay, TwoWay); else { for (i = 0; i < bLayNum; i++) if (hklLayouts[i] != hklCurLay) { if (mir_wstrlen(ptszMBox) != 0) mir_wstrcat(ptszMBox, L"\n\n"); ptrW ptszTemp(GetShortNameOfLayout(hklLayouts[i])); mir_wstrcat(ptszMBox, ptszTemp); mir_wstrcat(ptszMBox, L":\n"); ptrW ptszOutText(ChangeTextLayout(ptszInText, hklCurLay, hklLayouts[i], FALSE)); mir_wstrcat(ptszMBox, ptszOutText); } } } else if (TextOperation == TOT_Case) ptszMBox = ChangeTextCase(ptszInText); if ((WindowType == WTYPE_Edit) || (WindowType == WTYPE_RichEdit)) { SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection); SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0); InvalidateRect(hTextWnd, nullptr, FALSE); } if (TextOperation == TOT_Layout) Skin_PlaySound(SND_ChangeLayout); else if (TextOperation == TOT_Case) Skin_PlaySound(SND_ChangeCase); if (moOptions.CopyToClipboard) CopyTextToClipboard(ptszMBox); //-------------------------------Покажем попапы------------------------------------------ if (moOptions.ShowPopup) { LPTSTR ptszPopupText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t)); mir_wstrcpy(ptszPopupText, ptszMBox); POPUPDATAT_V2 pdtData = { 0 }; pdtData.cbSize = sizeof(pdtData); wcsncpy(pdtData.lptzContactName, TranslateT(MODULENAME), MAX_CONTACTNAME); wcsncpy(pdtData.lptzText, ptszPopupText, MAX_SECONDLINE); switch (poOptions.bColourType) { case PPC_POPUP: pdtData.colorBack = pdtData.colorText = 0; break; case PPC_WINDOWS: pdtData.colorBack = GetSysColor(COLOR_BTNFACE); pdtData.colorText = GetSysColor(COLOR_WINDOWTEXT); break; case PPC_CUSTOM: pdtData.colorBack = poOptions.crBackColour; pdtData.colorText = poOptions.crTextColour; break; } switch (poOptions.bTimeoutType) { case PPT_POPUP: pdtData.iSeconds = 0; break; case PPT_PERMANENT: pdtData.iSeconds = -1; break; case PPC_CUSTOM: pdtData.iSeconds = poOptions.bTimeout; break; } pdtData.PluginData = ptszPopupText; pdtData.PluginWindowProc = (WNDPROC)CKLPopupDlgProc; pdtData.lchIcon = hPopupIcon; poOptions.paActions[0].lchIcon = hCopyIcon; pdtData.lpActions = poOptions.paActions; pdtData.actionCount = 1; if (CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pdtData, APF_NEWDATA) < 0) { mir_free(ptszPopupText); MessageBox(nullptr, ptszMBox, TranslateT(MODULENAME), MB_ICONINFORMATION); } } } //------------------Редактируемые поля ---------------------------- else { ptrW ptszOutText; if (TextOperation == TOT_Layout) { hklCurLay = GetLayoutOfText(ptszInText); hklToLay = GetNextLayout(hklCurLay); TwoWay = (moOptions.TwoWay) && (bLayNum == 2); ptszOutText = ChangeTextLayout(ptszInText, hklCurLay, hklToLay, TwoWay); } else if (TextOperation == TOT_Case) ptszOutText = ChangeTextCase(ptszInText); if (WindowType == WTYPE_RichEdit) { SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crTemp); SendMessage(hTextWnd, EM_REPLACESEL, FALSE, (LPARAM)ptszOutText); SendMessage(hTextWnd, EM_EXSETSEL, 0, (LPARAM)&crSelection); } else { ptrW ptszTemp((LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t))); GetWindowText(hTextWnd, ptszTemp, MaxTextSize); for (i = crTemp.cpMin; i < crTemp.cpMax; i++) ptszTemp[i] = ptszOutText[i - crTemp.cpMin]; SetWindowText(hTextWnd, ptszTemp); SendMessage(hTextWnd, EM_SETSEL, crSelection.cpMin, crSelection.cpMax); } // Переключим раскладку или изменим состояние Caps Lock if (TextOperation == TOT_Layout && hklToLay != nullptr && moOptions.ChangeSystemLayout) ActivateKeyboardLayout(hklToLay, KLF_SETFORPROCESS); else if (TextOperation == TOT_Case) { // Если нужно инвертнуть if (moOptions.bCaseOperations == 0) { keybd_event(VK_CAPITAL, 0x45, 0, 0); keybd_event(VK_CAPITAL, 0x45, KEYEVENTF_KEYUP, 0); } // Если нужно отключить else if (moOptions.bCaseOperations == 1) { if (GetKeyState(VK_CAPITAL) & 0x0001) { keybd_event(VK_CAPITAL, 0x45, 0, 0); keybd_event(VK_CAPITAL, 0x45, KEYEVENTF_KEYUP, 0); } } } SendMessage(hTextWnd, WM_SETREDRAW, TRUE, 0); InvalidateRect(hTextWnd, nullptr, FALSE); if (TextOperation == TOT_Layout) Skin_PlaySound(SND_ChangeLayout); else if (TextOperation == TOT_Case) Skin_PlaySound(SND_ChangeCase); } return 0; }
static INT_PTR GetContactInfo(WPARAM, LPARAM lParam) { DBVARIANT dbv; CONTACTINFO *ci = (CONTACTINFO*)lParam; if (ci == NULL) return 1; if (ci->szProto == NULL) ci->szProto = Proto_GetBaseAccountName(ci->hContact); if (ci->szProto == NULL) return 1; ci->type = 0; switch (ci->dwFlag & 0x7F) { case CNF_FIRSTNAME: return ProcessDatabaseValueDefault(ci, "FirstName"); case CNF_LASTNAME: return ProcessDatabaseValueDefault(ci, "LastName"); case CNF_NICK: return ProcessDatabaseValueDefault(ci, "Nick"); case CNF_EMAIL: return ProcessDatabaseValueDefault(ci, "e-mail"); case CNF_CITY: return ProcessDatabaseValueDefault(ci, "City"); case CNF_STATE: return ProcessDatabaseValueDefault(ci, "State"); case CNF_PHONE: return ProcessDatabaseValueDefault(ci, "Phone"); case CNF_HOMEPAGE: return ProcessDatabaseValueDefault(ci, "Homepage"); case CNF_ABOUT: return ProcessDatabaseValueDefault(ci, "About"); case CNF_AGE: return ProcessDatabaseValueDefault(ci, "Age"); case CNF_GENDER: return ProcessDatabaseValueDefault(ci, "Gender"); case CNF_FAX: return ProcessDatabaseValueDefault(ci, "Fax"); case CNF_CELLULAR: return ProcessDatabaseValueDefault(ci, "Cellular"); case CNF_BIRTHDAY: return ProcessDatabaseValueDefault(ci, "BirthDay"); case CNF_BIRTHMONTH: return ProcessDatabaseValueDefault(ci, "BirthMonth"); case CNF_BIRTHYEAR: return ProcessDatabaseValueDefault(ci, "BirthYear"); case CNF_STREET: return ProcessDatabaseValueDefault(ci, "Street"); case CNF_ZIP: return ProcessDatabaseValueDefault(ci, "ZIP"); case CNF_LANGUAGE1: return ProcessDatabaseValueDefault(ci, "Language1"); case CNF_LANGUAGE2: return ProcessDatabaseValueDefault(ci, "Language2"); case CNF_LANGUAGE3: return ProcessDatabaseValueDefault(ci, "Language3"); case CNF_CONAME: return ProcessDatabaseValueDefault(ci, "Company"); case CNF_CODEPT: return ProcessDatabaseValueDefault(ci, "CompanyDepartment"); case CNF_COPOSITION: return ProcessDatabaseValueDefault(ci, "CompanyPosition"); case CNF_COSTREET: return ProcessDatabaseValueDefault(ci, "CompanyStreet"); case CNF_COCITY: return ProcessDatabaseValueDefault(ci, "CompanyCity"); case CNF_COSTATE: return ProcessDatabaseValueDefault(ci, "CompanyState"); case CNF_COZIP: return ProcessDatabaseValueDefault(ci, "CompanyZIP"); case CNF_COHOMEPAGE: return ProcessDatabaseValueDefault(ci, "CompanyHomepage"); case CNF_CUSTOMNICK: { char* saveProto = ci->szProto; ci->szProto = "CList"; if (ci->hContact != NULL && !ProcessDatabaseValueDefault(ci, "MyHandle")) { ci->szProto = saveProto; return 0; } ci->szProto = saveProto; } break; case CNF_COUNTRY: case CNF_COCOUNTRY: if (!GetDatabaseString(ci, (ci->dwFlag & 0x7F) == CNF_COUNTRY ? "CountryName" : "CompanyCountryName", &dbv)) return 0; if (!db_get(ci->hContact, ci->szProto, (ci->dwFlag & 0x7F) == CNF_COUNTRY ? "Country" : "CompanyCountry", &dbv)) { if (dbv.type == DBVT_WORD) { int i, countryCount; struct CountryListEntry *countries; CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&countryCount, (LPARAM)&countries); for (i = 0; i < countryCount; i++) { if (countries[i].id != dbv.wVal) continue; if (ci->dwFlag & CNF_UNICODE) { int cbLen = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)countries[i].szName, -1, NULL, 0); WCHAR* buf = (WCHAR*)mir_alloc(sizeof(WCHAR)*(cbLen + 1)); if (buf != NULL) MultiByteToWideChar(CP_ACP, 0, (LPCSTR)countries[i].szName, -1, buf, cbLen); ci->pszVal = (TCHAR*)buf; } else ci->pszVal = (TCHAR*)mir_strdup(countries[i].szName); ci->type = CNFT_ASCIIZ; db_free(&dbv); return 0; } } else return ProcessDatabaseValueDefault(ci, (ci->dwFlag & 0x7F) == CNF_COUNTRY ? "Country" : "CompanyCountry"); db_free(&dbv); } break; case CNF_FIRSTLAST: if (!GetDatabaseString(ci, "FirstName", &dbv)) { DBVARIANT dbv2; if (!GetDatabaseString(ci, "LastName", &dbv2)) { ci->type = CNFT_ASCIIZ; if (ci->dwFlag & CNF_UNICODE) { size_t len = mir_wstrlen(dbv.pwszVal) + mir_wstrlen(dbv2.pwszVal) + 2; WCHAR* buf = (WCHAR*)mir_alloc(sizeof(WCHAR)*len); if (buf != NULL) mir_wstrcat(mir_wstrcat(mir_wstrcpy(buf, dbv.pwszVal), L" "), dbv2.pwszVal); ci->pszVal = (TCHAR*)buf; } else { size_t len = mir_strlen(dbv.pszVal) + mir_strlen(dbv2.pszVal) + 2; char* buf = (char*)mir_alloc(len); if (buf != NULL) mir_strcat(mir_strcat(mir_strcpy(buf, dbv.pszVal), " "), dbv2.pszVal); ci->pszVal = (TCHAR*)buf; } db_free(&dbv); db_free(&dbv2); return 0; } db_free(&dbv); } break; case CNF_UNIQUEID: { if (db_mc_isMeta(ci->hContact)) { TCHAR buf[40]; _itot(ci->hContact, buf, 10); ci->pszVal = mir_tstrdup(buf); ci->type = CNFT_ASCIIZ; return 0; } char *uid = (char*)CallProtoService(ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid) if (!ProcessDatabaseValueDefault(ci, uid)) return 0; } break; case CNF_DISPLAYUID: { if (!ProcessDatabaseValueDefault(ci, "display_uid")) return 0; char *uid = (char*)CallProtoService(ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid) if (!ProcessDatabaseValueDefault(ci, uid)) return 0; } break; case CNF_DISPLAYNC: case CNF_DISPLAY: for (int i = 0; i < NAMEORDERCOUNT; i++) { switch (nameOrder[i]) { case 0: // custom name // make sure we aren't in CNF_DISPLAYNC mode // don't get custom name for NULL contact { char *saveProto = ci->szProto; ci->szProto = "CList"; if (ci->hContact != NULL && (ci->dwFlag & 0x7F) == CNF_DISPLAY && !ProcessDatabaseValueDefault(ci, "MyHandle")) { ci->szProto = saveProto; return 0; } ci->szProto = saveProto; } break; case 1: if (!ProcessDatabaseValueDefault(ci, "Nick")) // nick return 0; break; case 2: if (!ProcessDatabaseValueDefault(ci, "FirstName")) // First Name return 0; break; case 3: if (!ProcessDatabaseValueDefault(ci, "e-mail")) // E-mail return 0; break; case 4: if (!ProcessDatabaseValueDefault(ci, "LastName")) // Last Name return 0; break; case 5: // Unique id { // protocol must define a PFLAG_UNIQUEIDSETTING char *uid = (char*)CallProtoService(ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid) { if (!GetDatabaseString(ci, uid, &dbv)) { if (dbv.type == DBVT_BYTE || dbv.type == DBVT_WORD || dbv.type == DBVT_DWORD) { long value = (dbv.type == DBVT_BYTE) ? dbv.bVal : (dbv.type == DBVT_WORD ? dbv.wVal : dbv.dVal); if (ci->dwFlag & CNF_UNICODE) { WCHAR buf[40]; _ltow(value, buf, 10); ci->pszVal = (TCHAR*)mir_wstrdup(buf); } else { char buf[40]; _ltoa(value, buf, 10); ci->pszVal = (TCHAR*)mir_strdup(buf); } ci->type = CNFT_ASCIIZ; return 0; } if (dbv.type == DBVT_ASCIIZ && !(ci->dwFlag & CNF_UNICODE)) { ci->type = CNFT_ASCIIZ; ci->pszVal = dbv.ptszVal; return 0; } if (dbv.type == DBVT_WCHAR && (ci->dwFlag & CNF_UNICODE)) { ci->type = CNFT_ASCIIZ; ci->pszVal = dbv.ptszVal; return 0; } } } } break; case 6: // first + last name case 7: // last + first name if (!GetDatabaseString(ci, nameOrder[i] == 6 ? "FirstName" : "LastName", &dbv)) { DBVARIANT dbv2; if (!GetDatabaseString(ci, nameOrder[i] == 6 ? "LastName" : "FirstName", &dbv2)) { ci->type = CNFT_ASCIIZ; if (ci->dwFlag & CNF_UNICODE) { size_t len = mir_wstrlen(dbv.pwszVal) + mir_wstrlen(dbv2.pwszVal) + 2; WCHAR* buf = (WCHAR*)mir_alloc(sizeof(WCHAR)*len); if (buf != NULL) mir_wstrcat(mir_wstrcat(mir_wstrcpy(buf, dbv.pwszVal), L" "), dbv2.pwszVal); ci->pszVal = (TCHAR*)buf; } else { size_t len = mir_strlen(dbv.pszVal) + mir_strlen(dbv2.pszVal) + 2; char* buf = (char*)mir_alloc(len); if (buf != NULL) mir_strcat(mir_strcat(mir_strcpy(buf, dbv.pszVal), " "), dbv2.pszVal); ci->pszVal = (TCHAR*)buf; } db_free(&dbv); db_free(&dbv2); return 0; } db_free(&dbv); } break; case 8: if (ci->dwFlag & CNF_UNICODE) ci->pszVal = (TCHAR*)mir_wstrdup(TranslateW(L"'(Unknown contact)'")); else ci->pszVal = (TCHAR*)mir_strdup(Translate("'(Unknown contact)'")); ci->type = CNFT_ASCIIZ; return 0; } } break; case CNF_TIMEZONE: { HANDLE hTz = TimeZone_CreateByContact(ci->hContact, 0, TZF_KNOWNONLY); if (hTz) { LPTIME_ZONE_INFORMATION tzi = TimeZone_GetInfo(hTz); int offset = tzi->Bias + tzi->StandardBias; char str[80]; mir_snprintf(str, offset ? "UTC%+d:%02d" : "UTC", offset / -60, abs(offset % 60)); ci->pszVal = ci->dwFlag & CNF_UNICODE ? (TCHAR*)mir_a2u(str) : (TCHAR*)mir_strdup(str); ci->type = CNFT_ASCIIZ; return 0; } } break; case CNF_MYNOTES: char* saveProto = ci->szProto; ci->szProto = "UserInfo"; if (!ProcessDatabaseValueDefault(ci, "MyNotes")) { ci->szProto = saveProto; return 0; } ci->szProto = saveProto; break; } return 1; }
LRESULT CALLBACK BadConnectPopupProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) { DWORD PluginParam; switch(msg) { case WM_COMMAND: // if clicked and it's new mail popup window if ((HIWORD(wParam)==STN_CLICKED) && (CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&PluginParam))) { PROCESS_INFORMATION pi; STARTUPINFOW si; memset(&si, 0, sizeof(si)); si.cb=sizeof(si); HACCOUNT ActualAccount = (HACCOUNT)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, 0); #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read wait\n"); #endif if (WAIT_OBJECT_0==WaitToReadFcn(ActualAccount->AccountAccessSO)) { #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter\n"); #endif if (ActualAccount->BadConnectN.App != NULL) { WCHAR *Command; if (ActualAccount->BadConnectN.AppParam != NULL) Command = new WCHAR[wcslen(ActualAccount->BadConnectN.App)+wcslen(ActualAccount->BadConnectN.AppParam)+6]; else Command = new WCHAR[wcslen(ActualAccount->BadConnectN.App)+6]; if (Command != NULL) { mir_wstrcpy(Command,L"\""); mir_wstrcat(Command,ActualAccount->BadConnectN.App); mir_wstrcat(Command,L"\" "); if (ActualAccount->BadConnectN.AppParam != NULL) mir_wstrcat(Command,ActualAccount->BadConnectN.AppParam); CreateProcessW(NULL,Command,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi); delete[] Command; } } #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read done\n"); #endif ReadDoneFcn(ActualAccount->AccountAccessSO); } #ifdef DEBUG_SYNCHRO else DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter failed\n"); #endif SendMessage(hWnd,UM_DESTROYPOPUP,0,0); } break; case UM_FREEPLUGINDATA: //Here we'd free our own data, if we had it. return FALSE; case UM_INITPOPUP: //This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups. break; case WM_CONTEXTMENU: SendMessage(hWnd,UM_DESTROYPOPUP,0,0); break; } return DefWindowProc(hWnd,msg,wParam,lParam); }