From c66e87b53828c64cb1cc5ef3e7557e2955e0ce5b Mon Sep 17 00:00:00 2001 From: mateus Date: Sat, 11 Jun 2016 18:06:21 -0300 Subject: [PATCH 1/2] problem pull request #43 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 49b00f8320..4d6318a6a0 100644 --- a/configure.ac +++ b/configure.ac @@ -14,7 +14,7 @@ AC_SUBST(LIBTOOL_VERSION_RELEASE) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) -AM_INIT_AUTOMAKE([foreign subdir-objects]) +AM_INIT_AUTOMAKE m4_pattern_forbid([^PKG_]) AC_CANONICAL_HOST From 03922ef718d16b739bc5806a25db5625cbd98130 Mon Sep 17 00:00:00 2001 From: mateus Date: Sat, 11 Jun 2016 18:32:52 -0300 Subject: [PATCH 2/2] buddy list and contact presence --- apps/telepathy/Connection.cxx | 563 +++++++++++++++++++++++++----- apps/telepathy/Connection.hxx | 119 ++++--- resip/dum/BaseCreator.cxx | 7 +- resip/stack/TransportSelector.cxx | 13 + resip/stack/Via.cxx | 2 +- 5 files changed, 566 insertions(+), 138 deletions(-) diff --git a/apps/telepathy/Connection.cxx b/apps/telepathy/Connection.cxx index 43b57f4d3f..aa0fdb4747 100644 --- a/apps/telepathy/Connection.cxx +++ b/apps/telepathy/Connection.cxx @@ -5,7 +5,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -22,7 +22,13 @@ #include #include - +#include "resip/stack/Pidf.hxx" +#include "resip/stack/GenericPidfContents.hxx" +#include "resip/dum/PublicationHandler.hxx" +#include "resip/dum/ClientPublication.hxx" +#include "resip/dum/ClientAuthManager.hxx" +#include "resip/dum/DialogUsageManager.hxx" +#include "rutil/Random.hxx" #include "MyConversationManager.hxx" @@ -30,17 +36,22 @@ #include "Common.hxx" #include "SipCallChannel.hxx" +#define CRLF "\r\n" + using namespace recon; using namespace resip; using namespace std; #define RESIPROCATE_SUBSYSTEM ReconSubsystem::RECON +static const QString c_fileWithContacts = QLatin1String("data.txt"); + tr::Connection::Connection(const QDBusConnection &dbusConnection, const QString &cmName, const QString &protocolName, const QVariantMap ¶meters) : Tp::BaseConnection(dbusConnection, cmName, protocolName, parameters), mUAProfile(new TelepathyMasterProfile(parameters)), mConversationProfile(new TelepathyConversationProfile(mUAProfile, parameters)), ua(0), + mProfile(new TelepathyMasterProfile(parameters)), nextHandleId(1) { std::vector _codecIds; @@ -77,13 +88,13 @@ tr::Connection::Connection(const QDBusConnection &dbusConnection, const QString mContactsInterface = Tp::BaseConnectionContactsInterface::create(); mContactsInterface->setGetContactAttributesCallback(Tp::memFun(this, &Connection::getContactAttributes)); mContactsInterface->setContactAttributeInterfaces(QStringList() - << TP_QT_IFACE_CONNECTION - << TP_QT_IFACE_CONNECTION_INTERFACE_CONTACT_LIST - << TP_QT_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE - //<< TP_QT_IFACE_CONNECTION_INTERFACE_ALIASING - << TP_QT_IFACE_CONNECTION_INTERFACE_REQUESTS - //<< TP_QT_IFACE_CONNECTION_INTERFACE_AVATARS - ); + << TP_QT_IFACE_CONNECTION + << TP_QT_IFACE_CONNECTION_INTERFACE_CONTACT_LIST + << TP_QT_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE + << TP_QT_IFACE_CONNECTION_INTERFACE_ALIASING + << TP_QT_IFACE_CONNECTION_INTERFACE_REQUESTS + //<< TP_QT_IFACE_CONNECTION_INTERFACE_AVATARS + ); plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(mContactsInterface)); /* Connection.Interface.SimplePresence */ @@ -92,19 +103,25 @@ tr::Connection::Connection(const QDBusConnection &dbusConnection, const QString mSimplePresenceInterface->setSetPresenceCallback(Tp::memFun(this, &Connection::setPresence)); plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(mSimplePresenceInterface)); - /* Connection.Interface.ContactList */ - mContactListInterface = Tp::BaseConnectionContactListInterface::create(); - mContactListInterface->setContactListPersists(true); - mContactListInterface->setCanChangeContactList(true); - mContactListInterface->setDownloadAtConnection(true); - //mContactListInterface->setGetContactListAttributesCallback(Tp::memFun(this, &Connection::getContactListAttributes)); - //mContactListInterface->setRequestSubscriptionCallback(Tp::memFun(this, &Connection::requestSubscription)); - //mContactListInterface->setAuthorizePublicationCallback(Tp::memFun(this, &Connection::authorizePublication)); - //mContactListInterface->setRemoveContactsCallback(Tp::memFun(this, &Connection::removeContacts)); - //mContactListInterface->setUnsubscribeCallback(Tp::memFun(this, &Connection::unsubscribe)); - //mContactListInterface->setUnpublishCallback(Tp::memFun(this, &Connection::unpublish)); - plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(mContactListInterface)); - + /* Connection.Interface.ContactList */ + mContactListInterface = Tp::BaseConnectionContactListInterface::create(); + mContactListInterface->setContactListPersists(true); + mContactListInterface->setCanChangeContactList(true); + mContactListInterface->setDownloadAtConnection(true); + mContactListInterface->setGetContactListAttributesCallback(Tp::memFun(this, &Connection::getContactListAttributes)); + mContactListInterface->setRequestSubscriptionCallback(Tp::memFun(this, &Connection::requestSubscription)); + // mContactListInterface->setAuthorizePublicationCallback(Tp::memFun(this, &Connection::authorizePublication)); + mContactListInterface->setRemoveContactsCallback(Tp::memFun(this, &Connection::removeContacts)); + //mContactListInterface->setUnsubscribeCallback(Tp::memFun(this, &Connection::unsubscribe)); + //mContactListInterface->setUnpublishCallback(Tp::memFun(this, &Connection::unpublish)); + plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(mContactListInterface)); + + /* Connection.Interface.Aliasing */ + mAliasingInterface = Tp::BaseConnectionAliasingInterface::create(); + mAliasingInterface->setGetAliasesCallback(Tp::memFun(this, &Connection::getAliases)); + mAliasingInterface->setSetAliasesCallback(Tp::memFun(this, &Connection::setAliases)); + plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(mAliasingInterface)); + /* Connection.Interface.Requests */ mRequestsInterface = Tp::BaseConnectionRequestsInterface::create(this); /* Fill requestableChannelClasses */ @@ -144,6 +161,192 @@ tr::Connection::Connection(const QDBusConnection &dbusConnection, const QString connect(this, SIGNAL(disconnected()), SLOT(doDisconnect())); } +void +tr::Connection::getContactsFromFile(Tp::DBusError *error) +{ + if (error->isValid()) + { + return; + } + + QFile file(c_fileWithContacts); + + if ( file.open(QFile::ReadOnly) ) + { + QTextStream in(&file); + QString line = in.readLine(); + Tp::AliasMap aliases; + while ( !line.isNull() ) + { + QString identifier = line.split(" ").at(0); + uint handle = ensureHandle(identifier); + aliases[handle] = line.split(" ").at(1); + + string strIdentifier = identifier.toUtf8().constData(); + string uri = "sip:" + strIdentifier; + ua->createSubscription(Data("presence"), NameAddr(uri.c_str()), 3600, Mime("application", "pidf+xml")); + + line = in.readLine(); + } + setAliases(aliases, error); + } + + else + { + file.open(QFile::WriteOnly); + } + + mContactListInterface->setContactListState(Tp::ContactListStateSuccess); +} + +void +tr::Connection::setContactsInFile() +{ + QFile file(c_fileWithContacts); + + if( file.open(QIODevice::ReadWrite | QIODevice::Truncate) ) + { + QTextStream stream(&file); + QMap::iterator it; + for ( it = mHandles.begin(); it != mHandles.end(); it++ ) + { + if ( it.key() != selfHandle() ) + { + stream << it.value() << " " << mAliases[it.key()] << endl; + } + } + file.close(); + } + + else + { + ErrLog(<<"couldn't write contacts to file" << endl); + } +} + +Tp::AliasMap +tr::Connection::getAliases(const Tp::UIntList& handles, Tp::DBusError *error) +{ + if ( error->isValid() ) + { + return Tp::AliasMap(); + } + + qDebug() << Q_FUNC_INFO << handles; + + Tp::AliasMap aliases; + Q_FOREACH ( uint handle, handles ) + { + if ( mAliases.find(handle) == mAliases.end() ) + { + error->set(TP_QT_ERROR_INVALID_HANDLE, QLatin1String("Invalid handle(s)")); + } + aliases[handle] = mAliases[handle]; + } + + return aliases; +} + +void +tr::Connection::setAliases(const Tp::AliasMap &aliases, Tp::DBusError *error) +{ + if ( error->isValid() ) + { + return; + } + + qDebug() << Q_FUNC_INFO << aliases; + + for ( Tp::AliasMap::const_iterator it = aliases.begin(); it != aliases.end(); it++ ) + { + mAliases[it.key()] = it.value(); + } + +} + +void +tr::Connection::deleteContacts(const QStringList& contacts) +{ + + Tp::ContactSubscriptionMap changes; + Tp::HandleIdentifierMap identifiers; + Tp::HandleIdentifierMap removals; + Q_FOREACH ( const QString &contact, contacts ) + { + uint id = mIdentifiers[contact]; + removals[id] = contact; + } + mContactListInterface->contactsChangedWithID(changes, identifiers, removals); + + setContactsInFile(); +} + +Tp::ContactAttributesMap +tr::Connection::getContactListAttributes(const QStringList &interfaces, bool hold, Tp::DBusError *error) +{ + Tp::UIntList handles = mHandles.keys(); + handles.removeOne(selfHandle()); + + StackLog(<<"getContactListAttributes()"); + qDebug() << handles; + + return getContactAttributes(handles, interfaces, error); +} + +void +tr::Connection::requestSubscription(const Tp::UIntList &handles, const QString &message, Tp::DBusError *error) +{ + + QStringList contacts = inspectHandles(Tp::HandleTypeContact, handles, error); + + if ( error->isValid() ) + { + return; + } + + if ( contacts.isEmpty() ) + { + error->set(TP_QT_ERROR_INVALID_HANDLE, QLatin1String("Invalid handle(s)")); + } + + Tp::ContactSubscriptionMap changes; + Tp::HandleIdentifierMap identifiers; + Tp::HandleIdentifierMap removals; + Q_FOREACH ( const QString &contact, contacts ) + { + uint handle = ensureHandle(contact); + + Tp::ContactSubscriptions change; + change.publish = Tp::SubscriptionStateYes; + change.publishRequest = QString(); + change.subscribe = Tp::SubscriptionStateUnknown; + + changes[handle] = change; + identifiers[handle] = contact; + } + mContactListInterface->contactsChangedWithID(changes, identifiers, removals); + + setContactsInFile(); +} + +void +tr::Connection::removeContacts(const Tp::UIntList &handles, Tp::DBusError *error) +{ + QStringList contacts = inspectHandles(Tp::HandleTypeContact, handles, error); + + if ( error->isValid() ) + { + return; + } + + if ( contacts.isEmpty() ) + { + error->set(TP_QT_ERROR_INVALID_HANDLE, QLatin1String("Invalid handle(s)")); + } + + deleteContacts(contacts); +} + void tr::Connection::doConnect(Tp::DBusError *error) { @@ -153,8 +356,11 @@ tr::Connection::doConnect(Tp::DBusError *error) ua->startup(); myConversationManager->startup(); ua->run(); + statusMap = tr::Common::getSimpleStatusSpecMap(); mContactListInterface->setContactListState(Tp::ContactListStateWaiting); + + getContactsFromFile(error); } void @@ -163,19 +369,173 @@ tr::Connection::onConnected() setStatus(Tp::ConnectionStatusConnected, Tp::ConnectionStatusReasonRequested); Tp::SimpleContactPresences presences; - mSelfPresence.type = Tp::ConnectionPresenceTypeAvailable; - mSelfPresence.status = QLatin1String("available"); + Tp::DBusError error; + setPresence(QLatin1String("available"), QLatin1String(""), &error); + presences[selfHandle()] = mSelfPresence; + // TODO: get presence from contacts mSimplePresenceInterface->setPresences(presences); } +class ClientPubHandler : public ClientPublicationHandler { +public: + ClientPubHandler() {} + virtual void onSuccess(ClientPublicationHandle cph, const SipMessage& status) + { + handle = cph; + InfoLog(<<"ClientPubHandler::onSuccess\n"); + } + virtual void onRemove(ClientPublicationHandle cph, const SipMessage& status) + { + InfoLog(<<"ClientPubHandler::onRemove\n"); + handle = ClientPublicationHandle(); + } + virtual int onRequestRetry(ClientPublicationHandle cph, int retrySeconds, const SipMessage& status) + { + handle = cph; + InfoLog(<<"ClientPubHandler::onRequestRetry\n"); + return 30; + } + virtual void onFailure(ClientPublicationHandle cph, const SipMessage& status) + { + InfoLog(<<"ClientPubHandler::onFailure\n"); + handle = ClientPublicationHandle(); + } + ClientPublicationHandle handle; +}; + + +void +tr::Connection::sendPresence(const QString &status) +{ + + // bool first = true; + // string aor(argv[1]); + // string user(argv[2]); + // string passwd(argv[3]); + // string realm(argv[4]); + int port = 5060; + + Data eventName("presence"); + + // sip logic + // SharedPtr profile(new MasterProfile); + auto_ptr clientAuth(new ClientAuthManager()); + + SipStack clientStack; + DialogUsageManager clientDum(clientStack); + clientDum.addTransport(UDP, port); + clientDum.setMasterProfile(mProfile); + + clientDum.setClientAuthManager(clientAuth); + clientDum.getMasterProfile()->addSupportedMethod(PUBLISH); + clientDum.getMasterProfile()->addSupportedMimeType(PUBLISH,Pidf::getStaticType()); + + ClientPubHandler cph; + clientDum.addClientPublicationHandler(eventName,&cph); + + ///// + // NameAddr naAor(aor.c_str()); + string aor = mHandles[selfHandle()].toUtf8().constData(); + aor = "sip:" + aor; + NameAddr naAor(aor.c_str()); + // profile->setDefaultFrom(naAor); + // profile->setDigestCredential(realm.c_str(), user.c_str(), passwd.c_str()); + + Pidf pidf; + // pidf.setSimpleStatus(true); + // pidf.setEntity(naAor.uri()); + // pidf.setSimpleId(Random::getRandomHex(3)); + + Pidf::Tuple tuple; + tuple.status = true; + // tuple.id = "test id"; + tuple.id = Random::getRandomHex(3); + tuple.contact = Data::from(aor); + tuple.contactPriority = (int)0; + // tuple.note = "Away"; + tuple.note = status.toUtf8().constData(); + tuple.attributes["displayname"] = "displayName"; + tuple.attributes["status"] = "1"; + pidf.getTuples().push_back(tuple); + InfoLog( << "Generated tuple: " << endl << tuple ); + + + // Data txt( + // "" CRLF + // "" CRLF + // " " CRLF + // " " CRLF + // " " CRLF + // " " CRLF + // " " CRLF + // " open" CRLF + // " " CRLF + // " sip:mateus1@ws.sip5060.net" CRLF + // " Online" CRLF + // " " CRLF + // "" CRLF + // ); + // HeaderFieldValue hfv(txt.data(), txt.size()); + // GenericPidfContents pidf(hfv, GenericPidfContents::getStaticType()); + + { + SharedPtr pubMessage = clientDum.makePublication(naAor, mProfile, pidf, eventName, 120); + InfoLog( << "Generated publish: " << endl << *pubMessage ); + clientDum.send( pubMessage ); + } + +} + uint tr::Connection::setPresence(const QString &status, const QString &message, Tp::DBusError *error) { - //FIXME + // TODO: find out why message is always getting here empty + + StackLog(<<"setPresence()"); + + mSelfPresence.type = statusMap[status].type; + mSelfPresence.status = status; + if ( statusMap[status].canHaveMessage ) + { + mSelfPresence.statusMessage = message; + } + + qDebug() << "status = " << mSelfPresence.status << " type = " << mSelfPresence.type << " message = " << message; + sendPresence(status); + return selfHandle(); } +Tp::SimpleContactPresences +tr::Connection::getPresences(const Tp::UIntList &handles) +{ + StackLog(<<"getPresences()"); + + Tp::SimpleContactPresences presences; + Q_FOREACH ( uint handle, handles ) + { + presences[handle] = getPresence(handle); + } + + return presences; +} + +Tp::SimplePresence +tr::Connection::getPresence(uint handle) +{ + StackLog(<<"getPresence()"); + if ( !mPresences.contains(handle) ) + { + return Tp::SimplePresence(); + } + qDebug() << "presence = " << mPresences.value(handle).status; + + return mPresences.value(handle); +} void tr::Connection::doDisconnect() @@ -195,7 +555,8 @@ tr::Connection::setStatusSlot(uint newStatus, uint reason) uint tr::Connection::ensureHandle(const QString& identifier) { - if(!mIdentifiers.contains(identifier)) { + if ( !mIdentifiers.contains(identifier) ) + { long id = nextHandleId++; mHandles[id] = identifier; mIdentifiers[identifier] = id; @@ -223,9 +584,10 @@ tr::Connection::onIncomingCall(const QString & caller, uint callHandle) Tp::DBusError error; Tp::BaseChannelPtr channel = ensureChannel(request, yours, false, &error); - if (error.isValid() || channel.isNull()) { - qWarning() << "error creating the channel " << error.name() << error.message(); - return; + if ( error.isValid() || channel.isNull() ) + { + qWarning() << "error creating the channel " << error.name() << error.message(); + return; } } @@ -234,16 +596,19 @@ tr::Connection::inspectHandles(uint handleType, const Tp::UIntList &handles, Tp: { StackLog(<<"inspectHandles()"); - if(handleType != Tp::HandleTypeContact) { + if ( handleType != Tp::HandleTypeContact ) + { error->set(TP_QT_ERROR_INVALID_ARGUMENT, QLatin1String("Unsupported handle type")); return QStringList(); } QStringList result; - foreach (uint handle, handles) { - if(!mHandles.contains(handle)) { - return QStringList(); + Q_FOREACH ( uint handle, handles ) + { + if ( !mHandles.contains(handle) ) + { + return QStringList(); } result.append(mHandles.value(handle)); @@ -257,15 +622,16 @@ tr::Connection::requestHandles(uint handleType, const QStringList &identifiers, DebugLog(<<"requestHandles() "); Tp::UIntList result; - if(handleType != Tp::HandleTypeContact) { + if ( handleType != Tp::HandleTypeContact ) + { ErrLog(<<"requestHandles() unsupported handleType == " << handleType); error->set(TP_QT_ERROR_INVALID_ARGUMENT, QLatin1String("Connection::requestHandles - Handle Type unknown")); return result; } - Q_FOREACH(const QString &identifier, identifiers) { - ensureHandle(identifier); - result.append(mIdentifiers[identifier]); + Q_FOREACH ( const QString &identifier, identifiers ) + { + result.append(ensureHandle(identifier)); } return result; @@ -281,27 +647,40 @@ tr::Connection::createChannel(const QVariantMap &request, Tp::DBusError *error) uint targetHandle = 0; QString targetID; - switch (targetHandleType) { - case Tp::HandleTypeContact: - if (request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle"))) { - targetHandle = request.value(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle")).toUInt(); - targetID = mHandles[targetHandle]; - } else if (request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID"))) { - targetID = request.value(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID")).toString(); - targetHandle = ensureHandle(targetID); + switch ( targetHandleType ) + { + case Tp::HandleTypeContact: + { + if ( request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle")) ) + { + targetHandle = request.value(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle")).toUInt(); + targetID = mHandles[targetHandle]; + } + + else if ( request.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID")) ) + { + targetID = request.value(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID")).toString(); + targetHandle = ensureHandle(targetID); + } + break; } - break; - default: - if (error) { - error->set(TP_QT_ERROR_INVALID_ARGUMENT, QLatin1String("Unknown target handle type")); + + default: + { + if ( error ) + { + error->set(TP_QT_ERROR_INVALID_ARGUMENT, QLatin1String("Unknown target handle type")); + } + return Tp::BaseChannelPtr(); + break; } - return Tp::BaseChannelPtr(); - break; } - if (targetID.isEmpty()) { - if (error) { - error->set(TP_QT_ERROR_INVALID_HANDLE, QLatin1String("Target handle is empty.")); + if ( targetID.isEmpty() ) + { + if ( error ) + { + error->set(TP_QT_ERROR_INVALID_HANDLE, QLatin1String("Target handle is empty.")); } return Tp::BaseChannelPtr(); } @@ -309,30 +688,32 @@ tr::Connection::createChannel(const QVariantMap &request, Tp::DBusError *error) uint initiatorHandle = request.value(TP_QT_IFACE_CHANNEL + QLatin1String(".InitiatorHandle")).toUInt(); /*Tp::BaseChannelPtr baseChannel = Tp::BaseChannel::create(this, channelType, Tp::HandleType(targetHandleType), targetHandle); - baseChannel->setTargetID(targetID); - baseChannel->setInitiatorHandle(initiatorHandle); */ + baseChannel->setTargetID(targetID); + baseChannel->setInitiatorHandle(initiatorHandle); */ ParticipantHandle participantHandle = -1; bool incoming = false; StackLog(<<"createChannel - channelType = " << channelType.toUtf8().constData() << " and contact = " << targetID.toUtf8().constData()); - if(channelType == TP_QT_IFACE_CHANNEL_TYPE_CALL) { + if ( channelType == TP_QT_IFACE_CHANNEL_TYPE_CALL ) + { recon::ConversationHandle cHandle = 1; // FIXME - hardcoded default value, should create new Conversation //recon::ConversationHandle cHandle = myConversationManager->createConversation(); //myConversationManager->createLocalParticipant(); - if(!request.contains("participantHandle")) + if ( !request.contains("participantHandle") ) { - // Outgoing call - DebugLog(<<"outoing call"); - NameAddr callee(targetID.toUtf8().constData()); - participantHandle = myConversationManager->createRemoteParticipant(cHandle, callee); - myConversationManager->addParticipant(cHandle, participantHandle); + // Outgoing call + DebugLog(<<"outoing call"); + NameAddr callee(targetID.toUtf8().constData()); + participantHandle = myConversationManager->createRemoteParticipant(cHandle, callee); + myConversationManager->addParticipant(cHandle, participantHandle); } + else { - // Incoming call - DebugLog(<<"incoming call"); - incoming = true; - participantHandle = (ParticipantHandle)request["participantHandle"].toUInt(); + // Incoming call + DebugLog(<<"incoming call"); + incoming = true; + participantHandle = (ParticipantHandle)request["participantHandle"].toUInt(); } } @@ -346,23 +727,35 @@ tr::Connection::createChannel(const QVariantMap &request, Tp::DBusError *error) Tp::ContactAttributesMap tr::Connection::getContactAttributes(const Tp::UIntList &handles, const QStringList &ifaces, Tp::DBusError *error) { - StackLog(<<"getContactAttributes"); - qDebug() << "getContactAttributes" << handles << ifaces; - Tp::ContactAttributesMap attributesMap; - Q_FOREACH(uint handle, handles) { - QVariantMap attributes; - QStringList inspectedHandles = inspectHandles(Tp::HandleTypeContact, Tp::UIntList() << handle, error); - if (inspectedHandles.size() > 0) { - attributes[TP_QT_IFACE_CONNECTION+"/contact-id"] = inspectedHandles.at(0); - } else { - continue; - } - if (ifaces.contains(TP_QT_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE)) { - attributes[TP_QT_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE+"/presence"] = QVariant::fromValue(mSelfPresence); - } - attributesMap[handle] = attributes; - } - return attributesMap; -} + StackLog(<<"getContactAttributes"); + Tp::ContactAttributesMap attributesMap; + Q_FOREACH ( uint handle, handles ) + { + QVariantMap attributes; + QStringList inspectedHandle = inspectHandles(Tp::HandleTypeContact, Tp::UIntList() << handle, error); + if ( inspectedHandle.size() > 0 ) + { + attributes[TP_QT_IFACE_CONNECTION+"/contact-id"] = inspectedHandle.at(0); + } + + else + { + continue; + } + qDebug() << "handle = " << handle << " inspectedHandle = " << inspectedHandle; + if ( ifaces.contains(TP_QT_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE) ) + { + attributes[TP_QT_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE+"/presence"] = QVariant::fromValue(getPresence(handle)); + } + + if ( ifaces.contains(TP_QT_IFACE_CONNECTION_INTERFACE_ALIASING) ) + { + attributes[TP_QT_IFACE_CONNECTION_INTERFACE_ALIASING + QLatin1String("/alias")] = QVariant::fromValue(mAliases[handle]); + } + + attributesMap[handle] = attributes; + } + return attributesMap; +} diff --git a/apps/telepathy/Connection.hxx b/apps/telepathy/Connection.hxx index 9de94ad197..d3c0e3a56e 100644 --- a/apps/telepathy/Connection.hxx +++ b/apps/telepathy/Connection.hxx @@ -19,7 +19,7 @@ #define CONNECTION_HXX #if defined(HAVE_CONFIG_H) - #include "config.h" +#include "config.h" #endif @@ -28,6 +28,7 @@ #include #include + #include #include @@ -39,57 +40,73 @@ namespace tr { -class MyConversationManager; -class MyUserAgent; - -class Connection : public Tp::BaseConnection -{ - Q_OBJECT -public: - Connection(const QDBusConnection &dbusConnection, - const QString &cmName, const QString &protocolName, - const QVariantMap ¶meters); - - MyConversationManager& getConversationManager() { return *myConversationManager.get(); }; - -private: - uint setPresence(const QString &status, const QString &message, Tp::DBusError *error); - QStringList inspectHandles(uint handleType, const Tp::UIntList &handles, Tp::DBusError *error); - Tp::UIntList requestHandles(uint handleType, const QStringList &identifiers, Tp::DBusError *error); - Tp::BaseChannelPtr createChannel(const QVariantMap &request, Tp::DBusError *error); - Tp::ContactAttributesMap getContactAttributes(const Tp::UIntList &handles, const QStringList &ifaces, Tp::DBusError *error); - uint ensureHandle(const QString& identifier); - - -private slots: - void doConnect(Tp::DBusError *error); - void onConnected(); - void doDisconnect(); - void setStatusSlot(uint newStatus, uint reason); - void onIncomingCall(const QString & caller, uint callHandle); - - -private: - resip::SharedPtr mUAProfile; - resip::SharedPtr mConversationProfile; - tr::MyUserAgent* ua; - std::auto_ptr myConversationManager; - - Tp::BaseConnectionContactsInterfacePtr mContactsInterface; - Tp::BaseConnectionSimplePresenceInterfacePtr mSimplePresenceInterface; - Tp::BaseConnectionContactListInterfacePtr mContactListInterface; - Tp::BaseConnectionRequestsInterfacePtr mRequestsInterface; - - long nextHandleId; - QMap mHandles; - QMap mIdentifiers; - - Tp::SimplePresence mSelfPresence; -}; + class MyConversationManager; + class MyUserAgent; + + class Connection : public Tp::BaseConnection + { + Q_OBJECT + public: + Connection(const QDBusConnection &dbusConnection, + const QString &cmName, const QString &protocolName, + const QVariantMap ¶meters); + + MyConversationManager& getConversationManager() { return *myConversationManager.get(); }; + + Tp::ContactAttributesMap getContactListAttributes(const QStringList &interfaces, bool hold, Tp::DBusError *error); + + void requestSubscription(const Tp::UIntList &handles, const QString &message, Tp::DBusError *error); + void removeContacts(const Tp::UIntList &handles, Tp::DBusError *error); + Tp::AliasMap getAliases(const Tp::UIntList& handles, Tp::DBusError *error); + void setAliases(const Tp::AliasMap &aliases, Tp::DBusError *error); + void getContactsFromFile(Tp::DBusError *error); + void setContactsInFile(); + void deleteContacts(const QStringList& contacts); + Tp::SimpleStatusSpecMap getSimpleStatusSpecMap(); + Tp::SimpleContactPresences getPresences(const Tp::UIntList &handles); + Tp::SimplePresence getPresence(uint handle); + + private: + uint setPresence(const QString &status, const QString &message, Tp::DBusError *error); + QStringList inspectHandles(uint handleType, const Tp::UIntList &handles, Tp::DBusError *error); + Tp::UIntList requestHandles(uint handleType, const QStringList &identifiers, Tp::DBusError *error); + Tp::BaseChannelPtr createChannel(const QVariantMap &request, Tp::DBusError *error); + Tp::ContactAttributesMap getContactAttributes(const Tp::UIntList &handles, const QStringList &ifaces, Tp::DBusError *error); + uint ensureHandle(const QString& identifier); + void sendPresence(const QString& status); + + + private slots: + void doConnect(Tp::DBusError *error); + void onConnected(); + void doDisconnect(); + void setStatusSlot(uint newStatus, uint reason); + void onIncomingCall(const QString & caller, uint callHandle); + + + private: + resip::SharedPtr mUAProfile; + resip::SharedPtr mConversationProfile; + tr::MyUserAgent* ua; + std::auto_ptr myConversationManager; + resip::SharedPtr mProfile; + + Tp::BaseConnectionContactsInterfacePtr mContactsInterface; + Tp::BaseConnectionAliasingInterfacePtr mAliasingInterface; + Tp::BaseConnectionSimplePresenceInterfacePtr mSimplePresenceInterface; + Tp::BaseConnectionContactListInterfacePtr mContactListInterface; + Tp::BaseConnectionRequestsInterfacePtr mRequestsInterface; + + long nextHandleId; + QMap mHandles; + QMap mIdentifiers; + Tp::AliasMap mAliases; + + Tp::SimpleStatusSpecMap statusMap; + Tp::SimplePresence mSelfPresence; + Tp::SimpleContactPresences mPresences; + }; } #endif - - - diff --git a/resip/dum/BaseCreator.cxx b/resip/dum/BaseCreator.cxx index 4a38d0d50b..453f60c230 100644 --- a/resip/dum/BaseCreator.cxx +++ b/resip/dum/BaseCreator.cxx @@ -133,6 +133,11 @@ BaseCreator::makeInitialRequest(const NameAddr& target, const NameAddr& from, Me // Add ;ob parm to non-register requests - RFC5626 pg17 mLastRequest->header(h_Contacts).front().uri().param(p_ob); } + + if(method == SUBSCRIBE) + { + mLastRequest->header(h_Accepts).push_back( Mime( "application","pidf+xml") ); + } Via via; mLastRequest->header(h_Vias).push_front(via); @@ -145,7 +150,7 @@ BaseCreator::makeInitialRequest(const NameAddr& target, const NameAddr& from, Me //DumHelper::setOutgoingEncryptionLevel(mLastRequest, mEncryptionLevel); - DebugLog ( << "BaseCreator::makeInitialRequest: " << std::endl << std::endl << mLastRequest); + DebugLog ( << "BaseCreator::makeInitialRequest: " << std::endl << std::endl << *mLastRequest); } diff --git a/resip/stack/TransportSelector.cxx b/resip/stack/TransportSelector.cxx index 6bae0490bf..9d99469bdc 100644 --- a/resip/stack/TransportSelector.cxx +++ b/resip/stack/TransportSelector.cxx @@ -62,6 +62,8 @@ #include +#include "resip/stack/UnknownParameterType.hxx" + using namespace resip; #define RESIPROCATE_SUBSYSTEM Subsystem::TRANSPORT @@ -1141,11 +1143,20 @@ TransportSelector::transmit(SipMessage* msg, Tuple& target, SendData* sendData) Tuple::inet_ntop(source) ); contact.uri().port() = transport->port(); + DebugLog ( << "TransportSelector::transmit() " << std::endl << std::endl << " transport = " << *transport << std::endl); + if (transport->transport() != UDP && !contact.uri().exists(p_gr)) { contact.uri().param(p_transport) = Tuple::toDataLower(transport->transport()); + DebugLog ( << "TransportSelector::transmit() " << std::endl << std::endl << " p_transport = " << contact.uri().param(p_transport) << std::endl); } + contact.uri().param(UnknownParameterType("registering_acc")) = Data("ws_sip5060_net"); + + DebugLog ( << "TransportSelector::transmit() " << std::endl << std::endl << " contact uri = " << contact.uri() << std::endl); + DebugLog ( << "TransportSelector::transmit() " << std::endl << std::endl << " target = " << target << std::endl); + + // Add comp=sigcomp to contact URI // Also, If no +sip.instance on contact HEADER, // add sigcomp-id="" to contact URI. @@ -1170,9 +1181,11 @@ TransportSelector::transmit(SipMessage* msg, Tuple& target, SendData* sendData) { contact.uri().param(p_transport) = Tuple::toDataLower(target.getType()); } + DebugLog ( << "TransportSelector::transmit() " << std::endl << std::endl << "inside else p_transport = " << contact.uri().param(p_transport) << std::endl); contact.uri().remove(p_addTransport); } } + DebugLog ( << "TransportSelector::transmit() " << std::endl << std::endl << contact << std::endl); } } diff --git a/resip/stack/Via.cxx b/resip/stack/Via.cxx index 00c09fbde1..e854ff925a 100644 --- a/resip/stack/Via.cxx +++ b/resip/stack/Via.cxx @@ -27,7 +27,7 @@ Via::Via() { // insert a branch in all Vias (default constructor) this->param(p_branch); - this->param(p_rport); // add the rport parameter by default as per rfc 3581 + // this->param(p_rport); // add the rport parameter by default as per rfc 3581 } Via::Via(const HeaderFieldValue& hfv,