#include <Elementary.h>
#include <Eina.h>
#include <Ecore.h>
+#include <AppCommon.h>
#include "i18n.h"
#include "define.h"
#include "dbg.h"
}
-bool CPlayListCtxPopup::Create(Evas_Object* base, const SCallback* callback, Eina_List *playList)
+bool CPlayListCtxPopup::m_SetBtnString(Eina_List *playlistList)
{
- Eina_List *l = NULL;
- SCtxtPlaylistItem *item = NULL;
- int i;
- void *obj = NULL;
-
- m = new SPlayListCtxPopup;
- if (!m) {
- _ERR("Memory Alloc Failed!!");
- return false;
- }
-
- m->listSize = eina_list_count(playList);
- if (m->listSize == 0) {
- _DBG("Playlist is empty.");
- delete m;
- m = NULL;
- return false;
- }
+ Eina_List *l;
+ SCtxtPlaylistItem *item;
+ void *obj;
+ int index = 0;
- m->settingTexts = new char*[m->listSize];
- m->btnIds = new char*[m->listSize];
- m->dbIds = new int[m->listSize];
-
- i = 0;
- EINA_LIST_FOREACH(playList, l, obj) {
+ EINA_LIST_FOREACH(playlistList, l, obj) {
item = (SCtxtPlaylistItem *)obj;
- m->settingTexts[i] = new char[strlen(N_(item->name)) + 1];
- m->btnIds[i] = new char[strlen(item->name) + 1];
- m->dbIds[i] = item->id;
- strcpy(m->settingTexts[i], N_(item->name));
- strcpy(m->btnIds[i], item->name);
+ _CREATE_BEGIN{
+ _CHECK(m->settingTexts[index] = new char[strlen(N_(item->name)) + 1])
+ _CHECK(m->btnIds[index] = new char[strlen(item->name) + 1])
- i++;
- }
+ _WHEN_SUCCESS{
+ m->dbIds[index] = item->id;
+ strcpy(m->settingTexts[index], N_(item->name));
+ strcpy(m->btnIds[index], item->name);
+ }
- bool r = CCtxPopup::Create(base, callback, true);
- if (r == false) {
- _ERR("CCtxPopup::Create failed");
- for (i = 0; i < m->listSize; i++) {
- delete[] m->settingTexts[i];
- delete[] m->btnIds[i];
- }
+ _CHECK_FAIL{ delete[] m->btnIds[index]; m->btnIds[index] = NULL; }
+ _CHECK_FAIL{ delete[] m->settingTexts[index]; m->settingTexts[index] = NULL; }
+ } _CREATE_END_AND_CATCH{ return false; }
- delete[] m->settingTexts;
- delete[] m->btnIds;
- delete[] m->dbIds;
- delete m;
-
- m = NULL;
- return false;
+ index++;
}
return true;
}
-void CPlayListCtxPopup::Destroy(void)
+void CPlayListCtxPopup::m_DeleteBtnString(void)
{
- CCtxPopup::Destroy();
-
int i;
-
for (i = 0; i < m->listSize; i++) {
delete[] m->settingTexts[i];
delete[] m->btnIds[i];
}
+}
+
+
+bool CPlayListCtxPopup::Create(Evas_Object* base, const SCallback* callback, Eina_List *playList)
+{
+ Eina_List *l = NULL;
+ SCtxtPlaylistItem *item = NULL;
+
+ _CREATE_BEGIN{
+ _CHECK(m = new SPlayListCtxPopup)
+ _CHECK(m->listSize = eina_list_count(playList))
+ _CHECK(m->settingTexts = new char*[m->listSize])
+ _COMMAND{ memset(m->settingTexts, NULL, m->listSize * sizeof(char*)); }
+ _CHECK(m->btnIds = new char*[m->listSize])
+ _COMMAND{ memset(m->btnIds, NULL, m->listSize * sizeof(char*)); }
+ _CHECK(m->dbIds = new int[m->listSize])
+ _COMMAND{ memset(m->dbIds, NULL, m->listSize * sizeof(int)); }
+ _CHECK(m_SetBtnString(playList))
+ _CHECK(CCtxPopup::Create(base, callback, true))
+
+ _CHECK_FAIL{ CCtxPopup::Destroy(); }
+ _CHECK_FAIL{ m_DeleteBtnString(); }
+ _CHECK_FAIL{ delete[] m->dbIds; }
+ _CHECK_FAIL{ delete[] m->btnIds; }
+ _CHECK_FAIL{ delete[] m->settingTexts; }
+ _CHECK_FAIL{}
+ _CHECK_FAIL{ delete m; m = NULL; }
+ } _CREATE_END_AND_CATCH{ return false; }
+
+ return true;
+}
+
+
+void CPlayListCtxPopup::Destroy(void)
+{
+ CCtxPopup::Destroy();
+
+ m_DeleteBtnString();
delete[] m->settingTexts;
delete[] m->btnIds;