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& symbol )
123 if ( uiPlugin.success() )
125 createEWFunction_t createWE = ( 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);
162 if ( strcmp( wantedGUI.c_str(),
"" ) )
166 loadExternalWidgetsPlugin( wantedGUI, symbol );
182 std::string wantedNcurses = name;
183 wantedNcurses.append(
"-");
184 wantedNcurses.append(YUIPlugin_NCurses);
185 loadExternalWidgetsPlugin( wantedNcurses, symbol );
195 bool YUILoader::pluginExists(
const std::string & pluginBaseName )
197 struct stat fileinfo;
198 std::string pluginName = PLUGIN_PREFIX;
200 pluginName.append( pluginBaseName );
201 pluginName.append( PLUGIN_SUFFIX );
203 YPath plugin ( PLUGINDIR, pluginName );
205 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="_Z21createExternalWidgetsv")
int find(const std::string &argName) const
static void loadUI(bool withThreads=false)