Power save mode review and iteration.
[situare] / src / engine / engine.cpp
1  /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Kaj Wallin - kaj.wallin@ixonos.com
6         Henri Lampela - henri.lampela@ixonos.com
7         Jussi Laitinen - jussi.laitinen@ixonos.com
8         Sami Rämö - sami.ramo@ixonos.com
9
10     Situare is free software; you can redistribute it and/or
11     modify it under the terms of the GNU General Public License
12     version 2 as published by the Free Software Foundation.
13
14     Situare is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License for more details.
18
19     You should have received a copy of the GNU General Public License
20     along with Situare; if not, write to the Free Software
21     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
22     USA.
23  */
24
25 #include <QMessageBox>
26 #include <QNetworkReply>
27
28 #include "common.h"
29 #include "facebookservice/facebookauthentication.h"
30 #include "gps/gpsposition.h"
31 #include "map/mapengine.h"
32 #include "situareservice/situareservice.h"
33 #include "ui/mainwindow.h"
34 #include "mce.h"
35 #include <cmath>
36
37 #include "engine.h"
38
39
40 const QString SETTINGS_GPS_ENABLED = "GPS_ENABLED"; ///< GPS setting
41 const QString SETTINGS_AUTO_CENTERING_ENABLED = "AUTO_CENTERING_ENABLED";///< Auto centering setting
42 const int DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE = 12;  ///< Default zoom level when GPS available
43 const qreal USER_MOVEMENT_MINIMUM_LONGITUDE_DIFFERENCE = 0.003;///< Min value for user move latitude
44 const qreal USER_MOVEMENT_MINIMUM_LATITUDE_DIFFERENCE = 0.001;///< Min value for user move longitude
45 const int MIN_UPDATE_INTERVAL_MSECS = 5*60*1000;
46
47 SituareEngine::SituareEngine(QMainWindow *parent)
48     : QObject(parent),
49       m_autoCenteringEnabled(false),
50       m_automaticUpdateFirstStart(true),
51       m_automaticUpdateRequest(false),
52       m_userMoved(false),
53       m_automaticUpdateIntervalTimer(0),
54       m_lastUpdatedGPSPosition(QPointF())
55 {    
56     qDebug() << __PRETTY_FUNCTION__;
57     m_ui = new MainWindow;
58     m_ui->updateItemVisibility();
59
60     // build MapEngine
61     m_mapEngine = new MapEngine(this);
62     m_ui->setMapViewScene(m_mapEngine->scene());
63
64     // build GPS
65     m_gps = new GPSPosition(this);
66
67     // build SituareService
68     m_situareService = new SituareService(this);
69
70     // build FacebookAuthenticator
71     m_facebookAuthenticator = new FacebookAuthentication(this);
72
73     // connect signals
74     signalsFromMapEngine();
75     signalsFromGPS();
76     signalsFromSituareService();
77     signalsFromMainWindow();
78     signalsFromFacebookAuthenticator();
79
80     connect(this, SIGNAL(userLocationReady(User*)),
81             m_ui, SIGNAL(userLocationReady(User*)));
82
83     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
84             m_ui, SIGNAL(friendsLocationsReady(QList<User*>&)));
85
86     connect(this, SIGNAL(userLocationReady(User*)),
87             m_mapEngine, SLOT(receiveOwnLocation(User*)));
88
89     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
90             m_mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
91
92     m_automaticUpdateIntervalTimer = new QTimer(this);
93     connect(m_automaticUpdateIntervalTimer, SIGNAL(timeout()),
94             this, SLOT(startAutomaticUpdate()));
95
96     // signals connected, now it's time to show the main window
97     // but init the MapEngine before so starting location is set
98     m_mapEngine->init();
99     m_ui->show();
100
101     m_facebookAuthenticator->start();
102
103     m_gps->setMode(GPSPosition::Default);
104     initializeGpsAndAutocentering();
105
106     m_mce = new MCE(this);
107     connect(m_mce, SIGNAL(displayStateChanged(bool)), this, SLOT(displayStateChanged(bool)));
108 }
109
110 SituareEngine::~SituareEngine()
111 {
112     qDebug() << __PRETTY_FUNCTION__;
113
114     delete m_ui;
115
116     QSettings settings(DIRECTORY_NAME, FILE_NAME);
117     settings.setValue(SETTINGS_GPS_ENABLED, m_gps->isRunning());
118     settings.setValue(SETTINGS_AUTO_CENTERING_ENABLED, m_autoCenteringEnabled);
119 }
120
121 void SituareEngine::changeAutoCenteringSetting(bool enabled)
122 {
123     qDebug() << __PRETTY_FUNCTION__;
124
125     m_autoCenteringEnabled = enabled;
126     enableAutoCentering(enabled);
127 }
128
129 void SituareEngine::disableAutoCentering()
130 {
131     qDebug() << __PRETTY_FUNCTION__;
132
133     changeAutoCenteringSetting(false);
134     m_ui->buildInformationBox(tr("Auto centering disabled"));
135 }
136
137 void SituareEngine::displayStateChanged(bool enabled)
138 {
139     qDebug() << __PRETTY_FUNCTION__;
140
141     m_gps->enablePowerSave(!enabled);
142
143     if (m_autoCenteringEnabled)
144         enableAutoCentering(enabled);
145 }
146
147 void SituareEngine::enableAutoCentering(bool enabled)
148 {
149     qDebug() << __PRETTY_FUNCTION__;
150
151     m_ui->setAutoCenteringButtonEnabled(enabled);
152     m_mapEngine->setAutoCentering(enabled);
153
154     if (enabled)
155         m_gps->requestLastPosition();
156 }
157
158 void SituareEngine::enableGPS(bool enabled)
159 {
160     qDebug() << __PRETTY_FUNCTION__;
161
162     m_ui->setOwnLocationCrosshairVisibility(!enabled);
163
164     if (m_gps->isInitialized()) {
165         m_ui->setGPSButtonEnabled(enabled);
166         m_mapEngine->setGPSEnabled(enabled);
167
168         if (enabled && !m_gps->isRunning()) {
169             m_gps->start();
170             enableAutoCentering(m_autoCenteringEnabled);
171             m_gps->requestLastPosition();
172
173             if(m_ui->loginState())
174                 m_ui->readAutomaticLocationUpdateSettings();
175         }
176         else if (!enabled && m_gps->isRunning()) {
177             m_gps->stop();
178             enableAutoCentering(false);
179             enableAutomaticLocationUpdate(false);
180         }
181     }
182     else {
183         if (enabled)
184             m_ui->buildInformationBox(tr("Unable to start GPS"));
185         m_ui->setGPSButtonEnabled(false);
186         m_mapEngine->setGPSEnabled(false);
187     }
188 }
189
190 void SituareEngine::enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs)
191 {
192     qDebug() << __PRETTY_FUNCTION__;
193
194     //Show automatic update confirmation dialog
195     if (m_automaticUpdateFirstStart && m_gps->isRunning() && enabled) {
196         m_ui->showEnableAutomaticUpdateLocationDialog(
197                 tr("Do you want to enable automatic location update with %1 min update interval?")
198                 .arg(updateIntervalMsecs/1000/60));
199         m_automaticUpdateFirstStart = false;
200     } else {
201         if (enabled && m_gps->isRunning()) {
202             m_ui->buildInformationBox(tr("Automatic location update enabled"));
203             if (updateIntervalMsecs < MIN_UPDATE_INTERVAL_MSECS)
204                 m_automaticUpdateIntervalTimer->setInterval(MIN_UPDATE_INTERVAL_MSECS);
205             else
206                 m_automaticUpdateIntervalTimer->setInterval(updateIntervalMsecs);
207
208             connect(m_gps, SIGNAL(position(QPointF,qreal)),
209                     this, SLOT(requestAutomaticUpdateIfMoved(QPointF)));
210
211             m_automaticUpdateIntervalTimer->start();
212
213         } else {
214             disconnect(m_gps, SIGNAL(position(QPointF,qreal)),
215                     this, SLOT(requestAutomaticUpdateIfMoved(QPointF)));
216
217             m_automaticUpdateIntervalTimer->stop();
218         }
219     }
220 }
221
222 void SituareEngine::error(const int error)
223 {
224     qDebug() << __PRETTY_FUNCTION__;    
225
226     switch(error)
227     {
228     case QNetworkReply::ConnectionRefusedError:
229         m_ui->toggleProgressIndicator(false);
230         m_ui->buildInformationBox(tr("Connection refused by the server"), true);
231         break;
232     case QNetworkReply::RemoteHostClosedError:
233         m_ui->toggleProgressIndicator(false);
234         m_ui->buildInformationBox(tr("Connection closed by the server"), true);
235         break;
236     case QNetworkReply::HostNotFoundError:
237         m_ui->toggleProgressIndicator(false);
238         m_ui->buildInformationBox(tr("Remote server not found"), true);
239         break;
240     case QNetworkReply::TimeoutError:
241         m_ui->toggleProgressIndicator(false);
242         m_ui->buildInformationBox(tr("Connection timed out"), true);
243         break;
244     case SituareError::SESSION_EXPIRED:
245         m_ui->buildInformationBox(tr("Session expired. Please login again"), true);
246         m_facebookAuthenticator->clearAccountInformation(true); // keep username = true
247         m_situareService->clearUserData();
248         m_ui->loggedIn(false);
249         m_ui->loginFailed();
250         break;
251     case SituareError::LOGIN_FAILED:
252         m_ui->toggleProgressIndicator(false);
253         m_ui->buildInformationBox(tr("Invalid E-mail address or password"), true);
254         m_ui->loginFailed();
255         break;
256     case SituareError::UPDATE_FAILED:
257         m_ui->toggleProgressIndicator(false);
258         m_ui->buildInformationBox(tr("Update failed, please try again"), true);
259         break;
260     case SituareError::DATA_RETRIEVAL_FAILED:
261         m_ui->toggleProgressIndicator(false);
262         m_ui->buildInformationBox(tr("Data retrieval failed, please try again"), true);
263         break;
264     case SituareError::ADDRESS_RETRIEVAL_FAILED:
265         m_ui->buildInformationBox(tr("Address retrieval failed"), true);
266         break;
267     case SituareError::IMAGE_DOWNLOAD_FAILED:
268         m_ui->buildInformationBox(tr("Image download failed"), true);
269         break;
270     case SituareError::MAP_IMAGE_DOWNLOAD_FAILED:
271         m_ui->buildInformationBox(tr("Map image download failed"), true);
272         break;
273     case SituareError::GPS_INITIALIZATION_FAILED:
274         enableGPS(false);
275         m_ui->buildInformationBox(tr("GPS initialization failed"), true);
276         break;
277     case SituareError::UNKNOWN_REPLY:
278         m_ui->toggleProgressIndicator(false);
279         m_ui->buildInformationBox(tr("Unknown server response"), true);
280         break;
281     case SituareError::INVALID_JSON:
282         m_ui->buildInformationBox(tr("Malformatted reply from server"), true);
283         m_ui->loggedIn(false);
284         m_facebookAuthenticator->clearAccountInformation(false); // clean all
285         break;
286     default:
287         m_ui->toggleProgressIndicator(false);
288         qCritical() << "QNetworkReply::NetworkError :" << error;
289         break;
290     }
291 }
292
293 void SituareEngine::fetchUsernameFromSettings()
294 {
295     qDebug() << __PRETTY_FUNCTION__;
296
297     m_ui->setUsername(m_facebookAuthenticator->loadUsername());
298 }
299
300 void SituareEngine::initializeGpsAndAutocentering()
301 {
302     qDebug() << __PRETTY_FUNCTION__;
303
304     QSettings settings(DIRECTORY_NAME, FILE_NAME);
305     QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
306     QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);
307
308     if (m_gps->isInitialized()) {
309
310         if (gpsEnabled.toString().isEmpty()) { // First start. Situare.conf file does not exists
311
312             connect(m_gps, SIGNAL(position(QPointF,qreal)),
313                     this, SLOT(setFirstStartZoomLevel(QPointF,qreal)));
314
315             changeAutoCenteringSetting(true);
316             enableGPS(true);
317
318             m_ui->buildInformationBox(tr("GPS enabled"));
319             m_ui->buildInformationBox(tr("Auto centering enabled"));
320
321         } else { // Normal start
322             changeAutoCenteringSetting(autoCenteringEnabled.toBool());
323             enableGPS(gpsEnabled.toBool());
324
325             if (gpsEnabled.toBool())
326                 m_ui->buildInformationBox(tr("GPS enabled"));
327
328             if (gpsEnabled.toBool() && autoCenteringEnabled.toBool())
329                 m_ui->buildInformationBox(tr("Auto centering enabled"));
330         }
331     } else {
332         enableGPS(false);
333     }
334 }
335
336 void SituareEngine::loginActionPressed()
337 {
338     qDebug() << __PRETTY_FUNCTION__;
339
340     if(m_ui->loginState()) {
341         logout();
342         m_situareService->clearUserData();
343     } else {
344         m_facebookAuthenticator->start();
345     }
346 }
347
348 void SituareEngine::loginOk()
349 {
350     qDebug() << __PRETTY_FUNCTION__;
351
352     m_ui->loggedIn(true);
353
354     m_ui->show();
355     m_situareService->fetchLocations(); // request user locations
356
357     if (m_gps->isRunning())
358         m_ui->readAutomaticLocationUpdateSettings();
359 }
360
361 void SituareEngine::loginProcessCancelled()
362 {
363     qDebug() << __PRETTY_FUNCTION__;
364
365     m_ui->toggleProgressIndicator(false);
366     m_ui->updateItemVisibility();
367 }
368
369 void SituareEngine::logout()
370 {
371     qDebug() << __PRETTY_FUNCTION__;
372
373     m_ui->loggedIn(false);
374
375     // signal to clear locationUpdateDialog's data
376     connect(this, SIGNAL(clearUpdateLocationDialogData()),
377             m_ui, SIGNAL(clearUpdateLocationDialogData()));
378     emit clearUpdateLocationDialogData();
379
380     m_facebookAuthenticator->clearAccountInformation(); // clear all
381     m_automaticUpdateFirstStart = true;
382 }
383
384 void SituareEngine::refreshUserData()
385 {
386     qDebug() << __PRETTY_FUNCTION__;
387
388     m_ui->toggleProgressIndicator(true);
389
390     m_situareService->fetchLocations();
391 }
392
393 void SituareEngine::requestAddress()
394 {
395     qDebug() << __PRETTY_FUNCTION__;
396
397     if (m_gps->isRunning())
398         m_situareService->reverseGeo(m_gps->lastPosition());
399     else
400         m_situareService->reverseGeo(m_mapEngine->centerGeoCoordinate());
401 }
402
403 void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
404 {
405     qDebug() << __PRETTY_FUNCTION__;
406
407     m_ui->toggleProgressIndicator(true);
408
409     if (m_gps->isRunning())
410         m_situareService->updateLocation(m_gps->lastPosition(), status, publish);
411     else
412         m_situareService->updateLocation(m_mapEngine->centerGeoCoordinate(), status, publish);
413 }
414
415 void SituareEngine::requestAutomaticUpdateIfMoved(QPointF position)
416 {
417     qDebug() << __PRETTY_FUNCTION__;
418
419     if ((fabs(m_lastUpdatedGPSPosition.x() - position.x()) >
420          USER_MOVEMENT_MINIMUM_LONGITUDE_DIFFERENCE) ||
421         (fabs(m_lastUpdatedGPSPosition.y() - position.y()) >
422          USER_MOVEMENT_MINIMUM_LATITUDE_DIFFERENCE)) {
423
424         m_lastUpdatedGPSPosition = position;
425         m_userMoved = true;
426     }
427
428     if (m_automaticUpdateRequest && m_userMoved) {
429         requestUpdateLocation(tr("Automatic location update."));
430         m_automaticUpdateRequest = false;
431         m_userMoved = false;
432     }
433 }
434
435 void SituareEngine::setFirstStartZoomLevel(QPointF latLonCoordinate, qreal accuracy)
436 {
437     qDebug() << __PRETTY_FUNCTION__;
438
439     Q_UNUSED(latLonCoordinate);
440     Q_UNUSED(accuracy);
441
442     if (m_autoCenteringEnabled) // autocentering is disabled when map is scrolled        
443         m_mapEngine->setZoomLevel(DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE);
444
445     disconnect(m_gps, SIGNAL(position(QPointF,qreal)),
446                this, SLOT(setFirstStartZoomLevel(QPointF,qreal)));
447 }
448
449 void SituareEngine::signalsFromFacebookAuthenticator()
450 {
451     qDebug() << __PRETTY_FUNCTION__;
452
453     connect(m_facebookAuthenticator, SIGNAL(error(int)),
454             this, SLOT(error(int)));
455
456     connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
457             m_situareService, SLOT(credentialsReady(FacebookCredentials)));
458
459     connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
460             this, SLOT(loginOk()));
461
462     connect(m_facebookAuthenticator, SIGNAL(newLoginRequest()),
463             m_ui, SLOT(startLoginProcess()));
464
465     connect(m_facebookAuthenticator, SIGNAL(saveCookiesRequest()),
466             m_ui, SLOT(saveCookies()));
467
468     connect(m_facebookAuthenticator, SIGNAL(loginUsingCookies()),
469             m_ui, SLOT(loginUsingCookies()));
470 }
471
472 void SituareEngine::signalsFromGPS()
473 {
474     qDebug() << __PRETTY_FUNCTION__;
475
476     connect(m_gps, SIGNAL(position(QPointF,qreal)),
477             m_mapEngine, SLOT(gpsPositionUpdate(QPointF,qreal)));
478
479     connect(m_gps, SIGNAL(timeout()),
480             m_ui, SLOT(gpsTimeout()));
481
482     connect(m_gps, SIGNAL(error(int)),
483             this, SLOT(error(int)));
484 }
485
486 void SituareEngine::signalsFromMainWindow()
487 {
488     qDebug() << __PRETTY_FUNCTION__;    
489
490     connect(m_ui, SIGNAL(error(int)),
491             this, SLOT(error(int)));
492
493     connect(m_ui, SIGNAL(fetchUsernameFromSettings()),
494             this, SLOT(fetchUsernameFromSettings()));
495
496     connect(m_ui, SIGNAL(loginActionPressed()),
497             this, SLOT(loginActionPressed()));
498
499     connect(m_ui, SIGNAL(saveUsername(QString)),
500             m_facebookAuthenticator, SLOT(saveUsername(QString)));
501
502     connect(m_ui, SIGNAL(updateCredentials(QUrl)),
503             m_facebookAuthenticator, SLOT(updateCredentials(QUrl)));
504
505     // signals from map view
506     connect(m_ui, SIGNAL(mapViewScrolled(QPoint)),
507             m_mapEngine, SLOT(setLocation(QPoint)));
508
509     connect(m_ui, SIGNAL(mapViewResized(QSize)),
510             m_mapEngine, SLOT(viewResized(QSize)));
511
512     connect(m_ui, SIGNAL(viewZoomFinished()),
513             m_mapEngine, SLOT(viewZoomFinished()));
514
515     // signals from zoom buttons (zoom panel and volume buttons)
516     connect(m_ui, SIGNAL(zoomIn()),
517             m_mapEngine, SLOT(zoomIn()));
518
519     connect(m_ui, SIGNAL(zoomOut()),
520             m_mapEngine, SLOT(zoomOut()));
521
522     // signals from menu buttons
523     connect(m_ui, SIGNAL(autoCenteringTriggered(bool)),
524             this, SLOT(changeAutoCenteringSetting(bool)));
525
526     connect(m_ui, SIGNAL(gpsTriggered(bool)),
527             this, SLOT(enableGPS(bool)));
528
529     //signals from dialogs
530     connect(m_ui, SIGNAL(cancelLoginProcess()),
531             this, SLOT(loginProcessCancelled()));
532
533     connect(m_ui, SIGNAL(requestReverseGeo()),
534             this, SLOT(requestAddress()));
535
536     connect(m_ui, SIGNAL(statusUpdate(QString,bool)),
537             this, SLOT(requestUpdateLocation(QString,bool)));
538
539     connect(m_ui, SIGNAL(enableAutomaticLocationUpdate(bool, int)),
540             this, SLOT(enableAutomaticLocationUpdate(bool, int)));    
541
542     // signals from user info tab
543     connect(m_ui, SIGNAL(refreshUserData()),
544             this, SLOT(refreshUserData()));
545
546     connect(m_ui, SIGNAL(findUser(QPointF)),
547             m_mapEngine, SLOT(setViewLocation(QPointF)));
548
549     // signals from friend list tab
550     connect(m_ui, SIGNAL(findFriend(QPointF)),
551             m_mapEngine, SLOT(setViewLocation(QPointF)));
552 }
553
554 void SituareEngine::signalsFromMapEngine()
555 {
556     qDebug() << __PRETTY_FUNCTION__;
557
558     connect(m_mapEngine, SIGNAL(error(int)),
559             this, SLOT(error(int)));
560
561     connect(m_mapEngine, SIGNAL(locationChanged(QPoint)),
562             m_ui, SIGNAL(centerToSceneCoordinates(QPoint)));
563
564     connect(m_mapEngine, SIGNAL(zoomLevelChanged(int)),
565             m_ui, SIGNAL(zoomLevelChanged(int)));
566
567     connect(m_mapEngine, SIGNAL(mapScrolledManually()),
568             this, SLOT(disableAutoCentering()));
569
570     connect(m_mapEngine, SIGNAL(maxZoomLevelReached()),
571             m_ui, SIGNAL(maxZoomLevelReached()));
572
573     connect(m_mapEngine, SIGNAL(minZoomLevelReached()),
574             m_ui, SIGNAL(minZoomLevelReached()));
575
576     connect(m_mapEngine, SIGNAL(locationItemClicked(QList<QString>)),
577             m_ui, SIGNAL(locationItemClicked(QList<QString>)));
578
579     connect(m_mapEngine, SIGNAL(newMapResolution(qreal)),
580             m_ui, SIGNAL(newMapResolution(qreal)));
581 }
582
583 void SituareEngine::signalsFromSituareService()
584 {
585     qDebug() << __PRETTY_FUNCTION__;
586
587     connect(m_situareService, SIGNAL(error(int)),
588             this, SLOT(error(int)));
589
590     connect(m_situareService, SIGNAL(error(int)),
591             m_ui, SIGNAL(messageSendingFailed(int)));
592
593     connect(m_situareService, SIGNAL(reverseGeoReady(QString)),
594             m_ui, SIGNAL(reverseGeoReady(QString)));
595
596     connect(m_situareService, SIGNAL(userDataChanged(User*, QList<User*>&)),
597             this, SLOT(userDataChanged(User*, QList<User*>&)));
598
599     connect(m_situareService, SIGNAL(updateWasSuccessful()),
600             this, SLOT(updateWasSuccessful()));
601
602     connect(m_situareService, SIGNAL(updateWasSuccessful()),
603             m_ui, SIGNAL(clearUpdateLocationDialogData()));
604 }
605
606 void SituareEngine::startAutomaticUpdate()
607 {
608     qDebug() << __PRETTY_FUNCTION__;
609
610     m_gps->requestUpdate();
611     m_automaticUpdateRequest = true;
612 }
613
614 void SituareEngine::updateWasSuccessful()
615 {
616     qDebug() << __PRETTY_FUNCTION__;
617
618     m_situareService->fetchLocations();
619 }
620
621 void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
622 {
623     qDebug() << __PRETTY_FUNCTION__;
624
625     m_ui->toggleProgressIndicator(false);
626     m_ui->showPanels();
627
628     emit userLocationReady(user);
629     emit friendsLocationsReady(friendsList);
630 }