Esempio n. 1
0
void
Browser::execDatabase(const QString& command)
{
    if( tableviewmodel != nullptr ){
        delete tableviewmodel;
        tableviewmodel=nullptr;
    }
    tableviewmodel = new QSqlTableModel();
    tableviewmodel->setTable(currenttable);

    if (!command.isEmpty())
        tableviewmodel->setFilter(command);

    _execQuery();
}
Esempio n. 2
0
int main(const int argc, const char **argv)
{
  // error if no args
  if (argv[1] == 0)
  {
    _usage();
    return 1;
  }

  SSLContext *sslContext = 0; // initialized for unencrypted connection
  _c.setTimeout(TIMEOUT);

  // Get hostname from environment, if defined
  char *p = getenv("CIM_HOST");
  if (p) _hostName = p;

  // Get port number, if defined
  char *pn = getenv("CIM_PORT");
  if (pn) _portNumber = atol(pn);

  if (p)
  {
    // hostname was specified, we will not connect local
    // so decide whether encrypted or not
    char *s = getenv("CIM_NOSSL");
    if (s) // don't use ssl (not encrypted)
    {
      if (!pn) _portNumber = 5988; // use 5988 if no port specified
    }
    else
    {
      try
      {
        sslContext = new SSLContext(PEGASUS_SSLCLIENT_CERTIFICATEFILE,
                                    verifyServerCertificate,
                                    PEGASUS_SSLCLIENT_RANDOMFILE
                                    /* "/var/opt/wbem/ssl.rnd" */);
      }
      catch (Exception &e)
      {
        cerr << e.getMessage() << endl;
        return 1;
      }
      if (!pn) _portNumber = 5989; // use 5989 if no port specified
    }
  }

  // Get namespace from environment or use default
  p = getenv("CIM_NAMESPACE");
  _nameSpace = (p==0)? DEFAULT_NAMESPACE:p;
  
  // Get user from environment or don't specify
  p = getenv("CIM_USER");
  _userName = (p==0)? String::EMPTY : p;
  
  // Get password from environment or use empty
  p = getenv("CIM_PASSWORD");
  _passWord = (p==0)? String::EMPTY : p;

  try
  {
    if (String::equal(_hostName,String::EMPTY)) _c.connectLocal();
    else
    // hostname was specified; do remote connect
    {
      if (sslContext) _c.connect(_hostName, _portNumber, *sslContext, _userName, _passWord);
      else _c.connect(_hostName, _portNumber, _userName, _passWord);
    }
  }
  catch(Exception& e)
  {
    cerr << e.getMessage() << endl;
    return 1;
  }

  // command is first arg
  const char *cmd = argv[1];

  if (String::equalNoCase(cmd,"getClass") ||
      String::equalNoCase(cmd,"gc"))
    return _getClass(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"enumerateClasses") ||
           String::equalNoCase(cmd,"ec"))
    return _enumerateClasses(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"enumerateClassNames") ||
           String::equalNoCase(cmd,"ecn"))
    return _enumerateClassNames(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"getInstance") ||
           String::equalNoCase(cmd,"gi"))
    return _getInstance(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"enumerateInstances") ||
           String::equalNoCase(cmd,"ei"))
    return _enumerateInstances(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"enumerateInstanceNames") ||
           String::equalNoCase(cmd,"ein"))
    return _enumerateInstanceNames(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"getProperty") ||
           String::equalNoCase(cmd,"gp"))
    return _getProperty(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"setProperty") ||
           String::equalNoCase(cmd,"sp"))
    return _setProperty(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"invokeMethod") ||
           String::equalNoCase(cmd,"im"))
    return _invokeMethod(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"createClass") ||
           String::equalNoCase(cmd,"cc"))
    return _createClass(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"modifyClass") ||
           String::equalNoCase(cmd,"mc"))
    return _modifyClass(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"deleteClass") ||
           String::equalNoCase(cmd,"dc"))
    return _deleteClass(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"createInstance") ||
           String::equalNoCase(cmd,"ci"))
    return _createInstance(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"modifyInstance") ||
           String::equalNoCase(cmd,"mi"))
    return _modifyInstance(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"deleteInstance") ||
           String::equalNoCase(cmd,"di"))
    return _deleteInstance(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"associators") ||
           String::equalNoCase(cmd,"a"))
    return _associators(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"associatorNames") ||
           String::equalNoCase(cmd,"an"))
    return _associatorNames(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"references") ||
           String::equalNoCase(cmd,"r"))
    return _references(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"referenceNames") ||
           String::equalNoCase(cmd,"rn"))
    return _referenceNames(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"execQuery") ||
           String::equalNoCase(cmd,"exq"))
    return _execQuery(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"getQualifier") ||
           String::equalNoCase(cmd,"gq"))
    return _getQualifier(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"setQualifier") ||
           String::equalNoCase(cmd,"sq"))
    return _setQualifier(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"deleteQualifier") ||
           String::equalNoCase(cmd,"dq"))
    return _deleteQualifier(argc-2,&argv[2]);
  else if (String::equalNoCase(cmd,"enumerateQualifiers") ||
           String::equalNoCase(cmd,"eq"))
    return _enumerateQualifiers(argc-2,&argv[2]);
  else
  {
    cerr << cmd << ": Invalid CIM operation."<< endl;
   _usage();
    return 1;
  }
}