Пример #1
0
/*
    Service callback. Invoked by the SCM.
 */ 
static void WINAPI serviceCallback(ulong cmd)
{
    switch(cmd) {
    case SERVICE_CONTROL_INTERROGATE:
        break;

    case SERVICE_CONTROL_PAUSE:
        app->serviceStopped = 1;
        SuspendThread(app->threadHandle);
        svcStatus.dwCurrentState = SERVICE_PAUSED;
        break;

    case SERVICE_CONTROL_STOP:
        stopService(SERVICE_CONTROL_STOP);
        break;

    case SERVICE_CONTROL_CONTINUE:
        app->serviceStopped = 0;
        ResumeThread(app->threadHandle);
        svcStatus.dwCurrentState = SERVICE_RUNNING;
        break;

    case SERVICE_CONTROL_SHUTDOWN:
        stopService(SERVICE_CONTROL_SHUTDOWN);
        return;

    default:
        break;
    }
    tellSCM(svcStatus.dwCurrentState, NO_ERROR, 0);
}
void CSrvMsgHandler::onLoad(const char* srvName, const unsigned int srvId, unsigned short moduleId)
{
	if (!GatewayProxyConfig::config::getConfigValue(CCfg::getValue("GatewayProxyService", "BusinessXmlConfigFile")).isSetConfigValueSuccess())
	{
		ReleaseErrorLog("set business xml config value error");
		stopService();
		return;
	}
	
    const DBConfig::config& dbCfg = DBConfig::config::getConfigValue(CCfg::getValue("GatewayProxyService", "DbConfigFile"));
	if (!dbCfg.isSetConfigValueSuccess())
	{
		ReleaseErrorLog("set db xml config value error");
		stopService();
		return;
	}

	if (!m_redisDbOpt.connectSvr(dbCfg.redis_db_cfg.center_db_ip.c_str(), dbCfg.redis_db_cfg.center_db_port,
	    dbCfg.redis_db_cfg.center_db_timeout * MillisecondUnit))
	{
		ReleaseErrorLog("gateway connect center redis service failed, ip = %s, port = %u, time out = %u",
		dbCfg.redis_db_cfg.center_db_ip.c_str(), dbCfg.redis_db_cfg.center_db_port, dbCfg.redis_db_cfg.center_db_timeout);
		
		stopService();
		return;
	}
	
	static const unsigned int gatewayProxySrvId = getSrvId();
	m_gatewayProxySrvData.ip = CSocket::toIPInt(CCfg::getValue("NetConnect", "NetIP"));  // 外网IP
	m_gatewayProxySrvData.port = atoi(CCfg::getValue("NetConnect", "Port"));
	m_gatewayProxySrvData.curTimeSecs = time(NULL);
	m_gatewayProxySrvData.currentPersons = 0;
	int rc = m_redisDbOpt.setHField(GatewayProxyListKey, GatewayProxyListKeyLen,
	                                (const char*)&gatewayProxySrvId, sizeof(gatewayProxySrvId), (const char*)&m_gatewayProxySrvData, sizeof(m_gatewayProxySrvData));
	if (rc != 0)
	{
		ReleaseErrorLog("set gateway proxy service data to redis center service failed, rc = %d", rc);
		stopService();
		return;
	}
	
	m_gameHallId = GatewayProxyConfig::config::getConfigValue().commonCfg.game_hall_id;
	
	// 定时保存数据到redis
	unsigned int millisecondUnit = 1000; // 秒转换为毫秒乘值
	unsigned int timerId = setTimer(millisecondUnit * atoi(CCfg::getValue("GatewayProxyService", "SaveDataToDBInterval")),
	                                (TimerHandler)&CSrvMsgHandler::saveDataToDb, 0, NULL, (unsigned int)-1);

    ReleaseInfoLog("gateway message handler load, service name = %s, id = %d, timer id = %u", srvName, srvId, timerId);
}
Пример #3
0
void Process::Stub::onTransact(int32_t what, int32_t arg1, int32_t arg2, const sp<Object>& obj, const sp<Bundle>& data, const sp<Object>& result) {
    switch (what) {
    case MSG_CREATE_SERVICE: {
        sp<Intent> intent = object_cast<Intent>(data->getObject("intent"));
        sp<IBinder> binder = data->getBinder("binder");
        createService(intent, RemoteCallback::Stub::asInterface(binder));
        break;
    }
    case MSG_START_SERVICE: {
        sp<Intent> intent = object_cast<Intent>(data->getObject("intent"));
        int32_t flags = arg1;
        int32_t startId = arg2;
        sp<IBinder> binder = data->getBinder("binder");
        startService(intent, flags, startId, RemoteCallback::Stub::asInterface(binder));
        break;
    }
    case MSG_STOP_SERVICE: {
        sp<Intent> intent = object_cast<Intent>(data->getObject("intent"));
        sp<IBinder> binder = data->getBinder("binder");
        if (binder == nullptr) {
            stopService(intent);
        } else {
            stopService(intent, RemoteCallback::Stub::asInterface(binder));
        }
        break;
    }
    case MSG_BIND_SERVICE: {
        sp<Intent> intent = object_cast<Intent>(data->getObject("intent"));
        sp<ServiceConnection> conn = object_cast<ServiceConnection>(data->getObject("conn"));
        int32_t flags = data->getInt("flags");
        sp<IBinder> binder = data->getBinder("binder");
        bindService(intent, conn, flags, RemoteCallback::Stub::asInterface(binder));
        break;
    }
    case MSG_UNBIND_SERVICE: {
        sp<Intent> intent = object_cast<Intent>(data->getObject("intent"));
        sp<IBinder> binder = data->getBinder("binder");
        if (binder == nullptr) {
            unbindService(intent);
        } else {
            unbindService(intent, RemoteCallback::Stub::asInterface(binder));
        }
        break;
    }
    default:
        Binder::onTransact(what, arg1, arg2, obj, data, result);
        break;
    }
}
Пример #4
0
void ofxBonjourIp::startService( string type, string name, int port, string domain ){
    
    // format parameters
    CFStringRef serviceType = CFStringCreateWithCString(kCFAllocatorDefault, type.c_str(), kCFStringEncodingUTF8);
    CFStringRef serviceName =  CFStringCreateWithCString(kCFAllocatorDefault, name.c_str(), kCFStringEncodingUTF8); // if empty becomes device name
    SInt32 chosenPort = (SInt32) port;
    CFStringRef serviceDomain = CFStringCreateWithCString(kCFAllocatorDefault, domain.c_str(), kCFStringEncodingUTF8);
    
    // start service- async
    netService = CFNetServiceCreate(kCFAllocatorDefault, serviceDomain, serviceType, serviceName, chosenPort);
    CFNetServiceScheduleWithRunLoop(netService, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
    
    // creat a client context for a callback function when service successfully publishes
    CFNetServiceClientContext clientContext = { 0, this, NULL, NULL, NULL };
    CFNetServiceSetClient(netService, ofxBonjourIp::NetServicePublishedCallBack, &clientContext); //CFNetServiceSetClient(netService, registerCallback, &clientContext);
    
    
    if (!CFNetServiceRegisterWithOptions(netService, kCFNetServiceFlagNoAutoRename, NULL)) {
        stopService();
        ofLog() << "Could not register Bonjour service";
    }
    
    // do i need to do this?
    CFRelease(serviceType);
    CFRelease(serviceName);
    CFRelease(serviceDomain);
}
Пример #5
0
int main(int argc, char** argv)
{
  //
  // Be sure all files are only readable
  // by the user.
  //

  umask(0077);

  char *programName = NULL;

  if (argc > 1)
  {
    switch(parseArguments(programName, argc, argv))
    {
    case LIST:
      if (listServices(programName))
      {
        return 1;
      }
      break;
    case START:
      if (startService(programName, argc, argv))
      {
        return 1;
      }
      break;
    case STOP:
      if (stopService(programName, argc, argv))
      {
        return 1;
      }
      break;
    case CLEANUP:
      if (cleanupDirectories())
      {
        return 1;
      }
      break;
    case CHECK:
      logUser("NXSERVICE - is running");
      break;
    case PROGRAM_VERSION:
      logUser("NXSERVICE - version %s", VERSION);
      break;
    case UNKNOWN:
    default:
      logUser("Error: unknown parameter.");
      return 1;
    }
  }
  else
  {
    logUser("Error: Wrong parameters.");
    return 1;
  }

  return 0;
}
Пример #6
0
BootManager::~BootManager()
{
	stopService();

	delete m_states[BOOT_STATE_STARTUP];
	delete m_states[BOOT_STATE_FIRSTUSE];
	delete m_states[BOOT_STATE_NORMAL];
}
Пример #7
0
bool ServiceControl::setServiceRunning(bool running)
{
    if (running && !serviceRunning()) {
        return startService();
    } else if (!running && serviceRunning()) {
        return stopService();
    }
    return true; // Requested state is already the current state.
}
Пример #8
0
int AppUpdateInstall::run()
{
	m_pPrivates->m_iResult = -1;

	try
	{
		startService();

		IPC::PipeClient pc("DesuraIS");
		pc.onDisconnectEvent += delegate(this, &AppUpdateInstall::onIPCDisconnect);

		pc.setUpPipes();
		pc.start();

		std::shared_ptr<IPCUpdateApp> ipua = IPC::CreateIPCClass< IPCUpdateApp >(&pc, "IPCUpdateApp");

		if (!ipua)
		{
			m_pPrivates->m_iResult = 2;
			throw gcException(ERR_NULLHANDLE, "Failed to create UpdateApp service.");
		}

		ipua->onCompleteEvent += delegate(this, &AppUpdateInstall::onComplete);
		ipua->onErrorEvent += delegate(this, &AppUpdateInstall::onError);
		ipua->onProgressEvent += delegate(this, &AppUpdateInstall::onProgress);

		ipua->start(m_pPrivates->m_szMcfPath.c_str(), m_pPrivates->m_szInsPath.c_str(), m_pPrivates->m_bTestMode);
		WaitForSingleObject(m_pEvent, INFINITE);

		ipua->onCompleteEvent -= delegate(this, &AppUpdateInstall::onComplete);
		ipua->onErrorEvent -= delegate(this, &AppUpdateInstall::onError);
		ipua->onProgressEvent -= delegate(this, &AppUpdateInstall::onProgress);

		pc.onDisconnectEvent -= delegate(this, &AppUpdateInstall::onIPCDisconnect);

		uint32 p = 100;

		if (m_pPrivates->m_pProgressReport)
			m_pPrivates->m_pProgressReport->reportProgress(p);
	}
	catch (gcException &e)
	{
		m_pPrivates->m_iResult = 3;
		onError(e);
	}

	try
	{
		stopService();
	}
	catch(...)
	{
	}

	return m_pPrivates->m_iResult;
}
Пример #9
0
CefIPCPipeClient::~CefIPCPipeClient()
{
	try
	{
		stopService();
	}
	catch (...)
	{
	}
}
Пример #10
0
RESULT eNavigation::playService(const eServiceReference &service)
{
	stopService();

	ASSERT(m_servicehandler);
	RESULT res = m_servicehandler->play(service, m_runningService);
	if (m_runningService)
	{
		m_runningService->setTarget(m_decoder);
		m_runningService->connectEvent(slot(*this, &eNavigation::serviceEvent), m_service_event_conn);
		res = m_runningService->start();
	}
	return res;
}
Пример #11
0
AppUpdateInstall::~AppUpdateInstall()
{
	SetEvent(m_pEvent);
	CloseHandle(m_pEvent);

	try
	{
		stopService();
	}
	catch (gcException)
	{
	}

	safe_delete(m_pPrivates);
}
Пример #12
0
bool 
CArchAppUtilWindows::parseArg(const int& argc, const char* const* argv, int& i)
{
	if (app().isArg(i, argc, argv, NULL, "--service")) {

		const char* action = argv[++i];

		if (_stricmp(action, "install") == 0) {
			installService();
		}
		else if (_stricmp(action, "uninstall") == 0) {
			uninstallService();
		}
		else if (_stricmp(action, "start") == 0) {
			startService();
		}
		else if (_stricmp(action, "stop") == 0) {
			stopService();
		}
		else {
			LOG((CLOG_ERR "unknown service action: %s", action));
			app().m_bye(kExitArgs);
		}
		app().m_bye(kExitSuccess);
	}
	else if (app().isArg(i, argc, argv, NULL, "--debug-service-wait")) {

		app().argsBase().m_debugServiceWait = true;
	}
	else if (app().isArg(i, argc, argv, NULL, "--relaunch")) {

		app().argsBase().m_relaunchMode = true;
	}
	else if (app().isArg(i, argc, argv, NULL, "--exit-pause")) {

		app().argsBase().m_pauseOnExit = true;
	}
	else if (app().isArg(i, argc, argv, NULL, "--no-tray")) {

		app().argsBase().m_disableTray = true;
	}
	else {
		// option not supported here
		return false;
	}

	return true;
}
Пример #13
0
UserIPCPipeClient::~UserIPCPipeClient()
{
#ifdef WIN32
	try
	{
		stopService();
	}
	catch (...)
	{
	}
#else
	if (m_pServer)
	{
		m_pServer->destroy();
		m_pServer = NULL;
	}
#endif
}
Пример #14
0
void CALLBACK serviceHandler(DWORD ctl)
{
	switch (ctl)
	{
		case SERVICE_CONTROL_STOP:
		{
			serviceStatus.dwCheckPoint++;
			serviceStatus.dwCurrentState = SERVICE_STOP_PENDING;
			SetServiceStatus(serviceStatusHandle, &serviceStatus);

			stopService();

			serviceStatus.dwCheckPoint = 0;
			serviceStatus.dwCurrentState = SERVICE_STOPPED;
			SetServiceStatus(serviceStatusHandle, &serviceStatus);
			break;
		}
		case SERVICE_CONTROL_PAUSE:
		{
			pauseService();

			serviceStatus.dwCurrentState = SERVICE_PAUSED;
			SetServiceStatus(serviceStatusHandle, &serviceStatus);

			break;
		}
		case SERVICE_CONTROL_CONTINUE:
		{
			continueService();
			serviceStatus.dwCurrentState = SERVICE_RUNNING;
			SetServiceStatus(serviceStatusHandle, &serviceStatus);
			break;
		}
		default:
		{
			break;
		}
	}
}
Пример #15
0
void MainWindow::apply()
{
#ifdef ITALC_BUILD_WIN32
	ItalcCore::config->setValue( "EncodedLogonACL", LogonAclSettings().acl(),
															"Authentication" );
#endif
	if( ImcCore::applyConfiguration( *ItalcCore::config ) )
	{
#ifdef ITALC_BUILD_WIN32
		if( isServiceRunning() &&
			QMessageBox::question( this, tr( "Restart iTALC Service" ),
				tr( "All settings were saved successfully. In order to take "
					"effect the iTALC service needs to be restarted. "
					"Restart it now?" ), QMessageBox::Yes | QMessageBox::No,
				QMessageBox::Yes ) == QMessageBox::Yes )
		{
			stopService();
			startService();
		}
#endif
		ui->buttonBox->setEnabled( false );
		m_configChanged = false;
	}
}
Пример #16
0
void Process::ProcessImpl::stopService(const sp<Intent>& intent) {
    stopService(intent, nullptr);
}
Пример #17
0
void NetworkService::stop()
{
	stopService();

	ThreadBase::stop();
}
Пример #18
0
ofxBonjourIp::~ofxBonjourIp(){
    
    stopService();
    stopDiscoverService();
}
Пример #19
0
bool ServiceControl::restartService()
{
    return stopService() && startService();
}
Пример #20
0
eNavigation::~eNavigation()
{
	stopService();
	instance=NULL;
}
Пример #21
0
eNavigation::~eNavigation()
{
	stopService();
}
Пример #22
0
void ServiceManager::Stub::onTransact(int32_t what, int32_t arg1, int32_t arg2,
                                      const sp<Object>& obj, const sp<Bundle>& data, const sp<Object>& result)
{
    switch (what) {
    case MSG_START_SERVICE: {
            auto promise = object_cast<Promise<sp<ComponentName>>>(result);
            sp<Intent> service = object_cast<Intent>(obj);
            sp<ComponentName> component = startService(service);
            promise->set(component);
            break;
        }

    case MSG_STOP_SERVICE: {
            auto promise = object_cast<Promise<bool>>(result);
            sp<Intent> service = object_cast<Intent>(obj);
            promise->set(stopService(service));
            break;
        }

    case MSG_BIND_SERVICE: {
            auto promise = object_cast<Promise<bool>>(result);
            sp<Intent> service = object_cast<Intent>(data->getObject("intent"));
            sp<ServiceConnection> conn = object_cast<ServiceConnection>
                                         (data->getObject("conn"));
            int32_t flags = data->getInt("flags");
            sp<IBinder> binder = data->getBinder("binder");
            promise->set(bindService(service, conn, flags,
                                     binder::RemoteCallback::Stub::asInterface(binder)));
            break;
        }

    case MSG_UNBIND_SERVICE: {
            sp<Intent> intent = object_cast<Intent>(data->getObject("intent"));
            sp<ServiceConnection> conn = object_cast<ServiceConnection>
                                         (data->getObject("conn"));
            sp<IBinder> binder = nullptr;

            if (binder == nullptr) {
                unbindService(intent, conn);
            } else {
                unbindService(intent, conn, binder::RemoteCallback::Stub::asInterface(binder));
            }

            break;
        }

    case MSG_START_SYSTEM_SERVICE: {
            auto promise = object_cast<Promise<sp<ComponentName>>>(result);
            sp<Intent> service = object_cast<Intent>(obj);
            sp<ComponentName> component = startSystemService(service);
            promise->set(component);
            break;
        }

    case MSG_STOP_SYSTEM_SERVICE: {
            auto promise = object_cast<Promise<bool>>(result);
            sp<Intent> service = object_cast<Intent>(obj);
            promise->set(stopSystemService(service));
            break;
        }

    default:
        Binder::onTransact(what, arg1, arg2, obj, data, result);
    }
}
Пример #23
0
InputManager::~InputManager()
{
	stopService();
}
Пример #24
0
void dnsservice::onRebootService()
{
    g_serviceport++;
	stopService();
	start();
}
Пример #25
0
void LogMessage(wxString msg, int level)
{
	if (eventHandle)
	{
		LPCTSTR *tmp;

		tmp = (LPCTSTR *)malloc(sizeof(LPCTSTR));
		tmp[0] = _wcsdup(msg.wc_str());

		switch (level)
		{
			case LOG_DEBUG:
				if (minLogLevel >= LOG_DEBUG)
					ReportEvent(eventHandle, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, tmp, NULL);
				break;

			case LOG_WARNING:
				if (minLogLevel >= LOG_WARNING)
					ReportEvent(eventHandle, EVENTLOG_WARNING_TYPE, 0, 0, NULL, 1, 0, tmp, NULL);
				break;

			case LOG_ERROR:
				ReportEvent(eventHandle, EVENTLOG_ERROR_TYPE, 0, 0, NULL, 1, 0, tmp, NULL);
				stopService();

				// Set pgagent initialized to true, as initService
				// is waiting for it to be intialized
				pgagentInitialized = true;

				// Change service status
				serviceStatus.dwCheckPoint = 0;
				serviceStatus.dwCurrentState = SERVICE_STOPPED;
				SetServiceStatus(serviceStatusHandle, &serviceStatus);

				break;

				// Log startup/connection warnings (valid for any log level)
			case LOG_STARTUP:
				ReportEvent(eventHandle, EVENTLOG_WARNING_TYPE, 0, 0, NULL, 1, 0, tmp, NULL);
				break;
		}
	}
	else
	{
		switch (level)
		{
			case LOG_DEBUG:
				if (minLogLevel >= LOG_DEBUG)
					wxPrintf(_("DEBUG: %s\n"), msg);
				break;
			case LOG_WARNING:
				if (minLogLevel >= LOG_WARNING)
					wxPrintf(_("WARNING: %s\n"), msg);
				break;
			case LOG_ERROR:
				wxPrintf(_("ERROR: %s\n"), msg);
				pgagentInitialized = true;
				exit(1);
				break;
				// Log startup/connection warnings (valid for any log level)
			case LOG_STARTUP:
				wxPrintf(_("WARNING: %s\n"), msg);
				break;
		}
	}
}
Пример #26
0
WpaGui::WpaGui(QWidget *parent, const char *, Qt::WFlags) : QMainWindow(parent) {
	setupUi(this);

#ifdef CONFIG_NATIVE_WINDOWS
	fileStopServiceAction = new QAction(this);
	fileStopServiceAction->setObjectName("Stop Service");
	fileStopServiceAction->setIconText(tr("Stop Service"));
	fileMenu->insertAction(actionWPS, fileStopServiceAction);

	fileStartServiceAction = new QAction(this);
	fileStartServiceAction->setObjectName("Start Service");
	fileStartServiceAction->setIconText(tr("Start Service"));
	fileMenu->insertAction(fileStopServiceAction, fileStartServiceAction);

	connect(fileStartServiceAction, SIGNAL(triggered()), this,
		SLOT(startService()));
	connect(fileStopServiceAction, SIGNAL(triggered()), this,
		SLOT(stopService()));

	addInterfaceAction = new QAction(this);
	addInterfaceAction->setIconText(tr("Add Interface"));
	fileMenu->insertAction(fileStartServiceAction, addInterfaceAction);

	connect(addInterfaceAction, SIGNAL(triggered()), this,
		SLOT(addInterface()));
#endif /* CONFIG_NATIVE_WINDOWS */

//	(void) statusBar();

	/*
	 * Disable WPS tab by default; it will be enabled if wpa_supplicant is
	 * built with WPS support.
	 */
	wpsTab->setEnabled(false);
	wpaguiTab->setTabEnabled(wpaguiTab->indexOf(wpsTab), false);

	connect(fileEventHistoryAction, SIGNAL(triggered()), this,
		SLOT(eventHistory()));
	connect(fileSaveConfigAction, SIGNAL(triggered()), this,
		SLOT(saveConfig()));
	connect(actionWPS, SIGNAL(triggered()), this, SLOT(wpsDialog()));
	connect(actionPeers, SIGNAL(triggered()), this, SLOT(peersDialog()));
	connect(fileExitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
	connect(networkAddAction, SIGNAL(triggered()), this,
		SLOT(addNetwork()));
	connect(networkEditAction, SIGNAL(triggered()), this,
		SLOT(editSelectedNetwork()));
	connect(networkRemoveAction, SIGNAL(triggered()), this,
		SLOT(removeSelectedNetwork()));
	connect(networkEnableAllAction, SIGNAL(triggered()), this,
		SLOT(enableAllNetworks()));
	connect(networkDisableAllAction, SIGNAL(triggered()), this,
		SLOT(disableAllNetworks()));
	connect(networkRemoveAllAction, SIGNAL(triggered()), this,
		SLOT(removeAllNetworks()));
	connect(helpIndexAction, SIGNAL(triggered()), this, SLOT(helpIndex()));
	connect(helpContentsAction, SIGNAL(triggered()), this,
		SLOT(helpContents()));
	connect(helpAboutAction, SIGNAL(triggered()), this, SLOT(helpAbout()));
	connect(disconnectButton, SIGNAL(clicked()), this, SLOT(disconnect()));
	connect(scanButton, SIGNAL(clicked()), this, SLOT(scan()));
	connect(connectButton, SIGNAL(clicked()), this, SLOT(connectB()));
	connect(adapterSelect, SIGNAL(activated(const QString&)), this,
		SLOT(selectAdapter(const QString&)));
	connect(networkSelect, SIGNAL(activated(const QString&)), this,
		SLOT(selectNetwork(const QString&)));
	connect(addNetworkButton, SIGNAL(clicked()), this, SLOT(addNetwork()));
	connect(editNetworkButton, SIGNAL(clicked()), this,
		SLOT(editListedNetwork()));
	connect(removeNetworkButton, SIGNAL(clicked()), this,
		SLOT(removeListedNetwork()));
	connect(networkList, SIGNAL(itemSelectionChanged()), this,
		SLOT(updateNetworkDisabledStatus()));
	connect(enableRadioButton, SIGNAL(toggled(bool)), this,
		SLOT(enableListedNetwork(bool)));
	connect(disableRadioButton, SIGNAL(toggled(bool)), this,
		SLOT(disableListedNetwork(bool)));
	connect(scanNetworkButton, SIGNAL(clicked()), this, SLOT(scan()));
	connect(networkList, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
		this, SLOT(editListedNetwork()));
	connect(wpaguiTab, SIGNAL(currentChanged(int)), this,
		SLOT(tabChanged(int)));
	connect(wpsPbcButton, SIGNAL(clicked()), this, SLOT(wpsPbc()));
	connect(wpsPinButton, SIGNAL(clicked()), this, SLOT(wpsGeneratePin()));
	connect(wpsApPinEdit, SIGNAL(textChanged(const QString &)), this,
		SLOT(wpsApPinChanged(const QString &)));
	connect(wpsApPinButton, SIGNAL(clicked()), this, SLOT(wpsApPin()));

	eh = NULL;
	scanres = NULL;
	peers = NULL;
	add_iface = NULL;
	udr = NULL;
	tray_icon = NULL;
	startInTray = false;
	ctrl_iface = NULL;
	ctrl_conn = NULL;
	monitor_conn = NULL;
	msgNotifier = NULL;
	ctrl_iface_dir = strdup("/var/run/wpa_supplicant");

//	parse_argv();

#ifndef QT_NO_SESSIONMANAGER
//	if (app->isSessionRestored()) {
//		QSettings settings("wpa_supplicant", "wpa_gui");
//		settings.beginGroup("state");
//		if (app->sessionId().compare(settings.value("session_id").
//					     toString()) == 0)
//			startInTray = settings.value("in_tray").toBool();
//		settings.endGroup();
//	}
#endif

	if (QSystemTrayIcon::isSystemTrayAvailable())
		createTrayIcon(startInTray);
	else
		show();

	connectedToService = false;
	textStatus->setText(tr("connecting to wpa_supplicant"));
	timer = new QTimer(this);
	connect(timer, SIGNAL(timeout()), SLOT(ping()));
	timer->setSingleShot(FALSE);
	timer->start(1000);

	if (openCtrlConnection(ctrl_iface) < 0) {
		printf("Failed to open control connection to "
		       "wpa_supplicant.\n");
	}

	updateStatus();
	networkMayHaveChanged = true;
	updateNetworks();
}
Пример #27
0
void MainWindow::clearLogFiles()
{
#ifdef ITALC_BUILD_WIN32
	bool stopped = false;
	if( isServiceRunning() )
	{
		if( QMessageBox::question( this, tr( "iTALC Service" ),
				tr( "The iTALC service needs to be stopped temporarily "
					"in order to remove the log files. Continue?"
					), QMessageBox::Yes | QMessageBox::No,
				QMessageBox::Yes ) == QMessageBox::Yes )
		{
			stopService();
			stopped = true;
		}
		else
		{
			return;
		}
	}
#endif

	bool success = true;
	QDir d( LocalSystem::Path::expand( ItalcCore::config->logFileDirectory() ) );
	foreach( const QString &f, d.entryList( QStringList() << "Italc*.log" ) )
	{
		if( f != "ItalcManagementConsole.log" )
		{
			success &= d.remove( f );
		}
	}

#ifdef ITALC_BUILD_WIN32
	d = QDir( "C:\\Windows\\Temp" );
#else
	d = QDir( "/tmp" );
#endif

	foreach( const QString &f, d.entryList( QStringList() << "Italc*.log" ) )
	{
		if( f != "ItalcManagementConsole.log" )
		{
			success &= d.remove( f );
		}
	}

#ifdef ITALC_BUILD_WIN32
	if( stopped )
	{
		startService();
	}
#endif

	if( success )
	{
		QMessageBox::information( this, tr( "Log files cleared" ),
			tr( "All log files were cleared successfully." ) );
	}
	else
	{
		QMessageBox::critical( this, tr( "Error" ),
			tr( "Could not remove all log files." ) );
	}
}
Пример #28
0
static long msgProc(HWND hwnd, uint msg, uint wp, long lp)
{
    char    buf[MPR_MAX_FNAME];

    switch (msg) {
    case WM_DESTROY:
    case WM_QUIT:
        mprSignalExit(mpr);
        break;
    
    case APPWEB_MONITOR_MESSAGE:
        return monitorEvent(hwnd, wp, lp);

    case WM_COMMAND:
        switch (LOWORD(wp)) {
        case MA_MENU_STATUS:
            break;

        case MA_MENU_DOC:
            runBrowser("/doc/index.html");
            break;

        case MA_MENU_MANAGE:
            runBrowser("/index.html");
            break;

        case MA_MENU_START:
            startService();
            break;

        case MA_MENU_STOP:
            stopService();
            break;

        case MA_MENU_ABOUT:
            /*
             *  Single-threaded users beware. This blocks !!
             */
            mprSprintf(buf, sizeof(buf), "%s %s-%s", BLD_NAME, BLD_VERSION, BLD_NUMBER);
            MessageBoxEx(NULL, buf, mprGetAppTitle(mpr), MB_OK, 0);
            break;

        case MA_MENU_EXIT:
            /* 
             *  FUTURE
             *
             *  h = CreateDialog(appInst, MAKEINTRESOURCE(IDD_EXIT), appHwnd, dialogProc);
             *  ShowWindow(h, SW_SHOW);
             */
            PostMessage(hwnd, WM_QUIT, 0, 0L);
            break;

        default:
            return DefWindowProc(hwnd, msg, wp, lp);
        }
        break;

    default:
        return DefWindowProc(hwnd, msg, wp, lp);
    }
    return 0;
}
Пример #29
0
 void AutoCompleteService::restartWorker() {
     m_RestartRequired = true;
     stopService();
 }