Update change log and spec for wrt-plugins-tizen_0.4.58
[platform/framework/web/wrt-plugins-tizen.git] / src / Notification / StatusNotification.cpp
index 9ba6cbe..6e57f94 100755 (executable)
@@ -456,7 +456,13 @@ std::string StatusNotification::getTitle()
                        throw UnknownException("get notification title error");
                }
 
-               std::string notiTitle(title);
+               std::string notiTitle;
+               if (title)
+               {               
+                       notiTitle = title;
+                       LoggerI(" get title : " << title);
+               }
+
                return notiTitle;       
        }
        else
@@ -577,8 +583,12 @@ std::string StatusNotification::getIconPath()
                        throw UnknownException("get notification icon path error");
                }
 
-               std::string notiIconPath(iconPath);
-               LoggerI("icon Path = " << iconPath);
+               std::string notiIconPath;
+               if (iconPath)
+               {
+                       notiIconPath = iconPath;
+                       LoggerI("icon Path = " << iconPath);
+               }
                
                //if icon path invalid, return empty string.
                if ( notiIconPath.find(DEFAULT_ICON_PATH,0) == std::string::npos)
@@ -628,17 +638,21 @@ std::string StatusNotification::getSoundPath()
                {
                        throw UnknownException("get notification sound error");
                }
-
-               LoggerI(" sound type = " << type << " path = " << soundPath);
-               if ( type == NOTIFICATION_SOUND_TYPE_USER_DATA )
-               {
-                       LoggerI("soundPath = " << soundPath);
-                       return std::string(soundPath); 
-               }
-               else
+               
+               std::string strSoundPath;
+               if (soundPath)
                {
-                       return std::string("");
+                       LoggerI(" soudn type=" << type);
+                       if ( type == NOTIFICATION_SOUND_TYPE_USER_DATA)
+                       {
+                               LoggerI("soundPath = " << soundPath);
+                               strSoundPath = soundPath;
+                       }
                }
+               
+               LoggerI("soundPath :" << strSoundPath);
+               return strSoundPath;
+
        }
        else
        {
@@ -975,13 +989,10 @@ void StatusNotification::setApplicationId(const std::string& appId)
 
        if (m_service)
        {
-               if (!appId.empty())
+               m_launchFlag = true;
+               if (service_set_app_id(m_service, appId.c_str())!= SERVICE_ERROR_NONE)
                {
-                       m_launchFlag = true;
-                       if (service_set_app_id(m_service, appId.c_str())!= SERVICE_ERROR_NONE)
-                       {
-                               throw UnknownException("service set appId error");      
-                       }
+                       throw UnknownException("service set appId error");      
                }
        }
 
@@ -1779,7 +1790,7 @@ bool StatusNotification::isColorFormatNumberic(std::string& color)
        std::string hexCode = "0123456789abcdef";
        if (color.length() == 7 && !color.compare(0, 1, "#") )
        {
-               for ( int i = 1 ; i < color.length() ; i++)
+               for ( size_t i = 1 ; i < color.length() ; i++)
                {
                        if (std::string::npos == hexCode.find(color[i]))
                                return false;
@@ -1824,7 +1835,7 @@ void StatusNotification::setLight(std::string color)
                        LoggerI("color.length()=" << color.length());
                        if (color.length() == 0)
                        {
-                               if (notification_set_led(m_notiHandle, NOTIFICATION_LED_OP_OFF, NULL) != NOTIFICATION_ERROR_NONE)
+                               if (notification_set_led(m_notiHandle, NOTIFICATION_LED_OP_OFF, 0) != NOTIFICATION_ERROR_NONE)
                                {
                                        throw UnknownException("set notification led ");
                                }
@@ -1935,11 +1946,16 @@ void StatusNotification::loadDetailInfos()
         {
                for ( int idx = 0; idx < MAX_NOTIFICATION_DETAIL_INFO_LENGTH; idx++)
                {
-                   std::string main = getInformation(idx);
-                   std::string sub = getSubInformation(idx);
-                   LoggerI("Main : " << main << " Sub : " << sub);
-                   NotificationDetailInfo *info = new NotificationDetailInfo(m_notiHandle, idx, main, sub);
-                   m_detailInfos.push_back(info);
+                   if (!isNullInformation(idx))
+                   {
+                           std::string main = getInformation(idx);
+                           std::string sub = getSubInformation(idx);
+
+                           LoggerI("Main : [" << main << "] Sub : ['" << sub <<"]");      
+                           
+                           NotificationDetailInfo *info = new NotificationDetailInfo(m_notiHandle, idx, main, sub);
+                           m_detailInfos.push_back(info);
+                   }
                }
         }
         else
@@ -1969,6 +1985,7 @@ void StatusNotification::setDetailInfos(const std::vector<NotificationDetailInfo
             NotificationDetailInfo* info = *it;
             if ( idx < MAX_NOTIFICATION_DETAIL_INFO_LENGTH )
             {
+            
                 LoggerI("main " << info->getMainText() << " sub " << info->getSubText() );
                setInformation(info->getMainText(), idx);
                setSubInformation(info->getSubText(), idx);
@@ -2051,6 +2068,51 @@ std::string StatusNotification::getInformation(int index)
        
 }
 
+bool StatusNotification::isNullInformation(int index)
+{
+       if (m_notiHandle)
+       {
+               notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE; 
+               switch (index)
+               {
+                       case 0:
+                               type = NOTIFICATION_TEXT_TYPE_INFO_1;
+                               break;
+                       case 1:
+                               type = NOTIFICATION_TEXT_TYPE_INFO_2;
+                               break;
+                       case 2:
+                               type = NOTIFICATION_TEXT_TYPE_INFO_3;
+                               break;
+                       default :
+                               type = NOTIFICATION_TEXT_TYPE_NONE;
+               }
+               char *info = NULL;
+               
+               if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &info) != NOTIFICATION_ERROR_NONE)
+               {
+                       throw UnknownException("Detail Info index value is invalid or mainText value getting is failed in Detail Info.");
+               }
+               
+               if (info)
+               {
+                       LoggerI("is not null");
+                       return false;
+               }
+               else
+               {
+                       LoggerI("is null");
+                       return true;
+               }
+
+       }
+       else
+       {       
+               LoggerW("noti Handle is NULL");
+               throw UnknownException( "notification handle is null");
+       }
+}
+
 std::string StatusNotification::getSubInformation(int index)
 {
        if (m_notiHandle)
@@ -2119,7 +2181,7 @@ void StatusNotification::setInformation( const std::string& info, int index)
 
                if ( type != NOTIFICATION_TEXT_TYPE_NONE)
                {
-                       if (getInformation(idx).compare(info))
+                       if (getInformation(idx).compare(info) || isNullInformation(idx))
                        {
                                if (notification_set_text(m_notiHandle, type, info.c_str(),
                                        NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)