std::vector<Osp::Base::String> ActionsManager::split(Osp::Base::String toBeSplitted, char separator) { std::vector<Osp::Base::String> res; int length = toBeSplitted.GetLength(); int cursor = 0; while(cursor<length) { Osp::Base::String subString; bool charFound = false; for(int i=cursor;i<length && !charFound; i++) { mchar charToAdd; toBeSplitted.GetCharAt(i,charToAdd); if(charToAdd == separator) charFound = true; else subString.Append(charToAdd); cursor++; } res.push_back(subString); } return res; }
void FormMgr::SwitchToForm(RequestId requestId, Osp::Base::Collection::IList* pArgs) { Frame *pFrame = Application::GetInstance()->GetAppFrame()->GetFrame(); if (requestId == REQUEST_MAINFORM) { FMainForm* pExeForm = new FMainForm(); pExeForm->Initialize(); pFrame->AddControl(*pExeForm); pFrame->SetCurrentForm(*pExeForm); pExeForm->Draw(); pExeForm->Show(); if (__pPreviousForm != null) pFrame->RemoveControl(*__pPreviousForm); __pPreviousForm = pExeForm; } else if (requestId == REQUEST_CAMERAFORM) { Integer * arg1 = static_cast<Integer*>(pArgs->GetAt(0)); int sinterval = arg1->ToInt(); Osp::Graphics::Dimension * arg2 = static_cast<Osp::Graphics::Dimension*>(pArgs->GetAt(1)); Osp::Graphics::Dimension sresolution; sresolution.SetSize(arg2->width,arg2->height); Integer * arg3 = static_cast<Integer*>(pArgs->GetAt(2)); int sstopafter = arg3->ToInt(); FCameraForm* pExeForm = new FCameraForm(); pExeForm->Initialize(); pFrame->AddControl(*pExeForm); pFrame->SetCurrentForm(*pExeForm); pExeForm->Draw(); pExeForm->Show(); pExeForm->StartCamera(sinterval, sresolution, sstopafter); if (__pPreviousForm != null) pFrame->RemoveControl(*__pPreviousForm); __pPreviousForm = pExeForm; } else if (requestId == REQUEST_PLAYERFORM) { Osp::Base::String filename = L""; bool autoplay = false; Osp::Base::String * arg1 = static_cast<Osp::Base::String*>(pArgs->GetAt(0)); if (pArgs->GetCount() >= 2) { Osp::Base::Boolean * arg2 = static_cast<Osp::Base::Boolean*>(pArgs->GetAt(1)); autoplay = arg2->ToBool(); } filename.Append(*arg1); FPlayer* pExeForm = new FPlayer(); pExeForm->Initialize(); pFrame->AddControl(*pExeForm); pFrame->SetCurrentForm(*pExeForm); pExeForm->Draw(); pExeForm->Show(); pExeForm->LoadFile(filename, autoplay); if (__pPreviousForm != null) pFrame->RemoveControl(*__pPreviousForm); __pPreviousForm = pExeForm; } }
void SimpleCache::BuildPathForCacheDirectory(Osp::Base::String &dirPath) { dirPath = L"/Home"; dirPath.Append("/"); dirPath.Append(_cacheName); }
void FPlayer::OnActionPerformed(const Osp::Ui::Control& source, int actionId) { if (actionId == ABACK) { Frame *pFrame = Application::GetInstance()->GetAppFrame()->GetFrame(); FormMgr *pFormMgr = static_cast<FormMgr *>(pFrame->GetControl("FormMgr")); pFormMgr->SendUserEvent(FormMgr::REQUEST_MAINFORM, null); } else if (actionId == APLAYPAUSE) { HideControlsTimer_->Cancel(); infobtn->SetShowState(pPlayerThread_->playing); deletebtn->SetShowState(pPlayerThread_->playing); exportbtn->SetShowState(pPlayerThread_->playing); //editbtn->SetShowState(pPlayerThread_->playing); nextframebtn->SetShowState(pPlayerThread_->playing); prevframebtn->SetShowState(pPlayerThread_->playing); speedbtn->SetShowState(pPlayerThread_->playing); if (pPlayerThread_->playing == true) { playpausebtn->SetNormalBackgroundBitmap(*playpausebtnbmpn_); playpausebtn->SetPressedBackgroundBitmap(*playpausebtnbmps_); controlsarevisible = true; backbtn->SetShowState(true); playpausebtn->SetShowState(true); } else { playpausebtn->SetNormalBackgroundBitmap(*playpausepausebtnbmpn_); playpausebtn->SetPressedBackgroundBitmap(*playpausepausebtnbmps_); } RedrawDisplayBuffer(displaybuffer_->GetBounds()); this->RequestRedraw(); if (pPlayerThread_->playing != true) { Osp::System::PowerManager::KeepScreenOnState(true, false); HideControlsTimer_->Start(2000); } else { Osp::System::PowerManager::KeepScreenOnState(false, true); } pPlayerThread_->SendUserEvent(pPlayerThread_->THREAD_PLAYPAUSE, null); } else if (actionId == APREVFRAME) { if (pPlayerThread_->playing != true) { pPlayerThread_->SendUserEvent(pPlayerThread_->THREAD_PREVFRAME, null); } } else if (actionId == ANEXTFRAME) { if (pPlayerThread_->playing != true) { pPlayerThread_->SendUserEvent(pPlayerThread_->THREAD_NEXTFRAME, null); } } else if (actionId == ADELETEVIDEO) { if (pPlayerThread_->playing != true) { MessageBox msgbox; int modalResult = 0; msgbox.Construct("Delete?", "Do you want to delete video?", MSGBOX_STYLE_YESNO, 0); msgbox.ShowAndWait(modalResult); if (modalResult == MSGBOX_RESULT_YES) { Osp::Base::String filename = pPlayerThread_->filename; pPlayerThread_->Stop(); pPlayerThread_->Join(); delete pPlayerThread_; pPlayerThread_ = null; if (Osp::Io::File::IsFileExist(filename)) { Osp::Io::File::Remove(filename); } Frame *pFrame = Application::GetInstance()->GetAppFrame()->GetFrame(); FormMgr *pFormMgr = static_cast<FormMgr *>(pFrame->GetControl("FormMgr")); pFormMgr->SendUserEvent(FormMgr::REQUEST_MAINFORM, null); } } } else if (actionId == ASHOWINFO) { if (pPlayerThread_->playing != true) { Osp::Base::String strvalue; Osp::Ui::Controls::Label * infopopuplresel_ = static_cast<Label *>(infopopup_->GetControl(L"LBLRES")); Osp::Ui::Controls::Label * infopopupstimeel_ = static_cast<Label *>(infopopup_->GetControl(L"LBLSTIME")); Osp::Ui::Controls::Label * infopopupetimeel_ = static_cast<Label *>(infopopup_->GetControl(L"LBLETIME")); Osp::Ui::Controls::Label * infopopupframesel_ = static_cast<Label *>(infopopup_->GetControl(L"LBLFRAMES")); Osp::Ui::Controls::Label * infopopupfilesizeel_ = static_cast<Label *>(infopopup_->GetControl(L"LBLFILESIZE")); Osp::Ui::Controls::Label * infopopupftimeel_ = static_cast<Label *>(infopopup_->GetControl(L"LBLFTIME")); Osp::Ui::Controls::Label * infopopupframenel_ = static_cast<Label *>(infopopup_->GetControl(L"LBLFRAMEN")); Osp::Ui::Controls::Label * infopopupframesizeel_ = static_cast<Label *>(infopopup_->GetControl(L"LBLFRAMESIZE")); infopopuplresel_->SetText(Osp::Base::Integer::ToString(pPlayerThread_->resolution.width) + L"x" + Osp::Base::Integer::ToString(pPlayerThread_->resolution.height)); infopopupstimeel_->SetText(pPlayerThread_->startframetime.ToString()); infopopupetimeel_->SetText(pPlayerThread_->endframetime.ToString()); infopopupframesel_->SetText(Osp::Base::Integer::ToString(pPlayerThread_->framescount)); if (pPlayerThread_->filesize > 1048576) { strvalue = L""; strvalue.Format(25,L"%.2f",(double)(pPlayerThread_->filesize / 1048576.0f)); strvalue.Append(L" Mb"); } else { strvalue = L""; strvalue.Append((int)(pPlayerThread_->filesize / 1024)); strvalue.Append(L" Kb"); } infopopupfilesizeel_->SetText(strvalue); infopopupftimeel_->SetText(pPlayerThread_->curframedatetime.ToString()); infopopupframenel_->SetText(Osp::Base::Integer::ToString(pPlayerThread_->curframe)); if (pPlayerThread_->curframesize > 1048576) { strvalue = L""; strvalue.Format(25,L"%.2f",(double)(pPlayerThread_->curframesize / 1048576.0f)); strvalue.Append(L" Mb"); } else { strvalue = L""; strvalue.Append((int)(pPlayerThread_->curframesize / 1024)); strvalue.Append(L" Kb"); } infopopupframesizeel_->SetText(strvalue); infopopup_->SetShowState(true); infopopup_->Show(); } } else if (actionId == ACLOSEINFO) { infopopup_->SetShowState(false); this->RequestRedraw(); } else if (actionId == AEXPORT) { if (pPlayerThread_->playing != true) { if (exportfilenameset == false) { Osp::Ui::Controls::EditField * exportpopupfilenameel_ = static_cast<EditField *>(exportpopup_->GetControl(L"IDC_EDITFIELD1")); Osp::Base::String outfn; outfn = Osp::Io::File::GetFileName(pPlayerThread_->filename); outfn.Replace(L".tlv", L".avi"); exportpopupfilenameel_->SetText(outfn); exportpopupfilenameel_->RequestRedraw(); exportfilenameset = true; } exportpopup_->SetShowState(true); exportpopup_->Show(); } } else if (actionId == AEXPORTTYPESWITCH) { Osp::Ui::Controls::EditField * exportpopupfilenameel_ = static_cast<EditField *>(exportpopup_->GetControl(L"IDC_EDITFIELD1")); Osp::Base::String outfn; outfn = Osp::Io::File::GetFileName(pPlayerThread_->filename); Osp::Ui::Controls::Button * exportpopupswitchbtn_ = static_cast<Button *>(exportpopup_->GetControl(L"IDC_BUTTON5")); Osp::Ui::Controls::Label * exportpopupswitchlabel_ = static_cast<Label *>(exportpopup_->GetControl(L"IDC_LABEL2")); if (exporttotype == EXPORTTYPE_VIDEO) { exporttotype = EXPORTTYPE_FRAME; } else if (exporttotype == EXPORTTYPE_FRAME) { exporttotype = EXPORTTYPE_VIDEO; } if (exporttotype == EXPORTTYPE_VIDEO) { exportpopupswitchlabel_->SetText(L"Video file"); exportpopupswitchbtn_->SetText(L"Frame image"); outfn.Replace(L".tlv", L".avi"); } else if (exporttotype == EXPORTTYPE_FRAME) { exportpopupswitchlabel_->SetText(L"Frame image"); exportpopupswitchbtn_->SetText(L"Video file"); outfn.Replace(L".tlv", L".jpg"); } exportpopupswitchlabel_->Draw(); exportpopupswitchlabel_->Show(); exportpopupswitchbtn_->Draw(); exportpopupswitchbtn_->Show(); exportpopupfilenameel_->SetText(outfn); exportpopupfilenameel_->RequestRedraw(); } else if (actionId == AEDIT) { if (pPlayerThread_->playing != true) { //open edit form } } else if (actionId == AEXPORTCANCEL) { exportpopup_->SetShowState(false); this->RequestRedraw(); } else if ((actionId == AEXPORTSAVE) || (actionId == AEXPORTSAVESD)) { String setfilename; Osp::Ui::Controls::EditField * exportpopupfilenameel_ = static_cast<EditField *>(exportpopup_->GetControl(L"IDC_EDITFIELD1")); setfilename = exportpopupfilenameel_->GetText(); setfilename.Trim(); if (setfilename == L"") { MessageBox msgbox; int modalResult = 0; msgbox.Construct("Invalid filename", "Please enter file name!", MSGBOX_STYLE_OK, 10000); msgbox.ShowAndWait(modalResult); return; } exportfilename = L""; if (actionId == AEXPORTSAVESD) { exportfilename = L"/Storagecard/Media/"; } else { exportfilename = L"/Media/"; } exporttempfilename = L"/Home/"; if (exporttotype == EXPORTTYPE_VIDEO) { exportfilename.Append(L"Others/" + setfilename); exporttempfilename.Append(L"export.avi"); if (Osp::Io::File::GetFileExtension(exportfilename) != L"avi") { exportfilename = exportfilename + L".avi"; exportpopupfilenameel_->SetText(setfilename + L".avi"); exportpopupfilenameel_->RequestRedraw(); } } else if (exporttotype == EXPORTTYPE_FRAME) { exportfilename.Append(L"Images/" + setfilename); exporttempfilename.Append(L"export.jpg"); if (Osp::Io::File::GetFileExtension(exportfilename) != L"jpg") { exportfilename = exportfilename + L".jpg"; exportpopupfilenameel_->SetText(setfilename + L".jpg"); exportpopupfilenameel_->RequestRedraw(); } } if (Osp::Io::File::IsFileExist(exportfilename) == true) { MessageBox msgbox; int modalResult = 0; msgbox.Construct("File name exists", "File with that filename already exists!", MSGBOX_STYLE_OK, 10000); msgbox.ShowAndWait(modalResult); return; } if (exporttotype == EXPORTTYPE_VIDEO) { MessageBox msgbox; int modalResult = 0; msgbox.Construct("Notice", "Video file will not be playable on Wave phone's player, export only for playing on other media players (PC,Youtube,...).\nVideo will be exported in Others folder.", MSGBOX_STYLE_OKCANCEL, 60000); msgbox.ShowAndWait(modalResult); if (modalResult == MSGBOX_RESULT_CANCEL) { return; } } if (Osp::Io::File::IsFileExist(exporttempfilename)) { Osp::Io::File::Remove(exporttempfilename); } exportpopup_->SetShowState(false); this->RequestRedraw(); savingpopup_->SetShowState(true); Osp::Ui::Controls::Progress * savingpopupprogressel_ = static_cast<Progress *>(savingpopup_->GetControl(L"IDC_PROGRESS1")); savingpopupprogressel_->SetValue(0); savingpopup_->Show(); /*TimeLapseClass * TimeLapseClass_ = new TimeLapseClass(); if (exporttotype == EXPORTTYPE_VIDEO) { TimeLapseClass_->ExportToMJPEGfile(pPlayerThread_->filename, tempfilename); } else if (exporttotype == EXPORTTYPE_FRAME) { TimeLapseClass_->ExportToJPEGframefile(pPlayerThread_->filename, pPlayerThread_->curframefilepos, tempfilename); } delete TimeLapseClass_;*/ pExportThread_ = new FExportThread; pExportThread_->Construct(); pExportThread_->filename = pPlayerThread_->filename; pExportThread_->filenameout = exporttempfilename; pExportThread_->framefilepos = pPlayerThread_->curframefilepos; pExportThread_->Start(); ExportProgressRefTimer_->Start(500); if (exporttotype == EXPORTTYPE_VIDEO) { pExportThread_->SendUserEvent(pExportThread_->THREAD_EXPORTMJPEG, null); } else if (exporttotype == EXPORTTYPE_FRAME) { pExportThread_->SendUserEvent(pExportThread_->THREAD_EXPORTFRAME, null); } } else if (actionId == THREADCALLBACK_EXPORTPROGRESSUPDATE) { if (pExportThread_ != null) { double progress = ((double)pExportThread_->TimeLapseClass_->exportfileframecurno / (double)pExportThread_->TimeLapseClass_->exportfileframescount); if (progress > 1) progress = 1; if (progress < 1) { ExportProgressRefTimer_->Start(500); } int progressint = (int)(progress * 100.0f); if (progressint < 0) progressint = 0; if (progressint > 100) progressint = 100; Osp::Ui::Controls::Progress * savingpopupprogressel_ = static_cast<Progress *>(savingpopup_->GetControl(L"IDC_PROGRESS1")); savingpopupprogressel_->SetValue(progressint); savingpopupprogressel_->Draw(); savingpopupprogressel_->Show(); } } else if (actionId == THREADCALLBACK_EXPORTDONE) { ExportProgressRefTimer_->Cancel(); Osp::Ui::Controls::Progress * savingpopupprogressel_ = static_cast<Progress *>(savingpopup_->GetControl(L"IDC_PROGRESS1")); savingpopupprogressel_->SetValue(100); savingpopupprogressel_->Draw(); savingpopupprogressel_->Show(); pExportThread_->Stop(); pExportThread_->Join(); delete pExportThread_; pExportThread_ = null; ContentId contentId; ContentManager contentManager; contentManager.Construct(); if (Osp::Content::ContentManagerUtil::CopyToMediaDirectory(exporttempfilename, exportfilename) != E_SUCCESS) { savingpopup_->SetShowState(false); this->RequestRedraw(); MessageBox msgbox; int modalResult = 0; msgbox.Construct("Error", "Error saving file! Maybe out of disk space.", MSGBOX_STYLE_OK, 10000); msgbox.ShowAndWait(modalResult); return; } if (Osp::Io::File::IsFileExist(exporttempfilename)) { Osp::Io::File::Remove(exporttempfilename); } if (exporttotype == EXPORTTYPE_VIDEO) { VideoContentInfo videoContentInfo; videoContentInfo.Construct(exportfilename); contentId = contentManager.CreateContent(videoContentInfo); videoContentInfo.SetAuthor(L"Timelapse"); videoContentInfo.SetDescription(L"Timelapse app"); videoContentInfo.SetKeyword(L"Timelapse"); contentManager.UpdateContent(videoContentInfo); } else if (exporttotype == EXPORTTYPE_FRAME) { ImageContentInfo imageContentInfo; imageContentInfo.Construct(exportfilename); contentId = contentManager.CreateContent(imageContentInfo); imageContentInfo.SetAuthor(L"Timelapse"); imageContentInfo.SetDescription(L"Timelapse app"); imageContentInfo.SetKeyword(L"Timelapse"); contentManager.UpdateContent(imageContentInfo); } savingpopup_->SetShowState(false); this->RequestRedraw(); MessageBox msgbox; int modalResult = 0; msgbox.Construct("Saved", L"File saved to:\n" + exportfilename, MSGBOX_STYLE_OK, 10000); msgbox.ShowAndWait(modalResult); } else if (actionId == ASPEEDCHANGE) { if ((int)pPlayerThread_->fileinfo_.playframerate == 10) { pPlayerThread_->SetFrameRate(15); } else if ((int)pPlayerThread_->fileinfo_.playframerate == 15) { pPlayerThread_->SetFrameRate(20); } else if ((int)pPlayerThread_->fileinfo_.playframerate == 20) { pPlayerThread_->SetFrameRate(25); } else if ((int)pPlayerThread_->fileinfo_.playframerate == 25) { pPlayerThread_->SetFrameRate(30); } else { pPlayerThread_->SetFrameRate(10); } delete speedbtnbmpn_; delete speedbtnbmps_; speedbtnbmpn_ = CreateSpeedBtnBmp(164, Osp::Base::Integer::ToString((int)pPlayerThread_->fileinfo_.playframerate) + L" fps", false); speedbtnbmps_ = CreateSpeedBtnBmp(164, Osp::Base::Integer::ToString((int)pPlayerThread_->fileinfo_.playframerate) + L" fps", true); speedbtn->SetNormalBackgroundBitmap(*speedbtnbmpn_); speedbtn->SetPressedBackgroundBitmap(*speedbtnbmps_); this->RequestRedraw(); } }