Skip to content

Commit

Permalink
Squashed 'airdcpp-core/' changes from 9d3ca63..4fddc37
Browse files Browse the repository at this point in the history
4fddc37 Fix issues when removing viewed files that haven't finished downloading
010775d Merge branch 'master' of ssh://github.com/airdcpp/airgit
e23524c Set the correct connect state for newly added favorite hubs
138e55a include web-resources in updater

git-subtree-dir: airdcpp-core
git-subtree-split: 4fddc373c1b76c0f2213632768d9338a417845c1
  • Loading branch information
maksis committed Jan 19, 2016
1 parent 98787da commit 9fed2ea
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 21 deletions.
22 changes: 14 additions & 8 deletions airdcpp/FavoriteManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,21 +422,16 @@ bool FavoriteManager::addFavoriteHub(const FavoriteHubEntryPtr& aEntry) {
favoriteHubs.push_back(aEntry);
}

setConnectState(aEntry);

fire(FavoriteManagerListener::FavoriteHubAdded(), aEntry);
save();
return true;
}

void FavoriteManager::onFavoriteHubUpdated(const FavoriteHubEntryPtr& aEntry) {
// Update the connect state in case the address was changed
auto client = ClientManager::getInstance()->getClient(aEntry->getServer());
if (client) {
aEntry->setConnectState(client->isConnected() ? FavoriteHubEntry::STATE_CONNECTED : FavoriteHubEntry::STATE_CONNECTING);
aEntry->setCurrentHubToken(client->getClientId());
} else {
aEntry->setCurrentHubToken(0);
aEntry->setConnectState(FavoriteHubEntry::STATE_DISCONNECTED);
}
setConnectState(aEntry);

save();
fire(FavoriteManagerListener::FavoriteHubUpdated(), aEntry);
Expand Down Expand Up @@ -1229,6 +1224,17 @@ void FavoriteManager::on(ClientManagerListener::ClientRedirected, const ClientPt
onConnectStateChanged(aNewClient, FavoriteHubEntry::STATE_CONNECTING);
}

void FavoriteManager::setConnectState(const FavoriteHubEntryPtr& aEntry) noexcept {
auto client = ClientManager::getInstance()->getClient(aEntry->getServer());
if (client) {
aEntry->setConnectState(client->isConnected() ? FavoriteHubEntry::STATE_CONNECTED : FavoriteHubEntry::STATE_CONNECTING);
aEntry->setCurrentHubToken(client->getClientId());
} else {
aEntry->setCurrentHubToken(0);
aEntry->setConnectState(FavoriteHubEntry::STATE_DISCONNECTED);
}
}

void FavoriteManager::onConnectStateChanged(const ClientPtr& aClient, FavoriteHubEntry::ConnectState aState) noexcept {
auto hub = getFavoriteHubEntry(aClient->getHubUrl());
if (hub) {
Expand Down
1 change: 1 addition & 0 deletions airdcpp/FavoriteManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ class FavoriteManager : public Speaker<FavoriteManagerListener>, private HttpCon
bool onHttpFinished(bool fromHttp) noexcept;

void onConnectStateChanged(const ClientPtr& aClient, FavoriteHubEntry::ConnectState aState) noexcept;
void setConnectState(const FavoriteHubEntryPtr& aEntry) noexcept;

// SettingsManagerListener
void on(SettingsManagerListener::Load, SimpleXML& xml) noexcept {
Expand Down
6 changes: 6 additions & 0 deletions airdcpp/TrackableDownloadItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@


namespace dcpp {
TrackableDownloadItem::~TrackableDownloadItem() {
if (hasDownloads()) {
DownloadManager::getInstance()->removeListener(this);
}
}

void TrackableDownloadItem::updateState() noexcept {
State newState;
{
Expand Down
2 changes: 2 additions & 0 deletions airdcpp/TrackableDownloadItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ namespace dcpp {
virtual void onRemovedQueue(const string& aDir, bool aFinished) noexcept;
virtual void onAddedQueue(const string& aDir) noexcept;

~TrackableDownloadItem() noexcept;

enum State : uint8_t {
STATE_DOWNLOAD_PENDING,
STATE_DOWNLOADING,
Expand Down
2 changes: 2 additions & 0 deletions airdcpp/Updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ void Updater::createUpdate() {
//add the theme folder
auto installer = Util::getParentDir(updaterFilePath) + "installer" + PATH_SEPARATOR;
ZipFile::CreateZipFileList(files, installer, Util::emptyString, "^(Themes)$");
//Add the web-resources
ZipFile::CreateZipFileList(files, installer, Util::emptyString, "^(Web-resources)$");

ZipFile::CreateZipFile(updaterFilePath + updaterFile, files);

Expand Down
21 changes: 8 additions & 13 deletions airdcpp/ViewFileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace dcpp {

bool ViewFileManager::addFileNotify(const string& aFileName, int64_t aSize, const TTHValue& aTTH, const HintedUser& aUser, bool aIsText) noexcept {
try {
if (ViewFileManager::getInstance()->addFileThrow(aFileName, aSize, aTTH, aUser, true)) {
if (ViewFileManager::getInstance()->addFileThrow(aFileName, aSize, aTTH, aUser, aIsText)) {
return true;
}

Expand All @@ -145,21 +145,16 @@ namespace dcpp {
return false;
}

auto downloads = file->getDownloads();
if (!downloads.empty()) {
// It will come back here after being removed from the queue
for (const auto& p : downloads) {
QueueManager::getInstance()->removeFile(p);
}
} else {
{
WLock l(cs);
viewFiles.erase(aTTH);
}
// In case it hasn't been removed yet
QueueManager::getInstance()->removeFile(file->getPath());

fire(ViewFileManagerListener::FileClosed(), file);
{
WLock l(cs);
viewFiles.erase(aTTH);
}

fire(ViewFileManagerListener::FileClosed(), file);

return true;
}

Expand Down

0 comments on commit 9fed2ea

Please sign in to comment.