diff options
Diffstat (limited to 'daemon/bankmanager.cpp')
| -rw-r--r-- | daemon/bankmanager.cpp | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/daemon/bankmanager.cpp b/daemon/bankmanager.cpp index 7bc7f91..f0aa68b 100644 --- a/daemon/bankmanager.cpp +++ b/daemon/bankmanager.cpp @@ -7,17 +7,17 @@ #if 0 // TODO -- This is how language files seems to be installed. if (slot == -4) { - logger()->debug() << "starting lang install"; + qCDebug(l) << "starting lang install"; QFile *pbl = new QFile(QDir::home().absoluteFilePath("es.pbl")); if (!pbl->open(QIODevice::ReadOnly)) { - logger()->warn() << "Failed to open pbl"; + qCWarning(l) << "Failed to open pbl"; return false; } upload->uploadFile("lang", pbl, [this]() { - logger()->debug() << "success"; + qCDebug(l) << "success"; }, [this](int code) { - logger()->warn() << "Some error" << code; + qCWarning(l) << "Some error" << code; }); return true; @@ -25,7 +25,8 @@ if (slot == -4) { #endif BankManager::BankManager(WatchConnector *watch, UploadManager *upload, AppManager *apps, QObject *parent) : - QObject(parent), watch(watch), upload(upload), apps(apps), _refresh(new QTimer(this)) + QObject(parent), l(metaObject()->className()), + watch(watch), upload(upload), apps(apps), _refresh(new QTimer(this)) { connect(watch, &WatchConnector::connectedChanged, this, &BankManager::handleWatchConnected); @@ -55,43 +56,43 @@ bool BankManager::uploadApp(const QUuid &uuid, int slot) { AppInfo info = apps->info(uuid); if (info.uuid() != uuid) { - logger()->warn() << "uuid" << uuid << "is not installed"; + qCWarning(l) << "uuid" << uuid << "is not installed"; return false; } if (slot == -1) { slot = findUnusedSlot(); if (slot == -1) { - logger()->warn() << "no free slots!"; + qCWarning(l) << "no free slots!"; return false; } } if (slot < 0 || slot > _slots.size()) { - logger()->warn() << "invalid slot index"; + qCWarning(l) << "invalid slot index"; return false; } if (_slots[slot].used) { - logger()->warn() << "slot in use"; + qCWarning(l) << "slot in use"; return false; } QDir appDir(info.path()); - logger()->debug() << "about to install app from" << appDir.absolutePath() << "into slot" << slot; + qCDebug(l) << "about to install app from" << appDir.absolutePath() << "into slot" << slot; QFile *binaryFile = new QFile(appDir.absoluteFilePath("pebble-app.bin"), this); if (!binaryFile->open(QIODevice::ReadOnly)) { - logger()->warn() << "failed to open" << binaryFile->fileName() << ":" << binaryFile->errorString(); + qCWarning(l) << "failed to open" << binaryFile->fileName() << ":" << binaryFile->errorString(); delete binaryFile; return false; } - logger()->debug() << "binary file size is" << binaryFile->size(); + qCDebug(l) << "binary file size is" << binaryFile->size(); QFile *resourceFile = 0; if (appDir.exists("app_resources.pbpack")) { resourceFile = new QFile(appDir.absoluteFilePath("app_resources.pbpack"), this); if (!resourceFile->open(QIODevice::ReadOnly)) { - logger()->warn() << "failed to open" << resourceFile->fileName() << ":" << resourceFile->errorString(); + qCWarning(l) << "failed to open" << resourceFile->fileName() << ":" << resourceFile->errorString(); delete resourceFile; return false; } @@ -104,27 +105,27 @@ bool BankManager::uploadApp(const QUuid &uuid, int slot) upload->uploadAppBinary(slot, binaryFile, [this, binaryFile, resourceFile, slot]() { - logger()->debug() << "app binary upload succesful"; + qCDebug(l) << "app binary upload succesful"; delete binaryFile; // Proceed to upload the resource file if (resourceFile) { upload->uploadAppResources(slot, resourceFile, [this, resourceFile, slot]() { - logger()->debug() << "app resources upload succesful"; + qCDebug(l) << "app resources upload succesful"; delete resourceFile; // Upload succesful // Tell the watch to reload the slot refreshWatchApp(slot, [this]() { - logger()->debug() << "app refresh succesful"; + qCDebug(l) << "app refresh succesful"; _refresh->start(); }, [this](int code) { - logger()->warn() << "app refresh failed" << code; + qCWarning(l) << "app refresh failed" << code; _refresh->start(); }); }, [this, resourceFile](int code) { - logger()->warn() << "app resources upload failed" << code; + qCWarning(l) << "app resources upload failed" << code; delete resourceFile; _refresh->start(); @@ -134,15 +135,15 @@ bool BankManager::uploadApp(const QUuid &uuid, int slot) // No resource file // Tell the watch to reload the slot refreshWatchApp(slot, [this]() { - logger()->debug() << "app refresh succesful"; + qCDebug(l) << "app refresh succesful"; _refresh->start(); }, [this](int code) { - logger()->warn() << "app refresh failed" << code; + qCWarning(l) << "app refresh failed" << code; _refresh->start(); }); } }, [this, binaryFile, resourceFile](int code) { - logger()->warn() << "app binary upload failed" << code; + qCWarning(l) << "app binary upload failed" << code; delete binaryFile; delete resourceFile; @@ -155,15 +156,15 @@ bool BankManager::uploadApp(const QUuid &uuid, int slot) bool BankManager::unloadApp(int slot) { if (slot < 0 || slot > _slots.size()) { - logger()->warn() << "invalid slot index"; + qCWarning(l) << "invalid slot index"; return false; } if (!_slots[slot].used) { - logger()->warn() << "slot is empty"; + qCWarning(l) << "slot is empty"; return false; } - logger()->debug() << "going to unload app" << _slots[slot].name << "in slot" << slot; + qCDebug(l) << "going to unload app" << _slots[slot].name << "in slot" << slot; int installId = _slots[slot].id; @@ -184,10 +185,10 @@ bool BankManager::unloadApp(int slot) uint result = u.read<quint32>(); switch (result) { case Success: /* Success */ - logger()->debug() << "sucessfully unloaded app"; + qCDebug(l) << "sucessfully unloaded app"; break; default: - logger()->warn() << "could not unload app. result code:" << result; + qCWarning(l) << "could not unload app. result code:" << result; break; } @@ -201,7 +202,7 @@ bool BankManager::unloadApp(int slot) void BankManager::refresh() { - logger()->debug() << "refreshing bank status"; + qCDebug(l) << "refreshing bank status"; watch->sendMessage(WatchConnector::watchAPP_MANAGER, QByteArray(1, WatchConnector::appmgrGET_APPBANK_STATUS), @@ -211,7 +212,7 @@ void BankManager::refresh() } if (data.size() < 9) { - logger()->warn() << "invalid getAppbankStatus response"; + qCWarning(l) << "invalid getAppbankStatus response"; return true; } @@ -222,7 +223,7 @@ void BankManager::refresh() unsigned int num_banks = u.read<quint32>(); unsigned int apps_installed = u.read<quint32>(); - logger()->debug() << "Bank status:" << apps_installed << "/" << num_banks; + qCDebug(l) << "Bank status:" << apps_installed << "/" << num_banks; _slots.resize(num_banks); for (unsigned int i = 0; i < num_banks; i++) { @@ -244,12 +245,12 @@ void BankManager::refresh() unsigned short version = u.read<quint16>(); if (index < 0 || index >= _slots.size()) { - logger()->warn() << "Invalid slot index" << index; + qCWarning(l) << "Invalid slot index" << index; continue; } if (u.bad()) { - logger()->warn() << "short read"; + qCWarning(l) << "short read"; return true; } @@ -264,7 +265,7 @@ void BankManager::refresh() QUuid uuid = info.uuid(); _slots[index].uuid = uuid; - logger()->debug() << index << id << name << company << flags << version << uuid; + qCDebug(l) << index << id << name << company << flags << version << uuid; } emit this->slotsChanged(); @@ -332,10 +333,10 @@ void BankManager::getAppbankUuids(const function<void(const QList<QUuid> &)>& ca if (data.at(0) != WatchConnector::appmgrGET_APPBANK_UUIDS) { return false; } - logger()->debug() << "getAppbankUuids response" << data.toHex(); + qCDebug(l) << "getAppbankUuids response" << data.toHex(); if (data.size() < 5) { - logger()->warn() << "invalid getAppbankUuids response"; + qCWarning(l) << "invalid getAppbankUuids response"; return true; } @@ -345,24 +346,24 @@ void BankManager::getAppbankUuids(const function<void(const QList<QUuid> &)>& ca unsigned int apps_installed = u.read<quint32>(); - logger()->debug() << apps_installed; + qCDebug(l) << apps_installed; QList<QUuid> uuids; for (unsigned int i = 0; i < apps_installed; i++) { QUuid uuid = u.readUuid(); - logger()->debug() << uuid.toString(); + qCDebug(l) << uuid.toString(); if (u.bad()) { - logger()->warn() << "short read"; + qCWarning(l) << "short read"; return true; } uuids.push_back(uuid); } - logger()->debug() << "finished"; + qCDebug(l) << "finished"; callback(uuids); |
