Ejemplo n.º 1
0
/**
 * Creates a subgroup in the group and returns a reference to it.
 */
PwGroup* PwGroupV3::createGroup() {
    PwGroupV3* newGroup = new PwGroupV3(this);
    newGroup->setUuid(PwUuid::create());

    newGroup->setFlags(0);

    // create an ID that does not exist already
    qint32 newId = reinterpret_cast<PwDatabaseV3*>(getDatabase())->createNewGroupId();
    newGroup->setId(newId);

    // inherit the icon and recycled status
    newGroup->setIconId(this->getIconId());
    newGroup->setDeleted(this->isDeleted());

    // set times
    newGroup->setCreationTime(QDateTime::currentDateTime());
    newGroup->setLastAccessTime(QDateTime::currentDateTime());
    newGroup->setLastModificationTime(QDateTime::currentDateTime());
    // newGroup->setExpires(false); <- in V3 is managed by setExpiryTime()
    newGroup->setExpiryTime(PwDatabaseV3::EXPIRY_DATE_NEVER);

    // set parent group
    newGroup->setParentGroup(this);
    newGroup->setLevel(this->getLevel() + 1);
    this->addSubGroup(newGroup);

    newGroup->setDatabase(getDatabase());
    return newGroup;
}
/*
  Performs whatever has been requested in the request
  and returns the result of the request to the client
  over the tcp socket

        requestObject - The request being made that should be filled

        type - The type of request to be filled
*/
int ServerObjectResponse::fillObjectResponse(StorableInterface& requestObject, ServerObjectRequest::ObjectRequestType type){

   if(type == ServerObjectRequest::Query || type == ServerObjectRequest::EqualityQuery){
        QList<QMap<QString, QVariant> > responseData;

        bool equality = (type == ServerObjectRequest::EqualityQuery);
        int result = getDatabase()->queryForObjects(requestObject, responseData, equality);
        QString className = requestObject.className();
        fillXMLResponse(responseData, className);

        return result;

   }else{
       int result;


       if(type == ServerObjectRequest::Add){
            result = getDatabase()->addObject(requestObject);
       }else if(type == ServerObjectRequest::Edit){
            result = getDatabase()->editObject(requestObject);
       }else if(type == ServerObjectRequest::Remove){
            result = getDatabase()->removeObject(requestObject);
       }

       QList<QMap<QString, QVariant> > responseData;
       QMap<QString, QVariant> data;
       requestObject.getAttributesAndValues(data);
       responseData.append(data);
       QString className = requestObject.className();
       fillXMLResponse(responseData, className);
       return result;
    }
}
Ejemplo n.º 3
0
void FilterRequest::Execute() {
   if (!hasDispatched) {
      result=timeOutCode;
      setDataSource(DataSource(getDatabase()->getCurrentSource(), 
                    getDatabase()->getNetworkId(), getDatabase()->getTransportStreamId()));
      Detach();
   }
}
Ejemplo n.º 4
0
/********************************************************************************
 * Function: StartApplication
 * Description: This is the first function that gets called and it is 
 * responsible for initializing databases and other global variables, checking
 * to see whether private records will be shown and calculating the auto-off time
 * for the current system.
 * ******************************************************************************/ 
