| 59 | } |
| 60 | |
| 61 | void FlickrPhotoFrameSource::requestSourceUpdate() |
| 62 | { |
| 63 | // just load the images from cache if there is no internet connection |
| 64 | if (!ftManager->hasInternetConnection()) |
| 65 | loadPhotosFromCache(); |
| 66 | |
| 67 | // ensure we have a valid flickr source |
| 68 | if (!isValidFlickrPhotoFrame()) |
| 69 | return; |
| 70 | |
| 71 | // remove existing downloads |
| 72 | ftManager->removeTransfersToHandler(this); |
| 73 | |
| 74 | // See how many photos we currently have cached |
| 75 | int maxNumFilesToCache = 64; |
| 76 | createLocalCacheDirectory(); |
| 77 | StrList filesToDelete = fsManager->getDirectoryContents(native(_localCacheDirectory)); |
| 78 | if (filesToDelete.size() > maxNumFilesToCache) |
| 79 | { |
| 80 | for (int i = 0; i < filesToDelete.size(); ++i) |
| 81 | { |
| 82 | QFile::remove(filesToDelete[i]); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | // Determine what kind of photos to download |
| 87 | // The order is important here since both getting photos from favourite |
| 88 | // and getting photos from a specific user both involve the same parameter |
| 89 | FlickrClient flickrClient(FLICKR_AUTH_TOKEN); |
| 90 | if (_rssFeedUrl.contains("photos_faves")) |
| 91 | flickrClient.requestFavouritePhotosFromId(_userId, this); |
| 92 | else if (!_userId.isEmpty()) |
| 93 | flickrClient.requestPhotosFromId(_userId, false, this); |
| 94 | else if (!_groupId.isEmpty()) |
| 95 | flickrClient.requestPhotosFromId(_groupId, true, this); |
| 96 | else |
| 97 | flickrClient.requestPhotosByTag(_tag, this); |
| 98 | } |
| 99 | |
| 100 | void FlickrPhotoFrameSource::onSourceUpdate(const FileTransfer& transfer) |
| 101 | { |
nothing calls this directly
no test coverage detected