HANDLE CPluginW2800::Open(const void* apInfo)
{
	const struct OpenInfo *Info = (const struct OpenInfo*)apInfo;

	if (!mb_StartupInfoOk)
		return NULL;

	INT_PTR Item = Info->Data;
	bool bGuiMacroCall = false;

	if (Info->OpenFrom == OPEN_FROMMACRO)
	{
		Item = 0; // Сразу сброс
		OpenMacroInfo* p = (OpenMacroInfo*)Info->Data;
		if (p->StructSize >= sizeof(*p))
		{
			if (p->Count > 0)
			{
				switch (p->Values[0].Type)
				{
				case FMVT_INTEGER:
					Item = (INT_PTR)p->Values[0].Integer; break;
				// Far 3 Lua macros uses Double instead of Int :(
				case FMVT_DOUBLE:
					Item = (INT_PTR)p->Values[0].Double; break;
				case FMVT_STRING:
					_ASSERTE(p->Values[0].String!=NULL);
					bGuiMacroCall = true;
					Item = (INT_PTR)p->Values[0].String; break;
				default:
					_ASSERTE(p->Values[0].Type==FMVT_INTEGER || p->Values[0].Type==FMVT_STRING);
				}

				if (Item == CE_CALLPLUGIN_REQ_DIRS)
				{
					if (p->Count == 3)
					{
						LPCWSTR pszActive = (p->Values[1].Type == FMVT_STRING) ? p->Values[1].String : NULL;
						LPCWSTR pszPassive = (p->Values[2].Type == FMVT_STRING) ? p->Values[2].String : NULL;
						StorePanelDirs(pszActive, pszPassive);
					}
					return PANEL_NONE;
				}
			}
		}
		else
		{
			_ASSERTE(p->StructSize >= sizeof(*p));
		}
	}
	else if (Info->OpenFrom == OPEN_COMMANDLINE)
	{
		OpenCommandLineInfo* p = (OpenCommandLineInfo*)Info->Data;
		Item = (INT_PTR)p->CommandLine;
	}

	HANDLE h = OpenPluginCommon(Info->OpenFrom, Item, (Info->OpenFrom == OPEN_FROMMACRO));
	if (Info->OpenFrom == OPEN_FROMMACRO)
	{
		// В Far/lua можно вернуть величину и не только булевского типа
		if (h != NULL)
		{
			// That was GuiMacro call?
			if (bGuiMacroCall)
			{
				static FarMacroCall rc = {sizeof(rc)};
				static FarMacroValue val;
				rc.Count = 1;
				rc.Values = &val;
				rc.Callback = FreeMacroResult;
				val.Type = FMVT_STRING;
				val.String = GetEnvVar(CEGUIMACRORETENVVAR);
				h = (HANDLE)&rc;
			}
			else
			{
				h = (HANDLE)TRUE;
			}
		}
		else
		{
			h = NULL;
		}
	}
	else if ((h == INVALID_HANDLE_VALUE) || (h == (HANDLE)-2))
	{
		if (Info->OpenFrom == OPEN_ANALYSE)
			h = PANEL_STOP;
		else
			h = NULL;
	}

	return h;
}
Example #2
0
HANDLE CPluginW1900::Open(const void* apInfo)
{
	const struct OpenInfo *Info = (const struct OpenInfo*)apInfo;

	if (!mb_StartupInfoOk)
		return NULL;

	INT_PTR Item = Info->Data;
	if ((Info->OpenFrom & OPEN_FROM_MASK) == OPEN_FROMMACRO)
	{
		Item = 0; // Сразу сброс
		OpenMacroInfo* p = (OpenMacroInfo*)Info->Data;
		if (p->StructSize >= sizeof(*p))
		{
			if (p->Count > 0)
			{
				switch (p->Values[0].Type)
				{
				case FMVT_INTEGER:
					Item = (INT_PTR)p->Values[0].Integer; break;
				// Far 3 Lua macros uses Double instead of Int :( Unlock in Far2 for uniform.
				case FMVT_DOUBLE:
					Item = (INT_PTR)p->Values[0].Double; break;
				case FMVT_STRING:
					_ASSERTE(p->Values[0].String!=NULL);
					Item = (INT_PTR)p->Values[0].String; break;
				default:
					_ASSERTE(p->Values[0].Type==FMVT_INTEGER || p->Values[0].Type==FMVT_STRING);
				}

				if (Item == CE_CALLPLUGIN_REQ_DIRS)
				{
					if (p->Count == 3)
					{
						LPCWSTR pszActive = (p->Values[1].Type == FMVT_STRING) ? p->Values[1].String : NULL;
						LPCWSTR pszPassive = (p->Values[2].Type == FMVT_STRING) ? p->Values[2].String : NULL;
						StorePanelDirs(pszActive, pszPassive);
					}
					return PANEL_NONE;
				}
			}
		}
		else
		{
			_ASSERTE(p->StructSize >= sizeof(*p));
		}
	}

	HANDLE h = OpenPluginCommon(Info->OpenFrom, Item, (Info->OpenFrom == OPEN_FROMMACRO));
	if ((Info->OpenFrom & OPEN_FROM_MASK) == OPEN_FROMMACRO)
	{
		h = (HANDLE)(h != NULL);
	}
	else if ((h == INVALID_HANDLE_VALUE) || (h == (HANDLE)-2))
	{
		if ((Info->OpenFrom & OPEN_FROM_MASK) == OPEN_ANALYSE)
			h = PANEL_STOP;
		else
			h = NULL;
	}

	return h;
}