static Err 
StartApplication (void) 
{
	UInt16 mode = dmModeReadWrite;
	Err errors = 0;
	Boolean created;
	StripPrefType prefs;	
	UInt16 prefsSize, prefsVersion;

		// set current form to be the password opener
		currentForm = PasswordForm;
	
		// check about private records
		hideSecretRecords = PrefGetPreference (prefHidePrivateRecordsV33);
	if (!hideSecretRecords)
		mode |= dmModeShowSecret;

	/*  handle program prefrences */
	prefsSize = sizeof (StripPrefType);
	prefsVersion = PrefGetAppPreferences (StripCreator, StripPrefID, &prefs, &prefsSize, true);
	if (prefsVersion == noPreferenceFound) { 
        FrmCustomAlert (GenericError, "This version of StripCS is only able to convert 0.5 databases. If you're using an earlier version you must run the StripCS_0.5.prc file that came with this distro first. If you aren't upgrading, just run Strip.prc!", NULL, NULL);
		return -1;
	} else if (prefsVersion == StripVersionNumber) {
        FrmCustomAlert (GenericError, "It looks like you have already converted your databases with StripCS. You may now use the latest version of Strip.", NULL, NULL);
		return -1;
	}
	
		// open or create databases.
		errors =
		getDatabase (&SystemDB, systemDBTypeOld, StripCreator, mode, 0,
					  systemDBName, &created);

		errors =
		getDatabase (&AccountDB, accountDBTypeOld, StripCreator, mode, 0,
					  accountDBName, &created);

		errors =
		getDatabase (&PasswordDB, passwordDBTypeOld, StripCreator, mode, 0,
					  passwordDBName, &created);

	
		// if the password database does not exist, or there are no records in it note that 
		// this is the first run, so the user will be prompted to enter a new password.
		if (created 
			||(DmNumRecordsInCategory (PasswordDB, dmAllCategories) == 0))
		
	{
		firstRun = true;
	}
	
		// set up the timer stuff.  start by setting auto off time to 0. the function returns the old 
		// auto off time. If the oldAutoOffTime is 0 then the system will never shut down. this is not
		// the behavior that we want, so we reset the autoOffTime to 300. if the oldAutoOffTime is not 
		// 0 then we set it back immediatly.  Note that in the StopApplication function we 
		// set the autoOffTime back to what it was before this program started no matter what.
		return 0;
}
Ejemplo n.º 5
0
void DocumentationViewer::_render(shared_ptr<EntitiesEntity> entity, shared_ptr<XMLPortalExporter> exporter, uint32 level, uint32 levelMax, bool withTexts, bool forContent)
{
	if(entity == nullptr)
		return;

	if(levelMax == 0) // Disabled.
		return;

	if(forContent)
		exporter->setMode(XMLPortalExporter::emFull);
	else
		exporter->setMode(XMLPortalExporter::emLite);
	
	entity->exportXML(exporter);

	bool exportTexts = withTexts;
	// I testi già comparsi sopra non compaiono nel sottoindice.
	if( (exportTexts) && (forContent == false) )
		exportTexts = (level > 0);

	// Esporta gli oggetti testo
	if(exportTexts)
	{
		shared_ptr<EntitiesEntities> texts = entity->getChilds(getDatabase(), portalObjectTypeText, RangeUint32(0, 0), EntitiesEntity::coPositionAsc);
		if(texts != nullptr && texts->empty() == false)
		{
			shared_ptr<XMLNode> nodeTexts = exporter->getRoot()->addChild(_S("texts"));
			for(EntitiesEntities::const_iterator i = texts->begin(); i != texts->end(); ++i)
			{
				exporter->getPage()->getPortal()->getEntity(exporter->getDatabase(), *i)->exportXML(exporter->createChild<XMLPortalExporter>(nodeTexts->addChild(_S("text"))));
			}
		}
	}

	bool exportSections = true;
	if(levelMax != static_cast<uint32>(-1))
	{
		if(forContent)
			exportSections = (level<(levelMax-1));
		else
			exportSections = (level<=(levelMax-1));
	}

	// Crea un nodo delle sotto-sezioni
	if(exportSections)
	{
		shared_ptr<EntitiesEntities> subSections = entity->getChilds(getDatabase(), portalObjectTypeSection, RangeUint32(0, 0), EntitiesEntity::coPositionAsc);
		if(subSections != nullptr && subSections->empty() == false)
		{
			shared_ptr<XMLNode> nodeSubSections = exporter->getRoot()->addChild(_S("sections"));
			for(EntitiesEntities::const_iterator i = subSections->begin(); i != subSections->end(); ++i)
			{
				_render(exporter->getPage()->getPortal()->getEntity(getDatabase(), *i), exporter->createChild<XMLPortalExporter>(nodeSubSections->addChild(_S("section"))), level +1, levelMax, withTexts, forContent);
			}
		}
	}
}
Ejemplo n.º 6
0
void LegacyRulePlanNode::write(FileWriter &w, CPArea parentArea) const
{
	PlanNode::write(w, parentArea);
	// write rule identification including revision here
	w.appendIdentifier(getDatabase()->getId(),'/');
	w.appendIdentifier(getCube()->getId(),'/');
	w.appendIdentifier(getRule()->getId(),'/');
	w.appendIdentifier((IdentifierType)getDatabase()->getObjectRevision(),0); // TODO: -jj- serialize uint64_t
}
Ejemplo n.º 7
0
bool FilterRequest::checkFinish() {
   if (finished) {
      result=ResultCodeSuccess;
      setDataSource(DataSource(getDatabase()->getCurrentSource(), 
                    getDatabase()->getNetworkId(), getDatabase()->getTransportStreamId()));
      Detach();
      return true;
   }
   return false;
}
Ejemplo n.º 8
0
bool FilterRequest::CancelRequest() {
   if (!hasDispatched) {
      result=ResultCodeRequestCancelled;
      setDataSource(DataSource(getDatabase()->getCurrentSource(), 
                    getDatabase()->getNetworkId(), getDatabase()->getTransportStreamId()));
      Detach();
      return true;
   }
   return false;
}
Ejemplo n.º 9
0
/*******************************************************************************
**
** Function:        printDiagnostic
**
** Description:     Print some diagnostic output.
**
** Returns:         None.
**
*******************************************************************************/
void RouteDataSet::printDiagnostic ()
{
    static const char fn [] = "RouteDataSet::printDiagnostic";
    Database* db = getDatabase (DefaultRouteDatabase);

    ALOGD ("%s: default route database", fn);
    for (Database::iterator iter = db->begin(); iter != db->end(); iter++)
    {
        RouteData* routeData = *iter;
        switch (routeData->mRouteType)
        {
        case RouteData::ProtocolRoute:
            {
                RouteDataForProtocol* proto = (RouteDataForProtocol*) routeData;
                ALOGD ("%s: ee h=0x%X; protocol=0x%X", fn, proto->mNfaEeHandle, proto->mProtocol);
            }
            break;
        case RouteData::TechnologyRoute:
            {
                RouteDataForTechnology* tech = (RouteDataForTechnology*) routeData;
                ALOGD ("%s: ee h=0x%X; technology=0x%X", fn, tech->mNfaEeHandle, tech->mTechnology);
            }
            break;
        }
    }

    ALOGD ("%s: sec elem route database", fn);
    db = getDatabase (SecElemRouteDatabase);
    for (Database::iterator iter2 = db->begin(); iter2 != db->end(); iter2++)
    {
        RouteData* routeData = *iter2;
        switch (routeData->mRouteType)
        {
        case RouteData::ProtocolRoute:
            {
                RouteDataForProtocol* proto = (RouteDataForProtocol*) routeData;
                ALOGD ("%s: ee h=0x%X; protocol=0x%X", fn, proto->mNfaEeHandle, proto->mProtocol);
            }
            break;
        case RouteData::TechnologyRoute:
            {
                RouteDataForTechnology* tech = (RouteDataForTechnology*) routeData;
                ALOGD ("%s: ee h=0x%X; technology=0x%X", fn, tech->mNfaEeHandle, tech->mTechnology);
            }
            break;
        }
    }
}
Ejemplo n.º 10
0
bool DatabaseConnecter::isDatabaseOpened(const QString &connectionName,
                                         const QString &driver, const QString &host, int port,
                                         const QString &user, const QString &passwd,
                                         const QString &databaseName, HEHUI::DatabaseType databaseType)

