Example #1
0
int enumDB_SkinObjectsForEditorProc(const char *szSetting,LPARAM lParam)
{
	if (wildcmp((char *)szSetting,gl_Mask,0)||wildcmp((char *)szSetting,"$*",0))
	{
		char * value;
		char *desc;
		char *descKey;
		descKey=mir_strdup(szSetting);
		descKey[0]='%';
		value= ModernGetStringA(NULL,SKIN,szSetting);
		desc= ModernGetStringA(NULL,SKIN,descKey);
		if (wildcmp(value,"?lyph*",0))
		{
			OPT_OBJECT_DATA * a=(OPT_OBJECT_DATA*)mir_alloc(sizeof(OPT_OBJECT_DATA));
			a->szPath=desc;
			a->szName=mir_strdup(szSetting);
			a->szValue=value;
			a->szTempValue=NULL;
			TreeAddObject(gl_Dlg,gl_controlID,a);
		}
		else
		{
			if (value) mir_free_and_nill(value);
			if (desc) mir_free_and_nill(desc);
		}
		mir_free_and_nill(descKey);		
	}	
	return 0;
}
Example #2
0
void UpdateInfo(HWND hwndDlg)
{
	char *b=MadeString(hwndDlg);
	if (!b) 
	{
		SendDlgItemMessageA(hwndDlg,IDC_EDIT1,WM_SETTEXT,0,(LPARAM)"");
		return;
	}
	SendDlgItemMessageA(hwndDlg,IDC_EDIT1,WM_SETTEXT,0,(LPARAM)b);
	{
		OPT_OBJECT_DATA *sd=NULL;  
		HTREEITEM hti=TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_OBJECT_TREE));				
		if (hti)
		{
			TVITEMA tvi={0};
			tvi.hItem=hti;
			tvi.mask=TVIF_HANDLE|TVIF_PARAM;
			TreeView_GetItem(GetDlgItem(hwndDlg,IDC_OBJECT_TREE),&tvi);
			sd=(OPT_OBJECT_DATA*)(tvi.lParam);
			if (sd)
			{
				if (sd->szValue) mir_free_and_nill(sd->szValue);
				sd->szValue=mir_strdup(b);
			}
		}
	}
	mir_free_and_nill(b);
	glSkinWasModified=1;
}
Example #3
0
int TreeAddObject(HWND hwndDlg, int ID, OPT_OBJECT_DATA * data)
{
	HTREEITEM rootItem=NULL;
	HTREEITEM cItem=NULL;
	char * path;
	char * ptr;
	char * ptrE;
	char buf[255];
	BOOL ext=FALSE;
	path=data->szPath?mir_strdup(data->szPath):(data->szName[1]=='$')?mir_strdup((data->szName)+2):NULL;
	if (!path)
	{
		mir_snprintf(buf,SIZEOF(buf),"$(other)/%s",(data->szName)+1);
		path=mir_strdup(buf);
	}

	ptr=path;
	ptrE=path;	
	do 
	{
		
		while (*ptrE!='/' && *ptrE!='\0') ptrE++;
		if (*ptrE=='/')
		{
			*ptrE='\0';
			ptrE++;
			// find item if not - create;
			{
				cItem=FindChild(GetDlgItem(hwndDlg,ID),rootItem,ptr);
				if (!cItem) // not found - create node
				{
					TVINSERTSTRUCTA tvis;
					tvis.hParent=rootItem;
					tvis.hInsertAfter=TVI_SORT;
					tvis.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_PARAM;
					tvis.item.pszText=ptr;
					tvis.item.lParam=(LPARAM)NULL;
					cItem=TreeView_InsertItemA(GetDlgItem(hwndDlg,ID),&tvis);
					
				}	
				rootItem=cItem;
			}
			ptr=ptrE;
		}
		else ext=TRUE;
	}while (!ext);
	//Insert item node
	{
		TVINSERTSTRUCTA tvis;
		tvis.hParent=rootItem;
		tvis.hInsertAfter=TVI_SORT;
		tvis.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_PARAM;
		tvis.item.pszText=ptr;
		tvis.item.lParam=(LPARAM)data;
		TreeView_InsertItemA(GetDlgItem(hwndDlg,ID),&tvis);
	}
	mir_free_and_nill(path);
	return 0;
}
BOOL RemoveNode(NodeList * FromList)
{
	if (!FromList)  return FALSE;
	if (FromList->itemParent)
	{
		DWORD k;
		for (k=0;k<FromList->itemParent->AllocatedChilds;k++)
			if (&(FromList->itemParent->childNodes[k])==FromList)
			{
				BOOL res=RemoveChildNode(FromList->itemParent,k);				
				return res;
			}
	}
	do 
	{
		RemoveChildNode(FromList,0);
	}while (FromList->AllocatedChilds>0);
	mir_free_and_nill(FromList->childNodes);
	mir_free_and_nill(FromList);
	return TRUE;
}
void * AddTempGroup(HWND hwnd,struct ClcData *dat,const TCHAR *szName,DWORD flags,int groupId,int calcTotalMembers)
{
	int i=0;
	int f=0;
	TCHAR * szGroupName;
	DWORD groupFlags;
#ifdef UNICODE
	char *mbuf=mir_u2a((TCHAR *)szName);
#else
	char *mbuf=mir_strdup((char *)szName);
#endif
	if (wildcmp(mbuf,"-@-HIDDEN-GROUP-@-",0))
	{
		mir_free_and_nill(mbuf);
		return NULL;
	} 
	mir_free_and_nill(mbuf);
	for(i=1;;i++) 
	{
		szGroupName = pcli->pfnGetGroupName(i,&groupFlags);
		if(szGroupName==NULL) break;
		if (!mir_tstrcmpi(szGroupName,szName)) f=1;
	}
	if (!f)
	{
		char buf[20];
		TCHAR b2[255];
		void * res=NULL;
		mir_snprintf(buf,SIZEOF(buf),"%d",(i-1));
		mir_sntprintf(b2,SIZEOF(b2),_T("#%s"),szName);
		b2[0]=1|GROUPF_EXPANDED;
		ModernWriteSettingTString(NULL,"CListGroups",buf,b2);
		pcli->pfnGetGroupName(i,&groupFlags);      
		res=cli_AddGroup(hwnd,dat,szName,groupFlags,i,0);
		return res;
	}
	return NULL;
}
Example #6
0
int GetShortFileName(char * FullFile)
{
	char buf[MAX_PATH]={0};
	char * f=strrchr(FullFile,'\\');
	char * file=f?mir_strdup(f+1):0;
	if (!file) return 0;
	ske_GetFullFilename(buf,file,0,TRUE);
	if (mir_bool_strcmpi(buf,FullFile))
	{
		_snprintf(FullFile,MAX_PATH,"%s",file);
		mir_free_and_nill(file);
		return 1; //skin folder relative
	}
	else
	{
		CallService(MS_UTILS_PATHTORELATIVE,(WPARAM)FullFile,(LPARAM)buf);
		if (buf[0]!='\\' && buf[1]!=':')
			_snprintf(FullFile,MAX_PATH,"\\%s",buf);
		else
			_snprintf(FullFile,MAX_PATH,"%s",buf);
	}
	mir_free_and_nill(file);
	return 2; //mirand folder relative
}
int UnhookAll()
{
	DWORD i;
	TRACE("Unhooked Events:\n");
	if (!hooksrec) return 0;
	for (i=0;i<hooksRecAlloced;i++)
	{
		if (hooksrec[i].hHook!=NULL)
		{
			UnhookEvent(hooksrec[i].hHook);
			hooksrec[i].hHook=NULL;
		}
	}
	mir_free_and_nill(hooksrec);
	hooksRecAlloced=0;
	return 1;
}
void cli_FreeContact(struct ClcContact *p)
{
	if ( p->SubAllocated) {
		if ( p->subcontacts && !p->isSubcontact) {
			int i;
			for ( i = 0 ; i < p->SubAllocated ; i++ ) {
				p->subcontacts[i].ssText.DestroySmileyList();
				if ( p->subcontacts[i].avatar_pos==AVATAR_POS_ANIMATED )
					AniAva_RemoveAvatar( p->subcontacts[i].hContact );
					p->subcontacts[i].avatar_pos=AVATAR_POS_DONT_HAVE;
			}
			mir_free_and_nill(p->subcontacts);
	}	}

	p->ssText.DestroySmileyList();
	if ( p->avatar_pos==AVATAR_POS_ANIMATED )
		AniAva_RemoveAvatar( p->hContact );
	p->avatar_pos=AVATAR_POS_DONT_HAVE;
	corecli.pfnFreeContact( p );
}
BOOL RemoveChildNode(NodeList * FromList, DWORD index)
{
	DWORD i;
	NodeList * work;
	if (!FromList) return FALSE;
	if (FromList->AllocatedChilds<=index) return FALSE;
	work=&(FromList->childNodes[index]);
	for(i=0; i<work->AllocatedChilds; i++)
	{
		if (work->childNodes[i].AllocatedChilds)
			RemoveChildNode(work->childNodes,i);
	}
	if (work->AllocatedChilds) 
	{
		mir_free_and_nill(work->childNodes);
		work->AllocatedChilds=0;
	}
	//mir_free_and_nill(work);
	memmove(FromList->childNodes+index,FromList->childNodes+index+1,sizeof(NodeList)*(FromList->AllocatedChilds-index-1));
	FromList->AllocatedChilds--;
	return TRUE;
}
Example #10
0
INT_PTR CALLBACK DlgSkinEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
	case WM_DESTROY: 
		{
			if (object_clipboard) mir_free_and_nill(object_clipboard);
			break;
		}
	case WM_WINDOWPOSCHANGED:
		{
			WINDOWPOS * wp=(WINDOWPOS *)lParam;
			if (lParam && wp->flags&SWP_SHOWWINDOW)
			{
				if (glOtherSkinWasLoaded)
				{
					TreeView_DeleteAllItems(GetDlgItem(hwndDlg,IDC_OBJECT_TREE));
					FillObjectTree(hwndDlg,IDC_OBJECT_TREE,"$$*");
					glSkinWasModified=0;
					glOtherSkinWasLoaded=FALSE;
				}
			}
			break;
		}
	case WM_INITDIALOG:
		{ 			
			TranslateDialogDefault(hwndDlg);
			FillObjectTree(hwndDlg,IDC_OBJECT_TREE,"$$*");
			{	//Fill types combo
				int i=0;
				for (i=0; i<SIZEOF(TYPES); i++)
					SendDlgItemMessage(hwndDlg,IDC_TYPE,CB_ADDSTRING,0,(LPARAM)TranslateTS(TYPES[i]));
			}
			{	//Fill fit combo
				int i=0;
				for (i=0; i<SIZEOF(FITMODES); i++)
					SendDlgItemMessage(hwndDlg,IDC_FIT,CB_ADDSTRING,0,(LPARAM)TranslateTS(FITMODES[i]));
			}
			//SPIN Ranges
			{
				SendDlgItemMessage(hwndDlg,IDC_SPIN_ALPHA,UDM_SETRANGE,0,MAKELONG(255,0));
				SendDlgItemMessage(hwndDlg,IDC_SPIN_ALPHA,UDM_SETPOS,0,MAKELONG(255,0));

				SendDlgItemMessage(hwndDlg,IDC_SPIN_TOP,UDM_SETRANGE,0,MAKELONG(900,0));
				SendDlgItemMessage(hwndDlg,IDC_SPIN_LEFT,UDM_SETRANGE,0,MAKELONG(900,0));
				SendDlgItemMessage(hwndDlg,IDC_SPIN_BOTTOM,UDM_SETRANGE,0,MAKELONG(900,0));
				SendDlgItemMessage(hwndDlg,IDC_SPIN_RIGHT,UDM_SETRANGE,0,MAKELONG(900,0));
				
				SendDlgItemMessage(hwndDlg,IDC_SPIN_POSLEFT,UDM_SETRANGE,0,MAKELONG(1000,0));
				SendDlgItemMessage(hwndDlg,IDC_SPIN_POSTOP,UDM_SETRANGE,0,MAKELONG(1000,0));
				SendDlgItemMessage(hwndDlg,IDC_SPIN_WIDTH,UDM_SETRANGE,0,MAKELONG(1000,0));
				SendDlgItemMessage(hwndDlg,IDC_SPIN_HEIGHT,UDM_SETRANGE,0,MAKELONG(1000,0));
			}		
			EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_1),FALSE);
			EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_COLOUR),FALSE);
			EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_ALPHA),FALSE);
			EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_2),FALSE);
			EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_3),FALSE);
			EnableWindow(GetDlgItem(hwndDlg,IDC_PASTE),FALSE);
			EnableWindow(GetDlgItem(hwndDlg,IDC_COPY),FALSE);
			glSkinWasModified=0;
			glOtherSkinWasLoaded=FALSE;
			break;
		}

	case WM_COMMAND:	
		{	
			if (LOWORD(wParam)==IDC_TYPE)
			{
				if (HIWORD(wParam)==CBN_SELCHANGE)
				{
					int i=SendDlgItemMessage(hwndDlg,IDC_TYPE,CB_GETCURSEL,(WPARAM)0,(LPARAM)0);
					//if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_TYPE)))
						SetAppropriateGroups(hwndDlg,i);
					if (GetFocus()==GetDlgItem(hwndDlg,IDC_TYPE))
						SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
					UpdateInfo(hwndDlg);
					break;
				}
			}
			else if (LOWORD(wParam)==IDC_COPY)
			{
				if (HIWORD(wParam)==BN_CLICKED)
				{
					if (object_clipboard) mir_free_and_nill(object_clipboard);
					object_clipboard=NULL;
					{
							OPT_OBJECT_DATA *sd=NULL;  
							HTREEITEM hti=TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_OBJECT_TREE));				
							if (hti!=0)
							{
								TVITEM tvi={0};
								tvi.hItem=hti;
								tvi.mask=TVIF_HANDLE|TVIF_PARAM;
								TreeView_GetItem(GetDlgItem(hwndDlg,IDC_OBJECT_TREE),&tvi);
								sd=(OPT_OBJECT_DATA*)(tvi.lParam);
							}
							if (sd && sd->szValue) 
								object_clipboard=mir_strdup(sd->szValue);
					}
					EnableWindow(GetDlgItem(hwndDlg,IDC_PASTE),object_clipboard!=NULL);
					return 0;
				}

			}
			else if (LOWORD(wParam)==IDC_PASTE)
			{
				if (HIWORD(wParam)==BN_CLICKED)
				{
					if (object_clipboard) 
						SetControls(hwndDlg, object_clipboard);
					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
					UpdateInfo(hwndDlg);
					return 0;
				}
			}
			else if (LOWORD(wParam)==IDC_COLOR)
			{
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				UpdateInfo(hwndDlg);
			}
			else if (LOWORD(wParam)==IDC_BROWSE)
			{
				if (HIWORD(wParam)==BN_CLICKED)
				{
					{   		
						char str[MAX_PATH]={0};
						OPENFILENAMEA ofn={0};
						char filter[512]={0};
						int res=0;
						ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
						ofn.hwndOwner = hwndDlg;
						ofn.hInstance = NULL;					
						ofn.lpstrFilter = "Images (*.png,*.jpg,*.bmp,*.gif,*.tga)\0*.png;*.jpg;*.jpeg;*.bmp;*.gif;*.tga\0All files (*.*)\0*.*\0\0";
						ofn.Flags = (OFN_FILEMUSTEXIST | OFN_HIDEREADONLY);
						SendDlgItemMessageA(hwndDlg,IDC_FILE,WM_GETTEXT,(WPARAM)SIZEOF(str),(LPARAM)str);
						if (str[0]=='\0' || strchr(str,'%'))
						{
							ofn.Flags|=OFN_NOVALIDATE;
							str[0]='\0';
						}
						else
						{
							ske_GetFullFilename(str,str,(char*)0,TRUE);
						}
						ofn.lpstrFile = str;
						
						ofn.nMaxFile = SIZEOF(str);
						ofn.nMaxFileTitle = MAX_PATH;
						ofn.lpstrDefExt = "*.*";
//						{
//							DWORD tick=GetTickCount();
							res=GetOpenFileNameA(&ofn);
//							if(!res) 
//								if (GetTickCount()-tick<100)
//								{
//									res=GetOpenFileNameA(&ofn);
//									if(!res) break;
//								}
//								else break;
						//}
						if (res)
						{
							GetShortFileName(ofn.lpstrFile);
							SendDlgItemMessageA(hwndDlg,IDC_FILE,WM_SETTEXT,(WPARAM)0,(LPARAM)ofn.lpstrFile);
							SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
							UpdateInfo(hwndDlg);						
						}
					}
				}
			}
			else if (LOWORD(wParam)==IDC_FILE)
			{
				if (HIWORD(wParam) == EN_CHANGE)
				{
					fileChanged=TRUE;
					if ((HWND)lParam != GetFocus())
					{
						GetFileSizes(hwndDlg);
						fileChanged=FALSE;
					}
				}
				else if (HIWORD(wParam) == EN_KILLFOCUS)
				{
					if (fileChanged)
					{
						GetFileSizes(hwndDlg);
						fileChanged=FALSE;
					}
				}
			}
			else if ((
				(LOWORD(wParam)==IDC_E_TOP
			   ||LOWORD(wParam)==IDC_E_BOTTOM
			   ||LOWORD(wParam)==IDC_E_LEFT
			   ||LOWORD(wParam)==IDC_E_RIGHT
			   ||LOWORD(wParam)==IDC_E_X
			   ||LOWORD(wParam)==IDC_E_Y
			   ||LOWORD(wParam)==IDC_E_W
			   ||LOWORD(wParam)==IDC_E_H
			   ||LOWORD(wParam)==IDC_EDIT_ALPHA
			   ) 
				&& HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()))
			{
				return 0;
			}
			else if (LOWORD(wParam)!=IDC_EDIT1)
			{
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				UpdateInfo(hwndDlg);
			}
			//check (LOWORD(wParam))
			//SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;
		}
	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->idFrom) 
		{
		case IDC_OBJECT_TREE:
				{
					//Save existed object
					//Change to new object
					NMTREEVIEWA * nmtv = (NMTREEVIEWA *) lParam;
					if (!nmtv) return 0;
					if (nmtv->hdr.code==TVN_SELCHANGEDA || nmtv->hdr.code==TVN_SELCHANGEDW)
					{
						if (nmtv->itemOld.lParam)
						{
								OPT_OBJECT_DATA * dataOld=(OPT_OBJECT_DATA*)nmtv->itemOld.lParam;
								if (dataOld->szValue)								
								{
									mir_free_and_nill(dataOld->szValue);
									dataOld->szValue=MadeString(hwndDlg);
								}
						}
						if (nmtv->itemNew.lParam)
						{
						
							OPT_OBJECT_DATA * data=(OPT_OBJECT_DATA*)nmtv->itemNew.lParam;
							char buf[255];
							
							mir_snprintf(buf,SIZEOF(buf),"%s=%s",data->szName, data->szValue);						
							SendDlgItemMessageA(hwndDlg,IDC_EDIT1,WM_SETTEXT,0,(LPARAM)buf);					
							SetControls(hwndDlg,data->szValue);
							EnableWindow(GetDlgItem(hwndDlg,IDC_COPY),TRUE);
							EnableWindow(GetDlgItem(hwndDlg,IDC_PASTE),object_clipboard!=NULL);
						}
						else
						{
							SendDlgItemMessageA(hwndDlg,IDC_EDIT1,WM_SETTEXT,0,(LPARAM)"");
							SetControls(hwndDlg,NULL);
							EnableWindow(GetDlgItem(hwndDlg,IDC_COPY),FALSE);
							EnableWindow(GetDlgItem(hwndDlg,IDC_PASTE),FALSE);
						}

					}
					else if (nmtv->hdr.code==TVN_DELETEITEMA)
					{
						OPT_OBJECT_DATA * dataOld=(OPT_OBJECT_DATA*)nmtv->itemOld.lParam;
						if (dataOld)
						{
							if (dataOld->szName) mir_free_and_nill(dataOld->szName);
							if (dataOld->szPath) mir_free_and_nill(dataOld->szPath);
							if (dataOld->szTempValue) mir_free_and_nill(dataOld->szTempValue);
							if (dataOld->szValue) mir_free_and_nill(dataOld->szValue);
						}
					}
					return 0;
				}

		case 0:
			switch (((LPNMHDR)lParam)->code)
			{
			case PSN_APPLY:
				if (!glOtherSkinWasLoaded) //store only if skin is same
				{
					StoreTreeToDB(GetDlgItem(hwndDlg,IDC_OBJECT_TREE),SKIN);
					//ReloadSkin
					ske_LoadSkinFromDB();	
					pcli->pfnClcBroadcast( INTM_RELOADOPTIONS,0,0);
					Sync(CLUIFrames_OnClistResize_mod,0,0);
					ske_RedrawCompleteWindow();        
					Sync(CLUIFrames_OnClistResize_mod, (WPARAM)0, (LPARAM)0);
					{
						HWND hwnd=pcli->hwndContactList;
						RECT rc={0};
						GetWindowRect(hwnd, &rc);
						Sync(CLUIFrames_OnMoving,hwnd,&rc);
					}
					return TRUE;
				}
				else 
					return TRUE;
			}
			break;
		}
	}
	return FALSE;
}
Example #11
0
/*
*	Get the text for specified lines
*/
int Cache_GetLineText(PDNCE pdnce, int type, LPTSTR text, int text_size, TCHAR *variable_text, BOOL xstatus_has_priority, 
                      BOOL show_status_if_no_away, BOOL show_listening_if_no_away, BOOL use_name_and_message_for_xstatus, 
                      BOOL pdnce_time_show_only_if_different)
{
    text[0] = '\0';
    switch(type)
    {
    case TEXT_STATUS:
        {
            if (GetStatusName(text, text_size, pdnce, xstatus_has_priority) == -1 && use_name_and_message_for_xstatus)
            {
                DBVARIANT dbv={0};

                // Try to get XStatusMsg
                if (!ModernGetSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusMsg", &dbv)) 
                {
                    if (dbv.ptszVal != NULL && dbv.ptszVal[0] != 0)
                    {
                        TCHAR *tmp = mir_tstrdup(text);
                        mir_sntprintf(text, text_size, TEXT("%s: %s"), tmp, dbv.pszVal);
                        mir_free_and_nill(tmp);
                        CopySkipUnprintableChars(text, text, text_size-1);
                    }
                    ModernDBFreeVariant(&dbv);
                }
            }

            return TEXT_STATUS;
        }
    case TEXT_NICKNAME:
        {
            if (pdnce->m_cache_hContact && pdnce->m_cache_cszProto)
            {
                DBVARIANT dbv={0};
                if (!ModernGetSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "Nick", &dbv)) 
                {
                    lstrcpyn(text, dbv.ptszVal, text_size);
                    ModernDBFreeVariant(&dbv);
                    CopySkipUnprintableChars(text, text, text_size-1);
                }
            }

            return TEXT_NICKNAME;
        }
    case TEXT_STATUS_MESSAGE:
        {
            if (GetStatusMessage(text, text_size, pdnce, xstatus_has_priority) == -1 && use_name_and_message_for_xstatus)
            {
                DBVARIANT dbv={0};

                // Try to get XStatusName
                if (!ModernGetSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv)) 
                {
                    if (dbv.pszVal != NULL && dbv.pszVal[0] != 0)
                    {
                        TCHAR *tmp = mir_tstrdup(text);
                        
                        mir_sntprintf(text, text_size, TEXT("%s: %s"), dbv.pszVal, tmp);                        
                        mir_free_and_nill(tmp);
                    }
                    CopySkipUnprintableChars(text, text, text_size-1);
                    ModernDBFreeVariant(&dbv);
                }
            }
            else if (use_name_and_message_for_xstatus && xstatus_has_priority)
            {
                DBVARIANT dbv={0};
                // Try to get XStatusName
                if (!ModernGetSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv)) 
                {
                    if (dbv.pszVal != NULL && dbv.pszVal[0] != 0)
                        mir_sntprintf(text, text_size, TEXT("%s"), dbv.pszVal);
                    CopySkipUnprintableChars(text, text, text_size-1);
                    ModernDBFreeVariant(&dbv);
                }
            }

            if (text[0] == '\0')
            {
                if (show_listening_if_no_away)
                {
                    Cache_GetLineText(pdnce, TEXT_LISTENING_TO, text, text_size, variable_text, xstatus_has_priority, 0, 0, use_name_and_message_for_xstatus, pdnce_time_show_only_if_different);
                    if (text[0] != '\0')
                        return TEXT_LISTENING_TO;
                }

                if (show_status_if_no_away)
                {
                    //re-request status if no away
                    return Cache_GetLineText(pdnce, TEXT_STATUS, text, text_size, variable_text, xstatus_has_priority, 0, 0, use_name_and_message_for_xstatus, pdnce_time_show_only_if_different);		
                }
            }
            return TEXT_STATUS_MESSAGE;
        }
    case TEXT_LISTENING_TO:
        {
            GetListeningTo(text, text_size, pdnce);
            return TEXT_LISTENING_TO;
        }
    case TEXT_TEXT:
        {
            TCHAR *tmp = variables_parsedup(variable_text, pdnce->m_cache_tcsName, pdnce->m_cache_hContact);
            lstrcpyn(text, tmp, text_size);
            if (tmp) free(tmp);
            CopySkipUnprintableChars(text, text, text_size-1);

            return TEXT_TEXT;
        }
    case TEXT_CONTACT_TIME:
        {
            if (pdnce->hTimeZone)
            {
                // Get pdnce time
                text[0] = 0;
                tmi.printDateTime( pdnce->hTimeZone, _T("t"), text, text_size, 0);
            }

            return TEXT_CONTACT_TIME;
        }
    }

    return TEXT_EMPTY;
}
void AddSubcontacts(struct ClcData *dat, struct ClcContact * cont, BOOL showOfflineHereGroup)
{
	int subcount,i,j;
	HANDLE hsub;
	pdisplayNameCacheEntry cacheEntry;
	cacheEntry=(pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(cont->hContact);
	cont->SubExpanded=(ModernGetSettingByte(cont->hContact,"CList","Expanded",0) && (ModernGetSettingByte(NULL,"CLC","MetaExpanding",SETTING_METAEXPANDING_DEFAULT)));
	subcount=(int)CallService(MS_MC_GETNUMCONTACTS,(WPARAM)cont->hContact,0);

	if (subcount <= 0) {
		cont->isSubcontact=0;
		cont->subcontacts=NULL;
		cont->SubAllocated=0;
		return;
	}

	cont->isSubcontact=0;
    mir_free(cont->subcontacts);
	cont->subcontacts=(struct ClcContact *) mir_calloc(sizeof(struct ClcContact)*subcount);
	cont->SubAllocated=subcount;
	i=0;
	for (j=0; j<subcount; j++) {
		WORD wStatus;
		
		hsub=(HANDLE)CallService(MS_MC_GETSUBCONTACT,(WPARAM)cont->hContact,j);
		cacheEntry=(pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hsub);
		wStatus=pdnce___GetStatus( cacheEntry );
		if (showOfflineHereGroup||(!(ModernGetSettingByte(NULL,"CLC","MetaHideOfflineSub",SETTING_METAHIDEOFFLINESUB_DEFAULT) && ModernGetSettingByte(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT) ) ||
			wStatus!=ID_STATUS_OFFLINE )
			//&&
			//(!cacheEntry->Hidden || style&CLS_SHOWHIDDEN)
			)

		{
			cont->subcontacts[i].hContact=cacheEntry->m_cache_hContact;

			cont->subcontacts[i].avatar_pos = AVATAR_POS_DONT_HAVE;
			Cache_GetAvatar(dat, &cont->subcontacts[i]);

			cont->subcontacts[i].iImage=CallService(MS_CLIST_GETCONTACTICON,(WPARAM)cacheEntry->m_cache_hContact,1);
			memset(cont->subcontacts[i].iExtraImage,0xFF,sizeof(cont->subcontacts[i].iExtraImage));
			memset((void*)cont->subcontacts[i].iWideExtraImage,0xFF,sizeof(cont->subcontacts[i].iWideExtraImage));
			cont->subcontacts[i].proto=cacheEntry->m_cache_cszProto;		
			cont->subcontacts[i].type=CLCIT_CONTACT;
			cont->subcontacts[i].flags=0;//CONTACTF_ONLINE;
			cont->subcontacts[i].isSubcontact=i+1;
            cont->subcontacts[i].lastPaintCounter=0;
			cont->subcontacts[i].subcontacts=cont;
			cont->subcontacts[i].image_is_special=FALSE;
			//cont->subcontacts[i].status=cacheEntry->status;
			Cache_GetTimezone(dat, (&cont->subcontacts[i])->hContact);
			Cache_GetText(dat, &cont->subcontacts[i],1);

			{
				int apparentMode;
				char *szProto;  
				int idleMode;
				szProto=cacheEntry->m_cache_cszProto;
				if(szProto!=NULL && !pcli->pfnIsHiddenMode(dat,wStatus))
					cont->subcontacts[i].flags|=CONTACTF_ONLINE;
				apparentMode=szProto!=NULL?cacheEntry->ApparentMode:0;
				apparentMode=szProto!=NULL?cacheEntry->ApparentMode:0;
				if(apparentMode==ID_STATUS_OFFLINE)	cont->subcontacts[i].flags|=CONTACTF_INVISTO;
				else if(apparentMode==ID_STATUS_ONLINE) cont->subcontacts[i].flags|=CONTACTF_VISTO;
				else if(apparentMode) cont->subcontacts[i].flags|=CONTACTF_VISTO|CONTACTF_INVISTO;
				if(cacheEntry->NotOnList) cont->subcontacts[i].flags|=CONTACTF_NOTONLIST;
				idleMode=szProto!=NULL?cacheEntry->IdleTS:0;
				if (idleMode) cont->subcontacts[i].flags|=CONTACTF_IDLE;
            }
			i++;
		}	}

	cont->SubAllocated=i;
	if (!i && cont->subcontacts != NULL) mir_free_and_nill(cont->subcontacts);
}
INT_PTR CALLBACK DlgSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch ( msg )
	{
	case WM_DESTROY: 
		{
			if ( hPreviewBitmap ) ske_UnloadGlyphImage( hPreviewBitmap );
			break;
		}

	case WM_INITDIALOG:
		{ 
			HTREEITEM it;
			TranslateDialogDefault( hwndDlg );
			it = FillAvailableSkinList( hwndDlg );
			HWND wnd = GetDlgItem( hwndDlg, IDC_TREE1 );
			TreeView_SelectItem( wnd, it );						
		}
		return 0;
	case WM_COMMAND:
		{
			int isLoad = 0;
			switch ( LOWORD( wParam ) ) 
			{
			case IDC_COLOUR_MENUNORMAL:
			case IDC_COLOUR_MENUSELECTED:
			case IDC_COLOUR_FRAMES:
			case IDC_COLOUR_STATUSBAR:
				SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
				break;

			case IDC_BUTTON_INFO:
				{
					TCHAR Author[255];
					TCHAR URL[MAX_PATH];
					TCHAR Contact[255];
					TCHAR Description[400];
					TCHAR text[2000];
					SkinListData *sd = NULL;  
					HTREEITEM hti = TreeView_GetSelection( GetDlgItem( hwndDlg, IDC_TREE1 ) );				
					if ( hti == 0 ) return 0;
					{
						TVITEM tvi = {0};
						tvi.hItem = hti;
						tvi.mask = TVIF_HANDLE|TVIF_PARAM;
						TreeView_GetItem( GetDlgItem( hwndDlg, IDC_TREE1 ), &tvi );
						sd = ( SkinListData* )( tvi.lParam );
					}
					if ( !sd ) return 0;
					if ( sd->File && !_tcschr( sd->File, _T('%') ) )
					{
						GetPrivateProfileString( _T( "Skin_Description_Section" ), _T( "Author" ), 	TranslateT( "( unknown )" ), 	Author, 		SIZEOF( Author ), 		sd->File );
						GetPrivateProfileString( _T( "Skin_Description_Section" ), _T( "URL" ), 		_T( "" ), 						URL, 		SIZEOF( URL ), 		sd->File );
						GetPrivateProfileString( _T( "Skin_Description_Section" ), _T( "Contact" ), 	_T( "" ), 						Contact, 	SIZEOF( Contact ), 	sd->File );
						GetPrivateProfileString( _T( "Skin_Description_Section" ), _T( "Description" ), _T( "" ), 					Description, SIZEOF( Description ), sd->File );
						_sntprintf( text, SIZEOF( text ), TranslateT( "%s\n\n%s\n\nAuthor(s):\t %s\nContact:\t %s\nWeb:\t %s\n\nFile:\t %s" ), 
							sd->Name, Description, Author, Contact, URL, sd->File );
					}
					else
					{
						_sntprintf( text, SIZEOF( text ), TranslateT( "%s\n\n%s\n\nAuthor(s): %s\nContact:\t %s\nWeb:\t %s\n\nFile:\t %s" ), 
							TranslateT( "reVista for Modern v0.5" ), 
							TranslateT( "This is second default Modern Contact list skin in Vista Aero style" ), 
							TranslateT( "Angeli-Ka (graphics), FYR (template)" ), 
							_T( "JID: [email protected]" ), 
							_T("fyr.mirandaim.ru"), 
							TranslateT( "Inside library" ) );
					}
					MessageBox( hwndDlg, text, TranslateT( "Skin Information" ), MB_OK|MB_ICONINFORMATION );
				}
				break;
			case IDC_BUTTON_APPLY_SKIN:
				if ( HIWORD( wParam ) == BN_CLICKED )
				{ 		
					SkinListData *sd = NULL;  
					HTREEITEM hti = TreeView_GetSelection( GetDlgItem( hwndDlg, IDC_TREE1 ) );				
					if ( hti == 0 ) return 0;
					{
						TVITEM tvi = {0};
						tvi.hItem = hti;
						tvi.mask = TVIF_HANDLE|TVIF_PARAM;
						TreeView_GetItem( GetDlgItem( hwndDlg, IDC_TREE1 ), &tvi );
						sd = ( SkinListData* )( tvi.lParam );
					}
					if ( !sd ) return 0;
					if ( glSkinWasModified>0 )
					{
						int res = 0;
						if ( glSkinWasModified == 1 )
							res = MessageBox( hwndDlg, TranslateT( "Skin editor contains not stored changes.\n\nAll changes will be lost.\n\n Continue to load new skin?" ), TranslateT( "Warning!" ), MB_OKCANCEL|MB_ICONWARNING|MB_DEFBUTTON2|MB_TOPMOST );
						else
							res = MessageBox( hwndDlg, TranslateT( "Current skin was not saved to file.\n\nAll changes will be lost.\n\n Continue to load new skin?" ), TranslateT( "Warning!" ), MB_OKCANCEL|MB_ICONWARNING|MB_DEFBUTTON2|MB_TOPMOST );
						if ( res!= IDOK ) return 0;
					}
					ske_LoadSkinFromIniFile( sd->File, FALSE );
					ske_LoadSkinFromDB( );	
					glOtherSkinWasLoaded = TRUE;
					pcli->pfnClcBroadcast( INTM_RELOADOPTIONS, 0, 0 );
					Sync( CLUIFrames_OnClistResize_mod, 0, 0 );
					ske_RedrawCompleteWindow( );        
					Sync( CLUIFrames_OnClistResize_mod, 0, 0 );
					{
						HWND hwnd = pcli->hwndContactList;
						RECT rc = {0};
						GetWindowRect( hwnd, &rc );
						Sync( CLUIFrames_OnMoving, hwnd, &rc );
					}
					if ( g_hCLUIOptionsWnd )
					{
						SendDlgItemMessage( g_hCLUIOptionsWnd, IDC_LEFTMARGINSPIN, UDM_SETPOS, 0, ModernGetSettingByte( NULL, "CLUI", "LeftClientMargin", SETTING_LEFTCLIENTMARIGN_DEFAULT ) );
						SendDlgItemMessage( g_hCLUIOptionsWnd, IDC_RIGHTMARGINSPIN, UDM_SETPOS, 0, ModernGetSettingByte( NULL, "CLUI", "RightClientMargin", SETTING_RIGHTCLIENTMARIGN_DEFAULT ) );
						SendDlgItemMessage( g_hCLUIOptionsWnd, IDC_TOPMARGINSPIN, UDM_SETPOS, 0, ModernGetSettingByte( NULL, "CLUI", "TopClientMargin", SETTING_TOPCLIENTMARIGN_DEFAULT ) );
						SendDlgItemMessage( g_hCLUIOptionsWnd, IDC_BOTTOMMARGINSPIN, UDM_SETPOS, 0, ModernGetSettingByte( NULL, "CLUI", "BottomClientMargin", SETTING_BOTTOMCLIENTMARIGN_DEFAULT ) );
					}
				}
				break;
			case IDC_BUTTON_LOAD:
				isLoad = 1;
				if ( HIWORD( wParam ) == BN_CLICKED )
				{
					{   		
						TCHAR str[MAX_PATH] = {0};
						OPENFILENAME ofn = {0};
						TCHAR filter[512] = {0};
						int res = 0;
						ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
						ofn.hwndOwner = hwndDlg;
						ofn.hInstance = NULL;

						mir_sntprintf(filter, SIZEOF(filter), _T("%s (*.msf)%c*.MSF%c%c"), TranslateT("Miranda skin file"), 0, 0, 0);
						ofn.lpstrFilter = filter;
						ofn.lpstrFile = str;
						ofn.Flags = isLoad?( OFN_FILEMUSTEXIST | OFN_HIDEREADONLY ) : ( OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY ) | OFN_DONTADDTORECENT;
						ofn.nMaxFile = sizeof( str );
						ofn.nMaxFileTitle = MAX_PATH;
						ofn.lpstrDefExt = _T( "msf" );

						{
							DWORD tick = GetTickCount( );
							res = GetOpenFileName( &ofn );
							if( !res ) 
								if ( GetTickCount( )-tick<100 )
								{
									res = GetOpenFileName( &ofn );
									if( !res ) break;
								}
								else break;
						}
						if ( res )
						{
							HTREEITEM it = AddSkinToListFullName( hwndDlg, ofn.lpstrFile );
							TreeView_SelectItem( GetDlgItem( hwndDlg, IDC_TREE1 ), it );
							//SendDlgItemMessage( hwndDlg, IDC_SKINS_LIST, LB_SETCURSEL, it, 0 ); 
							//SendMessage( hwndDlg, WM_COMMAND, MAKEWPARAM( IDC_SKINS_LIST, LBN_SELCHANGE ), 0 );
						}
					}
				}
			}
			break;
		}
	case WM_DRAWITEM:
		if ( wParam == IDC_PREVIEW )
		{
			//TODO:Draw hPreviewBitmap here
			HDC memDC, imgDC;
			HBITMAP hbmp, holdbmp, imgOldbmp;
			int mWidth, mHeight;
			RECT workRect = {0};
			HBRUSH hbr = CreateSolidBrush( GetSysColor( COLOR_3DFACE ) );
			DRAWITEMSTRUCT *dis = ( DRAWITEMSTRUCT * )lParam;
			mWidth = dis->rcItem.right-dis->rcItem.left;
			mHeight = dis->rcItem.bottom-dis->rcItem.top;
			memDC = CreateCompatibleDC( dis->hDC );
			hbmp = ske_CreateDIB32( mWidth, mHeight );
			holdbmp = ( HBITMAP )SelectObject( memDC, hbmp );
			workRect = dis->rcItem;
			OffsetRect( &workRect, -workRect.left, -workRect.top );
			FillRect( memDC, &workRect, hbr );     
			DeleteObject( hbr );
			if ( hPreviewBitmap )
			{
				//variables
				BITMAP bmp = {0};
				POINT imgPos = {0};
				int wWidth, wHeight;
				int dWidth, dHeight;
				float xScale = 1, yScale = 1;
				//GetSize
				GetObject( hPreviewBitmap, sizeof( BITMAP ), &bmp );
				wWidth = workRect.right-workRect.left;
				wHeight = workRect.bottom-workRect.top;
				if ( wWidth<bmp.bmWidth ) xScale = ( float )wWidth/bmp.bmWidth;
				if ( wHeight<bmp.bmHeight ) yScale = ( float )wHeight/bmp.bmHeight;
				xScale = min( xScale, yScale );
				yScale = xScale;                    
				dWidth = ( int )( xScale*bmp.bmWidth );
				dHeight = ( int )( yScale*bmp.bmHeight );
				//CalcPosition
				imgPos.x = workRect.left+( ( wWidth-dWidth )>>1 );
				imgPos.y = workRect.top+( ( wHeight-dHeight )>>1 );     
				//DrawImage
				if ( !g_CluiData.fGDIPlusFail ) //Use gdi+ engine
				{
					DrawAvatarImageWithGDIp( memDC, imgPos.x, imgPos.y, dWidth, dHeight, hPreviewBitmap, 0, 0, bmp.bmWidth, bmp.bmHeight, 8, 255 );
				}   
				else
				{
					BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
					imgDC = CreateCompatibleDC( dis->hDC );
					imgOldbmp = ( HBITMAP )SelectObject( imgDC, hPreviewBitmap );                 
					ske_AlphaBlend( memDC, imgPos.x, imgPos.y, dWidth, dHeight, imgDC, 0, 0, bmp.bmWidth, bmp.bmHeight, bf );
					SelectObject( imgDC, imgOldbmp );
					mod_DeleteDC( imgDC );
				}
			}
			BitBlt( dis->hDC, dis->rcItem.left, dis->rcItem.top, mWidth, mHeight, memDC, 0, 0, SRCCOPY );
			SelectObject( memDC, holdbmp );
			DeleteObject( hbmp );
			mod_DeleteDC( memDC );
		}
		break;

	case WM_NOTIFY:
		switch ( ( ( LPNMHDR )lParam )->idFrom ) 
		{
		case IDC_TREE1:
			{		
				NMTREEVIEW * nmtv = ( NMTREEVIEW * ) lParam;
				if ( !nmtv ) return 0;
				if ( nmtv->hdr.code == TVN_SELCHANGEDA
					|| nmtv->hdr.code == TVN_SELCHANGEDW )
				{	
					SkinListData * sd = NULL;
					if ( hPreviewBitmap ) 
					{
						ske_UnloadGlyphImage( hPreviewBitmap );
						hPreviewBitmap = NULL;
					}
					if ( nmtv->itemNew.lParam )
					{
						sd = ( SkinListData* )nmtv->itemNew.lParam;
						{
							TCHAR buf[MAX_PATH];
							CallService( MS_UTILS_PATHTORELATIVET, ( WPARAM )sd->File, ( LPARAM )buf );
							SendDlgItemMessage( hwndDlg, IDC_EDIT_SKIN_FILENAME, WM_SETTEXT, 0, ( LPARAM )buf );
						}
						{
							TCHAR prfn[MAX_PATH] = {0};
							TCHAR imfn[MAX_PATH] = {0};
							TCHAR skinfolder[MAX_PATH] = {0};
							GetPrivateProfileString( _T( "Skin_Description_Section" ), _T( "Preview" ), _T( "" ), imfn, SIZEOF( imfn ), sd->File );
							IniParser::GetSkinFolder( sd->File, skinfolder );
							_sntprintf( prfn, SIZEOF( prfn ), _T("%s\\%s"), skinfolder, imfn );
							CallService( MS_UTILS_PATHTOABSOLUTET, ( WPARAM )prfn, ( LPARAM ) imfn );
							char * imfn_ch = mir_t2a( imfn ); 
							hPreviewBitmap = ske_LoadGlyphImage( imfn_ch );
							mir_free( imfn_ch );
						}
						EnableWindow( GetDlgItem( hwndDlg, IDC_BUTTON_APPLY_SKIN ), TRUE );
						EnableWindow( GetDlgItem( hwndDlg, IDC_BUTTON_INFO ), TRUE );
						if ( hPreviewBitmap ) 
							InvalidateRect( GetDlgItem( hwndDlg, IDC_PREVIEW ), NULL, TRUE );
						else  //prepare text
						{
							TCHAR Author[255];
							TCHAR URL[MAX_PATH];
							TCHAR Contact[255];
							TCHAR Description[400];
							TCHAR text[2000];
							SkinListData* sd = NULL;
							HTREEITEM hti = TreeView_GetSelection( GetDlgItem( hwndDlg, IDC_TREE1 ) );				
							if ( hti == 0 ) return 0;
							{
								TVITEM tvi = {0};
								tvi.hItem = hti;
								tvi.mask = TVIF_HANDLE|TVIF_PARAM;
								TreeView_GetItem( GetDlgItem( hwndDlg, IDC_TREE1 ), &tvi );
								sd = ( SkinListData* )( tvi.lParam );
							}
							if ( !sd ) return 0;

							if( sd->File && !_tcschr( sd->File, _T('%') ) )
							{
								GetPrivateProfileString( _T( "Skin_Description_Section" ), _T( "Author" ), 	TranslateT( "( unknown )" ), 	Author, 		SIZEOF( Author ), 		sd->File );
								GetPrivateProfileString( _T( "Skin_Description_Section" ), _T( "URL" ), 		_T( "" ), 						URL, 		SIZEOF( URL ), 		sd->File );
								GetPrivateProfileString( _T( "Skin_Description_Section" ), _T( "Contact" ), 	_T( "" ), 						Contact, 	SIZEOF( Contact ), 	sd->File );
								GetPrivateProfileString( _T( "Skin_Description_Section" ), _T( "Description" ), _T( "" ), 					Description, SIZEOF( Description ), sd->File );
								_sntprintf( text, SIZEOF( text ), TranslateT( "Preview is not available\n\n%s\n----------------------\n\n%s\n\nAUTHOR(S):\n%s\n\nCONTACT:\n%s\n\nHOMEPAGE:\n%s" ), 
									sd->Name, Description, Author, Contact, URL );
							}
							else
							{
								_sntprintf( text, SIZEOF( text ), TranslateT( "%s\n\n%s\n\nAUTHORS:\n%s\n\nCONTACT:\n%s\n\nWEB:\n%s\n\n\n" ), 
									TranslateT( "reVista for Modern v0.5" ), 
									TranslateT( "This is second default Modern Contact list skin in Vista Aero style" ), 
									TranslateT( "graphics by Angeli-Ka\ntemplate by FYR" ), 
									_T("JID: [email protected]"), 
									_T("fyr.mirandaim.ru") );
							}
							ShowWindow( GetDlgItem( hwndDlg, IDC_PREVIEW ), SW_HIDE );
							ShowWindow( GetDlgItem( hwndDlg, IDC_STATIC_INFO ), SW_SHOW );
							SendDlgItemMessage( hwndDlg, IDC_STATIC_INFO, WM_SETTEXT, 0, ( LPARAM )text );
						}					
					}
					else
					{
						//no selected
						SendDlgItemMessage( hwndDlg, IDC_EDIT_SKIN_FILENAME, WM_SETTEXT, 0, ( LPARAM )TranslateT( "Select skin from list" ) );
						EnableWindow( GetDlgItem( hwndDlg, IDC_BUTTON_APPLY_SKIN ), FALSE );
						EnableWindow( GetDlgItem( hwndDlg, IDC_BUTTON_INFO ), FALSE );
						SendDlgItemMessage( hwndDlg, IDC_STATIC_INFO, WM_SETTEXT, 0, ( LPARAM )TranslateT( "Please select skin to apply" ) );
						ShowWindow( GetDlgItem( hwndDlg, IDC_PREVIEW ), SW_HIDE );
					}
					ShowWindow( GetDlgItem( hwndDlg, IDC_PREVIEW ), hPreviewBitmap?SW_SHOW:SW_HIDE );
					return 0;
				}			
				else if ( nmtv->hdr.code == TVN_DELETEITEMA || nmtv->hdr.code == TVN_DELETEITEMW )
				{
					if ( nmtv->itemOld.lParam )
						mir_free_and_nill( nmtv->itemOld.lParam );
					return 0;
				}
				break;
			}
		case 0:
			switch ( ( ( LPNMHDR )lParam )->code )
			{
			case PSN_APPLY:
				{
					{
						DWORD tick = GetTickCount( );
						pcli->pfnClcBroadcast( INTM_RELOADOPTIONS, 0, 0 );
						NotifyEventHooks( g_CluiData.hEventBkgrChanged, 0, 0 );
						pcli->pfnClcBroadcast( INTM_INVALIDATE, 0, 0 );	
						RedrawWindow( GetParent( pcli->hwndContactTree ), NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_ALLCHILDREN );
					}
					return 0;
				}
				break;
			}
			break;
		}
	}
Example #14
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);
}