Changeset View
Changeset View
Standalone View
Standalone View
connection.cpp
Show All 24 Lines | |||||
25 | #include <QDebug> | 25 | #include <QDebug> | ||
26 | 26 | | |||
27 | Tp::SimpleStatusSpecMap ConnectConnection::getSimpleStatusSpecMap() | 27 | Tp::SimpleStatusSpecMap ConnectConnection::getSimpleStatusSpecMap() | ||
28 | { | 28 | { | ||
29 | //Presence | 29 | //Presence | ||
30 | Tp::SimpleStatusSpec spAvailable; | 30 | Tp::SimpleStatusSpec spAvailable; | ||
31 | spAvailable.type = Tp::ConnectionPresenceTypeAvailable; | 31 | spAvailable.type = Tp::ConnectionPresenceTypeAvailable; | ||
32 | spAvailable.maySetOnSelf = false; | 32 | spAvailable.maySetOnSelf = false; | ||
33 | spAvailable.canHaveMessage = true; | 33 | spAvailable.canHaveMessage = false; | ||
34 | 34 | | |||
35 | Tp::SimpleStatusSpec spOffline; | 35 | Tp::SimpleStatusSpec spOffline; | ||
36 | spOffline.type = Tp::ConnectionPresenceTypeOffline; | 36 | spOffline.type = Tp::ConnectionPresenceTypeOffline; | ||
37 | spOffline.maySetOnSelf = false; | 37 | spOffline.maySetOnSelf = false; | ||
38 | spOffline.canHaveMessage = false; | 38 | spOffline.canHaveMessage = false; | ||
39 | 39 | | |||
40 | Tp::SimpleStatusSpecMap specs; | 40 | Tp::SimpleStatusSpecMap specs; | ||
41 | specs.insert(QLatin1String("available"), spAvailable); | 41 | specs.insert(QLatin1String("available"), spAvailable); | ||
Show All 16 Lines | 48 | { | |||
58 | /* Connection.Interface.SimplePresence */ | 58 | /* Connection.Interface.SimplePresence */ | ||
59 | simplePresenceIface = Tp::BaseConnectionSimplePresenceInterface::create(); | 59 | simplePresenceIface = Tp::BaseConnectionSimplePresenceInterface::create(); | ||
60 | simplePresenceIface->setSetPresenceCallback(Tp::memFun(this,&ConnectConnection::setPresence)); | 60 | simplePresenceIface->setSetPresenceCallback(Tp::memFun(this,&ConnectConnection::setPresence)); | ||
61 | plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(simplePresenceIface)); | 61 | plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(simplePresenceIface)); | ||
62 | 62 | | |||
63 | /* Connection.Interface.ContactList */ | 63 | /* Connection.Interface.ContactList */ | ||
64 | contactListIface = Tp::BaseConnectionContactListInterface::create(); | 64 | contactListIface = Tp::BaseConnectionContactListInterface::create(); | ||
65 | contactListIface->setGetContactListAttributesCallback(Tp::memFun(this, &ConnectConnection::getContactListAttributes)); | 65 | contactListIface->setGetContactListAttributesCallback(Tp::memFun(this, &ConnectConnection::getContactListAttributes)); | ||
66 | // contactListIface->setRequestSubscriptionCallback(Tp::memFun(this, &ConnectConnection::requestSubscription)); | 66 | contactListIface->setContactListPersists(true); | ||
67 | contactListIface->setCanChangeContactList(false); // There is currently no pushing of contacts back to the phone | ||||
68 | contactListIface->setRequestUsesMessage(false); | ||||
69 | contactListIface->setRequestSubscriptionCallback(Tp::memFun(this, &ConnectConnection::requestSubscription)); | ||||
67 | plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(contactListIface)); | 70 | plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(contactListIface)); | ||
68 | 71 | | |||
69 | /* Connection.Interface.Requests */ | 72 | /* Connection.Interface.Requests */ | ||
70 | requestsIface = Tp::BaseConnectionRequestsInterface::create(this); | 73 | requestsIface = Tp::BaseConnectionRequestsInterface::create(this); | ||
71 | /* Fill requestableChannelClasses */ | 74 | /* Fill requestableChannelClasses */ | ||
72 | Tp::RequestableChannelClass text; | 75 | Tp::RequestableChannelClass text; | ||
73 | text.fixedProperties[TP_QT_IFACE_CHANNEL+".ChannelType"] = TP_QT_IFACE_CHANNEL_TYPE_TEXT; | 76 | text.fixedProperties[TP_QT_IFACE_CHANNEL+".ChannelType"] = TP_QT_IFACE_CHANNEL_TYPE_TEXT; | ||
74 | text.fixedProperties[TP_QT_IFACE_CHANNEL+".TargetHandleType"] = Tp::HandleTypeContact; | 77 | text.fixedProperties[TP_QT_IFACE_CHANNEL+".TargetHandleType"] = Tp::HandleTypeContact; | ||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Line(s) | 218 | // http://telepathy.freedesktop.org/spec/Connection_Interface_Contacts.html#Method:GetContactAttributes | |||
216 | 219 | | |||
217 | Tp::ContactAttributesMap contactAttributes; | 220 | Tp::ContactAttributesMap contactAttributes; | ||
218 | 221 | | |||
219 | Q_FOREACH (const uint handle, handles) { | 222 | Q_FOREACH (const uint handle, handles) { | ||
220 | if (m_handles.contains(handle)){ | 223 | if (m_handles.contains(handle)){ | ||
221 | QVariantMap attributes; | 224 | QVariantMap attributes; | ||
222 | attributes["org.freedesktop.Telepathy.Connection/contact-id"] = m_handles.value(handle); | 225 | attributes["org.freedesktop.Telepathy.Connection/contact-id"] = m_handles.value(handle); | ||
223 | 226 | | |||
224 | if (handle != selfHandle() && interfaces.contains("org.freedesktop.Telepathy.Connection.Interface.ContactList")) { | 227 | if (handle == selfHandle()) | ||
225 | attributes["org.freedesktop.Telepathy.Connection.Interface.ContactList/subscribe"] = Tp::SubscriptionStateYes; | 228 | { | ||
226 | attributes["org.freedesktop.Telepathy.Connection.Interface.ContactList/publish"] = Tp::SubscriptionStateYes; | 229 | contactAttributes[handle] = attributes; | ||
227 | attributes["org.freedesktop.Telepathy.Connection.Interface.SimplePresence/presence"] = QVariant::fromValue(getPresence(handle)); | 230 | continue; | ||
228 | } | 231 | } | ||
232 | | ||||
233 | if (interfaces.contains(TP_QT_IFACE_CONNECTION_INTERFACE_CONTACT_LIST)) | ||||
234 | { | ||||
235 | attributes[TP_QT_IFACE_CONNECTION_INTERFACE_CONTACT_LIST + QLatin1String("/subscribe")] = Tp::SubscriptionStateYes; | ||||
236 | attributes[TP_QT_IFACE_CONNECTION_INTERFACE_CONTACT_LIST + QLatin1String("/publish")] = Tp::SubscriptionStateYes; | ||||
237 | } | ||||
238 | | ||||
239 | if (interfaces.contains(TP_QT_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE)) | ||||
240 | { | ||||
241 | attributes[TP_QT_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE + QLatin1String("/presence")] = QVariant::fromValue(getPresence(handle)); | ||||
242 | } | ||||
243 | | ||||
229 | contactAttributes[handle] = attributes; | 244 | contactAttributes[handle] = attributes; | ||
230 | } | 245 | } | ||
231 | } | 246 | } | ||
232 | return contactAttributes; | 247 | return contactAttributes; | ||
233 | } | 248 | } | ||
234 | 249 | | |||
235 | /** | 250 | /** | ||
251 | * Since CanChangeContactList is set to false, this method must return Not Implemented | ||||
252 | * | ||||
253 | * RequestSubscription doesn't make much sense for SMS anyway | ||||
254 | */ | ||||
255 | void ConnectConnection::requestSubscription(const Tp::UIntList &handles, const QString &message, Tp::DBusError *error) | ||||
256 | { | ||||
257 | error->set(QLatin1String("RequestSubscription.Error.NotImplemented"), QLatin1String("")); | ||||
apol: `QString()`? | |||||
You're probably right. That error line is just one I copied from a similar method in protocol.cpp. I expect QString() would do exactly the same thing in this context but I don't know -- maybe the author before me intentionally used QLatin1String("") sredman: You're probably right. That error line is just one I copied from a similar method in protocol. | |||||
258 | return; | ||||
259 | } | ||||
260 | | ||||
261 | /** | ||||
236 | * Sets the presence (Online, away, snooze, etc.) of a contact | 262 | * Sets the presence (Online, away, snooze, etc.) of a contact | ||
237 | * | 263 | * | ||
238 | * Since SMS does not have the concept of online/offline, etc. this method does nothing | 264 | * Since SMS does not have the concept of online/offline, etc. this method does nothing | ||
265 | * | ||||
266 | * SimplePresence mentions the possibility of a "phone number" contact, but I can't figure out anything more: | ||||
pstn ? TBH, KTp and others just follow the ConnectionType rather than the status. So it'd be the same as just setting this to available. davidedmundson: pstn ?
TBH, KTp and others just follow the ConnectionType rather than the status. So it'd be… | |||||
Yes, that's what I had in mind. I think the trouble I was having was that pstn isn't in the Telepathy Qt library (That I could find). I haven't dug very far into this, since it's not a big deal for now. sredman: Yes, that's what I had in mind. I think the trouble I was having was that pstn isn't in the… | |||||
267 | * https://telepathy.freedesktop.org/spec/Connection_Interface_Simple_Presence.html#description | ||||
239 | */ | 268 | */ | ||
240 | Tp::SimplePresence ConnectConnection::getPresence(uint handle) | 269 | Tp::SimplePresence ConnectConnection::getPresence(uint handle) | ||
241 | { | 270 | { | ||
242 | Q_UNUSED(handle); | 271 | Q_UNUSED(handle); | ||
243 | 272 | | |||
244 | return Tp::Presence::offline().barePresence(); | 273 | return Tp::Presence::offline().barePresence(); | ||
245 | } | 274 | } | ||
246 | 275 | | |||
▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines |
QString()?