From: KeeBum Kim Date: Thu, 30 Aug 2012 01:17:16 +0000 (+0900) Subject: Apply tapi ready vconf. X-Git-Tag: 2.0_alpha~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7b2aa27342312dd7f574a0e937bcf4a76238a0af;p=platform%2Fcore%2Fmessaging%2Fmsg-service.git Apply tapi ready vconf. --- diff --git a/framework/main.cpp b/framework/main.cpp index 7e8f619..02c6ba4 100755 --- a/framework/main.cpp +++ b/framework/main.cpp @@ -285,6 +285,20 @@ void* InitMsgServer(void*) { msg_error_t err = MSG_SUCCESS; + try + { + // plugin manager initialize + MsgPluginManager::instance()->initialize(); + } + catch (MsgException& e) + { + MSG_FATAL("%s", e.what()); + } + catch (exception& e) + { + MSG_FATAL("%s", e.what()); + } + MSG_MAIN_TYPE_T mainType = MSG_SMS_TYPE; MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(mainType); @@ -414,20 +428,6 @@ signal( SIGCHLD, SIG_IGN ); // Regist vconf CB. MsgSettingRegVconfCB(); - try - { - // plugin manager initialize - MsgPluginManager::instance()->initialize(); - } - catch (MsgException& e) - { - MSG_FATAL("%s", e.what()); - } - catch (exception& e) - { - MSG_FATAL("%s", e.what()); - } - pthread_t startThreadId; // start transaction manager diff --git a/include/utils/MsgGconfWrapper.h b/include/utils/MsgGconfWrapper.h index 6b25914..6aee579 100755 --- a/include/utils/MsgGconfWrapper.h +++ b/include/utils/MsgGconfWrapper.h @@ -41,6 +41,8 @@ typedef struct _MSG_GOBJECT_CLIENT_S #endif +typedef void (*_vconf_change_cb)(keynode_t *key, void* data); + /*================================================================================================== FUNCTION PROTOTYPES ==================================================================================================*/ @@ -60,5 +62,6 @@ bool MsgSettingGetUnknownAutoReject(); void MsgSettingRegVconfCB(); void MsgSettingRemoveVconfCB(); +void MsgSettingRegVconfCBCommon(const char *pKey, _vconf_change_cb pCb); #endif // MSG_GCONF_WRAPPER_H diff --git a/plugin/sms_plugin/SmsPluginMain.cpp b/plugin/sms_plugin/SmsPluginMain.cpp index d81dfab..d405b7e 100755 --- a/plugin/sms_plugin/SmsPluginMain.cpp +++ b/plugin/sms_plugin/SmsPluginMain.cpp @@ -14,10 +14,13 @@ * limitations under the License. */ +#include + #include "MsgDebug.h" #include "MsgException.h" #include "MsgGconfWrapper.h" +#include "MsgMutex.h" #include "SmsPluginTransport.h" #include "SmsPluginSimMsg.h" #include "SmsPluginStorage.h" @@ -38,9 +41,20 @@ extern "C" struct tapi_handle *pTapiHandle = NULL; +Mutex mx; +CndVar cv; + /*================================================================================================== FUNCTION IMPLEMENTATION ==================================================================================================*/ +static void MsgTapiInitCB(keynode_t *key, void* data) +{ + MSG_DEBUG("MsgTapiInitCB is called."); + mx.lock(); + cv.signal(); + mx.unlock(); +} + msg_error_t MsgPlgCreateHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle) { if (pPluginHandle == NULL) @@ -93,18 +107,28 @@ msg_error_t SmsPlgInitialize() { MSG_BEGIN(); - TapiHandle *ph; + MSG_DEBUG("set MSG_SIM_CHANGED to MSG_SIM_STATUS_NOT_FOUND."); + MsgSettingSetInt(MSG_SIM_CHANGED, MSG_SIM_STATUS_NOT_FOUND); - ph = tel_init(NULL); + bool bReady; + MsgSettingGetBool(VCONFKEY_TELEPHONY_READY, &bReady); + MSG_DEBUG("Get VCONFKEY_TELEPHONY_READY [%d].", bReady); - if (!ph) - return MSG_ERR_PLUGIN_TAPIINIT; + int ret = 0; - pTapiHandle = ph; + if(!bReady) { + MsgSettingRegVconfCBCommon(VCONFKEY_TELEPHONY_READY, MsgTapiInitCB); + mx.lock(); + ret = cv.timedwait(mx.pMutex(), 90); + mx.unlock(); + } try { - SmsPluginCallback::instance()->registerEvent(); + if (ret != ETIMEDOUT) { + pTapiHandle = tel_init(NULL); + SmsPluginCallback::instance()->registerEvent(); + } } catch (MsgException& e) { @@ -127,6 +151,9 @@ msg_error_t SmsPlgFinalize() { MSG_BEGIN(); + if (!pTapiHandle) + return MSG_ERR_PLUGIN_TAPIINIT; + SmsPluginCallback::instance()->deRegisterEvent(); tel_deinit(pTapiHandle); @@ -153,6 +180,9 @@ msg_error_t SmsPlgCheckSimStatus(MSG_SIM_STATUS_T *pStatus) { MSG_BEGIN(); + if (!pTapiHandle) + return MSG_ERR_PLUGIN_TAPIINIT; + int tryNum = 0, tapiRet = TAPI_API_SUCCESS; TelSimCardStatus_t status = TAPI_SIM_STATUS_CARD_ERROR; @@ -246,6 +276,9 @@ msg_error_t SmsPlgCheckDeviceStatus() { MSG_BEGIN(); + if (!pTapiHandle) + return MSG_ERR_PLUGIN_TAPIINIT; + int status = 0, tapiRet = TAPI_API_SUCCESS; tapiRet = tel_check_sms_device_status(pTapiHandle, &status); diff --git a/utils/MsgGconfWrapper.cpp b/utils/MsgGconfWrapper.cpp index df5ce3d..248623d 100755 --- a/utils/MsgGconfWrapper.cpp +++ b/utils/MsgGconfWrapper.cpp @@ -265,3 +265,12 @@ void MsgSettingRemoveVconfCB() MSG_DEBUG("Fail to regist vconf CB with [%s]", VCONFKEY_CISSAPPL_AUTO_REJECT_UNKNOWN_BOOL); } } + +void MsgSettingRegVconfCBCommon(const char *pKey, _vconf_change_cb pCb) +{ + if (vconf_notify_key_changed(pKey, pCb, NULL) < 0) { + MSG_DEBUG("Fail to regist vconf CB with [%s]", pKey); + } else { + MSG_DEBUG("Success to regist vconf CB with [%s]", pKey); + } +}