SocketHandler::~SocketHandler() { Cancel(3); CloseConnection(); }
QWakeUpActiveObject::~QWakeUpActiveObject() { Cancel(); }
QCompleteDeferredAOs::~QCompleteDeferredAOs() { Cancel(); }
void CUpdateThread::Update() { // 读取本地配置 UpdateCommandButton(COMMAND_BUTTON_CANCEL); UpdateMainProgress(0); UpdateSubProgress(0); UpdateStatusText(_T("读取站点列表……")); CString strIniPath = theApp.GetProfileFile(); CString strSites; DWORD dwSize = 0; do { dwSize += 4096; } while(GetPrivateProfileSection(_T("Sites"), strSites.GetBuffer(dwSize), dwSize, strIniPath.GetString()) == dwSize - 2); UpdateSubProgress(100); CArray<CString> sites; LPCTSTR lpszSite = strSites.GetBuffer(); while (lpszSite[0]) { sites.Add(lpszSite); lpszSite += _tcslen(lpszSite) + 1; } strSites.ReleaseBuffer(); UpdateMainProgress(2); CMap<CString, LPCTSTR, AddonFile, AddonFile&> files; // 下载文件列表 double step = 6.0 / sites.GetSize(); for (int i = 0; i < sites.GetSize() && CheckCancel(); ++i) { CString &strSite = sites.GetAt(i); if (!GetFileList(strSite, files)) { UpdateSubProgress(100); UpdateMainProgress(100); UpdateStatusText(_T("无法下载文件列表。")); return; } UpdateMainProgress(2 + (int)(step * i + 0.5)); } if (!CheckCancel()) return; UpdateMainProgress(8); UpdateStatusText(_T("正在检测需要更新的文件……")); CString strWOWPath = theApp.GetWOWPath(); CString strTempPath = theApp.GetTempPath(); CArray <AddonFile *> aDownloadList; // 需要下载的文件 CMap<CString, LPCTSTR, AddonFile, AddonFile&>::CPair *pair = files.PGetFirstAssoc(); while (pair && CheckCancel()) { CString strMD5; try { CString strFilePath; strFilePath.Append(strWOWPath); strFilePath.Append(pair->value.m_strPath); md5_state_t md5; md5_init(&md5); md5_byte_t digest[16] = {0}; CFile file(strFilePath, CFile::shareDenyRead | CFile::modeRead); char buf[4096]; UINT nCount; while ((nCount = file.Read(buf, 4096)) > 0) { md5_append(&md5, buf, nCount); } file.Close(); md5_finish(&md5, digest); for (int i = 0; i < 16; ++i) { strMD5.AppendFormat(_T("%02x"), digest[i]); } } catch (CFileException *e) { e->Delete(); } if (strMD5.Compare(pair->value.m_strMD5) != 0) { aDownloadList.Add(&pair->value); } pair = files.PGetNextAssoc(pair); } if (!CheckCancel()) return; ULONG uTotalSize = 0; for (int i = 0; i < aDownloadList.GetSize(); ++i) { uTotalSize += aDownloadList.GetAt(i)->m_uCompressedSize; } if (!CheckCancel()) return; CString strStatus; strStatus.AppendFormat(_T("共有%u个文件需要更新,%.2fMB。"), aDownloadList.GetSize(), uTotalSize * 1.0f / 1024 / 1024); UpdateStatusText(strStatus); UpdateMainProgress(10); step = 88.0 / uTotalSize; ULONG uDownload = 0; for (int i = 0; i < aDownloadList.GetSize() && CheckCancel(); ++i) { AddonFile *pAddonFile = aDownloadList.GetAt(i); UpdateStatusText(CString(_T("下载 ") + pAddonFile->m_strPath).GetString()); CString strUrl = pAddonFile->m_strSite + pAddonFile->m_strPath + _T(".z"); strUrl.Replace(_T('\\'), _T('/')); CString strPath = strTempPath + pAddonFile->m_strPath + _T(".z"); CString strFolder = strPath.Mid(0, strPath.ReverseFind(_T('\\'))); SHCreateDirectoryEx(NULL, strFolder, NULL); if (!Download(strUrl, strPath, pAddonFile->m_uCompressedSize)) { UpdateStatusText(CString(_T("下载 ") + pAddonFile->m_strPath + _T("失败")).GetString()); Cancel(); CheckCancel(); return; } UpdateSubProgress(100); UpdateStatusText(CString(_T("解压 ") + pAddonFile->m_strPath + _T("...")).GetString()); CFile file(strPath, CFile::modeRead | CFile::shareDenyNone); unsigned char *compressed = new unsigned char[file.GetLength()]; UINT uRead = 0; UINT uTotalRead = 0; file.Read(compressed, file.GetLength()); ULONG uCompSize = file.GetLength(); file.Close(); unsigned char *uncompressed = new unsigned char[pAddonFile->m_uSize]; DWORD uSize = pAddonFile->m_uSize; if (uncompress(uncompressed, &uSize, compressed, uCompSize) != Z_OK) { delete[] compressed; delete[] uncompressed; UpdateStatusText(CString(_T("解压 ") + pAddonFile->m_strPath + _T("失败")).GetString()); Cancel(); CheckCancel(); return; } strPath = strWOWPath + pAddonFile->m_strPath; strFolder = strPath.Mid(0, strPath.ReverseFind(_T('\\'))); SHCreateDirectoryEx(NULL, strFolder, NULL); if (!file.Open(strPath, CFile::modeCreate | CFile::shareExclusive | CFile::modeReadWrite)) { delete[] compressed; delete[] uncompressed; UpdateStatusText(CString(_T("创建 ")) + strPath + _T("失败。")); Cancel(); CheckCancel(); return; } file.Write(uncompressed, pAddonFile->m_uSize); file.Close(); delete[] compressed; delete[] uncompressed; uDownload += pAddonFile->m_uCompressedSize; UpdateMainProgress(8 + uDownload * step + 0.5); } if (!CheckCancel()) return; // 需要删除的文件 CArray<CString, LPCTSTR> oldFiles; LoadOldList(oldFiles); for (int i = 0; i < oldFiles.GetSize(); ++i) { CString &strPath = oldFiles.GetAt(i); if (!files.PLookup(strPath.MakeLower())) { CString strFilePath = strWOWPath + strPath; DeleteFile(strFilePath); RemoveFolderIfEmpty(strWOWPath, strFilePath.Mid(0, strFilePath.ReverseFind(_T('\\')))); } } // 保存本次更新的列表 TiXmlDocument doc; TiXmlElement *root = new TiXmlElement("Files"); pair = files.PGetFirstAssoc(); USES_CONVERSION; while (pair) { TiXmlElement *file = new TiXmlElement("File"); file->SetAttribute("Path", T2A(pair->value.m_strPath)); root->LinkEndChild(file); pair = files.PGetNextAssoc(pair); } doc.LinkEndChild(root); doc.SaveFile(T2A(theApp.GetApplicationPath() + _T("AddonUpdater.xml"))); UpdateStatusText(_T("更新完毕。")); UpdateMainProgress(100); UpdateCommandButton(COMMAND_BUTTON_PLAY); }
cDeCsaTSBuffer::~cDeCsaTSBuffer() { Cancel(3); if(decsa) decsa->SetActive(false); delete ringBuffer; }
CSwiTask::~CSwiTask() { Cancel(); }
void DtSetModList::CloseCB() { Cancel(); }
CCheckNetwork::~CCheckNetwork() { Cancel(); // if any request outstanding, calls DoCancel() to cleanup delete iTelephony; delete iPkg; }
void CCheckNetwork::DoCancel() { Cancel(); }
// ----------------------------------------------------------------------------- // CMyLocationsEngine::~CCalenderNotification() // default destuctor. // ----------------------------------------------------------------------------- // CCalenderNotification::~CCalenderNotification() { Cancel(); iFsession.Close(); }
// --------------------------------------------------------------------------- // CNcmReceiver::~CNcmReceiver // --------------------------------------------------------------------------- // CNcmReceiver::~CNcmReceiver() { __CONNECTIONMULTIPLEXER( "CNcmReceiver::~CNcmReceiver" ) Cancel(); }
/** * Standard destructor. */ CSmsMessageSend::~CSmsMessageSend() { Cancel(); delete iSmsEventLogger; } // CSmsMessageSend::~CSmsMessageSend
void CSTTrackerConnection::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent) { switch (aEvent.iStatus) { case THTTPEvent::EGotResponseHeaders: { // HTTP response headers have been received. Use // aTransaction.Response() to get the response. However, it's not // necessary to do anything with the response when this event occurs. LWRITELN(iLog, _L("[Trackerconnection] Got HTTP headers")); // Get HTTP status code from header (e.g. 200) RHTTPResponse resp = aTransaction.Response(); TInt status = resp.StatusCode(); if (status != 200) // ERROR, hiba esetén mi legyen? 404-et lekezelni! { LWRITE(iLog, _L("[Trackerconnection] Error, status = ")); TBuf<20> numBuf; numBuf.Num(status); LWRITELN(iLog, numBuf); Cancel(); if (iObserver) iObserver->TrackerConnectionFailedL(); break; } // Get status text (e.g. "OK") HLWRITE(iLog, _L("[Trackerconnection] Status text = ")); TBuf<32> statusText; statusText.Copy(resp.StatusText().DesC()); HLWRITELN(iLog, statusText); #ifdef LOG_TO_FILE RHTTPHeaders headers = aTransaction.Response().GetHeaderCollection(); THTTPHdrFieldIter i = headers.Fields(); for (i.First(); !(i.AtEnd()); ++i) { RStringF header = iSession.StringPool().StringF(i()); if ((header.DesC() == _L8("Content-Type"))) { HLWRITE(iLog, header.DesC()); HLWRITE(iLog, _L(": ")); THTTPHdrVal val; headers.GetField(header, 0, val); RStringF value = val.StrF(); HLWRITELN(iLog, value.DesC()); } else HLWRITELN(iLog, header.DesC()); } #endif } break; case THTTPEvent::EGotResponseBodyData: { // Part (or all) of response's body data received. Use // aTransaction.Response().Body()->GetNextDataPart() to get the actual // body data. // Get the body data supplier MHTTPDataSupplier* body = aTransaction.Response().Body(); TPtrC8 dataChunk; // GetNextDataPart() returns ETrue, if the received part is the last // one. TBool isLast = body->GetNextDataPart(dataChunk); //iDownloadedSize += dataChunk.Size(); HLWRITELN(iLog, _L8("[TrackerConnection] HTTP response body chunk received: ")); HLWRITELN(iLog, dataChunk); if (iReceiveBuffer) { HBufC8* temp = HBufC8::NewL( iReceiveBuffer->Length() + dataChunk.Length()); TPtr8 tempPtr(temp->Des()); tempPtr.Copy(*iReceiveBuffer); tempPtr.Append(dataChunk); delete iReceiveBuffer; iReceiveBuffer = temp; } else iReceiveBuffer = dataChunk.AllocL(); // Always remember to release the body data. body->ReleaseData(); // NOTE: isLast may not be ETrue even if last data part received. // (e.g. multipart response without content length field) // Use EResponseComplete to reliably determine when body is completely // received. if (isLast) { #ifdef LOG_TO_FILE _LIT(KBodyReceived,"Body received"); HLWRITELN(iLog, KBodyReceived); #endif //CSTBencode* bencodedResponse = CSTBencode::ParseL(*iReceiveBuffer); //iLog->WriteLineL(*iReceiveBuffer); // //if (bencodedResponse) //{ // CleanupStack::PushL(bencodedResponse); // iTorrent.ProcessTrackerResponseL(bencodedResponse); // CleanupStack::PopAndDestroy(); // bencodedResponse //} } } break; case THTTPEvent::EResponseComplete: { // Indicates that header & body of response is completely received. // No further action here needed. //_LIT(KTransactionComplete, "Transaction Complete"); //iLog->WriteLineL(KTransactionComplete); //iResult = ESucceeded; } break; case THTTPEvent::ESucceeded: { LWRITELN(iLog, _L("[Trackerconnection] HTTP transaction succeded")); CSTBencode* bencodedResponse = CSTBencode::ParseL(*iReceiveBuffer); //iLog->WriteLineL(*iReceiveBuffer); if (bencodedResponse && iObserver) { CleanupStack::PushL(bencodedResponse); iObserver->TrackerResponseReceivedL(*bencodedResponse); CleanupStack::PopAndDestroy(); // bencodedResponse } iRunning = EFalse; if (iObserver) iObserver->TrackerConnectionSucceededL(); } break; case THTTPEvent::EFailed: { LWRITELN(iLog, _L("[Trackerconnection] HTTP transaction failed")); iRunning = EFalse; if (iObserver) iObserver->TrackerConnectionFailedL(); } break; default: // There are more events in THTTPEvent, but they are not usually // needed. However, event status smaller than zero should be handled // correctly since it's error. { TBuf<64> text; if (aEvent.iStatus < 0) { LWRITE(iLog, _L("[Trackerconnection] HTTP transaction failed, ")); _LIT(KErrorStr, "Error: %d"); text.Format(KErrorStr, aEvent.iStatus); LWRITELN(iLog, text); // Just close the transaction on errors aTransaction.Close(); iRunning = EFalse; if (iObserver) iObserver->TrackerConnectionFailedL(); } else { // Other events are not errors (e.g. permanent and temporary // redirections) _LIT(KUnrecognisedEvent, "[Trackerconnection] Unrecognised event: %d"); text.Format(KUnrecognisedEvent, aEvent.iStatus); LWRITELN(iLog, text); } } break; } }
cThread::~cThread() { Cancel(); // just in case the derived class didn't call it free(description); }
QMLBackendMonitorAO::~QMLBackendMonitorAO() { Cancel(); delete iTriggerMonitorInfo; //deletes the CBackendMonitorInfo object holding the linked list iLbt.Close(); //closes the subsession }
// Destructor CPhCltComHandRequestMonitor::~CPhCltComHandRequestMonitor() { Cancel(); }
CStateRefAdaptationTimer::~CStateRefAdaptationTimer() { Cancel(); }
CCopyContactsAO::~CCopyContactsAO() { Cancel(); delete iDatabase; }
// --------------------------------------------------------------------------- // NewL // --------------------------------------------------------------------------- // CSendUiEcomObserver::~CSendUiEcomObserver() { Cancel(); }
CCamcTestClient_9::~CCamcTestClient_9 () { Cancel(); delete iCamc; }
void JobManager::DoShutdown() { std::vector<InternalJob::Pointer> vec_ToCancel; { Poco::ScopedLock<Poco::Mutex> LockMe(m_mutex); if (m_active) { m_active = false; //cancel all running jobs vec_ToCancel.assign(m_running.begin(), m_running.end()); //clean up m_JobQueueSleeping.Clear(); m_JobQueueWaiting.Clear(); m_running.clear(); } } // Give running jobs a chance to finish. Wait 0.1 seconds for up to 3 times. if (!vec_ToCancel.empty()) { for (std::size_t i = 0; i < vec_ToCancel.size(); i++) { // cancel jobs outside sync block to avoid deadlock Cancel(vec_ToCancel[i]); } for (int waitAttempts = 0; waitAttempts < 3; waitAttempts++) { Poco::Thread::yield(); { Poco::ScopedLock<Poco::Mutex> LockMe(m_mutex); if (m_running.empty()) break; } if (DEBUG_SHUTDOWN) { // JobManager.debug("Shutdown - job wait cycle #" + (waitAttempts + 1)); std::vector<InternalJob::Pointer> vec_StillRunning; { Poco::ScopedLock<Poco::Mutex> LockMe(m_mutex); vec_StillRunning.assign(m_running.begin(), m_running.end()); // if (!vec_StillRunning.empty()) { //for (int j = 0; j < stillRunning.length; j++) { // JobManager.debug("\tJob: " + printJobName(stillRunning[j])); //$NON-NLS-1$ //} } } Poco::Thread::sleep(100); Poco::Thread::yield(); } // retrieve list of the jobs that are still running { Poco::ScopedLock<Poco::Mutex> LockMe(m_mutex); vec_ToCancel.assign(m_running.begin(), m_running.end()); } } if (!vec_ToCancel.empty()) { /*for (int i = 0; i < vec_ToCancel.size(); i++) {*/ // std::string tmp_jobName = PrintJobName(toCancel[i]); // //this doesn't need to be translated because it's just being logged // String msg = "Job found still running after platform shutdown. Jobs should be canceled by the plugin that // scheduled them during shutdown: " + jobName; // RuntimeLog.log(new Status(IStatus.WARNING, JobManager.PI_JOBS, JobManager.PLUGIN_ERROR, msg, null)); // // // TODO the RuntimeLog.log in its current implementation won't produce a log // // during this stage of shutdown. For now add a standard error output. // // One the logging story is improved, the System.err output below can be removed: // System.err.println(msg); // } } m_Pool->Shutdown(); }
MythEventHandler::ImpMythEventHandler::~ImpMythEventHandler() { Cancel(30); CMYTH->RefRelease(m_conn_t); m_conn_t=0; }
void CSocketsWriter::TimerExpired() { Cancel(); iWriteStatus = EWaiting; iEngineNotifier.ReportError(MEngineNotifier::ETimeOutOnWrite, KErrTimedOut); }
// --------------------------------------------------------------------------- // CSsmLangSelCmd::ExecuteCancel // --------------------------------------------------------------------------- // void CSsmLangSelCmd::ExecuteCancel() { FUNC_LOG; Cancel(); }
CMdSGarbageCollector::~CMdSGarbageCollector() { Cancel(); iTimer.Close(); }
// ----------------------------------------------------------------------------- // CBassBoostEventObserver::~CBassBoostEventObserver // Destructor // ----------------------------------------------------------------------------- // CBassBoostEventObserver::~CBassBoostEventObserver() { // We should not have to cancel the outstanding request because the message // handler will complete our request with KErrCancel in its destructor. Cancel(); }
QTimerActiveObject::~QTimerActiveObject() { Cancel(); m_rTimer.Close(); //close of null handle is safe }
void CInstance::Fail() { Cancel(); luautils::OnInstanceFailure(this); }
QSocketActiveObject::~QSocketActiveObject() { Cancel(); }
CGuiCommand::~CGuiCommand() { Cancel(); pCommand->Release(); pCommand=NULL; }