unsigned int KConfigBase::readUnsignedNumEntry(const char *pKey, unsigned int nDefault) const { QCString aValue = readEntryUtf8(pKey); if(aValue.isNull()) return nDefault; else { bool ok; unsigned int rc = aValue.toUInt(&ok); return (ok ? rc : nDefault); } }
void MigrateDialog::process() { unsigned size = 0; for (list<QCheckBox*>::iterator it = m_boxes.begin(); it != m_boxes.end(); ++it){ if (!(*it)->isChecked()) continue; QString path = user_file((*it)->text()); path += '/'; icqConf.close(); clientsConf.close(); contactsConf.close(); icqConf.setName(path + "icq.conf"); clientsConf.setName(path + "clients.conf"); contactsConf.setName(path + "contacts.conf"); lblStatus->setText(path + "icq.conf"); if (!icqConf.open(IO_ReadOnly)){ error(i18n("Can't open %1") .arg(path + "icq.conf")); return; } if (!clientsConf.open(IO_WriteOnly | IO_Truncate)){ error(i18n("Can't open %1") .arg(path + "clients.conf")); return; } if (!contactsConf.open(IO_WriteOnly | IO_Truncate)){ error(i18n("Can't open %1") .arg(path + "contacts.conf")); return; } m_uin = 0; m_passwd = ""; m_state = 0; m_grpId = 0; m_contactId = 0; Buffer cfg; cfg.init(icqConf.size()); icqConf.readBlock(cfg.data(), icqConf.size()); for (;;){ QCString section = cfg.getSection(); if (section.isEmpty()) break; m_state = 3; if (section == "Group") m_state = 1; if (section == "User") m_state = 2; if (!m_bProcess) return; for (;;){ QCString l = cfg.getLine(); if (l.isEmpty()) break; QCString line = l; QCString name = getToken(line, '='); if (name == "UIN") m_uin = line.toUInt(); if (name == "EncryptPassword") m_passwd = line; if (name == "Name") m_name = line; if (name == "Alias") m_name = line; } flush(); barCnv->setProgress(cfg.readPos()); qApp->processEvents(); } icqConf.close(); clientsConf.close(); contactsConf.close(); m_state = 3; size += icqConf.size(); if (!m_bProcess) return; barCnv->setProgress(size); qApp->processEvents(); QString h_path = path; #ifdef WIN32 h_path += "history\\"; #else h_path += "history/"; #endif QDir history(h_path); QStringList l = history.entryList("*.history", QDir::Files); for (QStringList::Iterator it = l.begin(); it != l.end(); ++it){ hFrom.close(); hTo.close(); hFrom.setName(h_path + (*it)); lblStatus->setText(h_path + (*it)); hTo.setName(h_path + QString(m_owner) + '.' + (*it).left((*it).find('.'))); if (!hFrom.open(IO_ReadOnly)){ error(i18n("Can't open %1") .arg(hFrom.name())); return; } if (!hTo.open(IO_WriteOnly | IO_Truncate)){ error(i18n("Can't open %1") .arg(hTo.name())); return; } cfg.init(hFrom.size()); hFrom.readBlock(cfg.data(), hFrom.size()); for (;;){ QCString section = cfg.getSection(); if (section.isEmpty()) break; m_state = 3; if (section == "Message") m_state = 4; if (!m_bProcess) return; for (;;){ QCString l = cfg.getLine(); if (l.isEmpty()) break; QCString line = l; QCString name = getToken(line, '='); if (name == "Message") m_message = line; if (name == "Time") m_time = line; if (name == "Direction") m_direction = line; if (name == "Charset") m_charset = line; } flush(); barCnv->setProgress(cfg.readPos()); qApp->processEvents(); } hFrom.close(); hTo.close(); m_state = 3; size += hFrom.size(); if (!m_bProcess) return; barCnv->setProgress(size); qApp->processEvents(); } if (chkRemove->isChecked()){ icqConf.remove(); icqConf.setName(path + "sim.conf"); icqConf.remove(); for (QStringList::Iterator it = l.begin(); it != l.end(); ++it){ hFrom.setName(h_path + (*it)); hFrom.remove(); } } } m_bProcess = false; accept(); }