void NotificationPresenterImpl::clearAll() { LOGV("NotificationPresenterImpl::clearAll"); //maybeLoadPermanentPermissions(); deleteDatabase(); s_notificationPermissions.clear(); }
void DatabaseTracker::deleteDatabasesModifiedSince(std::chrono::system_clock::time_point time) { Vector<RefPtr<SecurityOrigin>> originsCopy; origins(originsCopy); for (auto& origin : originsCopy) { Vector<String> databaseNames; if (!databaseNamesForOrigin(origin.get(), databaseNames)) continue; size_t deletedDatabases = 0; for (auto& databaseName : databaseNames) { auto fullPath = fullPathForDatabase(origin.get(), databaseName, false); time_t modificationTime; if (!getFileModificationTime(fullPath, modificationTime)) continue; if (modificationTime < std::chrono::system_clock::to_time_t(time)) continue; deleteDatabase(origin.get(), databaseName); ++deletedDatabases; } if (deletedDatabases == databaseNames.size()) deleteOrigin(origin.get()); } }
DatabaseTabWidget::~DatabaseTabWidget() { QHashIterator<Database*, DatabaseManagerStruct> i(m_dbList); while (i.hasNext()) { i.next(); deleteDatabase(i.key()); } }
int main() { int choose; int db = 0; printf("Hauptmenu Lager Logistic\n\n"); printf("1. New Database.\n"); printf("2. Show Database.\n"); printf("3. Use Database.\n"); printf("4. Delete Database.\n"); printf("-----------------------\n"); printf("Choose a menu: "); scanf("%i", &choose); printf("\n"); switch (choose) { case 1: printf("You want to make a new database.\n"); newDatabase(); break; case 2: printf("You want to show a database.\n"); printf("Which Database you want to see (id or name): "); scanf("%i", &db); if (db != 0) showDatabase(db); else printf("\n\n--! Database does not exist !--\n\n"); db = 0; break; case 3: printf("You want to edit a database.\n"); printf("Which Database you want to edit (id or name): "); scanf("%i", &db); if (db != 0) editDatabase(db); else printf("\n\n--! Database does not exist !--\n\n"); db = 0; break; case 4: printf("You want to delete a database.\n"); printf("Which Database you want to delete (id or name): "); scanf("%i", &db); if (db != 0) deleteDatabase(db); else printf("\n\n--! Database does not exist !--\n\n"); db = 0; break; } return 0; }
bool DatabaseTabWidget::closeDatabase(Database* db) { Q_ASSERT(db); const DatabaseManagerStruct& dbStruct = m_dbList.value(db); int index = databaseIndex(db); Q_ASSERT(index != -1); QString dbName = tabText(index); if (dbName.right(1) == "*") { dbName.chop(1); } if (dbStruct.dbWidget->isInEditMode() && db->hasKey() && dbStruct.dbWidget->isEditWidgetModified()) { QMessageBox::StandardButton result = MessageBox::question( this, tr("Close?"), tr("\"%1\" is in edit mode.\nDiscard changes and close anyway?").arg(dbName), QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel); if (result == QMessageBox::Cancel) { return false; } } if (dbStruct.modified) { if (config()->get("AutoSaveOnExit").toBool()) { if (!saveDatabase(db)) { return false; } } else { QMessageBox::StandardButton result = MessageBox::question( this, tr("Save changes?"), tr("\"%1\" was modified.\nSave changes?").arg(dbName), QMessageBox::Yes | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Yes); if (result == QMessageBox::Yes) { if (!saveDatabase(db)) { return false; } } else if (result == QMessageBox::Cancel) { return false; } } } deleteDatabase(db); return true; }
void IDBDatabaseBackendImpl::processPendingCalls() { if (m_pendingSecondHalfOpenWithVersion) { ASSERT(m_pendingSecondHalfOpenWithVersion->version() == m_metadata.intVersion); ASSERT(m_metadata.id != InvalidId); m_pendingSecondHalfOpenWithVersion->callbacks()->onSuccess(this); m_pendingSecondHalfOpenWithVersion.release(); // Fall through when complete, as pending deletes may be (partially) unblocked. } // Note that this check is only an optimization to reduce queue-churn and // not necessary for correctness; deleteDatabase and openConnection will // requeue their calls if this condition is true. if (m_runningVersionChangeTransaction) return; // Pending calls may be requeued. Deque<OwnPtr<PendingDeleteCall> > pendingDeleteCalls; m_pendingDeleteCalls.swap(pendingDeleteCalls); while (!pendingDeleteCalls.isEmpty()) { OwnPtr<PendingDeleteCall> pendingDeleteCall = pendingDeleteCalls.takeFirst(); deleteDatabase(pendingDeleteCall->callbacks()); } // This check is also not really needed, openConnection would just requeue its calls. if (m_runningVersionChangeTransaction || !m_pendingDeleteCalls.isEmpty()) return; Deque<OwnPtr<PendingOpenWithVersionCall> > pendingOpenWithVersionCalls; m_pendingOpenWithVersionCalls.swap(pendingOpenWithVersionCalls); while (!pendingOpenWithVersionCalls.isEmpty()) { OwnPtr<PendingOpenWithVersionCall> pendingOpenWithVersionCall = pendingOpenWithVersionCalls.takeFirst(); openConnectionWithVersion(pendingOpenWithVersionCall->callbacks(), pendingOpenWithVersionCall->databaseCallbacks(), pendingOpenWithVersionCall->version()); } // Open calls can be requeued if an openWithVersion call started a version // change transaction. Deque<OwnPtr<PendingOpenCall> > pendingOpenCalls; m_pendingOpenCalls.swap(pendingOpenCalls); while (!pendingOpenCalls.isEmpty()) { OwnPtr<PendingOpenCall> pendingOpenCall = pendingOpenCalls.takeFirst(); openConnection(pendingOpenCall->callbacks(), pendingOpenCall->databaseCallbacks()); } }
/******************************************************************************* ** ** Function: import ** ** Description: Import data from an XML file. Fill the databases. ** ** Returns: True if ok. ** *******************************************************************************/ bool RouteDataSet::import () { static const char fn [] = "RouteDataSet::import"; ALOGD ("%s: enter", fn); bool retval = false; #if 0 xmlDocPtr doc; xmlNodePtr node1; std::string strFilename(bcm_nfc_location); strFilename += sConfigFile; deleteDatabase (); doc = xmlParseFile (strFilename.c_str()); if (doc == NULL) { ALOGD ("%s: fail parse", fn); goto TheEnd; } node1 = xmlDocGetRootElement (doc); if (node1 == NULL) { ALOGE ("%s: fail root element", fn); goto TheEnd; } ALOGD ("%s: root=%s", fn, node1->name); node1 = node1->xmlChildrenNode; while (node1) //loop through all elements in <Routes ... { if (xmlStrcmp(node1->name, (const xmlChar*) "Route")==0) { xmlChar* value = xmlGetProp (node1, (const xmlChar*) "Type"); if (value && (xmlStrcmp (value, (const xmlChar*) "SecElemSelectedRoutes") == 0)) { ALOGD ("%s: found SecElemSelectedRoutes", fn); xmlNodePtr node2 = node1->xmlChildrenNode; while (node2) //loop all elements in <Route Type="SecElemSelectedRoutes" ... { if (xmlStrcmp(node2->name, (const xmlChar*) "Proto")==0) importProtocolRoute (node2, mSecElemRouteDatabase); else if (xmlStrcmp(node2->name, (const xmlChar*) "Tech")==0) importTechnologyRoute (node2, mSecElemRouteDatabase); node2 = node2->next; } //loop all elements in <Route Type="SecElemSelectedRoutes" ... } else if (value && (xmlStrcmp (value, (const xmlChar*) "DefaultRoutes") == 0)) { ALOGD ("%s: found DefaultRoutes", fn); xmlNodePtr node2 = node1->xmlChildrenNode; while (node2) //loop all elements in <Route Type="DefaultRoutes" ... { if (xmlStrcmp(node2->name, (const xmlChar*) "Proto")==0) importProtocolRoute (node2, mDefaultRouteDatabase); else if (xmlStrcmp(node2->name, (const xmlChar*) "Tech")==0) importTechnologyRoute (node2, mDefaultRouteDatabase); node2 = node2->next; } //loop all elements in <Route Type="DefaultRoutes" ... } if (value) xmlFree (value); } //check <Route ... node1 = node1->next; } //loop through all elements in <Routes ... retval = true; TheEnd: xmlFreeDoc (doc); xmlCleanupParser (); ALOGD ("%s: exit; return=%u", fn, retval); #endif return retval; }
/******************************************************************************* ** ** Function: ~RouteDataSet ** ** Description: Release all resources. ** ** Returns: None. ** *******************************************************************************/ RouteDataSet::~RouteDataSet () { deleteDatabase (); }