/* Get specific file info's, batch the files so update when we have 100 items and every 200ms after that */ void RemoteFileInfoGatherer::getFileInfos(const QString &path, const QStringList &files) { // List drives if (path.isEmpty()) { #ifdef QT_BUILD_INTERNAL fetchedRoot.store(true); #endif QFileInfoList infoList; if (files.isEmpty()) { infoList = QDir::drives(); } else { infoList.reserve(files.count()); for (const auto &file : files) infoList << QFileInfo(file); } for (int i = infoList.count() - 1; i >= 0; --i) { QString driveName = translateDriveName(infoList.at(i)); QVector<QPair<QString,FileInfo> > updatedFiles; updatedFiles.append(QPair<QString,FileInfo>(driveName, toFileInfo(infoList.at(i)))); emit updates(path, updatedFiles); } return; } QElapsedTimer base; base.start(); QFileInfo fileInfo; bool firstTime = true; QVector<QPair<QString, FileInfo> > updatedFiles; QStringList filesToCheck = files; QStringList allFiles; if (files.isEmpty()) { QDirIterator dirIt(path, QDir::AllEntries | QDir::System | QDir::Hidden); while (!abort.load() && dirIt.hasNext()) { dirIt.next(); fileInfo = dirIt.fileInfo(); allFiles.append(fileInfo.fileName()); fetch(fileInfo, base, firstTime, updatedFiles, path); } } if (!allFiles.isEmpty()) emit newListOfFiles(path, allFiles); QStringList::const_iterator filesIt = filesToCheck.constBegin(); while (!abort.load() && filesIt != filesToCheck.constEnd()) { fileInfo.setFile(path + QDir::separator() + *filesIt); ++filesIt; fetch(fileInfo, base, firstTime, updatedFiles, path); } if (!updatedFiles.isEmpty()) emit updates(path, updatedFiles); emit directoryLoaded(path); }
void Application::updateGotCurrent() { if (!updateReply || updateThread) return; cSetLastUpdateCheck(unixtime()); QRegularExpressionMatch m = QRegularExpression(qsl("^\\s*(\\d+)\\s*:\\s*([\\x21-\\x7f]+)\\s*$")).match(QString::fromUtf8(updateReply->readAll())); if (m.hasMatch()) { int32 currentVersion = m.captured(1).toInt(); if (currentVersion > AppVersion) { updateThread = new QThread(); connect(updateThread, SIGNAL(finished()), updateThread, SLOT(deleteLater())); updateDownloader = new PsUpdateDownloader(updateThread, m.captured(2)); updateThread->start(); } } if (updateReply) updateReply->deleteLater(); updateReply = 0; if (!updateThread) { QDir updates(cWorkingDir() + "tupdates"); if (updates.exists()) { QFileInfoList list = updates.entryInfoList(QDir::Files); for (QFileInfoList::iterator i = list.begin(), e = list.end(); i != e; ++i) { if (QRegularExpression("^(tupdate|tmacupd|tlinuxupd|tlinux32upd)\\d+$", QRegularExpression::CaseInsensitiveOption).match(i->fileName()).hasMatch()) { QFile(i->absoluteFilePath()).remove(); } } } emit updateLatest(); } startUpdateCheck(true); App::writeConfig(); }
void FeatureCompatibilityVersion::_runUpdateCommand(OperationContext* opCtx, UpdateBuilder builder) { DBDirectClient client(opCtx); NamespaceString nss(NamespaceString::kServerConfigurationNamespace); BSONObjBuilder updateCmd; updateCmd.append("update", nss.coll()); { BSONArrayBuilder updates(updateCmd.subarrayStart("updates")); { BSONObjBuilder updateSpec(updates.subobjStart()); { BSONObjBuilder queryFilter(updateSpec.subobjStart("q")); queryFilter.append("_id", FeatureCompatibilityVersionParser::kParameterName); } { BSONObjBuilder updateMods(updateSpec.subobjStart("u")); builder(std::move(updateMods)); } updateSpec.appendBool("upsert", true); } } updateCmd.append(WriteConcernOptions::kWriteConcernField, WriteConcernOptions::Majority); // Update the featureCompatibilityVersion document stored in the server configuration // collection. BSONObj updateResult; client.runCommand(nss.db().toString(), updateCmd.obj(), updateResult); uassertStatusOK(getStatusFromWriteCommandReply(updateResult)); }
void Session::workUpdates(InboundPkt &inboundPkt, qint64 msgId) { qCDebug(TG_CORE_SESSION) << "workUpdates: msgId =" << QString::number(msgId, 16); mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_Updates); //updates mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_Vector); qint32 n = inboundPkt.fetchInt(); QList<Update> updatesList; for (qint32 i = 0; i < n; i++) { updatesList.append(inboundPkt.fetchUpdate()); } //users mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_Vector); n = inboundPkt.fetchInt(); QList<User> users; for (qint32 i = 0; i < n; i++) { users.append(inboundPkt.fetchUser()); } //chats mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_Vector); n = inboundPkt.fetchInt(); QList<Chat> chats; for (qint32 i = 0; i < n; i++) { chats.append(inboundPkt.fetchChat()); } qint32 date = inboundPkt.fetchInt(); qint32 seq = inboundPkt.fetchInt(); Q_EMIT updates(updatesList, users, chats, date, seq); }
void Application::startUpdateCheck(bool forceWait) { updateCheckTimer.stop(); if (updateRequestId || updateThread || updateReply || !cAutoUpdate()) return; int32 updateInSecs = cLastUpdateCheck() + 3600 + (rand() % 3600) - unixtime(); bool sendRequest = (updateInSecs <= 0 || updateInSecs > 7200); if (!sendRequest && !forceWait) { QDir updates(cWorkingDir() + "tupdates"); if (updates.exists()) { QFileInfoList list = updates.entryInfoList(QDir::Files); for (QFileInfoList::iterator i = list.begin(), e = list.end(); i != e; ++i) { if (QRegularExpression("^(tupdate|tmacupd|tlinuxupd|tlinux32upd)\\d+$", QRegularExpression::CaseInsensitiveOption).match(i->fileName()).hasMatch()) { sendRequest = true; } } } } if (cManyInstance() && !cDebug()) return; // only main instance is updating if (sendRequest) { QNetworkRequest checkVersion(cUpdateURL()); if (updateReply) updateReply->deleteLater(); App::setProxySettings(updateManager); updateReply = updateManager.get(checkVersion); connect(updateReply, SIGNAL(finished()), this, SLOT(updateGotCurrent())); connect(updateReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(updateFailedCurrent(QNetworkReply::NetworkError))); // updateRequestId = MTP::send(MTPhelp_GetAppUpdate(MTP_string(cApiDeviceModel()), MTP_string(cApiSystemVersion()), MTP_string(cApiAppVersion()), MTP_string(cApiLang())), rpcDone(&Application::onAppUpdate), rpcFail(&Application::onAppUpdateFail); emit updateChecking(); } else { updateCheckTimer.start((updateInSecs + 5) * 1000); } }
int main(int argc, char **argv) { Aria::init(); ArClientBase client; ArArgumentParser parser(&argc, argv); /* This will be used to connect our client to the server. * It will get the hostname from the -host command line argument: */ ArClientSimpleConnector clientConnector(&parser); parser.loadDefaultArguments(); /* Check for -host, -help, ARIA arguments, and unhandled arguments: */ if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed()) { Aria::logOptions(); Aria::exit(0); } /* Connect our client object to the remote server: */ if (!clientConnector.connectClient(&client)) { if (client.wasRejected()) printf("Server '%s' rejected connection, exiting\n", client.getHost()); else printf("Could not connect to server '%s', exiting\n", client.getHost()); Aria::exit(1); } printf("Connected to server.\n"); client.setRobotName(client.getHost()); // include server name in log messages client.runAsync(); ArClientHandlerRobotUpdate updates(&client); updates.requestUpdates(); while (client.getRunningWithLock()) { updates.lock(); printf("Mode:%s Status:%s Pos:%.0f,%.0f,%.0f Vel:%.0f,%.0f,%.0f Bat:%.1f \r", updates.getMode(), updates.getStatus(), updates.getX(), updates.getY(), updates.getTh(), updates.getVel(), updates.getLatVel(), updates.getRotVel(), updates.getVoltage() ); updates.unlock(); ArUtil::sleep(1000); } /* The client stopped running, due to disconnection from the server, general * Aria shutdown, or some other reason. */ client.disconnect(); Aria::exit(0); return 0; }
void RemoteFileInfoGatherer::fetch(const QFileInfo &fileInfo, QElapsedTimer &base, bool &firstTime, QVector<QPair<QString, FileInfo> > &updatedFiles, const QString &path) { updatedFiles.append(QPair<QString, FileInfo>(fileInfo.fileName(), toFileInfo(fileInfo))); QElapsedTimer current; current.start(); if ((firstTime && updatedFiles.count() > 100) || base.msecsTo(current) > 1000) { emit updates(path, updatedFiles); updatedFiles.clear(); base = current; firstTime = false; } }
spl::spl(QWidget *parent) : QWidget(parent) { ql=new QLabel("<img src='D:/splashscreen-portrait2.jpg'/ >",this); ql->setFixedSize(360,640); qt1=new QTimer(this); qt1->start(); QTimer::singleShot(3000, this, SLOT(updates())); }
int main ( int argc , char** argv ) { double start, end; // get cmdline args std::string input_file = argv[1]; std::string output_file = argv[2]; int num_steps = atoi( argv[3] ); // check for valid input file if ( !utils::fexists( input_file ) ) { printf( "Error: Input file does not exist.\n" ); return 1; } // initialize adjacency list vector hash printf( "Loading network edges from %s\n", input_file.c_str() ); start = omp_get_wtime(); load_network( input_file ); end = omp_get_wtime(); printf( "Time to read input file = %lf seconds\n", end - start ); // compute the normalized credit after numSteps printf("\nComputing the Credit Values for %d Rounds:\n", num_steps); CreditVec C( nodevec.size(), 1 ); // initialize credit at t=0 to 1 for each node CreditVec C_( nodevec.size(), 0 ); std::vector<CreditVec> updates( num_steps ); for (int i=0; i<num_steps; ++i) { printf("round %d = ", i+1); start = omp_get_wtime(); credit_update(C, C_); end = omp_get_wtime(); printf( "%f seconds\n", end - start ); // store credit update before overwriting timestep t updates[i] = C_; C = C_; // C(t+1) becomes C(t) for next iteration } // output credit value results after the final step printf( "\nOutputting Network and Random Walk Data to %s\n", output_file.c_str() ); write_output( output_file, updates ); // free heap memory for ( auto& node: nodevec ) { delete node; } return 0 ; }
int QFileInfoGatherer::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QThread::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: updates((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QList<QPair<QString,QFileInfo> >(*)>(_a[2]))); break; case 1: newListOfFiles((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QStringList(*)>(_a[2]))); break; case 2: nameResolved((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break; case 3: list((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 4: fetchExtendedInformation((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QStringList(*)>(_a[2]))); break; case 5: updateFile((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 6: setResolveSymlinks((*reinterpret_cast< bool(*)>(_a[1]))); break; case 7: { bool _r = resolveSymlinks(); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 8: setIconProvider((*reinterpret_cast< QFileIconProvider*(*)>(_a[1]))); break; case 9: { QFileIconProvider* _r = iconProvider(); if (_a[0]) *reinterpret_cast< QFileIconProvider**>(_a[0]) = _r; } break; } _id -= 10; } return _id; }
RcppExport SEXP doAI_REML(SEXP curTheta_, SEXP curK_, SEXP y_, SEXP X_, SEXP yy_, SEXP Xy_, SEXP XX_, SEXP phi_, SEXP phiInv_, SEXP trphiInv_, SEXP S_, SEXP q_, SEXP itrmax_, SEXP threshold_){ double curTheta = Rcpp::as<double>(curTheta_); double curK = Rcpp::as<double>(curK_); arma::colvec y = Rcpp::as<arma::colvec>(y_); arma::mat X = Rcpp::as<arma::mat>(X_); double yy = Rcpp::as<double>(yy_); arma::colvec Xy = Rcpp::as<arma::colvec>(Xy_); arma::mat XX = Rcpp::as<arma::mat>(XX_); arma::mat phi = Rcpp::as<arma::mat>(phi_); arma::mat phiInv = Rcpp::as<arma::mat>(phiInv_); double trphiInv = Rcpp::as<double>(trphiInv_); int S = Rcpp::as<int>(S_); int q = Rcpp::as<int>(q_); int itrmax = Rcpp::as<int>(itrmax_); double threshold = Rcpp::as<double>(threshold_); arma::mat czz; arma::mat czzInv; double yVIy; arma::colvec XVIy; arma::mat XVIX; arma::mat XVIXInv; double yPy; arma::colvec Py; arma::mat Q; arma::mat QQ; arma::mat QX; arma::mat QVIQ; arma::mat QVIX; arma::mat QPQ; double Utheta; arma::mat c22; double UK; arma::colvec updates(2); arma::colvec tmp1(2); arma::colvec tmp2(2); arma::mat tX = arma::trans(X); arma::mat tQ; double logL; arma::colvec blue; arma::colvec predicted; arma::colvec blup; arma::mat I = arma::eye<arma::mat>(S, S); double val1, val2, sign; double curK2; arma::vec res(2); int itr = 1; while(1){ curK2 = pow(curK,2); czz = 1 / curK * I + phiInv; czzInv = arma::inv(czz); XVIy = Xy / curK - tX * czzInv * y / curK2; XVIX = XX / curK - tX * czzInv * X / curK2; XVIXInv = arma::inv(XVIX); blue = XVIXInv * XVIy; predicted = X * blue; blup = czzInv * (y / curK - predicted / curK); Py = ( y - predicted - blup ) / curK; Q = (y - predicted) / curTheta; Q.insert_rows(Q.n_elem, Py); Q.reshape(S, Q.n_elem / S); tQ = arma::trans(Q); QQ = tQ * Q; QX = tQ * X; QVIQ = QQ / curK - tQ * czzInv * Q / curK2; QVIX = QX / curK - tQ * czzInv * X / curK2; QPQ = QVIQ - QVIX * XVIXInv * arma::trans(QVIX); Utheta = - 0.5 * ( (S-q) / curTheta - QPQ(0, 0) ); c22 = czzInv + czzInv * X * XVIXInv * tX * czzInv / curK2; UK = -0.5 * ( trphiInv - arma::sum( arma::diagvec( phiInv * c22 * phiInv ) ) - arma::as_scalar( arma::trans(Py) * Py ) / curTheta ); tmp1[0] = curTheta; tmp1[1] = curK; tmp2[0] = Utheta; tmp2[1] = UK; updates = tmp1 + 2 * arma::vec( curTheta * arma::inv(QPQ) * tmp2 ); if(updates[0] <=0 || updates[1] <= 0){ Rprintf("Negative definite and EM is applied"); updates[0] = QPQ(0,0) * pow(curTheta,2) / (S-q); updates[1] = curK - (trphiInv - arma::sum( arma::diagvec( phiInv * c22 * phiInv ) ) ) * curK2 / S + arma::sum( arma::pow( y - predicted - blup, 2) ) / curTheta / S; } if(sqrt( arma::sum( arma::pow(updates - tmp1, 2) ) ) < threshold ){ curTheta = updates[0]; curK = updates[1]; czz = 1/curK * I + phiInv; czzInv = arma::inv(czz); yVIy = yy / curK - arma::as_scalar( arma::trans(y) * czzInv * y ) / curK2; XVIy = Xy / curK - tX * czzInv * y / curK2; XVIX = XX / curK - tX * czzInv * X / curK2; XVIXInv = arma::inv(XVIX); //yPy = yVIy - arma::scalar( arma::trans(XVIy) * XVIXInv * XVIy ); arma::log_det(val1, sign, XVIX); arma::log_det(val2, sign, phi + I * curK); logL = -0.5 * ( val1 + val2 + (S - q) * log( curTheta ) + QPQ(0, 0) * curTheta ); blue = XVIXInv * XVIy; predicted = X * blue; blup = czzInv * (y / curK - predicted / curK); return Rcpp::List::create(Rcpp::Named("para",blue), Rcpp::Named("sig2g",curTheta), Rcpp::Named("sig2", curK*curTheta), Rcpp::Named("logL", logL) ); } else{ //Rprintf("itr: %d, sig2: %f, sig2g, %f \n", itr, updates[0] * updates[1], updates[0]); curTheta = updates[0]; curK = updates[1]; } if(itr > itrmax){ Rprintf("It does not converge!!!"); return Rcpp::wrap(NA_REAL); } itr++; } }
void * vncDesktopThread::run_undetached(void *arg) { //******************************************************* // INIT //******************************************************* capture=true; vnclog.Print(LL_INTERR, VNCLOG("Hook changed 1\n")); // Save the thread's "home" desktop, under NT (no effect under 9x) m_desktop->m_home_desktop = GetThreadDesktop(GetCurrentThreadId()); vnclog.Print(LL_INTERR, VNCLOG("Hook changed 2\n")); // Attempt to initialise and return success or failure m_desktop->KillScreenSaver(); { keybd_event(VK_CONTROL, 0, 0, 0); keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0); Sleep(500); //Give screen some time to kill screensaver } DWORD startup_error; if ((startup_error = m_desktop->Startup()) != 0) { //TAG14 vncService::SelectHDESK(m_desktop->m_home_desktop); if (m_desktop->m_input_desktop) CloseDesktop(m_desktop->m_input_desktop); ReturnVal(startup_error); return NULL; } // Succeeded to initialise ok ReturnVal(0); // sf@2003 - Done here to take into account if the driver is actually activated m_desktop->InitHookSettings(); // We set a flag inside the desktop handler here, to indicate it's now safe // to handle clipboard messages m_desktop->SetClipboardActive(TRUE); // All changes in the state of the display are stored in a local // UpdateTracker object, and are flushed to the vncServer whenever // client updates are about to be triggered rfb::SimpleUpdateTracker clipped_updates; rfb::ClippedUpdateTracker updates(clipped_updates, m_desktop->m_Cliprect); clipped_updates.enable_copyrect(true); rfb::Region2D rgncache; // Incoming update messages are collated into a single region cache // The region cache areas are checked for changes before an update // is triggered, and the changed areas are passed to the UpdateTracker rgncache = m_desktop->m_Cliprect; m_server->SetScreenOffset(m_desktop->m_ScreenOffsetx,m_desktop->m_ScreenOffsety,m_desktop->nr_monitors); // The previous cursor position is stored, to allow us to erase the // old instance whenever it moves. rfb::Point oldcursorpos; // The driver gives smaller rectangles to check // if Accuracy is 4 you eliminate pointer updates if (m_desktop->VideoBuffer() && m_desktop->m_hookdriver) m_desktop->m_buffer.SetAccuracy(4); //init vars m_desktop->m_SWSizeChanged=FALSE; m_desktop->m_SWtoDesktop=FALSE; m_desktop->m_SWmoved=FALSE; m_desktop->Hookdll_Changed = true; m_desktop->m_displaychanged=false; m_desktop->m_hookswitch=false; m_desktop->m_hookinited = FALSE; // Set driver cursor state XRichCursorEnabled= (FALSE != m_desktop->m_server->IsXRichCursorEnabled()); if (!XRichCursorEnabled && m_desktop->m_videodriver) m_desktop->m_videodriver->HardwareCursor(); if (XRichCursorEnabled && m_desktop->m_videodriver) m_desktop->m_videodriver->NoHardwareCursor(); if (XRichCursorEnabled) m_server->UpdateCursorShape(); InvalidateRect(NULL,NULL,TRUE); oldtick=timeGetTime(); int fullpollcounter=0; //******************************************************* // END INIT //******************************************************* // START PROCESSING DESKTOP MESSAGES ///////////////////// HANDLE threadHandle=NULL; stop_hookwatch=false; ///////////////////// // We use a dynmiac value based on cpu usage //DWORD MIN_UPDATE_INTERVAL=33; ///////////////////// bool looping=true; int waiting_update=0; SetEvent(m_desktop->restart_event); /// Sleep(1000); rgncache.assign_union(rfb::Region2D(m_desktop->m_Cliprect)); if (m_desktop->VideoBuffer() && m_desktop->m_hookdriver) { m_desktop->m_buffer.GrabRegion(rgncache,true,true); } else { m_desktop->m_buffer.GrabRegion(rgncache,false,true); } /// while (looping && !fShutdownOrdered) { DWORD result; newtick = timeGetTime(); int waittime; waittime=100-(newtick-oldtick); if (m_desktop->VideoBuffer() && m_desktop->m_hookdriver) { int fastcounter=0; POINT cursorpos; while (m_desktop->m_videodriver->oldaantal==m_desktop->pchanges_buf->counter) { Sleep(5); fastcounter++; if (fastcounter>20) { #ifdef _DEBUG char szText[256]; sprintf(szText,"fastcounter\n"); OutputDebugString(szText); #endif break; } if (GetCursorPos(&cursorpos) && ((cursorpos.x != oldcursorpos.x) || (cursorpos.y != oldcursorpos.y))) break; } waittime=0; } else { waittime=waittime-(waiting_update*10); } if (waittime<0) waittime=0; if (waittime>100) waittime=100; result=WaitForMultipleObjects(6,m_desktop->trigger_events,FALSE,waittime); { //#ifdef _DEBUG // char szText[256]; // sprintf(szText,"WaitForMultipleObjects %i\n",result ); // OutputDebugString(szText); //#endif // We need to wait until restart is done // else wait_timeout goes in to looping while sink window is not ready // if no window could be started in 10 seconds something went wrong, close // desktop thread. DWORD status=WaitForSingleObject(m_desktop->restart_event,10000); if (status==WAIT_TIMEOUT) looping=false; switch(result) { case WAIT_TIMEOUT: case WAIT_OBJECT_0: { waiting_update=0; ResetEvent(m_desktop->trigger_events[0]); { //measure current cpu usage of winvnc cpuUsage = usage.GetUsage(); if (cpuUsage > m_server->MaxCpu()) MIN_UPDATE_INTERVAL+=10; else MIN_UPDATE_INTERVAL-=10; if (MIN_UPDATE_INTERVAL<MIN_UPDATE_INTERVAL_MIN) MIN_UPDATE_INTERVAL=MIN_UPDATE_INTERVAL_MIN; if (MIN_UPDATE_INTERVAL>MIN_UPDATE_INTERVAL_MAX) MIN_UPDATE_INTERVAL=MIN_UPDATE_INTERVAL_MAX; // vnclog.Print(LL_INTERR, VNCLOG("!PeekMessage \n")); // MAX 30fps newtick = timeGetTime(); // Better resolution than GetTickCount ;) if ((newtick-oldtick)<MIN_UPDATE_INTERVAL) { Sleep(MIN_UPDATE_INTERVAL-(newtick-oldtick)); //continue; Verify, this can cause screen lockup // We need another PeekMessage, but this is only done // by hookdll and viewer asking for new update // can cause a very long wait time } #ifdef _DEBUG char szText[256]; sprintf(szText," cpu2: %d %i %i\n",cpuUsage,MIN_UPDATE_INTERVAL,newtick-oldtick); OutputDebugString(szText); #endif oldtick=newtick; if (m_desktop->VideoBuffer() && m_desktop->m_hookdriver) handle_driver_changes(rgncache,updates); m_desktop->m_update_triggered = FALSE; g_update_triggered = FALSE; //if (m_desktop->m_timerid==NULL) m_desktop->m_timerid = SetTimer(m_desktop->m_hwnd, 1, 100, NULL); //******************************************************* // HOOKDLL START STOP need to be executed from the thread //******************************************************* if (m_desktop->Hookdll_Changed && !m_desktop->m_hookswitch) { vnclog.Print(LL_INTERR, VNCLOG("Hook changed \n")); m_desktop->StartStophookdll(m_desktop->On_Off_hookdll); if (m_desktop->On_Off_hookdll) m_desktop->m_hOldcursor = NULL; // Force mouse cursor grabbing if hookdll On // Todo: in case of hookdriver Off - Hoodll On -> hookdriver On - Hoodll Off // we must send an empty mouse cursor to the clients so they get rid of their local // mouse cursor bitmap m_desktop->Hookdll_Changed=false; } //******************************************************* // SCREEN DISPLAY HAS CHANGED, RESTART DRIVER (IF Used) //******************************************************* if (!m_server->IsThereFileTransBusy()) if (!handle_display_change(threadHandle, rgncache, clipped_updates, updates)) { //failed we need to quit thread looping=false; break; } //******************************************************* // END SCREEN DISPLAY HAS CHANGED //******************************************************* // m_server->SetSWOffset(m_desktop->m_SWOffsetx,m_desktop->m_SWOffsety); //******************************************************************* // SINGLE WINDOW // size SW changed // Position change -->change offsets //******************************************************************* bool SWSizeChanged=false; if (m_server->SingleWindow()) { omni_mutex_lock l(m_desktop->m_update_lock); m_desktop->GetQuarterSize(); m_server->SetSWOffset(m_desktop->m_SWOffsetx,m_desktop->m_SWOffsety); //SW size changed if (m_desktop->m_SWSizeChanged) { SWSizeChanged=true; m_desktop->m_SWSizeChanged=FALSE; m_desktop->GetQuarterSize(); rgncache.assign_union(rfb::Region2D(m_desktop->m_Cliprect)); // vnclog.Print(LL_INTINFO, VNCLOG("4 %i %i %i %i \n"),m_desktop->m_Cliprect.br.x,m_desktop->m_Cliprect.br.y,m_desktop->m_Cliprect.tl.x,m_desktop->m_Cliprect.tl.y); updates.set_clip_region(m_desktop->m_Cliprect); m_server->SetSWOffset(m_desktop->m_SWOffsetx,m_desktop->m_SWOffsety); m_desktop->m_buffer.ClearCache(); m_desktop->m_buffer.BlackBack(); } //SW position changed if (m_desktop->m_SWmoved) { m_desktop->m_SWmoved=FALSE; updates.set_clip_region(m_desktop->m_Cliprect); m_server->SetSWOffset(m_desktop->m_SWOffsetx,m_desktop->m_SWOffsety); rgncache.assign_union(rfb::Region2D(m_desktop->m_Cliprect)); // vnclog.Print(LL_INTINFO, VNCLOG("5 %i %i %i %i \n"),m_desktop->m_Cliprect.br.x,m_desktop->m_Cliprect.br.y,m_desktop->m_Cliprect.tl.x,m_desktop->m_Cliprect.tl.y); m_desktop->m_buffer.ClearCache(); m_desktop->m_buffer.BlackBack(); } if (m_server->SingleWindow() && SWSizeChanged) { m_server->SetNewSWSize(m_desktop->m_SWWidth,m_desktop->m_SWHeight,FALSE); m_server->SetScreenOffset(m_desktop->m_ScreenOffsetx,m_desktop->m_ScreenOffsety,m_desktop->nr_monitors); } }// end update lock //////////////////////////////////////////////////////////////////////////////// // END DYNAMIC CHANGES //////////////////////////////////////////////////////////////////////////////// //Beep(1000,10); // // CALCULATE CHANGES m_desktop->m_UltraEncoder_used=m_desktop->m_server->IsThereAUltraEncodingClient(); // vnclog.Print(LL_INTERR, VNCLOG("UpdateWanted B\n")); //#ifdef _DEBUG //// char szText[256]; // sprintf(szText," m_desktop->m_server->UpdateWanted check\n"); // OutputDebugString(szText); //#endif omni_mutex_lock l(m_desktop->m_update_lock); if (m_desktop->m_server->UpdateWanted()) { // vnclog.Print(LL_INTERR, VNCLOG("UpdateWanted N\n")); //TEST4 // Re-render the mouse's old location if it's moved bool cursormoved = false; POINT cursorpos; if (GetCursorPos(&cursorpos) && ((cursorpos.x != oldcursorpos.x) || (cursorpos.y != oldcursorpos.y))) { // vnclog.Print(LL_INTERR, VNCLOG("UpdateWanted M %i %i %i %i\n"),cursorpos.x, oldcursorpos.x,cursorpos.y,oldcursorpos.y); cursormoved = TRUE; oldcursorpos = rfb::Point(cursorpos); // nyama/marscha - PointerPos. Inform clients about mouse move. m_desktop->m_server->UpdateMouse(); if (MyGetCursorInfo) { MyCURSORINFO cinfo; cinfo.cbSize=sizeof(MyCURSORINFO); MyGetCursorInfo(&cinfo); m_desktop->SetCursor(cinfo.hCursor); } } //**************************************************************************** //************* Polling ---- no driver //**************************************************************************** if (!m_desktop->m_hookdriver || !m_desktop->can_be_hooked) { do_polling(threadHandle, rgncache, fullpollcounter, cursormoved); } //**************************************************************************** //************* driver No polling //**************************************************************************** else { // long lTime = timeGetTime(); if (cursormoved) { // if (lTime - m_desktop->m_lLastMouseUpdateTime < 200) // continue; m_desktop->m_buffer.SetAccuracy(m_desktop->m_server->TurboMode() ? 2 : 1); // m_desktop->m_lLastMouseUpdateTime = lTime; } else // 4 is not that bad...but not perfect (especially with tree branchs display) m_desktop->m_buffer.SetAccuracy(m_desktop->m_server->TurboMode() ? 4 : 2); } // PROCESS THE MOUSE POINTER // Some of the hard work is done in clients, some here // This code fetches the desktop under the old pointer position // but the client is responsible for actually encoding and sending // it when required. // This code also renders the pointer and saves the rendered position // Clients include this when rendering updates. // The code is complicated in this way because we wish to avoid // rendering parts of the screen the mouse moved through between // client updates, since in practice they will probably not have changed. if (cursormoved && !m_desktop->m_hookdriver) { if (!m_desktop->m_cursorpos.is_empty()) { // Cursor position seems to be outsite the bounding // When you make the screen smaller // add extra check rfb::Rect rect; int x = m_desktop->m_cursorpos.tl.x; int w = m_desktop->m_cursorpos.br.x-x; int y = m_desktop->m_cursorpos.tl.y; int h = m_desktop->m_cursorpos.br.y-y; if (ClipRect(&x, &y, &w, &h, m_desktop->m_bmrect.tl.x, m_desktop->m_bmrect.tl.y, m_desktop->m_bmrect.br.x-m_desktop->m_bmrect.tl.x, m_desktop->m_bmrect.br.y-m_desktop->m_bmrect.tl.y)) { rect.tl.x = x; rect.br.x = x+w; rect.tl.y = y; rect.br.y = y+h; rgncache.assign_union(rect); // vnclog.Print(LL_INTINFO, VNCLOG("6 %i %i %i %i \n"),m_desktop->m_cursorpos.br.x,m_desktop->m_cursorpos.br.y,m_desktop->m_cursorpos.tl.x,m_desktop->m_cursorpos.tl.y); // vnclog.Print(LL_INTINFO, VNCLOG("6 %i %i %i %i \n"),rect.br.x,rect.br.y,rect.tl.x,rect.tl.y); } } } { // Prevent any clients from accessing the Buffer omni_mutex_lock l(m_desktop->m_update_lock); // CHECK FOR COPYRECTS // This actually just checks where the Foreground window is if (!m_desktop->m_hookdriver && !m_server->SingleWindow()) m_desktop->CalcCopyRects(updates); // GRAB THE DISPLAY // Fetch data from the display to our display cache. // Update the scaled rects when using server side scaling // something wrong inithooking again // We make sure no updates are in the regions // sf@2002 - Added "&& m_desktop->m_hookdriver" // Otherwise we're still getting driver updates (from shared memory buffer) // after a m_hookdriver switching from on to off // (and m_hookdll from off to on) that causes mouse cursor garbage, // or missing mouse cursor. if (m_desktop->VideoBuffer() && m_desktop->m_hookdriver) { m_desktop->m_buffer.GrabRegion(rgncache,true,capture); } else { m_desktop->m_buffer.GrabRegion(rgncache,false,capture); } #ifdef _DEBUG char szText[256]; sprintf(szText," capture %i\n",capture); OutputDebugString(szText); #endif capture=true; // sf@2002 - v1.1.x - Mouse handling // If one client, send cursor shapes only when the cursor changes. // This is Disabled for now. if( !XRichCursorEnabled==m_desktop->m_server->IsXRichCursorEnabled()) { XRichCursorEnabled= (FALSE != m_desktop->m_server->IsXRichCursorEnabled()); if (m_desktop->m_videodriver) { if (!XRichCursorEnabled) m_desktop->m_videodriver->HardwareCursor(); else m_desktop->m_videodriver->NoHardwareCursor(); } } if (m_desktop->m_server->IsXRichCursorEnabled() && !m_desktop->m_UltraEncoder_used) { if (m_desktop->m_hcursor != m_desktop->m_hOldcursor || m_desktop->m_buffer.IsShapeCleared()) { m_desktop->m_hOldcursor = m_desktop->m_hcursor; m_desktop->m_buffer.SetCursorPending(TRUE); if (!m_desktop->m_hookdriver) m_desktop->m_buffer.GrabMouse(); // Grab mouse cursor in all cases m_desktop->m_server->UpdateMouse(); rfb::Rect rect; int x = m_desktop->m_cursorpos.tl.x; int w = m_desktop->m_cursorpos.br.x-x; int y = m_desktop->m_cursorpos.tl.y; int h = m_desktop->m_cursorpos.br.y-y; if (ClipRect(&x, &y, &w, &h, m_desktop->m_bmrect.tl.x, m_desktop->m_bmrect.tl.y, m_desktop->m_bmrect.br.x-m_desktop->m_bmrect.tl.x, m_desktop->m_bmrect.br.y-m_desktop->m_bmrect.tl.y)) { rect.tl.x = x; rect.br.x = x+w; rect.tl.y = y; rect.br.y = y+h; rgncache.assign_union(rect); // vnclog.Print(LL_INTINFO, VNCLOG("7 %i %i %i %i \n"),m_desktop->m_cursorpos.br.x,m_desktop->m_cursorpos.br.y,m_desktop->m_cursorpos.tl.x,m_desktop->m_cursorpos.tl.y); // vnclog.Print(LL_INTINFO, VNCLOG("6 %i %i %i %i \n"),rect.br.x,rect.br.y,rect.tl.x,rect.tl.y); } m_server->UpdateCursorShape(); } } else if (!m_desktop->m_hookdriver)// If several clients, send them all the mouse updates { // Render the mouse //if (!m_desktop->VideoBuffer()) m_desktop->m_buffer.GrabMouse(); if (cursormoved /*&& !m_desktop->m_buffer.IsCursorUpdatePending()*/) { // Inform clients that it has moved m_desktop->m_server->UpdateMouse(); // Get the buffer to fetch the pointer bitmap if (!m_desktop->m_cursorpos.is_empty()) { rfb::Rect rect; int x = m_desktop->m_cursorpos.tl.x; int w = m_desktop->m_cursorpos.br.x-x; int y = m_desktop->m_cursorpos.tl.y; int h = m_desktop->m_cursorpos.br.y-y; if (ClipRect(&x, &y, &w, &h, m_desktop->m_bmrect.tl.x, m_desktop->m_bmrect.tl.y, m_desktop->m_bmrect.br.x-m_desktop->m_bmrect.tl.x, m_desktop->m_bmrect.br.y-m_desktop->m_bmrect.tl.y)) { rect.tl.x = x; rect.br.x = x+w; rect.tl.y = y; rect.br.y = y+h; rgncache.assign_union(rect); vnclog.Print(LL_INTINFO, VNCLOG("8 %i %i %i %i \n"),m_desktop->m_cursorpos.br.x,m_desktop->m_cursorpos.br.y,m_desktop->m_cursorpos.tl.x,m_desktop->m_cursorpos.tl.y); vnclog.Print(LL_INTINFO, VNCLOG("8 %i %i %i %i \n"),rect.br.x,rect.br.y,rect.tl.x,rect.tl.y); } } } } // SCAN THE CHANGED REGION FOR ACTUAL CHANGES // The hooks return hints as to areas that may have changed. // We check the suggested areas, and just send the ones that // have actually changed. // Note that we deliberately don't check the copyrect destination // here, to reduce the overhead & the likelihood of corrupting the // backbuffer contents. rfb::Region2D checkrgn; rfb::Region2D changedrgn; rfb::Region2D cachedrgn; //Update the backbuffer for the copyrect region if (!clipped_updates.get_copied_region().is_empty()) { rfb::UpdateInfo update_info; rfb::RectVector::const_iterator i; clipped_updates.get_update(update_info); if (!update_info.copied.empty()) { for (i=update_info.copied.begin(); i!=update_info.copied.end(); i++) m_desktop->m_buffer.CopyRect(*i, update_info.copy_delta); } } //Remove the copyrect region from the other updates //checkrgn = rgncache.union_(clipped_updates.get_copied_region()); checkrgn = rgncache.subtract(clipped_updates.get_copied_region()); //make sure the copyrect is checked next update rgncache = clipped_updates.get_copied_region(); //Check all regions for changed and cached parts //This is very cpu intensive, only check once for all viewers if (!checkrgn.is_empty()) m_desktop->m_buffer.CheckRegion(changedrgn,cachedrgn, checkrgn); updates.add_changed(changedrgn); updates.add_cached(cachedrgn); clipped_updates.get_update(m_server->GetUpdateTracker()); } // end mutex lock // Clear the update tracker and region cache an solid clipped_updates.clear(); // screen blanking if (m_desktop->OldPowerOffTimeout!=0) { if (!m_server->BlackAlphaBlending() || m_desktop->VideoBuffer()) { if(OSversion()!=2) { SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 1, NULL, 0); SendMessage(m_desktop->m_hwnd,WM_SYSCOMMAND,SC_MONITORPOWER,(LPARAM)2); } // don't block input here, this is the wrong thread! } } #ifdef AVILOG if (m_desktop->AviGen) m_desktop->AviGen->AddFrame((BYTE*)m_desktop->m_DIBbits); #endif } newtick = timeGetTime(); } } break; case WAIT_OBJECT_0+1: ResetEvent(m_desktop->trigger_events[1]); m_desktop->lock_region_add=true; rgncache.assign_union(m_desktop->rgnpump); m_desktop->rgnpump.clear(); m_desktop->lock_region_add=false; waiting_update++; break; case WAIT_OBJECT_0+2: ResetEvent(m_desktop->trigger_events[2]); break; case WAIT_OBJECT_0+3: if (MyGetCursorInfo) { MyCURSORINFO cinfo; cinfo.cbSize=sizeof(MyCURSORINFO); MyGetCursorInfo(&cinfo); m_desktop->SetCursor(cinfo.hCursor); } ResetEvent(m_desktop->trigger_events[3]); break; case WAIT_OBJECT_0+4: rgncache.assign_union(m_desktop->m_Cliprect); ResetEvent(m_desktop->trigger_events[4]); break; case WAIT_OBJECT_0+5: //break to close looping=false; ResetEvent(m_desktop->trigger_events[5]); break; } } }//while stop_hookwatch=true; if (threadHandle) { WaitForSingleObject( threadHandle, 5000 ); CloseHandle(threadHandle); } m_desktop->SetClipboardActive(FALSE); vnclog.Print(LL_INTINFO, VNCLOG("quitting desktop server thread\n")); // Clear all the hooks and close windows, etc. m_desktop->SetBlockInputState(false); m_server->SingleWindow(false); vnclog.Print(LL_INTINFO, VNCLOG("quitting desktop server thread:SetBlockInputState\n")); // Clear the shift modifier keys, now that there are no remote clients vncKeymap::ClearShiftKeys(); vnclog.Print(LL_INTINFO, VNCLOG("quitting desktop server thread:ClearShiftKeys\n")); // Switch back into our home desktop, under NT (no effect under 9x) //TAG14 HWND mywin=FindWindow("blackscreen",NULL); if (mywin)SendMessage(mywin,WM_CLOSE, 0, 0); g_DesktopThread_running=false; vnclog.Print(LL_INTINFO, VNCLOG("quitting desktop server thread:g_DesktopThread_running=false\n")); m_desktop->Shutdown(); vnclog.Print(LL_INTINFO, VNCLOG("quitting desktop server thread:m_desktop->Shutdown\n")); return NULL; }
bool doUpgradeVideoDatabaseSchema(void) { QString dbver = gCoreContext->GetSetting("mythvideo.DBSchemaVer"); if (dbver == finalVideoDatabaseVersion) { return true; } QString olddbver = gCoreContext->GetSetting("VideoDBSchemaVer"); QString dvddbver = gCoreContext->GetSetting("DVDDBSchemaVer"); if (dbver.isEmpty() && olddbver.isEmpty() && dvddbver.isEmpty()) { if (!InitializeVideoSchema()) return false; dbver = gCoreContext->GetSetting("mythvideo.DBSchemaVer"); } if (dbver.isEmpty() || dbver.toInt() < minimumVideoDatabaseVersion.toInt()) { LOG(VB_GENERAL, LOG_ERR, "Unrecognized video database schema version. " "Unable to upgrade database."); LOG(VB_GENERAL, LOG_ERR, QString("mythvideo.DBSchemaVer: '%1', " "VideoDBSchemaVer: '%2', DVDDBSchemaVer: '%3'").arg(dbver) .arg(olddbver).arg(dvddbver)); return false; } if (dbver == "1016") { const QString updates[] = { "ALTER TABLE dvdbookmark" " MODIFY serialid varbinary(16) NOT NULL default ''," " MODIFY name varbinary(32) default NULL;", "ALTER TABLE dvdinput" " MODIFY v_format varbinary(16) default NULL;", "ALTER TABLE dvdtranscode" " MODIFY name varbinary(128) NOT NULL," " MODIFY codec varbinary(128) NOT NULL," " MODIFY codec_param varbinary(128) default NULL," " MODIFY tc_param varbinary(128) default NULL;", "ALTER TABLE filemarkup" " MODIFY filename blob NOT NULL;", "ALTER TABLE videocast" " MODIFY cast varbinary(128) NOT NULL;", "ALTER TABLE videocategory" " MODIFY category varbinary(128) NOT NULL;", "ALTER TABLE videocountry" " MODIFY country varbinary(128) NOT NULL;", "ALTER TABLE videogenre" " MODIFY genre varbinary(128) NOT NULL;", "ALTER TABLE videometadata" " MODIFY title varbinary(128) NOT NULL," " MODIFY director varbinary(128) NOT NULL," " MODIFY plot blob," " MODIFY rating varbinary(128) NOT NULL," " MODIFY inetref varbinary(255) NOT NULL," " MODIFY filename blob NOT NULL," " MODIFY coverfile blob NOT NULL," " MODIFY playcommand varbinary(255) default NULL;", "ALTER TABLE videotypes" " MODIFY extension varbinary(128) NOT NULL," " MODIFY playcommand varbinary(255) NOT NULL;", "" }; if (!performActualUpdate(updates, "1017", dbver, MythVideoVersionName)) return false; } if (dbver == "1017") { const QString updates[] = { "ALTER TABLE dvdbookmark" " DEFAULT CHARACTER SET default," " MODIFY serialid varchar(16) CHARACTER SET utf8 NOT NULL default ''," " MODIFY name varchar(32) CHARACTER SET utf8 default NULL;", "ALTER TABLE dvdinput" " DEFAULT CHARACTER SET default," " MODIFY v_format varchar(16) CHARACTER SET utf8 default NULL;", "ALTER TABLE dvdtranscode" " DEFAULT CHARACTER SET default," " MODIFY name varchar(128) CHARACTER SET utf8 NOT NULL," " MODIFY codec varchar(128) CHARACTER SET utf8 NOT NULL," " MODIFY codec_param varchar(128) CHARACTER SET utf8 default NULL," " MODIFY tc_param varchar(128) CHARACTER SET utf8 default NULL;", "ALTER TABLE filemarkup" " DEFAULT CHARACTER SET default," " MODIFY filename text CHARACTER SET utf8 NOT NULL;", "ALTER TABLE videocast" " DEFAULT CHARACTER SET default," " MODIFY cast varchar(128) CHARACTER SET utf8 NOT NULL;", "ALTER TABLE videocategory" " DEFAULT CHARACTER SET default," " MODIFY category varchar(128) CHARACTER SET utf8 NOT NULL;", "ALTER TABLE videocountry" " DEFAULT CHARACTER SET default," " MODIFY country varchar(128) CHARACTER SET utf8 NOT NULL;", "ALTER TABLE videogenre" " DEFAULT CHARACTER SET default," " MODIFY genre varchar(128) CHARACTER SET utf8 NOT NULL;", "ALTER TABLE videometadata" " DEFAULT CHARACTER SET default," " MODIFY title varchar(128) CHARACTER SET utf8 NOT NULL," " MODIFY director varchar(128) CHARACTER SET utf8 NOT NULL," " MODIFY plot text CHARACTER SET utf8," " MODIFY rating varchar(128) CHARACTER SET utf8 NOT NULL," " MODIFY inetref varchar(255) CHARACTER SET utf8 NOT NULL," " MODIFY filename text CHARACTER SET utf8 NOT NULL," " MODIFY coverfile text CHARACTER SET utf8 NOT NULL," " MODIFY playcommand varchar(255) CHARACTER SET utf8 default NULL;", "ALTER TABLE videometadatacast" " DEFAULT CHARACTER SET default;", "ALTER TABLE videometadatacountry" " DEFAULT CHARACTER SET default;", "ALTER TABLE videometadatagenre" " DEFAULT CHARACTER SET default;", "ALTER TABLE videotypes" " DEFAULT CHARACTER SET default," " MODIFY extension varchar(128) CHARACTER SET utf8 NOT NULL," " MODIFY playcommand varchar(255) CHARACTER SET utf8 NOT NULL;", "" }; if (!performActualUpdate(updates, "1018", dbver, MythVideoVersionName)) return false; } if (dbver == "1018") { QStringList updates; updates += "DELETE FROM settings WHERE value=" "'MovieListCommandLine' AND data LIKE '%imdb%';"; updates += "DELETE FROM settings WHERE value=" "'MovieDataCommandLine' AND data LIKE '%imdb%';"; updates += "DELETE FROM settings WHERE value=" "'MoviePosterCommandLine' AND data LIKE '%imdb%';"; if (!performActualUpdate(updates, "1019", dbver, MythVideoVersionName)) return false; } if (dbver == "1019") { QStringList updates( "ALTER TABLE videometadata ADD `trailer` TEXT;"); if (!performActualUpdate(updates, "1020", dbver, MythVideoVersionName)) return false; } if (dbver == "1020") { LOG(VB_GENERAL, LOG_NOTICE, "Upgrading to MythVideo schema version 1021"); AddFileType("mkv"); AddFileType("mp4"); AddFileType("m2ts"); AddFileType("evo"); AddFileType("divx"); AddFileType("mov"); AddFileType("qt"); AddFileType("wmv"); AddFileType("3gp"); AddFileType("asf"); AddFileType("ogg"); AddFileType("ogm"); AddFileType("flv"); if (!UpdateDBVersionNumber(MythVideoVersionName, "1021")) return false; dbver = "1021"; } if (dbver == "1021") { QStringList updates; updates += "ALTER TABLE videometadata ADD host text CHARACTER SET utf8 NOT NULL;"; if (!performActualUpdate(updates, "1022", dbver, MythVideoVersionName)) return false; } if (dbver == "1022") { QStringList updates; updates += "ALTER TABLE videometadata ADD `screenshot` TEXT;"; updates += "ALTER TABLE videometadata ADD `banner` TEXT;"; updates += "ALTER TABLE videometadata ADD `fanart` TEXT;"; if (!performActualUpdate(updates, "1023", dbver, MythVideoVersionName)) return false; } if (dbver == "1023") { QStringList updates; updates += "ALTER TABLE videometadata ADD `subtitle` TEXT " "NOT NULL AFTER `title`;"; updates += "ALTER TABLE videometadata ADD `season` SMALLINT " "UNSIGNED NOT NULL DEFAULT '0' AFTER `length`;"; updates += "ALTER TABLE videometadata ADD `episode` SMALLINT " "UNSIGNED NOT NULL DEFAULT '0' AFTER `season`;"; if (!performActualUpdate(updates, "1024", dbver, MythVideoVersionName)) return false; } if (dbver == "1024") { QStringList updates; updates += "ALTER TABLE videometadata ADD watched BOOL " "NOT NULL DEFAULT 0 AFTER browse;"; if (!performActualUpdate(updates, "1025", dbver, MythVideoVersionName)) return false; } if (dbver == "1025") { QStringList updates; updates += "ALTER TABLE videometadata ADD `insertdate` TIMESTAMP " "NULL DEFAULT CURRENT_TIMESTAMP AFTER `fanart`;"; if (!performActualUpdate(updates, "1026", dbver, MythVideoVersionName)) return false; } if (dbver == "1026") { QStringList updates; updates += "DELETE FROM keybindings " " WHERE action = 'DELETE' AND context = 'Video';"; if (!performActualUpdate(updates, "1027", dbver, MythVideoVersionName)) return false; } if (dbver == "1027") { LOG(VB_GENERAL, LOG_NOTICE, "Upgrading to MythVideo schema version 1028"); LOG(VB_GENERAL, LOG_INFO, "Converting filenames in filemarkup table " "from absolute to relative paths. This may take a long " "time if you have a large number of MythVideo seektables."); bool ok = true; MSqlQuery query(MSqlQuery::InitCon()); MSqlQuery update(MSqlQuery::InitCon()); query.prepare("SELECT DISTINCT filename FROM filemarkup;"); update.prepare("UPDATE filemarkup SET filename = :RELPATH " " WHERE filename = :FULLPATH;"); if (query.exec()) { QString origPath; QString relPath; while (query.next()) { origPath = query.value(0).toString(); if (origPath.startsWith("dvd:")) continue; relPath = StorageGroup::GetRelativePathname(origPath); if ((!relPath.isEmpty()) && (relPath != origPath)) { update.bindValue(":RELPATH", relPath); update.bindValue(":FULLPATH", origPath); if (!update.exec()) { LOG(VB_GENERAL, LOG_ERR, QString("ERROR converting '%1' to '%2' in " "filemarkup table.") .arg(origPath).arg(relPath)); ok = false; } } } } else ok = false; if (!ok) return false; if (!UpdateDBVersionNumber(MythVideoVersionName, "1028")) return false; dbver = "1028"; } if (dbver == "1028") { QStringList updates; updates += "ALTER TABLE videometadata ADD `releasedate` DATE " "NOT NULL AFTER `year`;"; updates += "ALTER TABLE videometadata ADD `homepage` TEXT " "NOT NULL AFTER `inetref`;"; if (!performActualUpdate(updates, "1029", dbver, MythVideoVersionName)) return false; } if (dbver == "1029") { QStringList updates; updates += "ALTER TABLE videometadata ADD `hash` VARCHAR(128) " "NOT NULL AFTER `filename`;"; if (!performActualUpdate(updates, "1030", dbver, MythVideoVersionName)) return false; } if (dbver == "1030") { UpdateHashes(); if (!UpdateDBVersionNumber(MythVideoVersionName, "1031")) return false; dbver = "1031"; } if (dbver == "1031") { MSqlQuery query(MSqlQuery::InitCon()); query.prepare("SHOW INDEX FROM videometadata"); if (!query.exec()) { MythDB::DBError("Unable to retrieve current indices on " "videometadata.", query); } else { while (query.next()) { QString index_name = query.value(2).toString(); if ("title_2" == index_name) { MSqlQuery update(MSqlQuery::InitCon()); update.prepare("ALTER TABLE videometadata " " DROP INDEX title_2"); if (!update.exec()) MythDB::DBError("Unable to drop duplicate index " "on videometadata. Ignoring.", update); break; } } } if (!UpdateDBVersionNumber(MythVideoVersionName, "1032")) return false; dbver = "1032"; } if (dbver == "1032") { QStringList updates; updates += "CREATE TEMPORARY TABLE bad_videometadatacast" " AS SELECT * FROM videometadatacast;"; updates += "CREATE TEMPORARY TABLE bad_videometadatagenre" " AS SELECT * FROM videometadatagenre;"; updates += "CREATE TEMPORARY TABLE bad_videometadatacountry" " AS SELECT * FROM videometadatacountry;"; updates += "TRUNCATE TABLE videometadatacast;"; updates += "TRUNCATE TABLE videometadatagenre;"; updates += "TRUNCATE TABLE videometadatacountry;"; updates += "INSERT videometadatacast SELECT idvideo,idcast" " FROM bad_videometadatacast GROUP BY idvideo,idcast;"; updates += "INSERT videometadatagenre SELECT idvideo,idgenre" " FROM bad_videometadatagenre GROUP BY idvideo,idgenre;"; updates += "INSERT videometadatacountry SELECT idvideo,idcountry" " FROM bad_videometadatacountry GROUP BY idvideo,idcountry;"; updates += "DROP TEMPORARY TABLE bad_videometadatacast;"; updates += "DROP TEMPORARY TABLE bad_videometadatagenre;"; updates += "DROP TEMPORARY TABLE bad_videometadatacountry;"; updates += "ALTER TABLE videometadatacast ADD UNIQUE INDEX (`idvideo`,`idcast`);"; updates += "ALTER TABLE videometadatagenre ADD UNIQUE INDEX (`idvideo`,`idgenre`);"; updates +="ALTER TABLE videometadatacountry ADD UNIQUE INDEX (`idvideo`,`idcountry`);"; if (!performActualUpdate(updates, "1033", dbver, MythVideoVersionName)) return false; dbver = "1033"; } if (dbver == "1033") { AddFileType("ogv"); AddFileType("BDMV"); AddFileType("nut"); AddFileType("mxf"); AddFileType("m4v"); AddFileType("rm"); AddFileType("ts"); AddFileType("swf"); AddFileType("f4v"); AddFileType("nuv"); if (!UpdateDBVersionNumber(MythVideoVersionName, "1034")) return false; dbver = "1034"; } if (dbver == "1034") { QStringList updates; updates += "ALTER TABLE videometadata ADD `tagline` VARCHAR (255) " "AFTER `subtitle`;"; if (!performActualUpdate(updates, "1035", dbver, MythVideoVersionName)) return false; } if (dbver == "1035") { QStringList updates; updates += "ALTER TABLE videometadata ADD processed BOOL " "NOT NULL DEFAULT 0 AFTER watched;"; if (!performActualUpdate(updates, "1036", dbver, MythVideoVersionName)) return false; } if (dbver == "1036") { QStringList updates; updates += "ALTER TABLE videometadata ADD `studio` VARCHAR( 128 ) " "AFTER `director`;"; if (!performActualUpdate(updates, "1037", dbver, MythVideoVersionName)) return false; } if (dbver == "1037") { QStringList updates; updates += "DELETE FROM videotypes WHERE extension = 'VIDEO_TS';"; updates += "DELETE FROM videotypes WHERE extension = 'BDMV';"; if (!performActualUpdate(updates, "1038", dbver, MythVideoVersionName)) return false; } return true; }
/* Tracks current rectangle in the image and populates a * collection. Every tracked box has a rank(=3) that increases if the box * is redetected and decreases otherwise. The threshold that is used to compare * the detected boxes with the stored ones. * * * PARAMETERS: * - cur_boxes : current image rectangles * - collection : the collection to be populated * - rank : the initial rank of a new box, * - max_rank : the initial rank of a new box, * - threshold : rectangle comparison threshold * * RETURN -- */ void track(vector< Rect_<int> >& cur_boxes, People& collection, int width, int height, int rank, int max_rank) { float step = 1.5; vector<bool> updates(collection.tracked_boxes.size(), false); if(!cur_boxes.empty()) { Rect_<int> all; //We reposition every tracked box with a union of //the boxes that fall in its area for(int a = 0; a < collection.tracked_boxes.size(); ++a) { all = Rect(0,0,0,0); for(vector< Rect_<int> >::iterator it = cur_boxes.begin(); it < cur_boxes.end();) { Rect_<int> cur_box = *it; Rect intersection = cur_box | collection.tracked_boxes[a]; int threshold = intersection.area(); float area_thres = max(cur_box.area(), collection.tracked_boxes[a].area()); if(threshold > 0 && threshold < 1.1*area_thres) { if (all.area() == 0) all = cur_box; else all = cur_box | all; it = cur_boxes.erase(it); } else ++it; } //The reposition rules if(all.area() > 0) { float x_new; float y_new; float w_new; float h_new; if(all.area() > collection.tracked_boxes[a].area()) { x_new = (all.x + collection.tracked_boxes[a].x)/2; y_new = (all.y + collection.tracked_boxes[a].y)/2; w_new = (all.width + collection.tracked_boxes[a].width)/2; h_new = (all.height + collection.tracked_boxes[a].height)/2; } else { float thresh = 1; float factor = 160; float power = 5*float(collection.tracked_boxes[a].area())/float(all.area()); float x_dif = (all.x - collection.tracked_boxes[a].x); float y_dif = (all.y - collection.tracked_boxes[a].y); float w_dif = (all.width - collection.tracked_boxes[a].width); float h_dif = (all.height - collection.tracked_boxes[a].height); x_new = collection.tracked_boxes[a].x + x_dif/(power); y_new = collection.tracked_boxes[a].y + y_dif/(power); w_new = collection.tracked_boxes[a].width + (abs((w_dif*(abs(x_dif) + abs(y_dif) + 1))/(factor*(power + 1))) < thresh? 0 : w_dif* (abs(x_dif) + abs(y_dif) + 1)/(factor*(power + 1))); h_new = collection.tracked_boxes[a].height + (abs((h_dif*(abs(x_dif) + abs(y_dif) + 1))/(factor*(power + 1))) < thresh? 0 : h_dif* (abs(x_dif) + abs(y_dif) + 1)/(factor*(power + 1))); if(w_new < 0) w_new = 0; if(h_new < 0) h_new = 0; } //Calculate features and diffs not normalized //**************************** //Ratio feature float ratio = float(collection.tracked_boxes[a].height)/float(collection.tracked_boxes[a].width); collection.tracked_pos[a].ratio_diff = ratio - collection.tracked_pos[a].ratio; collection.tracked_pos[a].ratio = ratio; //Area feature float area = w_new*h_new; collection.tracked_pos[a].area_diff = area - collection.tracked_pos[a].area; collection.tracked_pos[a].area = area; //x_diff and y_diff float x_diff = (x_new - collection.tracked_boxes[a].x)/area; float y_diff = (y_new - collection.tracked_boxes[a].y)/area; collection.tracked_pos[a].x_delta = x_diff - collection.tracked_pos[a].x_diff; collection.tracked_pos[a].y_delta = y_diff - collection.tracked_pos[a].y_diff; collection.tracked_pos[a].x_diff = x_diff; collection.tracked_pos[a].y_diff = y_diff; //y_norm float y_norm = y_new/area; collection.tracked_pos[a].y_norm_diff = y_norm - collection.tracked_pos[a].y_norm; collection.tracked_pos[a].y_norm = y_norm; //Distance feature int x1 = (x_new + w_new/2); int y1 = (y_new + h_new/2); int x2 = (collection.tracked_boxes[a].x + collection.tracked_boxes[a].width/2); int y2 = (collection.tracked_boxes[a].y + collection.tracked_boxes[a].height/2); float distance = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2))/area; collection.tracked_pos[a].distance_diff = distance - collection.tracked_pos[a].distance; collection.tracked_pos[a].distance = distance; //assign the new values collection.tracked_boxes[a].x = x_new; collection.tracked_boxes[a].y = y_new; collection.tracked_boxes[a].width = w_new; collection.tracked_boxes[a].height = h_new; //*************************** //check we did not exceed the limits if(collection.tracked_boxes[a].x + collection.tracked_boxes[a].width > width) collection.tracked_boxes[a].width = width - collection.tracked_boxes[a].x; if(collection.tracked_boxes[a].y + collection.tracked_boxes[a].height > height) collection.tracked_boxes[a].height = height - collection.tracked_boxes[a].y; updates.at(a) = true; } } for(int a = 0; a < cur_boxes.size(); ++a) { Position pos; collection.tracked_pos.push_back(pos); collection.tracked_boxes.push_back(cur_boxes[a]); collection.tracked_rankings.push_back(rank + step); } //In this phase we loop through all the produced rectangles and again try to merge those whose //intersection is above a certain threshold int end = collection.tracked_boxes.size(); for(int a = 0; a < end; ++a) { for(int b = a + 1; b < end; ++b) { Rect_<int> removal = collection.tracked_boxes[a]; Rect_<int> rect = collection.tracked_boxes[b]; Rect all = removal | rect; int y_distance = height; if (removal.y < rect.y) y_distance = rect.y - (removal.y + removal.height); else y_distance = removal.y - (rect.y + rect.height); Rect intersection; int threshold = 0; if(y_distance < height/20) { int y_temp = removal.y; removal.y = rect.y; intersection = removal & rect; threshold = intersection.area(); if (threshold == 0) { int x_distance = width; if (removal.x < rect.x) x_distance = rect.x - (removal.x + removal.width); else x_distance = removal.x - (rect.x + rect.width); //~ float area_thres = max(removal.area(), rect.area()); //~ if((x_distance < width/50) && (all.area() < 2*area_thres)) //~ { //~ threshold = 1; //~ } } removal.y = y_temp; } if(threshold > 0) { float rank_dif = abs(collection.tracked_rankings[a] - collection.tracked_rankings[b])/(collection.tracked_rankings[a] + collection.tracked_rankings[b]); float rank_ratio = (collection.tracked_rankings[a] + collection.tracked_rankings[b])/(max_rank); if(rank_ratio < 1.1) { collection.tracked_boxes[a] = all; collection.tracked_boxes[b] = collection.tracked_boxes.back(); collection.tracked_boxes.pop_back(); collection.tracked_rankings[b] = collection.tracked_rankings.back(); collection.tracked_rankings.pop_back(); collection.tracked_pos[b] = collection.tracked_pos.back(); collection.tracked_pos.pop_back(); b=a; --end; } } } } } //Update the rankings for(int a = 0; a < collection.tracked_boxes.size(); ++a) { if (updates[a] == true) { if(collection.tracked_rankings[a] <= max_rank) collection.tracked_rankings[a] = collection.tracked_rankings[a] + step; } collection.tracked_rankings[a] = collection.tracked_rankings[a] - 1; } //Delete those that fall below 0 rank for(vector<float>::iterator rank_it = collection.tracked_rankings.begin(); rank_it < collection.tracked_rankings.end();) { int dist = distance(collection.tracked_rankings.begin(), rank_it); if(*rank_it < rank || collection.tracked_boxes[dist].area() < rank) { rank_it = collection.tracked_rankings.erase(rank_it); collection.tracked_pos.erase(collection.tracked_pos.begin() + dist); collection.tracked_boxes.erase(collection.tracked_boxes.begin() + dist); } else ++rank_it; } }
void WorldController::updates() { updates("1"); }
void Session::workUpdateShortChatMessage(InboundPkt &inboundPkt, qint64 msgId) { qCDebug(TG_CORE_SESSION) << "workUpdateShortChatMessage: msgId =" << QString::number(msgId, 16); Q_UNUSED(msgId) UpdatesType upd(&inboundPkt); Q_EMIT updates(upd); }
void Session::workUpdates(InboundPkt &inboundPkt, qint64 msgId) { qCDebug(TG_CORE_SESSION) << "workUpdates: msgId =" << QString::number(msgId, 16); UpdatesType upd(&inboundPkt); Q_EMIT updates(upd.updates(), upd.users(), upd.chats(), upd.date(), upd.seq()); }
void Session::workUpdatesTooLong(InboundPkt &inboundPkt, qint64 msgId) { qCDebug(TG_CORE_SESSION) << "workUpdatesTooLong: msgId =" << QString::number(msgId, 16); UpdatesType upd(&inboundPkt); Q_EMIT updates(upd); }
void * vncDesktopThread::run_undetached(void *arg) { // Save the thread's "home" desktop, under NT (no effect under 9x) HDESK home_desktop = GetThreadDesktop(GetCurrentThreadId()); // Attempt to initialise and return success or failure if (!m_desktop->Startup()) { vncService::SelectHDESK(home_desktop); ReturnVal(FALSE); return NULL; } // Grab the initial display contents // *** m_desktop->m_buffer.GrabRegion(m_desktop->m_bmrect); // *** m_desktop->m_buffer.Clear(m_desktop->m_bmrect); // Succeeded to initialise ok ReturnVal(TRUE); // START PROCESSING DESKTOP MESSAGES // We set a flag inside the desktop handler here, to indicate it's now safe // to handle clipboard messages m_desktop->SetClipboardActive(TRUE); // All changes in the state of the display are stored in a local // UpdateTracker object, and are flushed to the vncServer whenever // client updates are about to be triggered rfb::SimpleUpdateTracker clipped_updates; rfb::ClippedUpdateTracker updates(clipped_updates, m_desktop->m_bmrect); clipped_updates.enable_copyrect(true); // Incoming update messages are collated into a single region cache // The region cache areas are checked for changes before an update // is triggered, and the changed areas are passed to the UpdateTracker rfb::Region2D rgncache = m_desktop->m_bmrect; // The previous cursor position is stored, to allow us to erase the // old instance whenever it moves. rfb::Point oldcursorpos; // Set the hook thread to a high priority // *** set_priority(omni_thread::PRIORITY_HIGH); BOOL idle_skip = TRUE; ULONG idle_skip_count = 0; MSG msg; while (TRUE) { if (!PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE)) { // // - MESSAGE QUEUE EMPTY // Whenever the message queue becomes empty, we check to see whether // there are updates to be passed to clients. if (idle_skip) { idle_skip = FALSE; if (idle_skip_count++ < 4) { Sleep(5); continue; } } idle_skip_count = 0; // Clear the triggered flag m_desktop->m_update_triggered = FALSE; // // CHECK SCREEN FORMAT // First, we must check that the screen hasnt changed too much. if (m_desktop->m_displaychanged || !vncService::InputDesktopSelected()) { rfbServerInitMsg oldscrinfo = m_desktop->m_scrinfo; m_desktop->m_displaychanged = FALSE; // Attempt to close the old hooks if (!m_desktop->Shutdown()) { m_server->KillAuthClients(); break; } // Now attempt to re-install them! if (!m_desktop->Startup()) { m_server->KillAuthClients(); break; } // Check that the screen info hasn't changed //vnclog.Print(LL_INTINFO, VNCLOG("SCR: old screen format %dx%dx%d\n"), // oldscrinfo.framebufferWidth, // oldscrinfo.framebufferHeight, // oldscrinfo.format.bitsPerPixel); //vnclog.Print(LL_INTINFO, VNCLOG("SCR: new screen format %dx%dx%d\n"), // m_desktop->m_scrinfo.framebufferWidth, // m_desktop->m_scrinfo.framebufferHeight, // m_desktop->m_scrinfo.format.bitsPerPixel); if ((m_desktop->m_scrinfo.framebufferWidth != oldscrinfo.framebufferWidth) || (m_desktop->m_scrinfo.framebufferHeight != oldscrinfo.framebufferHeight)) { m_server->KillAuthClients(); break; } else if (memcmp(&m_desktop->m_scrinfo.format, &oldscrinfo.format, sizeof(rfbPixelFormat)) != 0) { m_server->UpdateLocalFormat(); } // Adjust the UpdateTracker clip region updates.set_clip_region(m_desktop->m_bmrect); // Add a full screen update to all the clients rgncache = rgncache.union_(rfb::Region2D(m_desktop->m_bmrect)); m_server->UpdatePalette(); } // // CALCULATE CHANGES // if (m_desktop->m_server->UpdateWanted()) { // POLL PROBLEM AREAS // We add specific areas of the screen to the region cache, // causing them to be fetched for processing. if (m_desktop->m_server->PollFullScreen()) { rfb::Rect rect = m_desktop->m_qtrscreen; rect = rect.translate(rfb::Point(0, m_desktop->m_pollingcycle * m_desktop->m_qtrscreen.br.y)); rgncache = rgncache.union_(rfb::Region2D(rect)); m_desktop->m_pollingcycle = (m_desktop->m_pollingcycle + 1) % 4; } if (m_desktop->m_server->PollForeground()) { // Get the window rectangle for the currently selected window HWND hwnd = GetForegroundWindow(); if (hwnd != NULL) PollWindow(rgncache, hwnd); } if (m_desktop->m_server->PollUnderCursor()) { // Find the mouse position POINT mousepos; if (GetCursorPos(&mousepos)) { // Find the window under the mouse HWND hwnd = WindowFromPoint(mousepos); if (hwnd != NULL) PollWindow(rgncache, hwnd); } } // PROCESS THE MOUSE POINTER // Some of the hard work is done in clients, some here // This code fetches the desktop under the old pointer position // but the client is responsible for actually encoding and sending // it when required. // This code also renders the pointer and saves the rendered position // Clients include this when rendering updates. // The code is complicated in this way because we wish to avoid // rendering parts of the screen the mouse moved through between // client updates, since in practice they will probably not have changed. // Re-render the mouse's old location if it's moved BOOL cursormoved = FALSE; POINT cursorpos; if (GetCursorPos(&cursorpos) && ((cursorpos.x != oldcursorpos.x) || (cursorpos.y != oldcursorpos.y))) { cursormoved = TRUE; oldcursorpos = rfb::Point(cursorpos); } if (cursormoved) { if (!m_desktop->m_cursorpos.is_empty()) rgncache = rgncache.union_(rfb::Region2D(m_desktop->m_cursorpos)); } { // Prevent any clients from accessing the Buffer omni_mutex_lock l(m_desktop->m_update_lock); // CHECK FOR COPYRECTS // This actually just checks where the Foreground window is m_desktop->CalcCopyRects(updates); // GRAB THE DISPLAY // Fetch data from the display to our display cache. m_desktop->m_buffer.GrabRegion(rgncache); // Render the mouse m_desktop->m_buffer.GrabMouse(); if (cursormoved) { // Inform clients that it has moved m_desktop->m_server->UpdateMouse(); // Get the buffer to fetch the pointer bitmap if (!m_desktop->m_cursorpos.is_empty()) rgncache = rgncache.union_(rfb::Region2D(m_desktop->m_cursorpos)); } // SCAN THE CHANGED REGION FOR ACTUAL CHANGES // The hooks return hints as to areas that may have changed. // We check the suggested areas, and just send the ones that // have actually changed. // Note that we deliberately don't check the copyrect destination // here, to reduce the overhead & the likelihood of corrupting the // backbuffer contents. rfb::Region2D checkrgn = rgncache.subtract(clipped_updates.get_copied_region()); rgncache = clipped_updates.get_copied_region(); rfb::Region2D changedrgn; m_desktop->m_buffer.CheckRegion(changedrgn, checkrgn); // FLUSH UPDATES TO CLIENTS // Add the bits that have really changed to their update regions // Note that the cursor is NOT included - they must do that // themselves, for the reasons above. // This call implicitly kicks clients to update themselves updates.add_changed(changedrgn); clipped_updates.get_update(m_server->GetUpdateTracker()); } // Clear the update tracker and region cache clipped_updates.clear(); } // Now wait for more messages to be queued if (!WaitMessage()) { //vnclog.Print(LL_INTERR, VNCLOG("WaitMessage() failed\n")); break; } } else if (msg.message == RFB_SCREEN_UPDATE) { // Process an incoming update event // An area of the screen has changed rfb::Rect rect; rect.tl = rfb::Point((SHORT)LOWORD(msg.wParam), (SHORT)HIWORD(msg.wParam)); rect.br = rfb::Point((SHORT)LOWORD(msg.lParam), (SHORT)HIWORD(msg.lParam)); rect = rect.intersect(m_desktop->m_bmrect); if (!rect.is_empty()) { rgncache = rgncache.union_(rfb::Region2D(rect)); } idle_skip = TRUE; } else if (msg.message == RFB_MOUSE_UPDATE) { // Process an incoming mouse event // Save the cursor ID m_desktop->SetCursor((HCURSOR) msg.wParam); idle_skip = TRUE; } else if (msg.message == WM_QUIT) { break; } else { // Process any other messages normally DispatchMessage(&msg); idle_skip = TRUE; } } m_desktop->SetClipboardActive(FALSE); //vnclog.Print(LL_INTINFO, VNCLOG("quitting desktop server thread\n")); // Clear all the hooks and close windows, etc. m_desktop->Shutdown(); // Clear the shift modifier keys, now that there are no remote clients vncKeymap::ClearShiftKeys(); // Switch back into our home desktop, under NT (no effect under 9x) vncService::SelectHDESK(home_desktop); return NULL; }