Ejemplo n.º 1
0
int LoadFontserviceModule( void )
{
	code_page = LangPackGetDefaultCodePage();

	HookEvent(ME_OPT_INITIALISE, OptInit);
	HookEvent(ME_MODERNOPT_INITIALIZE, FontsModernOptInit);

	CreateServiceFunction(MS_FONT_REGISTER, RegisterFont);
	CreateServiceFunction(MS_FONT_GET, GetFont);

	CreateServiceFunction(MS_COLOUR_REGISTER, RegisterColour);
	CreateServiceFunction(MS_COLOUR_GET, GetColour);

	CreateServiceFunction(MS_EFFECT_REGISTER, RegisterEffect);
	CreateServiceFunction(MS_EFFECT_GET, GetEffect);

#if defined( _UNICODE )
	CreateServiceFunction(MS_FONT_REGISTERW, RegisterFontW);
	CreateServiceFunction(MS_FONT_GETW, GetFontW);

	CreateServiceFunction(MS_COLOUR_REGISTERW, RegisterColourW);
	CreateServiceFunction(MS_COLOUR_GETW, GetColourW);

	CreateServiceFunction(MS_EFFECT_REGISTERW, RegisterEffectW);
	CreateServiceFunction(MS_EFFECT_GETW, GetEffectW);
#endif

	hFontReloadEvent = CreateHookableEvent(ME_FONT_RELOAD);
	hColourReloadEvent = CreateHookableEvent(ME_COLOUR_RELOAD);

	// cretae generic fonts
	FontIDT fontid = {0};

	fontid.cbSize = sizeof(FontID);
	strncpy(fontid.dbSettingsGroup, "Fonts", sizeof(fontid.dbSettingsGroup));
	_tcsncpy(fontid.group, _T("General"), SIZEOF(fontid.group));

	_tcsncpy(fontid.name, _T("Headers"), SIZEOF(fontid.name));
	fontid.flags = FIDF_APPENDNAME | FIDF_NOAS | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS | FIDF_CLASSHEADER;
	strncpy(fontid.prefix, "Header", SIZEOF(fontid.prefix));
	fontid.order = 0;
	CallService(MS_FONT_REGISTERT, (WPARAM)&fontid, 0);

	_tcsncpy(fontid.name, _T("Generic text"), SIZEOF(fontid.name));
	fontid.flags = FIDF_APPENDNAME | FIDF_NOAS | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS | FIDF_CLASSGENERAL;
	strncpy(fontid.prefix, "Generic", SIZEOF(fontid.prefix));
	fontid.order = 0;
	CallService(MS_FONT_REGISTERT, (WPARAM)&fontid, 0);

	_tcsncpy(fontid.name, _T("Small text"), SIZEOF(fontid.name));
	fontid.flags = FIDF_APPENDNAME | FIDF_NOAS | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS | FIDF_CLASSSMALL;
	strncpy(fontid.prefix, "Small", SIZEOF(fontid.prefix));
	fontid.order = 0;
	CallService(MS_FONT_REGISTERT, (WPARAM)&fontid, 0);

	// do last for silly dyna plugin
	HookEvent(ME_SYSTEM_PRESHUTDOWN,   OnPreShutdown);
	return 0;
}
Ejemplo n.º 2
0
TCHAR* LangPackPcharToTchar( const char* pszStr )
{
	if ( pszStr == NULL )
		return NULL;

	#if defined( _UNICODE )
	{	int len = (int)strlen( pszStr );
		TCHAR* result = ( TCHAR* )alloca(( len+1 )*sizeof( TCHAR ));
		MultiByteToWideChar( LangPackGetDefaultCodePage(), 0, pszStr, -1, result, len );
		result[len] = 0;
		return mir_wstrdup( TranslateW( result ));
	}
	#else
		return mir_strdup( Translate( pszStr ));
	#endif
}
Ejemplo n.º 3
0
char* mir_u2a( const wchar_t* src )
{
	return mir_u2a_cp( src, LangPackGetDefaultCodePage());
}
Ejemplo n.º 4
0
wchar_t* mir_a2u( const char* src )
{
	return mir_a2u_cp( src, LangPackGetDefaultCodePage());
}
Ejemplo n.º 5
0
static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsafeSections, int secur, bool secFN)
{
	FILE *fp = _tfopen(szIniPath, _T("rt"));
	if ( fp == NULL )
		return;

	bool warnThisSection = false;
	char szSection[128]; szSection[0] = 0;

	while(!feof(fp)) {
		char szLine[2048];
		if (fgets(szLine,sizeof(szLine),fp) == NULL) 
			break;

		int lineLength = lstrlenA(szLine);
		while (lineLength && (BYTE)(szLine[lineLength-1])<=' ')
			szLine[--lineLength]='\0';

		if (szLine[0]==';' || szLine[0]<=' ') 
			continue;

		if (szLine[0]=='[') {
			char *szEnd = strchr(szLine+1,']');
			if (szEnd == NULL)
				continue;

			if (szLine[1] == '!')
				szSection[0] = '\0';
			else {
				lstrcpynA(szSection,szLine+1,min(sizeof(szSection),(int)(szEnd-szLine)));
				switch (secur) {
				case 0:
					warnThisSection = false;
					break;

				case 1:
					warnThisSection = !IsInSpaceSeparatedList(szSection, szSafeSections);
					break;

				case 2:
					warnThisSection = IsInSpaceSeparatedList(szSection, szUnsafeSections);
					break;

				default:
					warnThisSection = true;
					break;
				}
				if (secFN) warnThisSection=0;
			}
			if (szLine[1] == '?') {
				DBCONTACTENUMSETTINGS dbces;
				dbces.pfnEnumProc=SettingsEnumProc;
				lstrcpynA(szSection,szLine+2,min(sizeof(szSection),(int)(szEnd-szLine-1)));
				dbces.szModule=szSection;
				dbces.ofsSettings=0;
				CallService(MS_DB_CONTACT_ENUMSETTINGS,0,(LPARAM)&dbces);
				while (setting_items) {
					SettingsList *next = setting_items->next;

					DBCONTACTGETSETTING dbcgs;
					dbcgs.szModule = szSection;
					dbcgs.szSetting = setting_items->name;
					CallService(MS_DB_CONTACT_DELETESETTING, 0, (LPARAM)&dbcgs);

					mir_free(setting_items->name);
					mir_free(setting_items);
					setting_items = next;
				}
			}
			continue;
		}

		if(szSection[0]=='\0')
			continue;

		char *szValue=strchr(szLine,'=');
		if ( szValue == NULL )
			continue;

		char szName[128];
		lstrcpynA(szName,szLine,min(sizeof(szName),(int)(szValue-szLine+1)));
		szValue++;
		{
			warnSettingChangeInfo_t warnInfo;
			warnInfo.szIniPath=szIniPath;
			warnInfo.szName=szName;
			warnInfo.szSafeSections=szSafeSections;
			warnInfo.szSection=szSection;
			warnInfo.szUnsafeSections=szUnsafeSections;
			warnInfo.szValue=szValue;
			warnInfo.warnNoMore=0;
			warnInfo.cancel=0;
			if(warnThisSection && IDNO==DialogBoxParam(hMirandaInst,MAKEINTRESOURCE(IDD_WARNINICHANGE),NULL,WarnIniChangeDlgProc,(LPARAM)&warnInfo))
				continue;
			if(warnInfo.cancel)
				break;
			if(warnInfo.warnNoMore)
				warnThisSection=0;
		}

		switch(szValue[0]) {
		case 'b':
		case 'B':
			DBWriteContactSettingByte(NULL,szSection,szName,(BYTE)strtol(szValue+1,NULL,0));
			break;
		case 'w':
		case 'W':
			DBWriteContactSettingWord(NULL,szSection,szName,(WORD)strtol(szValue+1,NULL,0));
			break;
		case 'd':
		case 'D':
			DBWriteContactSettingDword(NULL,szSection,szName,(DWORD)strtoul(szValue+1,NULL,0));
			break;
		case 'l':
		case 'L':
			DBDeleteContactSetting(NULL,szSection,szName);
			break;
		case 'e':
		case 'E':
			ConvertBackslashes(szValue+1, LangPackGetDefaultCodePage());
		case 's':
		case 'S':
			DBWriteContactSettingString(NULL,szSection,szName,szValue+1);
			break;
		case 'g':
		case 'G':
			{	char *pstr;
				for(pstr=szValue+1;*pstr;pstr++){
					if(*pstr=='\\'){
						switch(pstr[1]){
						case 'n': *pstr='\n'; break;
						case 't': *pstr='\t'; break;
						case 'r': *pstr='\r'; break;
						default:  *pstr=pstr[1]; break;
						}
						MoveMemory(pstr+1,pstr+2,lstrlenA(pstr+2)+1);
			}	}	}
		case 'u':
		case 'U':
			DBWriteContactSettingStringUtf(NULL,szSection,szName,szValue+1);
			break;
		case 'n':
		case 'h':
		case 'N':
		case 'H':
			{	PBYTE buf;
				int len;
				char *pszValue,*pszEnd;
				DBCONTACTWRITESETTING cws;

				buf=(PBYTE)mir_alloc(lstrlenA(szValue+1));
				for(len=0,pszValue=szValue+1;;len++) {
					buf[len]=(BYTE)strtol(pszValue,&pszEnd,0x10);
					if(pszValue==pszEnd) break;
					pszValue=pszEnd;
				}
				cws.szModule=szSection;
				cws.szSetting=szName;
				cws.value.type=DBVT_BLOB;
				cws.value.pbVal=buf;
				cws.value.cpbVal=len;
				CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)(HANDLE)NULL,(LPARAM)&cws);
				mir_free(buf);
			}
			break;
		default:
			MessageBox(NULL,TranslateT("Invalid setting type. The first character of every value must be b, w, d, l, s, e, u, g, h or n."),TranslateT("Install Database Settings"),MB_OK);
			break;
		}
	}
	fclose(fp);
}