*/
EXPORT_API bool removeFile(const char *filePath);
+ /**
+ * @brief Get file state.
+ * @param[in] filePath File path.
+ * @return true if exist, otherwise false.
+ */
+ EXPORT_API bool isFileExist(const char *filePath);
+
/**
* @brief Create folder.
* @param[in] dirPath Destination path.
*/
const std::string &getPath() const;
+ /**
+ * @brief Get record file state.
+ * @return true if record file exist, otherwise false.
+ */
+ bool isExist() const;
+
private:
std::string m_Path;
};
bool Common::removeFile(const char *filePath)
{
int res = 0;
- struct stat st = {0};
- if (filePath != NULL && stat(filePath, &st) == 0) {
+ if (isFileExist(filePath)) {
res = std::remove(filePath);
}
return (res == 0);
}
+bool Common::isFileExist(const char *filePath)
+{
+ struct stat st = {0};
+ return (filePath != nullptr && stat(filePath, &st) == 0);
+}
+
bool Common::createFolder(const char *dirPath)
{
int res = 0;
- struct stat st = {0};
- if (stat(dirPath, &st) == -1) {
+ if (!isFileExist(dirPath)) {
res = mkdir(dirPath, ACCESSPERMS);
}
return (res == 0);
bool Memo::isEmpty() const
{
return (m_Title.empty() && m_Content.empty()
- && m_Images.empty() && !m_SoundRecord);
+ && m_Images.empty() && (!m_SoundRecord || !m_SoundRecord->isExist()));
}
int Memo::onUpdate(void *data)
*/
#include "Common/Model/SoundRecord.h"
+#include "Common/FileUtils.h"
+
#include "App/Path.h"
using namespace App;
+using namespace Common;
using namespace Common::Model;
namespace
{
return m_Path;
}
+
+bool SoundRecord::isExist() const
+{
+ return isFileExist(m_Path.c_str());
+}
ModePlayer
};
+ /**
+ * @brief Recording start callback
+ */
+ typedef std::function<void()> RecordingStartCallback;
+
/**
* @brief Delete callback
*/
explicit RecordField(std::string path, Mode mode = ModeRecorder);
~RecordField();
+ /**
+ * @brief Set recording start callback.
+ * @param[in] callback Recording start callback.
+ */
+ void setRecordingStartCallback(RecordingStartCallback callback);
+
/**
* @brief Set delete callback.
* @param[in] callback Delete callback.
Common::Recorder *m_Recorder;
Common::Player *m_Player;
Ecore_Timer *m_PlayTimer;
+ RecordingStartCallback m_OnRecordingStarted;
DeleteCallback m_OnDelete;
};
}
m_RecordField = new RecordField(m_Memo.getSoundRecord()->getPath(), mode);
m_RecordField->create(parent);
m_RecordField->setRotation(getRotation());
+ m_RecordField->setRecordingStartCallback(std::bind(&InputView::onMemoChanged, this));
m_RecordField->setDeleteCallback(std::bind(&InputView::onRecordFieldDelete, this));
return m_RecordField->getEvasObject();
void InputView::onRecordFieldDelete()
{
m_Memo.removeSoundRecord();
+ onMemoChanged();
}
void InputView::onMemoChanged()
delete m_Player;
}
+void RecordField::setRecordingStartCallback(RecordingStartCallback callback)
+{
+ m_OnRecordingStarted = std::move(callback);
+}
+
void RecordField::setDeleteCallback(DeleteCallback callback)
{
m_OnDelete = std::move(callback);
elm_object_signal_emit(getEvasObject(), SIGNAL_ICON_REC, "*");
elm_object_signal_emit(getEvasObject(), SIGNAL_BTN_STOP_SHOW, "*");
elm_object_signal_emit(m_RecordBtn, SIGNAL_BTN_PAUSE, "*");
+ if (m_OnRecordingStarted) {
+ m_OnRecordingStarted();
+ }
}
void RecordField::onRecordPausePressed()