From: Byounghui Date: Mon, 22 Apr 2013 07:37:54 +0000 (+0900) Subject: prevent to delete msg handle. X-Git-Tag: 2.1b_release X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Ftags%2F2.1b_release;p=samples%2Fnative%2FMessageSender.git prevent to delete msg handle. Change-Id: I3b49c5b35dbf4330a0a31d910925a9920ea894df Signed-off-by: Byounghui --- diff --git a/project/inc/MainForm.h b/project/inc/MainForm.h index 1b3621a..0bbe948 100644 --- a/project/inc/MainForm.h +++ b/project/inc/MainForm.h @@ -55,6 +55,8 @@ private: Button* __pBtnReceiveSms; ContextMenu* __pContextMenuText; ContextMenu* __pContextMenuTextSearch; + Tizen::Messaging::SmsManager *__pSmsManager; + SmsListener *__pListener; }; // MainForm diff --git a/project/src/MainForm.cpp b/project/src/MainForm.cpp index 9627dd9..21d3da1 100644 --- a/project/src/MainForm.cpp +++ b/project/src/MainForm.cpp @@ -51,11 +51,25 @@ MainForm::MainForm(void) , __pBtnReceiveSms(null) , __pContextMenuText(null) , __pContextMenuTextSearch(null) + ,__pSmsManager(null) + ,__pListener(null) { } MainForm::~MainForm(void) { + + if(__pSmsManager) + { + delete __pSmsManager; + __pSmsManager = null; + } + if(__pListener) + { + delete __pListener; + __pListener = null; + } + } result @@ -277,8 +291,6 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) int messageCount = 0; ArrayList* inputList = null; bool isSupported = false; - Tizen::Messaging::SmsManager sms; - SmsListener listener; result r = E_SUCCESS; r = Tizen::System::SystemInfo::GetValue(L"http://tizen.org/feature/network.telephony", isSupported); @@ -287,12 +299,17 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) SendSmsMessageBox(L"SMS is not supported"); break; } - - r = sms.Construct(listener); - if (r != E_SUCCESS) + if (!__pSmsManager) { - AppLogException("[%s] exception occurred.", GetErrorMessage(r)); - break; + __pListener = new (std::nothrow) SmsListener(); + __pSmsManager = new (std::nothrow) SmsManager(); + + r = __pSmsManager->Construct(*__pListener); + if (r != E_SUCCESS) + { + AppLogException("[%s] exception occurred.", GetErrorMessage(r)); + break; + } } inputList= new (std::nothrow) ArrayList(); @@ -301,7 +318,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) if (__flag == 0) { - messageCount = sms.GetTotalMessageCount((Tizen::Messaging::SmsMessageBoxType) __smsMsgBoxTypeSelected); + messageCount = __pSmsManager->GetTotalMessageCount((Tizen::Messaging::SmsMessageBoxType) __smsMsgBoxTypeSelected); strMsg.Format(100, L"Message Count: %d", messageCount); SendSmsMessageBox(strMsg); } @@ -320,8 +337,6 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) int messageCount = 0; ArrayList* inputList = null; bool isSupported = false; - Tizen::Messaging::SmsManager sms; - SmsListener listener; result r = E_SUCCESS; r = Tizen::System::SystemInfo::GetValue(L"http://tizen.org/feature/network.telephony", isSupported); @@ -331,20 +346,27 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) break; } - r = sms.Construct(listener); - if (r != E_SUCCESS) + if (!__pSmsManager) { - AppLogException("[%s] exception occurred.", GetErrorMessage(r)); - break; + __pListener = new (std::nothrow) SmsListener(); + __pSmsManager = new (std::nothrow) SmsManager(); + + r = __pSmsManager->Construct(*__pListener); + if (r != E_SUCCESS) + { + AppLogException("[%s] exception occurred.", GetErrorMessage(r)); + break; + } } + inputList= new (std::nothrow) ArrayList(); inputList->Construct(); inputList->Add(*(new (std::nothrow) Integer(__smsMsgBoxTypeSelected))); if (__flag == 0) { - messageCount = sms.GetTotalMessageCount((Tizen::Messaging::SmsMessageBoxType) __smsMsgBoxTypeSelected); + messageCount = __pSmsManager->GetTotalMessageCount((Tizen::Messaging::SmsMessageBoxType) __smsMsgBoxTypeSelected); strMsg.Format(100, L"Message Count: %d", messageCount); SendSmsMessageBox(strMsg); } @@ -362,8 +384,6 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) int messageCount = 0; ArrayList* inputList = null; bool isSupported = false; - Tizen::Messaging::SmsManager sms; - SmsListener listener; result r = E_SUCCESS; r = Tizen::System::SystemInfo::GetValue(L"http://tizen.org/feature/network.telephony", isSupported); @@ -373,13 +393,20 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) break; } - r = sms.Construct(listener); - if (r != E_SUCCESS) + if (!__pSmsManager) { - AppLogException("[%s] exception occurred.", GetErrorMessage(r)); - break; + __pListener = new (std::nothrow) SmsListener(); + __pSmsManager = new (std::nothrow) SmsManager(); + + r = __pSmsManager->Construct(*__pListener); + if (r != E_SUCCESS) + { + AppLogException("[%s] exception occurred.", GetErrorMessage(r)); + break; + } } + inputList= new (std::nothrow) ArrayList(); inputList->Construct(); @@ -387,7 +414,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) if (__flag == 0) { - messageCount = sms.GetTotalMessageCount((Tizen::Messaging::SmsMessageBoxType) __smsMsgBoxTypeSelected); + messageCount = __pSmsManager->GetTotalMessageCount((Tizen::Messaging::SmsMessageBoxType) __smsMsgBoxTypeSelected); strMsg.Format(100, L"Message Count: %d", messageCount); SendSmsMessageBox(strMsg); } @@ -405,8 +432,6 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) int messageCount = 0; ArrayList* inputList = null; bool isSupported = false; - Tizen::Messaging::SmsManager sms; - SmsListener listener; result r = E_SUCCESS; r = Tizen::System::SystemInfo::GetValue(L"http://tizen.org/feature/network.telephony", isSupported); @@ -415,21 +440,28 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) SendSmsMessageBox(L"SMS is not supported"); break; } - - r = sms.Construct(listener); - if (r != E_SUCCESS) + + if (!__pSmsManager) { - AppLogException("[%s] exception occurred.", GetErrorMessage(r)); - break; + __pListener = new (std::nothrow) SmsListener(); + __pSmsManager = new (std::nothrow) SmsManager(); + + r = __pSmsManager->Construct(*__pListener); + if (r != E_SUCCESS) + { + AppLogException("[%s] exception occurred.", GetErrorMessage(r)); + break; + } } + inputList= new (std::nothrow) ArrayList(); inputList->Construct(); inputList->Add(*(new (std::nothrow) Integer(__smsMsgBoxTypeSelected))); if (__flag == 0) { - messageCount = sms.GetTotalMessageCount((Tizen::Messaging::SmsMessageBoxType) __smsMsgBoxTypeSelected); + messageCount = __pSmsManager->GetTotalMessageCount((Tizen::Messaging::SmsMessageBoxType) __smsMsgBoxTypeSelected); strMsg.Format(100, L"Message Count: %d", messageCount); SendSmsMessageBox(strMsg); }