/*! Constructs a new QMaemo5HomescreenAdaptor for the given \a widget. Note: The widget must be a top-level widget, and must not be reparented during the lifetime of this adaptor. Note: \a widget is also the parent of this class, if the widget is destroyed, so is this adaptor. */ QMaemo5HomescreenAdaptor::QMaemo5HomescreenAdaptor(QWidget *widget) : QObject(widget), hasSettings(false) { Q_ASSERT(widget->isWindow()); if (!hsAtoms[0]) initAtoms(); Display *display = QX11Info::display(); const QStringList args = QApplication::arguments(); // parse the command line arguments. int idx; if ((idx = args.indexOf(QLatin1String("-plugin-id"))) != -1) { appletId = args.value(idx + 1); const QByteArray pluginId = appletId.toUtf8(); if (!pluginId.isEmpty()) { XChangeProperty(display, widget->winId(), hsAtoms[HildonAppletId], hsAtoms[Utf8String], 8, PropModeReplace, reinterpret_cast<const unsigned char *>(pluginId.constData()), pluginId.length()); } } if ((idx = args.indexOf(QLatin1String("-write-pipe"))) != -1) { bool ok; int sockId = args.value(idx + 1).toInt(&ok); if (ok) { socketNotifier = new QSocketNotifier(sockId, QSocketNotifier::Exception, this); connect(socketNotifier, SIGNAL(activated(int)), this, SLOT(socketException())); } }
bool StXDisplay::open() { hDisplay = XOpenDisplay(NULL); // get first display on server from DISPLAY in env //hDisplay = XOpenDisplay(":0.0"); //hDisplay = XOpenDisplay("somehost:0.0"); //hDisplay = XOpenDisplay("192.168.1.10:0.0"); if(isOpened()) { initAtoms(); hInputMethod = XOpenIM(hDisplay, NULL, NULL, NULL); if(hInputMethod == NULL) { return true; } XIMStyles* anIMStyles = NULL; char* anIMValues = XGetIMValues(hInputMethod, XNQueryInputStyle, &anIMStyles, NULL); if(anIMValues != NULL || anIMStyles == NULL || anIMStyles->count_styles <= 0) { // input method doesn't support any styles if(anIMStyles != NULL) { XFree(anIMStyles); } return true; } const XIMStyle anIMStyle = anIMStyles->supported_styles[0]; XFree(anIMStyles); hInputCtx = XCreateIC(hInputMethod, XNInputStyle, anIMStyle, NULL); return true; } return false; }
Atom KMenuBar::KMenuBarPrivate::makeSelectionAtom() { #ifdef Q_WS_X11 if(selection_atom == None) initAtoms(); return selection_atom; #else return 0; #endif }
/// Initialized the main CoMD data stucture, SimFlat, based on command /// line input from the user. Also performs certain sanity checks on /// the input to screen out certain non-sensical inputs. /// /// Simple data members such as the time step dt are initialized /// directly, substructures such as the potential, the link cells, the /// atoms, etc., are initialized by calling additional initialization /// functions (initPotential(), initLinkCells(), initAtoms(), etc.). /// Initialization order is set by the natural dependencies of the /// substructure such as the atoms need the link cells so the link cells /// must be initialized before the atoms. SimFlat* initSimulation(Command cmd) { SimFlat* sim = comdMalloc(sizeof(SimFlat)); sim->nSteps = cmd.nSteps; sim->printRate = cmd.printRate; sim->dt = cmd.dt; sim->domain = NULL; sim->boxes = NULL; sim->atoms = NULL; sim->ePotential = 0.0; sim->eKinetic = 0.0; sim->atomExchange = NULL; sim->pot = initPotential(cmd.doeam, cmd.potDir, cmd.potName, cmd.potType); real_t latticeConstant = cmd.lat; if (cmd.lat < 0.0) latticeConstant = sim->pot->lat; // ensure input parameters make sense. sanityChecks(cmd, sim->pot->cutoff, latticeConstant, sim->pot->latticeType); sim->species = initSpecies(sim->pot); real3 globalExtent; globalExtent[0] = cmd.nx * latticeConstant; globalExtent[1] = cmd.ny * latticeConstant; globalExtent[2] = cmd.nz * latticeConstant; sim->domain = initDecomposition( cmd.xproc, cmd.yproc, cmd.zproc, globalExtent); sim->boxes = initLinkCells(sim->domain, sim->pot->cutoff); sim->atoms = initAtoms(sim->boxes); // create lattice with desired temperature and displacement. createFccLattice(cmd.nx, cmd.ny, cmd.nz, latticeConstant, sim); setTemperature(sim, cmd.temperature); randomDisplacements(sim, cmd.initialDelta); sim->atomExchange = initAtomHaloExchange(sim->domain, sim->boxes); // Forces must be computed before we call the time stepper. startTimer(redistributeTimer); redistributeAtoms(sim); stopTimer(redistributeTimer); startTimer(computeForceTimer); computeForce(sim); stopTimer(computeForceTimer); kineticEnergy(sim); return sim; }
void initFunctors(void) { LOCK(); if ( !functorDefTable ) { initAtoms(); allocFunctorTable(); GD->functors.highest = 1; registerBuiltinFunctors(); registerControlFunctors(); registerArithFunctors(); } UNLOCK(); }
int main(int argc, char **argv) { FdEventHandlerPtr listener; int i; int rc; int expire = 0, printConfig = 0; initAtoms(); CONFIG_VARIABLE(daemonise, CONFIG_BOOLEAN, "Run as a daemon"); CONFIG_VARIABLE(pidFile, CONFIG_ATOM, "File with pid of running daemon."); preinitChunks(); preinitLog(); preinitObject(); preinitIo(); preinitDns(); preinitServer(); preinitHttp(); preinitDiskcache(); preinitLocal(); preinitForbidden(); preinitSocks(); preinitOffline(); i = 1; while(i < argc) { if(argv[i][0] != '-') break; if(strcmp(argv[i], "--") == 0) { i++; break; } else if(strcmp(argv[i], "-h") == 0) { usage(argv[0]); exit(0); } else if(strcmp(argv[i], "-v") == 0) { printConfig = 1; i++; } else if(strcmp(argv[i], "-x") == 0) { expire = 1; i++; } else if(strcmp(argv[i], "-c") == 0) { i++; if(i >= argc) { usage(argv[0]); exit(1); } if(configFile) releaseAtom(configFile); configFile = internAtom(argv[i]); i++; } else { usage(argv[0]); exit(1); } } if(configFile) configFile = expandTilde(configFile); if(configFile == NULL) { configFile = expandTilde(internAtom("~/.polipo")); if(configFile) if(access(configFile->string, F_OK) < 0) { releaseAtom(configFile); configFile = NULL; } } if(configFile == NULL) { if(access("/etc/polipo/config", F_OK) >= 0) configFile = internAtom("/etc/polipo/config"); if(configFile && access(configFile->string, F_OK) < 0) { releaseAtom(configFile); configFile = NULL; } } rc = parseConfigFile(configFile); if(rc < 0) exit(1); while(i < argc) { rc = parseConfigLine(argv[i], "command line", 0, 0); if(rc < 0) exit(1); i++; } initChunks(); initLog(); initObject(); if(!expire && !printConfig) initEvents(); initIo(); initDns(); initHttp(); initServer(); initDiskcache(); initForbidden(); initSocks(); initOffline(); if(printConfig) { printConfigVariables(stdout, 0); exit(0); } if(expire) { expireDiskObjects(); exit(0); } if(daemonise) do_daemonise(logFile == NULL || logFile->length == 0); if(pidFile) writePid(pidFile->string); listener = create_listener(proxyAddress->string, proxyPort, httpAccept, NULL); if(!listener) { if(pidFile) unlink(pidFile->string); exit(1); } eventLoop(); if(pidFile) unlink(pidFile->string); return 0; }
SimFlat* initSimulation(Command cmd) { SimFlat* sim = comdMalloc(sizeof(SimFlat)); sim->nSteps = cmd.nSteps; sim->printRate = cmd.printRate; sim->dt = cmd.dt; sim->domain = NULL; sim->boxes = NULL; sim->atoms = NULL; sim->ePotential = 0.0; sim->eKinetic = 0.0; sim->atomExchange = NULL; sim->pot = initPotential(cmd.doeam, cmd.potDir, cmd.potName, cmd.potType); real_t latticeConstant = cmd.lat; if (cmd.lat < 0.0) latticeConstant = sim->pot->lat; // ensure input parameters make sense. sanityChecks(cmd, sim->pot->cutoff, latticeConstant, sim->pot->latticeType); sim->species = initSpecies(sim->pot); real3 globalExtent; globalExtent[0] = cmd.nx * latticeConstant; globalExtent[1] = cmd.ny * latticeConstant; globalExtent[2] = cmd.nz * latticeConstant; sim->domain = initDecomposition(cmd.xproc, cmd.yproc, cmd.zproc, globalExtent); sim->boxes = initLinkCells(sim->domain, sim->pot->cutoff); sim->atoms = initAtoms(sim->boxes); sim->defInfo = initDeformation(sim, cmd.defGrad); //printf("Got to here\n"); // create lattice with desired temperature and displacement. createFccLattice(cmd.nx, cmd.ny, cmd.nz, latticeConstant, sim); setTemperature(sim,0.0); randomDisplacements(sim, cmd.initialDelta); sim->atomExchange = initAtomHaloExchange(sim->domain, sim->boxes); forwardDeformation(sim); //eamForce(sim); // Procedure for energy density passing from the macrosolver to CoMD //setTemperature(sim,((cmd.energy*latticeVolume*cmd.nx*cmd.ny*cmd.nz-sim->ePotential)/sim->atoms->nGlobal)/(kB_eV * 1.5)); //randomDisplacements(sim, cmd.initialDelta); // Forces must be computed before we call the time stepper. startTimer(redistributeTimer); redistributeAtoms(sim); stopTimer(redistributeTimer); startTimer(computeForceTimer); computeForce(sim); stopTimer(computeForceTimer); double cohmmEnergy=cmd.energy*sim->defInfo->globalVolume; double temperatureFromEnergyDensity=((cohmmEnergy-sim->ePotential)/sim->atoms->nGlobal)/(kB_eV*1.5); setTemperature(sim,temperatureFromEnergyDensity); //uncomment to set temperature according to hmm energy density //setTemperature(sim,cmd.temperature); //uncomment to directly input temperature kineticEnergy(sim); return sim; }
int psiphonMain( int bindAll, int proxyPortParam, int localParentProxyPortParam) { FdEventHandlerPtr listener; initAtoms(); CONFIG_VARIABLE(daemonise, CONFIG_BOOLEAN, "Run as a daemon"); CONFIG_VARIABLE(pidFile, CONFIG_ATOM, "File with pid of running daemon."); preinitChunks(); preinitLog(); preinitObject(); preinitIo(); preinitDns(); preinitServer(); preinitHttp(); preinitDiskcache(); preinitLocal(); preinitForbidden(); preinitSocks(); const int MAX_SIZE = 80; char proxyAddressParamLine[MAX_SIZE]; char proxyPortParamLine[MAX_SIZE]; char localParentProxyPortParamLine[MAX_SIZE]; snprintf( proxyAddressParamLine, MAX_SIZE, (0 == bindAll) ? "proxyAddress=127.0.0.1" : "proxyAddress=0.0.0.0"); snprintf( proxyPortParamLine, MAX_SIZE, "proxyPort=%d", proxyPortParam); snprintf( localParentProxyPortParamLine, MAX_SIZE, "socksParentProxy=127.0.0.1:%d", localParentProxyPortParam); if (0 > parseConfigLine(proxyAddressParamLine, "psiphon", 0, 0) || 0 > parseConfigLine(proxyPortParamLine, "psiphon", 0, 0) || 0 > parseConfigLine(localParentProxyPortParamLine, "psiphon", 0, 0) || 0 > parseConfigLine("disableLocalInterface=true", "psiphon", 0, 0) || 0 > parseConfigLine("logLevel=1", "psiphon", 0, 0) /* Allow HTTPS on all ports */ || 0 > parseConfigLine("tunnelAllowedPorts=1-65535", "psiphon", 0, 0)) { return -1; } initChunks(); initLog(); initObject(); initEvents(); initIo(); initDns(); initHttp(); initServer(); initDiskcache(); initForbidden(); initSocks(); listener = create_listener( proxyAddress->string, proxyPort, httpAccept, NULL); if (!listener) { return -1; } eventLoop(); return 0; }