static int OnBuildSubGroupMenu(WPARAM wParam,LPARAM lParam) { CLISTMENUITEM mi; BOOL gray1=FALSE; BOOL gray2=FALSE; BOOL showOfflineinGroup=FALSE; struct ClcGroup *group=(struct ClcGroup *)wParam; if (wParam==0) return 0; if (MirandaExiting()) return 0; //contact->group ZeroMemory(&mi,sizeof(mi)); mi.cbSize = sizeof(mi); showOfflineinGroup=CLCItems_IsShowOfflineGroup(group); gray1=(showOfflineinGroup!=FALSE); gray2=(group->hideOffline!=FALSE); if (gray1&&gray2) gray1=FALSE; //should not be cause CLCItems_IsShowOfflineGroup return false if group->hideOffline mi.flags = CMIM_FLAGS | ((group->hideOffline&&!gray1)?CMIF_CHECKED:0)| (gray1?CMIF_GRAYED:0); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hHideOfflineUsersHereMenuItem, (LPARAM)&mi); mi.flags = CMIM_FLAGS | ((showOfflineinGroup&&!gray2) ? CMIF_CHECKED:0)| (gray2?CMIF_GRAYED:0); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hShowOfflineUsersHereMenuItem, (LPARAM)&mi); return 0; };
static int OnBuildSubGroupMenu(WPARAM wParam, LPARAM) { BOOL gray1 = FALSE; BOOL gray2 = FALSE; BOOL showOfflineinGroup = FALSE; ClcGroup *group = (ClcGroup *)wParam; if (wParam == 0) return 0; if (MirandaExiting()) return 0; //contact->group showOfflineinGroup = CLCItems_IsShowOfflineGroup(group); gray1 = (showOfflineinGroup != FALSE); gray2 = (group->hideOffline != FALSE); if (gray1 && gray2) gray1 = FALSE; //should not be cause CLCItems_IsShowOfflineGroup return false if group->hideOffline CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_FLAGS | ((group->hideOffline && !gray1) ? CMIF_CHECKED : 0) | (gray1 ? CMIF_GRAYED : 0); Menu_ModifyItem(hHideOfflineUsersHereMenuItem, &mi); mi.flags = CMIM_FLAGS | ((showOfflineinGroup && !gray2) ? CMIF_CHECKED : 0) | (gray2 ? CMIF_GRAYED : 0); Menu_ModifyItem(hShowOfflineUsersHereMenuItem, &mi); return 0; }
static void _LoadDataToContact(ClcContact *cont, ClcGroup *group, ClcData *dat, MCONTACT hContact) { if (!cont) return; cont->type = CLCIT_CONTACT; cont->SubAllocated = 0; cont->isSubcontact = 0; cont->subcontacts = NULL; cont->szText[0] = 0; cont->lastPaintCounter = 0; cont->image_is_special = FALSE; cont->hContact = hContact; pcli->pfnInvalidateDisplayNameCacheEntry(hContact); ClcCacheEntry *cacheEntry = pcli->pfnGetCacheEntry(hContact); char *szProto = cacheEntry->m_cache_cszProto; cont->proto = szProto; if (szProto != NULL && !pcli->pfnIsHiddenMode(dat, pdnce___GetStatus(cacheEntry))) cont->flags |= CONTACTF_ONLINE; WORD apparentMode = szProto != NULL ? cacheEntry->ApparentMode : 0; if (apparentMode) switch (apparentMode) { case ID_STATUS_OFFLINE: cont->flags |= CONTACTF_INVISTO; break; case ID_STATUS_ONLINE: cont->flags |= CONTACTF_VISTO; break; default: cont->flags |= CONTACTF_VISTO | CONTACTF_INVISTO; } if (cacheEntry->NotOnList) cont->flags |= CONTACTF_NOTONLIST; DWORD idleMode = szProto != NULL ? cacheEntry->IdleTS : 0; if (idleMode) cont->flags |= CONTACTF_IDLE; // Add subcontacts if (szProto) if (dat->IsMetaContactsEnabled && mir_strcmp(cont->proto, META_PROTO) == 0) AddSubcontacts(dat, cont, CLCItems_IsShowOfflineGroup(group)); cont->lastPaintCounter = 0; cont->avatar_pos = AVATAR_POS_DONT_HAVE; Cache_GetAvatar(dat, cont); Cache_GetText(dat, cont, 1); Cache_GetTimezone(dat, cont->hContact); cont->iImage = corecli.pfnGetContactIcon(hContact); cont->bContactRate = db_get_b(hContact, "CList", "Rate", 0); }
// wparam menu handle to pass to clc.c // lparam WM_COMMAND HWND static int OnBuildSubGroupMenu(WPARAM wParam, LPARAM) { ClcGroup *group = (ClcGroup *)wParam; if (wParam == 0) return 0; if (MirandaExiting()) return 0; bool showOfflineinGroup = CLCItems_IsShowOfflineGroup(group); bool gray2 = group->hideOffline == 0; Menu_EnableItem(hShowOfflineUsersHereMenuItem, gray2); Menu_SetChecked(hShowOfflineUsersHereMenuItem, showOfflineinGroup && gray2); return 0; }
void cliRebuildEntireList(HWND hwnd, ClcData *dat) { DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE); ClcGroup *group = NULL; static int rebuildCounter = 0; BOOL PlaceOfflineToRoot = db_get_b(NULL, "CList", "PlaceOfflineToRoot", SETTING_PLACEOFFLINETOROOT_DEFAULT); KillTimer(hwnd, TIMERID_REBUILDAFTER); pcli->bAutoRebuild = false; 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)) { ClcContact *cont = NULL; ClcCacheEntry *cacheEntry = pcli->pfnGetCacheEntry(hContact); int nHiddenStatus = CLVM_GetContactHiddenStatus(hContact, NULL, dat); if ((style & CLS_SHOWHIDDEN && nHiddenStatus != -1) || !nHiddenStatus) { if (mir_tstrlen(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 && 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 && mir_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); }
void cliRebuildEntireList(HWND hwnd,struct ClcData *dat) { DWORD style=GetWindowLong(hwnd,GWL_STYLE); HANDLE hContact; struct ClcContact * cont; struct ClcGroup *group; static int rebuildCounter=0; BOOL PlaceOfflineToRoot=ModernGetSettingByte(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=ModernGetSettingByte(NULL,"CLC","HideOfflineRoot",SETTING_HIDEOFFLINEATROOT_DEFAULT) && style&CLS_USEGROUPS; dat->list.cl.count = dat->list.cl.limit = 0; dat->list.cl.increment = 50; dat->NeedResort=1; HANDLE hSelected = SaveSelection( dat ); dat->selection=-1; dat->HiLightMode=ModernGetSettingByte(NULL,"CLC","HiLightMode",SETTING_HILIGHTMODE_DEFAULT); { int i; TCHAR *szGroupName; DWORD groupFlags; for(i=1;;i++) { szGroupName=pcli->pfnGetGroupName(i,&groupFlags); //UNICODE if(szGroupName==NULL) break; cli_AddGroup(hwnd,dat,szGroupName,groupFlags,i,0); } } hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); while(hContact) { pdisplayNameCacheEntry cacheEntry=NULL; int nHiddenStatus; cont=NULL; cacheEntry=(pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hContact); nHiddenStatus=CLVM_GetContactHiddenStatus(hContact, NULL, dat); if ( (style&CLS_SHOWHIDDEN && nHiddenStatus!=-1) || !nHiddenStatus) { if(lstrlen(cacheEntry->m_cache_tcsGroup)==0) group=&dat->list; else { group=cli_AddGroup(hwnd,dat,cacheEntry->m_cache_tcsGroup,(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 && g_szMetaModuleName && dat->IsMetaContactsEnabled && strcmp(cont->proto,g_szMetaModuleName)==0) AddSubcontacts(dat,cont,CLCItems_IsShowOfflineGroup(group)); } hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0); } 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 void _LoadDataToContact(struct ClcContact * cont, struct ClcGroup *group, struct ClcData *dat, HANDLE hContact) { pdisplayNameCacheEntry cacheEntry=NULL; WORD apparentMode; DWORD idleMode; char * szProto; if (!cont) return; cont->type=CLCIT_CONTACT; cont->SubAllocated=0; cont->isSubcontact=0; cont->subcontacts=NULL; cont->szText[0]=0; cont->lastPaintCounter=0; cont->image_is_special=FALSE; cont->hContact=hContact; pcli->pfnInvalidateDisplayNameCacheEntry(hContact); cacheEntry=(pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hContact); szProto=cacheEntry->m_cache_cszProto; cont->proto=szProto; if(szProto!=NULL&&!pcli->pfnIsHiddenMode(dat,pdnce___GetStatus( cacheEntry ))) cont->flags |= CONTACTF_ONLINE; apparentMode=szProto!=NULL?cacheEntry->ApparentMode:0; if (apparentMode) switch (apparentMode) { case ID_STATUS_OFFLINE: cont->flags|=CONTACTF_INVISTO; break; case ID_STATUS_ONLINE: cont->flags|=CONTACTF_VISTO; break; default: cont->flags|=CONTACTF_VISTO|CONTACTF_INVISTO; } if(cacheEntry->NotOnList) cont->flags|=CONTACTF_NOTONLIST; idleMode=szProto!=NULL?cacheEntry->IdleTS:0; if (idleMode) cont->flags|=CONTACTF_IDLE; //Add subcontacts if (szProto) { if ( g_szMetaModuleName && dat->IsMetaContactsEnabled && mir_strcmp(cont->proto,g_szMetaModuleName)==0) AddSubcontacts(dat,cont,CLCItems_IsShowOfflineGroup(group)); } cont->lastPaintCounter=0; cont->avatar_pos=AVATAR_POS_DONT_HAVE; Cache_GetAvatar(dat,cont); Cache_GetText(dat,cont,1); Cache_GetTimezone(dat,cont->hContact); cont->iImage=CallService(MS_CLIST_GETCONTACTICON,(WPARAM)hContact,1); cont->bContactRate=ModernGetSettingByte(hContact, "CList", "Rate",0); }