yast2-core
|
#include <Y2WFMComponent.h>
Static Public Member Functions | |
static Y2WFMComponent * | instance () |
Private Types | |
typedef vector< WFMSubAgent * > | WFMSubAgents |
Private Member Functions | |
bool | createDefaultSCR () |
WFMSubAgents::iterator | find_handle (int) |
const char * | get_env_lang () const |
Private Attributes | |
WFMSubAgents | scrs |
int | handle_cnt |
int | default_handle |
WFMSubAgent | local |
string | modulename |
YCPList | argumentlist |
string | currentLanguage |
string | currentEncoding |
string | systemEncoding |
string | environmentEncoding |
YCPValue | script |
string | client_name |
string | fullname |
Static Private Attributes | |
static Y2WFMComponent * | current_wfm = 0 |
|
private |
Y2WFMComponent::Y2WFMComponent | ( | ) |
Creates a new WFM component
References YCPList::add(), createDefaultSCR(), current_wfm, environmentEncoding, get_env_lang(), scrs, SetLanguage(), and y2debug.
Referenced by instance().
Y2WFMComponent::~Y2WFMComponent | ( | ) |
Cleans up
References current_wfm, and scrs.
YCPValue Y2WFMComponent::Args | ( | const YCPInteger & | index = YCPNull () | ) | const |
Args Returns the arguments with which the module was called. The result is a list whose arguments are the module's arguments. If the module was called with CallFunction("my_mod", [17,true])
, Args()
will return [ 17, true ]
.
References argumentlist, YCPElement::isNull(), YCPList::value(), and YCPError().
Referenced by WFMArgs(), and WFMArgs2().
YCPValue Y2WFMComponent::CallFunction | ( | const YCPString & | client, |
const YCPList & | args = YCPList () |
||
) |
call Executes a YCP client or a Y2 client component.
string | name client name |
list | arguments list of arguments |
This implies * that the called YCP code has full access to all module status in the currently running YaST.
The modulename is temporarily changed to the name of the called script or a component.
In the example, WFM looks for the file YAST2HOME/clients/inst_mouse.ycp and executes it. If the client is not found, a Y2 client component is tried to be created.
call ("inst_mouse", [true, false]) -> ....
References Y2ComponentBroker::createClient(), Y2Component::doActualWork(), YaST::ee, YaST::ExecutionEnvironment::filename(), YaST::ExecutionEnvironment::linenumber(), Y2Component::result(), YaST::ExecutionEnvironment::setFilename(), YaST::ExecutionEnvironment::setLinenumber(), ycp2debug, ycp2error, and ycp2milestone.
Referenced by WFMCallFunction(), and WFMCallFunction1().
YCPBoolean Y2WFMComponent::ClientExists | ( | const YCPString & | client | ) |
ClientExists Checks whether a YCP client exists
string | name client name |
This is similar to 'call' or 'CallFunction' but client is only checked for existence and not executed. If client exists 'true' is returned, otherwise 'false'.
ClientExists ("inst_mouse") -> true ClientExists ("missing_client") -> false
References Y2ComponentBroker::createClient(), YCPElement::isNull(), and y2error.
Referenced by WFMClientExists().
|
private |
References WFMSubAgent::agent(), default_handle, SCR::registered, scrs, SCRAgent::setAsCurrentSCR(), WFMSubAgent::start(), and y2internal.
Referenced by Y2WFMComponent().
|
virtual |
Executes the YCP script.
Reimplemented from Y2Component.
References YCPList::add(), argumentlist, debugger, fullname, modulename, name(), YCPList::remove(), script, YCPList::size(), YCPList::value(), y2debug, and y2error.
Referenced by main().
Execute Special interface to the system agent. Not for general use.
path | path Path any options |
References WFMSubAgent::agent(), SCRAgent::Execute(), local, WFMSubAgent::start(), and YCPError().
Referenced by WFMExecute().
|
private |
Finds a SCR instance to a given handle.
References handle, scrs, and wfmsubagent_less().
Referenced by SCRClose(), SCRGetName(), and SCRSetDefault().
|
private |
YCPString Y2WFMComponent::GetEncoding | ( | ) | const |
GetEncoding Returns the current encoding code
References systemEncoding.
Referenced by WFMGetEncoding().
YCPString Y2WFMComponent::GetEnvironmentEncoding | ( | ) |
GetEnvironmentEncoding Returns the encoding code of the environment where YaST is started
References environmentEncoding.
Referenced by WFMGetEnvironmentEncoding().
YCPString Y2WFMComponent::GetLanguage | ( | ) | const |
GetLanguage Returns the current language code (without modifiers !)
References currentLanguage.
Referenced by WFMGetLanguage().
|
virtual |
Try to import a given namespace. This method is used for transparent handling of namespaces (YCP modules) through whole YaST. NOTICE: there is no reverse operation to import. Semantics of YCP modules is there is a single instance and it is available from the first import until the end of YaST run.
name_space | the name of the required namespace |
Reimplemented from Y2Component.
References Bytecode::readModule(), and y2debug.
|
static |
References current_wfm, and Y2WFMComponent().
Referenced by Y2CCWFM::create(), Y2CCWFM::createInLevel(), Y2CCWFM::provideNamespace(), WFMArgs(), WFMArgs2(), WFMCallFunction(), WFMCallFunction1(), WFMClientExists(), WFMExecute(), WFMGetEncoding(), WFMGetEnvironmentEncoding(), WFMGetLanguage(), WFMRead(), WFMSCRClose(), WFMSCRGetDefault(), WFMSCRGetName(), WFMSCROpen(), WFMSCRSetDefault(), WFMSetLanguage(), WFMSetLanguage2(), and WFMWrite3().
|
virtual |
Read Special interface to the system agent. Not for general use.
path | path Path any options |
References WFMSubAgent::agent(), YCPElement::isNull(), local, SCRAgent::Read(), WFMSubAgent::start(), and YCPError().
Referenced by WFMRead().
void Y2WFMComponent::SCRClose | ( | const YCPInteger & | handle | ) |
SCRClose Closes a scr instance.
integer | handle SCR handle |
References agent, default_handle, find_handle(), handle, scrs, ycperror, and ycpmilestone.
Referenced by WFMSCRClose().
YCPInteger Y2WFMComponent::SCRGetDefault | ( | ) | const |
SCRGetDefault Gets the default scr instance.
References default_handle.
Referenced by WFMSCRGetDefault().
YCPString Y2WFMComponent::SCRGetName | ( | const YCPInteger & | handle | ) |
SCRGetName Get the name of a scr instance.
integer | handle SCR handle |
References find_handle(), handle, scrs, and ycpinternal.
Referenced by WFMSCRGetName().
YCPInteger Y2WFMComponent::SCROpen | ( | const YCPString & | name, |
const YCPBoolean & | check_version | ||
) |
SCROpen Create a new scr instance.
Creates a new scr instance. The name must be a valid y2component name (e.g. "scr", "chroot=/mnt:scr"). The component is created immediately. The parameter check_version determines whether the SuSE Version should be checked. On error a negative value is returned.
string | name a valid y2component name |
boolean | check_version determines whether the SuSE Version should be checked |
References agent, handle, handle_cnt, name(), scrs, WFMSubAgent::start(), and y2error.
Referenced by WFMSCROpen().
void Y2WFMComponent::SCRSetDefault | ( | const YCPInteger & | handle | ) |
SCRSetDefault Sets the default scr instance.
integer | handle SCR handle |
References default_handle, find_handle(), scrs, and y2milestone.
Referenced by WFMSCRSetDefault().
Sets WFM::Args. It useful for clients component that need to set WFM:Args builts
References argumentlist, and Y2Component::result().
YCPString Y2WFMComponent::SetLanguage | ( | const YCPString & | language, |
const YCPString & | encoding = YCPNull () |
||
) |
SetLanguage Selects the language for translate()
string | language string encoding SetLanguage("de_DE", "UTF-8") -> "" SetLanguage("de_DE@euro") -> "ISO-8859-15" |
The "<proposed encoding>" is the output of 'nl_langinfo (CODESET)' and only given if SetLanguage() is called with a single argument.
References currentLanguage, YCPElement::isNull(), systemEncoding, y2debug, y2milestone, and y2warning.
Referenced by WFMSetLanguage(), WFMSetLanguage2(), and Y2WFMComponent().
void Y2WFMComponent::setupComponent | ( | string | client_name, |
string | fullname, | ||
const YCPValue & | script | ||
) |
Setups this script component.
the | name of the component that is realized be the script. |
script | the script. This component clones it, so you can destroy the script after the constructor call. |
References client_name, fullname, and script.
Referenced by Y2CCWFM::createInLevel(), and main().
YCPValue Y2WFMComponent::Write | ( | const YCPPath & | path, |
const YCPValue & | arg1, | ||
const YCPValue & | arg2 = YCPNull () |
||
) |
Write Special interface to the system agent. Not for general use.
path | path Path any options |
References WFMSubAgent::agent(), local, WFMSubAgent::start(), SCRAgent::Write(), and YCPError().
Referenced by WFMWrite3().
|
private |
Arguments of the module that is realized through the wfm. The script has access to it via the builtin args(). The symbol of the term itself is the module name.
Referenced by Args(), doActualWork(), and SetArgs().
|
private |
The name of the client that is implemented by the script.
Referenced by setupComponent().
|
staticprivate |
Referenced by instance(), Y2WFMComponent(), and ~Y2WFMComponent().
|
private |
|
private |
Referenced by GetLanguage(), and SetLanguage().
|
private |
Handle of default SCR instance.
Referenced by createDefaultSCR(), SCRClose(), SCRGetDefault(), and SCRSetDefault().
|
private |
environment encoding
Referenced by GetEnvironmentEncoding(), and Y2WFMComponent().
|
private |
The fullname of the script file.
Referenced by doActualWork(), and setupComponent().
|
private |
Handle count.
Referenced by SCROpen().
|
private |
|
private |
The name of the module that is realized by this wfm.
Referenced by doActualWork().
|
private |
The script that implements the component.
Referenced by doActualWork(), and setupComponent().
|
private |
Referenced by createDefaultSCR(), find_handle(), SCRClose(), SCRGetName(), SCROpen(), SCRSetDefault(), Y2WFMComponent(), and ~Y2WFMComponent().
|
private |
system encoding
Referenced by GetEncoding(), and SetLanguage().