50 #include "safec_lib.h"
52 #define TIME_ZONE_LENGTH 8
54 GHashTable* hostIf_Time::ifHash = NULL;
55 GMutex* hostIf_Time::m_mutex = NULL;
56 GHashTable* hostIf_Time::m_notifyHash = NULL;
62 hostIf_Time::hostIf_Time(
int dev_id):
64 bCalledLocalTimeZone(false),
65 bCalledCurrentLocalTime(false)
67 backupLocalTimeZone[0]=
'\0';
68 backupCurrentLocalTime[0]=
'\0';
69 m_bsStore = XBSStore::getInstance();
78 pRet = (
hostIf_Time *)g_hash_table_lookup(ifHash,(gpointer) dev_id);
82 ifHash = g_hash_table_new(NULL,NULL);
91 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"Caught exception, not able create MoCA Interface instance..\n");
93 g_hash_table_insert(ifHash, (gpointer)dev_id, pRet);
98 GList* hostIf_Time::getAllInstances()
101 return g_hash_table_get_keys(ifHash);
109 g_hash_table_remove(ifHash, (gconstpointer)pDev->dev_id);
114 void hostIf_Time::closeAllInstances()
118 GList* tmp_list = g_hash_table_get_values (ifHash);
123 tmp_list = tmp_list->next;
129 void hostIf_Time::getLock()
133 m_mutex = g_mutex_new();
135 g_mutex_lock(m_mutex);
138 void hostIf_Time::releaseLock()
140 g_mutex_unlock(m_mutex);
143 GHashTable* hostIf_Time::getNotifyHash()
151 return m_notifyHash = g_hash_table_new(g_str_hash, g_str_equal);
155 hostIf_Time::~hostIf_Time()
159 g_hash_table_destroy(m_notifyHash);
165 struct timeval time_now;
166 struct tm *newtime = NULL;
168 char tmp[_BUF_LEN_64];
170 gettimeofday(&time_now, NULL);
172 newtime = localtime((
const time_t*)&(time_now.tv_sec));
174 if(0 == strftime(tmp,
sizeof(tmp),
"%Z", newtime))
179 if(bCalledLocalTimeZone && pChanged && strncmp(tmp, backupLocalTimeZone,_BUF_LEN_64))
184 bCalledLocalTimeZone =
true;
185 strncpy(stMsgData->
paramValue,tmp,_BUF_LEN_64-1);
186 strncpy(backupLocalTimeZone,tmp,_BUF_LEN_64-1);
188 stMsgData->
paramtype = hostIf_StringType;
192 int hostIf_Time::get_Device_Time_Enable(
HOSTIF_MsgData_t *,
bool *pChanged )
224 struct tm * timeinfo;
226 char buffer [_BUF_LEN_64] = {
'\0'};
227 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Entering..\n", __FILE__, __FUNCTION__);
229 memset(timeZoneTmp, 0,
sizeof(timeZoneTmp));
232 timeinfo = localtime (&rawtime);
234 strftime(buffer,_BUF_LEN_64-1,
"%Y-%m-%dT%H:%M:%S", timeinfo);
235 strftime(timeZoneTmp,
sizeof(timeZoneTmp),
"%z", timeinfo);
236 sprintf(buffer + strlen(buffer),
".%0.6d%s", timeinfo->tm_sec, timeZoneTmp);
238 if(bCalledCurrentLocalTime && pChanged && strncmp(buffer, backupCurrentLocalTime, _BUF_LEN_64 ))
243 bCalledCurrentLocalTime =
true;
249 rc=strcpy_s(backupCurrentLocalTime,
sizeof(backupCurrentLocalTime),buffer);
255 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s:%s] buffer : %s stMsgData->paramValue: %s\n", __FILE__, __FUNCTION__, buffer, stMsgData->
paramValue);
257 stMsgData->
paramtype = hostIf_StringType;
259 RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,
"[%s:%s] Exiting..\n", __FILE__, __FUNCTION__);
265 return m_bsStore->getValue(stMsgData);
270 return m_bsStore->overrideValue(stMsgData);