30 #include "YCommandLine.h"
31 #include "YUILoader.h"
32 #include "YUIPlugin.h"
33 #include "YUIException.h"
36 #include "Libyui_config.h"
41 const char * envDisplay = getenv(
"DISPLAY" );
45 bool wantNcurses = cmdline.
find(
"--ncurses") != -1;
46 bool wantQt = cmdline.
find(
"--qt") != -1;
47 bool wantGtk = cmdline.
find(
"--gtk") != -1;
49 bool haveQt = pluginExists( YUIPlugin_Qt );
50 bool haveGtk = pluginExists( YUIPlugin_Gtk );
52 if ( envDisplay && !wantNcurses )
54 std::string wantedGUI;
56 if ( haveQt && !wantGtk)
57 wantedGUI = YUIPlugin_Qt;
58 else if ( haveGtk && !wantQt )
59 wantedGUI = YUIPlugin_Gtk;
61 if ( strcmp( wantedGUI.c_str(),
"" ) )
75 if ( isatty( STDOUT_FILENO ) )
103 if ( uiPlugin.success() )
105 createUIFunction_t createUI = (createUIFunction_t) uiPlugin.locateSymbol(
"_Z8createUIb" );
109 YUI * ui = createUI( withThreads );
119 void YUILoader::loadExternalWidgetsPlugin (
const std::string& name,
const std::string& plugin_name,
const std::string& symbol )
121 YUIPlugin uiPlugin ( plugin_name.c_str() );
123 if ( uiPlugin.success() )
125 createEWFunction_t createEW = ( createEWFunction_t ) uiPlugin.locateSymbol ( symbol.c_str() );
141 const char * envDisplay = getenv(
"DISPLAY" );
145 bool wantNcurses = cmdline.
find(
"--ncurses") != -1;
146 bool wantQt = cmdline.
find(
"--qt") != -1;
147 bool wantGtk = cmdline.
find(
"--gtk") != -1;
149 bool haveQt = pluginExists( YUIPlugin_Qt );
150 bool haveGtk = pluginExists( YUIPlugin_Gtk );
152 if ( envDisplay && !wantNcurses )
154 std::string wantedGUI = name;
155 wantedGUI.append(
"-");
157 if ( haveQt && !wantGtk)
158 wantedGUI.append(YUIPlugin_Qt);
159 else if ( haveGtk && !wantQt )
160 wantedGUI.append(YUIPlugin_Gtk);
164 loadExternalWidgetsPlugin(name, wantedGUI, symbol );
179 std::string wantedNcurses = name;
180 wantedNcurses.append(
"-");
181 wantedNcurses.append(YUIPlugin_NCurses);
182 loadExternalWidgetsPlugin(name, wantedNcurses, symbol );
192 bool YUILoader::pluginExists(
const std::string & pluginBaseName )
194 struct stat fileinfo;
195 std::string pluginName = PLUGIN_PREFIX;
197 pluginName.append( pluginBaseName );
198 pluginName.append( PLUGIN_SUFFIX );
200 YPath plugin ( PLUGINDIR, pluginName );
202 return stat( plugin.path().c_str(), &fileinfo) == 0;
static void loadPlugin(const std::string &name, bool withThreads=false)
static void loadExternalWidgets(const std::string &name, const std::string &symbol="_Z21createExternalWidgetsPKc")
int find(const std::string &argName) const
static void loadUI(bool withThreads=false)