/* note: not yet in mutex at this point. returns >= 0 if ok. return -1 if you want to reconnect. return value of zero indicates no sleep necessary before next call */ int ReplSource::sync(int& nApplied) { _sleepAdviceTime = 0; ReplInfo r("sync"); if ( !cmdLine.quiet ) { LogstreamBuilder l = log(); l << "repl: syncing from "; if( sourceName() != "main" ) { l << "source:" << sourceName() << ' '; } l << "host:" << hostName << endl; } nClonedThisPass = 0; // FIXME Handle cases where this db isn't on default port, or default port is spec'd in hostName. if ( (string("localhost") == hostName || string("127.0.0.1") == hostName) && cmdLine.port == CmdLine::DefaultDBPort ) { log() << "repl: can't sync from self (localhost). sources configuration may be wrong." << endl; sleepsecs(5); return -1; } if ( !oplogReader.connect(hostName, _me) ) { LOG(4) << "repl: can't connect to sync source" << endl; return -1; } return sync_pullOpLog(nApplied); }
media_node JackClient::FindNativeNode(const char* jack_client) { media_node ret; BString sourceName(jack_client); if (sourceName.FindFirst(Name()) == 0) { // We are the client return fClientNode->Node(); } if (strcmp(jack_client, "system:playback_1") == 0 || strcmp(jack_client, "system:playback_2") == 0 || strcmp(jack_client, "system:capture_1") == 0 || strcmp(jack_client, "system:capture_2") == 0) { fRoster->GetAudioMixer(&ret); } else { // This is not a banal case, find the native node int32 live_count; live_node_info* nativeNodes = _LiveNodes(&live_count); for (int i = 0; i < live_count; i++) { if (sourceName.FindFirst(nativeNodes[i].name) == 0) { return nativeNodes[i].node; } } } return ret; }
Boolean ImageItem::targetDrop(IDMTargetDropEvent& event) { movieFrame->imageCenter = targetOperation()->position(); movieFrame->newFileName = containerName() + sourceName(); movieFrame->postEvent(WM_CUSTOM_SETMOVIE); return true; }
Transliterator* AnyTransliterator::getTransliterator(UScriptCode source) const { if (source == targetScript || source == USCRIPT_INVALID_CODE) { return NULL; } Transliterator* t = (Transliterator*) uhash_iget(cache, (int32_t) source); if (t == NULL) { UErrorCode ec = U_ZERO_ERROR; UnicodeString sourceName(uscript_getName(source), -1, US_INV); UnicodeString id(sourceName); id.append(TARGET_SEP).append(target); t = Transliterator::createInstance(id, UTRANS_FORWARD, ec); if (U_FAILURE(ec) || t == NULL) { delete t; // Try to pivot around Latin, our most common script id = sourceName; id.append(LATIN_PIVOT, -1).append(target); t = Transliterator::createInstance(id, UTRANS_FORWARD, ec); if (U_FAILURE(ec) || t == NULL) { delete t; t = NULL; } } if (t != NULL) { uhash_iput(cache, (int32_t) source, t, &ec); } } return t; }
Boolean DMDatei::sourceDiscard (IDMSourceDiscardEvent &e) { e.setWhoDiscards (IDM::sourceDiscards); DosDelete (containerName () + "\\" + sourceName ()); delete (Datei *)object (); return true; }
static Source * fileOpenSource(File *f, u32int offset, u32int gen, int dir, uint mode, int issnapshot) { char *rname, *fname; Source *r; if(!sourceLock(f->source, mode)) return nil; r = sourceOpen(f->source, offset, mode, issnapshot); sourceUnlock(f->source); if(r == nil) return nil; if(r->gen != gen){ vtSetError(ERemoved); goto Err; } if(r->dir != dir && r->mode != -1){ /* this hasn't been as useful as we hoped it would be. */ rname = sourceName(r); fname = fileName(f); consPrint("%s: source %s for file %s: fileOpenSource: " "dir mismatch %d %d\n", f->source->fs->name, rname, fname, r->dir, dir); free(rname); free(fname); vtSetError(EBadMeta); goto Err; } return r; Err: sourceClose(r); return nil; }
MidiInput::MidiInput(std::vector<unsigned int> sources) { if(OSStatus status = MIDIClientCreate(CFSTR("March"), 0, 0, &_midi_client)) { std::cerr << "Couldn't create MIDI client: " << status << std::endl; #ifdef GetMacOSStatusErrorString std::cerr << GetMacOSStatusErrorString(status) << std::endl; #endif throw "Couldn't create MIDI client."; } if(OSStatus status = MIDIInputPortCreate(_midi_client, CFSTR("March Input"), MidiInput::read, this, &_midi_in)) { std::cerr << "Couldn't create MIDI input port: " << status << std::endl; #ifdef GetMacOSStatusErrorString std::cerr << GetMacOSStatusErrorString(status) << std::endl; #endif throw "Couldn't create MIDI input port."; } for(std::vector<unsigned int>::iterator it = sources.begin(); it != sources.end(); it++) { MIDIEndpointRef src = MIDIGetSource(*it); std::cout << "Using source " << *it << " (" << sourceName(src) << ", " << sourceModel(src) << ", " << sourceManufacturer(src) << ")" << std::endl; MIDIPortConnectSource(_midi_in, src, 0); } }
QgsVectorLayer *QgsFeatureSource::materialize( const QgsFeatureRequest &request, QgsFeedback *feedback ) { QgsWkbTypes::Type outWkbType = request.flags() & QgsFeatureRequest::NoGeometry ? QgsWkbTypes::NoGeometry : wkbType(); QgsCoordinateReferenceSystem crs = request.destinationCrs().isValid() ? request.destinationCrs() : sourceCrs(); QgsAttributeList requestedAttrs = request.subsetOfAttributes(); QgsFields outFields; if ( request.flags() & QgsFeatureRequest::SubsetOfAttributes ) { int i = 0; const QgsFields sourceFields = fields(); for ( const QgsField &field : sourceFields ) { if ( requestedAttrs.contains( i ) ) outFields.append( field ); i++; } } else { outFields = fields(); } std::unique_ptr< QgsVectorLayer > layer( QgsMemoryProviderUtils::createMemoryLayer( sourceName(), outFields, outWkbType, crs ) ); QgsFeature f; QgsFeatureIterator it = getFeatures( request ); int fieldCount = fields().count(); while ( it.nextFeature( f ) ) { if ( feedback && feedback->isCanceled() ) break; if ( request.flags() & QgsFeatureRequest::SubsetOfAttributes ) { // remove unused attributes QgsAttributes attrs; for ( int i = 0; i < fieldCount; ++i ) { if ( requestedAttrs.contains( i ) ) { attrs.append( f.attributes().at( i ) ); } } f.setAttributes( attrs ); } layer->dataProvider()->addFeature( f, QgsFeatureSink::FastInsert ); } return layer.release(); }
const MidiInput::SourceInfo MidiInput::getSourceInfo(unsigned int source) { SourceInfo source_info; MIDIEndpointRef src = MIDIGetSource(source); source_info.name = sourceName(src); source_info.model = sourceModel(src); source_info.manufacturer = sourceManufacturer(src); return source_info; }
/* note: not yet in mutex at this point. returns >= 0 if ok. return -1 if you want to reconnect. return value of zero indicates no sleep necessary before next call */ int ReplSource::sync(int& nApplied) { _sleepAdviceTime = 0; ReplInfo r("sync"); if ( !cmdLine.quiet ) { Nullstream& l = log(); l << "repl: from "; if( sourceName() != "main" ) { l << "source:" << sourceName() << ' '; } l << "host:" << hostName << endl; } nClonedThisPass = 0; // FIXME Handle cases where this db isn't on default port, or default port is spec'd in hostName. if ( (string("localhost") == hostName || string("127.0.0.1") == hostName) && cmdLine.port == CmdLine::DefaultDBPort ) { log() << "repl: can't sync from self (localhost). sources configuration may be wrong." << endl; sleepsecs(5); return -1; } if ( !oplogReader.connect(hostName) ) { log(4) << "repl: can't connect to sync source" << endl; return -1; } /* // get current mtime at the server. BSONObj o = conn->findOne("admin.$cmd", opTimeQuery); BSONElement e = o.getField("optime"); if( e.eoo() ) { log() << "repl: failed to get cur optime from master" << endl; log() << " " << o.toString() << endl; return false; } uassert( 10124 , e.type() == Date ); OpTime serverCurTime; serverCurTime.asDate() = e.date(); */ return sync_pullOpLog(nApplied); }
CString getLabelStringFromID(int id) { CString sourceName(""); int labelStringID = -1; switch (id) { case SYNCSOURCE_CONTACTS: { labelStringID = IDS_MAIN_CONTACTS; break; } case SYNCSOURCE_CALENDAR: { labelStringID = IDS_MAIN_CALENDAR; break; } case SYNCSOURCE_TASKS: { labelStringID = IDS_MAIN_TASKS; break; } case SYNCSOURCE_NOTES: { labelStringID = IDS_MAIN_NOTES; break; } case SYNCSOURCE_PICTURES: { labelStringID = IDS_MAIN_PICTURES; break; } case SYNCSOURCE_VIDEOS: { labelStringID = IDS_MAIN_VIDEOS; break; } case SYNCSOURCE_FILES: { labelStringID = IDS_MAIN_FILES; break; } default: { StringBuffer msg; msg.sprintf("[%s] wrong id: %d", __FUNCTION__, id); printLog(msg.c_str(), "ERROR"); return sourceName; } } sourceName.LoadString(labelStringID); return sourceName; }
Transliterator* AnyTransliterator::getTransliterator(UScriptCode source) const { if (source == targetScript || source == USCRIPT_INVALID_CODE) { return NULL; } Transliterator* t = NULL; { Mutex m(NULL); t = (Transliterator*) uhash_iget(cache, (int32_t) source); } if (t == NULL) { UErrorCode ec = U_ZERO_ERROR; UnicodeString sourceName(uscript_getShortName(source), -1, US_INV); UnicodeString id(sourceName); id.append(TARGET_SEP).append(target); t = Transliterator::createInstance(id, UTRANS_FORWARD, ec); if (U_FAILURE(ec) || t == NULL) { delete t; // Try to pivot around Latin, our most common script id = sourceName; id.append(LATIN_PIVOT, -1).append(target); t = Transliterator::createInstance(id, UTRANS_FORWARD, ec); if (U_FAILURE(ec) || t == NULL) { delete t; t = NULL; } } if (t != NULL) { Transliterator *rt = NULL; { Mutex m(NULL); rt = static_cast<Transliterator *> (uhash_iget(cache, (int32_t) source)); if (rt == NULL) { // Common case, no race to cache this new transliterator. uhash_iput(cache, (int32_t) source, t, &ec); } else { // Race case, some other thread beat us to caching this transliterator. Transliterator *temp = rt; rt = t; // Our newly created transliterator that lost the race & now needs deleting. t = temp; // The transliterator from the cache that we will return. } } delete rt; // will be non-null only in case of races. } } return t; }
void EventScanAlgorithm::showEvent(const EVENTLOGRECORD* record) { static const std::wstring eventName[] = {L" Error", L"Warning", L"Information", L"Success/Failure Audit"}; int nameIndex = log(record->EventType) / log(2); std::wstring sourceName(reinterpret_cast<const wchar_t*>( reinterpret_cast<const unsigned char*>(record) + sizeof(EVENTLOGRECORD))); // Getting a description error by the error(warning) code. wchar_t* errorMess = NULL; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM, NULL, record->EventID, MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), (wchar_t*)&errorMess, 0, NULL); QString tmp; tmp = QString::fromStdWString(eventName[nameIndex]) + " " + QString::fromStdWString(sourceName) + ": " + QString::number((int)record->EventID); result << tmp; /* if(errorMess == NULL) { errorMess = L"No description"; } //---------------------------------- std::wcout << " Event ID: " << record->EventID << " EventType: " << eventName[nameIndex] << " Source: " << sourceName << std::endl << "Description: " << errorMess << std::endl << std::endl; std::wfstream file("report.txt", std::ios_base::out | std::ios_base::app); file << " Event ID: " << record->EventID << " EventType: " << eventName[nameIndex] << " Source: " << sourceName << std::endl << "Description: " << errorMess << std::endl << std::endl; */ LocalFree((void*)errorMess); }
DMDatei::DMDatei (const IDMItem::Handle &h) : IDMItem (h) { if ( object () ) { setTypes (IDM::plainText); // sollte aus EA ermitteln addType ("Datei"); enableLink (); enableMove (); enableCopy (); setRMFs (rmfFrom (IDM::rmFile, IDM::rfText)); addRMF (IDM::rmDiscard, IDM::rfUnknown); addRMF (IDM::rmPrint, IDM::rfUnknown); Datei *d = (Datei *)object (); setSourceName (d->iconText ()); setContainerName (Struktur::aktiv ()->path ()); setTargetName (sourceName ()); } }
/** * Get all sources which are linked to the workspace which is to be deleted. The * workspace * can be a rebinned workspace or an unrebinned workspace. * @param workspaceName The workspace name associated with the source. * @returns a list with all tracked (true sources) which are associated with the * workspace */ std::vector<pqPipelineSource *> RebinnedSourcesManager::findAllRebinnedSourcesForWorkspace( std::string workspaceName) { std::vector<std::string> linkedSources; // We need to iterate over the map for (std::map<std::pair<std::string, std::string>, std::string>::const_iterator it = m_rebinnedWorkspaceAndSourceToOriginalWorkspace.begin(); it != m_rebinnedWorkspaceAndSourceToOriginalWorkspace.begin(); ++it) { // Check the first part of the key and the value ofthe map std::string rebinnedWorkspaceName = it->first.first; std::string originalWorkspaceName = it->second; if (workspaceName == rebinnedWorkspaceName || workspaceName == originalWorkspaceName) { linkedSources.push_back(it->first.second); } } // Now that we have the sources it is time to get them from the ParaView // server std::vector<pqPipelineSource *> sourcesToBeDeleted; pqServer *server = pqActiveObjects::instance().activeServer(); pqServerManagerModel *smModel = pqApplicationCore::instance()->getServerManagerModel(); const QList<pqPipelineSource *> sources = smModel->findItems<pqPipelineSource *>(server); foreach (pqPipelineSource *source, sources) { pqPipelineFilter *filter = qobject_cast<pqPipelineFilter *>(source); if (!filter) { std::string sourceName(source->getProxy()->GetGlobalIDAsString()); if (doesSourceNeedToBeDeleted(sourceName, linkedSources)) { sourcesToBeDeleted.push_back(source); } } }
/** * Get workspace name and type * @param source The pipeline source. * @param workspaceName Reference to workspace name. * @param workspaceType Reference to workspace type. */ void RebinnedSourcesManager::getWorkspaceInfo(pqPipelineSource *source, std::string &workspaceName, std::string &workspaceType) { // Make sure that the input source exists. Note that this can happen when // there is no active view if (!source) { return; } // Update the source/filter vtkSMProxy *proxy = source->getProxy(); proxy->UpdateVTKObjects(); proxy->UpdatePropertyInformation(); source->updatePipeline(); // Crawl up to the source level pqPipelineFilter *filter = qobject_cast<pqPipelineFilter *>(source); while (filter) { source = filter->getInput(0); filter = qobject_cast<pqPipelineFilter *>(source); } // Ensure that the source is either an MDEvent source or an MDHisto source std::string sourceName(source->getProxy()->GetXMLName()); if (sourceName.find("MDEW Source") == std::string::npos && sourceName.find("MDHW Source") == std::string::npos) { return; } // Check if the source has an underlying event workspace or histo workspace workspaceName = vtkSMPropertyHelper(source->getProxy(), "WorkspaceName", true) .GetAsString(); workspaceType = vtkSMPropertyHelper(source->getProxy(), "WorkspaceTypeName", true).GetAsString(); }
/* slave: pull some data from the master's oplog note: not yet in db mutex at this point. @return -1 error 0 ok, don't sleep 1 ok, sleep */ int ReplSource::sync_pullOpLog(int& nApplied) { int okResultCode = 1; string ns = string("local.oplog.$") + sourceName(); log(2) << "repl: sync_pullOpLog " << ns << " syncedTo:" << syncedTo.toStringLong() << '\n'; bool tailing = true; oplogReader.tailCheck(); bool initial = syncedTo.isNull(); if ( !oplogReader.haveCursor() || initial ) { if ( initial ) { // Important to grab last oplog timestamp before listing databases. syncToTailOfRemoteLog(); BSONObj info; bool ok = oplogReader.conn()->runCommand( "admin", BSON( "listDatabases" << 1 ), info ); massert( 10389 , "Unable to get database list", ok ); BSONObjIterator i( info.getField( "databases" ).embeddedObject() ); while( i.moreWithEOO() ) { BSONElement e = i.next(); if ( e.eoo() ) break; string name = e.embeddedObject().getField( "name" ).valuestr(); if ( !e.embeddedObject().getBoolField( "empty" ) ) { if ( name != "local" ) { if ( only.empty() || only == name ) { log( 2 ) << "adding to 'addDbNextPass': "******"$gte", syncedTo.asDate()); BSONObjBuilder query; query.append("ts", q.done()); if ( !only.empty() ) { // note we may here skip a LOT of data table scanning, a lot of work for the master. query.appendRegex("ns", string("^") + only); // maybe append "\\." here? } BSONObj queryObj = query.done(); // e.g. queryObj = { ts: { $gte: syncedTo } } oplogReader.tailingQuery(ns.c_str(), queryObj); tailing = false; } else { log(2) << "repl: tailing=true\n"; } if( !oplogReader.haveCursor() ) { problem() << "repl: dbclient::query returns null (conn closed?)" << endl; oplogReader.resetConnection(); return -1; } // show any deferred database creates from a previous pass { set<string>::iterator i = addDbNextPass.begin(); if ( i != addDbNextPass.end() ) { BSONObjBuilder b; b.append("ns", *i + '.'); b.append("op", "db"); BSONObj op = b.done(); sync_pullOpLog_applyOperation(op, false); } } if ( !oplogReader.more() ) { if ( tailing ) { log(2) << "repl: tailing & no new activity\n"; if( oplogReader.awaitCapable() ) okResultCode = 0; // don't sleep } else { log() << "repl: " << ns << " oplog is empty\n"; } { dblock lk; save(); } return okResultCode; } OpTime nextOpTime; { BSONObj op = oplogReader.next(); BSONElement ts = op.getField("ts"); if ( ts.type() != Date && ts.type() != Timestamp ) { string err = op.getStringField("$err"); if ( !err.empty() ) { // 13051 is "tailable cursor requested on non capped collection" if (op.getIntField("code") == 13051) { problem() << "trying to slave off of a non-master" << '\n'; massert( 13344 , "trying to slave off of a non-master", false ); } else { problem() << "repl: $err reading remote oplog: " + err << '\n'; massert( 10390 , "got $err reading remote oplog", false ); } } else { problem() << "repl: bad object read from remote oplog: " << op.toString() << '\n'; massert( 10391 , "repl: bad object read from remote oplog", false); } } nextOpTime = OpTime( ts.date() ); log(2) << "repl: first op time received: " << nextOpTime.toString() << '\n'; if ( initial ) { log(1) << "repl: initial run\n"; } if( tailing ) { if( !( syncedTo < nextOpTime ) ) { log() << "repl ASSERTION failed : syncedTo < nextOpTime" << endl; log() << "repl syncTo: " << syncedTo.toStringLong() << endl; log() << "repl nextOpTime: " << nextOpTime.toStringLong() << endl; assert(false); } oplogReader.putBack( op ); // op will be processed in the loop below nextOpTime = OpTime(); // will reread the op below } else if ( nextOpTime != syncedTo ) { // didn't get what we queried for - error Nullstream& l = log(); l << "repl: nextOpTime " << nextOpTime.toStringLong() << ' '; if ( nextOpTime < syncedTo ) l << "<??"; else l << ">"; l << " syncedTo " << syncedTo.toStringLong() << '\n'; log() << "repl: time diff: " << (nextOpTime.getSecs() - syncedTo.getSecs()) << "sec\n"; log() << "repl: tailing: " << tailing << '\n'; log() << "repl: data too stale, halting replication" << endl; replInfo = replAllDead = "data too stale halted replication"; assert( syncedTo < nextOpTime ); throw SyncException(); } else { /* t == syncedTo, so the first op was applied previously or it is the first op of initial query and need not be applied. */ } } // apply operations { int n = 0; time_t saveLast = time(0); while ( 1 ) { bool moreInitialSyncsPending = !addDbNextPass.empty() && n; // we need "&& n" to assure we actually process at least one op to get a sync point recorded in the first place. if ( moreInitialSyncsPending || !oplogReader.more() ) { dblock lk; // NOTE aaron 2011-03-29 This block may be unnecessary, but I'm leaving it in place to avoid changing timing behavior. { dbtemprelease t; if ( !moreInitialSyncsPending && oplogReader.more() ) { continue; } // otherwise, break out of loop so we can set to completed or clone more dbs } if( oplogReader.awaitCapable() && tailing ) okResultCode = 0; // don't sleep syncedTo = nextOpTime; save(); // note how far we are synced up to now log() << "repl: applied " << n << " operations" << endl; nApplied = n; log() << "repl: end sync_pullOpLog syncedTo: " << syncedTo.toStringLong() << endl; break; } else { } OCCASIONALLY if( n > 0 && ( n > 100000 || time(0) - saveLast > 60 ) ) { // periodically note our progress, in case we are doing a lot of work and crash dblock lk; syncedTo = nextOpTime; // can't update local log ts since there are pending operations from our peer save(); log() << "repl: checkpoint applied " << n << " operations" << endl; log() << "repl: syncedTo: " << syncedTo.toStringLong() << endl; saveLast = time(0); n = 0; } BSONObj op = oplogReader.next(); unsigned b = replApplyBatchSize; bool justOne = b == 1; scoped_ptr<writelock> lk( justOne ? 0 : new writelock() ); while( 1 ) { BSONElement ts = op.getField("ts"); if( !( ts.type() == Date || ts.type() == Timestamp ) ) { log() << "sync error: problem querying remote oplog record" << endl; log() << "op: " << op.toString() << endl; log() << "halting replication" << endl; replInfo = replAllDead = "sync error: no ts found querying remote oplog record"; throw SyncException(); } OpTime last = nextOpTime; nextOpTime = OpTime( ts.date() ); if ( !( last < nextOpTime ) ) { log() << "sync error: last applied optime at slave >= nextOpTime from master" << endl; log() << " last: " << last.toStringLong() << endl; log() << " nextOpTime: " << nextOpTime.toStringLong() << endl; log() << " halting replication" << endl; replInfo = replAllDead = "sync error last >= nextOpTime"; uassert( 10123 , "replication error last applied optime at slave >= nextOpTime from master", false); } if ( replSettings.slavedelay && ( unsigned( time( 0 ) ) < nextOpTime.getSecs() + replSettings.slavedelay ) ) { assert( justOne ); oplogReader.putBack( op ); _sleepAdviceTime = nextOpTime.getSecs() + replSettings.slavedelay + 1; dblock lk; if ( n > 0 ) { syncedTo = last; save(); } log() << "repl: applied " << n << " operations" << endl; log() << "repl: syncedTo: " << syncedTo.toStringLong() << endl; log() << "waiting until: " << _sleepAdviceTime << " to continue" << endl; return okResultCode; } sync_pullOpLog_applyOperation(op, !justOne); n++; if( --b == 0 ) break; // if to here, we are doing mulpile applications in a singel write lock acquisition if( !oplogReader.moreInCurrentBatch() ) { // break if no more in batch so we release lock while reading from the master break; } op = oplogReader.next(); getDur().commitIfNeeded(); } } } return okResultCode; }
void NotificationWindow::MessageReceived(BMessage* message) { switch (message->what) { case B_NODE_MONITOR: { _LoadSettings(); break; } case kNotificationMessage: { if (!fShouldRun) break; BMessage reply(B_REPLY); BNotification* notification = new BNotification(message); if (notification->InitCheck() == B_OK) { bigtime_t timeout; if (message->FindInt64("timeout", &timeout) != B_OK) timeout = fTimeout; BString sourceSignature(notification->SourceSignature()); BString sourceName(notification->SourceName()); bool allow = false; appfilter_t::iterator it = fAppFilters .find(sourceSignature.String()); AppUsage* appUsage = NULL; if (it == fAppFilters.end()) { if (sourceSignature.Length() > 0 && sourceName.Length() > 0) { appUsage = new AppUsage(sourceName.String(), sourceSignature.String(), true); fAppFilters[sourceSignature.String()] = appUsage; // TODO save back to settings file } allow = true; } else { appUsage = it->second; allow = appUsage->Allowed(); } if (allow) { BString groupName(notification->Group()); appview_t::iterator aIt = fAppViews.find(groupName); AppGroupView* group = NULL; if (aIt == fAppViews.end()) { group = new AppGroupView(this, groupName == "" ? NULL : groupName.String()); fAppViews[groupName] = group; GetLayout()->AddView(group); } else group = aIt->second; NotificationView* view = new NotificationView(notification, timeout, fIconSize); group->AddInfo(view); _ShowHide(); reply.AddInt32("error", B_OK); } else reply.AddInt32("error", B_NOT_ALLOWED); } else { reply.what = B_MESSAGE_NOT_UNDERSTOOD; reply.AddInt32("error", B_ERROR); } message->SendReply(&reply); break; } case kRemoveGroupView: { AppGroupView* view = NULL; if (message->FindPointer("view", (void**)&view) != B_OK) return; // It's possible that between sending this message, and us receiving // it, the view has become used again, in which case we shouldn't // delete it. if (view->HasChildren()) return; // this shouldn't happen if (fAppViews.erase(view->Group()) < 1) break; view->RemoveSelf(); delete view; _ShowHide(); break; } default: BWindow::MessageReceived(message); } }
void SimplePipeReader::run() { if(debug) std::cout << "SimplePipeReader: start()" << std::endl; bool closing=false; QByteArray charList; // int counter = 0; while ( !closing ) { usleep(1000); QString line = input_line->readLine (); // std::cout << "SimplePipeReader: read " << line.size() << " chars" << std::endl; if ( line.isEmpty() ) continue; else if ( line.startsWith ( "#QUIT" ) ) { if(debug) std::cout << "SimplePipeReader: have seen #QUIT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; closing = true; break; } else if ( line.startsWith ( "#RESET" ) ) { if(debug) std::cout << "SimplePipeReader: have seen #RESET **************************" << std::endl; } else if ( line.startsWith ( "#V" ) ) { // video recording -> capture frames if(!noVideo){ QStringList pieces = line.split(" "); if(pieces.length()<3) { std::cout << "got" << line.toStdString() << ", but missing parameters expect \"#V idx directory\"" << std::endl; }else{ long int cnt=pieces.at(1).toLong(); emit captureFrame(cnt, pieces.at(2)); waitUntilGo(); // wait for gui thread } } } else if ( line.startsWith ( "#IN" ) ) { // Name emit sourceName(line.mid(4)); } if (debug) std::cout << "currDatalin: " << (currentDataLine.section(' ', 0, 0)).toDouble(); if (debug) std::cout << "oldline: " << (line.section(' ', 0, 0)).toDouble() << std::endl; if ( line.startsWith ( "#C" ) ) { //cut the first 2 chars (#C) line = line.mid ( 3 ); currentChannelLine = line; // std::cout << "SimplePipeReader currentChannelLine: [" << currentChannelLine.toStdString() << "]" << std::endl; } else if ( line.startsWith ( "#" ) ) { continue; } else if ( (currentChannelLine.size() > 2) && (line.section(' ', 0, 0) != currentDataLine.section(' ', 0, 0))) { while(waitForGui){ msleep(100); } currentDataLine = line; emit newData(); //wenn timestamp geändert (erstes element) } // if ( line.startsWith ( "#D" ) ) { // //cut the first 2 chars (#C) // line = line.mid ( 3 ); // currentDescriptionLine = line; //// printf("SimplePipeReader currentDescriptionLine: [%s]\r\n",currentDescriptionLine.toStdString().c_str()); // } } if(debug) std::cout << "SimplePipeReader SIGNAL(finished())" << std::endl; emit(finished()); }
static Source * sourceAlloc(Fs *fs, Block *b, Source *p, uint32_t offset, int mode, int issnapshot) { int epb; uint32_t epoch; char *pname = nil; Source *r; Entry e; assert(p==nil || sourceIsLocked(p)); if(p == nil) { assert(offset == 0); epb = 1; } else epb = p->dsize / VtEntrySize; if(b->l.type != BtDir) goto Bad; /* * a non-active entry is the only thing that * can legitimately happen here. all the others * get prints. */ if(!entryUnpack(&e, b->data, offset % epb)) { pname = sourceName(p); consPrint("%s: %s %V: sourceAlloc: entryUnpack failed\n", fs->name, pname, b->score); goto Bad; } if(!(e.flags & VtEntryActive)) { pname = sourceName(p); if(0) consPrint("%s: %s %V: sourceAlloc: not active\n", fs->name, pname, e.score); goto Bad; } if(e.psize < 256 || e.dsize < 256) { pname = sourceName(p); consPrint("%s: %s %V: sourceAlloc: psize %ud or dsize %ud < 256\n", fs->name, pname, e.score, e.psize, e.dsize); goto Bad; } if(e.depth < sizeToDepth(e.size, e.psize, e.dsize)) { pname = sourceName(p); consPrint("%s: %s %V: sourceAlloc: depth %ud size %llud " "psize %ud dsize %ud\n", fs->name, pname, e.score, e.depth, e.size, e.psize, e.dsize); goto Bad; } if((e.flags & VtEntryLocal) && e.tag == 0) { pname = sourceName(p); consPrint("%s: %s %V: sourceAlloc: flags %#ux tag %#ux\n", fs->name, pname, e.score, e.flags, e.tag); goto Bad; } if(e.dsize > fs->blockSize || e.psize > fs->blockSize) { pname = sourceName(p); consPrint("%s: %s %V: sourceAlloc: psize %ud or dsize %ud " "> blocksize %ud\n", fs->name, pname, e.score, e.psize, e.dsize, fs->blockSize); goto Bad; } epoch = b->l.epoch; if(mode == OReadWrite) { if(e.snap != 0) { vtSetError(ESnapRO); return nil; } } else if(e.snap != 0) { if(e.snap < fs->elo) { vtSetError(ESnapOld); return nil; } if(e.snap >= fs->ehi) goto Bad; epoch = e.snap; } r = vtMemAllocZ(sizeof(Source)); r->fs = fs; r->mode = mode; r->issnapshot = issnapshot; r->dsize = e.dsize; r->gen = e.gen; r->dir = (e.flags & VtEntryDir) != 0; r->lk = vtLockAlloc(); r->ref = 1; r->parent = p; if(p) { vtLock(p->lk); assert(mode == OReadOnly || p->mode == OReadWrite); p->ref++; vtUnlock(p->lk); } r->epoch = epoch; // consPrint("sourceAlloc: have %V be.%d fse.%d %s\n", b->score, // b->l.epoch, r->fs->ehi, mode == OReadWrite? "rw": "ro"); memmove(r->score, b->score, VtScoreSize); r->scoreEpoch = b->l.epoch; r->offset = offset; r->epb = epb; r->tag = b->l.tag; // consPrint("%s: sourceAlloc: %p -> %V %d\n", r, r->score, r->offset); return r; Bad: free(pname); vtSetError(EBadEntry); return nil; }