Skip to content

Commit 991a70c

Browse files
FileLink: Add getPackages function
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
1 parent c659aee commit 991a70c

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/link/filelink.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,32 @@ bool FileLink::startConnection() {
9696
return ok;
9797
};
9898

99+
QList<QByteArray> FileLink::getPackages()
100+
{
101+
bool ok = _file.open(QIODevice::ReadOnly);
102+
if(!ok || _openModeFlag != QIODevice::ReadOnly) {
103+
qCCritical(PING_PROTOCOL_FILELINK) << "It's not possible to get packages!";
104+
qCDebug(PING_PROTOCOL_FILELINK) << "Ok:" << ok;
105+
qCDebug(PING_PROTOCOL_FILELINK) << "ReadWrite:" << ok;
106+
return QList<QByteArray>();
107+
}
108+
109+
Pack pack;
110+
QList<QByteArray> output;
111+
while(true) {
112+
// Get data
113+
_inout >> pack.time >> pack.data;
114+
115+
// Check if we have a new package
116+
if(pack.time.isEmpty()) {
117+
qCDebug(PING_PROTOCOL_FILELINK) << "No more packages !";
118+
break;
119+
}
120+
output.append(pack.data);
121+
}
122+
return output;
123+
}
124+
99125
bool FileLink::finishConnection()
100126
{
101127
_file.close();

src/link/filelink.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class FileLink : public AbstractLink
2828
void setPackageIndex(int index) { if(_logThread) _logThread->setPackageIndex(index); }
2929
QTime totalTime() final { return _logThread ? _logThread->totalTime() : QTime(); };
3030
QTime elapsedTime() final { return _logThread ? _logThread->elapsedTime() : QTime(); };
31-
31+
QList<QByteArray> getPackages();
3232
private:
3333
struct Pack {
3434
QString time;

0 commit comments

Comments
 (0)