void FtpApp::createActions() { refresh = new QAction("&Refresh",this); refresh->setStatusTip("Refresh the list of files"); refresh->setShortcut(Qt::Key_F5); connect(refresh,SIGNAL(triggered()),this,SLOT(refreshList())); quitAction = new QAction(tr("&Quit"),this); quitAction->setStatusTip("Quit the JIGS File Sharing"); quitAction->setShortcut(Qt::CTRL + Qt::Key_Q); connect(quitAction, SIGNAL(triggered()), this, SLOT(quit())); aboutAction=new QAction(tr("&About"),this); aboutAction->setStatusTip("About JIGS File Sharing"); connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutPopup())); uploadFileAction=new QAction("&Upload Single File",this); uploadFileAction->setShortcut(Qt::CTRL + Qt::Key_U); uploadFileAction->setStatusTip("Upload a single File to the FTP Server"); connect(uploadFileAction,SIGNAL(triggered()),this,SLOT(uploadFile())); downloadFileAction = new QAction("&Download Single File",this); downloadFileAction->setShortcut(Qt::CTRL + Qt::Key_D); downloadFileAction->setStatusTip("Download a single file from FTP sever"); connect(downloadFileAction,SIGNAL(triggered()),this,SLOT(downloadFile())); }
/* Called when the "upload file" action is triggered. Pop up a file dialog, and try to upload the given file to the board. This is only for uploading pre-built .bins. */ void MainWindow::onUploadFile( ) { QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::homePath(), tr("Binaries (*.bin)")); if(!fileName.isNull()) uploadFile(fileName); }
void Systray::createActions() { myAccountAction = new QAction(tr("&My Account")); connect(myAccountAction, SIGNAL(triggered()), this, SLOT(openAccount())); uploadFileAction = new QAction(tr("Upload &File...")); connect(uploadFileAction, SIGNAL(triggered()), this, SLOT(uploadFile())); uploadClipboardAction = new QAction(tr("Upload &Clipboard")); connect(uploadClipboardAction, SIGNAL(triggered()), this, SLOT(uploadClipboard())); fullScreenAction = new QAction(tr("Capture &Desktop")); connect(fullScreenAction, SIGNAL(triggered()), this, SLOT(fullScreenScreenshot())); selectAreaAction = new QAction(tr("Capture &Area")); connect(selectAreaAction, SIGNAL(triggered()), this, SLOT(selectAreaScreenshot())); activeAction = new QAction(tr("Capture Current &Window")); connect(activeAction, SIGNAL(triggered()), this, SLOT(activeWindowScreenshotTimed())); historyMenu = new QMenu(tr("&History")); settingsAction = new QAction(tr("&Settings...")); connect(settingsAction, SIGNAL(triggered()), this, SLOT(openSettings())); quitAction = new QAction(tr("&Quit")); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); openSaveDirectoryAction = new QAction(tr("&Open Screenshot Directory")); connect(openSaveDirectoryAction, SIGNAL(triggered()), this, SLOT(openSaveDirectory())); }
INT PutFile(SOCKET sd, char *fileName) { INT status; INT fileSize; /* Send the the request to the server on socket sd */ printf("uploading %s...\n", fileName); strcpy_s(request.fileName, fileName); if ((fileSize=getFileSize(fileName)) == -1) return IO_ERROR; _itoa_s(fileSize, request.fileSize, 10); strcpy_s(request.cmdName, PUT_FILE); if (!WriteRequest(sd, &request)) return IO_ERROR; if ((status = uploadFile(fileName, sd, fileSize)) != STATUS_OK) return status; if (!ReadResponse(sd, &response)) return IO_ERROR; return atoi(response.status); }
void TestRenderServer::uploadDone(){ if(fileList.isEmpty()){ link->deleteLater(); link = NULL; ui->uploadFolderPushButton->setEnabled(true); ui->renderPushButton->setEnabled(true); }else { uploadFile(fileList[0], myHash[fileList[0]]); } }
/*! * \brief Uploads a file at \a localPath to \a path. * * \a Path should start with '/', append by bucket name and file path. * eg: /demobucket/upload.png. If the path is a directory, it MUST end with '/'. * * Sets \a autoMkdir to true if auto mkdir needed (10 at most). * * Sets \a appendFileMD5 to true if append file MD5 value needed. If this value * is different from the server computed, 406 Not Accepted will be recieved. * * Sets \a fileSecret as file secret key. ONLY picture spaces support secret. * If this is set, the file could not access directly by URL, * use THUMB_SEPERATOR + SECRET instead. eg, if THUMB_SEPERATOR is "!", * secret is "bac" and file upload path is "/folder/test.jpg", the image accessed * URL will be http://BUCKET/folder/test.jpg!bac. * * Extra parameters should be stored in \a params. * * \sa QUpYun::uploadFile(const QString &, QFile *, bool, bool, const QString &, const RequestParams &) * \sa QUpYun::requestUploadFinished(bool, const PicInfo &) */ void QUpYun::uploadFile(const QString &path, const QString &localPath, bool autoMkdir, bool appendFileMD5, const QString &fileSecret, const RequestParams ¶ms) { QFile file(localPath); uploadFile(path, &file, autoMkdir, appendFileMD5, fileSecret, params); }
bool OnlineAstrometryParser::startSovler(const QString &in_filename, const QStringList &args, bool generated) { bool ok; isGenerated = generated; job_retries=0; if (networkManager->networkAccessible() == false) { align->appendLogText(i18n("Error: No connection to the internet.")); emit solverFailed(); return false; } filename = in_filename; for (int i=0; i < args.count(); i++) { if (args[i] == "-L") lowerScale = args[i+1].toDouble(&ok); else if (args[i] == "-H") upperScale = args[i+1].toDouble(&ok); else if (args[i] == "-3") center_ra = args[i+1].toDouble(&ok); else if (args[i] == "-4") center_dec = args[i+1].toDouble(&ok); else if (args[i] == "-5") radius = args[i+1].toDouble(&ok); else if (args[i] == "--downsample") downsample_factor = args[i+1].toInt(&ok); else if (args[i] == "--parity") { QString arg = args[i+1]; if (arg == "both") parity = 2; else if (arg == "pos") parity = 0; else parity = 1; } } connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onResult(QNetworkReply*))); solverTimer.start(); if (sessionKey.isEmpty()) authenticate(); else uploadFile(); return true; }
void MainLoop::saveUI(PModel& model, Model::GameType type, View::SplashType splashType) { ProgressMeter meter(1.0 / 62500); Square::progressMeter = &meter; view->displaySplash(meter, splashType); string path = getSavePath(model.get(), type); MEASURE(saveGame(model, path), "saving time"); view->clearSplash(); Square::progressMeter = nullptr; if (type == Model::GameType::RETIRED_KEEPER && options->getBoolValue(OptionId::ONLINE)) uploadFile(path); }
bool HttpClient::doMultipartPost() { //如果有Fields段 已经写入了body内 直接发送 if (!sendBody()) { setErrorCode(HTTPERROR_TRANSPORT); return false; } //发送文件 const std::vector<HttpFile*>& post_files = _request->getFiles(); const std::string& boundary = _request->getBoundary(); for (size_t i = 0; i < post_files.size(); i++) { const std::string name = post_files[i]->_name; IHttpPostFile* post_file = post_files[i]->_post_file; std::string file_header = "--" + boundary + "\r\n" "content-disposition: form-data; name=\"" + name + "\"; filename=\"" + post_file->getFilename() + "\"\r\n" + "content-type: " + post_file->getContentType() + "\r\n" + "\r\n"; bool send_file_header = _proxy_socket->writeAll(file_header.c_str(),file_header.size()); if (!send_file_header) { setErrorCode(HTTPERROR_TRANSPORT); return false; } bool post_file_success = uploadFile(post_file); if (!post_file_success) { setErrorCode(HTTPERROR_TRANSPORT); return false; } std::string file_tailer = "\r\n"; bool send_file_tailer = _proxy_socket->writeAll(file_tailer.c_str(),file_tailer.size()); if (!send_file_tailer) { setErrorCode(HTTPERROR_TRANSPORT); return false; } } //发送boundary结束标记 std::string post_tailer = "--" + boundary + "--\r\n"; bool send_post_tailer = _proxy_socket->writeAll(post_tailer.c_str(),post_tailer.size()); return send_post_tailer ? getResponse() : setErrorCode(HTTPERROR_TRANSPORT) , false; }
/* Called when the "upload" action is triggered. Build the current project and upload the resulting .bin to the board. */ void MainWindow::onUpload( ) { if(currentProject.isEmpty()) return statusBar()->showMessage( "Open a project to upload, or create a new one from the File menu.", 3500 ); QDir projectDir(currentProject); projectDir.cd("build"); projectDir.setNameFilters(QStringList() << "*.bin"); QFileInfoList bins = projectDir.entryInfoList(); if(bins.count()) uploadFile(bins.first().filePath()); else return statusBar()->showMessage( "Couldn't find the file to upload for this project.", 3500 ); }
// Main int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); MSG msg; TCHAR szThisPath[MAX_PATH]; DWORD sLen; // Find the path of this program sLen = GetModuleFileName(NULL, szThisPath, MAX_PATH); for(unsigned int i = sLen; i >= 0; i--) { if(szThisPath[i] == _T('\\')) { szThisPath[i] = _T('\0'); break; } } // Set path of where the program is currently running SetCurrentDirectory(szThisPath); // File specified when the application was launched if ( 2 == __argc ) { // Upload file uploadFile(NULL, __targv[1], false); return TRUE; } // Register the window class MyRegisterClass(hInstance); // Attempt to initialize the application if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } // Main program loop while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int) msg.wParam; }
void TestRenderServer::uploadFolder(){ ui->uploadFolderPushButton->setEnabled(false); ui->renderPushButton->setEnabled(false); ui->deletePushButton->setEnabled(false); QString myFolder = ui->nameFolderLineEdit->text(); //QString myServerFolder = ui->nameFolderLineEdit->text(); createListUpload(myFolder,serverPath); fileList = myHash.keys(); if(!fileList.isEmpty()){ uploadFile(fileList[0], myHash[fileList[0]]); } }
bool abb_file_suite::AbbMotionFtpDownloader::handleServiceCall(abb_file_suite::ExecuteProgram::Request &req, abb_file_suite::ExecuteProgram::Response &res) { ROS_INFO("Handling program execution request"); // Check for existence std::ifstream ifh (req.file_path.c_str()); if (!ifh) { ROS_WARN("Could not open file '%s'.", req.file_path.c_str()); return false; } ifh.close(); return uploadFile(ip_ + "/PARTMODULES", req.file_path.c_str()); }
void trayClicked(QSystemTrayIcon::ActivationReason reason) { if (reason == QSystemTrayIcon::DoubleClick) { switch (settings.onDoubleClickAction) { case Settings::ShowSettings: showSettings(); break; case Settings::CaptureScreen: takeArea(); break; case Settings::UploadFile: uploadFile(); break; } } }
// upload a file, i.e. put it on remote fs static INT ExecPut(PAIO_DEV sock, PSERVICE_CONTEXT sc) { int fileSize = atoi(sc->req.fileSize); HANDLE hFile = CreateFileA(sc->req.fileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { printf("Error %d creating file %s!\n", GetLastError(), sc->req.fileName); return FS_ERROR; } int status = uploadFile((SOCKET) sock->dev, hFile, fileSize); CloseHandle(hFile); _itoa_s(status, sc->resp.status, 10); if (!writeResponse(sock->dev, &sc->resp)) return IO_ERROR; return STATUS_OK; }
TestFolderServer::TestFolderServer(QWidget *parent) : QWidget(parent), ui(new Ui::TestFolderServer) { ui->setupUi(this); connect(ui->userLineEdit, SIGNAL(textChanged(QString)), SLOT(activateUpload())); connect(ui->lineEdit, SIGNAL(textChanged(QString)), SLOT(activateUpload())); connect(ui->fileLineEdit, SIGNAL(textChanged(QString)), SLOT(activateUpload())); connect(ui->uploadPushButton, SIGNAL(clicked()), SLOT(uploadFile())); /*ui->fileLineEdit->setText("c:/data/file.txt"); ui->lineEdit->setText("123"); ui->userLineEdit->setText("abc");*/ link = NULL; }
void UploadThread::Run() { DIR *dir = opendir(mSearchDirectory.c_str()); if(dir) { dirent* entry; while((entry = readdir(dir)) != NULL) { std::string entryName = entry->d_name; std::string::size_type extPos = entryName.find_last_of('.'); if(extPos != std::string::npos && entryName.substr(extPos+1) == mSearchExtension) { uploadFile(mSearchDirectory + "/" + entryName); } } } closedir(dir); }
void AutoUpdateManager::onFileChanged(const QString& local_path) { qDebug("[AutoUpdateManager] detected cache file %s changed", local_path.toUtf8().data()); if (!watch_infos_.contains(local_path)) { // filter unwanted events return; } WatchedFileInfo &info = watch_infos_[local_path]; QFileInfo finfo(local_path); // Download the doc file in the mac will automatically upload // If the timestamp has not changed, it will not be uploaded qint64 mtime = finfo.lastModified().toMSecsSinceEpoch(); if (mtime == info.mtime) { qDebug("[AutoUpdateManager] Received a file %s upload notification, but the timestamp has not changed, " "it will not upload", local_path.toUtf8().data()); return; } #ifdef Q_OS_MAC if (MacImageFilesWorkAround::instance()->isRecentOpenedImage(local_path)) { qDebug("[AutoUpdateManager] skip the image file updates on mac for %s", toCStr(local_path)); return; } #endif removePath(&watcher_, local_path); QString repo_id, path_in_repo; if (!finfo.exists()) { qDebug("[AutoUpdateManager] detected cache file %s renamed or removed", local_path.toUtf8().data()); WatchedFileInfo deferred_info = info; removeWatch(local_path); // Some application would deleted and recreate the file when saving. // We work around that by double checking whether the file gets // recreated after a short period QTimer::singleShot(5000, this, SLOT(checkFileRecreated())); deleted_files_infos_.enqueue(deferred_info); return; } uploadFile(local_path); }
void Systray::doDoubleClickAction() { if (s.radioValueIs(Settings::TRAY_CLICK_ACTION, Settings::OPEN_UPLOADS)) { openSaveDirectory(); } else if (s.radioValueIs(Settings::TRAY_CLICK_ACTION, Settings::OPEN_SETTINGS)) { openSettings(); } else if (s.radioValueIs(Settings::TRAY_CLICK_ACTION, Settings::UPLOAD_FILE)) { uploadFile(); } else if (s.radioValueIs(Settings::TRAY_CLICK_ACTION, Settings::CAPTURE_DESKTOP)) { fullScreenScreenshot(); } else if (s.radioValueIs(Settings::TRAY_CLICK_ACTION, Settings::CAPTURE_AREA)) { selectAreaScreenshot(); } else if (s.radioValueIs(Settings::TRAY_CLICK_ACTION, Settings::CAPTURE_WINDOW)) { activeWindowScreenshotTimed(); } else if (s.radioValueIs(Settings::TRAY_CLICK_ACTION, Settings::OPEN_ACCOUNT)) { openAccount(); } else { qDebug() << "Option not recognized"; } }
void abb_file_suite::AbbMotionFtpDownloader::handleJointTrajectory(const trajectory_msgs::JointTrajectory &traj) { ROS_INFO_STREAM("Trajectory received"); // generate temporary file with appropriate rapid code std::ofstream ofh ("/tmp/mGodel_blend.mod"); if (!ofh) { ROS_WARN_STREAM("Could not create file"); return; } std::vector<rapid_emitter::TrajectoryPt> pts; pts.reserve(traj.points.size()); for (std::size_t i = 0; i < traj.points.size(); ++i) { std::vector<double> tmp = toDegrees(traj.points[i].positions); if (j23_coupled_) linkageAdjust(tmp); double duration = 0.0; // Timing if (i > 0) { duration = (traj.points[i].time_from_start - traj.points[i-1].time_from_start).toSec(); } rapid_emitter::TrajectoryPt pt (tmp, duration); pts.push_back(pt); } rapid_emitter::ProcessParams params; params.wolf = false; rapid_emitter::emitJointTrajectoryFile(ofh, pts, params); ofh.close(); // send to controller if (!uploadFile(ip_ + "/PARTMODULES", "/tmp/mGodel_blend.mod")) { ROS_WARN("Could not upload joint trajectory to remote ftp server"); } }
bool FtpMainWindow::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: connectToHost(); break; case 1: languageChange(); break; case 2: uploadFile(); break; case 3: downloadFile(); break; case 4: removeFile(); break; case 5: changePath((const QString&)static_QUType_QString.get(_o+1)); break; case 6: ftp_commandStarted(); break; case 7: ftp_commandFinished(); break; case 8: ftp_done((bool)static_QUType_bool.get(_o+1)); break; case 9: ftp_stateChanged((int)static_QUType_int.get(_o+1)); break; case 10: ftp_listInfo((const QUrlInfo&)*((const QUrlInfo*)static_QUType_ptr.get(_o+1))); break; case 11: ftp_rawCommandReply((int)static_QUType_int.get(_o+1),(const QString&)static_QUType_QString.get(_o+2)); break; case 12: changePathOrDownload((QListViewItem*)static_QUType_ptr.get(_o+1)); break; default: return QMainWindow::qt_invoke( _id, _o ); } return TRUE; }
OnlineAstrometryParser::OnlineAstrometryParser() : AstrometryParser() { job_retries=0; solver_retries=0; networkManager = new QNetworkAccessManager(this); connect(this, SIGNAL(authenticateFinished()), this, SLOT(uploadFile())); connect(this, SIGNAL(uploadFinished()), this, SLOT(getJobID())); connect(this, SIGNAL(jobIDFinished()), this, SLOT(checkJobs())); connect(this, SIGNAL(jobFinished()), this, SLOT(checkJobCalibration())); // Reset parity on solver failure connect(this, &OnlineAstrometryParser::solverFailed, this, [&]() { parity = -1;}); connect(this, SIGNAL(solverFailed()), this, SLOT(resetSolver())); connect(this, SIGNAL(solverFinished(double,double,double, double)), this, SLOT(resetSolver())); downsample_factor = 0; isGenerated = true; }
// �E�B���h�E�v���V�[�W�� LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; static BOOL onClip = FALSE; static BOOL firstDraw = TRUE; static RECT clipRect = {0, 0, 0, 0}; switch (message) { case WM_RBUTTONDOWN: // �L�����Z�� DestroyWindow(hWnd); return DefWindowProc(hWnd, message, wParam, lParam); break; case WM_TIMER: // ESC�L�[�����̌��m if (GetKeyState(VK_ESCAPE) & 0x8000){ DestroyWindow(hWnd); return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_MOUSEMOVE: if (onClip) { // �V�������W���Z�b�g clipRect.right = LOWORD(lParam) + ofX; clipRect.bottom = HIWORD(lParam) + ofY; hdc = GetDC(NULL); drawRubberband(hdc, &clipRect, FALSE); ReleaseDC(NULL, hdc); } break; case WM_LBUTTONDOWN: { // �N���b�v�J�n onClip = TRUE; // �����ʒu���Z�b�g clipRect.left = LOWORD(lParam) + ofX; clipRect.top = HIWORD(lParam) + ofY; // �}�E�X���L���v�`�� SetCapture(hWnd); } break; case WM_LBUTTONUP: { // �N���b�v�I�� onClip = FALSE; // �}�E�X�̃L���v�`�������� ReleaseCapture(); // �V�������W���Z�b�g clipRect.right = LOWORD(lParam) + ofX; clipRect.bottom = HIWORD(lParam) + ofY; // ��ʂɒ��ڕ`��C���Č` HDC hdc = GetDC(NULL); // �������� drawRubberband(hdc, &clipRect, TRUE); // ���W�`�F�b�N if ( clipRect.right < clipRect.left ) { int tmp = clipRect.left; clipRect.left = clipRect.right; clipRect.right = tmp; } if ( clipRect.bottom < clipRect.top ) { int tmp = clipRect.top; clipRect.top = clipRect.bottom; clipRect.bottom = tmp; } // �摜�̃L���v�`�� int iWidth, iHeight; iWidth = clipRect.right - clipRect.left + 1; iHeight = clipRect.bottom - clipRect.top + 1; if(iWidth == 0 || iHeight == 0) { // �摜�ɂȂ��ĂȂ�, �Ȃɂ����Ȃ� ReleaseDC(NULL, hdc); DestroyWindow(hWnd); break; } // �r�b�g�}�b�v�o�b�t�@���쐬 HBITMAP newBMP = CreateCompatibleBitmap(hdc, iWidth, iHeight); HDC newDC = CreateCompatibleDC(hdc); // �֘A�Â� SelectObject(newDC, newBMP); // �摜���擾 BitBlt(newDC, 0, 0, iWidth, iHeight, hdc, clipRect.left, clipRect.top, SRCCOPY); // �E�B���h�E���B��! ShowWindow(hWnd, SW_HIDE); /* // �摜���N���b�v�{�[�h�ɃR�s�[ if ( OpenClipboard(hWnd) ) { // ���� EmptyClipboard(); // �Z�b�g SetClipboardData(CF_BITMAP, newBMP); // ���� CloseClipboard(); } */ // �e���|�����t�@�C���������� TCHAR tmpDir[MAX_PATH], tmpFile[MAX_PATH]; GetTempPath(MAX_PATH, tmpDir); GetTempFileName(tmpDir, _T("gya"), 0, tmpFile); if (savePNG(tmpFile, newBMP)) { // ���� if (!uploadFile(hWnd, tmpFile)) { // �A�b�v���[�h�Ɏ��s... // �G���[���b�Z�[�W�͊��ɕ\������Ă��� /* TCHAR sysDir[MAX_PATH]; if (SUCCEEDED(StringCchCopy(sysDir, MAX_PATH, tmpFile)) && SUCCEEDED(StringCchCat(sysDir, MAX_PATH, _T(".png")))) { MoveFile(tmpFile, sysDir); SHELLEXECUTEINFO lsw = {0}; lsw.hwnd = hWnd; lsw.cbSize = sizeof(SHELLEXECUTEINFO); lsw.lpVerb = _T("open"); lsw.lpFile = sysDir; ShellExecuteEx(&lsw); } */ } } else { // PNG�ۑ����s... MessageBox(hWnd, _T("Cannot save png image"), szTitle, MB_OK | MB_ICONERROR); } // ��n�� DeleteFile(tmpFile); DeleteDC(newDC); DeleteObject(newBMP); ReleaseDC(NULL, hdc); DestroyWindow(hWnd); PostQuitMessage(0); } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// ウィンドウプロシージャ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; static BOOL onClip = FALSE; static BOOL firstDraw = TRUE; static RECT clipRect = {0, 0, 0, 0}; switch (message) { case WM_RBUTTONDOWN: // キャンセル DestroyWindow(hWnd); return DefWindowProc(hWnd, message, wParam, lParam); break; case WM_TIMER: // ESCキー押下の検知 if (GetKeyState(VK_ESCAPE) & 0x8000){ DestroyWindow(hWnd); return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_MOUSEMOVE: if (onClip) { // 新しい座標をセット clipRect.right = LOWORD(lParam) + ofX; clipRect.bottom = HIWORD(lParam) + ofY; hdc = GetDC(NULL); drawRubberband(hdc, &clipRect, FALSE); ReleaseDC(NULL, hdc); } break; case WM_LBUTTONDOWN: { // クリップ開始 onClip = TRUE; // 初期位置をセット clipRect.left = LOWORD(lParam) + ofX; clipRect.top = HIWORD(lParam) + ofY; // マウスをキャプチャ SetCapture(hWnd); } break; case WM_LBUTTONUP: { // クリップ終了 onClip = FALSE; // マウスのキャプチャを解除 ReleaseCapture(); // 新しい座標をセット clipRect.right = LOWORD(lParam) + ofX; clipRect.bottom = HIWORD(lParam) + ofY; // 画面に直接描画,って形 HDC hdc = GetDC(NULL); // 線を消す drawRubberband(hdc, &clipRect, TRUE); // 座標チェック if ( clipRect.right < clipRect.left ) { int tmp = clipRect.left; clipRect.left = clipRect.right; clipRect.right = tmp; } if ( clipRect.bottom < clipRect.top ) { int tmp = clipRect.top; clipRect.top = clipRect.bottom; clipRect.bottom = tmp; } // 画像のキャプチャ int iWidth, iHeight; iWidth = clipRect.right - clipRect.left + 1; iHeight = clipRect.bottom - clipRect.top + 1; if(iWidth == 0 || iHeight == 0) { // 画像になってない, なにもしない ReleaseDC(NULL, hdc); DestroyWindow(hWnd); break; } // ビットマップバッファを作成 HBITMAP newBMP = CreateCompatibleBitmap(hdc, iWidth, iHeight); HDC newDC = CreateCompatibleDC(hdc); // 関連づけ SelectObject(newDC, newBMP); // 画像を取得 BitBlt(newDC, 0, 0, iWidth, iHeight, hdc, clipRect.left, clipRect.top, SRCCOPY); // ウィンドウを隠す! ShowWindow(hWnd, SW_HIDE); /* // 画像をクリップボードにコピー if ( OpenClipboard(hWnd) ) { // 消去 EmptyClipboard(); // セット SetClipboardData(CF_BITMAP, newBMP); // 閉じる CloseClipboard(); } */ // テンポラリファイル名を決定 TCHAR tmpDir[MAX_PATH], tmpFile[MAX_PATH]; GetTempPath(MAX_PATH, tmpDir); GetTempFileName(tmpDir, _T("gya"), 0, tmpFile); if (savePNG(tmpFile, newBMP)) { // うp if (!uploadFile(hWnd, tmpFile)) { // アップロードに失敗... // エラーメッセージは既に表示されている /* TCHAR sysDir[MAX_PATH]; if (SUCCEEDED(StringCchCopy(sysDir, MAX_PATH, tmpFile)) && SUCCEEDED(StringCchCat(sysDir, MAX_PATH, _T(".png")))) { MoveFile(tmpFile, sysDir); SHELLEXECUTEINFO lsw = {0}; lsw.hwnd = hWnd; lsw.cbSize = sizeof(SHELLEXECUTEINFO); lsw.lpVerb = _T("open"); lsw.lpFile = sysDir; ShellExecuteEx(&lsw); } */ } } else { // PNG保存失敗... MessageBox(hWnd, _T("Cannot save png image"), szTitle, MB_OK | MB_ICONERROR); } // 後始末 DeleteFile(tmpFile); DeleteDC(newDC); DeleteObject(newBMP); ReleaseDC(NULL, hdc); DestroyWindow(hWnd); PostMessage(hWnd,WM_CLOSE,0,0); // PostQuitMessage(0); } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// エントリーポイント int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); MSG msg; TCHAR szThisPath[MAX_PATH]; DWORD sLen; // 自身のディレクトリを取得する sLen = GetModuleFileName(NULL, szThisPath, MAX_PATH); for(unsigned int i = sLen; i >= 0; i--) { if(szThisPath[i] == _T('\\')) { szThisPath[i] = _T('\0'); break; } } // カレントディレクトリを exe と同じ場所に設定 SetCurrentDirectory(szThisPath); // 引数にファイルが指定されていたら if ( 2 == __argc ) { // ファイルをアップロードして終了 if (isPng(__targv[1])) { // PNG はそのままupload uploadFile(NULL, __targv[1]); }else { // PNG 形式に変換 TCHAR tmpDir[MAX_PATH], tmpFile[MAX_PATH]; GetTempPath(MAX_PATH, tmpDir); GetTempFileName(tmpDir, _T("gya"), 0, tmpFile); if (convertPNG(tmpFile, __targv[1])) { //アップロード uploadFile(NULL, tmpFile); } else { // PNGに変換できなかった... MessageBox(NULL, _T("Cannot convert this image"), szTitle, MB_OK | MB_ICONERROR); } DeleteFile(tmpFile); } return TRUE; } // ウィンドウクラスを登録 MyRegisterClass(hInstance); // アプリケーションの初期化を実行します: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } // メイン メッセージ ループ: while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int) msg.wParam; }
void loop() { if (safeMode) { // safeMode engaged, enter blocking loop wait for an OTA update int safeDelay=30000; // five minutes in 100ms counts while (safeDelay--) { ArduinoOTA.handle(); delay(100); } ESP.reset(); // restart, try again delay(5000); // give esp time to reboot } if(wifiMulti.run() != WL_CONNECTED) { // reboot if wifi connection drops ESP.reset(); delay(5000); } if (!mqtt.connected()) { mqttreconnect(); // check mqqt status } doTick(); if (hasRSSI) doRSSI(); if (hasTout) doTout(); if (hasVout) doVout(); if (hasIout) doIout(); if (getRGB) doRGBout(); if (hasSpeed) doSpeed(); if ( (doUpdate) || (updateCnt>= 60 / ((updateRate * 20) / 1000) ) ) runUpdate(); // check for config update as requested or every 60 loops if (wsConcount>0) wsData(); if (useMQTT) mqttData(); // regular update for non RGB controllers if (prtConfig) printConfig(); // config print was requested sprintf(str,"Sleeping in %u seconds.", (updateRate*20/1000)); if ((!skipSleep) && (sleepEn)) { if (useMQTT) mqtt.publish(mqttpub, str); } int cnt = 30; if (updateRate>30) cnt=updateRate; while(cnt--) { ArduinoOTA.handle(); if (useMQTT) mqtt.loop(); #ifndef _MINI httpd.handleClient(); #endif webSocket.loop(); if (getTime) updateNTP(); // update time if requested by command if (scanI2C) i2c_scan(); if (hasRGB) doRGB(); // rgb updates as fast as possible if (rgbTest) testRGB(); #ifndef _MINI if (doUpload) { // upload file to spiffs by command doUpload = false; fileSet = false; int stat = uploadFile(fileName, fileURL); sprintf(str, "Upload complete: %s %d bytes.",fileName,stat); if (useMQTT) mqtt.publish(mqttpub, str); } #endif if (setPolo) { setPolo = false; // respond to an mqtt 'ping' of sorts if (useMQTT) mqtt.publish(mqttpub, "Polo"); } if (doReset) { // reboot on command if (useMQTT) { mqtt.publish(mqttpub, "Rebooting!"); mqtt.loop(); } delay(50); ESP.reset(); delay(5000); // allow time for reboot } if (!hasRGB) delay(20); // don't delay for rgb controller } if ((!skipSleep) && (sleepEn)) { if ((sleepPeriod<60) || (sleepPeriod>43200)) sleepPeriod=900; // prevent sleeping for less than 1 minute or more than 12 hours sprintf(myChr,"Back in %d minutes", sleepPeriod/60); if (useMQTT) { mqtt.publish(mqttpub, myChr); mqtt.loop(); } ESP.deepSleep(1000000 * sleepPeriod, WAKE_RF_DEFAULT); // sleep for 15 min delay(5000); // give esp time to fall asleep } skipSleep = false; updateCnt++; }
int main(int argc, char* argv[]){ const char* options[] = {"-u", "upload", "-d", "download", \ "-h", "help", "-l", "list", "-r", "remove", 0}; int op; if (argc != 3 && argc != 2){ helpInfo(); return 0; } op = getOption(options, argv[1]); switch(op){ case 0: case 1: if (argc == 2){ fprintf(stdout, "Please input the filename!\n"); exit(0); } if (access(argv[2], R_OK)){ fprintf(stdout, "File '%s' not exists,\n", argv[2]); fprintf(stdout, "Or permession denied.\n"); fprintf(stdout, "Please check the filename.\n"); exit(0); } if(!uploadFile(argv[2])) fprintf(stdout, "Upload %s success\n", argv[2]); break; case 2: case 3: if (argc == 2){ fprintf(stdout, "Please input the filename!\n"); exit(0); } if(!downloadFile(argv[2])) fprintf(stdout, "Downloadload %s success\n", argv[2]); break; case 4: case 5: helpInfo(); break; case 6: case 7: if (argc == 2){ fprintf(stdout, "Please input the filename!\n"); exit(0); } dfsList(argv[2]); break; case 8: case 9: if (argc == 2){ fprintf(stdout, "Please input the filename!\n"); exit(0); } if (!dfsRemove(argv[2])) fprintf(stdout, "Delete %s success\n", argv[2]); break; default: exit(-1); } exit(0); }
// �G���g���[�|�C���g int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); MSG msg; TCHAR szThisPath[MAX_PATH]; DWORD sLen; // ���g�̃f�B���N�g�����擾���� sLen = GetModuleFileName(NULL, szThisPath, MAX_PATH); for(unsigned int i = sLen; i >= 0; i--) { if(szThisPath[i] == _T('\\')) { szThisPath[i] = _T('\0'); break; } } // �J�����g�f�B���N�g���� exe �Ɠ����ꏊ�ɐݒ� SetCurrentDirectory(szThisPath); // �����Ƀt�@�C�����w�肳��Ă����� if ( 2 == __argc ) { // �t�@�C�����A�b�v���[�h���ďI�� if (isPng(__targv[1])) { // PNG �͂��̂܂�upload uploadFile(NULL, __targv[1]); }else { // PNG �`���ɕϊ� TCHAR tmpDir[MAX_PATH], tmpFile[MAX_PATH]; GetTempPath(MAX_PATH, tmpDir); GetTempFileName(tmpDir, _T("gya"), 0, tmpFile); if (convertPNG(tmpFile, __targv[1])) { //�A�b�v���[�h uploadFile(NULL, tmpFile); } else { // PNG�ɕϊ��ł��Ȃ�����... MessageBox(NULL, _T("Cannot convert this image"), szTitle, MB_OK | MB_ICONERROR); } DeleteFile(tmpFile); } return TRUE; } // �E�B���h�E�N���X��o�^ MyRegisterClass(hInstance); // �A�v���P�[�V�����̏����������s���܂�: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } // ���C�� ���b�Z�[�W ���[�v: while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int) msg.wParam; }
/* * Constructs a FtpMainWindow as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * */ FtpMainWindow::FtpMainWindow( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ), image0( (const char **) image0_data ), image1( (const char **) image1_data ), image2( (const char **) image2_data ), image3( (const char **) image3_data ) { (void)statusBar(); if ( !name ) setName( "FtpMainWindow" ); setCentralWidget( new QWidget( this, "qt_central_widget" ) ); FtpMainWindowLayout = new QGridLayout( centralWidget(), 1, 1, 11, 6, "FtpMainWindowLayout"); remoteView = new QListView( centralWidget(), "remoteView" ); remoteView->addColumn( tr( "Name" ) ); remoteView->addColumn( tr( "Size" ) ); remoteView->addColumn( tr( "Last Modified" ) ); remoteView->setShowSortIndicator( TRUE ); FtpMainWindowLayout->addMultiCellWidget( remoteView, 1, 1, 0, 1 ); remotePath = new QComboBox( FALSE, centralWidget(), "remotePath" ); remotePath->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, remotePath->sizePolicy().hasHeightForWidth() ) ); remotePath->setEditable( TRUE ); remotePath->setDuplicatesEnabled( FALSE ); FtpMainWindowLayout->addWidget( remotePath, 0, 1 ); TextLabel4 = new QLabel( centralWidget(), "TextLabel4" ); FtpMainWindowLayout->addWidget( TextLabel4, 0, 0 ); // actions fileDownloadAction = new QAction( this, "fileDownloadAction" ); fileDownloadAction->setIconSet( QIconSet( image0 ) ); fileDownloadAction->setAccel( 0 ); fileExitAction = new QAction( this, "fileExitAction" ); fileExitAction->setAccel( 0 ); fileRemoveAction = new QAction( this, "fileRemoveAction" ); fileRemoveAction->setIconSet( QIconSet( image1 ) ); fileUploadAction = new QAction( this, "fileUploadAction" ); fileUploadAction->setIconSet( QIconSet( image2 ) ); fileConnectAction = new QAction( this, "fileConnectAction" ); fileConnectAction->setIconSet( QIconSet( image3 ) ); // toolbars toolBar = new QToolBar( QString(""), this, DockTop ); fileConnectAction->addTo( toolBar ); fileDownloadAction->addTo( toolBar ); fileUploadAction->addTo( toolBar ); fileRemoveAction->addTo( toolBar ); // menubar menubar = new QMenuBar( this, "menubar" ); fileMenu = new QPopupMenu( this ); fileConnectAction->addTo( fileMenu ); fileDownloadAction->addTo( fileMenu ); fileUploadAction->addTo( fileMenu ); fileRemoveAction->addTo( fileMenu ); fileMenu->insertSeparator(); fileExitAction->addTo( fileMenu ); menubar->insertItem( QString(""), fileMenu, 1 ); languageChange(); resize( QSize(600, 480).expandedTo(minimumSizeHint()) ); clearWState( WState_Polished ); // signals and slots connections connect( fileExitAction, SIGNAL( activated() ), this, SLOT( close() ) ); connect( fileDownloadAction, SIGNAL( activated() ), this, SLOT( downloadFile() ) ); connect( fileRemoveAction, SIGNAL( activated() ), this, SLOT( removeFile() ) ); connect( fileUploadAction, SIGNAL( activated() ), this, SLOT( uploadFile() ) ); connect( fileConnectAction, SIGNAL( activated() ), this, SLOT( connectToHost() ) ); connect( remotePath, SIGNAL( activated(const QString&) ), this, SLOT( changePath(const QString&) ) ); connect( remoteView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( changePathOrDownload(QListViewItem*) ) ); connect( remoteView, SIGNAL( returnPressed(QListViewItem*) ), this, SLOT( changePathOrDownload(QListViewItem*) ) ); // buddies TextLabel4->setBuddy( remotePath ); init(); }
void App::Go() { ofstream log("Log.txt"); string defaultTitle = "Model name unknown"; string defaultTags = "Component"; vector<string> modelList = Utility::GetFileLines("StanfordSceneDBModels.txt", 3); for(const string &id : modelList) { string description = "This is a model re-uploaded to 3D Warehouse for the Stanford Scene Database.\nIf still available, the original model can be found at: http://sketchup.google.com/3dwarehouse/details?mid=" + id + "\nSee http://graphics.stanford.edu/projects/scenesynth/ for more information."; _skpFiles[id] = SkpFileInfo(id, "C:\\SceneModeling\\Database\\SketchUp\\" + id + ".skp", defaultTitle + ". ID=" + id, description, defaultTags); } vector<string> modelNames = Utility::GetFileLines("names.txt", 3); vector<string> modelTags = Utility::GetFileLines("tags.txt", 3); for(const string &s : modelNames) { vector<string> parts = Utility::PartitionString(s, "|"); string id = parts[0]; if(_skpFiles.find(id) != _skpFiles.end()) { if(parts[1] == "*") parts[1] = "Unnammed model"; _skpFiles[id].title = parts[1] + ". ID=" + parts[0]; } } for(const string &s : modelTags) { vector<string> parts = Utility::PartitionString(s, "|"); string id = parts[0]; if(_skpFiles.find(id) != _skpFiles.end()) { string tags; for(UINT i = 1; i < parts.size(); i++) { tags += parts[i] + ","; } if(tags.length() > 0) { tags.pop_back(); _skpFiles[id].tags = tags; } } } //PartitionString(const string &s, const string &separator) //_skpFiles.push_back(SkpFileInfo("C:\\SceneModeling\\Database\\SketchUp\\1a0c94a2e3e67e4a2e4877b52b3fca7.skp", "TITLE A!!!! AN OBJECT!!!", "DESCRIPTION!!! Here is some stuff that is sort of long and convoluted.", "TAGS!!!! APPLE ORANGE COUCH POTATO RUBIK'S CUBE")); //_skpFiles.push_back(SkpFileInfo("C:\\SceneModeling\\Database\\SketchUp\\1a1a7da3b8028d19cb98ab132d4b77f1.skp", "TITLE B!!!! AN OBJECT!!!", "DESCRIPTION!!! Here is some stuff that is sort of long and convoluted.", "TAGS!!!! APPLE ORANGE COUCH POTATO RUBIK'S CUBE")); //_skpFiles.push_back(SkpFileInfo("C:\\SceneModeling\\Database\\SketchUp\\1a1cfc219ddbae7f86e0b9bedd915f08.skp", "TITLE C!!!! AN OBJECT!!!", "DESCRIPTION!!! Here is some stuff that is sort of long and convoluted.", "TAGS!!!! APPLE ORANGE COUCH POTATO RUBIK'S CUBE")); //_skpFiles.push_back(SkpFileInfo("C:\\SceneModeling\\Database\\SketchUp\\1a1ec1cfe633adcdebbf11b1629fc16a.skp", "TITLE D!!!! AN OBJECT!!!", "DESCRIPTION!!! Here is some stuff that is sort of long and convoluted.", "TAGS!!!! APPLE ORANGE COUCH POTATO RUBIK'S CUBE")); BlockOnKey(KEY_NUMPADADD); for(const auto &pair : _skpFiles) { const auto &s = pair.second; if(Utility::FileExists("uploaded/" + s.id + ".dat")) { log << "Skipping " << s.id << endl; cout << "Skipping " << s.id << endl; } else { ofstream uploadFile(("uploaded/" + s.id + ".dat").c_str()); // // TODO: check if already exported (probably by creating a dummy file when we successfully upload? // log << "Uploading " << s.id << endl; cout << "Uploading " << s.id << endl; // // Load the filename to load onto the clipboard // CopyStringToClipboard(s.filename); SendKey(KEY_O, true, false); SendKey(KEY_V, true, false); SendKey(KEY_ENTER, false, false); Sleep(1000); log << "Clearing annoying save dialog" << endl; cout << "Clearing annoying save dialog" << endl; SendKey(KEY_ENTER, false, false); log << "Waiting for file load to finish" << endl; cout << "Waiting for file load to finish" << endl; Sleep(5000); SendKey(KEY_F, false, true); SendKey(KEY_3, false, false); SendKey(KEY_ENTER, false, false); SendKey(KEY_S, false, false); log << "Clearing remove unused objects window" << endl; cout << "Clearing remove unused objects window" << endl; Sleep(1000); SendKey(KEY_ENTER, false, false); log << "Saving model" << endl; cout << "Saving model" << endl; Sleep(1000); SendKey(KEY_S, true, false); SendKey(KEY_ENTER, false, false); log << "Waiting for upload page to load" << endl; cout << "Waiting for upload page to load" << endl; Sleep(1000); log << "Clicking to set focus on title" << endl; cout << "Clicking to set focus on title" << endl; ClickMouse(mouseXTitle, mouseYTitle); Sleep(1000); log << "Inputting fields" << endl; cout << "Inputting fields" << endl; CopyStringToClipboard(s.title); SendKey(KEY_V, true, false); SendKey(KEY_TAB, false, false); CopyStringToClipboard(s.description); SendKey(KEY_V, true, false); SendKey(KEY_TAB, false, false); CopyStringToClipboard(s.tags); SendKey(KEY_V, true, false); SendKey(KEY_TAB, false, false); SendKey(KEY_TAB, false, false); Sleep(500); SendKey(KEY_ENTER, false, false); log << "Waiting for upload to finish" << endl; cout << "Waiting for upload to finish" << endl; Sleep(30000); log << "Exiting browser" << endl; cout << "Exiting browser" << endl; ClickMouse(mouseXClose, mouseYClose); Sleep(1000); if(GetAsyncKeyState(VK_ESCAPE)) { BlockOnKey(KEY_NUMPADADD); } } } }