static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { static bool bInitialized = false; static MCONTACT hSelectedContact = 0; switch (msg) { case WM_INITDIALOG: bInitialized = false; TranslateDialogDefault(hwnd); CheckDlgButton(hwnd, IDC_CHK_GROUPS, g_Options.bUseGroups ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_CHK_GROUPCOLUMS, g_Options.bUseColumns ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_CHK_SECONDLINE, g_Options.bSecondLine ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_CHK_AVATARS, g_Options.bAvatars ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_CHK_AVATARBORDER, g_Options.bAvatarBorder ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_CHK_NOTRANSPARENTBORDER, g_Options.bNoTransparentBorder ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_CHK_SYSCOLORS, g_Options.bSysColors ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_CHK_CENTERHOTKEY, g_Options.bCenterHotkey ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_CHK_RIGHTAVATARS, g_Options.bRightAvatars ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_CHK_DIMIDLE, g_Options.bDimIdle ? BST_CHECKED : BST_UNCHECKED); SetDlgItemInt(hwnd, IDC_TXT_RADIUS, g_Options.wAvatarRadius, FALSE); SetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, g_Options.wMaxRecent, FALSE); SetWindowLongPtr(GetDlgItem(hwnd, IDC_CLIST), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwnd, IDC_CLIST), GWL_STYLE) | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE | CLS_GROUPCHECKBOXES); SendMessage(GetDlgItem(hwnd, IDC_CLIST), CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT, 0); sttResetListOptions(GetDlgItem(hwnd, IDC_CLIST)); hSelectedContact = db_find_first(); { for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) SendDlgItemMessage(hwnd, IDC_CLIST, CLM_SETCHECKMARK, SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0), db_get_b(hContact, "FavContacts", "IsFavourite", 0)); } bInitialized = true; PostMessage(hwnd, WM_APP, 0, 0); return TRUE; case WM_APP: { BOOL bGroups = IsDlgButtonChecked(hwnd, IDC_CHK_GROUPS); EnableWindow(GetDlgItem(hwnd, IDC_CHK_GROUPCOLUMS), bGroups); BOOL bAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARS); BOOL bBorders = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARBORDER); EnableWindow(GetDlgItem(hwnd, IDC_CHK_AVATARBORDER), bAvatars); EnableWindow(GetDlgItem(hwnd, IDC_CHK_RIGHTAVATARS), bAvatars); EnableWindow(GetDlgItem(hwnd, IDC_CHK_NOTRANSPARENTBORDER), bAvatars && bBorders); EnableWindow(GetDlgItem(hwnd, IDC_TXT_RADIUS), bAvatars && bBorders); } return TRUE; case WM_DRAWITEM: { LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; if (lpdis->CtlID == IDC_CANVAS) { MEASUREITEMSTRUCT mis = { 0 }; DRAWITEMSTRUCT dis = *lpdis; FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_BTNFACE)); if (hSelectedContact) { Options options; options.bSecondLine = IsDlgButtonChecked(hwnd, IDC_CHK_SECONDLINE); options.bAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARS); options.bAvatarBorder = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARBORDER); options.bNoTransparentBorder = IsDlgButtonChecked(hwnd, IDC_CHK_NOTRANSPARENTBORDER); options.bSysColors = IsDlgButtonChecked(hwnd, IDC_CHK_SYSCOLORS); options.bCenterHotkey = IsDlgButtonChecked(hwnd, IDC_CHK_CENTERHOTKEY); options.bRightAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_RIGHTAVATARS); options.bDimIdle = IsDlgButtonChecked(hwnd, IDC_CHK_DIMIDLE); options.wAvatarRadius = GetDlgItemInt(hwnd, IDC_TXT_RADIUS, NULL, FALSE); options.wMaxRecent = GetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, NULL, FALSE); mis.CtlID = 0; mis.CtlType = ODT_MENU; mis.itemData = (DWORD)hSelectedContact; MenuMeasureItem(&mis, &options); dis.rcItem.bottom = dis.rcItem.top + mis.itemHeight; dis.CtlID = 0; dis.CtlType = ODT_MENU; dis.itemData = (DWORD)hSelectedContact; MenuDrawItem(&dis, &options); RECT rc = lpdis->rcItem; rc.bottom = rc.top + mis.itemHeight; FrameRect(lpdis->hDC, &rc, GetSysColorBrush(COLOR_HIGHLIGHT)); } return TRUE; } } return FALSE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CHK_SECONDLINE: case IDC_CHK_AVATARS: case IDC_CHK_AVATARBORDER: case IDC_CHK_NOTRANSPARENTBORDER: case IDC_CHK_SYSCOLORS: case IDC_CHK_CENTERHOTKEY: case IDC_CHK_GROUPS: case IDC_CHK_GROUPCOLUMS: case IDC_CHK_RIGHTAVATARS: SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), NULL, NULL, RDW_INVALIDATE); PostMessage(hwnd, WM_APP, 0, 0); break; case IDC_BTN_FONTS: { OPENOPTIONSDIALOG ood = { sizeof(ood) }; ood.pszGroup = "Customize"; ood.pszPage = "Fonts and colors"; ood.pszTab = NULL; Options_Open(&ood); } break; case IDC_TXT_RADIUS: if ((HIWORD(wParam) == EN_CHANGE) && bInitialized) { RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), NULL, NULL, RDW_INVALIDATE); SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); } break; case IDC_TXT_MAXRECENT: if ((HIWORD(wParam) == EN_CHANGE) && bInitialized) SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); break; } break; case WM_NOTIFY: if ((((LPNMHDR)lParam)->idFrom == 0) && (((LPNMHDR)lParam)->code == PSN_APPLY)) { g_Options.bSecondLine = IsDlgButtonChecked(hwnd, IDC_CHK_SECONDLINE); g_Options.bAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARS); g_Options.bAvatarBorder = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARBORDER); g_Options.bNoTransparentBorder = IsDlgButtonChecked(hwnd, IDC_CHK_NOTRANSPARENTBORDER); g_Options.bSysColors = IsDlgButtonChecked(hwnd, IDC_CHK_SYSCOLORS); g_Options.bCenterHotkey = IsDlgButtonChecked(hwnd, IDC_CHK_CENTERHOTKEY); g_Options.bUseGroups = IsDlgButtonChecked(hwnd, IDC_CHK_GROUPS); g_Options.bUseColumns = IsDlgButtonChecked(hwnd, IDC_CHK_GROUPCOLUMS); g_Options.bRightAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_RIGHTAVATARS); g_Options.bDimIdle = IsDlgButtonChecked(hwnd, IDC_CHK_DIMIDLE); g_Options.wAvatarRadius = GetDlgItemInt(hwnd, IDC_TXT_RADIUS, NULL, FALSE); g_Options.wMaxRecent = GetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, NULL, FALSE); sttSaveOptions(); for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { BYTE fav = SendDlgItemMessage(hwnd, IDC_CLIST, CLM_GETCHECKMARK, SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0), 0); if (fav != db_get_b(hContact, "FavContacts", "IsFavourite", 0)) db_set_b(hContact, "FavContacts", "IsFavourite", fav); if (fav) CallService(MS_AV_GETAVATARBITMAP, hContact, 0); } } else if (((LPNMHDR)lParam)->idFrom == IDC_CLIST) { int iSelection; switch (((LPNMHDR)lParam)->code) { case CLN_OPTIONSCHANGED: sttResetListOptions(GetDlgItem(hwnd, IDC_CLIST)); break; case CLN_NEWCONTACT: iSelection = (int)((NMCLISTCONTROL *)lParam)->hItem; for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { if (SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0) == iSelection) { SendDlgItemMessage(hwnd, IDC_CLIST, CLM_SETCHECKMARK, iSelection, db_get_b(hContact, "FavContacts", "IsFavourite", 0)); break; } } break; case CLN_CHECKCHANGED: iSelection = (int)((NMCLISTCONTROL *)lParam)->hItem; for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { if (SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0) == iSelection) { hSelectedContact = hContact; RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), NULL, NULL, RDW_INVALIDATE); } } SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); } } break; } return FALSE; }
HANDLE CIrcProto::CList_FindContact (CONTACT* user) { if ( !user || !user->name ) return 0; TCHAR* lowercasename = mir_tstrdup( user->name ); CharLower(lowercasename); DBVARIANT dbv1; DBVARIANT dbv2; DBVARIANT dbv3; DBVARIANT dbv4; DBVARIANT dbv5; for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if ( isChatRoom(hContact)) continue; HANDLE hContact_temp = NULL; TCHAR* DBDefault = NULL; TCHAR* DBNick = NULL; TCHAR* DBWildcard = NULL; TCHAR* DBUser = NULL; TCHAR* DBHost = NULL; if ( !getTString(hContact, "Default", &dbv1)) DBDefault = dbv1.ptszVal; if ( !getTString(hContact, "Nick", &dbv2)) DBNick = dbv2.ptszVal; if ( !getTString(hContact, "UWildcard", &dbv3)) DBWildcard = dbv3.ptszVal; if ( !getTString(hContact, "UUser", &dbv4)) DBUser = dbv4.ptszVal; if ( !getTString(hContact, "UHost", &dbv5)) DBHost = dbv5.ptszVal; if ( DBWildcard ) CharLower( DBWildcard ); if ( IsChannel( user->name )) { if ( DBDefault && !lstrcmpi( DBDefault, user->name )) hContact_temp = (HANDLE)-1; } else if ( user->ExactNick && DBNick && !lstrcmpi( DBNick, user->name )) hContact_temp = hContact; else if ( user->ExactOnly && DBDefault && !lstrcmpi( DBDefault, user->name )) hContact_temp = hContact; else if ( user->ExactWCOnly ) { if ( DBWildcard && !lstrcmpi( DBWildcard, lowercasename ) || ( DBWildcard && !lstrcmpi( DBNick, lowercasename ) && !WCCmp( DBWildcard, lowercasename )) || ( !DBWildcard && !lstrcmpi(DBNick, lowercasename))) { hContact_temp = hContact; } } else if ( _tcschr(user->name, ' ' ) == 0 ) { if (( DBDefault && !lstrcmpi(DBDefault, user->name) || DBNick && !lstrcmpi(DBNick, user->name) || DBWildcard && WCCmp( DBWildcard, lowercasename )) && ( WCCmp(DBUser, user->user) && WCCmp(DBHost, user->host))) { hContact_temp = hContact; } } if ( DBDefault ) db_free(&dbv1); if ( DBNick ) db_free(&dbv2); if ( DBWildcard ) db_free(&dbv3); if ( DBUser ) db_free(&dbv4); if ( DBHost ) db_free(&dbv5); if ( hContact_temp != NULL ) { mir_free(lowercasename); if ( hContact_temp != (HANDLE)-1 ) return hContact_temp; return 0; } } mir_free(lowercasename); return 0; }
char* CIcqProto::buildUinList(int subtype, size_t wMaxLen, MCONTACT *hContactResume) { MCONTACT hContact; WORD wCurrentLen = 0; DWORD dwUIN; uid_str szUID; int add; char *szList = (char*)SAFE_MALLOC(CallService(MS_DB_CONTACT_GETCOUNT, 0, 0) * UINMAXLEN); char szLen[2]; szLen[1] = '\0'; if (*hContactResume) hContact = *hContactResume; else hContact = db_find_first(m_szModuleName); while (hContact != NULL) { if (!getContactUid(hContact, &dwUIN, &szUID)) { szLen[0] = (char)mir_strlen(strUID(dwUIN, szUID)); switch (subtype) { case BUL_VISIBLE: add = ID_STATUS_ONLINE == getWord(hContact, "ApparentMode", 0); break; case BUL_INVISIBLE: add = ID_STATUS_OFFLINE == getWord(hContact, "ApparentMode", 0); break; case BUL_TEMPVISIBLE: add = getByte(hContact, "TemporaryVisible", 0); // clear temporary flag // Here we assume that all temporary contacts will be in one packet setByte(hContact, "TemporaryVisible", 0); break; default: add = 1; // If we are in SS mode, we only add those contacts that are // not in our SS list, or are awaiting authorization, to our // client side list if (m_bSsiEnabled && getWord(hContact, DBSETTING_SERVLIST_ID, 0) && !getByte(hContact, "Auth", 0)) add = 0; // Never add hidden contacts to CS list if (db_get_b(hContact, "CList", "Hidden", 0)) add = 0; break; } if (add) { wCurrentLen += szLen[0] + 1; if (wCurrentLen > wMaxLen) { *hContactResume = hContact; return szList; } strcat(szList, szLen); strcat(szList, szUID); } } hContact = db_find_next(hContact, m_szModuleName); } *hContactResume = NULL; return szList; }
INT_PTR CALLBACK DlgProcContactOpts(HWND hwnd, UINT msg, WPARAM, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwnd); SendDlgItemMessage(hwnd, IDC_ICO_AUTO, STM_SETICON, (WPARAM)LoadIconEx(IDI_ACT_OK), 0); SendDlgItemMessage(hwnd, IDC_ICO_FAVORITE, STM_SETICON, (WPARAM)LoadIconEx(IDI_OPT_FAVORITE), 0); SendDlgItemMessage(hwnd, IDC_ICO_FULLSCREEN, STM_SETICON, (WPARAM)LoadIconEx(IDI_OPT_FULLSCREEN), 0); SendDlgItemMessage(hwnd, IDC_ICO_BLOCK, STM_SETICON, (WPARAM)LoadIconEx(IDI_OPT_BLOCK), 0); { HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 5, 5); ImageList_AddIcon(hIml, Skin_LoadIcon(SKINICON_OTHER_SMALLDOT)); ImageList_AddIcon(hIml, LoadIconEx(IDI_ACT_OK)); ImageList_AddIcon(hIml, LoadIconEx(IDI_OPT_FAVORITE)); ImageList_AddIcon(hIml, LoadIconEx(IDI_OPT_FULLSCREEN)); ImageList_AddIcon(hIml, LoadIconEx(IDI_OPT_BLOCK)); SendDlgItemMessage(hwnd, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml); SendDlgItemMessage(hwnd, IDC_LIST, CLM_SETEXTRACOLUMNS, 4 /*_countof(sttIcons)*/, 0); sttResetListOptions(GetDlgItem(hwnd, IDC_LIST)); sttSetAllContactIcons(GetDlgItem(hwnd, IDC_LIST)); } break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case IDC_LIST: switch (((LPNMHDR)lParam)->code) { case CLN_NEWCONTACT: case CLN_LISTREBUILT: sttSetAllContactIcons(GetDlgItem(hwnd, IDC_LIST)); break; case CLN_OPTIONSCHANGED: sttResetListOptions(GetDlgItem(hwnd, IDC_LIST)); break; case NM_CLICK: NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam; if (nm->iColumn == -1) break; DWORD hitFlags; HANDLE hItem = (HANDLE)SendDlgItemMessage(hwnd, IDC_LIST, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y)); if (hItem == NULL) break; if (!(hitFlags&CLCHT_ONITEMEXTRA)) break; int iImage = SendDlgItemMessage(hwnd, IDC_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, 0)); if (iImage != EMPTY_EXTRA_ICON) { for (int i = 0; i < 4 /*_countof(sttIcons)*/; ++i) // hIml element [0] = SKINICON_OTHER_SMALLDOT // hIml element [1..5] = IcoLib_GetIcon(....) ~ old sttIcons SendDlgItemMessage(hwnd, IDC_LIST, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, (i == nm->iColumn) ? i + 1 : 0)); } SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); } break; case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: HWND hwndList = GetDlgItem(hwnd, IDC_LIST); for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0); for (int i = 0; i < 4 /*_countof(sttIcons)*/; ++i) { if (SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, 0))) { db_set_b(hContact, MODULNAME, "ShowMode", i); break; } } } return TRUE; } } break; } return FALSE; }
ClcGroup* fnAddGroup(HWND hwnd, ClcData *dat, const TCHAR *szName, DWORD flags, int groupId, int calcTotalMembers) { dat->bNeedsResort = true; if (!(GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_USEGROUPS)) return &dat->list; ClcGroup *group = &dat->list; TCHAR *pNextField = NEWTSTR_ALLOCA(szName); do { TCHAR *pBackslash = _tcschr(pNextField, '\\'), *pThisField = pNextField; if (pBackslash == NULL) { pNextField = NULL; } else { *pBackslash = 0; pNextField = pBackslash + 1; } int i, compareResult = 1; for (i = 0; i < group->cl.getCount(); i++) { ClcContact *cc = group->cl[i]; if (cc->type == CLCIT_CONTACT) break; if (cc->type != CLCIT_GROUP) continue; compareResult = mir_tstrcmp(pThisField, cc->szText); if (compareResult == 0) { if (pNextField == NULL && flags != (DWORD)-1) { cc->groupId = (WORD)groupId; group = cc->group; group->expanded = (flags & GROUPF_EXPANDED) != 0; group->hideOffline = (flags & GROUPF_HIDEOFFLINE) != 0; group->groupId = groupId; } else group = cc->group; break; } if (pNextField == NULL && cc->groupId == 0) break; if (!(dat->exStyle & CLS_EX_SORTGROUPSALPHA) && groupId && cc->groupId > groupId) break; } if (compareResult) { // not found if (groupId == 0) return NULL; ClcContact *cc = cli.pfnAddItemToGroup(group, i); cc->type = CLCIT_GROUP; mir_tstrncpy(cc->szText, pThisField, _countof(cc->szText)); cc->groupId = (WORD)(pNextField ? 0 : groupId); cc->group = new ClcGroup(10); cc->group->parent = group; group = cc->group; if (flags == (DWORD)-1 || pNextField != NULL) { group->expanded = 0; group->hideOffline = 0; } else { group->expanded = (flags & GROUPF_EXPANDED) != 0; group->hideOffline = (flags & GROUPF_HIDEOFFLINE) != 0; } group->groupId = pNextField ? 0 : groupId; group->totalMembers = 0; if (flags != (DWORD)-1 && pNextField == NULL && calcTotalMembers) { DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE); for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { ClcCacheEntry *cache = cli.pfnGetCacheEntry(hContact); if (!mir_tstrcmp(cache->tszGroup, szName) && (style & CLS_SHOWHIDDEN || !cache->bIsHidden)) group->totalMembers++; } } } } while (pNextField); return group; }
std::string FacebookProto::ThreadIDToContactID(const std::string &thread_id) { if (thread_id.empty()) { debugLogA("!!! Calling ThreadIDToContactID() with empty thread_id"); return ""; } // First check cache std::map<std::string, std::string>::iterator it = facy.thread_id_to_user_id.find(thread_id); if (it != facy.thread_id_to_user_id.end()) { return it->second; } // Go through all local contacts for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if (!IsMyContact(hContact)) continue; ptrA tid(getStringA(hContact, FACEBOOK_KEY_TID)); if (tid && !mir_strcmp(tid, thread_id.c_str())) { ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); std::string user_id = (id ? id : ""); if (!user_id.empty()) { facy.thread_id_to_user_id.insert(std::make_pair(thread_id, user_id)); return user_id; } break; // this shouldn't happen unless user manually deletes ID from FB contact in DB } } // We don't have any contact with this thread_id cached, we must ask server if (isOffline()) return ""; std::string data = "client=mercury"; data += "&__user="******"&__dyn=" + facy.__dyn(); data += "&__req=" + facy.__req(); data += "&fb_dtsg=" + facy.dtsg_; data += "&ttstamp=" + facy.ttstamp_; data += "&__rev=" + facy.__rev(); data += "&threads[thread_ids][0]=" + utils::url::encode(thread_id); std::string user_id; http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); // NOTE: Request revised 1.9.2015 if (resp.code == HTTP_CODE_OK) { CODE_BLOCK_TRY facebook_json_parser* p = new facebook_json_parser(this); p->parse_thread_info(&resp.data, &user_id); delete p; if (!user_id.empty()) facy.thread_id_to_user_id.insert(std::make_pair(thread_id, user_id)); debugLogA("*** Thread info processed"); CODE_BLOCK_CATCH debugLogA("*** Error processing thread info: %s", e.what()); CODE_BLOCK_END }
int CMraProto::SetStatus(int iNewStatus) { // remap global statuses to local supported switch (iNewStatus) { case ID_STATUS_OCCUPIED: iNewStatus = ID_STATUS_DND; break; case ID_STATUS_NA: case ID_STATUS_ONTHEPHONE: case ID_STATUS_OUTTOLUNCH: iNewStatus = ID_STATUS_AWAY; break; } // nothing to change if (m_iStatus == iNewStatus) return 0; DWORD dwOldStatusMode; //set all contacts to offline if ((m_iDesiredStatus = iNewStatus) == ID_STATUS_OFFLINE) { m_bLoggedIn = FALSE; dwOldStatusMode = InterlockedExchange((volatile LONG*)&m_iStatus, m_iDesiredStatus); // всех в offline, только если мы бывали подключены if (dwOldStatusMode > ID_STATUS_OFFLINE) for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, (SCBIF_ID | SCBIF_GROUP_ID | SCBIF_SERVER_FLAG | SCBIF_STATUS), -1, -1, 0, 0, ID_STATUS_OFFLINE, 0, 0, 0); NETLIB_CLOSEHANDLE(m_hConnection); } else { // если offline то сразу ставим connecting, но обработка как offline dwOldStatusMode = InterlockedCompareExchange((volatile LONG*)&m_iStatus, ID_STATUS_CONNECTING, ID_STATUS_OFFLINE); switch (dwOldStatusMode) { case ID_STATUS_OFFLINE: // offline, connecting if (StartConnect() != NO_ERROR) { m_bLoggedIn = FALSE; m_iDesiredStatus = ID_STATUS_OFFLINE; dwOldStatusMode = InterlockedExchange((volatile LONG*)&m_iStatus, m_iDesiredStatus); } break; case ID_STATUS_ONLINE:// connected, change status case ID_STATUS_AWAY: case ID_STATUS_DND: case ID_STATUS_FREECHAT: case ID_STATUS_INVISIBLE: MraSendNewStatus(m_iDesiredStatus, m_iXStatus, _T(""), _T("")); case ID_STATUS_CONNECTING: // предотвращаем переход в любой статус (кроме offline) из статуса connecting, если он не вызван самим плагином if (dwOldStatusMode == ID_STATUS_CONNECTING && iNewStatus != m_iDesiredStatus) break; default: dwOldStatusMode = InterlockedExchange((volatile LONG*)&m_iStatus, m_iDesiredStatus); break; } } MraSetContactStatus(NULL, m_iStatus); ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)dwOldStatusMode, m_iStatus); return 0; }
void CVkInviteChatForm::OnInitDialog() { for (MCONTACT hContact = db_find_first(m_proto->m_szModuleName); hContact; hContact = db_find_next(hContact, m_proto->m_szModuleName)) { if (!m_proto->isChatRoom(hContact)) { TCHAR *ptszNick = pcli->pfnGetContactDisplayName(hContact, 0); m_cbxCombo.AddString(ptszNick, hContact); } } }
void CLC::RebuildEntireList(HWND hwnd, ClcData *dat) { char *szProto; DWORD style = GetWindowLong(hwnd, GWL_STYLE); MCONTACT hContact; ClcGroup *group; DBVARIANT dbv = {0}; RowHeight::Clear(dat); RowHeight::getMaxRowHeight(dat, hwnd); dat->list.expanded = 1; dat->list.hideOffline = cfg::getByte("CLC", "HideOfflineRoot", 0); dat->list.cl.count = 0; dat->list.totalMembers = 0; dat->selection = -1; dat->SelectMode = cfg::getByte("CLC", "SelectMode", 0); { int i; wchar_t *szGroupName; DWORD groupFlags; for (i = 1; ; i++) { szGroupName = pcli->pfnGetGroupName(i, &groupFlags); if (szGroupName == NULL) break; pcli->pfnAddGroup(hwnd, dat, szGroupName, groupFlags, i, 0); } } hContact = db_find_first(); while (hContact) { if (style & CLS_SHOWHIDDEN || !CLVM_GetContactHiddenStatus(hContact, NULL, dat)) { ZeroMemory((void *)&dbv, sizeof(dbv)); if (cfg::getTString(hContact, "CList", "Group", &dbv)) group = &dat->list; else { group = pcli->pfnAddGroup(hwnd, dat, dbv.ptszVal, (DWORD) - 1, 0, 0); mir_free(dbv.ptszVal); } if (group != NULL) { group->totalMembers++; if (!(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) { szProto = GetContactProto(hContact); if (szProto == NULL) { if (!pcli->pfnIsHiddenMode(dat, ID_STATUS_OFFLINE)) AddContactToGroup(dat, group, hContact); } else if (!pcli->pfnIsHiddenMode(dat, (WORD) cfg::getWord(hContact, szProto, "Status", ID_STATUS_OFFLINE))) AddContactToGroup(dat, group, hContact); } else AddContactToGroup(dat, group, hContact); } } hContact = db_find_next(hContact); } if (style & CLS_HIDEEMPTYGROUPS) { group = &dat->list; group->scanIndex = 0; for (; ;) { if (group->scanIndex == group->cl.count) { group = group->parent; if (group == NULL) break; } else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) { if (group->cl.items[group->scanIndex]->group->cl.count == 0) { group = pcli->pfnRemoveItemFromGroup(hwnd, group, group->cl.items[group->scanIndex], 0); } else { group = group->cl.items[group->scanIndex]->group; group->scanIndex = 0; } continue; } group->scanIndex++; } } pcli->pfnSortCLC(hwnd, dat, 0); pcli->pfnSetAllExtraIcons(NULL); if(!dat->bisEmbedded) FLT_SyncWithClist(); }
CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) : PROTO<CMsnProto>(aProtoName, aUserName), m_arContacts(10, CompareLists), m_arGroups(10, CompareId), m_arThreads(10, PtrKeySortT), m_arGCThreads(10, PtrKeySortT), #ifdef OBSOLETE m_arSessions(10, PtrKeySortT), m_arDirect(10, PtrKeySortT), #endif lsMessageQueue(1), lsAvatarQueue(1), msgCache(5, CompareId) { db_set_resident(m_szModuleName, "IdleTS"); db_set_resident(m_szModuleName, "p2pMsgId"); db_set_resident(m_szModuleName, "MobileEnabled"); db_set_resident(m_szModuleName, "MobileAllowed"); // Protocol services and events... CreateProtoService(PS_CREATEACCMGRUI, &CMsnProto::SvcCreateAccMgrUI); CreateProtoService(PS_GETAVATARINFO, &CMsnProto::GetAvatarInfo); CreateProtoService(PS_GETMYAWAYMSG, &CMsnProto::GetMyAwayMsg); CreateProtoService(PS_LEAVECHAT, &CMsnProto::OnLeaveChat); CreateProtoService(PS_GETMYAVATAR, &CMsnProto::GetAvatar); CreateProtoService(PS_SETMYAVATAR, &CMsnProto::SetAvatar); CreateProtoService(PS_GETAVATARCAPS, &CMsnProto::GetAvatarCaps); CreateProtoService(PS_SETMYNICKNAME, &CMsnProto::SetNickName); #ifdef OBSOLETE CreateProtoService(PS_GET_LISTENINGTO, &CMsnProto::GetCurrentMedia); CreateProtoService(PS_SET_LISTENINGTO, &CMsnProto::SetCurrentMedia); MsgQueue_Init(); #endif hMSNNudge = CreateProtoEvent("/Nudge"); CreateProtoService(PS_SEND_NUDGE, &CMsnProto::SendNudge); CreateProtoService(PS_GETUNREADEMAILCOUNT, &CMsnProto::GetUnreadEmailCount); // event hooks HookProtoEvent(ME_MSG_WINDOWPOPUP, &CMsnProto::OnWindowPopup); HookProtoEvent(ME_CLIST_GROUPCHANGE, &CMsnProto::OnGroupChange); HookProtoEvent(ME_OPT_INITIALISE, &CMsnProto::OnOptionsInit); HookProtoEvent(ME_CLIST_DOUBLECLICKED, &CMsnProto::OnContactDoubleClicked); LoadOptions(); for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { delSetting(hContact, "Status"); delSetting(hContact, "IdleTS"); delSetting(hContact, "p2pMsgId"); delSetting(hContact, "AccList"); } delSetting("MobileEnabled"); delSetting("MobileAllowed"); char path[MAX_PATH]; if (db_get_static(NULL, m_szModuleName, "LoginServer", path, sizeof(path)) == 0 && (mir_strcmp(path, MSN_DEFAULT_LOGIN_SERVER) == 0 || mir_strcmp(path, MSN_DEFAULT_GATEWAY) == 0)) delSetting("LoginServer"); if (MyOptions.SlowSend) { if (db_get_dw(NULL, "SRMsg", "MessageTimeout", 10000) < 60000) db_set_dw(NULL, "SRMsg", "MessageTimeout", 60000); if (db_get_dw(NULL, "SRMM", "MessageTimeout", 10000) < 60000) db_set_dw(NULL, "SRMM", "MessageTimeout", 60000); } mailsoundname = (char*)mir_alloc(64); mir_snprintf(mailsoundname, 64, "%s:Hotmail", m_szModuleName); SkinAddNewSoundExT(mailsoundname, m_tszUserName, LPGENT("Live Mail")); alertsoundname = (char*)mir_alloc(64); mir_snprintf(alertsoundname, 64, "%s:Alerts", m_szModuleName); SkinAddNewSoundExT(alertsoundname, m_tszUserName, LPGENT("Live Alert")); AvatarQueue_Init(); InitCustomFolders(); TCHAR szBuffer[MAX_PATH]; char szDbsettings[64]; NETLIBUSER nlu1 = { 0 }; nlu1.cbSize = sizeof(nlu1); nlu1.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR; nlu1.szSettingsModule = szDbsettings; nlu1.ptszDescriptiveName = szBuffer; mir_snprintf(szDbsettings, _countof(szDbsettings), "%s_HTTPS", m_szModuleName); mir_sntprintf(szBuffer, TranslateT("%s plugin HTTPS connections"), m_tszUserName); hNetlibUserHttps = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu1); NETLIBUSER nlu = { 0 }; nlu.cbSize = sizeof(nlu); nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR; nlu.szSettingsModule = m_szModuleName; nlu.ptszDescriptiveName = szBuffer; nlu.szHttpGatewayUserAgent = (char*)MSN_USER_AGENT; nlu.pfnHttpGatewayInit = msn_httpGatewayInit; nlu.pfnHttpGatewayWrapSend = msn_httpGatewayWrapSend; nlu.pfnHttpGatewayUnwrapRecv = msn_httpGatewayUnwrapRecv; mir_sntprintf(szBuffer, TranslateT("%s plugin connections"), m_tszUserName); m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); m_DisplayNameCache = NULL; }
/* * callback function for tab 2 options page */ INT_PTR CALLBACK DlgProcOpts_Tab2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static HANDLE hItemAll; switch ( msg ) { case WM_INITDIALOG: { TranslateDialogDefault(hwndDlg); mirfoxMiranda.getMirfoxData().setTab2OptionsState(MFENUM_OPTIONS_INIT); //load icons HIMAGELIST hIml; int smCx = GetSystemMetrics(SM_CXSMICON); int smCy = GetSystemMetrics(SM_CYSMICON); hIml = ImageList_Create(smCx,smCy,((LOBYTE(LOWORD(GetVersion()))>=5 && LOWORD(GetVersion())!=5) ? ILC_COLOR32 : ILC_COLOR16) | ILC_MASK, 4, 4); //load icons (direct) icoHandle_ICON_OFF = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_OFF)); icoHandle_ICON_FF = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_FF)); //add icons to ImageList list ImageList_AddIcon(hIml, icoHandle_ICON_OFF); ImageList_AddIcon(hIml, icoHandle_ICON_FF); SendDlgItemMessage(hwndDlg, IDC2_CONTACTS_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml); //m_clc.h //list params init resetListOptions(GetDlgItem(hwndDlg, IDC2_CONTACTS_LIST)); SendDlgItemMessage(hwndDlg, IDC2_CONTACTS_LIST, CLM_SETEXTRACOLUMNS, 1, 0); //add 'All contacts' list record { CLCINFOITEM cii = {0}; cii.cbSize = sizeof(cii); cii.flags = CLCIIF_GROUPFONT; cii.pszText =TranslateT("** All contacts **"); hItemAll = (HANDLE)SendDlgItemMessage(hwndDlg, IDC2_CONTACTS_LIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); } //set contacts and groups icons setListContactIcons(GetDlgItem(hwndDlg, IDC2_CONTACTS_LIST)); setListGroupIcons(GetDlgItem(hwndDlg, IDC2_CONTACTS_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC2_CONTACTS_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL); mirfoxMiranda.getMirfoxData().setTab2OptionsState(MFENUM_OPTIONS_WORK); return FALSE; } case WM_SETFOCUS: SetFocus(GetDlgItem(hwndDlg, IDC2_CONTACTS_LIST)); break; case WM_NOTIFY: if (mirfoxMiranda.getMirfoxData().getTab2OptionsState() != MFENUM_OPTIONS_WORK){ break; //options not inited yet } switch(((LPNMHDR)lParam)->idFrom) { case IDC2_CONTACTS_LIST: switch (((LPNMHDR)lParam)->code){ case CLN_NEWCONTACT: case CLN_LISTREBUILT: setListContactIcons(GetDlgItem(hwndDlg, IDC2_CONTACTS_LIST)); //fall through case CLN_CONTACTMOVED: setListGroupIcons(GetDlgItem(hwndDlg, IDC2_CONTACTS_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC2_CONTACTS_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL); break; case CLN_OPTIONSCHANGED: resetListOptions(GetDlgItem(hwndDlg, IDC2_CONTACTS_LIST)); break; case NM_CLICK: { NMCLISTCONTROL *nm=(NMCLISTCONTROL*)lParam; // Make sure we have an extra column if (nm->iColumn == -1){ break; } // Find clicked item DWORD hitFlags; HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC2_CONTACTS_LIST, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y)); // Nothing was clicked if (hItem == NULL){ break; } // It was not a visbility icon if (!(hitFlags & CLCHT_ONITEMEXTRA)){ break; } // Get image in clicked column (0=off, 1=on) int iImage = SendDlgItemMessage(hwndDlg, IDC2_CONTACTS_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, 0)); if (iImage == 0){ iImage=nm->iColumn + 1; } else { if (iImage == 1){ iImage = 0; } } // Get item type (contact, group, etc...) int itemType = SendDlgItemMessage(hwndDlg, IDC2_CONTACTS_LIST, CLM_GETITEMTYPE, (WPARAM)hItem, 0); // Update list if (itemType == CLCIT_CONTACT) { // A contact SendDlgItemMessage(hwndDlg, IDC2_CONTACTS_LIST, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, iImage)); } else if (itemType == CLCIT_INFO) { // All Contacts setAllChildIcons(GetDlgItem(hwndDlg, IDC2_CONTACTS_LIST), hItem, nm->iColumn, iImage); } else if (itemType == CLCIT_GROUP) { // A group hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC2_CONTACTS_LIST, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); if (hItem) { setAllChildIcons(GetDlgItem(hwndDlg, IDC2_CONTACTS_LIST), hItem, nm->iColumn, iImage); } } // Update the all/none icons setListGroupIcons(GetDlgItem(hwndDlg, IDC2_CONTACTS_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC2_CONTACTS_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL); // Activate Apply button SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; }//end case NM_CLICK }//end switch break; case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: { for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)){ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC2_CONTACTS_LIST, CLM_FINDCONTACT, hContact, 0); if(hItem) { int iImage = SendDlgItemMessage(hwndDlg, IDC2_CONTACTS_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0,0)); MFENUM_MIRANDACONTACT_STATE contactState; if (iImage == EMPTY_EXTRA_ICON){ //TODO impossible?? } else { if (iImage == 1){ contactState = MFENUM_MIRANDACONTACT_STATE_ON; } else { contactState = MFENUM_MIRANDACONTACT_STATE_OFF; } } //save to mirfoxData int result = mirfoxMiranda.getMirfoxData().updateMirandaContactState(hContact, contactState); if (result != 0){ //todo errors handling } //save to db 1 - on, 2 - off if (contactState == MFENUM_MIRANDACONTACT_STATE_OFF){ db_set_b(hContact, PLUGIN_DB_ID, "state", 2); } else { db_set_b(hContact, PLUGIN_DB_ID, "state", 1); } }//TODO else { ... (and at others if(hItem)) //TODO contacts witch are not ay mirfoxData but on list //( check hash concat(all id) on mirfoxData and on list, if doesn't match - refresh mirfoxData //same for protocols //for now it schould be ok } //TODO contacts at MirfoxData but not on list now return TRUE; } } break; } break; case WM_DESTROY: { HIMAGELIST hIml=(HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC2_CONTACTS_LIST, CLM_GETEXTRAIMAGELIST, 0, 0); //m_clc.h ImageList_Destroy(hIml); // use DestroyIcon only witchout icolib DestroyIcon(icoHandle_ICON_OFF); icoHandle_ICON_OFF = NULL; DestroyIcon(icoHandle_ICON_FF); icoHandle_ICON_FF = NULL; break; } }//end switch return 0; }
static void RemoveExtraIcons(int slot) { for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) Clist_SetExtraIcon(hContact, slot, INVALID_HANDLE_VALUE); }
void cliRebuildEntireList(HWND hwnd, ClcData *dat) { DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE); ClcContact *cont; ClcGroup *group; static int rebuildCounter = 0; BOOL PlaceOfflineToRoot = db_get_b(NULL, "CList", "PlaceOfflineToRoot", SETTING_PLACEOFFLINETOROOT_DEFAULT); KillTimer(hwnd, TIMERID_REBUILDAFTER); ClearRowByIndexCache(); ImageArray_Clear(&dat->avatar_cache); RowHeights_Clear(dat); RowHeights_GetMaxRowHeight(dat, hwnd); TRACEVAR("Rebuild Entire List %d times\n", ++rebuildCounter); dat->list.expanded = 1; dat->list.hideOffline = db_get_b(NULL, "CLC", "HideOfflineRoot", SETTING_HIDEOFFLINEATROOT_DEFAULT) && style&CLS_USEGROUPS; dat->list.cl.count = dat->list.cl.limit = 0; dat->list.cl.increment = 50; dat->needsResort = 1; MCONTACT hSelected = SaveSelection(dat); dat->selection = -1; dat->HiLightMode = db_get_b(NULL, "CLC", "HiLightMode", SETTING_HILIGHTMODE_DEFAULT); { for (int i = 1;; i++) { DWORD groupFlags; TCHAR *szGroupName = pcli->pfnGetGroupName(i, &groupFlags); //UNICODE if (szGroupName == NULL) break; cli_AddGroup(hwnd, dat, szGroupName, groupFlags, i, 0); } } for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { ClcCacheEntry *cacheEntry = NULL; cont = NULL; cacheEntry = pcli->pfnGetCacheEntry(hContact); int nHiddenStatus = CLVM_GetContactHiddenStatus(hContact, NULL, dat); if ((style & CLS_SHOWHIDDEN && nHiddenStatus != -1) || !nHiddenStatus) { if (lstrlen(cacheEntry->tszGroup) == 0) group = &dat->list; else group = cli_AddGroup(hwnd, dat, cacheEntry->tszGroup, (DWORD)-1, 0, 0); if (group != NULL) { WORD wStatus = pdnce___GetStatus(cacheEntry); if (wStatus == ID_STATUS_OFFLINE) if (PlaceOfflineToRoot) group = &dat->list; group->totalMembers++; if (!(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) { if (cacheEntry->m_cache_cszProto == NULL) { if (!pcli->pfnIsHiddenMode(dat, ID_STATUS_OFFLINE) || cacheEntry->m_cache_nNoHiddenOffline || CLCItems_IsShowOfflineGroup(group)) cont = AddContactToGroup(dat, group, cacheEntry); } else if (!pcli->pfnIsHiddenMode(dat, wStatus) || cacheEntry->m_cache_nNoHiddenOffline || CLCItems_IsShowOfflineGroup(group)) cont = AddContactToGroup(dat, group, cacheEntry); } else cont = AddContactToGroup(dat, group, cacheEntry); } } if (cont) { cont->SubAllocated = 0; if (cont->proto && dat->IsMetaContactsEnabled && strcmp(cont->proto, META_PROTO) == 0) AddSubcontacts(dat, cont, CLCItems_IsShowOfflineGroup(group)); } } if (style & CLS_HIDEEMPTYGROUPS) { group = &dat->list; group->scanIndex = 0; for (;;) { if (group->scanIndex == group->cl.count) { group = group->parent; if (group == NULL) break; } else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) { if (group->cl.items[group->scanIndex]->group->cl.count == 0) { group = pcli->pfnRemoveItemFromGroup(hwnd, group, group->cl.items[group->scanIndex], 0); } else { group = group->cl.items[group->scanIndex]->group; group->scanIndex = 0; } continue; } group->scanIndex++; } } pcli->pfnSortCLC(hwnd, dat, 0); RestoreSelection(dat, hSelected); }
static MEVENT findDbEvent(MCONTACT hContact, MEVENT hDbEvent, int flags) { DBEVENTINFO dbe; BOOL bEventOk; do { memset(&dbe, 0, sizeof(DBEVENTINFO)); dbe.cbSize = sizeof(DBEVENTINFO); dbe.cbBlob = 0; dbe.pBlob = NULL; if (hContact != NULL) { if ((flags & DBE_FIRST) && (flags & DBE_UNREAD)) { hDbEvent = db_event_firstUnread(hContact); if (hDbEvent == NULL && (flags & DBE_READ)) hDbEvent = db_event_first(hContact); } else if (flags & DBE_FIRST) hDbEvent = db_event_first(hContact); else if (flags & DBE_LAST) hDbEvent = db_event_last(hContact); else if (flags & DBE_NEXT) hDbEvent = db_event_next(hContact, hDbEvent); else if (flags & DBE_PREV) hDbEvent = db_event_prev(hContact, hDbEvent); } else { MEVENT hMatchEvent = NULL, hSearchEvent = NULL; DWORD matchTimestamp = 0, priorTimestamp = 0; if (flags & DBE_FIRST) { for (MCONTACT hSearchContact = db_find_first(); hSearchContact; hSearchContact = db_find_next(hSearchContact)) { hSearchEvent = findDbEvent(hSearchContact, NULL, flags); dbe.cbBlob = 0; if (!db_event_get(hSearchEvent, &dbe)) { if ((dbe.timestamp < matchTimestamp) || (matchTimestamp == 0)) { hMatchEvent = hSearchEvent; matchTimestamp = dbe.timestamp; } } } hDbEvent = hMatchEvent; } else if (flags & DBE_LAST) { for (MCONTACT hSearchContact = db_find_first(); hSearchContact; hSearchContact = db_find_next(hSearchContact)) { hSearchEvent = findDbEvent(hSearchContact, NULL, flags); dbe.cbBlob = 0; if (!db_event_get(hSearchEvent, &dbe)) { if ((dbe.timestamp > matchTimestamp) || (matchTimestamp == 0)) { hMatchEvent = hSearchEvent; matchTimestamp = dbe.timestamp; } } } hDbEvent = hMatchEvent; } else if (flags & DBE_NEXT) { dbe.cbBlob = 0; if (!db_event_get(hDbEvent, &dbe)) { priorTimestamp = dbe.timestamp; for (MCONTACT hSearchContact = db_find_first(); hSearchContact; hSearchContact = db_find_next(hSearchContact)) { hSearchEvent = findDbEvent(hSearchContact, hDbEvent, flags); dbe.cbBlob = 0; if (!db_event_get(hSearchEvent, &dbe)) { if (((dbe.timestamp < matchTimestamp) || (matchTimestamp == 0)) && (dbe.timestamp > priorTimestamp)) { hMatchEvent = hSearchEvent; matchTimestamp = dbe.timestamp; } } } hDbEvent = hMatchEvent; } } else if (flags & DBE_PREV) { if (!db_event_get(hDbEvent, &dbe)) { priorTimestamp = dbe.timestamp; for (MCONTACT hSearchContact = db_find_first(); hSearchContact; hSearchContact = db_find_next(hSearchContact)) { hSearchEvent = findDbEvent(hSearchContact, hDbEvent, flags); dbe.cbBlob = 0; if (!db_event_get(hSearchEvent, &dbe)) { if (((dbe.timestamp > matchTimestamp) || (matchTimestamp == 0)) && (dbe.timestamp < priorTimestamp)) { hMatchEvent = hSearchEvent; matchTimestamp = dbe.timestamp; } } } hDbEvent = hMatchEvent; } } } dbe.cbBlob = 0; if (db_event_get(hDbEvent, &dbe)) bEventOk = FALSE; else bEventOk = isValidDbEvent(&dbe, flags); if (!bEventOk) { if (flags&DBE_FIRST) { flags |= DBE_NEXT; flags &= ~DBE_FIRST; } else if (flags&DBE_LAST) { flags |= DBE_PREV; flags &= ~DBE_LAST; } } } while ((!bEventOk) && (hDbEvent != NULL)); return hDbEvent; }
// erase all current weather information from database // lastver = the last used version number in dword (using PLUGIN_MAKE_VERSION) void EraseAllInfo() { TCHAR str[255]; int ContactCount = 0; MCONTACT LastContact = NULL; DBVARIANT dbv; // loop through all contacts for (MCONTACT hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME)) { db_set_w(hContact, WEATHERPROTONAME, "Status", ID_STATUS_OFFLINE); db_set_w(hContact, WEATHERPROTONAME, "StatusIcon", ID_STATUS_OFFLINE); db_unset(hContact, "CList", "MyHandle"); // clear all data if (db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) { db_set_ts(hContact, WEATHERPROTONAME, "Nick", TranslateT("<Enter city name here>")); db_set_s(hContact, WEATHERPROTONAME, "LastLog", "never"); db_set_s(hContact, WEATHERPROTONAME, "LastCondition", "None"); db_set_s(hContact, WEATHERPROTONAME, "LastTemperature", "None"); } else db_free(&dbv); DBDataManage(hContact, WDBM_REMOVE, 0, 0); db_set_s(hContact, "UserInfo", "MyNotes", ""); // reset update tag db_set_b(hContact, WEATHERPROTONAME, "IsUpdated", FALSE); // reset logging settings if (!db_get_ts(hContact, WEATHERPROTONAME, "Log", &dbv)) { db_set_b(hContact, WEATHERPROTONAME, "File", (BYTE)(dbv.ptszVal[0] != 0)); db_free(&dbv); } else db_set_b(hContact, WEATHERPROTONAME, "File", FALSE); // if no default station find, assign a new one if (opt.Default[0] == 0) { GetStationID(hContact, opt.Default, _countof(opt.Default)); opt.DefStn = hContact; if (!db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) { mir_sntprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal); db_free(&dbv); MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION); } } // get the handle of the default station if (opt.DefStn == NULL) { if (!db_get_ts(hContact, WEATHERPROTONAME, "ID", &dbv)) { if (!mir_tstrcmp(dbv.ptszVal, opt.Default)) opt.DefStn = hContact; db_free(&dbv); } } ContactCount++; // increment counter LastContact = hContact; } // if weather contact exists, set the status to online so it is ready for update // if (ContactCount != 0) status = ONLINE; // in case where the default station is missing if (opt.DefStn == NULL && ContactCount != 0) { if (!db_get_ts(LastContact, WEATHERPROTONAME, "ID", &dbv)) { _tcsncpy(opt.Default, dbv.ptszVal, _countof(opt.Default) - 1); db_free(&dbv); } opt.DefStn = LastContact; if (!db_get_ts(LastContact, WEATHERPROTONAME, "Nick", &dbv)) { mir_sntprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal); db_free(&dbv); MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION); } } // save option in case of default station changed db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default); }
void MF_UpdateThread(LPVOID) { HANDLE hEvent = OpenEvent(EVENT_ALL_ACCESS, FALSE, g_ptszEventName); WaitForSingleObject(hEvent, 20000); ResetEvent(hEvent); while (mf_updatethread_running) { for (MCONTACT hContact = db_find_first(); hContact && mf_updatethread_running; hContact = db_find_next(hContact)) { MF_CalcFrequency(hContact, 50, 1); if (mf_updatethread_running) WaitForSingleObject(hEvent, 5000); ResetEvent(hEvent); } if (mf_updatethread_running) WaitForSingleObject(hEvent, 1000000); ResetEvent(hEvent); } CloseHandle(hEvent); }
void CSkypeGCCreateDlg::btnOk_OnOk(CCtrlButton*) { for (MCONTACT hContact = db_find_first(m_proto->m_szModuleName); hContact; hContact = db_find_next(hContact, m_proto->m_szModuleName)) { if (!m_proto->isChatRoom(hContact)) { if (HANDLE hItem = m_clc.FindContact(hContact)) { if (m_clc.GetCheck(hItem)) { char *szName = db_get_sa(hContact, m_proto->m_szModuleName, SKYPE_SETTINGS_ID); if (szName != NULL) m_ContactsList.insert(szName); } } } } m_ContactsList.insert(m_proto->li.szSkypename); EndDialog(m_hwnd, m_ContactsList.getCount()); }
void RebuildEntireList(HWND hwnd,struct ClcData *dat) { // char *szProto; DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE); struct ClcContact * cont; ClcGroup *group; //DBVARIANT dbv; int tick = GetTickCount(); ClearRowByIndexCache(); ClearClcContactCache(dat,INVALID_HANDLE_VALUE); dat->list.expanded = 1; dat->list.hideOffline = db_get_b(NULL,"CLC","HideOfflineRoot",0); memset( &dat->list.cl, 0, sizeof( dat->list.cl )); dat->list.cl.increment = 30; dat->needsResort = 1; dat->selection = -1; { int i; TCHAR *szGroupName; DWORD groupFlags; for (i = 1;;i++) { szGroupName = pcli->pfnGetGroupName(i,&groupFlags); if (szGroupName == NULL) break; AddGroup(hwnd,dat,szGroupName,groupFlags,i,0); } } for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { ClcCacheEntry *cacheEntry; cont = NULL; cacheEntry = GetContactFullCacheEntry(hContact); //cacheEntry->ClcContact = NULL; ClearClcContactCache(dat,hContact); if (cacheEntry == NULL) MessageBoxA(0,"Fail To Get CacheEntry for hContact","!!!!!!!!",0); if (style&CLS_SHOWHIDDEN || !cacheEntry->bIsHidden) { if (lstrlen(cacheEntry->tszGroup) == 0) group = &dat->list; else { group = AddGroup(hwnd,dat,cacheEntry->tszGroup,(DWORD)-1,0,0); //mir_free(dbv.pszVal); } if (group != NULL) { group->totalMembers++; if ( !(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) { if (cacheEntry->szProto == NULL) { if ( !pcli->pfnIsHiddenMode(dat,ID_STATUS_OFFLINE)||cacheEntry->noHiddenOffline) cont = AddContactToGroup(dat,group,cacheEntry); } else if ( !pcli->pfnIsHiddenMode(dat,cacheEntry->status)||cacheEntry->noHiddenOffline) cont = AddContactToGroup(dat,group,cacheEntry); } else cont = AddContactToGroup(dat,group,cacheEntry); } } if (cont && cont->proto) { cont->SubAllocated = 0; if (strcmp(cont->proto,"MetaContacts") == 0) AddSubcontacts(cont); } } if (style&CLS_HIDEEMPTYGROUPS) { group = &dat->list; group->scanIndex = 0; for (;;) { if (group->scanIndex == group->cl.count) { group = group->parent; if (group == NULL) break; } else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) { if (group->cl.items[group->scanIndex]->group->cl.count == 0) { group = RemoveItemFromGroup(hwnd,group,group->cl.items[group->scanIndex],0); } else { group = group->cl.items[group->scanIndex]->group; group->scanIndex = 0; } continue; } group->scanIndex++; } } SortCLC(hwnd,dat,0); tick = GetTickCount()-tick; { char buf[255]; //sprintf(buf,"%s %s took %i ms",__FILE__,__LINE__,tick); mir_snprintf(buf, SIZEOF(buf), "RebuildEntireList %d \r\n", tick); OutputDebugStringA(buf); db_set_dw((HANDLE)0,"CLUI","PF:Last RebuildEntireList Time:",tick); } }
void CVkGCCreateForm::btnOk_OnOk(CCtrlButton*) { CMStringA szUIds; for (MCONTACT hContact = db_find_first(m_proto->m_szModuleName); hContact; hContact = db_find_next(hContact, m_proto->m_szModuleName)) { if (m_proto->isChatRoom(hContact)) continue; HANDLE hItem = m_clCList.FindContact(hContact); if (hItem && m_clCList.GetCheck(hItem)) { int uid = m_proto->getDword(hContact, "ID"); if (uid != 0) { if (!szUIds.IsEmpty()) szUIds.AppendChar(','); szUIds.AppendFormat("%d", uid); } } } bool bRes = !szUIds.IsEmpty(); if (bRes) m_proto->CreateNewChat(szUIds, ptrT(m_edtTitle.GetText())); EndDialog(m_hwnd, bRes); }
INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) { switch(msg) { case WM_INITDIALOG: { int startupmode,exitmode; COMBOBOXINFO cbi={0}; cbi.cbSize = sizeof(cbi); opses_count=0; g_opHdlg=hdlg; bOptionsInit=TRUE; TranslateDialogDefault(hdlg); hMarked = Skin_GetIconByHandle(iconList[1].hIcolib); hNotMarked = Skin_GetIconByHandle(iconList[2].hIcolib); hIcon=(bChecked=IsMarkedUserDefSession(opses_count))?hMarked:hNotMarked; SetDlgItemInt(hdlg, IDC_TRACK,ses_limit=db_get_b(0, MODNAME, "TrackCount", 10), FALSE); SendDlgItemMessage(hdlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(10, 1)); SendDlgItemMessage(hdlg, IDC_SPIN1, UDM_SETPOS, 0, GetDlgItemInt(hdlg, IDC_TRACK, NULL, FALSE)); SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0); SetDlgItemInt(hdlg, IDC_STARTDELAY, db_get_w(NULL, MODNAME, "StartupModeDelay", 1500), FALSE); startupmode = db_get_b(NULL, MODNAME, "StartupMode", 3); exitmode = db_get_b(NULL, MODNAME, "ShutdownMode", 2); g_bExclHidden = db_get_b(NULL, MODNAME, "ExclHidden", 0); g_bWarnOnHidden = db_get_b(NULL, MODNAME, "WarnOnHidden", 0); g_bOtherWarnings = db_get_b(NULL, MODNAME, "OtherWarnings", 1); g_bCrashRecovery = db_get_b(NULL, MODNAME, "CrashRecovery", 0); CheckDlgButton(hdlg,IDC_EXCLHIDDEN,g_bExclHidden?BST_CHECKED:BST_UNCHECKED); CheckDlgButton(hdlg,IDC_LASTHIDDENWARN,g_bWarnOnHidden?BST_CHECKED:BST_UNCHECKED); CheckDlgButton(hdlg,IDC_WARNINGS,g_bOtherWarnings?BST_CHECKED:BST_UNCHECKED); CheckDlgButton(hdlg,IDC_CRASHRECOVERY,g_bCrashRecovery?BST_CHECKED:BST_UNCHECKED); if (startupmode == 1) CheckDlgButton(hdlg,IDC_STARTDIALOG,BST_CHECKED); else if (startupmode == 3) { CheckDlgButton(hdlg,IDC_STARTDIALOG,BST_CHECKED); CheckDlgButton(hdlg,IDC_CHECKLAST,BST_CHECKED); } else if (startupmode == 2) { CheckDlgButton(hdlg,IDC_RLOADLAST,BST_CHECKED); EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE); } else if (startupmode == 0) { CheckDlgButton(hdlg,IDC_RNOTHING,BST_CHECKED); EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), FALSE); EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), FALSE); EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), FALSE); EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE); } if (exitmode == 0) { CheckDlgButton(hdlg,IDC_REXDSAVE,BST_CHECKED); EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),FALSE); EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),FALSE); EnableWindow(GetDlgItem(hdlg,IDC_TRACK),FALSE); EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),FALSE); } else if (exitmode == 1) CheckDlgButton(hdlg,IDC_REXASK,BST_CHECKED); else if (exitmode == 2) CheckDlgButton(hdlg,IDC_REXSAVE,BST_CHECKED); LoadSessionToCombobox (hdlg,1,255,"UserSessionDsc",0); if (SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, 0, 0)) { EnableWindow(GetDlgItem(hdlg,IDC_EDIT),TRUE); SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0); if (!OpLoadSessionContacts(0,opses_count)) EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE); } GetComboBoxInfo(GetDlgItem(hdlg,IDC_LIST),&cbi); mir_subclassWindow(cbi.hwndItem, ComboBoxSubclassProc); hComboBoxEdit=cbi.hwndItem; hComboBox=cbi.hwndCombo; SetWindowPos( hComboBoxEdit, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED ); bOptionsInit=FALSE; } break; case WM_CTLCOLORLISTBOX: switch(GetDlgCtrlID((HWND) lparam)) { case IDC_OPCLIST: SetBkMode((HDC) wparam, TRANSPARENT); return (BOOL) CreateSolidBrush(GetSysColor(COLOR_3DFACE)); } break; case WM_NOTIFY: switch(((LPNMHDR)lparam)->code) { case PSN_APPLY: { int iDelay=GetDlgItemInt(hdlg, IDC_STARTDELAY,NULL, FALSE); db_set_w(0, MODNAME, "StartupModeDelay", (WORD)iDelay); db_set_b(0, MODNAME, "TrackCount", (BYTE)(ses_limit=GetDlgItemInt(hdlg, IDC_TRACK,NULL, FALSE))); if (IsDlgButtonChecked(hdlg, IDC_REXSAVE)) db_set_b(NULL, MODNAME, "ShutdownMode", 2); else if (IsDlgButtonChecked(hdlg, IDC_REXDSAVE)) db_set_b(NULL, MODNAME, "ShutdownMode", 0); else if (IsDlgButtonChecked(hdlg, IDC_REXASK)) db_set_b(NULL, MODNAME, "ShutdownMode", 1); if (IsDlgButtonChecked(hdlg, IDC_STARTDIALOG)) { if (!IsDlgButtonChecked(hdlg, IDC_CHECKLAST)) db_set_b(NULL, MODNAME, "StartupMode", 1); else db_set_b(NULL, MODNAME, "StartupMode", 3); } else if (IsDlgButtonChecked(hdlg, IDC_RLOADLAST)) db_set_b(NULL, MODNAME, "StartupMode", 2); else if (IsDlgButtonChecked(hdlg, IDC_RNOTHING)) db_set_b(NULL, MODNAME, "StartupMode", 0); db_set_b(NULL, MODNAME, "ExclHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_EXCLHIDDEN) ? (g_bExclHidden = 1) : (g_bExclHidden = 0))); db_set_b(NULL, MODNAME, "WarnOnHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_LASTHIDDENWARN) ? (g_bWarnOnHidden = 1) : (g_bWarnOnHidden = 0))); db_set_b(NULL, MODNAME, "OtherWarnings", (BYTE)(IsDlgButtonChecked(hdlg, IDC_WARNINGS) ? (g_bOtherWarnings = 1) : (g_bOtherWarnings = 0))); db_set_b(NULL, MODNAME, "CrashRecovery", (BYTE)(IsDlgButtonChecked(hdlg, IDC_CRASHRECOVERY) ? (g_bCrashRecovery = 1) : (g_bCrashRecovery = 0))); } return 1; case CLN_CHECKCHANGED: if (((LPNMHDR)lparam)->idFrom == IDC_EMCLIST) { int iSelection = (int)((NMCLISTCONTROL *)lparam)->hItem; MCONTACT hContact = db_find_first(); for ( ; hContact; hContact = db_find_next(hContact)) if (SendDlgItemMessage(hdlg, IDC_EMCLIST, CLM_FINDCONTACT, hContact, 0) == iSelection) break; if (hContact) EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE); else EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE); } } break; case WM_COMMAND: switch(LOWORD(wparam)) { case IDC_LIST: switch(HIWORD(wparam)) { case CBN_EDITCHANGE: EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE); bSesssionNameChanged=TRUE; break; case CBN_SELCHANGE: { HWND hCombo = GetDlgItem(hdlg, IDC_LIST); int index = SendMessage(hCombo, CB_GETCURSEL, 0, 0); if (index != CB_ERR) { opses_count = SendMessage(hCombo, CB_GETITEMDATA, (WPARAM)index, 0); SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0); if (IsMarkedUserDefSession(opses_count)) { hIcon=hMarked; bChecked=TRUE; RedrawWindow(hComboBoxEdit, NULL, NULL, RDW_INVALIDATE|RDW_NOCHILDREN|RDW_UPDATENOW|RDW_FRAME); } else { hIcon=hNotMarked; bChecked=FALSE; RedrawWindow(hComboBoxEdit, NULL, NULL, RDW_INVALIDATE|RDW_NOCHILDREN|RDW_UPDATENOW|RDW_FRAME); } OpLoadSessionContacts(0,opses_count); if (!hOpClistControl) EnableWindow(GetDlgItem(hdlg,IDC_DEL),TRUE); else { for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) SendMessage(hOpClistControl, CLM_SETCHECKMARK, hContact,0); for (int i=0 ; session_list_t[i] > 0; i++) { MCONTACT hContact = (MCONTACT)SendMessage(hOpClistControl, CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0); SendMessage(hOpClistControl, CLM_SETCHECKMARK, hContact, 1); } EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE); } } }break; }break; case IDC_EDIT: if (!hOpClistControl) { ShowWindow(GetDlgItem(hdlg,IDC_OPCLIST),SW_HIDE); EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE); //EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE); SetWindowText(GetDlgItem(hdlg,IDC_EDIT),TranslateT("View")); hOpClistControl = CreateWindowEx(WS_EX_STATICEDGE, _T(CLISTCONTROL_CLASS), _T(""), WS_TABSTOP |WS_VISIBLE | WS_CHILD , 14,198,161,163,hdlg, (HMENU)IDC_EMCLIST, hinstance, 0); SetWindowLongPtr(hOpClistControl, GWL_STYLE, GetWindowLongPtr(hOpClistControl, GWL_STYLE)|CLS_CHECKBOXES|CLS_HIDEEMPTYGROUPS|CLS_USEGROUPS|CLS_GREYALTERNATE|CLS_GROUPCHECKBOXES); SendMessage(hOpClistControl, CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP|CLS_EX_TRACKSELECT, 0); SendMessage(hOpClistControl,WM_TIMER,TIMERID_REBUILDAFTER,0); for (int i=0 ; session_list_t[i] > 0; i++) { HANDLE hItem=(HANDLE)SendMessage(hOpClistControl,CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0); SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hItem,1); } } else { ShowWindow(GetDlgItem(hdlg,IDC_OPCLIST),SW_SHOWNA); EnableWindow(GetDlgItem(hdlg,IDC_DEL),TRUE); EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE); SetWindowText(GetDlgItem(hdlg,IDC_EDIT),TranslateT("Edit")); DestroyWindow(hOpClistControl); hOpClistControl=NULL; } break; case IDC_SAVE: { int i=0; for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { BYTE res =(BYTE)SendMessage(GetDlgItem(hdlg,IDC_EMCLIST), CLM_GETCHECKMARK, SendMessage(GetDlgItem(hdlg,IDC_EMCLIST), CLM_FINDCONTACT, hContact, 0), 0); if (res) { SetSessionMark(hContact,1,'1',opses_count); SetInSessionOrder(hContact,1,opses_count,i); i++; } else { SetSessionMark(hContact,1,'0',opses_count); SetInSessionOrder(hContact,1,opses_count,0); } } if (bSesssionNameChanged) { if (GetWindowTextLength(hComboBoxEdit)) { TCHAR szUserSessionName[MAX_PATH]={'\0'}; GetWindowText(hComboBoxEdit, szUserSessionName, SIZEOF(szUserSessionName)); RenameUserDefSession(opses_count,szUserSessionName); SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT ,0,0); LoadSessionToCombobox (hdlg,1,255,"UserSessionDsc",0); } bSesssionNameChanged=FALSE; } EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE); } break; case IDC_DEL: DelUserDefSession(opses_count); SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0); SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0); LoadSessionToCombobox (hdlg,1,255,"UserSessionDsc",0); opses_count=0; if (SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, 0, 0)) { EnableWindow(GetDlgItem(hdlg,IDC_EDIT),TRUE); SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0); if (!OpLoadSessionContacts(0,opses_count)) EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE); } else { EnableWindow(GetDlgItem(hdlg,IDC_EDIT),FALSE); EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE); } break; case IDC_STARTDIALOG: EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), TRUE); EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), TRUE); EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), TRUE); EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), TRUE); SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); break; case IDC_RLOADLAST: EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), TRUE); EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), TRUE); EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), TRUE); EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE); SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); break; case IDC_RNOTHING: EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), FALSE); EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), FALSE); EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), FALSE); EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE); SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); break; case IDC_REXSAVE: EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),TRUE); EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),TRUE); EnableWindow(GetDlgItem(hdlg,IDC_TRACK),TRUE); EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),TRUE); SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); break; case IDC_REXDSAVE: EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),FALSE); EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),FALSE); EnableWindow(GetDlgItem(hdlg,IDC_TRACK),FALSE); EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),FALSE); SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); break; case IDC_REXASK: EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),TRUE); EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),TRUE); EnableWindow(GetDlgItem(hdlg,IDC_TRACK),TRUE); EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),TRUE); SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); break; } if (HIWORD(wparam) == CBN_DROPDOWN&&!hOpClistControl) { SendMessage(hComboBoxEdit,EM_SETSEL ,0,0); SendMessage(hComboBoxEdit,EM_SCROLLCARET ,0,0); SendMessage(hComboBoxEdit,WM_KILLFOCUS ,0,0); HideCaret(hComboBoxEdit); } if ((HIWORD(wparam)!=CBN_DROPDOWN)&&(LOWORD(wparam) == IDC_LIST)&&!hOpClistControl) { SendMessage(hComboBoxEdit,EM_SCROLLCARET ,0,0); HideCaret(hComboBoxEdit); } if ((LOWORD(wparam) == IDC_STARTDELAY) && (HIWORD(wparam)!=EN_CHANGE || (HWND)lparam != GetFocus())) return 0; if (lparam&&!bOptionsInit&&(HIWORD(wparam) == BN_CLICKED)&& (GetFocus() == (HWND)lparam) &&((LOWORD(wparam) == IDC_CHECKLAST)||((LOWORD(wparam)>=IDC_EXCLHIDDEN)&&(LOWORD(wparam)<=IDC_CRASHRECOVERY)))) SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); return 0; case WM_CLOSE: EndDialog(hdlg,0); return 0; } return 0; }
int CMraProto::OnModulesLoaded(WPARAM, LPARAM) { HookProtoEvent(ME_CLIST_EXTRA_IMAGE_APPLY, &CMraProto::MraExtraIconsApply); HookProtoEvent(ME_OPT_INITIALISE, &CMraProto::OnOptionsInit); HookProtoEvent(ME_DB_CONTACT_DELETED, &CMraProto::MraContactDeleted); HookProtoEvent(ME_DB_CONTACT_SETTINGCHANGED, &CMraProto::MraDbSettingChanged); HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CMraProto::MraRebuildContactMenu); HookProtoEvent(ME_WAT_NEWSTATUS, &CMraProto::MraMusicChanged); HookProtoEvent(ME_CLIST_GROUPCHANGE, &CMraProto::OnGroupChanged); // всех в offline // тк unsaved values сохран¤ютс¤ их нужно инициализировать for (MCONTACT hContact = db_find_first(m_szModuleName); hContact != NULL; hContact = db_find_next(hContact, m_szModuleName)) SetContactBasicInfoW(hContact, SCBIFSI_LOCK_CHANGES_EVENTS, (SCBIF_ID | SCBIF_GROUP_ID | SCBIF_SERVER_FLAG | SCBIF_STATUS), -1, -1, 0, 0, ID_STATUS_OFFLINE, 0, 0, 0); // unsaved values db_set_resident(m_szModuleName, "LogonTS"); db_set_resident(m_szModuleName, "ContactID"); db_set_resident(m_szModuleName, "GroupID"); db_set_resident(m_szModuleName, "ContactFlags"); db_set_resident(m_szModuleName, "ContactServerFlags"); db_set_resident(m_szModuleName, "HooksLocked"); db_set_resident(m_szModuleName, DBSETTING_CAPABILITIES); db_set_resident(m_szModuleName, DBSETTING_XSTATUSNAME); db_set_resident(m_szModuleName, DBSETTING_XSTATUSMSG); db_set_resident(m_szModuleName, DBSETTING_BLOGSTATUSTIME); db_set_resident(m_szModuleName, DBSETTING_BLOGSTATUSID); db_set_resident(m_szModuleName, DBSETTING_BLOGSTATUS); db_set_resident(m_szModuleName, DBSETTING_BLOGSTATUSMUSIC); // destroy all chat sessions bChatExists = MraChatRegister(); return 0; }
bool ipcGetSortedContacts(THeaderIPC *ipch, int *pSlot, bool bGroupMode) { DBVARIANT dbv; int n, rc; bool Result = false; // hide offliners? bool bHideOffline = db_get_b(0, "CList", "HideOffline", 0) == 1; // do they wanna hide the offline people anyway? if (db_get_b(0, SHLExt_Name, SHLExt_ShowNoOffline, 0) == 1) // hide offline people bHideOffline = true; // get the number of contacts int dwContacts = (int)CallService(MS_DB_CONTACT_GETCOUNT, 0, 0); if (dwContacts == 0) return false; // get the contacts in the array to be sorted by status, trim out anyone // who doesn't wanna be seen. TSlotInfo *pContacts = (TSlotInfo*)mir_alloc((dwContacts + 2) * sizeof(TSlotInfo)); int i = 0; int dwOnline = 0; for (MCONTACT hContact = db_find_first(); hContact != 0; hContact = db_find_next(hContact)) { if (i >= dwContacts) break; // do they have a running protocol? char *szProto = GetContactProto(hContact); if (szProto != NULL) { // does it support file sends? DWORD dwCaps = ProtoCallService(szProto, PS_GETCAPS, PFLAGNUM_1, 0); if ((dwCaps & PF1_FILESEND) == 0) continue; int dwStatus = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); if (dwStatus != ID_STATUS_OFFLINE) dwOnline++; else if (bHideOffline) continue; // is HIT on? if (BST_UNCHECKED == db_get_b(0, SHLExt_Name, SHLExt_UseHITContacts, BST_UNCHECKED)) { // don't show people who are "Hidden" "NotOnList" or Ignored if (db_get_b(hContact, "CList", "Hidden", 0) == 1 || db_get_b(hContact, "CList", "NotOnList", 0) == 1 || CallService(MS_IGNORE_ISIGNORED, hContact, IGNOREEVENT_MESSAGE | IGNOREEVENT_URL | IGNOREEVENT_FILE) != 0) continue; } // is HIT2 off? if (BST_UNCHECKED == db_get_b(0, SHLExt_Name, SHLExt_UseHIT2Contacts, BST_UNCHECKED)) if (db_get_w(hContact, szProto, "ApparentMode", 0) == ID_STATUS_OFFLINE) continue; // store pContacts[i].hContact = hContact; pContacts[i].dwStatus = dwStatus; pContacts[i].hProto = murmur_hash(szProto); i++; } } // if no one is online and the CList isn't showing offliners, quit if (dwOnline == 0 && bHideOffline) { mir_free(pContacts); return false; } dwContacts = i; qsort(pContacts, dwContacts, sizeof(TSlotInfo), SortContact); // create an IPC slot for each contact and store display name, etc for (i=0; i < dwContacts; i++) { char *szContact = (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)pContacts[i].hContact, 0); if (szContact != NULL) { n = 0; rc = 1; if (bGroupMode) { rc = db_get_s(pContacts[i].hContact, "CList", "Group", &dbv); if (!rc) n = lstrlenA(dbv.pszVal) + 1; } int cch = lstrlenA(szContact) + 1; TSlotIPC *pct = ipcAlloc(ipch, cch + 1 + n); if (pct == NULL) { db_free(&dbv); break; } // lie about the actual size of the TSlotIPC pct->cbStrSection = cch; LPSTR szSlot = LPSTR(pct) + sizeof(TSlotIPC); lstrcpyA(szSlot, szContact); pct->fType = REQUEST_CONTACTS; pct->hContact = pContacts[i].hContact; pct->Status = pContacts[i].dwStatus; pct->hProto = pContacts[i].hProto; pct->MRU = db_get_b(pct->hContact, SHLExt_Name, SHLExt_MRU, 0); if (ipch->ContactsBegin == NULL) ipch->ContactsBegin = pct; szSlot += cch + 1; if (rc == 0) { pct->hGroup = murmur_hash(dbv.pszVal); lstrcpyA(szSlot, dbv.pszVal); db_free(&dbv); } else { pct->hGroup = 0; *szSlot = 0; } pSlot[0]++; } } mir_free(pContacts); return true; }
void fnRebuildEntireList(HWND hwnd, ClcData *dat) { DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE); dat->list.expanded = 1; dat->list.hideOffline = db_get_b(NULL, "CLC", "HideOfflineRoot", 0) && (style & CLS_USEGROUPS); dat->list.cl.destroy(); dat->list.totalMembers = 0; dat->selection = -1; for (int i = 1;; i++) { DWORD groupFlags; TCHAR *szGroupName = Clist_GroupGetName(i, &groupFlags); if (szGroupName == NULL) break; cli.pfnAddGroup(hwnd, dat, szGroupName, groupFlags, i, 0); } for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { int nHiddenStatus = cli.pfnGetContactHiddenStatus(hContact, NULL, dat); if (((style & CLS_SHOWHIDDEN) && nHiddenStatus != -1) || !nHiddenStatus) { ClcCacheEntry *pce = cli.pfnGetCacheEntry(hContact); ClcGroup *group; ptrT tszGroupName(db_get_tsa(hContact, "CList", "Group")); if (tszGroupName == NULL) group = &dat->list; else { group = cli.pfnAddGroup(hwnd, dat, tszGroupName, (DWORD)-1, 0, 0); if (group == NULL && style & CLS_SHOWHIDDEN) group = &dat->list; } if (group != NULL) { group->totalMembers++; if (dat->bFilterSearch && dat->szQuickSearch[0] != '\0') { TCHAR *name = cli.pfnGetContactDisplayName(hContact, 0); TCHAR *lowered_name = CharLowerW(NEWTSTR_ALLOCA(name)); TCHAR *lowered_search = CharLowerW(NEWTSTR_ALLOCA(dat->szQuickSearch)); if (_tcsstr(lowered_name, lowered_search)) cli.pfnAddContactToGroup(dat, group, hContact); } else if (!(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) { char *szProto = GetContactProto(hContact); if (szProto == NULL) { if (!cli.pfnIsHiddenMode(dat, ID_STATUS_OFFLINE) || cli.pfnIsVisibleContact(pce, group)) cli.pfnAddContactToGroup(dat, group, hContact); } else if (!cli.pfnIsHiddenMode(dat, db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE)) || cli.pfnIsVisibleContact(pce, group)) cli.pfnAddContactToGroup(dat, group, hContact); } else cli.pfnAddContactToGroup(dat, group, hContact); } } } if (style & CLS_HIDEEMPTYGROUPS) { ClcGroup *group = &dat->list; group->scanIndex = 0; for (;;) { if (group->scanIndex == group->cl.getCount()) { if ((group = group->parent) == NULL) break; group->scanIndex++; continue; } ClcContact *cc = group->cl[group->scanIndex]; if (cc->type == CLCIT_GROUP) { if (cc->group->cl.getCount() == 0) { group = cli.pfnRemoveItemFromGroup(hwnd, group, cc, 0); } else { group = cc->group; group->scanIndex = 0; } continue; } group->scanIndex++; } } cli.pfnSortCLC(hwnd, dat, 0); cli.pfnSetAllExtraIcons(0); }
// worker thread to clear MRU, called by the IPC bridge void __cdecl ClearMRUThread(void*) { for (MCONTACT hContact = db_find_first(); hContact != 0; hContact = db_find_next(hContact)) if ( db_get_b(hContact, SHLExt_Name, SHLExt_MRU, 0) > 0) db_set_b(hContact, SHLExt_Name, SHLExt_MRU, 0); }
INT_PTR CALLBACK SaveSessionDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) { g_hSDlg = hdlg; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hdlg); { LoadSessionToCombobox(hdlg, 1, 5, "UserSessionDsc", 0); LoadPosition(hdlg, "SaveDlg"); ShowWindow(hdlg, SW_SHOW); } break; case WM_CLOSE: DestroyWindow(hdlg); g_hSDlg = 0; break; case WM_NOTIFY: switch (((LPNMHDR)lparam)->idFrom) { case IDC_CLIST: switch (((LPNMHDR)lparam)->code) { case CLN_CHECKCHANGED: bSC = TRUE; memcpy(user_session_list, session_list, sizeof(user_session_list)); break; } } break; case WM_COMMAND: switch (LOWORD(wparam)) { case IDC_SELCONTACTS: HANDLE hItem; RECT rWnd; { int i = 0, x = 0, y = 0, dy = 0, dx = 0, dd = 0; GetWindowRect(hdlg, &rWnd); x = rWnd.right - rWnd.left; y = rWnd.bottom - rWnd.top; if (IsDlgButtonChecked(hdlg, IDC_SELCONTACTS)) { EnableWindow(GetDlgItem(hdlg, IDC_SANDCCHECK), FALSE); dy = 20; dx = 150; dd = 5; hClistControl = CreateWindowEx(WS_EX_CLIENTEDGE, _T(CLISTCONTROL_CLASS), _T(""), WS_TABSTOP | WS_VISIBLE | WS_CHILD, x, y, dx, dy, hdlg, (HMENU)IDC_CLIST, g_hInst, 0); SetWindowLongPtr(hClistControl, GWL_STYLE, GetWindowLongPtr(hClistControl, GWL_STYLE) | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE | CLS_GROUPCHECKBOXES); SendMessage(hClistControl, CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT, 0); } else { EnableWindow(GetDlgItem(hdlg, IDC_SANDCCHECK), TRUE); dy = -20; dx = -150; dd = 5; DestroyWindow(hClistControl); } SetWindowPos(hdlg, NULL, rWnd.left, rWnd.top, x + dx, y + (dx / 3), SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE); SetWindowPos(hClistControl, 0, x - dd, dd, dx - dd, y + (dx / 12), SWP_NOZORDER/*|SWP_NOSIZE|SWP_SHOWWINDOW*/); SendMessage(hClistControl, WM_TIMER, TIMERID_REBUILDAFTER, 0); for (i = 0; session_list[i] > 0; i++) { hItem = (HANDLE)SendMessage(hClistControl, CLM_FINDCONTACT, (WPARAM)session_list[i], 0); SendMessage(hClistControl, CLM_SETCHECKMARK, (WPARAM)hItem, 1); } OffsetWindow(hdlg, GetDlgItem(hdlg, IDC_LIST), 0, dy); OffsetWindow(hdlg, GetDlgItem(hdlg, IDC_STATIC), 0, dy); OffsetWindow(hdlg, GetDlgItem(hdlg, IDC_SANDCCHECK), 0, dy); OffsetWindow(hdlg, GetDlgItem(hdlg, IDOK), 0, dy); OffsetWindow(hdlg, GetDlgItem(hdlg, IDCANCEL), 0, dy); } break; case IDOK: TCHAR szUserSessionName[MAX_PATH]; { DWORD session_list_temp[255] = { 0 }; int i = 0, length = GetWindowTextLength(GetDlgItem(hdlg, IDC_LIST)); SavePosition(hdlg, "SaveDlg"); if (length > 0) { GetDlgItemText(hdlg, IDC_LIST, szUserSessionName, _countof(szUserSessionName)); szUserSessionName[length + 1] = '\0'; if (IsDlgButtonChecked(hdlg, IDC_SELCONTACTS) && bSC) { for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { BYTE res = (BYTE)SendMessage(hClistControl, CLM_GETCHECKMARK, SendMessage(hClistControl, CLM_FINDCONTACT, hContact, 0), 0); if (res) { user_session_list[i] = hContact; i++; } } memcpy(session_list_temp, session_list, sizeof(session_list_temp)); memcpy(session_list, user_session_list, sizeof(session_list)); SaveSessionHandles(0, 1); SaveUserSessionName(szUserSessionName); memcpy(session_list, session_list_temp, sizeof(session_list)); DestroyWindow(hdlg); g_hSDlg = 0; } else if (!SaveUserSessionName(szUserSessionName)) { SaveSessionHandles(0, 1); if (IsDlgButtonChecked(hdlg, IDC_SANDCCHECK)) CloseCurrentSession(0, 0); DestroyWindow(hdlg); g_hSDlg = 0; } else MessageBox(NULL, TranslateT("Current session is empty!"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING); } else MessageBox(NULL, TranslateT("Session name is empty, enter the name and try again"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING); } break; case IDCANCEL: SavePosition(hdlg, "SaveDlg"); DestroyWindow(hdlg); g_hSDlg = 0; } break; default: return FALSE; } return TRUE; }
static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam) { static HICON hVisibleIcon, hInvisibleIcon; static HANDLE hItemAll; HIMAGELIST hIml; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 3, 3); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_SMALLDOT); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_VISIBLE_ALL); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_INVISIBLE_ALL); SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml); hVisibleIcon = ImageList_GetIcon(hIml, 1, ILD_NORMAL); SendDlgItemMessage(hwndDlg, IDC_VISIBLEICON, STM_SETICON, (WPARAM)hVisibleIcon, 0); hInvisibleIcon = ImageList_GetIcon(hIml, 2, ILD_NORMAL); SendDlgItemMessage(hwndDlg, IDC_INVISIBLEICON, STM_SETICON, (WPARAM)hInvisibleIcon, 0); ResetListOptions( GetDlgItem(hwndDlg, IDC_LIST)); SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRACOLUMNS, 2, 0); { CLCINFOITEM cii = { sizeof(cii) }; cii.flags = CLCIIF_GROUPFONT; cii.pszText = TranslateT("** All contacts **"); hItemAll = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); } SetAllContactIcons( GetDlgItem(hwndDlg, IDC_LIST)); SetListGroupIcons( GetDlgItem(hwndDlg, IDC_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL); return TRUE; case WM_SETFOCUS: SetFocus( GetDlgItem(hwndDlg, IDC_LIST)); break; case WM_NOTIFY: switch(((LPNMHDR)lParam)->idFrom) { case IDC_LIST: switch (((LPNMHDR)lParam)->code) { case CLN_NEWCONTACT: case CLN_LISTREBUILT: SetAllContactIcons( GetDlgItem(hwndDlg, IDC_LIST)); //fall through case CLN_CONTACTMOVED: SetListGroupIcons( GetDlgItem(hwndDlg, IDC_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL); break; case CLN_OPTIONSCHANGED: ResetListOptions( GetDlgItem(hwndDlg, IDC_LIST)); break; case NM_CLICK: { // Make sure we have an extra column NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam; if (nm->iColumn == -1) break; // Find clicked item DWORD hitFlags; HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y)); if (hItem == NULL) break; // It was not a visbility icon if (!(hitFlags & CLCHT_ONITEMEXTRA)) break; // Get image in clicked column (0 = none, 1 = visible, 2 = invisible) int iImage = SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, 0)); if (iImage == 0) iImage = nm->iColumn + 1; else if (iImage == 1 || iImage == 2) iImage = 0; // Get item type (contact, group, etc...) int itemType = SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETITEMTYPE, (WPARAM)hItem, 0); // Update list, making sure that the options are mutually exclusive if (itemType == CLCIT_CONTACT) { // A contact SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, iImage)); if (iImage && SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn?0:1, 0)) != EMPTY_EXTRA_ICON) SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn?0:1, 0)); } else if (itemType == CLCIT_INFO) { // All Contacts SetAllChildIcons( GetDlgItem(hwndDlg, IDC_LIST), hItem, nm->iColumn, iImage); if (iImage) SetAllChildIcons( GetDlgItem(hwndDlg, IDC_LIST), hItem, nm->iColumn?0:1, 0); } else if (itemType == CLCIT_GROUP) { // A group hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); if (hItem) { SetAllChildIcons( GetDlgItem(hwndDlg, IDC_LIST), hItem, nm->iColumn, iImage); if (iImage) SetAllChildIcons( GetDlgItem(hwndDlg, IDC_LIST), hItem, nm->iColumn?0:1, 0); } } // Update the all/none icons SetListGroupIcons( GetDlgItem(hwndDlg, IDC_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL); // Activate Apply button SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } } break; case 0: if (((LPNMHDR)lParam)->code == PSN_APPLY) { for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_FINDCONTACT, hContact, 0); if (hItem == NULL) continue; int set = 0; for (int i=0; i < 2; i++) { int iImage = SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, 0)); if (iImage == i+1) { CallContactService(hContact, PSS_SETAPPARENTMODE, iImage == 1?ID_STATUS_ONLINE:ID_STATUS_OFFLINE, 0); set = 1; break; } } if (!set) CallContactService(hContact, PSS_SETAPPARENTMODE, 0, 0); } return TRUE; } } break; case WM_DESTROY: DestroyIcon(hVisibleIcon); DestroyIcon(hInvisibleIcon); hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0); ImageList_Destroy(hIml); break; } return FALSE; }
INT_PTR CALLBACK SessionAnnounceDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { SessionAnnounceDialogProc_arg* arg = (SessionAnnounceDialogProc_arg*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); CSametimeProto *proto; switch (uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); arg = (SessionAnnounceDialogProc_arg*)lParam; proto = arg->proto; proto->debugLog(_T("SessionAnnounceDialogProc WM_INITDIALOG")); SendDlgItemMessage(hwndDlg, IDC_LST_ANTO, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES); { LVCOLUMN lvc; // Initialize the LVCOLUMN structure. // The mask specifies that the format, width, text, and // subitem members of the structure are valid. lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; lvc.iSubItem = 0; lvc.pszText = TranslateT("Recipients"); lvc.cx = 300; // width of column in pixels ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_LST_ANTO), 0, &lvc); } //enumerate plugins, fill in list { ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_LST_ANTO)); LVITEM lvI; // Some code to create the list-view control. // Initialize LVITEM members that are common to all items. lvI.mask = LVIF_TEXT | LVIF_PARAM;// | LVIF_NORECOMPUTE;// | LVIF_IMAGE; lvI.iItem = 0; lvI.iSubItem = 0; for (MCONTACT hContact = db_find_first(proto->m_szModuleName); hContact; hContact = db_find_next(hContact, proto->m_szModuleName)) { if (db_get_b(hContact, proto->m_szModuleName, "ChatRoom", 0) == 0 && db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) { lvI.lParam = (LPARAM)hContact; lvI.pszText = pcli->pfnGetContactDisplayName(hContact, 0); ListView_InsertItem(GetDlgItem(hwndDlg, IDC_LST_ANTO), &lvI); lvI.iItem++; } } } } return 0; case WM_CLOSE: proto = arg->proto; proto->debugLog(_T("SessionAnnounceDialogProc WM_CLOSE")); mir_free(arg); DestroyWindow(hwndDlg); break; case WM_COMMAND: proto = arg->proto; if (HIWORD(wParam) == BN_CLICKED) { int size; switch (LOWORD(wParam)) { case IDC_BUT_SELALL: size = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_LST_ANTO)); for (int i = 0; i < size; i++) ListView_SetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i, true); return 0; case IDC_BUT_SELINV: size = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_LST_ANTO)); for (int i = 0; i < size; i++) ListView_SetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i, !ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i)); return 0; case IDOK: proto->debugLog(_T("SessionAnnounceDialogProc IDOK BN_CLICKED")); { // build SendAnnouncementFunc_arg SendAnnouncementFunc_arg* safArg = (SendAnnouncementFunc_arg*)mir_calloc(sizeof(SendAnnouncementFunc_arg)); DBVARIANT dbv; LVITEM lvI = { 0 }; char id[1024]; mir_strcpy(id, "@U"); // documentation says prepend '@U' to usernames and '@G' to notes group names - but char *p = id + 2; // it's wrong - it works for a list of user id's with no prefix - so we'll do both // build recipient list safArg->recipients = 0; int size = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_LST_ANTO)); int send_count = 0; for (int i = 0; i < size; i++) { if (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i)) { lvI.iItem = i; lvI.iSubItem = 0; lvI.mask = LVIF_PARAM; ListView_GetItem(GetDlgItem(hwndDlg, IDC_LST_ANTO), &lvI); if (!db_get_utf((MCONTACT)lvI.lParam, proto->m_szModuleName, "stid", &dbv)) { safArg->recipients = g_list_prepend(safArg->recipients, _strdup(dbv.pszVal)); mir_strcpy(p, dbv.pszVal); safArg->recipients = g_list_prepend(safArg->recipients, _strdup(id)); send_count++; db_free(&dbv); } } } if (send_count > 0) { GetDlgItemText(hwndDlg, IDC_ED_ANMSG, safArg->msg, MAX_MESSAGE_SIZE); safArg->proto = proto; SendAnnouncementFunc sendAnnouncementFunc = arg->sendAnnouncementFunc; sendAnnouncementFunc(safArg); } // clean up recipient list if (safArg->recipients) { for (GList *rit = safArg->recipients; rit; rit = rit->next) { free(rit->data); } g_list_free(safArg->recipients); } mir_free(safArg); DestroyWindow(hwndDlg); } return 0; case IDCANCEL: DestroyWindow(hwndDlg); return 0; } } break; } return 0; }
// always call in context of main thread static void RemoveExtraImages(void) { for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) ExtraIcon_Clear(hExtraIcon, hContact); }
static INT_PTR CALLBACK DlgProcMirOTROptsContacts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND lv = GetDlgItem(hwndDlg, IDC_LV_CONT_CONTACTS); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) new ContactPolicyMap()); HWND cmb = GetDlgItem(hwndDlg, IDC_CMB_CONT_POLICY); SendMessage(cmb, CB_ADDSTRING, 0, (WPARAM)TranslateT(LANG_POLICY_DEFAULT)); SendMessage(cmb, CB_ADDSTRING, 0, (WPARAM)TranslateT(LANG_POLICY_ALWAYS)); SendMessage(cmb, CB_ADDSTRING, 0, (WPARAM)TranslateT(LANG_POLICY_OPP)); SendMessage(cmb, CB_ADDSTRING, 0, (WPARAM)TranslateT(LANG_POLICY_MANUAL)); SendMessage(cmb, CB_ADDSTRING, 0, (WPARAM)TranslateT(LANG_POLICY_NEVER)); EnableWindow(GetDlgItem(hwndDlg, IDC_CMB_CONT_POLICY), FALSE); SendDlgItemMessage(hwndDlg, IDC_LV_CONT_CONTACTS, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT);// | LVS_EX_CHECKBOXES); // add list columns LVCOLUMN lvc; // Initialize the LVCOLUMN structure. // The mask specifies that the format, width, text, and // subitem members of the structure are valid. lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; lvc.iSubItem = 0; lvc.pszText = TranslateT(LANG_CONTACT); lvc.cx = 150; // width of column in pixels ListView_InsertColumn(lv, 0, &lvc); lvc.iSubItem = 1; lvc.pszText = TranslateT(LANG_PROTO); lvc.cx = 100; // width of column in pixels ListView_InsertColumn(lv, 1, &lvc); lvc.iSubItem = 2; lvc.pszText = TranslateT(LANG_POLICY); lvc.cx = 90; // width of column in pixels ListView_InsertColumn(lv, 2, &lvc); lvc.iSubItem = 3; lvc.pszText = TranslateT(LANG_HTMLCONV); lvc.cx = 80; // width of column in pixels ListView_InsertColumn(lv, 3, &lvc); } SendMessage(hwndDlg, WMU_REFRESHLIST, 0, 0); return TRUE; case WMU_REFRESHLIST: ListView_DeleteAllItems(lv); { LVITEM lvI = { 0 }; // Some code to create the list-view control. // Initialize LVITEM members that are common to all // items. lvI.mask = LVIF_TEXT | LVIF_PARAM;// | LVIF_NORECOMPUTE;// | LVIF_IMAGE; for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { const char *proto = GetContactProto(hContact); if (proto && db_get_b(hContact, proto, "ChatRoom", 0) == 0 && Proto_IsProtoOnContact(hContact, MODULENAME) // ignore chatrooms && mir_strcmp(proto, META_PROTO) != 0) // and MetaContacts { lvI.iItem = 0; lvI.iSubItem = 0; lvI.lParam = hContact; lvI.pszText = (TCHAR*)contact_get_nameT(hContact); lvI.iItem = ListView_InsertItem(lv, &lvI); PROTOACCOUNT *pa = Proto_GetAccount(proto); ListView_SetItemText(lv, lvI.iItem, 1, pa->tszAccountName); ListView_SetItemText(lv, lvI.iItem, 2, (TCHAR*)policy_to_string((OtrlPolicy)db_get_dw(hContact, MODULENAME, "Policy", CONTACT_DEFAULT_POLICY))); ListView_SetItemText(lv, lvI.iItem, 3, (db_get_b(hContact, MODULENAME, "HTMLConv", 0)) ? TranslateT(LANG_YES) : TranslateT(LANG_NO)); } } } return TRUE; case WM_COMMAND: switch (HIWORD(wParam)) { case CBN_SELCHANGE: switch (LOWORD(wParam)) { case IDC_CMB_CONT_POLICY: int iUser = ListView_GetSelectionMark(GetDlgItem(hwndDlg, IDC_LV_CONT_CONTACTS)); if (iUser == -1) break; int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_CONT_POLICY, CB_GETCURSEL, 0, 0); if (sel == CB_ERR) break; int len = SendDlgItemMessage(hwndDlg, IDC_CMB_CONT_POLICY, CB_GETLBTEXTLEN, sel, 0); if (len < 0) break; TCHAR *text = new TCHAR[len + 1]; SendDlgItemMessage(hwndDlg, IDC_CMB_CONT_POLICY, CB_GETLBTEXT, sel, (LPARAM)text); ListView_SetItemText(GetDlgItem(hwndDlg, IDC_LV_CONT_CONTACTS), iUser, 2, text); OtrlPolicy policy = policy_from_string(text); delete[] text; LVITEM lvi = { 0 }; lvi.mask = LVIF_PARAM; lvi.iItem = iUser; lvi.iSubItem = 0; ListView_GetItem(GetDlgItem(hwndDlg, IDC_LV_CONT_CONTACTS), &lvi); ContactPolicyMap* cpm = (ContactPolicyMap*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); MCONTACT hContact = (MCONTACT)lvi.lParam; (*cpm)[hContact].policy = policy; SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } break; } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->code == PSN_APPLY) { // handle apply ContactPolicyMap *cpm = (ContactPolicyMap*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); // Iterate over the map and print out all key/value pairs. // Using a const_iterator since we are not going to change the values. for (ContactPolicyMap::const_iterator it = cpm->begin(); it != cpm->end(); ++it) { if (!it->first) continue; db_set_dw(it->first, MODULENAME, "Policy", (DWORD)it->second.policy); db_set_b(it->first, MODULENAME, "HTMLConv", it->second.htmlconv); } return TRUE; } if (((LPNMHDR)lParam)->hwndFrom == lv) { LPNMLISTVIEW notif = (LPNMLISTVIEW)lParam; if (((LPNMHDR)lParam)->code == LVN_ITEMCHANGED && (notif->uNewState & LVIS_SELECTED)) { if (notif->iItem == -1) { SendDlgItemMessage(hwndDlg, IDC_CMB_CONT_POLICY, CB_SETCURSEL, (LPARAM)-1, 0); EnableWindow(GetDlgItem(hwndDlg, IDC_CMB_CONT_POLICY), FALSE); } else { EnableWindow(GetDlgItem(hwndDlg, IDC_CMB_CONT_POLICY), TRUE); TCHAR buff[50]; ListView_GetItemText(((LPNMHDR)lParam)->hwndFrom, notif->iItem, 2, buff, _countof(buff)); SendDlgItemMessage(hwndDlg, IDC_CMB_CONT_POLICY, CB_SELECTSTRING, (LPARAM)-1, (WPARAM)buff); } } else if (((LPNMHDR)lParam)->code == NM_CLICK) { if (notif->iSubItem == 3) { LVITEM lvi; lvi.mask = LVIF_PARAM; lvi.iItem = notif->iItem; if (lvi.iItem < 0) return FALSE; lvi.iSubItem = 0; SendDlgItemMessage(hwndDlg, IDC_LV_CONT_CONTACTS, LVM_GETITEM, 0, (LPARAM)&lvi); MCONTACT hContact = (MCONTACT)lvi.lParam; ContactPolicyMap *cp = (ContactPolicyMap *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); TCHAR buff[50]; ListView_GetItemText(((LPNMHDR)lParam)->hwndFrom, lvi.iItem, 3, buff, _countof(buff)); if (_tcsncmp(buff, TranslateT(LANG_YES), 50) == 0) { (*cp)[hContact].htmlconv = HTMLCONV_DISABLE; ListView_SetItemText(((LPNMHDR)lParam)->hwndFrom, lvi.iItem, 3, TranslateT(LANG_NO)); } else { (*cp)[hContact].htmlconv = HTMLCONV_ENABLE; ListView_SetItemText(((LPNMHDR)lParam)->hwndFrom, lvi.iItem, 3, TranslateT(LANG_YES)); } SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } } } break; case WM_DESTROY: ContactPolicyMap *cpm = (ContactPolicyMap*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); cpm->clear(); delete cpm; break; } return FALSE; }
// always call in context of main thread static void EnsureExtraImages(void) { for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) SetExtraImage(hContact); }