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())); } }
bool ConfigImporter::importContactsFromV1toV3(const string & fromDir, UserProfile & userProfile) { File mDir(fromDir); StringList fileList = mDir.getFileList(); ContactList & contactList = userProfile.getContactList(); ContactGroup contactGroup( "Classic", EnumGroupType::GroupType_User); //JRT-GRPS contactList.addContactGroup( contactGroup ); ///VOXOX - JRT - 2009.05.07 - JRT-GRPS IMAccountList imAccountList = userProfile.getIMAccountManager().getIMAccountsOfProtocol(EnumIMProtocol::IMProtocolWengo); if (!imAccountList.size()) { return false; } for (unsigned i = 0; i < fileList.size(); i++) { File mFile(fromDir + fileList[i]); string Id = fileList[i].substr(0, fileList[i].find("_", 0)); vcard_t mVcard; initVcard(&mVcard); if (!mFile.getExtension().compare("vcf")) { if (classicVcardParser(fromDir + fileList[i], &mVcard) == false) { continue; } int extPos = fileList[i].find_last_of('.'); string fileWoExt = fileList[i].substr(0, extPos + 1); classicXMLParser(fromDir + fileWoExt + "xml", &mVcard); // IMContact imContact(*imAccountList.begin(), mVcard.id); //VOXOX - JRT - 2009.04.09 IMContact imContact(imAccountList.begin()->second, mVcard.id); //VOXOX - JRT - 2009.04.26 // Contact & contact = contactList.createContact(); // contact.setGroupId(contactList.getContactGroupIdFromName("Classic")); // addContactDetails(contact, &mVcard); // contact.addIMContact(imContact); Contact* contact = contactList.createContact(); // contact->setGroupId(contactList.getContactGroupIdFromName("Classic")); contact->addToGroup(contactList.getContactGroupIdFromName("Classic"), EnumGroupType::GroupType_User); //VOXOX - JRT - 2009.05.06 JRT-GRPS addContactDetails(*contact, &mVcard); contact->addIMContact(imContact); contactList.addContact( contact ); //ContactList will delete contact //End Voxox } } return true; }
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); } }
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; }
void CommandServer::incomingRequestEventHandler(ServerSocket & sender, const std::string & connectionId, const std::string & data) { LOG_DEBUG("incoming request connectionId=" + connectionId + " data=" + data); String query = String(data); if (query == QueryStatus) { //Find the phoneline status and answer UserProfile * userprofile = _wengoPhone.getUserProfileHandler().getCurrentUserProfile(); if (userprofile) { IPhoneLine * phoneLine = userprofile->getActivePhoneLine(); if (phoneLine && phoneLine->isConnected()) { _serverSocket->writeToClient(connectionId, QueryStatus + "|1"); } else { _serverSocket->writeToClient(connectionId, QueryStatus + "|0"); } } } else if (query == QueryBringToFront) { bringMainWindowToFrontEvent(); } else if (query.beginsWith(QueryCall)) { //Extract the number from query & place the call StringList l = query.split("/"); if (l.size() == 2) { LOG_DEBUG("call peer=" + l[1]); UserProfile * userprofile = _wengoPhone.getUserProfileHandler().getCurrentUserProfile(); if (userprofile) { IPhoneLine * phoneLine = userprofile->getActivePhoneLine(); if (phoneLine && phoneLine->isConnected()) { phoneLine->makeCall(l[1]); _serverSocket->writeToClient(connectionId, data + "|1"); return; } } } _serverSocket->writeToClient(connectionId, data + "|0"); } else if (query.beginsWith(QuerySms)) { LOG_WARN("not yet implemented"); } else if (query.contains(QueryChat)) { UserProfile * userProfile = _wengoPhone.getUserProfileHandler().getCurrentUserProfile(); if (userProfile) { IPhoneLine * phoneLine = userProfile->getActivePhoneLine(); if (phoneLine && phoneLine->isConnected()) { // extract the nickname from 1|o|chat/pseudo=value&sip=value StringList l = query.split("/"); std::string nickname; if (l.size() == 2) { int sepPos = l[1].find("&"); nickname = l[1].substr(7, sepPos - 7); } //// // get THE Wengo account IMAccountList imAccountList = userProfile->getIMAccountManager().getIMAccountsOfProtocol(EnumIMProtocol::IMProtocolWengo); //// // create the IMContactSet IMAccount *imAccount = userProfile->getIMAccountManager().getIMAccount( imAccountList.begin()->second ); //VOXOX - JRT - 2009.04.24 IMContact imContact(*imAccount, nickname); IMContactSet imContactSet; imContactSet.insert(imContact); //// // create the chat session std::string temp = ""; ChatHandler & chatHandler = userProfile->getChatHandler(); chatHandler.createSession(imAccount->getKey(), imContactSet, IMChat::Chat, temp ); //VOXOX - JRT - 2009.04.24 //// OWSAFE_DELETE(imAccount); } } // failed _serverSocket->writeToClient(connectionId, QueryChat + "|0"); } else if (query.beginsWith(QueryAddContact)) { UserProfile * userProfile = _wengoPhone.getUserProfileHandler().getCurrentUserProfile(); if (userProfile) { ContactInfo contactInfo; String tmp = query.substr(QueryAddContact.size(), query.size() - 1); StringList args = tmp.split("&"); for (unsigned i = 0; i < args.size(); i++) { String tmp = args[i]; if (!tmp.size()) { continue; } StringList list = tmp.split("="); if ((!(list.size() == 2)) || list[0].empty()) { continue; } // remove the first and the last quote if any String value = list[1]; if (list[0] == NICKNAME_STR) { contactInfo.wengoName = value; } else if (list[0] == SIP_STR) { contactInfo.sip = value; } else if (list[0] == FIRSTNAME_STR) { contactInfo.firstname = value; } else if (list[0] == LASTNAME_STR) { contactInfo.lastname = value; } else if (list[0] == COUNTRY_STR) { contactInfo.country = value; } else if (list[0] == CITY_STR) { contactInfo.city = value; } else if (list[0] == STATE_STR) { contactInfo.state = value; } else if (list[0] == GROUP_STR) { contactInfo.group = value; } else if (list[0] == WDEALSERVICETITLE_STR) { contactInfo.wdealServiceTitle = value; } else if (list[0] == URL_STR) { if (value.beginsWith("\"")) { value = value.substr(1, value.size() - 2); } contactInfo.website = value; } } showAddContactEvent(contactInfo); } } else { Config & config = ConfigManager::getInstance().getCurrentConfig(); //"emulate" a http server. Needed for Flash sockets std::string tmp = "<?xml version=\"1.0\"?>\n" "<!DOCTYPE cross-domain-policy SYSTEM \"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\">\n" "<cross-domain-policy>\n"; StringList domains = config.getCmdServerAuthorizedDomains(); StringList::const_iterator it = domains.begin(), end = domains.end(); for (;it!=end; ++it) { tmp += "<allow-access-from domain=\"" + *it + "\" to-ports=\"*\" />\n"; } tmp += "<allow-access-from domain=\"localhost\" to-ports=\"*\" />\n" "</cross-domain-policy>"; _serverSocket->writeToClient(connectionId, buildHttpForFlash(tmp)); } }