int CFrmUserList::InsertUser(CRoster *pRoster) { int nRet = 0; if(NULL == pRoster) { LOG_MODEL_ERROR("CFrmUserList", "Don't memery"); return -1; } QMap<QString, CRoster*>::iterator itRosters; itRosters = m_Rosters.find(pRoster->BareJid()); if(m_Rosters.end() == itRosters) { //新建好友对象实例 m_Rosters.insert(pRoster->BareJid(), pRoster); } else { LOG_MODEL_ERROR("Roster", qPrintable("Error:User had existed")); return -1; } nRet = UpdateGroup(pRoster, pRoster->Groups()); return nRet; }
HRESULT COpcAdapter::GatherDeviceData() { USES_CONVERSION; HRESULT hr=S_OK; ULONG dwInterval = _nOPCServerRate; try { // Check if connected - this could take too long if if(!IsConnected() && _bAutoConnect) { GLogger.LogMessage(StdStringFormat("COpcAdapter %s attempt Connect at %s\n",_opcservermachine.c_str(), (LPCSTR) COleDateTime::GetCurrentTime().Format() ),INFO); Off(); if(FAILED(Connect())) { throw std::exception("Attempt Connect FAILED\n"); return E_FAIL; } GLogger.LogMessage(StdStringFormat("COpcAdapter %s Connected at %s\n",_opcservermachine.c_str(), (LPCSTR) COleDateTime::GetCurrentTime().Format() ),INFO); } if(IsConnected()) { //if(FAILED(GetStatusString(_status))) // throw std::exception("GetStatusString failed \n"); // OPC Server can be working, but adding items can fail if(FAILED(UpdateGroup())) { throw std::exception("UpdateGroup failed \n"); return E_FAIL; } On(); } } catch(std::exception e) { GLogger.LogMessage(StdStringFormat("COpcAdapter Exception in %s - COpcAdapter::GatherDeviceData() %s\n",_device.c_str(), (LPCSTR) e.what() ),LOWERROR); Off(); dwInterval=_nQueryServerPeriod; Disconnect(); hr= E_FAIL; } catch(...) { GLogger.LogMessage(StdStringFormat("COpcAdapter Exception in %s - COpcAdapter::GatherDeviceData()\n",_device.c_str() ),LOWERROR); Off(); dwInterval=_nQueryServerPeriod; Disconnect(); hr= E_FAIL; } return hr; }
void CFrmUserList::slotItemChanged(const QString &bareJid) { LOG_MODEL_DEBUG("Roster", "CFrmUserList::itemChanged jid:%s", qPrintable(bareJid)); QMap<QString, CRoster*>::iterator it; it = m_Rosters.find(QXmppUtils::jidToBareJid(bareJid)); if(m_Rosters.end() != it) { CRoster* pRoster = it.value(); QXmppRosterIq::Item item = CGlobal::Instance()->GetXmppClient()->rosterManager().getRosterEntry(bareJid); pRoster->UpdateItems(item); UpdateGroup(pRoster, item.groups()); } }
int CFrmUserList::InsertUser(QXmppRosterIq::Item rosterItem) { int nRet = 0; CRoster* pRoster = NULL; QMap<QString, CRoster*>::iterator itRosters; itRosters = m_Rosters.find(rosterItem.bareJid()); if(m_Rosters.end() == itRosters) { //新建好友对象实例 pRoster = new CRoster(rosterItem); m_Rosters.insert(pRoster->BareJid(), pRoster); } else { LOG_MODEL_ERROR("Roster", qPrintable("Error:User had existed")); return -1; } nRet = UpdateGroup(pRoster, rosterItem.groups()); return nRet; }