Apply tapi ready vconf.
authorKeeBum Kim <keebum.kim@samsung.com>
Thu, 30 Aug 2012 01:17:16 +0000 (10:17 +0900)
committerKeeBum Kim <keebum.kim@samsung.com>
Thu, 30 Aug 2012 01:17:16 +0000 (10:17 +0900)
framework/main.cpp
include/utils/MsgGconfWrapper.h
plugin/sms_plugin/SmsPluginMain.cpp
utils/MsgGconfWrapper.cpp

index 7e8f619..02c6ba4 100755 (executable)
@@ -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
index 6b25914..6aee579 100755 (executable)
@@ -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
index d81dfab..d405b7e 100755 (executable)
 * limitations under the License.
 */
 
+#include <errno.h>
+
 #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);
index df5ce3d..248623d 100755 (executable)
@@ -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);
+       }
+}