void UserInfo::loadInfo() { if (m_nUin){ ICQUser *u = pClient->getUser(m_nUin); if (u == NULL) return; emit loadInfo(u); return; } ICQGroup *grp = NULL; if (m_nGrpId) grp = pClient->getGroup(m_nGrpId); emit loadInfo(grp); }
void MapDB::load() { if (mLoaded) unload(); loadRemapXmlFile(paths.getStringValue("mapsRemapFile"), SkipError_true); loadRemapXmlFile(paths.getStringValue("mapsRemapPatchFile"), SkipError_true); loadXmlDir("mapsRemapPatchDir", loadRemapXmlFile); loadInfo(paths.getStringValue("mapsFile"), SkipError_false); loadInfo(paths.getStringValue("mapsPatchFile"), SkipError_true); loadXmlDir("mapsPatchDir", loadInfo); mLoaded = true; }
void UserInfo::processEvent(ICQEvent *e) { if (inSave) return; btnUpdate->setEnabled(pClient->isLogged()); if ((e->type() != EVENT_INFO_CHANGED) || (e->Uin() != m_nUin)) return; loadInfo(); }
void MapDB::loadInfo(const std::string &fileName, const SkipError skipError) { XML::Document *doc = new XML::Document(fileName, UseResman_true, skipError); const XmlNodePtrConst root = doc->rootNode(); if (!root) { delete doc; return; } for_each_xml_child_node(node, root) { if (xmlNameEqual(node, "map")) { readMap(node); } else if (xmlNameEqual(node, "atlas")) { readAtlas(node); } else if (xmlNameEqual(node, "include")) { const std::string name = XML::getProperty(node, "name", ""); if (!name.empty()) loadInfo(name, skipError); continue; } } delete doc; }
void PointViewerMainWindow::reloadFiles() { const GeometryCollection::GeometryVec& geoms = m_geometries->get(); for (auto g = geoms.begin(); g != geoms.end(); ++g) { FileLoadInfo loadInfo((*g)->fileName(), (*g)->label(), false); m_fileLoader->reloadFile(loadInfo); } }
void KeyBoardPreview::setVariant(QString variant) { this->variant = variant; if (!loadCodes()) return; loadInfo(); repaint(); }
void Client::beginClientLoad(const StringData &ns, const vector<BSONObj> &indexes, const BSONObj &options) { uassert( 16915, "Cannot begin load, one is already in progress", !loadInProgress() ); shared_ptr<Client::LoadInfo> loadInfo(new Client::LoadInfo(ns)); LOCK_REASON(lockReason, "loader: beginning load"); Client::WriteContext ctx(ns, lockReason); beginBulkLoad(ns, indexes, options); _loadInfo = loadInfo; }
// ShowWait void dWMShop_c::beginState_ShowWait() { MapSoundPlayer(SoundRelatedClass, SE_SYS_DIALOGUE_IN, 1); layout.disableAllAnimations(); layout.enableNonLoopAnim(SHOW_ALL); visible = true; scaleEase = 0.0; loadInfo(); loadModels(); }
UserInfo::UserInfo(QWidget *parent, unsigned long uin, int page) : UserInfoBase(parent) { inSave = false; m_nUin = uin; ICQUser *u = pClient->getUser(m_nUin); if (uin && (u == NULL)) return; lstBars->clear(); lstBars->header()->hide(); lstBars->setSorting(1); connect(lstBars, SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); itemMain = new QListViewItem(lstBars, i18n("User info"), QString::number(SETUP_DETAILS)); itemMain->setOpen(true); addWidget(new MainInfo(tabBars, true), SETUP_MAININFO, i18n("Main info"), "main"); if (u && (u->Type == USER_TYPE_ICQ)){ addWidget(new HomeInfo(tabBars, true), SETUP_HOMEINFO, i18n("Home info"), "home"); addWidget(new WorkInfo(tabBars, true), SETUP_WORKINFO, i18n("Work info"), "work"); addWidget(new MoreInfo(tabBars, true), SETUP_MOREINFO, i18n("More info"), "more"); addWidget(new AboutInfo(tabBars, true), SETUP_ABOUT, i18n("About info"), "info"); addWidget(new InterestsInfo(tabBars, true), SETUP_INTERESTS, i18n("Interests"), "interest"); addWidget(new PastInfo(tabBars, true), SETUP_PAST, i18n("Group/Past"), "past"); } addWidget(new PhoneBookDlg(tabBars, true), SETUP_PHONE, i18n("Phone book"), "phone"); if (u && (u->Type == USER_TYPE_ICQ)){ itemMain = new QListViewItem(lstBars, i18n("Preferences"), QString::number(SETUP_PREFERENCES)); itemMain->setOpen(true); addWidget(new AlertDialog(tabBars, true), SETUP_ALERT, i18n("Alert"), "alert"); addWidget(new AcceptDialog(tabBars, true), SETUP_ACCEPT, i18n("Accept file"), "file"); addWidget(new SoundSetup(tabBars, true), SETUP_SOUND, i18n("Sound"), "sound"); addWidget(new MsgDialog(tabBars, ICQ_STATUS_AWAY, true), SETUP_AR_AWAY, Client::getStatusText(ICQ_STATUS_AWAY), Client::getStatusIcon(ICQ_STATUS_AWAY)); addWidget(new MsgDialog(tabBars, ICQ_STATUS_NA, true), SETUP_AR_NA, Client::getStatusText(ICQ_STATUS_NA), Client::getStatusIcon(ICQ_STATUS_NA)); addWidget(new MsgDialog(tabBars, ICQ_STATUS_OCCUPIED, true), SETUP_AR_OCCUPIED, Client::getStatusText(ICQ_STATUS_OCCUPIED), Client::getStatusIcon(ICQ_STATUS_OCCUPIED)); addWidget(new MsgDialog(tabBars, ICQ_STATUS_DND, true), SETUP_AR_DND, Client::getStatusText(ICQ_STATUS_DND), Client::getStatusIcon(ICQ_STATUS_DND)); addWidget(new MsgDialog(tabBars, ICQ_STATUS_FREEFORCHAT, true), SETUP_AR_FREEFORCHAT, Client::getStatusText(ICQ_STATUS_FREEFORCHAT), Client::getStatusIcon(ICQ_STATUS_FREEFORCHAT)); } tabBars->raiseWidget(page ? page : SETUP_MAININFO); connect(pClient, SIGNAL(event(ICQEvent*)), this, SLOT(processEvent(ICQEvent*))); connect(btnSave, SIGNAL(clicked()), this, SLOT(saveInfo())); connect(btnUpdate, SIGNAL(clicked()), this, SLOT(update())); loadInfo(); }
void Info::onIDViewSelectionChanged() { m_SelectedUnitId.clear(); mp_TreeViewIDs->get_selection()->selected_foreach_iter( sigc::mem_fun(*this, &Info::loadSelectedID)); std::set<int>::iterator it; for (it = m_SelectedUnitId.begin(); it != m_SelectedUnitId.end(); it++) { loadInfo(*it, m_SelectedUnitId.size()); loadInputData(*it, m_SelectedUnitId.size()); //TODO les evenements à faire loadEvent(*it, m_SelectedUnitId.size()); } }
void sm::BoostPropertyTree::load(const boost::filesystem::path& fileName) { switch(getFileFormatAndThrowIfUnknown(fileName)){ case XML: loadXml(fileName); break; case INI: loadIni(fileName); break; case JSON: loadJson(fileName); break; case INFO: loadInfo(fileName); break; } }
void UserInfo::selectionChanged() { QListViewItem *item = lstBars->currentItem(); if (item == NULL) return; unsigned id = item->text(1).toULong(); if (id == 0) return; QWidget *w = tabBars->widget(id); if (w == NULL){ PAGEPROC *p = (PAGEPROC*)(item->text(3).toUInt()); if (p == NULL) return; QWidget *page = p(tabBars, item->text(4).toUInt()); connect(this, SIGNAL(loadInfo(ICQUser*)), page, SLOT(load(ICQUser*))); connect(this, SIGNAL(saveInfo(ICQUser*)), page, SLOT(save(ICQUser*))); connect(this, SIGNAL(loadInfo(ICQGroup*)), page, SLOT(load(ICQGroup*))); connect(this, SIGNAL(saveInfo(ICQGroup*)), page, SLOT(save(ICQGroup*))); tabBars->addWidget(page, id); loadInfo(); tabBars->setMinimumSize(tabBars->minimumSizeHint()); }
bool ManageDoubleexpRes::loadContent(Document * xml_doc) { if (NULL == xml_doc) { return false; } Element * root_ele = xml_doc->get_root(); if (NULL == root_ele) { return false; } bool result = true; Elements ele_list = root_ele->get_elements(); for (Elements::iterator it = ele_list.begin(); it != ele_list.end(); ++it) { result = loadInfo(*it) && result; } return result; }
bool Layout::loadLayoutFiles(string dataPath, string infoPath) { printf("loadLayoutFiles\n"); this->dataPath = dataPath; this->infoPath = infoPath; if (loadInfo(dataPath + infoPath)) { if (loadSVG(dataPath + svgPath)) { printf("loaded layout %s\n", layoutName.c_str()); return true; } else { printf("ERR: failed to load svg from %s\n", svgPath.c_str()); } } else { printf("ERR: failed to load info from %s\n", infoPath.c_str()); } return false; }
Map::Map(int stage) { _mapSize = 0; this->_stage = stage; loadInfo(); loadPretties(); loadAnimatedPretties(); loadTile(); loadMobs(); loadSignatureObjects(); // Concatenate all map object's reference to split into 4tree. vector<Object*> mapObjects; mapObjects.insert(mapObjects.end(), _pretties.begin(), _pretties.end()); _mapObjects = new QuadTree(new RECT(Default::createRECT(0, _mapSize, _mapSize, 0))); _mapObjects->assign(mapObjects); }
void PointViewerMainWindow::addFiles() { QStringList files = QFileDialog::getOpenFileNames( this, tr("Add point clouds or meshes"), m_currFileDir.path(), tr("Data sets (*.las *.laz *.txt *.xyz *.ply);;All files (*)"), 0, QFileDialog::ReadOnly ); if (files.empty()) return; for (int i = 0; i < files.size(); ++i) { FileLoadInfo loadInfo(files[i]); loadInfo.replaceLabel = false; m_fileLoader->loadFile(loadInfo); } m_currFileDir = QFileInfo(files[0]).dir(); m_currFileDir.makeAbsolute(); }
void MainWindow::load() { // Prompt a video to load QString file = QFileDialog::getOpenFileName(this, "Load Video", QString()); if(!file.isNull()) { _decoderNormal.openFile(file); std::string folder = file.toStdString(); folder = folder.substr(0, folder.find_last_of("/")); loadInfo(folder+"/MoveInfo.txt"); _decoderAlpha.openFile(QString((folder+"/Alpha.avi").c_str())); _currentFrame = -1; ui->widget->setFrame(&_frame); ui->widget->setReplace(&_replace); ui->widget->setCurrentFrame(&_currentFrame); next(); } }
HRESULT starwarsScene::init() { loadInfo(); switch (_type) { case BATTLE: _ship = new battle; _ship->init("battle", _loadAngle, _loadMaxSpd); break; case CARRIER: _ship = new carrier; _ship->init("carrier", _loadAngle, _loadMaxSpd); break; case PHOENIX: _ship = new phoenix; _ship->init("phoenix", _loadAngle, _loadMaxSpd); break; } return S_OK; }
bool RasterInfo::load( QString imgFileName ) { defaults(); fileName = imgFileName; parseFileName(); if( QFile::exists( fileName + ".xml" ) ) { return loadXml(); } else if( QFile::exists( fileName + ".img.info" ) ) { loadInfo(); save(); QFile::remove( fileName + ".img.info" ); } else { return false; } return true; }
bool ManageFreeTimeBag::loadContent(Document * xml_doc) { if (NULL == xml_doc) { return false; } Element * root_ele = xml_doc->get_root(); if (NULL == root_ele) { return false; } bool result = true; Elements ele_list = root_ele->get_elements(); for (Elements::iterator it = ele_list.begin(); it != ele_list.end(); ++it) { result = loadInfo(*it) && result; } // check the id int index = 0; for (int i = 0; i < m_free_time_bag_vec.size(); ++i) { FreeTimeBag * free_time_bag = m_free_time_bag_vec[i]; ++index; if (index != free_time_bag->id_value) { result = false; break; } } return result; }
/* ============================================================================ Funcion principal ============================================================================ */ int main(int argc, char *argv[]) { stHeaderIPC *unHeaderIPC = NULL, *stHeaderSwitch = NULL; stMensajeIPC unMensaje; stPCB *unPCB = NULL; t_UMCConfig UMCConfig; pthread_t p_thread, p_threadCpu; char* temp_file = "nucleo.log"; elEstadoActual.path_conf = argv[1]; uint32_t pid_desconectado = 0; int unCliente = 0, maximoAnterior = 0, unSocket, agregarSock; struct sockaddr addressAceptado; /*Inicializacion de las colas del planificador*/ inicializar_pidCounter(); inicializar_cola_ready(); listaBlock = list_create(); consola_crear_lista(); log_create(temp_file, "NUCLEO", -1, LOG_LEVEL_INFO); log_info("Arrancando el Nucleo"); if (elEstadoActual.path_conf == NULL) { log_error("Falta el parametro de configuracion"); exit(-1); } /*Carga del archivo de configuracion*/ if (loadInfo(&elEstadoActual, 0)) { log_error("Error al cargar la configuracion"); exit(-2); } log_info("Configuracion cargada satisfactoriamente..."); /*Se lanza el thread para identificar cambios en el archivo de configuracion*/ pthread_create(&p_thread, NULL, &monitor_configuracion, (void*) &elEstadoActual); inicializarThreadsDispositivos(&elEstadoActual); /*Inicializacion de listas de socket*/ FD_ZERO(&(fds_master)); FD_ZERO(&(read_fds)); /*Inicializacion de socket de escucha*/ elEstadoActual.salir = 0; elEstadoActual.sockEscuchador = -1; /*Iniciando escucha en el socket escuchador de Consola*/ elEstadoActual.sockEscuchador = escuchar(elEstadoActual.miPuerto); FD_SET(elEstadoActual.sockEscuchador, &(fds_master)); log_debug("Se establecio conexion con el socket de escucha..."); /*Seteamos el maximo socket*/ elEstadoActual.fdMax = elEstadoActual.sockEscuchador; /*Conexion con el proceso UMC*/ log_debug("Estableciendo conexion con la UMC..."); elEstadoActual.sockUmc = conectar(elEstadoActual.ipUmc, elEstadoActual.puertoUmc); if (elEstadoActual.sockUmc != -1) { //FD_SET(elEstadoActual.sockUmc, &(fds_master)); unHeaderIPC = nuevoHeaderIPC(ERROR); if (!recibirHeaderIPC(elEstadoActual.sockUmc, unHeaderIPC)) { log_error("UMC handshake error - No se pudo recibir mensaje de respuesta"); log_error("No se pudo conectar a la UMC"); elEstadoActual.salir = 1; } if (unHeaderIPC->tipo == QUIENSOS) { unHeaderIPC = nuevoHeaderIPC(CONNECTNUCLEO); if (!enviarHeaderIPC(elEstadoActual.sockUmc, unHeaderIPC)) { log_error("UMC handshake error - No se pudo enviar mensaje de conexion"); log_error("No se pudo conectar a la UMC"); elEstadoActual.salir = 1; } } liberarHeaderIPC(unHeaderIPC); unHeaderIPC = nuevoHeaderIPC(OK); if (!recibirHeaderIPC(elEstadoActual.sockUmc, unHeaderIPC)) { log_error("UMC handshake error - No se pudo recibir mensaje de confirmacion"); log_error("No se pudo conectar a la UMC"); elEstadoActual.salir = 1; } else { if (recibirConfigUMC(elEstadoActual.sockUmc, &UMCConfig)) { log_error("UMC error - No se pudo recibir la configuracion"); close(unCliente); exit(-2); } agregar_master(elEstadoActual.sockUmc,maximoAnterior); log_info("Paginas por proceso:[%d]", UMCConfig.paginasXProceso); log_info("Tamanio de pagina:[%d]", UMCConfig.tamanioPagina); elEstadoActual.tamanio_paginas = UMCConfig.tamanioPagina; } liberarHeaderIPC(unHeaderIPC); } else { log_error("No se pudo conectar a la UMC"); elEstadoActual.salir = 1; } /*Ciclo Principal del Nucleo*/ log_info("............................................................................."); log_info("..............................Esperando Conexion.............................\n\n"); fflush(stdout); while (elEstadoActual.salir == 0) { read_fds = fds_master; if (seleccionar(elEstadoActual.fdMax, &read_fds, 0) == -1) { log_error("Error Preparando el Select"); break; } for (unSocket = 0; unSocket <= elEstadoActual.fdMax; unSocket++) { if (FD_ISSET(unSocket, &read_fds)) { /*Nueva conexion*/ if (unSocket == elEstadoActual.sockEscuchador) { unCliente = aceptar(elEstadoActual.sockEscuchador, &addressAceptado); unHeaderIPC = nuevoHeaderIPC(QUIENSOS); if (!enviarHeaderIPC(unCliente, unHeaderIPC)) { log_error("Cliente Handshake error - No se puede enviar el mensaje QUIENSOS"); liberarHeaderIPC(unHeaderIPC); close(unCliente); break;/*Sale del for*/ } liberarHeaderIPC(unHeaderIPC); unHeaderIPC = nuevoHeaderIPC(ERROR); if (!recibirHeaderIPC(unCliente, unHeaderIPC)) { log_error("Cliente Handshake error - No se puede recibir el mensaje"); liberarHeaderIPC(unHeaderIPC); close(unCliente); break;/*Sale del for*/ } /*Identifico quien se conecto y procedo*/ switch (unHeaderIPC->tipo) { case CONNECTCONSOLA: stHeaderSwitch = nuevoHeaderIPC(OK); if (!enviarHeaderIPC(unCliente, stHeaderSwitch)) { log_error("Handshake Consola - No se pudo enviar el OK"); liberarHeaderIPC(stHeaderSwitch); close(unCliente); break;/*Sale del switch*/ } liberarHeaderIPC(stHeaderSwitch); log_info("Nueva consola conectada"); agregarSock = 1; /*Agrego el socket conectado a la lista Master*/ if (agregarSock == 1) { agregar_master(unCliente, maximoAnterior); agregarSock = 0; } /* Recibo Programa */ if (!recibirMensajeIPC(unCliente, &unMensaje)) { log_error("No se puede recibir el programa a procesar"); break;/*Sale del switch*/ } else { if (unMensaje.header.tipo == SENDANSISOP) { /*metadata_desde_literal hace un malloc adentro*/ int cantidadDePaginasCodigo = calcular_cantidad_paginas(unMensaje.header.largo, UMCConfig.tamanioPagina); /***Creacion del PCB***/ unPCB = crear_pcb(unCliente, cantidadDePaginasCodigo, elEstadoActual.stackSize, &unMensaje); if (unPCB == NULL) { log_error("Error al crear el PCB... se cierra la consola\n"); quitar_master(unCliente, maximoAnterior); close(unCliente); break;/*Sale del switch*/ } if (inicializar_programa(unPCB, (char *)unMensaje.contenido, elEstadoActual.sockUmc) == EXIT_FAILURE) { log_error("No se pudo inicializar el programa"); quitar_master(unCliente, maximoAnterior); close(unCliente); break;/*Sale del switch*/ } /* Inicializada la consola la agrego a consolas activas */ agregar_consola(unCliente, unPCB->pid); /*Cuando se usa mensajeIPC liberar el contenido*/ free(unMensaje.contenido); ready_productor(unPCB); log_info("PCB [PID - %d] NEW a READY\n", unPCB->pid); fflush(stdout); } } break; case CONNECTCPU: stHeaderSwitch = nuevoHeaderIPC(OK); if (!enviarHeaderIPC(unCliente, stHeaderSwitch)) { liberarHeaderIPC(stHeaderSwitch); log_error("CPU error - No se pudo enviar OK"); close(unCliente); break;/*Sale del switch*/ } liberarHeaderIPC(stHeaderSwitch); if (pthread_create(&p_threadCpu, NULL, (void*) consumidor_cpu, (void*) &unCliente) != 0) { log_error("No se pudo lanzar el hilo correspondiente al cpu conectado"); close(unCliente); break;/*Sale del switch*/ } log_info("Se lanza hilo de atencion a CPU conectado"); fflush(stdout); break; default: break; } if (unHeaderIPC != NULL) { liberarHeaderIPC(unHeaderIPC); } } else { /*Conexion existente*/ log_debug("Recibi otro evento de un cliente ya conectado"); if (!recibirMensajeIPC(unSocket, &unMensaje)) { log_info("Desconexion detectada"); // Desconexion de una consola pid_desconectado = borrar_consola(unSocket); // Desconexion de la UMC if (unSocket == elEstadoActual.sockUmc) { log_info("Se perdio conexion con la UMC..."); elEstadoActual.salir = 1; cerrarSockets(&elEstadoActual); } if (unSocket == elEstadoActual.sockEscuchador) { log_debug("Se perdio conexion..."); } /*Saco el socket de la lista Master*/ quitar_master(unSocket, maximoAnterior); fflush(stdout); } } } } } destruir_planificador(); destruir_lista_dispositivos(&elEstadoActual); consola_destruir_lista(&elEstadoActual); cerrarSockets(&elEstadoActual); finalizarSistema(&unMensaje, unSocket, &elEstadoActual); log_info("Fin del programa"); return 0; }
void MainMenu() { int choice; int *keyPressed = malloc(sizeof(int)); int *inputBoxPressed = malloc(sizeof(int)); int *buttonPressed = malloc(sizeof(int)); int *sdBoxPressed = malloc(sizeof(int)); while (1) { choice = displayMenu(keyPressed, inputBoxPressed, buttonPressed, sdBoxPressed); if (choice >= 0) { if (*keyPressed == 1) { executeKeyPress(choice); } else { if (globalCurrentPage == map) { executeMapPress(globalCurrentPage->buttons[choice], choice); } else if (globalCurrentPage == passwordSetup) { executePWSetupPress(choice, inputBoxPressed, buttonPressed, sdBoxPressed); } else if (globalCurrentPage == password) { executePWLogin(choice, inputBoxPressed, buttonPressed, sdBoxPressed); } else if (globalCurrentPage == loggingSettings) { executeLoggingSettings(choice, inputBoxPressed, buttonPressed, sdBoxPressed); // GENERAL PAGE HANDLING (SELF AND DEST PAGES) } else { if (*sdBoxPressed == 1) { char *secureFilename; char *plaintextFilename; /* * We need to modify the file names depending on the page we are on in the general handler * This is a quicker solution than writing two seperate handlers * */ if (globalCurrentPage == self) { secureFilename = ESELF; plaintextFilename = NSELF; } if (globalCurrentPage == destination) { secureFilename = EDEST; plaintextFilename = NDEST; } //if choice = 0 save plaintext if (choice == 0) { InputBox *tempSD = globalCurrentPage->inputBoxes; // write to SD and update SD Box status if (formatAndSaveSD(tempSD[0].inputBuf, tempSD[1].inputBuf, tempSD[2].inputBuf, tempSD[3].inputBuf, plaintextFilename) == 0) { greenLEDS = 0xff; redLEDS = 0x00; } else { greenLEDS = 0x00; redLEDS = 0xff; } } //choice = 1 save encrypted if (choice == 1) { printf("Saving encrypted \n"); InputBox *tempSD = globalCurrentPage->inputBoxes; // write to SD and update SD Box status if (formatAndSaveSDEncrypted(tempSD[0].inputBuf, tempSD[1].inputBuf, tempSD[2].inputBuf, tempSD[3].inputBuf, secureFilename) == 0) { greenLEDS = 0xff; redLEDS = 0x00; } else { greenLEDS = 0x00; redLEDS = 0xff; } } //choice = 2 load plaintext if (choice == 2) { char read[512] = ""; InputBox *tempSD = globalCurrentPage->inputBoxes; if (readFromSD(read, plaintextFilename, 512) == 0) { greenLEDS = 0xff; redLEDS = 0x00; } else { greenLEDS = 0x00; redLEDS = 0xff; } loadInfo(tempSD[0].inputBuf, tempSD[1].inputBuf, tempSD[2].inputBuf, tempSD[3].inputBuf, read); } //choice 3 = load encrypted if (choice == 3) { //readFromSD(key, KEYFILE, 16); char read[512] = ""; InputBox *tempSD = globalCurrentPage->inputBoxes; if (readFromSDEncrypted(read, secureFilename, 512) == 0) { greenLEDS = 0xff; redLEDS = 0x00; } else { greenLEDS = 0x00; redLEDS = 0xff; } printf("read: %s, \n", read); loadInfo(tempSD[0].inputBuf, tempSD[1].inputBuf, tempSD[2].inputBuf, tempSD[3].inputBuf, read); } } if (*inputBoxPressed == 1) { printf("input box choice: %d \n", choice); keys->keyboard.curInputBoxIndex = choice; keys->keyboard.caller = globalCurrentPage; strcpy(keys->keyboard.buffer, globalCurrentPage->inputBoxes[choice].inputBuf); keys->keyboard.bufCount = strlen( globalCurrentPage->inputBoxes[choice].inputBuf); strcpy(keys->objects[0].objectText, globalCurrentPage->inputBoxes[choice].inputBuf); keys->objects[0].captionLength = strlen( globalCurrentPage->inputBoxes[choice].inputBuf); globalCurrentPage = keys; } if (*buttonPressed == 1) { Button theButton = globalCurrentPage->buttons[choice]; printf("button choice: %d \n", choice); //if going to the keyboard, then set the caller on the keyboard. if (theButton.targetPage == keys) { globalCurrentPage->keyboard.caller = home; } globalCurrentPage = theButton.targetPage; } } } } } free(keyPressed); free(buttonPressed); free(inputBoxPressed); free(sdBoxPressed); }
UserInfo::UserInfo(unsigned long uin, unsigned short grpId, int page) : UserInfoBase(NULL, "userinfo", WType_TopLevel | WStyle_Dialog| WDestructiveClose) { SET_WNDPROC("userinfo") inSave = false; setButtonsPict(this); m_nUin = uin; m_nGrpId = grpId; ICQUser *u = NULL; if (uin){ u = pClient->getUser(uin); if (u == NULL) return; } ICQGroup *g = NULL; if (grpId){ g = pClient->getGroup(grpId); if (g == NULL) return; } lstBars->clear(); lstBars->header()->hide(); lstBars->setSorting(1); connect(lstBars, SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); itemMain = new QListViewItem(lstBars, i18n("User info"), QString::number(SETUP_DETAILS)); itemMain->setOpen(true); if (u){ addWidget(p_MainInfo, SETUP_MAININFO, i18n("Main info"), "main"); if (u->Type == USER_TYPE_ICQ){ addWidget(p_HomeInfo, SETUP_HOMEINFO, i18n("Home info"), "home"); addWidget(p_WorkInfo, SETUP_WORKINFO, i18n("Work info"), "work"); addWidget(p_MoreInfo, SETUP_MOREINFO, i18n("More info"), "more"); addWidget(p_AboutInfo, SETUP_ABOUT, i18n("About info"), "info"); addWidget(p_InterestsInfo, SETUP_INTERESTS, i18n("Interests"), "interest"); addWidget(p_PastInfo, SETUP_PAST, i18n("Group/Past"), "past"); } addWidget(p_PhoneBookDlg, SETUP_PHONE, i18n("Phone book"), "phone"); } if ((uin == 0) || (u->Type == USER_TYPE_ICQ)){ itemMain = new QListViewItem(lstBars, i18n("Preferences"), QString::number(SETUP_PREFERENCES)); itemMain->setOpen(true); addWidget(p_AlertDialog, SETUP_ALERT, i18n("Alert"), "alert"); addWidget(p_AcceptDialog, SETUP_ACCEPT, i18n("Accept"), "message"); addWidget(p_SoundSetup, SETUP_SOUND, i18n("Sound"), "sound"); } if (g || (u && (u->Type == USER_TYPE_ICQ))){ itemMain = new QListViewItem(lstBars, i18n("Auto reply"), QString::number(SETUP_AUTOREPLY)); itemMain->setOpen(true); addWidget(p_MsgDialog, SETUP_AR_AWAY, SIMClient::getStatusText(ICQ_STATUS_AWAY), SIMClient::getStatusIcon(ICQ_STATUS_AWAY), ICQ_STATUS_AWAY); addWidget(p_MsgDialog, SETUP_AR_NA, SIMClient::getStatusText(ICQ_STATUS_NA), SIMClient::getStatusIcon(ICQ_STATUS_NA), ICQ_STATUS_NA); addWidget(p_MsgDialog, SETUP_AR_OCCUPIED, SIMClient::getStatusText(ICQ_STATUS_OCCUPIED), SIMClient::getStatusIcon(ICQ_STATUS_OCCUPIED), ICQ_STATUS_OCCUPIED); addWidget(p_MsgDialog, SETUP_AR_DND, SIMClient::getStatusText(ICQ_STATUS_DND), SIMClient::getStatusIcon(ICQ_STATUS_DND), ICQ_STATUS_DND); addWidget(p_MsgDialog, SETUP_AR_FREEFORCHAT, SIMClient::getStatusText(ICQ_STATUS_FREEFORCHAT), SIMClient::getStatusIcon(ICQ_STATUS_FREEFORCHAT), ICQ_STATUS_FREEFORCHAT); } raiseWidget(page ? page : (u ? SETUP_MAININFO : SETUP_ALERT)); connect(pClient, SIGNAL(event(ICQEvent*)), this, SLOT(processEvent(ICQEvent*))); connect(btnSave, SIGNAL(clicked()), this, SLOT(saveInfo())); connect(btnClose, SIGNAL(clicked()), this, SLOT(close())); if (u && (u->Type == USER_TYPE_ICQ)){ connect(btnUpdate, SIGNAL(clicked()), this, SLOT(update())); }else{ btnUpdate->hide(); } loadInfo(); setTitle(); setIcon(); }
void UserInfo::loadInfo() { ICQUser *u = pClient->getUser(m_nUin); if (u == NULL) return; emit loadInfo(u); }
void PointViewerMainWindow::handleMessage(QByteArray message) { QList<QByteArray> commandTokens = message.split('\n'); if (commandTokens.empty()) return; if (commandTokens[0] == "OPEN_FILES") { QList<QByteArray> flags = commandTokens[1].split('\0'); bool replaceLabel = flags.contains("REPLACE_LABEL"); bool deleteAfterLoad = flags.contains("DELETE_AFTER_LOAD"); for (int i = 2; i < commandTokens.size(); ++i) { QList<QByteArray> pathAndLabel = commandTokens[i].split('\0'); if (pathAndLabel.size() != 2) { g_logger.error("Unrecognized OPEN_FILES token: %s", QString(commandTokens[i])); continue; } FileLoadInfo loadInfo(pathAndLabel[0], pathAndLabel[1], replaceLabel); loadInfo.deleteAfterLoad = deleteAfterLoad; m_fileLoader->loadFile(loadInfo); } } else if (commandTokens[0] == "CLEAR_FILES") { m_geometries->clear(); } else if (commandTokens[0] == "UNLOAD_FILES") { QString regex_str = commandTokens[1]; QRegExp regex(regex_str, Qt::CaseSensitive, QRegExp::WildcardUnix); if (!regex.isValid()) { g_logger.error("Invalid pattern in -unload command: '%s': %s", regex_str, regex.errorString()); return; } m_geometries->unloadFiles(regex); } else if (commandTokens[0] == "SET_VIEW_POSITION") { if (commandTokens.size()-1 != 3) { tfm::format(std::cerr, "Expected three coordinates, got %d\n", commandTokens.size()-1); return; } bool xOk = false, yOk = false, zOk = false; double x = commandTokens[1].toDouble(&xOk); double y = commandTokens[2].toDouble(&yOk); double z = commandTokens[3].toDouble(&zOk); if (!zOk || !yOk || !zOk) { std::cerr << "Could not parse XYZ coordinates for position\n"; return; } m_pointView->setExplicitCursorPos(Imath::V3d(x, y, z)); } else if (commandTokens[0] == "SET_VIEW_ANGLES") { if (commandTokens.size()-1 != 3) { tfm::format(std::cerr, "Expected three view angles, got %d\n", commandTokens.size()-1); return; } bool yawOk = false, pitchOk = false, rollOk = false; double yaw = commandTokens[1].toDouble(&yawOk); double pitch = commandTokens[2].toDouble(&pitchOk); double roll = commandTokens[3].toDouble(&rollOk); if (!yawOk || !pitchOk || !rollOk) { std::cerr << "Could not parse Euler angles for view\n"; return; } m_pointView->camera().setRotation( QQuaternion::fromAxisAndAngle(0,0,1, roll) * QQuaternion::fromAxisAndAngle(1,0,0, pitch-90) * QQuaternion::fromAxisAndAngle(0,0,1, yaw) ); } else if (commandTokens[0] == "SET_VIEW_RADIUS") { bool ok = false; double viewRadius = commandTokens[1].toDouble(&ok); if (!ok) { std::cerr << "Could not parse view radius"; return; } m_pointView->camera().setEyeToCenterDistance(viewRadius); } else if (commandTokens[0] == "QUERY_CURSOR") { // Yuck! IpcChannel* channel = dynamic_cast<IpcChannel*>(sender()); if (!channel) { qWarning() << "Signalling object not a IpcChannel!\n"; return; } V3d p = m_pointView->cursorPos(); std::string response = tfm::format("%.15g %.15g %.15g", p.x, p.y, p.z); channel->sendMessage(QByteArray(response.data(), (int)response.size())); } else if (commandTokens[0] == "QUIT") { close(); } else if (commandTokens[0] == "SET_MAX_POINT_COUNT") { m_maxPointCount = commandTokens[1].toLongLong(); } else if (commandTokens[0] == "OPEN_SHADER") { openShaderFile(commandTokens[1]); } else if(commandTokens[0] == "HOOK") { IpcChannel* channel = dynamic_cast<IpcChannel*>(sender()); if (!channel) { qWarning() << "Signalling object not a IpcChannel!\n"; return; } for(int i=1; i<commandTokens.count(); i+=2) { HookFormatter* formatter = new HookFormatter(this, commandTokens[i], commandTokens[i+1], channel); m_hookManager->connectHook(commandTokens[i], formatter); } } else { g_logger.error("Unkown remote message:\n%s", QString::fromUtf8(message)); } }
// initialize basic geometry and shaders for this example bool initialize( const char* filename) { // define model with model loader /*bool geometryLoadedCorrectly; Mesh object; ShaderLoader programLoad;*/ int index; std::vector<Mesh> meshes; ShaderLoader programLoad; // load the image info if( !loadInfo( filename, meshes, numImages ) ) { return false; } // loop through each planet for( index = 0; index < numImages; index++ ) { // Create a Vertex Buffer object to store this vertex info on the GPU glGenBuffers(1, &(images[index].vbo_geometry)); glBindBuffer(GL_ARRAY_BUFFER, images[index].vbo_geometry); glBufferData(GL_ARRAY_BUFFER, meshes[index].geometry.size()* sizeof(Vertex), &(meshes[index].geometry[0]), GL_STATIC_DRAW); // Create Texture object glGenTextures(1, &(images[index].texture)); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, images[index].texture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, images[index].imageCols, images[index].imageRows, 0, GL_RGBA, GL_UNSIGNED_BYTE, images[index].m_blob.data()); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glGenBuffers(1, &(images[index].normalbuffer)); glBindBuffer(GL_ARRAY_BUFFER, images[index].normalbuffer); glBufferData(GL_ARRAY_BUFFER, meshes[index].geometry.size() * sizeof(Vertex), &(meshes[index].geometry[0]), GL_STATIC_DRAW); //glBufferData(GL_ARRAY_BUFFER, meshes[index].geometry.size() * sizeof(Vertex), &(meshes[index].geometry[offsetof(Vertex,normals)]), GL_STATIC_DRAW); } //if( viewType == 0 ) //{ // loads shaders to program programLoad.loadShader( vsFileName, fsFileName1, program ); //} /* else { // loads shaders to program programLoad.loadShader( vsFileName, fsFileName1, program ); } */ // Get a handle for our "MVP" uniform loc_mvpmat = glGetUniformLocation(program, "mvpMatrix"); if(loc_mvpmat == -1) { std::cerr << "[F] MVP MATRIX NOT FOUND" << std::endl; return false; } viewMatrixID = glGetUniformLocation(program, "V"); if(viewMatrixID == -1) { std::cerr << "[F] VIEW NOT FOUND" << std::endl; return false; } modelMatrixID = glGetUniformLocation(program, "M"); if(modelMatrixID == -1) { std::cerr << "[F] MODEL NOT FOUND" << std::endl; return false; } /* // Get a handle for our buffers loc_position = glGetAttribLocation(program, "v_position"); if(loc_position == -1) { std::cerr << "[F] POSITION NOT FOUND" << std::endl; return false; } loc_texture = glGetAttribLocation(program, "v_color"); if(loc_texture == -1) { std::cerr << "[F] COLOR NOT FOUND" << std::endl; return false; } */ // Get a handle for our buffers loc_position = glGetAttribLocation(program, "v_position"); if(loc_position == -1) { std::cerr << "[F] POSITION NOT FOUND" << std::endl; return false; } loc_texture = glGetAttribLocation(program, "v_color"); if(loc_texture == -1) { std::cerr << "[F] UV NOT FOUND" << std::endl; return false; } vertexNormal_modelspaceID = glGetAttribLocation(program, "vertexNormal_modelspace"); if(vertexNormal_modelspaceID == -1) { std::cerr << "[F] NORMAL NOT FOUND" << std::endl; return false; } //--Init the view and projection matrices // if you will be having a moving camera the view matrix will need to more dynamic // ...Like you should update it before you render more dynamic // for this project having them static will be fine view = glm::lookAt( glm::vec3(0.0, 7.0, -23.0), //Eye Position glm::vec3(0.0, 0.0, 0.0), //Focus point glm::vec3(0.0, 1.0, 0.0)); //Positive Y is up projection = glm::perspective( 45.0f, //the FoV typically 90 degrees is good which is what this is set to float(w)/float(h), //Aspect Ratio, so Circles stay Circular 0.01f, //Distance to the near plane, normally a small value like this 100.0f); //Distance to the far plane //enable depth testing glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); //and its done return true; }
void PointViewerMainWindow::handleMessage(QByteArray message) { QList<QByteArray> commandTokens = message.split('\n'); if (commandTokens.empty()) return; if (commandTokens[0] == "OPEN_FILES") { QList<QByteArray> flags = commandTokens[1].split('\0'); bool replaceLabel = flags.contains("REPLACE_LABEL"); bool deleteAfterLoad = flags.contains("DELETE_AFTER_LOAD"); bool mutateExisting = flags.contains("MUTATE_EXISTING"); for (int i = 2; i < commandTokens.size(); ++i) { QList<QByteArray> pathAndLabel = commandTokens[i].split('\0'); if (pathAndLabel.size() != 2) { g_logger.error("Unrecognized OPEN_FILES token: %s", QString(commandTokens[i])); continue; } FileLoadInfo loadInfo(pathAndLabel[0], pathAndLabel[1], replaceLabel); loadInfo.deleteAfterLoad = deleteAfterLoad; loadInfo.mutateExisting = mutateExisting; m_fileLoader->loadFile(loadInfo); } } else if (commandTokens[0] == "CLEAR_FILES") { m_geometries->clear(); } else if (commandTokens[0] == "UNLOAD_FILES") { QString regex_str = commandTokens[1]; QRegExp regex(regex_str, Qt::CaseSensitive, QRegExp::WildcardUnix); if (!regex.isValid()) { g_logger.error("Invalid pattern in -unload command: '%s': %s", regex_str, regex.errorString()); return; } m_geometries->unloadFiles(regex); m_pointView->removeAnnotations(regex); } else if (commandTokens[0] == "SET_VIEW_LABEL") { QString regex_str = commandTokens[1]; QRegExp regex(regex_str, Qt::CaseSensitive, QRegExp::FixedString); if (!regex.isValid()) { g_logger.error("Invalid pattern in -unload command: '%s': %s", regex_str, regex.errorString()); return; } QModelIndex index = m_geometries->findLabel(regex); if (index.isValid()) m_pointView->centerOnGeometry(index); } else if (commandTokens[0] == "ANNOTATE") { if (commandTokens.size() - 1 != 5) { tfm::format(std::cerr, "Expected five arguments, got %d\n", commandTokens.size() - 1); return; } QString label = commandTokens[1]; QString text = commandTokens[2]; bool xOk = false, yOk = false, zOk = false; double x = commandTokens[3].toDouble(&xOk); double y = commandTokens[4].toDouble(&yOk); double z = commandTokens[5].toDouble(&zOk); if (!zOk || !yOk || !zOk) { std::cerr << "Could not parse XYZ coordinates for position\n"; return; } m_pointView->addAnnotation(label, text, Imath::V3d(x, y, z)); } else if (commandTokens[0] == "SET_VIEW_POSITION") { if (commandTokens.size()-1 != 3) { tfm::format(std::cerr, "Expected three coordinates, got %d\n", commandTokens.size()-1); return; } bool xOk = false, yOk = false, zOk = false; double x = commandTokens[1].toDouble(&xOk); double y = commandTokens[2].toDouble(&yOk); double z = commandTokens[3].toDouble(&zOk); if (!zOk || !yOk || !zOk) { std::cerr << "Could not parse XYZ coordinates for position\n"; return; } m_pointView->setExplicitCursorPos(Imath::V3d(x, y, z)); } else if (commandTokens[0] == "SET_VIEW_ANGLES") { if (commandTokens.size()-1 != 3) { tfm::format(std::cerr, "Expected three view angles, got %d\n", commandTokens.size()-1); return; } bool yawOk = false, pitchOk = false, rollOk = false; double yaw = commandTokens[1].toDouble(&yawOk); double pitch = commandTokens[2].toDouble(&pitchOk); double roll = commandTokens[3].toDouble(&rollOk); if (!yawOk || !pitchOk || !rollOk) { std::cerr << "Could not parse Euler angles for view\n"; return; } m_pointView->camera().setRotation( QQuaternion::fromAxisAndAngle(0,0,1, roll) * QQuaternion::fromAxisAndAngle(1,0,0, pitch-90) * QQuaternion::fromAxisAndAngle(0,0,1, yaw) ); } else if (commandTokens[0] == "SET_VIEW_ROTATION") { if (commandTokens.size()-1 != 9) { tfm::format(std::cerr, "Expected 9 rotation matrix components, got %d\n", commandTokens.size()-1); return; } # ifdef DISPLAZ_USE_QT4 qreal rot[9] = {0}; # else float rot[9] = {0}; # endif for (int i = 0; i < 9; ++i) { bool ok = true; rot[i] = commandTokens[i+1].toDouble(&ok); if(!ok) { tfm::format(std::cerr, "badly formatted view matrix message:\n%s", message.constData()); return; } } m_pointView->camera().setRotation(QMatrix3x3(rot)); } else if (commandTokens[0] == "SET_VIEW_RADIUS") { bool ok = false; double viewRadius = commandTokens[1].toDouble(&ok); if (!ok) { std::cerr << "Could not parse view radius"; return; } m_pointView->camera().setEyeToCenterDistance(viewRadius); } else if (commandTokens[0] == "QUERY_CURSOR") { // Yuck! IpcChannel* channel = dynamic_cast<IpcChannel*>(sender()); if (!channel) { qWarning() << "Signalling object not a IpcChannel!\n"; return; } V3d p = m_pointView->cursorPos(); std::string response = tfm::format("%.15g %.15g %.15g", p.x, p.y, p.z); channel->sendMessage(QByteArray(response.data(), (int)response.size())); } else if (commandTokens[0] == "QUIT") { close(); } else if (commandTokens[0] == "SET_MAX_POINT_COUNT") { m_maxPointCount = commandTokens[1].toLongLong(); } else if (commandTokens[0] == "OPEN_SHADER") { openShaderFile(commandTokens[1]); } else if (commandTokens[0] == "NOTIFY") { if (commandTokens.size() < 3) { g_logger.error("Could not parse NOTIFY message: %s", QString::fromUtf8(message)); return; } QString spec = QString::fromUtf8(commandTokens[1]); QList<QString> specList = spec.split(':'); if (specList[0].toLower() != "log") { g_logger.error("Could not parse NOTIFY spec: %s", spec); return; } Logger::LogLevel level = Logger::Info; if (specList.size() > 1) level = Logger::parseLogLevel(specList[1].toLower().toStdString()); // Ugh, reassemble message from multiple lines. Need a better // transport serialization! QByteArray message; for (int i = 2; i < commandTokens.size(); ++i) { if (i > 2) message += "\n"; message += commandTokens[i]; } g_logger.log(level, "%s", tfm::makeFormatList(message.constData())); } else if(commandTokens[0] == "HOOK") { IpcChannel* channel = dynamic_cast<IpcChannel*>(sender()); if (!channel) { qWarning() << "Signalling object not a IpcChannel!\n"; return; } for(int i=1; i<commandTokens.count(); i+=2) { HookFormatter* formatter = new HookFormatter(this, commandTokens[i], commandTokens[i+1], channel); m_hookManager->connectHook(commandTokens[i], formatter); } } else { g_logger.error("Unkown remote message:\n%s", QString::fromUtf8(message)); } }