int ExtraImage_ColumnNumToExtraID(int column) { if (HasExtraIconsService()) return column+1; for (int i=0; i<EXTRA_ICON_COUNT; i++) if (ExtraImage_ExtraIDToColumnNum(i)==column) return i; return -1; }
int Clist_SetExtraIcon(MCONTACT hContact, int slot, HANDLE hImage) { if (cli.hwndContactTree == 0) return -1; int icol = ExtraImage_ExtraIDToColumnNum( ConvertToClistSlot(slot)); if (icol == -1) return -1; HANDLE hItem = (HANDLE)SendMessage(cli.hwndContactTree, CLM_FINDCONTACT, hContact, 0); if (hItem == 0) return -1; SendMessage(cli.hwndContactTree, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(icol,hImage)); return 0; }
INT_PTR SetIconForExtraColumn(WPARAM wParam,LPARAM lParam) { pIconExtraColumn piec; int icol; HANDLE hItem; if (pcli->hwndContactTree==0){return(-1);}; if (wParam==0||lParam==0){return(-1);}; piec=(pIconExtraColumn)lParam; if (piec->cbSize!=sizeof(IconExtraColumn)){return(-1);}; icol=ExtraImage_ExtraIDToColumnNum(piec->ColumnType); if (icol==-1){return(-1);}; hItem=(HANDLE)SendMessage(pcli->hwndContactTree,CLM_FINDCONTACT,(WPARAM)wParam,0); if (hItem==0){return(-1);}; SendMessage(pcli->hwndContactTree,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(icol,piec->hImage)); return(0); };
void ExtraImage_SetAllExtraIcons(HWND hwndList,HANDLE hContact) { HANDLE hItem; int locApparentMode=0; char * locApparentModeProto=NULL; boolean hcontgiven=FALSE; char *szProto; char *(ImgIndex[64]); int maxpr,count,i; PROTOACCOUNT **accs; pdisplayNameCacheEntry pdnce; int em,pr,sms,a1,a2,w1,c1; int tick=0; g_mutex_bSetAllExtraIconsCycle=1; hcontgiven=(hContact!=0); if (pcli->hwndContactTree==0){return;}; tick=GetTickCount(); if (ImageCreated==FALSE) ExtraImage_ReloadExtraIcons(); SetNewExtraColumnCount(); BOOL hasExtraIconsService = HasExtraIconsService(); if (!hasExtraIconsService) { em=ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_EMAIL); pr=ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_PROTO); sms=ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_SMS); a1=ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_ADV1); a2=ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_ADV2); w1=ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_WEB); c1=ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_CLIENT); memset( ImgIndex, 0, sizeof( ImgIndex ) ); ProtoEnumAccounts( &count, &accs ); maxpr=0; //calc only needed protocols for(i=0;i<count;i++) { if ( !IsAccountEnabled( accs[i] ) || CallProtoService(accs[i]->szModuleName,PS_GETCAPS,PFLAGNUM_2,0)==0) continue; ImgIndex[maxpr]=accs[i]->szModuleName; maxpr++; } } if (hContact==NULL) { hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); } do { szProto=NULL; hItem=hContact; if (hItem==0){continue;}; pdnce=(pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hItem); if (pdnce==NULL) {continue;}; // szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); szProto=pdnce->m_cache_cszProto; if (!hasExtraIconsService) { { boolean showweb; showweb=FALSE; if (ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_WEB)!=-1) { if (szProto != NULL) { char *homepage; homepage= ModernGetStringA(pdnce->m_cache_hContact,"UserInfo", "Homepage"); if (!homepage) homepage= ModernGetStringA(pdnce->m_cache_hContact,pdnce->m_cache_cszProto, "Homepage"); if (homepage!=NULL) { showweb=TRUE; mir_free_and_nill(homepage); } } SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_WEB),(showweb)?2:0xFF)); } } { DBVARIANT dbv={0}; boolean showemail; showemail=TRUE; if (ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_EMAIL)!=-1) { if (szProto == NULL || ModernGetSettingString(hContact, szProto, "e-mail",&dbv)) { ModernDBFreeVariant(&dbv); if (ModernGetSettingString(hContact, "UserInfo", "Mye-mail0", &dbv)) showemail=FALSE; } SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_EMAIL),(showemail)?0:0xFF)); ModernDBFreeVariant(&dbv); } } { DBVARIANT dbv={0}; boolean showsms; showsms=TRUE; if (ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_SMS)!=-1) { if (szProto == NULL || ModernGetSettingString(hContact, szProto, "Cellular",&dbv)) { ModernDBFreeVariant(&dbv); if (ModernGetSettingString(hContact, "UserInfo", "MyPhone0", &dbv)) showsms=FALSE; } SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_SMS),(showsms)?1:0xFF)); ModernDBFreeVariant(&dbv); } } if(ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_PROTO)!=-1) { for (i=0;i<maxpr;i++) { if(!mir_strcmp(ImgIndex[i],szProto)) { SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_PROTO),i+3)); break; }; }; }; if(ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_VISMODE)!=-1) { BYTE iconIndex=0xFF; if (szProto != NULL) { if (!ModernGetSettingByte(hContact, szProto, "ChatRoom", 0)) { if (pdnce->ApparentMode==ID_STATUS_OFFLINE) iconIndex=ExtraImageIconsIndex[4]; else if (pdnce->ApparentMode==ID_STATUS_ONLINE) { if (szProto!=locApparentModeProto) { locApparentModeProto=szProto; locApparentMode=CallProtoService(locApparentModeProto,PS_GETSTATUS,0,0); } if(locApparentMode == ID_STATUS_INVISIBLE || ModernGetSettingByte(NULL,"CList","AlwaysShowAlwaysVisIcon",SETTING_ALWAYSVISICON_DEFAULT) == 1) iconIndex=ExtraImageIconsIndex[3]; } } else { if (pdnce->ApparentMode==ID_STATUS_OFFLINE) iconIndex=ExtraImageIconsIndex[5]; else iconIndex=255; } } SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(ExtraImage_ExtraIDToColumnNum(EXTRA_ICON_VISMODE),iconIndex)); } } NotifyEventHooks(g_CluiData.hEventExtraImageApplying,(WPARAM)hContact,0); if (hcontgiven) break; Sleep(0); } while(hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0)); tick=GetTickCount()-tick; g_mutex_bSetAllExtraIconsCycle=0; CLUI__cliInvalidateRect(hwndList,NULL,FALSE); Sleep(0); }