Beispiel #1
0
void getProfileCmdLine(TCHAR * szProfile, size_t cch, TCHAR * profiledir)
{
	TCHAR buf[MAX_PATH];
	if (getProfileCmdLineArgs(buf, SIZEOF(buf))) 
	{
		TCHAR *p, profileName[MAX_PATH], newProfileDir[MAX_PATH];

		p = _tcsrchr(buf, '\\'); if (p) ++p; else p = buf; 

		if (!isValidProfileName(buf) && *p)
			_tcscat(buf, _T(".dat"));

		_tcscpy(profileName, p);
		p = _tcsrchr(profileName, '.'); if (p) *p = 0; 

		mir_sntprintf(newProfileDir, cch, _T("%s\\%s\\"), profiledir, profileName);
		pathToAbsoluteT(buf, szProfile, newProfileDir);

		if (_tcschr(buf, '\\')) 
		{
			_tcscpy(profiledir, szProfile);
			if (profileName[0])
			{
				p = _tcsrchr(profiledir, '\\'); *p = 0;
				p = _tcsrchr(profiledir, '\\');
				if (p && _tcsicmp(p + 1, profileName) == 0)
					*p = 0;
			}
			else
				szProfile[0] = 0;

		}
	}
}
Beispiel #2
0
int LoadLangPackModule(void)
{
	HANDLE hFind;
	TCHAR szSearch[MAX_PATH];
	WIN32_FIND_DATA fd;

	bModuleInitialized = TRUE;

	ZeroMemory(&langPack,sizeof(langPack));
	LoadLangPackServices();
	pathToAbsoluteT(_T("langpack_*.txt"), szSearch, NULL); 
	hFind = FindFirstFile( szSearch, &fd );
	if( hFind != INVALID_HANDLE_VALUE ) {
		pathToAbsoluteT(fd.cFileName, szSearch, NULL); 
		FindClose(hFind);
		LoadLangPack(szSearch);
	}
	return 0;
}
Beispiel #3
0
int LoadDatabaseModule(void)
{
	TCHAR szProfile[MAX_PATH];
	pathToAbsoluteT(_T("."), szProfile, NULL);
	_tchdir(szProfile);
	szProfile[0] = 0;

	// load the older basic services of the db
	InitUtils();

	// find out which profile to load
	if ( !getProfile( szProfile, SIZEOF( szProfile )))
		return 1;

	PLUGIN_DB_ENUM dbe;
	dbe.cbSize = sizeof(PLUGIN_DB_ENUM);
	dbe.lParam = (LPARAM)szProfile;

	if ( _taccess(szProfile, 0) && shouldAutoCreate( szProfile ))
		dbe.pfnEnumCallback=( int(*) (const char*,void*,LPARAM) )FindDbPluginAutoCreate;
	else
		dbe.pfnEnumCallback=( int(*) (const char*,void*,LPARAM) )FindDbPluginForProfile;

	// find a driver to support the given profile
	int rc = CallService(MS_PLUGINS_ENUMDBPLUGINS, 0, (LPARAM)&dbe);
	switch ( rc ) {
	case -1: {
		// no plugins at all
		TCHAR buf[256];
		TCHAR* p = _tcsrchr(szProfile,'\\');
		mir_sntprintf(buf,SIZEOF(buf),TranslateT("Miranda is unable to open '%s' because you do not have any profile plugins installed.\nYou need to install dbx_3x.dll or equivalent."), p ? ++p : szProfile );
		MessageBox(0,buf,TranslateT("No profile support installed!"),MB_OK | MB_ICONERROR);
		break;
	}
	case 1:
		// if there were drivers but they all failed cos the file is locked, try and find the miranda which locked it
		if (fileExist(szProfile)) {
			// file isn't locked, just no driver could open it.
			TCHAR buf[256];
			TCHAR* p = _tcsrchr(szProfile,'\\');
			mir_sntprintf(buf,SIZEOF(buf),TranslateT("Miranda was unable to open '%s', it's in an unknown format.\nThis profile might also be damaged, please run DB-tool which should be installed."), p ? ++p : szProfile);
			MessageBox(0,buf,TranslateT("Miranda can't understand that profile"),MB_OK | MB_ICONERROR);
		}
		else if (!FindMirandaForProfile(szProfile)) {
			TCHAR buf[256];
			TCHAR* p = _tcsrchr(szProfile,'\\');
			mir_sntprintf(buf,SIZEOF(buf),TranslateT("Miranda was unable to open '%s'\nIt's inaccessible or used by other application or Miranda instance"), p ? ++p : szProfile);
			MessageBox(0,buf,TranslateT("Miranda can't open that profile"),MB_OK | MB_ICONERROR);
		}
		break;
	}
	return (rc != 0);
}
Beispiel #4
0
int InitIni(void)
{
	TCHAR szMirandaDir[MAX_PATH];

	bModuleInitialized = true;

	DoAutoExec();
	pathToAbsoluteT(_T("."), szMirandaDir, NULL);
	hIniChangeNotification=FindFirstChangeNotification(szMirandaDir, 0, FILE_NOTIFY_CHANGE_FILE_NAME);
	if (hIniChangeNotification != INVALID_HANDLE_VALUE) {
		CreateServiceFunction("DB/Ini/CheckImportNow", CheckIniImportNow);
		CallService(MS_SYSTEM_WAITONHANDLE, (WPARAM)hIniChangeNotification, (LPARAM)"DB/Ini/CheckImportNow");
	}
	return 0;
}
Beispiel #5
0
// returns 1 if the profile path was returned, without trailing slash
int getProfilePath(TCHAR * buf, size_t cch)
{
	TCHAR profiledir[MAX_PATH];
	GetPrivateProfileString(_T("Database"), _T("ProfileDir"), _T(""), profiledir, SIZEOF(profiledir), mirandabootini);

	if (profiledir[0] == 0)
		_tcscpy(profiledir, _T("%miranda_path%\\Profiles"));

	TCHAR* exprofiledir = Utils_ReplaceVarsT(profiledir);
	size_t len = pathToAbsoluteT(exprofiledir, buf, NULL);
	mir_free(exprofiledir);

	if (buf[len-1] == '/' || buf[len-1] == '\\')
		buf[len-1] = 0;

	return 0;
}
Beispiel #6
0
int LoadNewPluginsModuleInfos(void)
{
	bModuleInitialized = TRUE;

	hPluginListHeap=HeapCreate(HEAP_NO_SERIALIZE, 0, 0);
	mirandaVersion = (DWORD)CallService(MS_SYSTEM_GETVERSION, 0, 0);
	//
	CreateServiceFunction(MS_PLUGINS_ENUMDBPLUGINS, PluginsEnum);
	CreateServiceFunction(MS_PLUGINS_GETDISABLEDEFAULTARRAY, PluginsGetDefaultArray);
	// make sure plugins can get internal core APIs
	pluginCoreLink.CallService                    = CallService;
	pluginCoreLink.ServiceExists                  = ServiceExists;
	pluginCoreLink.CreateServiceFunction          = CreateServiceFunction;
	pluginCoreLink.CreateServiceFunctionParam     = CreateServiceFunctionParam;
	pluginCoreLink.CreateServiceFunctionObj       = CreateServiceFunctionObj;
	pluginCoreLink.CreateServiceFunctionObjParam  = CreateServiceFunctionObjParam;
	pluginCoreLink.CreateTransientServiceFunction = CreateServiceFunction;
	pluginCoreLink.DestroyServiceFunction         = DestroyServiceFunction;
	pluginCoreLink.CreateHookableEvent            = CreateHookableEvent;
	pluginCoreLink.DestroyHookableEvent           = DestroyHookableEvent;
	pluginCoreLink.HookEvent                      = HookEvent;
	pluginCoreLink.HookEventParam                 = HookEventParam;
	pluginCoreLink.HookEventObj                   = HookEventObj;
	pluginCoreLink.HookEventObjParam              = HookEventObjParam;
	pluginCoreLink.HookEventMessage               = HookEventMessage;
	pluginCoreLink.UnhookEvent                    = UnhookEvent;
	pluginCoreLink.NotifyEventHooks               = NotifyEventHooks;
	pluginCoreLink.SetHookDefaultForHookableEvent = SetHookDefaultForHookableEvent;
	pluginCoreLink.CallServiceSync                = CallServiceSync;
	pluginCoreLink.CallFunctionAsync              = CallFunctionAsync;
	pluginCoreLink.NotifyEventHooksDirect         = CallHookSubscribers;
	pluginCoreLink.CallProtoService               = CallProtoService;
	pluginCoreLink.CallContactService             = CallContactService;
	pluginCoreLink.KillObjectServices             = KillObjectServices;
	pluginCoreLink.KillObjectEventHooks           = KillObjectEventHooks;

	// remember where the mirandaboot.ini goes
	pathToAbsoluteT(_T("mirandaboot.ini"), mirandabootini, NULL);
	// look for all *.dll's
	enumPlugins(scanPluginsDir, 0, 0);
	// the database will select which db plugin to use, or fail if no profile is selected
	if (LoadDatabaseModule()) return 1;
	InitIni();
	//  could validate the plugin entries here but internal modules arent loaded so can't call Load() in one pass
	return 0;
}
Beispiel #7
0
static void DoAutoExec(void)
{
	TCHAR szUse[7], szIniPath[MAX_PATH], szFindPath[MAX_PATH];
	TCHAR *str2;
	TCHAR buf[2048], szSecurity[11], szOverrideSecurityFilename[MAX_PATH], szOnCreateFilename[MAX_PATH];
	char *szSafeSections, *szUnsafeSections;
	int secur;

	GetPrivateProfileString(_T("AutoExec"),_T("Use"),_T("prompt"),szUse,SIZEOF(szUse),mirandabootini);
	if(!lstrcmpi(szUse,_T("no"))) return;
	GetPrivateProfileString(_T("AutoExec"),_T("Safe"),_T("CLC Icons CLUI CList SkinSounds"),buf,SIZEOF(buf),mirandabootini);
	szSafeSections = mir_t2a(buf);
	GetPrivateProfileString(_T("AutoExec"),_T("Unsafe"),_T("ICQ MSN"),buf,SIZEOF(buf),mirandabootini);
	szUnsafeSections = mir_t2a(buf);
	GetPrivateProfileString(_T("AutoExec"),_T("Warn"),_T("notsafe"),szSecurity,SIZEOF(szSecurity),mirandabootini);
	if (!lstrcmpi(szSecurity,_T("none"))) secur = 0;
	else if (!lstrcmpi(szSecurity,_T("notsafe"))) secur = 1;
	else if (!lstrcmpi(szSecurity,_T("onlyunsafe"))) secur = 2;

	GetPrivateProfileString(_T("AutoExec"),_T("OverrideSecurityFilename"),_T(""),szOverrideSecurityFilename,SIZEOF(szOverrideSecurityFilename),mirandabootini);
	GetPrivateProfileString(_T("AutoExec"),_T("OnCreateFilename"),_T(""),szOnCreateFilename,SIZEOF(szOnCreateFilename),mirandabootini);
	GetPrivateProfileString(_T("AutoExec"),_T("Glob"),_T("autoexec_*.ini"),szFindPath,SIZEOF(szFindPath),mirandabootini);
    
	if (dbCreated && szOnCreateFilename[0]) {
		str2 = Utils_ReplaceVarsT(szOnCreateFilename);
		pathToAbsoluteT(str2, szIniPath, NULL);
		mir_free(str2);

		ProcessIniFile(szIniPath, szSafeSections, szUnsafeSections, 0, 1);
	}

	str2 = Utils_ReplaceVarsT(szFindPath);
	pathToAbsoluteT(str2, szFindPath, NULL);
	mir_free(str2);

	WIN32_FIND_DATA fd;
	HANDLE hFind = FindFirstFile(szFindPath, &fd);
	if (hFind == INVALID_HANDLE_VALUE) {
		mir_free(szSafeSections);
		mir_free(szUnsafeSections);
		return;
	}

	str2 = _tcsrchr(szFindPath, '\\');
	if (str2 == NULL) szFindPath[0] = 0;
	else str2[1] = 0;

	do {
		bool secFN = lstrcmpi(fd.cFileName,szOverrideSecurityFilename) == 0;

		mir_sntprintf(szIniPath, SIZEOF(szIniPath), _T("%s%s"), szFindPath, fd.cFileName);
		if(!lstrcmpi(szUse,_T("prompt")) && !secFN) {
			int result=DialogBoxParam(hMirandaInst,MAKEINTRESOURCE(IDD_INSTALLINI),NULL,InstallIniDlgProc,(LPARAM)szIniPath);
			if(result==IDC_NOTOALL) break;
			if(result==IDCANCEL) continue;
		}

		ProcessIniFile(szIniPath, szSafeSections, szUnsafeSections, secur, secFN);

		if(secFN)
			DeleteFile(szIniPath);
		else {
			TCHAR szOnCompletion[8];
			GetPrivateProfileString(_T("AutoExec"),_T("OnCompletion"),_T("recycle"),szOnCompletion,SIZEOF(szOnCompletion),mirandabootini);
			if(!lstrcmpi(szOnCompletion,_T("delete")))
				DeleteFile(szIniPath);
			else if(!lstrcmpi(szOnCompletion,_T("recycle"))) {
				SHFILEOPSTRUCT shfo={0};
				shfo.wFunc=FO_DELETE;
				shfo.pFrom=szIniPath;
				szIniPath[lstrlen(szIniPath)+1]=0;
				shfo.fFlags=FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO;
				SHFileOperation(&shfo);
			}
			else if(!lstrcmpi(szOnCompletion,_T("rename"))) {
				TCHAR szRenamePrefix[MAX_PATH];
				TCHAR szNewPath[MAX_PATH];
				GetPrivateProfileString(_T("AutoExec"),_T("RenamePrefix"),_T("done_"),szRenamePrefix,SIZEOF(szRenamePrefix),mirandabootini);
				lstrcpy(szNewPath,szFindPath);
				lstrcat(szNewPath,szRenamePrefix);
				lstrcat(szNewPath,fd.cFileName);
				MoveFile(szIniPath,szNewPath);
			}
			else if(!lstrcmpi(szOnCompletion,_T("ask")))
				DialogBoxParam(hMirandaInst,MAKEINTRESOURCE(IDD_INIIMPORTDONE),NULL,IniImportDoneDlgProc,(LPARAM)szIniPath);
		}
	} while (FindNextFile(hFind, &fd));
	FindClose(hFind);
	mir_free(szSafeSections);
	mir_free(szUnsafeSections);
}