void QtAddIMContact::addIMContact() { QString contactId = _ui->contactIdLineEdit->text().trimmed(); if (contactId.isEmpty()) { return; } QString protocolName = _ui->protocolComboBox->currentText(); EnumIMProtocol::IMProtocol imProtocol = EnumIMProtocol::toIMProtocol(protocolName.toStdString()); // sip contact should know their domain Config & config = ConfigManager::getInstance().getCurrentConfig(); QString wengoSuffix = "@" + QString::fromStdString( config.getWengoRealm() ); if (imProtocol == EnumIMProtocol::IMProtocolWengo) { contactId += wengoSuffix; } else if (imProtocol == EnumIMProtocol::IMProtocolSIP) { if (!contactId.contains("@")) { SipAccount * sipaccount = _cUserProfile.getUserProfile().getSipAccount(); if (sipaccount) { contactId += QString("@") + QString::fromStdString(sipaccount->getRealm()); } } } //// IMContact imContact(imProtocol, contactId.toStdString()); IMAccountList imAccounts = getSelectedIMAccounts(imProtocol); if (imAccounts.empty()) { _contactProfile.addIMContact(imContact); } for (IMAccountList::const_iterator it = imAccounts.begin(); it != imAccounts.end(); ++it) { IMAccount * imAccount = // _cUserProfile.getUserProfile().getIMAccountManager().getIMAccount((*it).getUUID()); //VOXOX - JRT - 2009.04.09 // _cUserProfile.getUserProfile().getIMAccountManager().getIMAccount( it->second.getUUID()); _cUserProfile.getUserProfile().getIMAccountManager().getIMAccount( it->second ); //VOXOX - JRT - 2009.04.24 imContact.setIMAccount(imAccount); _contactProfile.addIMContact(imContact); OWSAFE_DELETE(imAccount); } }
void QtAddIMContact::loadIMAccounts(EnumIMProtocol::IMProtocol imProtocol) { _ui->treeWidget->clear(); IMAccountList imAccounts = _cUserProfile.getUserProfile().getIMAccountManager().getIMAccountsOfProtocol(imProtocol); for (IMAccountList::const_iterator it = imAccounts.begin(); it != imAccounts.end(); ++it) { QTreeWidgetItem * item = new QTreeWidgetItem(_ui->treeWidget); //By default, check the first element only if (it == imAccounts.begin()) { item->setCheckState(0, Qt::Checked); } else { item->setCheckState(0, Qt::Unchecked); } // item->setText(1, QString::fromStdString((*it).getLogin())); //VOXOX - JRT - 2009.04.09 item->setText(1, QString::fromStdString( it->second.getLogin())); } }
IMAccountList QtAddIMContact::getSelectedIMAccounts(EnumIMProtocol::IMProtocol imProtocol) const { IMAccountList result; IMAccountList imAccounts = _cUserProfile.getUserProfile().getIMAccountManager().getIMAccountsOfProtocol(imProtocol); for (IMAccountList::const_iterator it = imAccounts.begin(); it != imAccounts.end(); ++it) { // QList<QTreeWidgetItem *> list = _ui->treeWidget->findItems(QString::fromStdString((*it).getLogin()), Qt::MatchExactly, 1); //VOXOX - JRT - 2009.04.09 QList<QTreeWidgetItem *> list = _ui->treeWidget->findItems(QString::fromStdString( it->second.getLogin()), Qt::MatchExactly, 1); if (list.size() > 0) { //There should be only one item QTreeWidgetItem * item = list[0]; if (item->checkState(0) == Qt::Checked) { // result.push_back(*it); //VOXOX - JRT - 2009.04.09 result.Add( const_cast<IMAccount&>(it->second) ); } } } return result; }
bool ConfigImporter::importConfigFromV7toV8() { StringList list = UserProfileHandler::getUserProfileNames(); std::map<std::string, EnumIMProtocol::IMProtocol> accountMap; for (StringList::const_iterator it = list.begin(); it != list.end(); ++it) { std::string userProfileDirectory = File::convertPathSeparators(Config::getConfigDir() + "profiles/" + *it + "/"); //Loading data FileReader iIMAccountsFile(userProfileDirectory + "imaccounts.xml"); iIMAccountsFile.open(); String data = iIMAccountsFile.read(); IMAccountList imAccountList; IMAccountListXMLSerializer1 imAccountListSerializer1(imAccountList); imAccountListSerializer1.unserialize(data); FileReader iContactListFile(userProfileDirectory + "contactlist.xml"); iContactListFile.open(); data = iContactListFile.read(); UserProfile userProfile; ContactList contactList(userProfile); ContactListXMLSerializer1 contactListSerializer1(contactList, imAccountList); contactListSerializer1.unserialize(data); // Look for IMAccount and Contact link to the IMAccount with login FAKE_LOGIN. It has been introduced by a previous importation step // to avoid the SSO request. for (IMAccountList::iterator ait = imAccountList.begin(); ait != imAccountList.end(); ++ait) { // if (((*ait).getProtocol() == EnumIMProtocol::IMProtocolWengo) // && ((*ait).getLogin() == FAKE_LOGIN)) { if (( ait->second.getProtocol() == EnumIMProtocol::IMProtocolWengo) && ( ait->second.getLogin() == FAKE_LOGIN)) { // Update contact links to this IMAccount (update UUID and remove CONTACT_PREFIX). //VOXOX - JRT - 2009.04.07 - Use new map-based class. // for (ContactList::Contacts::iterator cit = const_cast<ContactList::Contacts &>(contactList.getContacts()).begin(); // cit != contactList.getContacts().end(); for ( Contacts::iterator cit = const_cast<Contacts &>(contactList.getContacts()).begin(); cit != contactList.getContacts().end(); cit++) { // IMContactSet & imContactSet = const_cast<IMContactSet &>((*cit).getIMContactSet()); //VOXOX - JRT - 2009.04.07 IMContactSet & imContactSet = const_cast<IMContactSet &>((*cit).second.getIMContactSet()); for (IMContactSet::iterator imit = imContactSet.begin(); imit != imContactSet.end(); imit++) { if (String((*imit).getContactId()).beginsWith(CONTACT_PREFIX)) { const_cast<IMContact &>(*imit).setContactId((*imit).getContactId().substr(CONTACT_PREFIX.size())); // const_cast<IMContact &>(*imit).setIMAccount(&(*ait)); //VOXOX - JRT - 2009.04.09 const_cast<IMContact &>(*imit).setIMAccount(&(ait->second)); } } } // Removing the IMAccount imAccountList.erase(ait); break; } } //// IMAccountListXMLSerializer lastIMAccountListSerializer(imAccountList); data = lastIMAccountListSerializer.serialize(); FileWriter oIMAccountsFile(userProfileDirectory + "imaccounts.xml"); oIMAccountsFile.write(data); ContactListXMLSerializer lastContactListSerializer(contactList, imAccountList); data = lastContactListSerializer.serialize(); FileWriter oContactListFile(userProfileDirectory + "contactlist.xml"); oContactListFile.write(data); //// } return true; }