CVMIDialog::CVMIDialog(QWidget* parent) : QDialog(parent) // : QDialog (0, Qt::WindowMinMaxButtonsHint | Qt::WindowTitleHint|Qt::WindowSystemMenuHint|Qt::WindowCloseButtonHint|Qt::Dialog) 
{

  // Select page
  selectPage = new CVMISelectPage;
  Q_ASSERT(connect(selectPage, SIGNAL(vmSelected(CVMIRelease)), this, SLOT(showVMCreate(CVMIRelease))));
  selectPage->setReady(false);

  // Create page
  createPage = new CVMICreatePage;
  Q_ASSERT(connect(createPage, SIGNAL(back()), this, SLOT(showVMSelect()))); 
  Q_ASSERT(connect(createPage, SIGNAL(createVM(CVMIInstanceConfig)), this, SLOT(showVMInstall(CVMIInstanceConfig))));

  // Install page
  installPage = new CVMIInstallPage;
  Q_ASSERT(connect(installPage, SIGNAL(done()), this, SLOT(showVMSelect())));

  // Config page
  CVMIConfigPage* configPage = new CVMIConfigPage;
  Q_ASSERT(connect(configPage, SIGNAL(displayOptionChanged()), selectPage, SLOT(displayOptionChanged())));
  Q_ASSERT(connect(configPage, SIGNAL(configChanged()), this, SLOT(verifyConfig())));  
   
  // About page
  CVMIAboutPage* aboutPage = new CVMIAboutPage;

  // Stacked Widget 
  contentWidget = new QStackedWidget;
  contentWidget->addWidget (selectPage);
  contentWidget->addWidget (createPage);  
  contentWidget->addWidget (installPage);

  // Tabs 
  QTabWidget *tabWidget = new QTabWidget;
  tabWidget->insertTab(0, contentWidget, tr("Installer"));
  tabWidget->insertTab(1, configPage, tr("Preferences"));
  tabWidget->insertTab(2, aboutPage, tr("About"));

   // Window decoration
  setWindowTitle(tr("CernVM installation tool"));  
  setWindowFlags(windowFlags() | Qt::WindowMinMaxButtonsHint | Qt::CustomizeWindowHint);

  // Layout
  QHBoxLayout *bodyLayout = new QHBoxLayout;
  bodyLayout->addWidget(tabWidget);
  setLayout(bodyLayout);

  // Application icon
  this->setWindowIcon(QIcon(":images/application_icon.png"));
  verifyConfig();
}
//****************************************************************************
//****************************************************************************
//****************************************************************************
//****************************************************************************
struct ndb_mgm_configuration*
ConfigRetriever::getConfig() {

  struct ndb_mgm_configuration * p = 0;

  if(m_handle != 0)
    p = getConfig(m_handle);

  if(p == 0)
    return 0;
  
  if(!verifyConfig(p, _ownNodeId)){
    free(p);
    p= 0;
  }
  
  return p;
}