@@ -109,11 +109,11 @@ void ShareHelperPrivate::notifyMessage(const QString &body, const QStringList &a
109
109
void ShareHelperPrivate::stopCooperation ()
110
110
{
111
111
if (targetDeviceInfo && targetDeviceInfo->connectStatus () == DeviceInfo::Connected) {
112
- ShareHelper::instance ()->disconnectToDevice (targetDeviceInfo);
113
112
#ifdef linux
114
113
static QString body (tr (" Coordination with \" %1\" has ended" ));
115
114
notifyMessage (body.arg (CommonUitls::elidedText (targetDeviceInfo->deviceName (), Qt::ElideMiddle, 15 )), {}, 3 * 1000 );
116
115
#endif
116
+ ShareHelper::instance ()->disconnectToDevice (targetDeviceInfo);
117
117
}
118
118
}
119
119
@@ -172,7 +172,9 @@ void ShareHelperPrivate::onActionTriggered(const QString &action)
172
172
auto info = DiscoverController::instance ()->findDeviceByIP (senderDeviceIp);
173
173
if (!info) {
174
174
WLOG << " AcceptAction, but not find: " << senderDeviceIp.toStdString ();
175
- return ;
175
+ // create by remote connect info, that is not discoveried.
176
+ info = DeviceInfoPointer (new DeviceInfo (senderDeviceIp, targetDevName));
177
+ info->setPeripheralShared (true );
176
178
}
177
179
178
180
// 更新设备列表中的状态
@@ -266,13 +268,17 @@ void ShareHelper::disconnectToDevice(const DeviceInfoPointer info)
266
268
267
269
ShareCooperationServiceManager::instance ()->stop ();
268
270
269
- if (d->targetDeviceInfo ) {
270
- d->targetDeviceInfo ->setConnectStatus (DeviceInfo::Connectable);
271
- DiscoverController::instance ()->updateDeviceState ({ d->targetDeviceInfo });
272
-
273
- static QString body (tr (" Coordination with \" %1\" has ended" ));
274
- d->notifyMessage (body.arg (CommonUitls::elidedText (d->targetDeviceInfo ->deviceName (), Qt::ElideMiddle, 15 )), {}, 3 * 1000 );
271
+ // The targetDeviceInfo can be null
272
+ if (d->targetDeviceInfo .isNull ()) {
273
+ d->targetDeviceInfo = DeviceInfoPointer::create (*info.data ());
275
274
}
275
+
276
+ info->setConnectStatus (DeviceInfo::Connectable);
277
+ d->targetDeviceInfo ->setConnectStatus (DeviceInfo::Connectable);
278
+ DiscoverController::instance ()->updateDeviceState ({ d->targetDeviceInfo });
279
+
280
+ static QString body (tr (" Coordination with \" %1\" has ended" ));
281
+ d->notifyMessage (body.arg (CommonUitls::elidedText (d->targetDeviceInfo ->deviceName (), Qt::ElideMiddle, 15 )), {}, 3 * 1000 );
276
282
}
277
283
278
284
void ShareHelper::buttonClicked (const QString &id, const DeviceInfoPointer info)
@@ -504,3 +510,19 @@ void ShareHelper::onShareExcepted(int type, const QString &remote)
504
510
break ;
505
511
}
506
512
}
513
+
514
+ int ShareHelper::selfSharing (const QString &shareIp)
515
+ {
516
+ if (shareIp == CooperationUtil::localIPAddress ()) {
517
+ auto server = ShareCooperationServiceManager::instance ()->server ();
518
+ auto client = ShareCooperationServiceManager::instance ()->client ();
519
+ if (server.isNull () && client.isNull ()) {
520
+ return 1 ;
521
+ }
522
+
523
+ auto sharing = (server && server->isRunning ()) || (client && client->isRunning ());
524
+ return sharing ? 0 : 1 ;
525
+ }
526
+
527
+ return -1 ;
528
+ }
0 commit comments