{

    qDebug() << "----DatabaseConnecter::isDatabaseOpened(...)";
    Q_ASSERT_X(!connectionName.isEmpty(), "DatabaseConnecter::isDatabaseOpened(...)", "'connectionName' is empty!");
    Q_ASSERT_X(!driver.isEmpty(), "DatabaseConnecter::isDatabaseOpened(...)", "'driver' is empty!");
    Q_ASSERT_X(!databaseName.isEmpty(), "DatabaseConnecter::isDatabaseOpened(...)", "'databaseName' is empty!");

    QSqlDatabase db;
    db = QSqlDatabase::database(connectionName);

    if (!db.isValid()) {
        db = getDatabase(connectionName, driver, host, port, user, passwd,
                         databaseName, databaseType);

        //        db = QSqlDatabase::database(connectionName);

    }

    if(db.isValid() && db.isOpen()){
        return true;
    }else{
        return false;
    }


}
Ejemplo n.º 11
0
bool DatabaseConnecter::connectToNewDatabase(QString *connectionName) {
    qDebug() << "----DatabaseConnecter::connectToNewDatabase()";

    DatabaseConnecterDialog dbConnecterDlg(parentWidget);

    QStringList parameters = dbConnecterDlg.getParameters();
    if (parameters.size() <= 0) {
        QMessageBox::critical(parentWidget, tr("Fatal Error"), tr(
                                  "Can not connect to database server!"));
        qCritical() << QString("XX Fatal Error!") << QString(
                           "Can not connect to database server!");
        return false;
    }

    getDatabase(parameters.at(0), parameters.at(1), parameters.at(2),
                parameters.at(3).toInt(), parameters.at(4), parameters.at(5),
                parameters.at(6), (HEHUI::DatabaseType) parameters.at(7).toUInt());

    QSqlDatabase db;
    db = QSqlDatabase::database(parameters.at(0));

    if(connectionName){
        *connectionName = parameters.at(0);
    }

    return db.isValid();
}
Ejemplo n.º 12
0
void Functions::load(ProgressIndicator* progressIndicator)
{
    wxString stmt = "select rdb$function_name from rdb$functions"
        " where (rdb$system_flag = 0 or rdb$system_flag is null)"
        " order by 1";
    setItems(getDatabase()->loadIdentifiers(stmt, progressIndicator));
}
Ejemplo n.º 13
0
bool QgsDb2Provider::changeGeometryValues( const QgsGeometryMap &geometry_map )
{
  if ( geometry_map.isEmpty() )
    return true;

  if ( mFidColName.isEmpty() )
    return false;

  for ( QgsGeometryMap::const_iterator it = geometry_map.constBegin(); it != geometry_map.constEnd(); ++it )
  {
    QgsFeatureId fid = it.key();
    // skip added features
    if ( FID_IS_NEW( fid ) )
    {
      continue;
    }

    QString statement;
    statement = QString( "UPDATE %1.%2 SET %3 = " )
                .arg( mSchemaName, mTableName, mGeometryColName );

    if ( !mDatabase.isOpen() )
    {
      QString errMsg;
      mDatabase = getDatabase( mConnInfo, errMsg );
      if ( !errMsg.isEmpty() )
      {
        return false;
      }
    }
    QSqlQuery query = QSqlQuery( mDatabase );
    query.setForwardOnly( true );

    statement += QString( "db2gse.%1(CAST (%2 AS BLOB(2M)),%3)" )
                 .arg( mGeometryColType,
                       QString( "?" ),
                       QString::number( mSRId ) );

    // set attribute filter
    statement += QString( " WHERE %1=%2" ).arg( mFidColName, FID_TO_STRING( fid ) );
    QgsDebugMsg( statement );
    if ( !query.prepare( statement ) )
    {
      QgsDebugMsg( query.lastError().text() );
      return false;
    }

    // add geometry param
    QByteArray bytea = QByteArray(( char* )it->asWkb(), ( int ) it->wkbSize() );
    query.addBindValue( bytea, QSql::In | QSql::Binary );

    if ( !query.exec() )
    {
      QgsDebugMsg( query.lastError().text() );
      return false;
    }
  }

  return true;
}
Ejemplo n.º 14
0
T * DataMapper<Subclass, T, I>::getBy(const QString & whereClause)
{
    QSqlQuery query = getDatabase().build(SELECT("*").FROM(table()).WHERE(whereClause).LIMIT(1));

    if (query.exec())
    {
        QSqlRecord record = query.record();
        QMap<QString, int> indices;

        for (unsigned i = 0;i < record.count();++i)
        {
            indices[record.fieldName(i)] = i;
        }

        if (query.next())
        {
            QVariantMap map;

            for (QString fieldName : indices.keys())
            {
                map[fieldName] = query.value(indices[fieldName]);
            }

            return obtainFromIdentityMap(map);
        }
    }

    return nullptr;
}
Ejemplo n.º 15
0
string Document::getURL(bool withRevision) const
{
   string url = "/" + getDatabase() + "/" + getID();
   if(withRevision && revision.size() > 0)
      url += "?rev=" + revision;
   return url;
}
Ejemplo n.º 16
0
QSqlDatabase QrSqlDatabase::getDatabaseCloned()
{
    QSqlError dbError;
    Q_UNUSED(dbError);
    QString connectionName = QUuid::createUuid ().toString ();
    return QSqlDatabase::cloneDatabase (getDatabase (dbError), connectionName);
}
Ejemplo n.º 17
0
bool QgsMssqlConnection::truncateTable( const QString &uri, QString *errorMessage )
{
  QgsDataSourceUri dsUri( uri );

  // connect to database
  QSqlDatabase db = getDatabase( dsUri.service(), dsUri.host(), dsUri.database(), dsUri.username(), dsUri.password() );
  const QString schema = dsUri.schema();
  const QString table = dsUri.table();

  if ( !openDatabase( db ) )
  {
    if ( errorMessage )
      *errorMessage = db.lastError().text();
    return false;
  }

  QSqlQuery q = QSqlQuery( db );
  q.setForwardOnly( true );
  const QString sql = QStringLiteral( "TRUNCATE TABLE [%1].[%2]" ).arg( schema, table );
  if ( !q.exec( sql ) )
  {
    if ( errorMessage )
      *errorMessage = q.lastError().text();
    return false;
  }

  return true;
}
void NaiveBayesianClassifier::changeCount(const QString &category, int change)
{
    long idxsearch=-1;
    c4_Row findrow;
    c4_StringProp match("name");
    match(findrow)=category;
    c4_IntProp count("count");

    c4_View catCount = getDatabase().GetAs("categories[name:S,count:I]");
    idxsearch = catCount.Find(findrow,idxsearch+1);
    if (idxsearch>=0) 
    {
        long zero = 0;
        count(catCount[idxsearch]) = std::max(zero, count(catCount[idxsearch]) + change);
    }
    else 
    {
        c4_StringProp newCat("name");
        c4_IntProp newCount("count");
        c4_Row newRow;
        newCat(newRow)=category;
        newCount(newRow)=std::max(0, change);
        catCount.Add(newRow);
    }
}
Ejemplo n.º 19
0
bool QgsMssqlConnection::createSchema( const QString &uri, const QString &schemaName, QString *errorMessage )
{
  QgsDataSourceUri dsUri( uri );

  // connect to database
  QSqlDatabase db = getDatabase( dsUri.service(), dsUri.host(), dsUri.database(), dsUri.username(), dsUri.password() );

  if ( !openDatabase( db ) )
  {
    if ( errorMessage )
      *errorMessage = db.lastError().text();
    return false;
  }

  QSqlQuery q = QSqlQuery( db );
  q.setForwardOnly( true );
  const QString sql = QStringLiteral( "CREATE SCHEMA [%1]" ).arg( schemaName );
  if ( !q.exec( sql ) )
  {
    if ( errorMessage )
      *errorMessage = q.lastError().text();
    return false;
  }

  return true;
}
Ejemplo n.º 20
0
void
test_drop_table_does_not_loop()
{
  nsCOMPtr<mozIStorageConnection> db(getDatabase());

  // Need to prepare our statement ahead of time so we make sure to only test
  // step and not prepare.
  nsCOMPtr<mozIStorageStatement> stmt;
  nsresult rv = db->CreateStatement(NS_LITERAL_CSTRING(
    "SELECT * FROM test"
  ), getter_AddRefs(stmt));
  do_check_success(rv);

  RefPtr<DatabaseTester> tester(new DatabaseTester(db, "DROP TABLE test"));
  do_check_true(tester);
  mozilla::ReentrantMonitorAutoEnter lock(tester->monitor);
  tester->RunInBackground();

  // Hold a read lock on the database, and then let the tester try to execute.
  bool hasResult;
  rv = stmt->ExecuteStep(&hasResult);
  do_check_success(rv);
  do_check_true(hasResult);
  tester->Notify(READ_LOCK);

  // Make sure the tester finishes its test before we move on.
  tester->WaitFor(TEST_DONE);
}
Ejemplo n.º 21
0
void
test_step_locked_does_not_block_main_thread()
{
  nsCOMPtr<mozIStorageConnection> db(getDatabase());

  // Need to prepare our statement ahead of time so we make sure to only test
  // step and not prepare.
  nsCOMPtr<mozIStorageStatement> stmt;
  nsresult rv = db->CreateStatement(NS_LITERAL_CSTRING(
    "INSERT INTO test (data) VALUES ('test1')"
  ), getter_AddRefs(stmt));
  do_check_success(rv);

  RefPtr<DatabaseLocker> locker(new DatabaseLocker("SELECT * FROM test"));
  do_check_true(locker);
  mozilla::ReentrantMonitorAutoEnter lock(locker->monitor);
  locker->RunInBackground();

  // Wait for the locker to notify us that it has locked the database properly.
  locker->WaitFor(WRITE_LOCK);

  bool hasResult;
  rv = stmt->ExecuteStep(&hasResult);
  do_check_eq(rv, NS_ERROR_FILE_IS_LOCKED);

  locker->Notify(TEST_DONE);
}
Ejemplo n.º 22
0
MetadataItem::MetadataItem(NodeType type, MetadataItem* parent,
        const wxString& name)
   : Subject(), typeM(type), parentM(parent), identifierM(name, getDatabase() != nullptr ? getDatabase()->getSqlDialect() : 3),
        childrenLoadedM(lsNotLoaded), descriptionLoadedM(lsNotLoaded),
        propertiesLoadedM(lsNotLoaded)
{
}
Ejemplo n.º 23
0
int main(int argc, char** argv) {
    if(argc != 2) {
        printf("Usage: %s <Student ID>\n", argv[0]);
        exit(2);
    }

    // Load database and semaphores from shared memory
    struct StudentInfo* infoptr = getDatabase(false);
    int* num_readers = getReadcount(false);
    int semaset = semget(SEMA_KEY, 0, 0);

    // Wait on semaphores to ensure there are no other
    // writers to num_readers and that there are no active
    // writers to the database
    Wait(semaset, 1);
    (*num_readers)++;
    if( (*num_readers) == 1) {
        Wait(semaset, 0);
    }
    Signal(semaset, 1);

    // Print the database to the screen
    output_student(infoptr, argv[1]);

    // Decrement num_readers and if this was the last reader,
    // signal that the database is free
    Wait(semaset, 1);
    (*num_readers)--;
    if( (*num_readers) == 0) {
        Signal(semaset, 0);
    }
    Signal(semaset, 1);
}
Ejemplo n.º 24
0
bool QgsMssqlConnection::dropTable( const QString &uri, QString *errorMessage )
{
  QgsDataSourceUri dsUri( uri );

  // connect to database
  QSqlDatabase db = getDatabase( dsUri.service(), dsUri.host(), dsUri.database(), dsUri.username(), dsUri.password() );
  const QString schema = dsUri.schema();
  const QString table = dsUri.table();

  if ( !openDatabase( db ) )
  {
    if ( errorMessage )
      *errorMessage = db.lastError().text();
    return false;
  }

  QSqlQuery q = QSqlQuery( db );
  q.setForwardOnly( true );
  const QString sql = QString( "IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[%1].[%2]') AND type in (N'U')) DROP TABLE [%1].[%2]\n"
                               "DELETE FROM geometry_columns WHERE f_table_schema = '%1' AND f_table_name = '%2'" )
                      .arg( schema,
                            table );
  if ( !q.exec( sql ) )
  {
    if ( errorMessage )
      *errorMessage = q.lastError().text();
    return false;
  }

  return true;
}
Ejemplo n.º 25
0
PUBLIC EdiRec *readRec(cchar *tableName, cchar *key)
{
    if (key == 0 || *key == 0) {
        key = "1";
    }
    return setRec(ediReadRec(getDatabase(), tableName, key));
}
Ejemplo n.º 26
0
void Exceptions::load(ProgressIndicator* progressIndicator)
{
    DatabasePtr db = getDatabase();
    MetadataLoader* loader = db->getMetadataLoader();
    MetadataLoaderTransaction tr(loader);
    wxMBConv* converter = db->getCharsetConverter();

    IBPP::Statement& st1 = loader->getStatement(
        Exception::getLoadStatement(true));

    CollectionType exceptions;
    st1->Execute();
    checkProgressIndicatorCanceled(progressIndicator);
    while (st1->Fetch())
    {
        if (!st1->IsNull(1))
        {
            std::string s;
            st1->Get(1, s);
            wxString name(std2wxIdentifier(s, converter));

            ExceptionPtr exception = findByName(name);
            if (!exception)
            {
                exception.reset(new Exception(db, name));
                initializeLockCount(exception, getLockCount());
            }
            exceptions.push_back(exception);
            exception->loadProperties(st1, converter);
        }
        checkProgressIndicatorCanceled(progressIndicator);
    }

    setItems(exceptions);
}
Ejemplo n.º 27
0
void NexusFlagItem::dismount(DismountMode dismountMode)
{
    if(isGhost())      // Server only
        return;
    if(getDatabase() == NULL)  // must be in database, switching levels makes database NULL
        return;

    if(dismountMode == DISMOUNT_MOUNT_WAS_KILLED)
    {
        // Should getting shot up count as a flag drop event for statistics purposes?
        if(mMount && mMount->getClientInfo())
            mMount->getClientInfo()->getStatistics()->mFlagDrop += mFlagCount + 1;

        dropFlags(mFlagCount + 1);    // Drop at least one flag plus as many as the ship carries

        // Now delete the flag itself
        removeFromDatabase(false);
        deleteObject();
    }
    else
    {
        GameType *gameType = getGame()->getGameType();
        if(!gameType)        // Crashed here once, don't know why, so I added the check
            return;

        gameType->itemDropped(mMount, this, dismountMode); // Sends messages; no flags actually dropped here; server only method
        dropFlags(mFlagCount);                             // Only dropping the flags we're carrying, not the "extra" one that comes when we die
    }
}
Ejemplo n.º 28
0
/**
 * Moves all the group's entries (recursively) to Backup group; subgroups are deleted.
 * Returns true if successful.
 */
