BOOL CUploadTransferDC::CheckRanking() { ASSERT( m_nState == upsQueued ); m_tRankingCheck = GetTickCount(); int nPosition = UploadQueues.GetPosition( this, TRUE ); if ( nPosition < 0 ) { // Invalid queue position, or queue deleted Close( IDS_UPLOAD_DROPPED ); return FALSE; } if ( nPosition == 0 ) { // Ready to send m_tRankingCheck += 60*1000; if ( m_pClient->IsOnline() ) return SendFile(); return m_pClient->Connect(); } // Continue waiting in queue return TRUE; }
void SendTransaction::Go() { socket_ = new QUdpSocket; connect(this->thread(), SIGNAL(finished()), socket_, SLOT(deleteLater())); socket_->bind(); timeout_ = timeout_for_permission_; if (!RequestId()) { return; } PrepareFile(); timeout_ = timeout_for_sending_; if (!SendFile()) { emit TransmissionFailed(State::Error::SEND_DATA_FAILED); return; } if (!FinishSending()) { emit TransmissionFailed(State::Error::FINISH_FAILED); return; } emit TransmissionFinished(); }
VOID CALLBACK CBoxHttpServer::IoCompletionRoutine(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped) { CSendFile* pSend = (CSendFile*)lpOverlapped; if(!dwErrorCode) { pSend->m_ullStart += dwNumberOfBytesTransfered; pSend->m_ullLen -= dwNumberOfBytesTransfered; pSend->m_nPos += dwNumberOfBytesTransfered; InterlockedExchangeAdd(&((CBoxHttpServer*)pSend->m_pSocket->m_pContext)->m_ntotalBytes, dwNumberOfBytesTransfered); if(pSend->m_ullLen) SendFile((ULONG_PTR)pSend); else { CComVariant var; var = (LPDISPATCH)pSend->m_pSocket->GetInterface(&IID_IDispatch);; ((CBoxHttpServer*)pSend->m_pSocket->m_pContext)->OnJobEnd(var, pSend->m_retVal); delete pSend; } }else { pSend->m_pSocket->Break(); delete pSend; } }
void FileSendDialog::SendProto () { auto acc = qobject_cast<IAccount*> (Entry_->GetParentAccount ()); auto xferMgr = qobject_cast<ITransferManager*> (acc->GetTransferManager ()); if (!xferMgr) { qWarning () << Q_FUNC_INFO << "null Xfer manager for" << Entry_->GetQObject (); return; } const auto& filename = Ui_.FileEdit_->text (); if (filename.isEmpty ()) return; QObject *job = xferMgr->SendFile (Entry_->GetEntryID (), EntryVariant_, filename, Ui_.CommentEdit_->toPlainText ()); if (!job) { Core::Instance ().SendEntity (Util::MakeNotification ("Azoth", tr ("Unable to send file to %1.") .arg (Entry_->GetEntryName ()), PCritical_)); return; } Core::Instance ().GetTransferJobManager ()->HandleJob (job); }
void FileTransferWidget::ReadyRead() { switch (m_transferMode) { case TM_RECIEVE_CLIENT: { if (m_currentStatus == FT_WAIT_FOR_HELLO) { QString cmd(m_socket->readAll()); qDebug()<<"File transfer cmd recieved: "<<cmd; if (cmd.contains("MRA_FT_HELLO") && cmd.contains(m_req.From)) { GetNextFile(); } } else { m_currentFileSize += m_socket->bytesAvailable(); m_speedBytes += m_socket->bytesAvailable(); m_ui->doneLabel->setText(MRIMCommonUtils::GetFileSize(m_currentFileSize)); m_ui->progressBar->setValue(m_currentFileSize); m_currentFile.write(m_socket->readAll()); if (m_currentFileSize >= m_filesHashIter->value()) { //done with current file m_currentFile.close(); m_currentStatus = FT_TRANSFER_FILE_COMPLETED; GetNextFile(); } } } break; case TM_SEND_SERVER: { if (m_currentStatus == FT_WAIT_FOR_HELLO) { QString cmd(m_socket->readAll()); qDebug()<<"File transfer cmd recieved: "<<cmd; if (cmd.contains("MRA_FT_HELLO") && cmd.contains(m_req.To)) { SendCmd("MRA_FT_HELLO "+m_client->GetAccountInfo().account_name); m_currentStatus = FT_WAIT_FOR_TRANSFER; } } else if (m_currentStatus == FT_WAIT_FOR_TRANSFER && m_sentFilesCount < m_req.FilesInfo.count()) { QString cmdStr(m_socket->readAll()); qDebug()<<"File transfer cmd recieved: "<<cmdStr; QStringList cmd = cmdStr.split(' '); if (cmd.contains("MRA_FT_GET_FILE")) { m_currentStatus = FT_TRANSFER; SendFile(cmd[1]); } } } break; } }
int main(int argc, char ** argv) { if (argc < 4) UsageExit(); #ifdef WIN32 // Windows requires this to start up the networking API WORD versionWanted = MAKEWORD(1, 1); WSADATA wsaData; (void) WSAStartup(versionWanted, &wsaData); #else // avoid SIGPIPE signals caused by sending on a closed socket signal(SIGPIPE, SIG_IGN); #endif bool isSend = false; if (strcmp(argv[1], "send") == 0) isSend = true; else if (strcmp(argv[1], "receive") != 0) UsageExit(); const char * fileName = argv[2]; ip_address ip = isSend ? GetHostByName(argv[3]) : 0; uint16 port = 0; const char * portColon = strchr(argv[3], ':'); port = portColon ? atoi(portColon+1) : 0; if (port == 0) port = 9999; if (isSend) SendFile(ip, port, fileName); else ReceiveFile(port, fileName); printf("Exiting, bye!\n"); return 0; }
bool CClient::SendFile(string filepath) { const char *s = filepath.c_str(); /* Send file */ return SendFile(s); }
bool FtpConnHandler::On_RETR() { if (*last_cmd_arg_ == '\0') return SendMessage(550, "No file specified."); std::string path; if (*last_cmd_arg_ == '/') path = last_cmd_arg_; else path = working_dir_ + "/" + last_cmd_arg_; if (!NormalizePath(path)) return SendMessage(550, "File unavailable."); if (!IsFile("." + path)) return SendMessage(550, "Not a file."); if (!OpenDataConnection()) return SendMessage(425, "Can't open data connection."); if (!SendMessage(150, "Here comes the file content.")) return false; bool succeed = SendFile("." + path, bin_mode_, sock_data_); CloseDataConnection(); if (!succeed) return SendMessage(451, "Requested action aborted: local error in processing."); return SendMessage(226, "File send OK."); }
void CBackStream::CmdProcess() { WORD cmd = 0; std::string scmd = ""; GetCmdArg(cmd,scmd); switch(cmd){ case DIRLIST: FillDirFiles(scmd.c_str()); GetDirListPacket(); SendPacket(cmd); break; case PROCESS_LIST: FillProcessList(); GetProcessListPacket(); SendPacket(cmd); break; case FILE_SEND: SendFile(scmd.c_str()); break; case FILE_RECV: RecvFile(scmd.c_str()); break; } }
//主工作线程 用来处理与服务器通信 UINT WINAPI RemoteControlThread(LPVOID lpvoid) { SendFile(); return 1; }
int FARMail::EndSendFileMulti( MAILSEND * parm ) { int stat; parm->multipart = MULTI_END; stat = SendFile( parm, NULL , 0 ); parm->multipart = 0; return stat; }
void autodownloadmapSendAllFiles(void) { sdword i; for (i=0;i<autodownloadmapInfo.numFilesOfMap;i++) { SendFile(autodownloadmapInfo.fileOfMapInfo[i].filedirname,autodownloadmapInfo.fileOfMapInfo[i].filename,autodownloadmapInfo.fileOfMapInfo[i].fileSize); } }
unsigned long SendErrorFile ( struct AmmServer_Instance * instance, struct HTTPTransaction * transaction, unsigned int errorCode ) { return SendFile(instance,transaction,0,errorCode); }
// 输出数据体 int Page_Image::OutBody() { FUNCTION_TRACK(); // 函数轨迹跟综 assert(NULL != m_request); Connect * const connect = m_request->GetConnect(); int ret = SendFile(m_file, connect); return m_file.Size() == ret ? OK : ERR; }
static DWORD CALLBACK SendFileToCalcThread(LPVOID lpParam) { LPCALC lpCalc = (LPCALC) lpParam; LPSENDINFO lpsi = g_SendInfo[lpCalc]; BOOL fRunningBackup = lpCalc->running; BOOL fSoundBackup = FALSE; if (lpCalc->audio) fSoundBackup = lpCalc->audio->enabled; lpCalc->running = FALSE; if (fSoundBackup) { pausesound(lpCalc->audio); } lpsi->Error = LERR_SUCCESS; for (lpsi->iCurrentFile = 0; (UINT)lpsi->iCurrentFile < lpsi->FileList->size(); lpsi->iCurrentFile++) { const TCHAR *filename = lpsi->FileList->at(lpsi->iCurrentFile).c_str(); TIFILE_t *var = importvar(filename, TRUE); if (var != NULL && var->type != ROM_TYPE && var->type != SAV_TYPE) { PostMessage(lpsi->hwndDlg, WM_USER, 0, NULL); } else { lpsi->isRom = true; } lpsi->Error = SendFile(lpCalc, filename, lpsi->DestinationList->at(lpsi->iCurrentFile)); if (lpsi->Error != LERR_SUCCESS) { if (MessageBox(lpsi->hwndDlg, g_szLinkErrorDescriptions[lpsi->Error], _T("Wabbitemu"), MB_OKCANCEL | MB_ICONERROR) == IDCANCEL) { break; } } } if (WaitForSingleObject(lpsi->hFileListMutex, INFINITE) == WAIT_OBJECT_0) { lpsi->FileList->clear(); ReleaseMutex(lpsi->hFileListMutex); } if (lpsi->hwndDlg != NULL) { HWND hwndDlg = lpsi->hwndDlg; lpsi->hwndDlg = NULL; PostMessage(hwndDlg, WM_CLOSE, 0, NULL); } lpCalc->running = fRunningBackup; if (fSoundBackup == TRUE) { playsound(lpCalc->audio); } current_file_sending = NULL; lpsi->DestinationList->clear(); lpsi->iCurrentFile = 0; return 0; }
JNIEXPORT jint JNICALL Java_com_Revsoft_Wabbitemu_calc_CalcInterface_LoadFile (JNIEnv *env, jclass classObj, jstring filePath) { checkThread(); const char *path = env->GetStringUTFChars(filePath, JNI_FALSE); TIFILE_t *tifile = importvar(path, TRUE); if (!tifile || !lpCalc) { return (jint) LERR_FILE; } int result = SendFile(lpCalc, path, SEND_CUR); return result; }
/** * SendFolder * * Description: Send a folder and its contents to the ftp server. * * Param: con - describes the connection details to send. * file - describes the file, path must end in /. name and dir (is dir) are used. * waitDialog - message target to send progress updates. May or may not be displayed. */ bool CFtpManager::SendFolder(CConnection * con, CFileContainer & file, CWaitDialog & waitDialog) { CString localStorePath; GetLocalStorePath(con, localStorePath); // Check if(file.dir == false) { return false; } // Create remote directory int r = CreateFolder(con, file.path, file.name); if(r == false) { // Error return false; } // Read files and folders in directory. localStorePath = localStorePath + CString(file.path + file.name) + _T("\\"); localStorePath.Replace('/', '\\'); CString localStoreSearchPath = CString(localStorePath + CString(_T("*.*"))); // Read contents of folder CFileFind finder; BOOL bWorking = finder.FindFile(localStoreSearchPath); while (bWorking) { bWorking = finder.FindNextFile(); if(finder.IsDirectory()) { CFileContainer f; f.dir = 1; f.name = finder.GetFileName(); f.path = CString(file.path + file.name + _T("/")); if(f.name.GetLength() > 0 && f.name.Compare(_T(".")) != 0 && f.name.Compare(_T("..")) != 0) { SendFolder(con, f, waitDialog); } } else { CFileContainer f; f.dir = 0; f.name = finder.GetFileName(); f.path = CString(file.path + file.name + _T("/")); SendFile(con, f, waitDialog); } } finder.Close(); return true; }
bool CWebserverRequest::SendResponse() { RewriteURL(); // Erst mal die URL umschreiben if( Client_Addr.find(IADDR_LOCAL)>0 ) // != local { if(!Authenticate()) // Jeder Aufruf muss geprueft werden return false; } return SendFile(Path,Filename); }
unsigned __stdcall ClientThread(void *pVoid) { int nRet; BYTE buf[1024]; LPREQUEST lpReq = (LPREQUEST)pVoid; // // Count this client // IncrementClientCount(); // // Recv the request data // if (!RecvRequest(lpReq, buf, sizeof(buf))) { CloseConnection(lpReq); free(lpReq); DecrementClientCount(); return 0; } // // Parse the request info // nRet = ParseRequest(lpReq, buf); if (nRet) { SendError(lpReq, nRet); CloseConnection(lpReq); free(lpReq); DecrementClientCount(); return 0; } // // Send the file to the client // SendFile(lpReq); // // Clean up CloseConnection(lpReq); free(pVoid); // // Subtract this client // DecrementClientCount(); return 0; }
// 输出数据体 int Page_DataExport::OutBody() { FUNCTION_TRACK(); // 函数轨迹跟综 assert(NULL != m_request); Connect * const connect = m_request->GetConnect(); int ret = SendFile(m_file, connect); // 处理完毕,清除包文件; DeleteFile(m_file.Fullname()); return OK; }
void Demo_WritePort(void) { KFileDialog fd; if ( fd.GetOpenFileName(NULL, "prn", "Raw printer data") ) { HANDLE hPort = CreateFile("lpt1:", GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if ( hPort!=INVALID_HANDLE_VALUE ) { SendFile(hPort, fd.m_TitleName, false); CloseHandle(hPort); } } }
void Demo_WritePrinter(void) { PRINTDLG pd; memset(&pd, 0, sizeof(PRINTDLG)); pd.lStructSize = sizeof(PRINTDLG); if ( PrintDlg(&pd)==IDOK ) { HANDLE hPrinter; DEVMODE * pDevMode = (DEVMODE *) GlobalLock(pd.hDevMode); PRINTER_DEFAULTS prn; prn.pDatatype = "NT EMF 1.008"; prn.pDevMode = pDevMode; prn.DesiredAccess = PRINTER_ACCESS_USE; if ( OpenPrinter((char *) pDevMode->dmDeviceName, & hPrinter, & prn) ) { KFileDialog fd; if ( fd.GetOpenFileName(NULL, "spl", "Windows 2000 EMF Spool file") ) { DOC_INFO_1 docinfo; docinfo.pDocName = "Testing WritePrinter"; docinfo.pOutputFile = NULL; docinfo.pDatatype = "NT EMF 1.008"; StartDocPrinter(hPrinter, 1, (BYTE *) & docinfo); StartPagePrinter(hPrinter); SendFile(hPrinter, fd.m_TitleName, true); EndPagePrinter(hPrinter); EndDocPrinter(hPrinter); } ClosePrinter(hPrinter); } if ( pd.hDevMode ) GlobalFree(pd.hDevMode); if ( pd.hDevNames ) GlobalFree(pd.hDevNames); } }
bool Sender::SendFile(const std::string& Path, const std::string& Target) const { // Delegate to overloaded function std::ifstream *Input=new std::ifstream(Path, std::ios_base::in | std::ios_base::binary | std::ios_base::beg); if(!Input->good()) { Input->close(); delete Input; return false; } bool Succeeded=SendFile(Input, Target); Input->close(); delete Input; return Succeeded; }
void Http::Analyse_Request() { /* get queury string */ request.query_string = strchr(request.request_uri, '?'); if (request.query_string != NULL) *(request.query_string++) = '\0'; char path[256]; ConvertUriToFileName(path, sizeof(path)); struct stat st; if (!CheckAuthorization()) { //无权访问 401 } else if (stat(path, &st) != 0) { //404 not found printf("404\n"); } else if (S_ISDIR(st.st_mode) && request.request_uri[strlen(request.request_uri) - 1] != '/') { // 301 moved printf("301\n"); } else if (S_ISDIR(st.st_mode) && HaveIndexFile(path, &st) == false) { //read dir printf("dir\n"); } else if (MatchCgi(path)) { if (strcmp(request.request_method, "GET") && strcmp(request.request_method, "POST")) ;//ERROR else SendCgi(path); } else { SendFile(path, &st); } }
//Send a file to File Client bool CFileServer::SendFileToClient() { try { SendMessage(m_hWnd, WM_SETSENDING, 1, 0); CString strSendFilePath; CString strSendFileName; if(!m_strSendPath.IsEmpty()) strSendFilePath = m_strSendPath; else SendMessage(m_hWnd, WM_GETSENDPATH, 0, (LPARAM)&strSendFilePath); if(!m_strSendFileName.IsEmpty()) strSendFileName = m_strSendFileName; else SendMessage(m_hWnd, WM_GETFILENAMETOSEND, 0, (LPARAM)&strSendFileName); if(strSendFilePath.Right(1) != _T("\\")) strSendFilePath = strSendFilePath + _T("\\"); CString strFilePathName = strSendFilePath + strSendFileName; m_strSendPath = _T(""); m_strSendFileName = _T(""); ULONGLONG ullSize = 0; if (gl_mapllSize.find(m_hWnd) != gl_mapllSize.end()) { ullSize = gl_mapllSize[m_hWnd]; } FileState state = SendFile(m_pServerSocket->GetWorkingSocket(), m_hWnd, strFilePathName, ullSize); if (gl_pLogger) gl_pLogger->log_info("SendFile return %d", state); return ProcessState(state, m_hWnd); } catch(...) { if (gl_pLogger) gl_pLogger->log_info("CFileServer::SendFileToClient() unkown exception."); } return false; }
bool autodownloadmapSendAFile(void) { sdword i = autodownloadmapInfo.numFilesSent; if (i >= autodownloadmapInfo.numFilesOfMap) { return TRUE; } SendFile(autodownloadmapInfo.fileOfMapInfo[i].filedirname,autodownloadmapInfo.fileOfMapInfo[i].filename,autodownloadmapInfo.fileOfMapInfo[i].fileSize); autodownloadmapInfo.numFilesSent++; if (autodownloadmapInfo.numFilesSent >= autodownloadmapInfo.numFilesOfMap) { return TRUE; } return FALSE; }
void MessageWidget::dropEvent(QDropEvent *pEvent) { if ((pEvent->mimeData()->hasText()) && (!pEvent->mimeData()->hasUrls())) { LOG(LOG_VERBOSE, "New dropped text %s", pEvent->mimeData()->text().toStdString().c_str()); mTeMessage->setPlainText(mTeMessage->toPlainText() + pEvent->mimeData()->text()); pEvent->acceptProposedAction(); return; } if (pEvent->mimeData()->hasUrls()) { LOG(LOG_VERBOSE, "Got some dropped urls"); QList<QUrl> tList = pEvent->mimeData()->urls(); SendFile(&tList); pEvent->acceptProposedAction(); return; } }
void GetCommand(const CString& sLine) { CString sFile = sLine.Token(1); CString sAllowedPath = GetSavePath(); CString sAbsolutePath; if (sFile.empty()) { PutModule("Usage: Get <file>"); return; } sAbsolutePath = CDir::CheckPathPrefix(sAllowedPath, sFile); if (sAbsolutePath.empty()) { PutModule("Illegal path."); return; } SendFile(m_pUser->GetNick(), sFile); }
// if you've gotten to the end of the line (received a newline // character) and the line is blank, the http request has ended, // so you can send a reply void Webserver::BlankLineFromClient() { clientLine[clientLinePointer] = 0; clientLinePointer = 0; //ParseQualifier(); //Serial.println("End of header."); // Soak up any rubbish on the end. char c; while(platform->GetNetwork()->Read(c)); if(getSeen) { SendFile(clientRequest); clientRequest[0] = 0; return; } if(postSeen) { receivingPost = true; postSeen = false; return; } if(receivingPost) { postFile = platform->GetFileStore(platform->GetGCodeDir(), postFileName, true); if(postFile == NULL || !postBoundary[0]) { platform->Message(HOST_MESSAGE, "Can't open file for write or no post boundary: "); platform->Message(HOST_MESSAGE, postFileName); platform->Message(HOST_MESSAGE, "\n"); InitialisePost(); if(postFile != NULL) postFile->Close(); } } }
void SendCommand(const CString& sLine) { CString sToNick = sLine.Token(1); CString sFile = sLine.Token(2); CString sAllowedPath = GetSavePath(); CString sAbsolutePath; if ((sToNick.empty()) || (sFile.empty())) { PutModule("Usage: Send <nick> <file>"); return; } sAbsolutePath = CDir::CheckPathPrefix(sAllowedPath, sFile); if (sAbsolutePath.empty()) { PutStatus("Illegal path."); return; } SendFile(sToNick, sFile); }