void CSmsDialer::doWork(boost::shared_ptr<yApi::IYPluginApi> api) { // Load configuration values (provided by database) m_configuration.initializeWith(api->getConfiguration()); // the main loop std::cout << "CSmsDialer is running..." << std::endl; // Create the phone instance m_phone = CSmsDialerFactory::constructPhone(m_configuration); m_phone->connect(); api->setPluginState(yApi::historization::EPluginState::kCustom, "connecting"); // Timer used to periodically try to connect to phone m_connectionTimer = api->getEventHandler().createTimer(kEvtTimerTryToConnectToPhone, shared::event::CEventTimer::kPeriodic, boost::posix_time::minutes(1)); m_connectionTimer->stop(); // Timer used to periodically check for incoming SMS m_incommingSmsPollTimer = api->getEventHandler().createTimer(kEvtTimerCheckForIncommingSms, shared::event::CEventTimer::kPeriodic, boost::posix_time::seconds(30)); m_incommingSmsPollTimer->stop(); auto stopIsRequested = false; while (!stopIsRequested) { if (!m_phone->isConnected()) { stopIsRequested = processNotConnectedState(api); } else { stopIsRequested = processConnectedState(api); } } std::cout << "Stop requested" << std::endl; api->setPluginState(yApi::historization::EPluginState::kStopped); }
void CulistGui::onConnnected() { processConnectedState(); }