bool PwGroupV3::moveToBackup() {
    PwGroup* parentGroup = this->getParentGroup();
    if (!parentGroup) {
        LOG("PwGroupV3::moveToBackup fail - no parent group");
        return false;
    }

    PwGroup* backupGroup = getDatabase()->getBackupGroup(true);
    // For v3, backupGroup is guaranteed to be not NULL

    parentGroup->removeSubGroup(this);
    // detach this branch from the parent group; memory will be released later.

    // flag the group and all its children deleted
    setDeleted(true);
    QList<PwGroup*> childGroups;
    QList<PwEntry*> childEntries;
    getAllChildren(childGroups, childEntries);
    // V3 does not backup subgroups, so move only entries
    for (int i = 0; i < childEntries.size(); i++) {
        if (!childEntries.at(i)->moveToBackup()) {
            LOG("PwGroupV3::moveToBackup fail on child entry");
            return false;
        }
    }
    childGroups.clear();
    childEntries.clear();
    LOG("PwGroupV3::moveToBackup OK");
    return true;
}
Ejemplo n.º 29
0
QList<T *> DataMapper<Subclass, T, I>::basicFind(const QString & sql)
{
    QList<T *> results;

    QSqlQuery query = getDatabase().build(sql);

    if (query.exec())
    {
        QSqlRecord record = query.record();
        QMap<QString, int> indices;

        for (unsigned i = 0;i < record.count();++i)
        {
            indices[record.fieldName(i)] = i;
        }

        while (query.next())
        {
            QVariantMap map;

            for (QString fieldName : indices.keys())
            {
                map[fieldName] = query.value(indices[fieldName]);
            }

            results << obtainFromIdentityMap(map);
        }
    }

    return results;
}
Ejemplo n.º 30
0
QStringList QgsMssqlConnection::schemas( const QString &uri, QString *errorMessage )
{
  QgsDataSourceUri dsUri( uri );

// connect to database
  QSqlDatabase db = getDatabase( dsUri.service(), dsUri.host(), dsUri.database(), dsUri.username(), dsUri.password() );

  if ( !openDatabase( db ) )
  {
    if ( errorMessage )
      *errorMessage = db.lastError().text();
    return QStringList();
  }

  const QString sql = QStringLiteral( "select s.name as schema_name from sys.schemas s" );

  QSqlQuery q = QSqlQuery( db );
  q.setForwardOnly( true );
  if ( !q.exec( sql ) )
  {
    if ( errorMessage )
      *errorMessage = q.lastError().text();
    return QStringList();
  }

  QStringList result;

  while ( q.next() )
  {
    const QString schemaName = q.value( 0 ).toString();
    result << schemaName;
  }
  return result;
}