/*!
    Dispatch the SMS datagram \a msg according to its SMS port number
    or WAP Push MIME type.  This is used by telephony services that
    accept incoming SMS messages to dispatch them according to the
    installed services.  Returns true if the message was dispatched,
    or false if no service exists that can handle the message.

    See the documentation for QSMSMessage::destinationPort() for more
    information on how WAP push messages and SMS datagrams are dispatched.

    \sa QSMSMessage::destinationPort()
*/
bool QTelephonyService::dispatchDatagram( const QSMSMessage& msg )
{
    QString chan, type;
    QDSServiceInfo info;
    QByteArray payload;
    QByteArray raw;

    // If the message does not have a port number, then it isn't a datagram.
    int port = msg.destinationPort();
    if ( port == -1 )
        return dispatchFlashMessage( msg );

    // Recognise port numbers that may contain WAP push datagrams.
    // We want to check the content type to see if we have a
    // specialised handler for it before dispatching by port number.
    if ( port == 2948 || port == 49999 ) {
        type = QWspPush::quickContentType( msg.applicationData() );
        qLog(Modem) << "WAP push message of type " << type;
        QDSServices services( type, QString(), QStringList() << "push" );
        if ( !services.isEmpty() ) {
            info = services.first();
            QByteArray a = msg.applicationData();
            QBuffer pushpdu(&a);
            pushpdu.open(QIODevice::ReadOnly);
            QWspPduDecoder decoder(&pushpdu);
            QWspPush push = decoder.decodePush();
            payload = push.data();
        }
    }

    // See if we have a registered service for this port number.
    if ( !info.isValid() ) {
        qLog(Modem) << "SMS datagram on port " << port;
        type = "application/x-smsapp-" + QString::number(port);
        QDSServices services( type, QString(), QStringList() << "push" );
        if ( !services.isEmpty() ) {
            info = services.first();
            payload = msg.applicationData();
        } else {
            return dispatchFlashMessage( msg );
        }
    }

    // Pack the entire SMS message into a raw datastream, to be sent
    // along with the message as auxillary data.  This allows programs
    // that need the full SMS/WAP headers to access them.
    {
        QDataStream stream
            ( &raw, QIODevice::WriteOnly | QIODevice::Append );
        stream << msg;
    }

    // Send the datagram to the specified QDS service for processing.
    QDSAction action( info );
    action.invoke( QDSData( payload, QMimeType( type ) ), raw );

    // The datagram has been dispatched.
    return true;
}
Exemple #2
0
void CameraMainWindow::moveToContact()
{
    /*if ( cur_thumb >= 0 ) {
        QtopiaServiceRequest e("Contacts","setContactImage(QString)");
        e << picturefile[cur_thumb].fileName();
        e.send();
    }*/

    if ( cur_thumb >= 0 ) {
        // Find a suitable QDS service
        QDSServices services( QString( "image/jpeg" ) );

        // Select the first service to create the action (assuming there
        // is only be one address book type application on the device)
        QDSAction action( services.findFirst( "setContactImage" ) );
        if ( !action.isValid() ) {
            qWarning( "Camera found no service to set the contact image" );
            return;
        }

        QFile pixFile(picturefile[cur_thumb].fileName());
        QDSData pixData(pixFile, QMimeType( "image/jpeg" ) );

        if ( action.exec( pixData ) != QDSAction::Complete ) {
            qWarning( "Camera unable to set contact image" );
            return;
        }
    }
}
void RegistrationMethodPlatePluginActivator::start(ctkPluginContext* context)
{
	RegServices services(context);
	RegistrationMethodPlateImageToPatientService* image2patientService = new RegistrationMethodPlateImageToPatientService(services);

	mRegistrationImageToPatient = RegisteredServicePtr(new RegisteredService(context, image2patientService, RegistrationMethodService_iid));
}
Exemple #4
0
void MHSyncItemInfo::setExportedServicesFromString(const char* servicesList)
{
    StringBuffer services(servicesList);
    
    if (services.empty() == false) {
        ArrayList servicesParam;
        int servicesNum = 0;
        
        services.split(servicesParam, ",");
        
        servicesNum = servicesParam.size();
        
        for (int i = 0; i < servicesNum; i++) {
            StringBuffer* serviceParamStr = static_cast<StringBuffer *>(servicesParam.get(i));
                
            if ((serviceParamStr) && (serviceParamStr->empty() == false)) {
                ArrayList serviceParam;
                              
                serviceParamStr->split(serviceParam, ":");
                
                if (serviceParam.size() == 2) {
                    StringBuffer* serviceName = static_cast<StringBuffer *>(serviceParam.get(0));
                    StringBuffer* serviceExportTime = static_cast<StringBuffer *>(serviceParam.get(1));
                        
                    exportedServices.put(serviceName->c_str(), serviceExportTime->c_str());
                }
            }
        }
    }
}
void
BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue)
{
  const nsString& name = aValue.name();
  const BluetoothValue& value = aValue.value();
  if (name.EqualsLiteral("Name")) {
    mName = value.get_nsString();
  } else if (name.EqualsLiteral("Path")) {
    MOZ_ASSERT(value.get_nsString().Length() > 0);
    mPath = value.get_nsString();
  } else if (name.EqualsLiteral("Address")) {
    mAddress = value.get_nsString();
  } else if (name.EqualsLiteral("Class")) {
    mClass = value.get_uint32_t();
  } else if (name.EqualsLiteral("Icon")) {
    mIcon = value.get_nsString();
  } else if (name.EqualsLiteral("Connected")) {
    mConnected = value.get_bool();
  } else if (name.EqualsLiteral("Paired")) {
    mPaired = value.get_bool();
  } else if (name.EqualsLiteral("UUIDs")) {
    mUuids = value.get_ArrayOfnsString();

    AutoJSAPI jsapi;
    if (!jsapi.Init(GetOwner())) {
      BT_WARNING("Failed to initialise AutoJSAPI!");
      return;
    }
    JSContext* cx = jsapi.cx();
    JS::Rooted<JSObject*> uuids(cx);
    if (NS_FAILED(nsTArrayToJSArray(cx, mUuids, &uuids))) {
      BT_WARNING("Cannot set JS UUIDs object!");
      return;
    }
    mJsUuids = uuids;
    Root();
  } else if (name.EqualsLiteral("Services")) {
    mServices = value.get_ArrayOfnsString();

    AutoJSAPI jsapi;
    if (!jsapi.Init(GetOwner())) {
      BT_WARNING("Failed to initialise AutoJSAPI!");
      return;
    }
    JSContext* cx = jsapi.cx();
    JS::Rooted<JSObject*> services(cx);
    if (NS_FAILED(nsTArrayToJSArray(cx, mServices, &services))) {
      BT_WARNING("Cannot set JS Services object!");
      return;
    }
    mJsServices = services;
    Root();
  } else {
    nsCString warningMsg;
    warningMsg.AssignLiteral("Not handling device property: ");
    warningMsg.Append(NS_ConvertUTF16toUTF8(name));
    BT_WARNING(warningMsg.get());
  }
}
void
BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue)
{
  const nsString& name = aValue.name();
  const BluetoothValue& value = aValue.value();
  if (name.EqualsLiteral("Name")) {
    mName = value.get_nsString();
  } else if (name.EqualsLiteral("Path")) {
    MOZ_ASSERT(value.get_nsString().Length() > 0);
    mPath = value.get_nsString();
  } else if (name.EqualsLiteral("Address")) {
    mAddress = value.get_nsString();
  } else if (name.EqualsLiteral("Class")) {
    mClass = value.get_uint32_t();
  } else if (name.EqualsLiteral("Icon")) {
    mIcon = value.get_nsString();
  } else if (name.EqualsLiteral("Connected")) {
    mConnected = value.get_bool();
  } else if (name.EqualsLiteral("Paired")) {
    mPaired = value.get_bool();
  } else if (name.EqualsLiteral("UUIDs")) {
    mUuids = value.get_ArrayOfnsString();
    nsresult rv;
    nsIScriptContext* sc = GetContextForEventHandlers(&rv);
    NS_ENSURE_SUCCESS_VOID(rv);
    NS_ENSURE_TRUE_VOID(sc);

    AutoPushJSContext cx(sc->GetNativeContext());

    JS::Rooted<JSObject*> uuids(cx);
    if (NS_FAILED(nsTArrayToJSArray(cx, mUuids, uuids.address()))) {
      BT_WARNING("Cannot set JS UUIDs object!");
      return;
    }
    mJsUuids = uuids;
    Root();
  } else if (name.EqualsLiteral("Services")) {
    mServices = value.get_ArrayOfnsString();
    nsresult rv;
    nsIScriptContext* sc = GetContextForEventHandlers(&rv);
    NS_ENSURE_SUCCESS_VOID(rv);
    NS_ENSURE_TRUE_VOID(sc);

    AutoPushJSContext cx(sc->GetNativeContext());

    JS::Rooted<JSObject*> services(cx);
    if (NS_FAILED(nsTArrayToJSArray(cx, mServices, services.address()))) {
      BT_WARNING("Cannot set JS Services object!");
      return;
    }
    mJsServices = services;
    Root();
  } else {
    nsCString warningMsg;
    warningMsg.AssignLiteral("Not handling device property: ");
    warningMsg.Append(NS_ConvertUTF16toUTF8(name));
    BT_WARNING(warningMsg.get());
  }
}
void RegistrationGUIPluginActivator::start(ctkPluginContext* context)
{
	mRegistration = RegisteredService::create<RegistrationGUIExtenderService>(context, GUIExtenderService_iid);

	RegServices services(context);
	RegistrationHistoryGUIExtenderService *history = new RegistrationHistoryGUIExtenderService(services);
	mRegistrationHistory = RegisteredServicePtr(new RegisteredService(context, history, GUIExtenderService_iid));
}
Exemple #8
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nCmdShow)
{
    ConsoleRig::StartupConfig cfg("texturetransform");
    cfg._setWorkingDir = false;
    ConsoleRig::GlobalServices services(cfg);

    TRY {
        TextureTransform::Execute(lpCmdLine);
    } CATCH (const std::exception& e) {
        LogAlwaysError << "Hit top level exception. Aborting program!";
        LogAlwaysError << e.what();
    }
Exemple #9
0
void JobSupervisorTest::TestResubmit()
{
  std::list<Arc::Job> jobs;
  std::string id1("http://test.nordugrid.org/1234567890test1"),
              id2("http://test.nordugrid.org/1234567890test2"),
              id3("http://test.nordugrid.org/1234567890test3");

  j.State = Arc::JobStateTEST(Arc::JobState::FAILED);
  j.JobID = id1;
  j.JobDescriptionDocument = "CONTENT";
  jobs.push_back(j);

  j.State = Arc::JobStateTEST(Arc::JobState::RUNNING);
  j.JobID = id1;
  j.JobDescriptionDocument = "CONTENT";
  jobs.push_back(j);

  usercfg.Broker("TEST");

  Arc::ComputingServiceType cs;

  Arc::ComputingEndpointType ce;
  ce->URLString = "http://test2.nordugrid.org";
  ce->InterfaceName = "org.nordugrid.test";
  ce->Capability.insert(Arc::Endpoint::GetStringForCapability(Arc::Endpoint::JOBSUBMIT));
  ce->HealthState = "ok";

  cs.ComputingEndpoint.insert(std::pair<int, Arc::ComputingEndpointType>(0, ce));
  cs.ComputingShare.insert(std::pair<int, Arc::ComputingShareType>(0, Arc::ComputingShareType()));
  Arc::ComputingManagerType cm;
  cm.ExecutionEnvironment.insert(std::pair<int, Arc::ExecutionEnvironmentType>(0, Arc::ExecutionEnvironmentType()));
  cs.ComputingManager.insert(std::pair<int, Arc::ComputingManagerType>(0, cm));

  Arc::TargetInformationRetrieverPluginTESTControl::targets.push_back(cs);
  Arc::TargetInformationRetrieverPluginTESTControl::status = Arc::EndpointQueryingStatus::SUCCESSFUL;

  Arc::BrokerPluginTestACCControl::match = true;

  js = new Arc::JobSupervisor(usercfg, jobs);

  std::list<Arc::Endpoint> services(1, Arc::Endpoint("http://test2.nordugrid.org",  Arc::Endpoint::COMPUTINGINFO, "org.nordugrid.tirtest"));
  std::list<Arc::Job> resubmitted;
  CPPUNIT_ASSERT(js->Resubmit(0, services, resubmitted));
  CPPUNIT_ASSERT_EQUAL(2, (int)resubmitted.size());

  delete js;
}
bool APIServiceManager::_AuthenticateUserNamePassword(std::string username, std::string password)
{
    // Query account info
    AccountInfo account_info;
    if( !services().serviceDB().GetAccountInformation(
            username.c_str(), account_info ) )
        return false;

    // Compute pass hash
    std::string passHash;
    if( !PasswordModule::GeneratePassHash(
            username, password, passHash ) )
        return false;

    // Compare the hashes
    return passHash == account_info.hash;
}
std::tr1::shared_ptr<std::string> APIServerManager::_ServerStatus(const APICommandCall * pAPICommandCall)
{
    uint32 playersOnline = services().entity_list.GetClientCount();
    std::string playersOnlineStr( itoa( playersOnline ) );

    _BuildXMLHeader();
    {
        _BuildXMLTag( "result" );
        {
            _BuildSingleXMLTag( "serverOpen", "True" );
            _BuildSingleXMLTag( "onlinePlayers", playersOnlineStr );
        }
        _CloseXMLTag(); // close tag "result"
    }
    _CloseXMLHeader( EVEAPI::CacheStyles::Modified );

    return _GetXMLDocumentString();
}
Exemple #12
0
QString RDUser::serviceCheckDefault(QString serv) const
{
  bool match_flag = false;
  QStringList services_list = services();

  for ( QStringList::Iterator it = services_list.begin(); 
        it != services_list.end(); ++it ) {
    if (serv.compare(*it) == 0) {
      match_flag = true;
      break;
    }
  }

  if (match_flag)
    return serv;
  else
    return QString("");
}
int main(int argc, char** argv) {
	ros::init(argc, argv, "runaway");
	
	//handle to Node
	ros::NodeHandle nh;
	
	//publish to the turtle
	ros::Publisher turtle_pub = nh.advertise<geometry_msgs::Twist>("/turtle1/cmd_vel", 1);
	
	Services services(&nh);	
	
	//subscribe from the rp lidar scan
	//as arguments pass -> method which should be invoked and reference to the publisher, it is the turtle
	ros::Subscriber sub = nh.subscribe<sensor_msgs::LaserScan>("/scan", 1, boost::bind(scanFromReader, _1, boost::ref(turtle_pub), boost::ref(services)));
	
	ros::spin();
	
	return 0;
}
bool APIServiceManager::_AuthenticateUserNamePassword(std::string username, std::string password)
{
    AccountInfo account_info;
    std::string passHash;
    std::wstring w_username = Utils::Strings::StringToWString( username );
    std::wstring w_password = Utils::Strings::StringToWString( password );
    PasswordModule::GeneratePassHash( w_username,w_password,passHash );
    //std::string hexHash = PasswordModule::GenerateHexString( passHash );
    //std::string dateTime = Win32TimeToString( Win32TimeNow() );

    if (!services().serviceDB().GetAccountInformation( username.c_str(),  account_info ) )
    {
        return false;
    }

    if( passHash.compare( account_info.hash ) == 0 )
        return true;
    else
        return false;
}
// Check for and dispatch flash sms messages.
static bool dispatchFlashMessage( const QSMSMessage& msg )
{
    if ( msg.messageClass() != 0 )
        return false;
    qLog(Modem) << "SMS flash message";
    QString type = "application/x-sms-flash";
    QDSServices services( type, QString(), QStringList() << "push" );
    if ( !services.isEmpty() ) {
        QDSAction action( services.first() );
        QByteArray payload;
        {
            QDataStream stream
                ( &payload, QIODevice::WriteOnly | QIODevice::Append );
            stream << msg;
        }
        action.invoke( QDSData( payload, QMimeType( type ) ) );
        return true;
    } else {
        return false;
    }
}
//test only
int mmain(int argc, char** argv) {
	ros::init(argc, argv, "runaway");
	
	ros::NodeHandle nh;

	//publish to turtle	
	ros::Publisher turtle_pub = nh.advertise<geometry_msgs::Twist>("/turtle1/cmd_vel", 1);
	
	Services services(&nh);
	
	while(ros::ok()){
		
		//define loop rate
		ros::Rate loop_rate(FREQ);		
		//teleport turtle
		services.teleport_turtle();
		//clear his path
		services.clear_turtle();
		//move him
		moveTurtle(&turtle_pub, 2.0);	

		loop_rate.sleep();
	}
}
Exemple #17
0
int main( int argc, char* argv[] )
{
#if defined( MSVC ) && !defined( NDEBUG )
    // Under Visual Studio setup memory leak detection
    _CrtSetDbgFlag( _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) );
#endif /* defined( MSVC ) && !defined( NDEBUG ) */

    printf("Copyright (C) 2006-2011 EVEmu Team. http://evemu.org/\n");
    printf("This program is free software; you can redistribute it and/or modify it under\n");
    printf("the terms of the GNU Lesser General Public License as published by the Free \n");
    printf("Software Foundation; either version 2 of the License, or (at your option) any\n");
    printf("later version.\n");
    printf("\n");
    printf("This program is distributed in the hope that it will be useful, but WITHOUT\n");
    printf("ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n");
    printf("FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more\n");
    printf("details.\n");
    printf("\n");

    sLog.Log("main", "EVEmu "EVEMU_VERSION );
    sLog.Log("server init", "\n"
        "\tSupported Client: %s\n"
        "\tVersion %.2f\n"
        "\tBuild %d\n"
        "\tMachoNet %u",
        EVEProjectVersion,
        EVEVersionNumber,
        EVEBuildVersion,
        MachoNetVersion
    );

    //it is important to do this before doing much of anything, in case they use it.
    Timer::SetCurrentTime();

    // Load server configuration
    sLog.Log("server init", "Loading server configuration...");

    if( !sConfig.ParseFile( CONFIG_FILE ) )
    {
        sLog.Error( "server init", "Loading server configuration '%s' failed.", CONFIG_FILE );
        return 1;
    }

    // Load server log settings ( will be removed )
    if( load_log_settings( sConfig.files.logSettings.c_str() ) )
        sLog.Success( "server init", "Log settings loaded from %s", sConfig.files.logSettings.c_str() );
    else
        sLog.Warning( "server init", "Unable to read %s (this file is optional)", sConfig.files.logSettings.c_str() );

    // open up the log file if specified ( will be removed )
    if( !sConfig.files.log.empty() )
    {
        if( log_open_logfile( sConfig.files.log.c_str() ) )
            sLog.Success( "server init", "Opened log file %s", sConfig.files.log.c_str() );
        else
            sLog.Warning( "server init", "Unable to open log file '%s', only logging to the screen now.", sConfig.files.log.c_str() );
    }

    //connect to the database...
    DBerror err;
    if( !sDatabase.Open( err,
        sConfig.database.host.c_str(),
        sConfig.database.username.c_str(),
        sConfig.database.password.c_str(),
        sConfig.database.db.c_str(),
        sConfig.database.port ) )
    {
        sLog.Error( "server init", "Unable to connect to the database: %s", err.c_str() );
        return 1;
    }
    _sDgmTypeAttrMgr = new dgmtypeattributemgr(); // needs to be after db init as its using it

    _sDgmTypeAttrMgr = new dgmtypeattributemgr(); // needs to be after db init as its using it

    //Start up the TCP server
    EVETCPServer tcps;

    char errbuf[ TCPCONN_ERRBUF_SIZE ];
    if( tcps.Open( sConfig.net.port, errbuf ) )
    {
        sLog.Success( "server init", "TCP listener started on port %u.", sConfig.net.port );
    }
    else
    {
        sLog.Error( "server init", "Failed to start TCP listener on port %u: %s.", sConfig.net.port, errbuf );
        return 1;
    }
	//make the item factory
    ItemFactory item_factory( sEntityList );

    //now, the service manager...
    PyServiceMgr services( 888444, sEntityList, item_factory );

    //setup the command dispatcher
    CommandDispatcher command_dispatcher( services );
    RegisterAllCommands( command_dispatcher );

    /*
     * Service creation and registration.
     *
     */
    sLog.Log("server init", "Creating services.");

    services.RegisterService(new ClientStatsMgr(&services));
    services.RegisterService(new AgentMgrService(&services));
    services.RegisterService(new MissionMgrService(&services));
    services.RegisterService(new AccountService(&services));
    services.RegisterService(new UserService(&services));
    services.RegisterService(new AlertService(&services));
    services.RegisterService(new AuthService(&services));
    services.RegisterService(new BillMgrService(&services));
    services.RegisterService(new BookmarkService(&services));
    services.RegisterService(new BrowserLockDownService(&services));
    services.RegisterService(new CertificateMgrService(&services));
    services.RegisterService(new CharacterService(&services));
    services.RegisterService(new CharMgrService(&services));
    services.RegisterService(new ConfigService(&services));
    services.RegisterService(new LanguageService(&services));
    services.RegisterService(new CorpMgrService(&services));
    services.RegisterService(new CorpStationMgrService(&services));
    services.RegisterService(new CorporationService(&services));
    services.RegisterService(new CorpRegistryService(&services));
    services.RegisterService(new ContractProxyService(&services));
    services.RegisterService(new LPService(&services));
    services.RegisterService(new DogmaIMService(&services));
    services.RegisterService(new InvBrokerService(&services));
    services.RegisterService(services.lsc_service = new LSCService(&services, &command_dispatcher));
    services.RegisterService(services.cache_service = new ObjCacheService(&services, sConfig.files.cacheDir.c_str()));
    services.RegisterService(new LookupService(&services));
    services.RegisterService(new VoiceMgrService(&services));
    services.RegisterService(new ShipService(&services));
    services.RegisterService(new InsuranceService(&services));
    services.RegisterService(new BeyonceService(&services));
    services.RegisterService(new MapService(&services));
    services.RegisterService(new OnlineStatusService(&services));
    services.RegisterService(new Standing2Service(&services));
    services.RegisterService(new WarRegistryService(&services));
    services.RegisterService(new FactionWarMgrService(&services));
    services.RegisterService(new StationService(&services));
    services.RegisterService(new StationSvcService(&services));
    services.RegisterService(new JumpCloneService(&services));
    services.RegisterService(new KeeperService(&services));
    services.RegisterService(new DungeonService(&services));
    services.RegisterService(new SkillMgrService(&services));
    services.RegisterService(new TutorialService(&services));
    services.RegisterService(new PetitionerService(&services));
    services.RegisterService(new SlashService(&services, &command_dispatcher));
    services.RegisterService(new MarketProxyService(&services));
    services.RegisterService(new ContractMgrService(&services));
    services.RegisterService(new ReprocessingService(&services));
    services.RegisterService(new FactoryService(&services));
    services.RegisterService(new RamProxyService(&services));
    services.RegisterService(new PosMgrService(&services));
    services.RegisterService(new NetService(&services));
	services.RegisterService(new TradeService(&services));
	services.RegisterService(new CharUnboundMgrService(&services));
	services.RegisterService(new PaperDollService(&services));
	services.RegisterService(new PhotoUploadService(&services));
	services.RegisterService(new AggressionMgrService(&services));
	services.RegisterService(new SovereigntyMgrService(&services));

    sLog.Log("server init", "Priming cached objects.");
    services.cache_service->PrimeCache();
    sLog.Log("server init", "finished priming");

	// start up the image server
	ImageServer::get().Run();

    services.serviceDB().SetServerOnlineStatus(true);

    sLog.Log("server init", "Init done.");

    /*
     * THE MAIN LOOP
     *
     * Everything except IO should happen in this loop, in this thread context.
     *
     */

    /* program events system */
    SetupSignals();

    uint32 start;
    uint32 etime;
    uint32 last_time = GetTickCount();

    EVETCPConnection* tcpc;
    while( RunLoops == true )
    {
        Timer::SetCurrentTime();
        start = GetTickCount();

        //check for timeouts in other threads
        //timeout_manager.CheckTimeouts();
        while( ( tcpc = tcps.PopConnection() ) )
        {
            Client* c = new Client( services, &tcpc );

            sEntityList.Add( &c );
        }

        sEntityList.Process();
        services.Process();

        /* UPDATE */
        last_time = GetTickCount();
        etime = last_time - start;

        // do the stuff for thread sleeping
        if( MAIN_LOOP_DELAY > etime )
            Sleep( MAIN_LOOP_DELAY - etime );
    }

    sLog.Log("server shutdown", "Main loop stopped" );

    tcps.Close();

    sLog.Log("server shutdown", "TCP listener stopped." );

    services.serviceDB().SetServerOnlineStatus(false);

    sLog.Log("server shutdown", "Cleanup db cache" );
    delete _sDgmTypeAttrMgr;

    log_close_logfile();

    // win crap.
    //_CrtDumpMemoryLeaks();
    return 0;
}
Exemple #18
0
  // arguments: # of bins and range for histogram to be tested
  DQMQualityTest(int NBINS, float XMIN, float XMAX)
  { 
    // Process each file given as argument.
    edm::ParameterSet emptyps;
    std::vector<edm::ParameterSet> emptyset;
    edm::ServiceToken services(edm::ServiceRegistry::createSet(emptyset));

    edm::ServiceRegistry::Operate operate(services);

    //dbe_ = edm::Service<DQMStore>().operator->();
    DQMStore* dbe_ = new DQMStore(emptyps);	

    xmin_ = XMIN; xmax_ = XMAX;
    // distribution: gaussian w/ parameters: mean, sigma
    mean = (xmin_ + xmax_)/2.0;
    sigma = (xmax_ - xmin_)/6.0;

    // reference histogram
    dbe_->setCurrentFolder("/Reference");
    my_ref = dbe_->book1D("my_ref", "reference histo", NBINS, XMIN, XMAX);
    // test histogram
    dbe_->setCurrentFolder("/");
    my_test = dbe_->book1D("my_test", "test histo", NBINS, XMIN, XMAX);
    dbe_->setCurrentFolder("/");

    // Chi2-based test
    chi2_test_ = new Comp2RefChi2("my_chi2");
    // Kolmogorov-based test
    ks_test_ = new Comp2RefKolmogorov("my_kolm");
    // contents within x-range test
    xrange_test_ = new ContentsXRange("my_xrange");
    // set allowed range to [10, 90]% of nominal
    xrange_test_->setAllowedXRange(0.1*xmin_, 0.9*xmax_);
     // contents within y-range test
    yrange_test_ = new ContentsYRange("my_yrange");
    // set allowed range to [0, 40] entries
    yrange_test_->setAllowedYRange(0, 40);
   // check for dead channels
    deadChan_test_ = new DeadChannel("deadChan");
    // set threshold for dead channel (default: 0)
    deadChan_test_->setThreshold(0);
   // check for noisy channels
    noisyChan_test_ = new NoisyChannel("noisyChan");
    // set tolerance for noisy channel
    noisyChan_test_->setTolerance(0.30);
    // set # of neighboring channels for calculating average (default: 1)
    noisyChan_test_->setNumNeighbors(2);

    // Mean-within-expected-value test
    meanNear_test_ = new MeanWithinExpected("meanNear");
    // set expected mean value
    meanNear_test_->setExpectedMean(mean);
    // use RMS of distribution to judge if mean near expected value
    meanNear_test_->useRMS();
    //
//    emu_test_ = new AllContentWithinFixedRange("Ricks_test");

    // MostProbableLandau
    //poMPLandau_test_ = new MostProbableLandau( "mplandau");
    //poMPLandau_test_->setXMin( xmin_);
    //poMPLandau_test_->setXMax( xmax_);
    //poMPLandau_test_->setMostProbable( dLandauMP_);
    //poMPLandau_test_->setSigma( dLandauSigma_);

    // equality test for histograms
    equalH_test_ = new Comp2RefEqualH("my_histo_equal");
    // equality test for integers
    // equalInt_test_ = new Comp2RefEqualInt("my_int_equal");
    // init
  }
