Client::Client(ContactModel *contactModel, QObject *parent) : QObject(parent),m_trackInterval(5), m_authentificated(0), m_trackingPermitted(Settings::getInstance().getPermission()), m_isHavingOwnChannel(true), m_contactModel(contactModel) { m_timer = new QTimer(this); connect(m_timer, SIGNAL(timeout()), SLOT(track())); m_additionalTimer = new QTimer(this); connect(m_additionalTimer, SIGNAL(timeout()),SLOT(getTagsRequest())); m_loginQuery = new LoginQuery(this); connect(m_loginQuery, SIGNAL(connected()), SLOT(onAuthentificated())); connect(m_loginQuery, SIGNAL(errorOccured(QString)), SLOT(onError(QString))); connect(m_loginQuery, SIGNAL(errorOccured(int)),SLOT(onError(int))); m_RegisterUserQuery = new RegisterUserQuery(this); connect(m_RegisterUserQuery, SIGNAL(connected()), SLOT(onRegistered())); connect(m_RegisterUserQuery, SIGNAL(errorOccured(int)),SLOT(onError(int))); m_netManager = new QNetworkConfigurationManager(this); m_history = new MarksHistory(this); connect(m_history,SIGNAL(isFull()),SLOT(onHistoryFull())); m_history->setHistoryLimit(Settings::getInstance().getTimeInterval()/m_trackInterval); m_addNewMarkQuery = new WriteTagQuery(this); connect(m_addNewMarkQuery,SIGNAL(tagAdded()),SLOT(onMarkAdded())); // connect(m_addNewMarkQuery, SIGNAL(errorOccured(QString)), SIGNAL(error(QString))); m_applyChannelQuery = new ApplyChannelQuery(this); connect(m_applyChannelQuery, SIGNAL(channelAdded(QSharedPointer<Channel>)),SLOT(subscribeToOwnChannel())); connect(m_applyChannelQuery, SIGNAL(errorOccured(int)), SLOT(onError(int))); m_subscribeChannelQuery = new SubscribeChannelQuery(this); connect(m_subscribeChannelQuery,SIGNAL(channelSubscribed(QSharedPointer<Channel>)),SLOT(onChannelSubscribed(QSharedPointer<Channel>))); connect(m_subscribeChannelQuery, SIGNAL(errorOccured(int)), SLOT(onError(int))); m_subscibedChannelsQuery = new SubscribedChannelsQuery(this); //connect(m_subscibedChannelsQuery,SIGNAL(responseReceived()),SLOT(constructContactModel())); connect(m_subscibedChannelsQuery,SIGNAL(errorOccured(int)), SLOT(onError(int))); m_loadTagsQuery = new LoadTagsQuery(this); connect(m_loadTagsQuery, SIGNAL(tagsReceived()), SLOT(onGetTags())); connect(m_loadTagsQuery,SIGNAL(errorOccured(int)), SLOT(onError(int))); m_unsubscribeChannelQuery = new UnsubscribeChannelQuery(this); connect(m_unsubscribeChannelQuery, SIGNAL(channelUnsubscribed()),SLOT(onChannelUnsubscribed())); connect(m_unsubscribeChannelQuery,SIGNAL(errorOccured(int)), SLOT(onError(int))); qDebug()<<Settings::getInstance().getLogin(); qDebug()<<Settings::getInstance().getPassword(); if (Settings::getInstance().isHavingAuthData()) auth(Settings::getInstance().getLogin(),Settings::getInstance().getPassword()); }
void Channel::onMessage(Json::Value &jsonObj) { LOGI("%s:receive:%s",m_sComponentName.c_str(),jsonObj.toStyledString().data()); bool run = false; // id if (jsonObj.isMember("id")) { int msgID = jsonObj["id"].asInt(); if(jsonObj.isMember("result")){ if(msgID==m_iIDRegRequest){ run=true; m_iIDStart = jsonObj["result"].asInt(); m_iGenerateId= m_iIDStart; onRegistered(); } else if(msgID == m_iIDUnRegRequest){ run=true; m_iIDUnRegRequest=jsonObj["result"].asInt(); onUnregistered(); } else { run=true; onResult(jsonObj); } } else if(jsonObj.isMember("error")){ run=true; onError(jsonObj["error"].asString()); } else{ run=true; onRequest(jsonObj); } } else { run=true; onNotification(jsonObj); } if(!run){ LOGE("NOT USED"); } }
void System::onRegisteredWorld(World * world) { m_world = world; onRegistered(); }