Changeset View
Changeset View
Standalone View
Standalone View
protocols/bonjour/bonjouraccount.cpp
Show First 20 Lines • Show All 226 Lines • ▼ Show 20 Line(s) | 210 | { | |||
---|---|---|---|---|---|
227 | 227 | | |||
228 | myself()->setOnlineStatus(BonjourProtocol::protocol()->bonjourOnline); | 228 | myself()->setOnlineStatus(BonjourProtocol::protocol()->bonjourOnline); | ||
229 | 229 | | |||
230 | startBrowse(); | 230 | startBrowse(); | ||
231 | } | 231 | } | ||
232 | 232 | | |||
233 | void BonjourAccount::comingOnline(KDNSSD::RemoteService::Ptr pointer) | 233 | void BonjourAccount::comingOnline(KDNSSD::RemoteService::Ptr pointer) | ||
234 | { | 234 | { | ||
235 | if (!pointer->resolve()) { | 235 | if (contacts().value(pointer->serviceName())) | ||
236 | qDebug()<<"Unable to Resolve! Dumping Contact"; | 236 | return; | ||
237 | | ||||
238 | if (pointer->isResolved()) | ||||
239 | comingOnlineResolved(pointer, true); | ||||
240 | | ||||
241 | const auto ptrValue = &*pointer; | ||||
jpalecek: We use a raw pointer value here instead of RemoteService::Ptr, because that is a shared pointer… | |||||
242 | QObject::connect(ptrValue, &KDNSSD::RemoteService::resolved, this, [this, ptrValue](bool r) { comingOnlineResolved(KDNSSD::RemoteService::Ptr(ptrValue), r); }); | ||||
243 | pointer->resolveAsync(); | ||||
237 | } | 244 | } | ||
238 | 245 | | |||
246 | void BonjourAccount::comingOnlineResolved(KDNSSD::RemoteService::Ptr pointer, bool success) | ||||
247 | { | ||||
248 | if (!success) { | ||||
249 | qDebug()<<"Unable to Resolve! Dumping Contact"; | ||||
250 | return; | ||||
251 | } | ||||
239 | qDebug()<<"Coming Online:"<<pointer->serviceName(); | 252 | qDebug()<<"Coming Online:"<<pointer->serviceName(); | ||
240 | 253 | | |||
241 | if (pointer->serviceName() == username) { // Don't Add Ourselves | 254 | if (pointer->serviceName() == username) { // Don't Add Ourselves | ||
242 | return; | 255 | return; | ||
243 | } | 256 | } | ||
244 | 257 | | |||
245 | QMap <QString, QByteArray> map = pointer->textData(); | 258 | QMap <QString, QByteArray> map = pointer->textData(); | ||
246 | QString cfirst = QString::fromLocal8Bit(map[QStringLiteral("1st")]); | 259 | QString cfirst = QString::fromLocal8Bit(map[QStringLiteral("1st")]); | ||
Show All 33 Lines | 279 | if (hostAddress != QHostAddress()) { | |||
280 | c->setusername(pointer->serviceName()); | 293 | c->setusername(pointer->serviceName()); | ||
281 | c->setOnlineStatus(Kopete::OnlineStatus::Online); | 294 | c->setOnlineStatus(Kopete::OnlineStatus::Online); | ||
282 | } | 295 | } | ||
283 | } | 296 | } | ||
284 | } | 297 | } | ||
285 | 298 | | |||
286 | void BonjourAccount::goingOffline(KDNSSD::RemoteService::Ptr pointer) | 299 | void BonjourAccount::goingOffline(KDNSSD::RemoteService::Ptr pointer) | ||
287 | { | 300 | { | ||
288 | pointer->resolve(); | | |||
289 | | ||||
290 | // In case we have lost connection, this may return NULL | 301 | // In case we have lost connection, this may return NULL | ||
291 | Kopete::Contact *c = contacts().value(pointer->serviceName()); | 302 | Kopete::Contact *c = contacts().value(pointer->serviceName()); | ||
292 | 303 | | |||
293 | if (c) { | 304 | if (c) { | ||
294 | c->setOnlineStatus(Kopete::OnlineStatus::Offline); | 305 | c->setOnlineStatus(Kopete::OnlineStatus::Offline); | ||
295 | } | 306 | } | ||
296 | } | 307 | } | ||
297 | 308 | | |||
▲ Show 20 Lines • Show All 216 Lines • Show Last 20 Lines |
We use a raw pointer value here instead of RemoteService::Ptr, because that is a shared pointer which would create an ownership loop RemoteService -> (via signal-slot connection) lambda -> RemoteService (via captured variable).