static int HookContactSettingChanged(WPARAM hContact, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; char *szProto = GetContactProto(hContact); if (strcmpnull(cws->szModule, "CList") && strcmpnull(cws->szModule, szProto)) return 0; WindowList_Broadcast(g_hSendWindowList, DM_UPDATETITLE, 0, 0); WindowList_Broadcast(g_hRecvWindowList, DM_UPDATETITLE, 0, 0); return 0; }
static MCONTACT CreateTemporaryContactForItem(HWND hwndDlg, TRecvContactsData *wndData, int iItem) { TCHAR *caUIN = ListView_GetItemTextEx(GetDlgItem(hwndDlg, IDC_CONTACTS), iItem, 0); char *szProto = GetContactProto(wndData->mhContact); wndData->rhSearch = (HANDLE)CallProtoService(szProto, PS_BASICSEARCH, 0, (LPARAM)caUIN); // find it replaceStrT(wndData->haUin, caUIN); for (int j = 0; j < wndData->cbReceived; j++) if (!lstrcmp(wndData->maReceived[j]->mcaUIN, caUIN)) return (MCONTACT)CallProtoService(szProto, PS_ADDTOLISTBYEVENT, MAKEWPARAM(PALF_TEMPORARY, j), (LPARAM)wndData->mhDbEvent); return NULL; }
void HideNudgeButton(MCONTACT hContact) { char *szProto = GetContactProto(hContact); if (!ProtoServiceExists(szProto, PS_SEND_NUDGE)) { BBButton bbd = { sizeof(bbd) }; bbd.bbbFlags = BBSF_HIDDEN | BBSF_DISABLED; bbd.pszModuleName = "Nudge"; bbd.dwButtonID = 6000; CallService(MS_BB_SETBUTTONSTATE, hContact, (LPARAM)&bbd); } }
static int SRUrlPreBuildMenu(WPARAM wParam, LPARAM) { bool bEnabled = false; char *szProto = GetContactProto(wParam); if (szProto != NULL) if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_URLSEND) bEnabled = true; Menu_ShowItem(hSRUrlMenuItem, bEnabled); return 0; }
INT_PTR ContactChangeGroup(WPARAM hContact, LPARAM lParam) { CallService(MS_CLUI_CONTACTDELETED, hContact, 0); if ((HANDLE)lParam == NULL) db_unset(hContact, "CList", "Group"); else db_set_s(hContact, "CList", "Group", (char*)CallService(MS_CLIST_GROUPGETNAME2, lParam, (LPARAM)(int*)NULL)); CallService(MS_CLUI_CONTACTADDED, hContact, ExtIconFromStatusMode(hContact, GetContactProto(hContact), GetContactStatus(hContact))); return 0; }
int onContactSettingChanged(WPARAM hContact, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; const char *proto = GetContactProto((MCONTACT)hContact); if (!proto) return 0; if (!strcmp(cws->szModule, proto)) if (!strcmp(cws->szSetting, "Auth") || !strcmp(cws->szSetting, "Grant") || !strcmp(cws->szSetting, "ServerId") || !strcmp(cws->szSetting, "ContactType")) onExtraImageApplying(hContact, 1); return 0; }
int onContactSettingChanged(WPARAM wParam, LPARAM lParam) { char *proto = GetContactProto(wParam); if (!proto) return 0; DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; if (!strcmp(cws->szModule, proto) && !strcmp(cws->szSetting, "MirVer")) ExtraIconsApply(wParam, 1); return 0; }
void ReloadExtraInfo(MCONTACT hContact) { if(hContact && pcli->hwndContactTree) { int index = cfg::getCache(hContact, NULL); if(index >= 0 && index < cfg::nextCacheEntry) { char *szProto = GetContactProto(hContact); TZ_LoadTimeZone(hContact, &cfg::eCache[index], szProto); InvalidateRect(pcli->hwndContactTree, NULL, FALSE); } } }
// Helper functions static WhatsAppProto* GetInstanceByHContact(MCONTACT hContact) { char *proto = GetContactProto(hContact); if (!proto) return 0; for (int i = 0; i < g_Instances.getCount(); i++) if (!mir_strcmp(proto, g_Instances[i].m_szModuleName)) return &g_Instances[i]; return 0; }
static CMsnProto* GetProtoInstanceByHContact(MCONTACT hContact) { char* szProto = GetContactProto(hContact); if (szProto == NULL) return NULL; for (int i = 0; i < g_Instances.getCount(); i++) if (!mir_strcmp(szProto, g_Instances[i].m_szModuleName)) return &g_Instances[i]; return NULL; }
static CIcqProto* IcqGetInstanceByHContact(HANDLE hContact) { char* szProto = GetContactProto(hContact); if (szProto == NULL) return NULL; for (int i = 0; i < g_Instances.getCount(); i++) if (!strcmp(szProto, g_Instances[i]->m_szModuleName)) return g_Instances[i]; return NULL; }
std::wstring EventList::GetMyId() { std::wstring myId; CONTACTINFO ci; memset(&ci, 0, sizeof(ci)); ci.cbSize = sizeof(ci); ci.szProto = GetContactProto(hContact); ci.hContact = 0; ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR; GetInfo(ci, myId); return myId; }
inline std::wstring GetContactId(MCONTACT hContact) { std::wstring id; CONTACTINFO ci; memset(&ci, 0, sizeof(ci)); ci.cbSize = sizeof(ci); ci.szProto = GetContactProto(hContact); ci.hContact = hContact; ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR; GetInfo(ci, id); return id; }
static HANDLE CreateTemporaryContactForItem(HWND hwndDlg, TRecvContactsData* wndData, int iItem) { char* caUIN = ListView_GetItemTextEx(GetDlgItem(hwndDlg, IDC_CONTACTS), iItem, 0); char* szProto = GetContactProto(wndData->mhContact); wndData->rhSearch = (HANDLE)SRCCallProtoService(szProto, PS_BASICSEARCH, 0, (LPARAM)caUIN); // find it SAFE_FREE((void**)&wndData->haUin); wndData->haUin = caUIN; for (int j = 0; j < wndData->cbReceived; j++) if (!strcmpnull(wndData->maReceived[j]->mcaUIN, caUIN)) return (HANDLE)SRCCallProtoService(szProto, PS_ADDTOLISTBYEVENT, MAKEWPARAM(PALF_TEMPORARY, j), (LPARAM)wndData->mhDbEvent); return NULL; }
protoPicCacheEntry* GetProtoDefaultAvatar(MCONTACT hContact) { char *szProto = GetContactProto(hContact); if (szProto) { for (int i = 0; i < g_ProtoPictures.getCount(); i++) { protoPicCacheEntry& p = g_ProtoPictures[i]; if (!mir_strcmp(p.szProtoname, szProto) && p.hbmPic != NULL) return &g_ProtoPictures[i]; } } return NULL; }
//--------------------------------------------------------------------------- void CSend::SetContact(MCONTACT hContact) { m_hContact = hContact; if (hContact) { m_pszProto = GetContactProto(hContact); m_ChatRoom = db_get_b(hContact, m_pszProto, "ChatRoom", 0); /* m_PFflag = hasCap(PF1_URLSEND); m_PFflag = hasCap(PF1_CHAT); m_PFflag = hasCap(PF1_IMSEND);// */ } }
void ReloadExtraInfo(MCONTACT hContact) { if (hContact && pcli->hwndContactTree) { TExtraCache *p = cfg::getCache(hContact, NULL); if (p) { char *szProto = GetContactProto(hContact); TZ_LoadTimeZone(hContact, p, szProto); InvalidateRect(pcli->hwndContactTree, NULL, FALSE); } } }
MIR_CORE_DLL(HANDLE) TimeZone_CreateByContact(MCONTACT hContact, LPCSTR szModule, DWORD dwFlags) { if (hContact == NULL && szModule == NULL) return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? NULL : &myInfo.myTZ; if (szModule == NULL) szModule = "UserInfo"; DBVARIANT dbv; if (!db_get_ts(hContact, szModule, "TzName", &dbv)) { HANDLE res = TimeZone_CreateByName(dbv.ptszVal, dwFlags); db_free(&dbv); if (res) return res; } signed char timezone = (signed char)db_get_b(hContact, szModule, "Timezone", -1); if (timezone == -1) { char *szProto = GetContactProto(hContact); if (!db_get_ts(hContact, szProto, "TzName", &dbv)) { HANDLE res = TimeZone_CreateByName(dbv.ptszVal, dwFlags); db_free(&dbv); if (res) return res; } timezone = (signed char)db_get_b(hContact, szProto, "Timezone", -1); } if (timezone != -1) { MIM_TIMEZONE tzsearch; tzsearch.tzi.Bias = timezone * 30; if (myInfo.myTZ.tzi.Bias == tzsearch.tzi.Bias) { if (dwFlags & TZF_DIFONLY) return NULL; return &myInfo.myTZ; } int i = g_timezonesBias.getIndex(&tzsearch); while (i >= 0 && g_timezonesBias[i]->tzi.Bias == tzsearch.tzi.Bias) --i; int delta = LONG_MAX; for (int j = ++i; j < g_timezonesBias.getCount() && g_timezonesBias[j]->tzi.Bias == tzsearch.tzi.Bias; ++j) { int delta1 = abs(g_timezonesBias[j]->tzi.DaylightDate.wMonth - myInfo.myTZ.tzi.DaylightDate.wMonth); if (delta1 <= delta) { delta = delta1; i = j; } } if (i >= 0) { MIM_TIMEZONE *tz = g_timezonesBias[i]; return ((dwFlags & TZF_DIFONLY) && IsSameTime(tz)) ? NULL : tz; } } return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? NULL : &myInfo.myTZ; }
int CLC::AddContactToGroup(struct ClcData *dat, struct ClcGroup *group, MCONTACT hContact) { int i = coreCli.pfnAddContactToGroup( dat, group, hContact ); struct ClcContact* p = group->cl.items[i]; p->wStatus = cfg::getWord(hContact, p->proto, "Status", ID_STATUS_OFFLINE); p->xStatus = cfg::getByte(hContact, p->proto, "XStatusId", 0); //p->iRowHeight = -1; if (p->proto) p->bIsMeta = !strcmp(p->proto, cfg::dat.szMetaName); else p->bIsMeta = FALSE; if (p->bIsMeta && cfg::dat.bMetaAvail) { p->hSubContact = db_mc_getMostOnline(hContact); p->metaProto = GetContactProto(p->hSubContact); p->iImage = CallService(MS_CLIST_GETCONTACTICON, (WPARAM) p->hSubContact, 0); } else { p->iImage = CallService(MS_CLIST_GETCONTACTICON, (WPARAM) hContact, 0); p->metaProto = NULL; } p->bSecondLine = cfg::dat.dualRowMode; p->bSecondLineLocal = cfg::getByte(hContact, "CList", "CLN_2ndline", -1); p->dwDFlags = cfg::getDword(hContact, "CList", "CLN_Flags", 0); if(dat->bisEmbedded) p->extraCacheEntry = -1; else { p->extraCacheEntry = cfg::getCache(p->hContact, p->proto); GetExtendedInfo( p, dat); if(p->extraCacheEntry >= 0 && p->extraCacheEntry < cfg::nextCacheEntry) { cfg::eCache[p->extraCacheEntry].proto_status_item = GetProtocolStatusItem(p->bIsMeta ? p->metaProto : p->proto); if(cfg::getByte(p->hContact, "CList", "floating", 0) && g_floatoptions.enabled) { if(cfg::eCache[p->extraCacheEntry].floater == NULL) FLT_Create(p->extraCacheEntry); else { ShowWindow(cfg::eCache[p->extraCacheEntry].floater->hwnd, SW_SHOWNOACTIVATE); FLT_Update(dat, p); } } } LoadAvatarForContact(p); // notify other plugins to re-supply their extra images (icq for xstatus, mBirthday etc...) pcli->pfnSetAllExtraIcons(hContact); } RTL_DetectAndSet( p, p->hContact); p->avatarLeft = p->extraIconRightBegin = -1; p->flags |= cfg::getByte(p->hContact, "CList", "Priority", 0) ? CONTACTF_PRIORITY : 0; return i; }
static MCONTACT HContactFromNumericID(char *pszProtoName, char *pszSetting, DWORD dwID) { MCONTACT hContact = dstDb->FindFirstContact(); while (hContact != NULL) { if ( db_get_dw((MCONTACT)hContact, pszProtoName, pszSetting, 0) == dwID) { char* szProto = GetContactProto((MCONTACT)hContact); if (szProto != NULL && !lstrcmpA(szProto, pszProtoName)) return hContact; } hContact = dstDb->FindNextContact((MCONTACT)hContact); } return INVALID_CONTACT_ID; }
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); }
HICON createProtoOverlayedIcon(MCONTACT hContact) { HICON icon1 = LoadIconEx(I_OVERLAY); char *szProto = GetContactProto(hContact); HICON icon0 = LoadSkinnedProtoIcon(szProto, ID_STATUS_ONLINE); HICON resIcon = getOverlayedIcon(icon0, icon1, FALSE); ReleaseIconEx(icon1); Skin_ReleaseIcon(icon0); return resIcon; }
static int StatusSettingChanged(WPARAM wParam, LPARAM lParam) { if (currentWatcherType&SDWTF_STATUS) { DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING*)lParam; if ((HANDLE)wParam != NULL && dbcws->value.wVal == ID_STATUS_OFFLINE && !strcmp(dbcws->szSetting, "Status")) { char *pszProto = GetContactProto(wParam); if (pszProto != NULL && !strcmp(dbcws->szModule, pszProto)) if (CheckAllContactsOffline()) ShutdownAndStopWatcher(); } } return 0; }
// returns a string in the form <PROTOID:UNIQUEID>, cannot be _HANDLE_! // result must be freed TCHAR* encodeContactToString(MCONTACT hContact) { char *szProto = GetContactProto(hContact); TCHAR *tszUniqueId = getContactInfoT(CNF_UNIQUEID, hContact); if (szProto == NULL || tszUniqueId == NULL) return NULL; size_t size = _tcslen(tszUniqueId) + strlen(szProto) + 4; TCHAR *tszResult = (TCHAR *)mir_calloc(size * sizeof(TCHAR)); if (tszResult) mir_sntprintf(tszResult, size, _T("<%S:%s>"), szProto, tszUniqueId); return tszResult; }
static int GetContactStatus(MCONTACT hContact) { if (hContact == NULL) { assert(!"Contact is NULL"); return 0; } char *szProto = GetContactProto(hContact); if (szProto == NULL) return ID_STATUS_OFFLINE; return db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); }
static int EMailPreBuildMenu(WPARAM hContact, LPARAM) { bool bEnabled = true; DBVARIANT dbv = { 0 }; char *szProto = GetContactProto(hContact); if (szProto == NULL || db_get_s(hContact, szProto, "e-mail", &dbv)) if (db_get_s(hContact, "UserInfo", "Mye-mail0", &dbv)) bEnabled = false; Menu_ShowItem(hEMailMenuItem, bEnabled); if (dbv.pszVal) db_free(&dbv); return 0; }
int OnExtraImageApply(WPARAM hContact, LPARAM) { if (hContact == NULL) return 0; ptrT tszMirver; char *szProto = GetContactProto(hContact); if (szProto != NULL) tszMirver = db_get_tsa(hContact, szProto, "MirVer"); ApplyFingerprintImage(hContact, tszMirver); return 0; }
static INT_PTR CALLBACK SummaryDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case 0: if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) { HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam; if (hContact != NULL) { char *szProto = GetContactProto(hContact); if (szProto == NULL) break; SetValue(hwndDlg, IDC_NICK, hContact, szProto, "Nick", 0); SetValue(hwndDlg, IDC_FIRSTNAME, hContact, szProto, "FirstName", 0); SetValue(hwndDlg, IDC_LASTNAME, hContact, szProto, "LastName", 0); SetValue(hwndDlg, IDC_EMAIL, hContact, szProto, "e-mail", 0); SetValue(hwndDlg, IDC_AGE, hContact, szProto, "Age", SVS_ZEROISUNSPEC); SetValue(hwndDlg, IDC_GENDER, hContact, szProto, "Gender", SVS_GENDER); SetValue(hwndDlg, IDC_DOBDAY, hContact, szProto, "BirthDay", 0); SetValue(hwndDlg, IDC_DOBMONTH, hContact, szProto, "BirthMonth", SVS_MONTH); SetValue(hwndDlg, IDC_DOBYEAR, hContact, szProto, "BirthYear", 0); SetValue(hwndDlg, IDC_MARITAL, hContact, szProto, "MaritalStatus", 0); } } break; } break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDCANCEL: SendMessage(GetParent(hwndDlg), msg, wParam, lParam); break; case IDC_EMAIL: if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EMAIL))) { TCHAR szExec[264], szEmail[256]; GetDlgItemText(hwndDlg, IDC_EMAIL, szEmail, SIZEOF(szEmail)); mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail); ShellExecute(hwndDlg, _T("open"), szExec, NULL, NULL, SW_SHOW); } break; } break; } return FALSE; }
static int ClcSettingChanged(WPARAM hContact, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam; if (hContact == NULL) { if (!mir_strcmp(cws->szModule, "CListGroups")) cli.pfnClcBroadcast(INTM_GROUPSCHANGED, hContact, lParam); return 0; } if (!mir_strcmp(cws->szModule, "CList")) { if (!mir_strcmp(cws->szSetting, "MyHandle")) { cli.pfnInvalidateDisplayNameCacheEntry(hContact); cli.pfnClcBroadcast(INTM_NAMECHANGED, hContact, lParam); } else if (!mir_strcmp(cws->szSetting, "Group")) cli.pfnClcBroadcast(INTM_GROUPCHANGED, hContact, lParam); else if (!mir_strcmp(cws->szSetting, "Hidden")) cli.pfnClcBroadcast(INTM_HIDDENCHANGED, hContact, lParam); else if (!mir_strcmp(cws->szSetting, "NotOnList")) cli.pfnClcBroadcast(INTM_NOTONLISTCHANGED, hContact, lParam); else if (!mir_strcmp(cws->szSetting, "Status")) cli.pfnClcBroadcast(INTM_INVALIDATE, 0, 0); else if (!mir_strcmp(cws->szSetting, "NameOrder")) cli.pfnClcBroadcast(INTM_NAMEORDERCHANGED, 0, 0); } else { char *szProto = GetContactProto(hContact); if (szProto != NULL) { if (!mir_strcmp(cws->szModule, "Protocol") && !mir_strcmp(cws->szSetting, "p")) cli.pfnClcBroadcast(INTM_PROTOCHANGED, hContact, lParam); // something is being written to a protocol module if (!mir_strcmp(szProto, cws->szModule)) { // was a unique setting key written? char *id = (char *) CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); if ((INT_PTR)id != CALLSERVICE_NOTFOUND && id != NULL && !mir_strcmp(id, cws->szSetting)) cli.pfnClcBroadcast(INTM_PROTOCHANGED, hContact, lParam); } } if (szProto == NULL || mir_strcmp(szProto, cws->szModule)) return 0; if (!mir_strcmp(cws->szSetting, "Nick") || !mir_strcmp(cws->szSetting, "FirstName") || !mir_strcmp(cws->szSetting, "e-mail") || !mir_strcmp(cws->szSetting, "LastName") || !mir_strcmp(cws->szSetting, "UIN")) cli.pfnClcBroadcast(INTM_NAMECHANGED, hContact, lParam); else if (!mir_strcmp(cws->szSetting, "ApparentMode")) cli.pfnClcBroadcast(INTM_APPARENTMODECHANGED, hContact, lParam); else if (!mir_strcmp(cws->szSetting, "IdleTS")) cli.pfnClcBroadcast(INTM_IDLECHANGED, hContact, lParam); } return 0; }
INT_PTR SendMessageCommand_W(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; TNewWindowData newData = { 0 }; int isSplit = 1; /* * make sure that only the main UI thread will handle window creation */ if (GetCurrentThreadId() != PluginConfig.dwThreadID) { if (lParam) { unsigned iLen = lstrlenW((wchar_t *)lParam); wchar_t *tszText = (wchar_t *)mir_alloc((iLen + 1) * sizeof(wchar_t)); wcsncpy(tszText, (wchar_t *)lParam, iLen + 1); tszText[iLen] = 0; PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_SENDMESSAGECOMMANDW, wParam, (LPARAM)tszText); } else PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_SENDMESSAGECOMMANDW, wParam, 0); return 0; } /* does the HCONTACT's protocol support IM messages? */ char *szProto = GetContactProto(hContact); if (szProto) { if (!CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) return 0; } else { /* unknown contact */ return 0; } HWND hwnd = M.FindWindow(hContact); if (hwnd) { if (lParam) { HWND hEdit = GetDlgItem(hwnd, IDC_MESSAGE); SendMessage(hEdit, EM_SETSEL, -1, SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0)); SendMessage(hEdit, EM_REPLACESEL, FALSE, (LPARAM)(TCHAR*) lParam); } SendMessage(hwnd, DM_ACTIVATEME, 0, 0); } else { TCHAR szName[CONTAINER_NAMELEN + 1]; GetContainerNameForContact(hContact, szName, CONTAINER_NAMELEN); TContainerData *pContainer = FindContainerByName(szName); if (pContainer == NULL) pContainer = CreateContainer(szName, FALSE, hContact); if (pContainer) CreateNewTabForContact(pContainer, hContact, 1, (const char *)lParam, TRUE, TRUE, FALSE, 0); } return 0; }