void TranslatorGUIClient::slotTranslateChat() { if ( !m_manager->view() ) return; Kopete::Message msg = m_manager->view()->currentMessage(); QString body = msg.plainBody(); if ( body.isEmpty() ) return; QString src_lang = TranslatorPlugin::plugin()->m_myLang; QString dst_lang; QList<Kopete::Contact*> list = m_manager->members(); Kopete::MetaContact *to = list.first()->metaContact(); dst_lang = to->pluginData( TranslatorPlugin::plugin(), "languageKey" ); if ( dst_lang.isEmpty() || dst_lang == "null" ) { kDebug( 14308 ) << "Cannot determine dst Metacontact language (" << to->displayName() << ")"; return; } // We search for src_dst TranslatorPlugin::plugin()->translateMessage( body, src_lang, dst_lang, this, SLOT(messageTranslated(QVariant)) ); }
QStringList KopeteIface::metacontactsForContactId( const QString & contactId ) { Kopete::MetaContact * mc = Kopete::ContactList::self()->findMetaContactByContactId( contactId ); if ( mc ) return QStringList( mc->displayName() ); else return QStringList(); }
WPAccount::WPAccount(WPProtocol *parent, const QString &accountID, const char *name) : Kopete::Account(parent, accountID, name) { // kdDebug(14170) << "WPAccount::WPAccount()" << endl; mProtocol = WPProtocol::protocol(); // we need this before initActions Kopete::MetaContact *myself = Kopete::ContactList::self()->myself(); setMyself( new WPContact(this, accountID, myself->displayName(), myself) ); // if (excludeConnect()) connect(Kopete::OnlineStatus::Online); // ?? }
void XmlContactStorage_Test::testLoad() { // TODO: Check plugin data. // TODO: Check more things. QString xmlFilename = QString( SRCDIR ) + QString("xmlcontactstorage_test_list.xml"); Kopete::ContactListStorage *storage = new Kopete::XmlContactStorage( xmlFilename ); storage->load(); // Verify that the loading went well. QVERIFY( storage->isValid() ); // Check that we have the correct numbers of groups and contacts. QCOMPARE( storage->groups().size(), 5 ); QCOMPARE( storage->contacts().size(), 6 ); // Verify that we parsed the correct group names. QStringList groupNameList = expectedGroupList(); QStringList::ConstIterator expectedIt, expectedItEnd = groupNameList.constEnd(); uint groupId = 1; Kopete::Group::List loadGroupList = storage->groups(); Kopete::Group::List::ConstIterator it, itEnd = loadGroupList.constEnd(); for(it = loadGroupList.constBegin(), expectedIt = groupNameList.constBegin(); it != itEnd, expectedIt != expectedItEnd; ++it, ++expectedIt) { Kopete::Group *group = (*it); QString groupName = group->displayName(); QString expectedGroupName = (*expectedIt); QCOMPARE( groupName, expectedGroupName ); QCOMPARE( group->groupId(), groupId++ ); } // Verify that we parsed the correct contacts. QStringList contactList = expectedContactList(); QStringList::ConstIterator contactIt, contactItEnd = contactList.constEnd(); Kopete::MetaContact::List loadContactList = storage->contacts(); Kopete::MetaContact::List::ConstIterator loadContactIt, loadContactItEnd = loadContactList.constEnd(); for(loadContactIt = loadContactList.constBegin(), contactIt = contactList.constBegin(); loadContactIt != loadContactItEnd, contactIt != contactItEnd; ++loadContactIt, ++contactIt) { Kopete::MetaContact *contact = (*loadContactIt); QString expectedContactName = (*contactIt); QCOMPARE( contact->displayName(), expectedContactName ); QCOMPARE( (int)contact->displayNameSource(), (int)Kopete::MetaContact::SourceCustom ); } }
void MeanwhileSession::syncContactsToServer() { HERE; struct mwSametimeList *list = mwSametimeList_new(); /* set up a fallback group for top-level contacts */ struct mwSametimeGroup *topstgroup = mwSametimeGroup_new(list, mwSametimeGroup_DYNAMIC, "People"); mwSametimeGroup_setOpen(topstgroup, true); const QHash<QString, Kopete::Contact *> contacts = account->contacts(); // Q3DictIterator<Kopete::Contact> it(account->contacts()); for(QHash<QString, Kopete::Contact *>::const_iterator it = contacts.constBegin(); it != contacts.constEnd(); ++it ) { MeanwhileContact *contact = static_cast<MeanwhileContact *>(it.value()); /* Find the group that the metacontact is in */ Kopete::MetaContact *mc = contact->metaContact(); if (!mc) continue; Kopete::Group *contactgroup = mc->groups().value(0); if (!contactgroup) continue; if (contactgroup->type() == Kopete::Group::Temporary) continue; struct mwSametimeGroup *stgroup; if (contactgroup->type() == Kopete::Group::TopLevel) { stgroup = topstgroup; } else { /* find (or create) a matching sametime list group */ stgroup = mwSametimeList_findGroup(list, contactgroup->displayName().toUtf8().constData()); if (!stgroup) { stgroup = mwSametimeGroup_new(list, mwSametimeGroup_DYNAMIC, contactgroup->displayName().toUtf8().constData()); } mwSametimeGroup_setOpen(stgroup, contactgroup->isExpanded()); mwSametimeGroup_setAlias(stgroup, contactgroup->pluginData(account->protocol(), "alias").toUtf8().constData()); } QByteArray tmpMeanwhileId = contact->meanwhileId().toUtf8(); /* now add the user (by IDBlock) */ struct mwIdBlock id = { (gchar*)tmpMeanwhileId.constData(), 0 }; struct mwSametimeUser *stuser = mwSametimeUser_new(stgroup, mwSametimeUser_NORMAL, &id); mwSametimeUser_setAlias(stuser, mc->displayName().toUtf8().constData()); } /* store! */ struct mwPutBuffer *buf = mwPutBuffer_new(); struct mwStorageUnit *unit = mwStorageUnit_new(mwStore_AWARE_LIST); struct mwOpaque *opaque = mwStorageUnit_asOpaque(unit); mwSametimeList_put(buf, list); mwPutBuffer_finalize(opaque, buf); mwServiceStorage_save(storageService, unit, NULL, NULL, NULL); mwSametimeList_free(list); }