Exemple #19
0
IRendererController::Status MasterRenderer::initialize_and_render_frame_sequence()
{
    assert(m_project.get_scene());
    assert(m_project.get_frame());

    // Reset the abort switch.
    if (m_abort_switch)
        m_abort_switch->clear();

#ifdef WITH_OSL

    // Create the error handler.
    OIIOErrorHandler error_handler;

    // While debugging, we want all possible outputs.
#ifndef NDEBUG
    error_handler.verbosity(OIIO::ErrorHandler::VERBOSE);
#endif

    const size_t texture_cache_size =
        m_params.get_optional<size_t>("texture_cache_size",  256 * 1024 * 1024);

    // If the texture cache size changes, we have to recreate the texture system.
    if (texture_cache_size != m_texture_cache_size)
    {
        m_texture_cache_size = texture_cache_size;
        m_texture_system.reset();
    }

    // Create the OIIO texture system, if needed.
    if (!m_texture_system)
    {
        m_texture_system.reset(
            OIIO::TextureSystem::create(false),
            bind(&OIIO::TextureSystem::destroy, _1));
    }

    // Set the texture system mem limit.
    m_texture_system->attribute("max_memory_MB", static_cast<float>(m_texture_cache_size / 1024));

    std::string search_paths;

    // Skip search paths for builtin projects.
    if (m_project.search_paths().has_root_path())
    {
        // Setup texture / shader search paths.
        // In OIIO / OSL, the path priorities are the opposite of appleseed,
        // so we copy the paths in reverse order.

        const filesystem::path root_path = m_project.search_paths().get_root_path();

        if (!m_project.search_paths().empty())
        {
            for (size_t i = 0, e = m_project.search_paths().size(); i != e; ++i)
            {
                filesystem::path p(m_project.search_paths()[e - 1 - i]);

                if (p.is_relative())
                   p = root_path / p;

                search_paths.append(p.string());
                search_paths.append(";");
            }
        }

        search_paths.append(root_path.string());
    }

    if (!search_paths.empty())
        m_texture_system->attribute("searchpath", search_paths);

    // TODO: set other texture system options here.

    // Create our renderer services.
    RendererServices services(m_project, *m_texture_system);

    // Create our OSL shading system.
    boost::shared_ptr<OSL::ShadingSystem> shading_system(
        OSL::ShadingSystem::create(
            &services,
            m_texture_system.get(),
            &error_handler),
            bind(&destroy_osl_shading_system, _1, m_texture_system.get()));

    if (!search_paths.empty())
        shading_system->attribute("searchpath:shader", search_paths);

    shading_system->attribute("lockgeom", 1);
    shading_system->attribute("colorspace", "Linear");
    shading_system->attribute("commonspace", "world");

    // This array needs to be kept in sync with the ShadingRay::Type enumeration.
    static const char* ray_type_labels[] =
    {
        "camera",
        "light",
        "shadow",
        "probe",
        "diffuse",
        "glossy",
        "specular"
    };

    shading_system->attribute(
        "raytypes",
        OSL::TypeDesc(
            OSL::TypeDesc::STRING,
            sizeof(ray_type_labels) / sizeof(ray_type_labels[0])),
        ray_type_labels);

#ifndef NDEBUG
    // While debugging, we want all possible outputs.
    shading_system->attribute("debug", 1);
    shading_system->attribute("statistics:level", 1);
    shading_system->attribute("compile_report", 1);
    shading_system->attribute("countlayerexecs", 1);
    shading_system->attribute("clearmemory", 1);
#endif

    register_closures(*shading_system);

#endif  // WITH_OSL

    // We start by binding entities inputs. This must be done before creating/updating the trace context.
    if (!bind_scene_entities_inputs())
        return IRendererController::AbortRendering;

    m_project.create_aov_images();
    m_project.update_trace_context();

    const Scene& scene = *m_project.get_scene();

    Frame& frame = *m_project.get_frame();
    frame.print_settings();

    const TraceContext& trace_context = m_project.get_trace_context();

    // Create the texture store.
    TextureStore texture_store(scene, m_params.child("texture_store"));

    // Create the light sampler.
    LightSampler light_sampler(scene, m_params.child("light_sampler"));

    // Create the shading engine.
    ShadingEngine shading_engine(m_params.child("shading_engine"));

    //
    // Create a lighting engine factory.
    //

    auto_ptr<IPassCallback> pass_callback;
    auto_ptr<ILightingEngineFactory> lighting_engine_factory;
    {
        const string value = m_params.get_required<string>("lighting_engine", "pt");

        if (value == "drt")
        {
            lighting_engine_factory.reset(
                new DRTLightingEngineFactory(
                    light_sampler,
                    m_params.child("drt")));    // todo: change to "drt_lighting_engine" -- or?
        }
        else if (value == "pt")
        {
            lighting_engine_factory.reset(
                new PTLightingEngineFactory(
                    light_sampler,
                    m_params.child("pt")));     // todo: change to "pt_lighting_engine" -- or?
        }
        else if (value == "sppm")
        {
            const SPPMParameters params(m_params.child("sppm"));

            SPPMPassCallback* sppm_pass_callback =
                new SPPMPassCallback(
                    scene,
                    light_sampler,
                    trace_context,
                    texture_store,
#ifdef WITH_OSL
                    *shading_system,
#endif
                    params);
            pass_callback.reset(sppm_pass_callback);

            lighting_engine_factory.reset(
                new SPPMLightingEngineFactory(
                    *sppm_pass_callback,
                    light_sampler,
                    params));
        }
        else
        {
            RENDERER_LOG_ERROR(
                "invalid value for \"lighting_engine\" parameter: \"%s\".",
                value.c_str());

            return IRendererController::AbortRendering;
        }
    }

    //
    // Create a sample renderer factory.
    //

    auto_ptr<ISampleRendererFactory> sample_renderer_factory;
    {
        const string value = m_params.get_required<string>("sample_renderer", "generic");

        if (value == "generic")
        {
            sample_renderer_factory.reset(
                new GenericSampleRendererFactory(
                    scene,
                    frame,
                    trace_context,
                    texture_store,
                    lighting_engine_factory.get(),
                    shading_engine,
#ifdef WITH_OSL
                    *shading_system,
#endif
                    m_params.child("generic_sample_renderer")));
        }
        else if (value == "blank")
        {
            sample_renderer_factory.reset(new BlankSampleRendererFactory());
        }
        else if (value == "debug")
        {
            sample_renderer_factory.reset(new DebugSampleRendererFactory());
        }
        else
        {
            RENDERER_LOG_ERROR(
                "invalid value for \"sample_renderer\" parameter: \"%s\".",
                value.c_str());

            return IRendererController::AbortRendering;
        }
    }

    //
    // Create a sample generator factory.
    //

    auto_ptr<ISampleGeneratorFactory> sample_generator_factory;
    {
        const string value = m_params.get_optional<string>("sample_generator", "");

        if (value == "generic")
        {
            sample_generator_factory.reset(
                new GenericSampleGeneratorFactory(
                    frame,
                    sample_renderer_factory.get()));
        }
        else if (value == "lighttracing")
        {
            sample_generator_factory.reset(
                new LightTracingSampleGeneratorFactory(
                    scene,
                    frame,
                    trace_context,
                    texture_store,
                    light_sampler,
#ifdef WITH_OSL
                    *shading_system,
#endif
                    m_params.child("lighttracing_sample_generator")));
        }
        else if (!value.empty())
        {
            RENDERER_LOG_ERROR(
                "invalid value for \"sample_generator\" parameter: \"%s\".",
                value.c_str());

            return IRendererController::AbortRendering;
        }
    }

    //
    // Create a pixel renderer factory.
    //

    auto_ptr<IPixelRendererFactory> pixel_renderer_factory;
    {
        const string value = m_params.get_optional<string>("pixel_renderer", "");

        if (value == "uniform")
        {
            pixel_renderer_factory.reset(
                new UniformPixelRendererFactory(
                    sample_renderer_factory.get(),
                    m_params.child("uniform_pixel_renderer")));
        }
        else if (value == "adaptive")
        {
            pixel_renderer_factory.reset(
                new AdaptivePixelRendererFactory(
                    frame,
                    sample_renderer_factory.get(),
                    m_params.child("adaptive_pixel_renderer")));
        }
        else if (!value.empty())
        {
            RENDERER_LOG_ERROR(
                "invalid value for \"pixel_renderer\" parameter: \"%s\".",
                value.c_str());

            return IRendererController::AbortRendering;
        }
    }

    //
    // Create a shading result framebuffer factory.
    //

    auto_ptr<IShadingResultFrameBufferFactory> shading_result_framebuffer_factory;
    {
        const string value =
            m_params.get_optional<string>("shading_result_framebuffer", "ephemeral");

        if (value == "ephemeral")
        {
            shading_result_framebuffer_factory.reset(
                new EphemeralShadingResultFrameBufferFactory());
        }
        else if (value == "permanent")
        {
            shading_result_framebuffer_factory.reset(
                new PermanentShadingResultFrameBufferFactory(frame));
        }
        else if (!value.empty())
        {
            RENDERER_LOG_ERROR(
                "invalid value for \"shading_result_framebuffer\" parameter: \"%s\".",
                value.c_str());

            return IRendererController::AbortRendering;
        }
    }

    //
    // Create a tile renderer factory.
    //

    auto_ptr<ITileRendererFactory> tile_renderer_factory;
    {
        const string value = m_params.get_optional<string>("tile_renderer", "");

        if (value == "generic")
        {
            tile_renderer_factory.reset(
                new GenericTileRendererFactory(
                    frame,
                    pixel_renderer_factory.get(),
                    shading_result_framebuffer_factory.get(),
                    m_params.child("generic_tile_renderer")));
        }
        else if (value == "blank")
        {
            tile_renderer_factory.reset(new BlankTileRendererFactory());
        }
        else if (value == "debug")
        {
            tile_renderer_factory.reset(new DebugTileRendererFactory());
        }
        else if (!value.empty())
        {
            RENDERER_LOG_ERROR(
                "invalid value for \"tile_renderer\" parameter: \"%s\".",
                value.c_str());

            return IRendererController::AbortRendering;
        }
    }

    //
    // Create a frame renderer.
    //

    auto_release_ptr<IFrameRenderer> frame_renderer;
    {
        const string value = m_params.get_required<string>("frame_renderer", "generic");

        if (value == "generic")
        {
            ParamArray params = m_params.child("generic_frame_renderer");
            copy_param(params, m_params, "rendering_threads");

            frame_renderer.reset(
                GenericFrameRendererFactory::create(
                    frame,
                    tile_renderer_factory.get(),
                    m_tile_callback_factory,
                    pass_callback.get(),
                    params));
        }
        else if (value == "progressive")
        {
            ParamArray params = m_params.child("progressive_frame_renderer");
            copy_param(params, m_params, "rendering_threads");

            frame_renderer.reset(
                ProgressiveFrameRendererFactory::create(
                    m_project,
                    sample_generator_factory.get(),
                    m_tile_callback_factory,
                    params));
        }
        else
        {
            RENDERER_LOG_ERROR(
                "invalid value for \"frame_renderer\" parameter: \"%s\".",
                value.c_str());

            return IRendererController::AbortRendering;
        }
    }

    // Execute the main rendering loop.
    const IRendererController::Status status =
        render_frame_sequence(
            frame_renderer.get()
#ifdef WITH_OSL
            , *shading_system
#endif
            );

    // Print texture store performance statistics.
    RENDERER_LOG_DEBUG("%s", texture_store.get_statistics().to_string().c_str());

    return status;
}
Exemple #20
0
void MainWindow::createActions()
{
  // file
  updateAction = new QAction(trUtf8("Обновить"), this);
  updateAction->setShortcut(tr("F5"));
  connect(updateAction, SIGNAL(triggered()), this, SLOT(update()));
  
  loadServicesAction = new QAction(trUtf8("Загрузка услуг"), this);
  connect(loadServicesAction, SIGNAL(triggered()), this, SLOT(loadServices()));

  loadServicesMtsAction = new QAction(trUtf8("Загрузка услуг MTC"), this);
  connect(loadServicesMtsAction, SIGNAL(triggered()), this, SLOT(loadServicesMts()));

  loadPaysAction = new QAction(trUtf8("Загрузка платежей"), this);
  connect(loadPaysAction, SIGNAL(triggered()), this, SLOT(loadPays()));

  exitAction = new QAction(trUtf8("Выход"), this);
  exitAction->setShortcut(tr("Ctrl+Q"));
  exitAction->setStatusTip(trUtf8("Выйти из программы"));
  connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));

  // refs
  clientsAction = new QAction(trUtf8("Клиенты"), this);
  // clientsAction->setStatusTip(trUtf8("Информация по клиентам"));
  connect(clientsAction, SIGNAL(triggered()), this, SLOT(clients()));

  abonentTypesAction = new QAction(trUtf8("Типы абонентов"), this);
  // abonentTypesAction->setStatusTip(trUtf8("Информация по клиентам"));
  connect(abonentTypesAction, SIGNAL(triggered()), this, SLOT(abonentTypes()));

  tplansAction = new QAction(trUtf8("Тарифные планы"), this);
  // tplansAction->setStatusTip(trUtf8("Информация по клиентам"));
  connect(tplansAction, SIGNAL(triggered()), this, SLOT(tplans()));

  operatorsAction = new QAction(trUtf8("Операторы"), this);
  operatorsAction->setStatusTip(trUtf8("Операторы"));
  connect(operatorsAction, SIGNAL(triggered()), this, SLOT(operators()));

  servicesAction = new QAction(trUtf8("Услуги"), this);
  // tplansAction->setStatusTip(trUtf8("Информация по клиентам"));
  connect(servicesAction, SIGNAL(triggered()), this, SLOT(services()));

  paysAction = new QAction(trUtf8("Платежи"), this);
  paysAction->setStatusTip(trUtf8("Информация по платежам"));
  connect(paysAction, SIGNAL(triggered()), this, SLOT(pays()));

  correctionsAction = new QAction(trUtf8("Корректировки"), this);
  connect(correctionsAction, SIGNAL(triggered()), this, SLOT(corrections()));

  arcsAction = new QAction(trUtf8("Архив"), this);
  arcsAction->setStatusTip(trUtf8("Архив"));
  arcsAction->setEnabled(userGr_ == 0);
  connect(arcsAction, SIGNAL(triggered()), this, SLOT(arcs()));
    
  // operations
  calc4abonentsAction = new QAction(trUtf8("1 Рассчет по абонентам"), this);
  connect(calc4abonentsAction, SIGNAL(triggered()), this, SLOT(calc4abonents()));

  calc4clientsAction = new QAction(trUtf8("2 Рассчет по клиентам (+счета)"), this);
  connect(calc4clientsAction, SIGNAL(triggered()), this, SLOT(calc4clients()));

  files4clientsAction = new QAction(trUtf8("Счета по по клиентам"), this);
  connect(files4clientsAction, SIGNAL(triggered()), this, SLOT(files4clients()));

  // reports
  noAbonentsAction = new QAction(trUtf8("Начисления без абонентов"), this);
  connect(noAbonentsAction, SIGNAL(triggered()), this, SLOT(noAbonents()));

  noAccrualsAction = new QAction(trUtf8("Абоненты без начислений"), this);
  connect(noAccrualsAction, SIGNAL(triggered()), this, SLOT(noAccruals()));


  aboutAction = new QAction(tr("&About"), this);
  aboutAction->setStatusTip(tr("Show the application's About box"));
  connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
}
int main(){

    HWND hwnd = GetConsoleWindow();
	ShowWindow(hwnd,SW_MAXIMIZE);
    console_settings();
    console_resize(3);
    login=fopen("save\\logins.dat","rb");
    if(login==NULL)
        admin_settings_signup();
    else
        admin_settings_signin();

    main_menu();
    start_socket();
    start_server();

    handleAccept = (HANDLE) _beginthread(thd_accept_connections,0,0);
    handleMessages = (HANDLE) _beginthread(thd_program_messages,0,0);
    //clientHandle = (HANDLE) _beginthread( thd_receive_data,0,0);

    while(1){  // The interface part
      switch(getch()){
        case '1':
                if(flag_menu==0)
                   requests();
                else if(flag_menu==2)
                    services();
                else if(flag_menu==21)
                    add_services();
                else if(flag_menu==22)
                    setcost();
                else if(flag_menu==24)
                    change_password();
                break;
            case '2':
                if(flag_menu==0)
                    settings();
                else if(flag_menu==2)
                    cost();
                else if(flag_menu==22)
                    viewcost();
                else if(flag_menu==21)
                    view_services();
                break;
            case '3':
                if(flag_menu==0){
                    saveMessagesToFile();
                    exit(0);
                }
                else if(flag_menu==2)
                    member_settings_signup();
                else if(flag_menu==21)
                    edit_services();
                break;
            case '4':
                if(flag_menu==21)
                    search_services();
                else if(flag_menu==2)
                    admin_settings();
                break;
            case '5':
                if(flag_menu==21)
                    delete_services();
                         break;
            case 'r':
                if(flag_menu == 0)
                    flag_reset = true;
                    main_menu();
                    break;

            case 27:
                if(flag_menu==2 || flag_menu==1 )
                    main_menu();
                else if(flag_menu==21)
                     settings();
                else if( flag_menu==22)
                     settings();
                else if(flag_menu==23)
                     settings();
                else if(flag_menu==24)
                     settings();
                else if(flag_menu==211)
                     services();
                else if(flag_menu==212)
                     services();
                else if(flag_menu==213)
                     services();
                else if(flag_menu==214)
                     services();
                else if(flag_menu==215)
                     services();
                else if(flag_menu==221 || flag_menu==222)
                     cost();
                break;
            default:
                break;
            }
        }
return 0;
}
int main( int argc, char* argv[] )
{
#if defined( HAVE_CRTDBG_H ) && !defined( NDEBUG )
    // Under Visual Studio setup memory leak detection
    _CrtSetDbgFlag( _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) );
