void JabberBrowser::changeMode() { if (m_client->getAllLevels()){ if (m_list->firstChild()) changeMode(m_list->firstChild()); }else{ if (m_list->firstChild()) loadItem(m_list->firstChild()); if (m_list->currentItem()) loadItem(m_list->currentItem()); } }
void Configurator::currentItemChanged( QListWidgetItem* current, QListWidgetItem* previous ) { _currentWigetItem = current; saveItem( previous ); loadItem( current ); }
int FrmImport::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = SecondaryFrm::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: rollbackImport(); break; case 1: loadItem((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break; case 2: { bool _r = readTableNames(); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 3: { bool _r = readTableNames((*reinterpret_cast< AbstractTableFormat*(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 4: hideAppend((*reinterpret_cast< bool(*)>(_a[1]))); break; case 5: Ok(); break; case 6: Cancel(); break; case 7: preview((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break; case 8: preview(); break; case 9: chooseFile(); break; default: ; } _id -= 10; } return _id; }
void CBonusTypeHandler::load(const JsonNode& config) { for(auto & node : config.Struct()) { auto it = bonusNameMap.find(node.first); if(it == bonusNameMap.end()) { //TODO: new bonus // CBonusType bt; // loadItem(node.second, bt); // // auto new_id = bonusTypes.size(); // // bonusTypes.push_back(bt); logBonus->warnStream() << "Adding new bonuses not implemented (" << node.first << ")"; } else { CBonusType& bt = bonusTypes[it->second]; loadItem(node.second, bt); logBonus->traceStream() << "Loaded bonus type " << node.first; } } }
bool Item::loadContainer(xmlNodePtr parentNode, Container* parent) { xmlNodePtr node = parentNode->children; while (node) { if (node->type != XML_ELEMENT_NODE) { node = node->next; continue; } if (xmlStrcmp(node->name, (const xmlChar*)"item") == 0) { if (!loadItem(node, parent)) { return false; } } node = node->next; } return true; }
void FrmReports::browseFiles() { QString fileName = QFileDialog::getOpenFileName(this, tr("Open Report"), "", tr("Report Files (*.bdrt)")); lineOpen->setText(fileName); loadItem(fileName); }
bool IOMapSerialize::loadMap(Map* map) { int64_t start = OTSYS_TIME(); Database* db = Database::getInstance(); std::ostringstream query; DBResult* result = db->storeQuery("SELECT `id` FROM `houses`"); if (!result) { return true; } do { query.str(""); query << "SELECT `data` FROM `tile_store` WHERE `house_id` = " << result->getDataInt("id"); DBResult* tileResult = db->storeQuery(query.str()); if (!tileResult) { continue; } do { unsigned long attrSize = 0; const char* attr = tileResult->getDataStream("data", attrSize); PropStream propStream; propStream.init(attr, attrSize); uint16_t x = 0, y = 0; uint8_t z = 0; propStream.GET_USHORT(x); propStream.GET_USHORT(y); propStream.GET_UCHAR(z); if (x == 0 || y == 0) { continue; } Tile* tile = map->getTile(x, y, z); if (!tile) { continue; } uint32_t item_count = 0; propStream.GET_ULONG(item_count); while (item_count--) { loadItem(propStream, tile); } } while (tileResult->next()); db->freeResult(tileResult); } while (result->next()); db->freeResult(result); std::cout << "> Loaded house items in: " << (OTSYS_TIME() - start) / (1000.) << " s" << std::endl; return true; }
IROM void Flash::get(char* value, int length, const char* key, const char* dflt) { int idx=findKey(key); uint16_t len=4; if ( idx>=0 ) { if ( !loadItem(idx+1,(uint8_t*)value,len) ) { os_strncpy(value,dflt,length); } else { value[len]='\0'; } } else os_strncpy(value,dflt,length); }
void CBay::draw() { m_devref = m_Info.devref; QGraphicsItem* pItem = CItemFactory::instance()->getItem(m_devref); CGraphicsComponent* pBay = dynamic_cast<CGraphicsComponent*>(pItem); if (pBay) { QString strID; loadItem(pBay->getFileName(),strID); } setPos(m_Info.x, m_Info.y); }
bool Item::loadContainer(xmlNodePtr parentNode, Container* parent) { for(xmlNodePtr node = parentNode->children; node; node = node->next) { if(node->type != XML_ELEMENT_NODE) continue; if(!xmlStrcmp(node->name, (const xmlChar*)"item") && !loadItem(node, parent)) return false; } return true; }
bool food_manager::load(const boost::filesystem::path & p) { if(!boost::filesystem::is_directory(p)) { log_error() << "The path " << p << " is not a directory." << std::endl; return true; } for(auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(p), {})) { if(boost::filesystem::is_directory(entry)) load(entry); else loadItem(entry); } return true; }
void ModulesDialog::moduleAction(QTreeWidgetItem *) { kdebugf(); QTreeWidgetItem *selectedItem = getSelected(); if (!selectedItem) return; // TODO: OH LOL if ((selectedItem->text(2) == tr("Dynamic")) && (selectedItem->text(3) == tr("Loaded"))) unloadItem(selectedItem->text(0)); else if ((selectedItem->text(2) == tr("Dynamic")) && (selectedItem->text(3) == tr("Not loaded"))) loadItem(selectedItem->text(0)); kdebugf2(); }
void PropertyBrowser::itemMoved(int id) { if (m_currentId != id) { loadItem(id); } ObjectVisual *objVis = m_scene->getObjectById(id); if (objVis == NULL) return; QtProperty *property; property = m_idToProperty[PROPERTY_POSITION_X]; m_doubleManager->setValue(property, objVis->pos().x()); property = m_idToProperty[PROPERTY_POSITION_Y]; m_doubleManager->setValue(property, objVis->pos().y()); }
bool IOMapSerialize::loadContainer(PropStream& propStream, Container* container) { while (container->serializationCount > 0) { if (!loadItem(propStream, container)) { std::cout << "[Warning - IOMapSerialize::loadContainer] Unserialization error for container item: " << container->getID() << std::endl; return false; } container->serializationCount--; } uint8_t endAttr; if (!propStream.read<uint8_t>(endAttr) || endAttr != 0) { std::cout << "[Warning - IOMapSerialize::loadContainer] Unserialization error for container item: " << container->getID() << std::endl; return false; } return true; }
bool IOMapSerialize::loadContainer(PropStream& propStream, Container* container) { while (container->serializationCount > 0) { if (!loadItem(propStream, container)) { std::cout << "WARNING: Unserialization error for containing item in IOMapSerialize::loadContainer() - " << container->getID() << std::endl; return false; } container->serializationCount--; } uint8_t endAttr = 0; propStream.GET_UCHAR(endAttr); if (endAttr != 0x00) { std::cout << "WARNING: Unserialization error for containing item in IOMapSerialize::loadContainer() - " << container->getID() << std::endl; return false; } return true; }
void SearchPkcs11::buttonPress(QAbstractButton *but) { QList<QListWidgetItem *> libitems; QListWidgetItem *lib; switch (buttonBox->standardButton(but)) { case QDialogButtonBox::Ok: accept(); break; default: case QDialogButtonBox::Cancel: reject(); break; case QDialogButtonBox::Open: libitems = liblist->selectedItems(); foreach(lib, libitems) loadItem(lib); break; } }
void IOMapSerialize::loadMap(Map* map) { int64_t start = OTSYS_TIME(); Database* db = Database::getInstance(); DBResult* result = db->storeQuery("SELECT `data` FROM `tile_store`"); if (!result) { return; } do { unsigned long attrSize; const char* attr = result->getDataStream("data", attrSize); PropStream propStream; propStream.init(attr, attrSize); uint16_t x, y; uint8_t z; if (!propStream.GET_USHORT(x) || !propStream.GET_USHORT(y) || !propStream.GET_UCHAR(z)) { continue; } Tile* tile = map->getTile(x, y, z); if (!tile) { continue; } uint32_t item_count; if (!propStream.GET_ULONG(item_count)) { continue; } while (item_count--) { loadItem(propStream, tile); } } while (result->next()); db->freeResult(result); std::cout << "> Loaded house items in: " << (OTSYS_TIME() - start) / (1000.) << " s" << std::endl; }
bool IOMapSerialize::loadContainer(PropStream& propStream, Container* container) { while(container->serializationCount > 0) { if(!loadItem(propStream, container, false)) { std::clog << "[Warning - IOMapSerialize::loadContainer] Unserialization error [0] for item in container " << container->getID() << std::endl; return false; } container->serializationCount--; } uint8_t endAttr = ATTR_END; propStream.getByte(endAttr); if(endAttr == ATTR_END) return true; std::clog << "[Warning - IOMapSerialize::loadContainer] Unserialization error [1] for item in container " << container->getID() << std::endl; return false; }
void SavegameManager::loadTrainer() { ska::IniReader reader("./Data/Saves/" + m_pathname + "/trainer.ini"); m_startMapName = reader.get<std::string>("Trainer start_map_name"); std::string buf = "./Levels/"; buf += m_startMapName; buf += "/"; buf += m_startMapName; buf += ".ini"; ska::IniReader mapReader(buf); m_startMapChipsetName = mapReader.get<std::string>("Chipset file"); for (unsigned int i = 0; reader.exists("Items " + ska::StringUtils::intToStr(i) + "_id"); i++) { const auto& id = ska::StringUtils::intToStr(i); loadItem(reader.get<int>("Items " + id + "_id"), reader.get<unsigned int>("Items " + id + "_amount")); } }
void JabberBrowser::currentChanged(QListViewItem*) { Command cmd; cmd->id = CmdBrowseInfo; cmd->flags = m_list->currentItem() ? 0 : COMMAND_DISABLED; cmd->param = this; Event eNext(EventCommandDisabled, cmd); eNext.process(); cmd->id = CmdBrowseSearch; cmd->flags = haveFeature("jabber:iq:search") ? 0 : COMMAND_DISABLED; eNext.process(); cmd->id = CmdRegister; cmd->flags = haveFeature("jabber:iq:register") ? 0 : COMMAND_DISABLED; eNext.process(); cmd->id = CmdBrowseConfigure; cmd->flags = haveFeature("jabber:iq:data") ? 0 : COMMAND_DISABLED; eNext.process(); QListViewItem *item = m_list->currentItem(); if (item == NULL) return; loadItem(item); }
bool MSWeaponArmory::loadItemsDB(char* xmlData, int xmlSize) { pugi::xml_document xmlFile; pugi::xml_parse_result parseResult = xmlFile.load_buffer_inplace(xmlData, xmlSize); if(!parseResult) r3dError("Failed to parse XML, error: %s", parseResult.description()); pugi::xml_node xmlDB = xmlFile.child("DB"); { pugi::xml_node xmlArmory = xmlDB.child("WeaponsArmory"); pugi::xml_node xmlWeapon = xmlArmory.child("Weapon"); while(!xmlWeapon.empty()) { loadWeapon(xmlWeapon); xmlWeapon = xmlWeapon.next_sibling(); } } { pugi::xml_node xmlArmory = xmlDB.child("GearArmory"); pugi::xml_node xmlGear = xmlArmory.child("Gear"); while(!xmlGear.empty()) { loadGear(xmlGear); xmlGear = xmlGear.next_sibling(); } } { pugi::xml_node xmlItems = xmlDB.child("ItemsDB"); pugi::xml_node xmlItem = xmlItems.child("Item"); while(!xmlItem.empty()) { loadItem(xmlItem); xmlItem = xmlItem.next_sibling(); } } return true; }
IROM int Flash::findKey(const char*s) { Quad temp; uint16_t strLen=os_strlen(s); char* szKey[40]; uint16_t offset=8; // after signature and sequence while(true) { temp.w = flashReadQuad(offset); // INFO(" temp.index %u temp.length %u",temp.index,temp.length); if ( temp.index==0xFFFF ) return -1; if ( temp.length == strLen ) { uint16_t length=40; loadItem(offset,(uint8_t*)szKey,length); szKey[length]='\0'; // INFO(" strcmp %s : %s : %u ",szKey,s,length); if ( os_strncmp((const char*)szKey,s,(int)length)==0) return temp.index; } offset = offset + roundQuad(temp.length)+4; if ( offset > PAGE_SIZE) return -1; } return -1; }
bool IOMapSerialize::loadMapBinaryTileBased(Map* map) { Database* db = Database::getInstance(); DBResult* result; DBQuery query; query << "SELECT `house_id`, `data` FROM `tile_store` WHERE `world_id` = " << g_config.getNumber(ConfigManager::WORLD_ID); if(!(result = db->storeQuery(query.str()))) return false; House* house = NULL; do { int32_t houseId = result->getDataInt("house_id"); house = Houses::getInstance()->getHouse(houseId); uint64_t attrSize = 0; const char* attr = result->getDataStream("data", attrSize); PropStream propStream; propStream.init(attr, attrSize); while(propStream.size()) { uint16_t x = 0, y = 0; uint8_t z = 0; propStream.getShort(x); propStream.getShort(y); propStream.getByte(z); uint32_t itemCount = 0; propStream.getLong(itemCount); Position pos(x, y, (int16_t)z); if(house && house->hasPendingTransfer()) { if(Player* player = g_game.getPlayerByGuidEx(house->getOwner())) { while(itemCount--) loadItem(propStream, player->getInbox(), true); if(player->isVirtual()) { IOLoginData::getInstance()->savePlayer(player); delete player; } } } else if(Tile* tile = map->getTile(pos)) { while(itemCount--) loadItem(propStream, tile, false); } else { std::clog << "[Error - IOMapSerialize::loadMapBinary] Unserialization of invalid tile" << " at position " << pos << std::endl; break; } } } while(result->next()); result->free(); return true; }
void FrmReports::loadItem(QListWidgetItem* item) { loadItem(qApp->translate("dir", strReportsDir) + tr("\\") + item->text() + tr(".bdrt")); }
// ---------------------------------------------------------------------------- Track::Track(path file) { m_valid = true; FILE* pFile; pFile = fopen(file.c_str(), "rb"); if (!pFile) { m_valid = false; stringw emsg = _("Editor failed to open file:\n \""); emsg += file; emsg += "\""; MsgWndw::get()->showMsg(emsg); return; } // SIGN u64 sign; fread(&sign, sizeof(u64), 1, pFile); if (sign != TOP_SECRET_SIGNATURE_NUMBER) { MsgWndw::get()->showMsg(_("File can not be opened: signature failed.")); m_valid = false; fclose(pFile); return; } // TRACK NAME u8 size; wchar_t* c; fread(&size, sizeof(u8), 1, pFile); if (!Editor::isValidSize(size)) { fclose(pFile); m_valid = false; MsgWndw::get()->showMsg(_("File loading failed!")); return; } c = new wchar_t[size]; fread(c, sizeof(wchar_t), size, pFile); m_track_name = c; delete[] c; // DESIGNER NAME fread(&size, sizeof(u8), 1, pFile); if (!Editor::isValidSize(size)) { fclose(pFile); m_valid = false; MsgWndw::get()->showMsg(_("File loading failed!")); return; } c = new wchar_t[size]; fread(c, sizeof(wchar_t), size, pFile); m_designer = c; delete[] c; // FILE NAME c8* cc; fread(&size, sizeof(u8), 1, pFile); if (!Editor::isValidSize(size)) { fclose(pFile); m_valid = false; MsgWndw::get()->showMsg(_("File loading failed!")); return; } cc = new c8[size]; fread(cc, sizeof(c8), size, pFile); m_file_name = cc; delete[] cc; // MUSIC fread(&size, sizeof(u8), 1, pFile); if (!Editor::isValidSize(size)) { fclose(pFile); m_valid = false; MsgWndw::get()->showMsg(_("File loading failed!")); return; } cc = new c8[size]; fread(cc, sizeof(c8), size, pFile); m_music = cc; delete[] cc; // TERRAIN ISceneManager* sm = Editor::getEditor()->getSceneManager(); m_terrain = new Terrain(sm->getRootSceneNode(), sm, 1, pFile); if (!m_terrain->isValid()) { fclose(pFile); MsgWndw::get()->showMsg(_("Loading failed :invalid terrain!")); m_valid = false; return; } // SKY Sky* s = Viewport::get()->getSky(); delete s; s = new Sky(pFile); Viewport::get()->setSky(s); // GRAVITY ROAD FLAG fread(&m_gravity_road, sizeof(bool), 1, pFile); // ROADS IRoad* r; fread(&size, sizeof(u8), 1, pFile); if (size < 0 || size > MAX_ROAD_NUM) { MsgWndw::get()->showMsg(_("Loading failed: invalid terrain!")); } else { if (size > 0) { m_driveline = new DriveLine(sm->getRootSceneNode(), sm, 0, pFile); if (!m_driveline->isValid()) { std::cerr << _("Warning: invalid driveline!\n"); ISpline* spline = new TCR(sm->getRootSceneNode(), sm, 0); m_driveline = new DriveLine(sm->getRootSceneNode(), sm, 0, spline, L"DriveLine"); } m_roads.push_back(m_driveline); m_driveline->refresh(); } // driveline for (u8 i = 1; i < size; i++) { r = new Road(sm->getRootSceneNode(), sm, 0, pFile); if (r->isValid()) { m_roads.push_back(r); r->refresh(); r->setWireFrame(false); Viewport::get()->setSplineMode(false); } else std::cerr << "Warning: invalid road - skipped :(\n"; } // roads } // valid roadnum // CHECKLINES Viewport::get()->loadCheckLines(pFile); // OBJECTS u32 num; fread(&num, sizeof(u32), 1, pFile); Viewport::setLastEntityID(num + MAGIC_NUMBER); for (u32 i = 0; i < num; i++) { ISceneNode* node = 0; vector3df pos, rot, sca; fread(&pos, sizeof(vector3df), 1, pFile); fread(&rot, sizeof(vector3df), 1, pFile); fread(&sca, sizeof(vector3df), 1, pFile); u8 size; fread(&size, sizeof(u8), 1, pFile); if (!Editor::isValidSize(size)) { m_valid = false; MsgWndw::get()->showMsg(_("Loading failed!")); fclose(pFile); return; } c8 *name = new c8[size]; fread(name, sizeof(c8), size, pFile); path p = name; if (p == path("banana") || p == path("item") || p == path("small-nitro") || p == path("big-nitro")) { node = loadItem(name); } // item else { node = sm->addAnimatedMeshSceneNode(sm->getMesh(p)); node->setName(name); } // object if (node) { node->setPosition(pos); node->setRotation(rot); node->setScale(sca); node->setID(MAGIC_NUMBER + i + 1); } // valid node else { std::cerr << "Warning: couldn't load object < " << name << " >!\n"; num -= 1; i -= 1; } // invalid node delete[] name; } fclose(pFile); } // Track - from file
void *JabberBrowser::processEvent(Event *e) { if (e->type() == EventAgentInfo){ JabberAgentInfo *data = (JabberAgentInfo*)(e->param()); if (m_search_id == data->ReqID.ptr){ if (data->Type.ptr == NULL){ if (data->nOptions.value){ QString err; if (data->Label.ptr && *data->Label.ptr) err = i18n(data->Label.ptr); if (err.isEmpty()) err = i18n("Error %1") .arg(data->nOptions.value); m_search_id = ""; delete m_search; m_search = NULL; Command cmd; cmd->id = CmdBrowseSearch; cmd->param = this; Event eWidget(EventCommandWidget, cmd); QWidget *parent = (QWidget*)(eWidget.process()); if (parent == NULL) parent = this; BalloonMsg::message(err, parent); }else{ m_search->m_search->addWidget(data); QTimer::singleShot(0, this, SLOT(showSearch())); } m_search_id = ""; return e->param(); } m_search->m_search->addWidget(data); return e->param(); } if (m_reg_id == data->ReqID.ptr){ if (data->Type.ptr == NULL){ if (data->nOptions.value){ QString err; if (data->Label.ptr && *data->Label.ptr) err = i18n(data->Label.ptr); if (err.isEmpty()) err = i18n("Error %1") .arg(data->nOptions.value); m_reg_id = ""; delete m_reg; m_reg = NULL; Command cmd; cmd->id = CmdRegister; cmd->param = this; Event eWidget(EventCommandWidget, cmd); QWidget *parent = (QWidget*)(eWidget.process()); if (parent == NULL) parent = this; BalloonMsg::message(err, parent); }else{ m_reg->m_search->addWidget(data); QTimer::singleShot(0, this, SLOT(showReg())); } m_reg_id = ""; return e->param(); } m_reg->m_search->addWidget(data); return e->param(); } if (m_config_id == data->ReqID.ptr){ if (data->Type.ptr == NULL){ if (data->nOptions.value){ QString err; if (data->Label.ptr && *data->Label.ptr) err = i18n(data->Label.ptr); if (err.isEmpty()) err = i18n("Error %1") .arg(data->nOptions.value); m_config_id = ""; delete m_config; m_config = NULL; Command cmd; cmd->id = CmdBrowseConfigure; cmd->param = this; Event eWidget(EventCommandWidget, cmd); QWidget *parent = (QWidget*)(eWidget.process()); if (parent == NULL) parent = this; BalloonMsg::message(err, parent); }else{ m_config->m_search->addWidget(data); QTimer::singleShot(0, this, SLOT(showConfig())); } m_config_id = ""; return e->param(); } m_config->m_search->addWidget(data); return e->param(); } } if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->param != this) return NULL; if (cmd->menu_id != MenuBrowser) return NULL; cmd->flags &= ~COMMAND_CHECKED; switch (cmd->id){ case CmdOneLevel: if (!m_client->getAllLevels()) cmd->flags |= COMMAND_CHECKED; return e->param(); case CmdAllLevels: if (m_client->getAllLevels()) cmd->flags |= COMMAND_CHECKED; return e->param(); case CmdModeDisco: if (m_client->getBrowseType() & BROWSE_DISCO) cmd->flags |= COMMAND_CHECKED; return e->param(); case CmdModeBrowse: if (m_client->getBrowseType() & BROWSE_BROWSE) cmd->flags |= COMMAND_CHECKED; return e->param(); case CmdModeAgents: if (m_client->getBrowseType() & BROWSE_AGENTS) cmd->flags |= COMMAND_CHECKED; return e->param(); } } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->param != this) return NULL; QListViewItem *item = m_list->currentItem(); if (cmd->menu_id == MenuBrowser){ cmd->flags &= ~COMMAND_CHECKED; unsigned mode = m_client->getBrowseType(); switch (cmd->id){ case CmdOneLevel: m_client->setAllLevels(false); changeMode(); return e->param(); case CmdAllLevels: m_client->setAllLevels(true); changeMode(); return e->param(); case CmdModeDisco: mode ^= BROWSE_DISCO; m_client->setBrowseType(mode); changeMode(); return e->param(); case CmdModeBrowse: mode ^= BROWSE_BROWSE; m_client->setBrowseType(mode); changeMode(); return e->param(); case CmdModeAgents: mode ^= BROWSE_AGENTS; m_client->setBrowseType(mode); changeMode(); return e->param(); } return NULL; } if (item){ if (cmd->id == CmdBrowseSearch){ if (m_search) delete m_search; m_search = new JabberWizard(this, i18n("%1 Search") .arg(item->text(COL_NAME).utf8()), "find", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "search"); m_search_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "search"); return e->param(); } if (cmd->id == CmdRegister){ if (m_reg) delete m_reg; m_reg = new JabberWizard(this, i18n("%1 Register") .arg(item->text(COL_NAME).utf8()), "reg", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "register"); m_reg_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "register"); return e->param(); } if (cmd->id == CmdBrowseConfigure){ if (m_config) delete m_config; m_config = new JabberWizard(this, i18n("%1 Configure") .arg(item->text(COL_NAME).utf8()), "configure", m_client, item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "data"); m_config_id = m_client->get_agent_info(item->text(COL_JID).utf8(), item->text(COL_NODE).utf8(), "data"); return e->param(); } if (cmd->id == CmdBrowseInfo){ if (m_info == NULL) m_info = new DiscoInfo(this, m_list->currentItem()->text(COL_FEATURES), item->text(COL_NAME), item->text(COL_TYPE), item->text(COL_CATEGORY)); m_info->reset(); raiseWindow(m_info); return e->param(); } } if (cmd->id == CmdBack){ if (m_historyPos){ m_historyPos--; QString url = QString::fromUtf8(m_history[m_historyPos].c_str()); QString node; if (!m_nodes[m_historyPos].empty()) node = QString::fromUtf8(m_nodes[m_historyPos].c_str()); go(url, node); } } if (cmd->id == CmdForward){ if (m_historyPos + 1 < (int)(m_history.size())){ m_historyPos++; QString url = QString::fromUtf8(m_history[m_historyPos].c_str()); QString node; if (!m_nodes[m_historyPos].empty()) node = QString::fromUtf8(m_nodes[m_historyPos].c_str()); go(url, node); } } if (cmd->id == CmdUrl){ if (m_bInProcess){ stop(""); return e->param(); } QString jid; QString node; Command cmd; cmd->id = CmdUrl; cmd->param = this; Event eWidget(EventCommandWidget, cmd); CToolCombo *cmbUrl = (CToolCombo*)(eWidget.process()); if (cmbUrl) jid = cmbUrl->lineEdit()->text(); cmd->id = CmdNode; CToolCombo *cmbNode = (CToolCombo*)(eWidget.process()); if (cmbNode) node = cmbNode->lineEdit()->text(); if (!jid.isEmpty()){ addHistory(jid); goUrl(jid, node); } return e->param(); } } if (e->type() == EventDiscoItem){ if (!m_bInProcess) return NULL; DiscoItem *item = (DiscoItem*)(e->param()); QListViewItem *it = findItem(COL_ID_DISCO_ITEMS, item->id.c_str()); if (it){ if (item->jid.empty()){ it->setText(COL_ID_DISCO_ITEMS, ""); if (it != m_list->firstChild()){ checkDone(); adjustColumn(it); return e->param(); } QString err; if (!item->name.empty()){ err = QString::fromUtf8(item->name.c_str()); }else if (!item->node.empty()){ err = i18n("Error %1") .arg(atol(item->node.c_str())); } if (!err.isEmpty()){ unsigned mode = atol(it->text(COL_MODE).latin1()); if (((mode & BROWSE_BROWSE) == 0) || (it->text(COL_ID_BROWSE).isEmpty() & m_bError)) stop(err); m_bError = true; } checkDone(); adjustColumn(it); return e->param(); } if (it->firstChild() == NULL){ it->setExpandable(true); if ((it == m_list->firstChild()) || (it == m_list->currentItem())) it->setOpen(true); } QListViewItem *i; for (i = it->firstChild(); i; i = i->nextSibling()){ if ((i->text(COL_JID) == QString::fromUtf8(item->jid.c_str())) && (i->text(COL_NODE) == QString::fromUtf8(item->node.c_str()))) return e->param(); } i = new QListViewItem(it); i->setText(COL_JID, QString::fromUtf8(item->jid.c_str())); i->setText(COL_NAME, item->name.empty() ? QString::fromUtf8(item->jid.c_str()) : QString::fromUtf8(item->name.c_str())); i->setText(COL_NODE, QString::fromUtf8(item->node.c_str())); int mode = 0; if (m_client->getBrowseType() & BROWSE_DISCO){ i->setText(COL_ID_DISCO_INFO, m_client->discoInfo(item->jid.c_str(), item->node.c_str()).c_str()); mode |= BROWSE_INFO; } i->setText(COL_MODE, QString::number(mode)); if (m_client->getAllLevels()) loadItem(i); return e->param(); } it = findItem(COL_ID_DISCO_INFO, item->id.c_str()); if (it){ if (item->jid.empty()){ it->setText(COL_ID_DISCO_INFO, ""); checkDone(); adjustColumn(it); return e->param(); } if (it->text(COL_NAME) == it->text(COL_JID)) it->setText(COL_NAME, QString::fromUtf8(item->name.c_str())); it->setText(COL_CATEGORY, QString::fromUtf8(item->category.c_str())); it->setText(COL_TYPE, QString::fromUtf8(item->type.c_str())); it->setText(COL_FEATURES, QString::fromUtf8(item->features.c_str())); if ((m_client->getAllLevels()) || (it == m_list->currentItem())) loadItem(it); setItemPict(it); if (it == m_list->currentItem()) currentChanged(it); return e->param(); } it = findItem(COL_ID_BROWSE, item->id.c_str()); if (it){ if (item->jid.empty()){ it->setText(COL_ID_BROWSE, ""); if (it != m_list->firstChild()){ checkDone(); adjustColumn(it); return e->param(); } QString err; if (!item->name.empty()){ err = QString::fromUtf8(item->name.c_str()); }else if (!item->node.empty()){ err = i18n("Error %1") .arg(atol(item->node.c_str())); } if (!err.isEmpty()){ unsigned mode = atol(it->text(COL_MODE).latin1()); if (((mode & BROWSE_DISCO) == 0) || (it->text(COL_ID_DISCO_ITEMS).isEmpty() & m_bError)) stop(err); m_bError = true; } checkDone(); adjustColumn(it); return e->param(); } if (it->text(COL_JID) != QString::fromUtf8(item->jid.c_str())){ QListViewItem *i; for (i = it->firstChild(); i; i = i->nextSibling()){ if ((i->text(COL_JID) == QString::fromUtf8(item->jid.c_str())) && (i->text(COL_NODE) == QString::fromUtf8(item->node.c_str()))) break; } if (i){ it = i; }else{ if (it->firstChild() == NULL){ it->setExpandable(true); if ((it == m_list->firstChild()) || (it == m_list->currentItem())) it->setOpen(true); } it = new QListViewItem(it); it->setText(COL_JID, QString::fromUtf8(item->jid.c_str())); if (m_client->getAllLevels()) loadItem(it); } } if (it->text(COL_NAME) == it->text(COL_JID)) it->setText(COL_NAME, QString::fromUtf8(item->name.c_str())); it->setText(COL_CATEGORY, QString::fromUtf8(item->category.c_str())); it->setText(COL_TYPE, QString::fromUtf8(item->type.c_str())); it->setText(COL_FEATURES, QString::fromUtf8(item->features.c_str())); if (m_client->getAllLevels() || (it == m_list->currentItem())) loadItem(it); setItemPict(it); return e->param(); } } return NULL; }
IROM void Flash::get(int& value, const char* key, int dflt) { int idx=findKey(key); uint16_t length=4; if (idx>=0 ) loadItem(idx+1,(uint8_t*)&value,length); else value=dflt; }
void JabberBrowser::changeMode(QListViewItem *item) { loadItem(item); for (item = item->firstChild(); item; item = item->nextSibling()) changeMode(item); }