#endif /* defined( HAVE_CRTDBG_H ) && !defined( NDEBUG ) */

    printf("Copyright (C) 2006-2011 EVEmu Team. http://evemu.org/\n");
    printf("This program is free software; you can redistribute it and/or modify it under\n");
    printf("the terms of the GNU Lesser General Public License as published by the Free \n");
    printf("Software Foundation; either version 2 of the License, or (at your option) any\n");
    printf("later version.\n");
    printf("\n");
    printf("This program is distributed in the hope that it will be useful, but WITHOUT\n");
    printf("ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n");
    printf("FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more\n");
    printf("details.\n");
    printf("\n");

    // Load server configuration
    if( !sConfig.ParseFile( CONFIG_FILE ) )
    {
        printf("ERROR: Loading server configuration '%s' failed.", CONFIG_FILE );
        //sLog.Error( "server init", "Loading server configuration '%s' failed.", CONFIG_FILE );
        std::cout << std::endl << "press any key to exit...";  std::cin.get();
        return 1;
    }

    sLog.InitializeLogging(sConfig.files.logDir);
    sLog.Log("server init", "Loading server configuration...");

    sLog.Log("", "" );
    sLog.Log("SERVER VERSION", "EVEmu " EVEMU_VERSION );
    sLog.Log("", "" );
    sLog.Log("SOURCE", "get at " EVEMU_REPOSITORY );
    sLog.Log("", "" );
    sLog.Log("SERVER INIT", "\n"
        "\tSupported Client: %s\n"
        "\tVersion %.2f\n"
        "\tBuild %d\n"
        "\tMachoNet %u",
        EVEProjectVersion,
        EVEVersionNumber,
        EVEBuildVersion,
        MachoNetVersion
    );

    //it is important to do this before doing much of anything, in case they use it.
    Timer::SetCurrentTime();

    // Load server log settings ( will be removed )
    if( load_log_settings( sConfig.files.logSettings.c_str() ) )
        sLog.Success( "server init", "Log settings loaded from %s", sConfig.files.logSettings.c_str() );
    else
        sLog.Warning( "server init", "Unable to read %s (this file is optional)", sConfig.files.logSettings.c_str() );

    // open up the log file if specified ( will be removed )
    if( !sConfig.files.logDir.empty() )
    {
        std::string logFile = sConfig.files.logDir + "eve-server.log";
        if( log_open_logfile( logFile.c_str() ) )
            sLog.Success( "server init", "Found log directory %s", sConfig.files.logDir.c_str() );
        else
            sLog.Warning( "server init", "Unable to find log directory '%s', only logging to the screen now.", sConfig.files.logDir.c_str() );
    }

    //connect to the database...
    DBerror err;
    if( !sDatabase.Open( err,
        sConfig.database.host.c_str(),
        sConfig.database.username.c_str(),
        sConfig.database.password.c_str(),
        sConfig.database.db.c_str(),
        sConfig.database.port ) )
    {
        sLog.Error( "server init", "Unable to connect to the database: %s", err.c_str() );
        std::cout << std::endl << "press any key to exit...";  std::cin.get();
        return 1;
    }
    _sDgmTypeAttrMgr = new dgmtypeattributemgr(); // needs to be after db init as its using it

    //Start up the TCP server
    EVETCPServer tcps;

    char errbuf[ TCPCONN_ERRBUF_SIZE ];
    if( tcps.Open( sConfig.net.port, errbuf ) )
    {
        sLog.Success( "server init", "TCP listener started on port %u.", sConfig.net.port );
    }
    else
    {
        sLog.Error( "server init", "Failed to start TCP listener on port %u: %s.", sConfig.net.port, errbuf );
        std::cout << std::endl << "press any key to exit...";  std::cin.get();
        return 1;
    }

    //make the item factory
    ItemFactory item_factory( sEntityList );
	sLog.Log("server init", "starting item factory");

    //now, the service manager...
    PyServiceMgr services( 888444, sEntityList, item_factory );
	sLog.Log("server init", "starting service manager");

    //setup the command dispatcher
    CommandDispatcher command_dispatcher( services );
    RegisterAllCommands( command_dispatcher );

    /*
     * Service creation and registration.
     *
     */
    sLog.Log("server init", "Creating services.");

    // Please keep the services list clean so it's easyier to find something

    services.RegisterService(new AccountService(&services));
    services.RegisterService(new AgentMgrService(&services));
    services.RegisterService(new AggressionMgrService(&services));
    services.RegisterService(new AlertService(&services));
    services.RegisterService(new AuthService(&services));
    services.RegisterService(new BillMgrService(&services));
    services.RegisterService(new BeyonceService(&services));
    services.RegisterService(new BookmarkService(&services));
    services.RegisterService(new BrowserLockdownService(&services));
    services.RegisterService(new BulkMgrService(&services));
    services.RegisterService(new CertificateMgrService(&services));
    services.RegisterService(new CharFittingMgrService(&services));
    services.RegisterService(new CharUnboundMgrService(&services));
    services.RegisterService(new CharMgrService(&services));
    services.RegisterService(new ClientStatLogger(&services));
    services.RegisterService(new ClientStatsMgr(&services));
    services.RegisterService(new ConfigService(&services));
    services.RegisterService(new CorpBookmarkMgrService(&services));
    services.RegisterService(new CorpMgrService(&services));
    services.RegisterService(new CorporationService(&services));
    services.RegisterService(new CorpRegistryService(&services));
    services.RegisterService(new CorpStationMgrService(&services));
    services.RegisterService(new ContractMgrService(&services));
    services.RegisterService(new ContractProxyService(&services));
    services.RegisterService(new DevToolsProviderService(&services));
    services.RegisterService(new DogmaIMService(&services));
    services.RegisterService(new DogmaService(&services));
    services.RegisterService(new DungeonExplorationMgrService(&services));
    services.RegisterService(new DungeonService(&services));
    services.RegisterService(new FactionWarMgrService(&services));
    services.RegisterService(new FactoryService(&services));
    services.RegisterService(new FleetProxyService(&services));
    services.RegisterService(new HoloscreenMgrService(&services));
    services.RegisterService(new InfoGatheringMgr(&services));
    services.RegisterService(new InsuranceService(&services));
    services.RegisterService(new InvBrokerService(&services));
    services.RegisterService(new JumpCloneService(&services));
    services.RegisterService(new KeeperService(&services));
    services.RegisterService(new LanguageService(&services));
    services.RegisterService(new LocalizationServerService(&services));
    services.RegisterService(new LookupService(&services));
    services.RegisterService(new LPService(&services));
    services.RegisterService(services.lsc_service = new LSCService(&services, &command_dispatcher));
    services.RegisterService(new MailMgrService(&services));
    services.RegisterService(new MailingListMgrService(&services));
    services.RegisterService(new MapService(&services));
    services.RegisterService(new MarketProxyService(&services));
    services.RegisterService(new MissionMgrService(&services));
    services.RegisterService(new NetService(&services));
    services.RegisterService(new NotificationMgrService(&services));
    services.RegisterService(services.cache_service = new ObjCacheService(&services, sConfig.files.cacheDir.c_str()));
    services.RegisterService(new OnlineStatusService(&services));
    services.RegisterService(new PaperDollService(&services));
    services.RegisterService(new PetitionerService(&services));
    services.RegisterService(new PhotoUploadService(&services));
    services.RegisterService(new PlanetMgrService(&services));
    services.RegisterService(new PosMgrService(&services));
    services.RegisterService(new RamProxyService(&services));
    services.RegisterService(new RepairService(&services));
    services.RegisterService(new ReprocessingService(&services));
    services.RegisterService(new ShipService(&services));
    services.RegisterService(new SkillMgrService(&services));
    services.RegisterService(new SlashService(&services, &command_dispatcher));
    services.RegisterService(new SovereigntyMgrService(&services));
    services.RegisterService(new Standing2Service(&services));
    services.RegisterService(new StationService(&services));
    services.RegisterService(new StationSvcService(&services));
    services.RegisterService(new TutorialService(&services));
    services.RegisterService(new UserService(&services));
    services.RegisterService(new VoiceMgrService(&services));
    services.RegisterService(new WarRegistryService(&services));

    sLog.Log("server init", "Priming cached objects.");
    services.cache_service->PrimeCache();
    sLog.Log("server init", "finished priming");

    // start up the image server
    sImageServer.Run();
	sLog.Log("server init", "started image server");

    // start up the api server
    sAPIServer.CreateServices( services );
    sAPIServer.Run();
	sLog.Log("server init", "started API server");

    // start up the image server
    sLog.Log("server init", "Loading Dynamic Database Table Objects...");

	// Create In-Memory Database Objects for Critical Systems, such as ModuleManager:
	sLog.Log("server init", "---> sDGM_Effects_Table: Loading...");
	sDGM_Effects_Table.Initialize();
	sLog.Log("server init", "---> sDGM_Type_Effects_Table: Loading...");
	sDGM_Type_Effects_Table.Initialize();
	sLog.Log("server init", "---> sDGM_Skill_Bonus_Modifiers_Table: Loading...");
	sDGM_Skill_Bonus_Modifiers_Table.Initialize();
	//sLog.Log("server init", "---> sDGM_Ship_Bonus_Modifiers_Table: Loading...");
	//sDGM_Ship_Bonus_Modifiers_Table.Initialize();
	sLog.Log("server init", "---> sDGM_Types_to_Wrecks_Table: Loading...");
	sDGM_Types_to_Wrecks_Table.Initialize();

    sLog.Log("server init", "Init done.");

	/////////////////////////////////////////////////////////////////////////////////////
	//     !!!  DO NOT PUT ANY INITIALIZATION CODE OR CALLS BELOW THIS LINE   !!!
	/////////////////////////////////////////////////////////////////////////////////////
	services.serviceDB().SetServerOnlineStatus(true);
	sLog.Success("server init", "SERVER IS NOW [ONLINE]");
	sLog.Log("INFO", "(press Ctrl+C to start controlled server shutdown)");

    /*
     * THE MAIN LOOP
     *
     * Everything except IO should happen in this loop, in this thread context.
     *
     */

    /* program events system */
    SetupSignals();

    uint32 start;
    uint32 etime;
    uint32 last_time = GetTickCount();

    EVETCPConnection* tcpc;
    while( RunLoops == true )
    {
        Timer::SetCurrentTime();
        start = GetTickCount();

        //check for timeouts in other threads
        //timeout_manager.CheckTimeouts();
        while( ( tcpc = tcps.PopConnection() ) )
        {
            Client* c = new Client( services, &tcpc );

            sEntityList.Add( &c );
        }

        sEntityList.Process();
        services.Process();

        /* UPDATE */
        last_time = GetTickCount();
        etime = last_time - start;

        // do the stuff for thread sleeping
        if( MAIN_LOOP_DELAY > etime )
            Sleep( MAIN_LOOP_DELAY - etime );
    }

    sLog.Log("server shutdown", "Main loop stopped" );

    // Shutting down EVE Client TCP listener
    tcps.Close();
    sLog.Log("server shutdown", "TCP listener stopped." );

    // Shutting down API Server:
    sAPIServer.Stop();
    sLog.Log("server shutdown", "Image Server TCP listener stopped." );

    // Shutting down Image Server:
    sImageServer.Stop();
    sLog.Log("server shutdown", "API Server TCP listener stopped." );

    services.serviceDB().SetServerOnlineStatus(false);
	sLog.Log("server shutdown", "SERVER IS NOW [OFFLINE]");

    sLog.Log("server shutdown", "Cleanup db cache" );
    delete _sDgmTypeAttrMgr;

    log_close_logfile();

    //std::cout << std::endl << "press the ENTER key to exit...";  std::cin.get();

	// Shut down the Item system ensuring ALL items get saved to the database:
	sLog.Log("server shutdown", "Shutting down Item Factory." );

	return 0;
}