This repository has been archived by the owner on Sep 4, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[tools] contextkit-monitor
Signed-off-by: Denis Zalevskiy <denis.zalevskiy@jolla.com>
- Loading branch information
Denis Zalevskiy
committed
Oct 29, 2013
1 parent
e91ddf6
commit 39661b2
Showing
5 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
if(ENABLE_QT4) | ||
# target_link_libraries(contextkit-monitor | ||
# ${QT_QTCORE_LIBRARY} | ||
# ) | ||
|
||
MESSAGE(STATUS "Monitor tool is not built for Qt4") | ||
|
||
else(ENABLE_QT4) | ||
|
||
# fix for gcc 4.6 specific compiling/linking issues, no dwarf-4 | ||
set(CMAKE_CXX_FLAGS | ||
"${CMAKE_CXX_FLAGS} -gdwarf-3" | ||
) | ||
|
||
set(CMAKE_AUTOMOC TRUE) | ||
|
||
add_executable(contextkit-monitor monitor.cpp) | ||
target_link_libraries(contextkit-monitor | ||
contextkit-statefs-qt5 | ||
statefs-qt5 | ||
) | ||
|
||
target_link_libraries(contextkit-monitor | ||
${Qt5Core_LIBRARIES} | ||
) | ||
install(TARGETS contextkit-monitor DESTINATION bin) | ||
|
||
add_executable(file-monitor filemon.cpp) | ||
|
||
target_link_libraries(file-monitor | ||
${Qt5Core_LIBRARIES} | ||
) | ||
|
||
endif(ENABLE_QT4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <QCoreApplication> | ||
#include <QString> | ||
#include <QStringList> | ||
#include <QDebug> | ||
#include <QDir> | ||
#include <QRegExp> | ||
#include <QSocketNotifier> | ||
#include <map> | ||
#include <memory> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
QCoreApplication app(argc, argv); | ||
auto args = app.arguments(); | ||
if (args.size() <= 1) { | ||
qDebug() << "Usage: " << args[0] << " <namespace_path>..."; | ||
return -1; | ||
} | ||
auto dirname = args[1]; | ||
QDir d(dirname); | ||
auto files = d.entryList(QDir::Files); | ||
auto prefix = d.path() + "/"; | ||
files = files.replaceInStrings(QRegExp("^"), prefix); | ||
qDebug() << files; | ||
|
||
auto begin = files.begin(), end = files.end(); | ||
for (auto pos = begin; pos != end; ++pos) { | ||
auto f = std::make_shared<QFile>(*pos); | ||
f->open(QIODevice::ReadOnly | QIODevice::Unbuffered); | ||
auto p = std::make_shared<QSocketNotifier>(f->handle(), QSocketNotifier::Read); | ||
app.connect(p.get(), &QSocketNotifier::activated, [p, f](int) mutable { | ||
qDebug() << "Activated " << f->fileName() << ", " << f->isOpen(); | ||
//p->setEnabled(false); | ||
//QFile touchFile(f->fileName()); | ||
//touchFile.open(QIODevice::ReadOnly | QIODevice::Unbuffered); | ||
f->seek(0); | ||
QByteArray buf(128, 0); | ||
qDebug() << f->read(buf.data(), 120); | ||
qDebug() << "(" << QString(buf) << ")"; | ||
//p->setEnabled(true); | ||
}); | ||
p->setEnabled(true); | ||
} | ||
return app.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <QCoreApplication> | ||
#include <contextproperty.h> | ||
#include <QString> | ||
#include <QStringList> | ||
#include <QDebug> | ||
#include <QDir> | ||
#include <QRegExp> | ||
#include <map> | ||
#include <memory> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
QCoreApplication app(argc, argv); | ||
auto args = app.arguments(); | ||
if (args.size() <= 1) { | ||
qDebug() << "Usage: " << args[0] << " <namespace_path>..."; | ||
return -1; | ||
} | ||
auto dirname = args[1]; | ||
QDir d(dirname); | ||
auto files = d.entryList(QDir::Files); | ||
auto prefix = d.dirName() + "."; | ||
files = files.replaceInStrings(QRegExp("^"), prefix); | ||
qDebug() << files; | ||
|
||
auto begin = files.begin(), end = files.end(); | ||
for (auto pos = begin; pos != end; ++pos) { | ||
auto p = std::make_shared<ContextProperty>(*pos); | ||
app.connect(p.get(), &ContextProperty::valueChanged, [p]() { | ||
qDebug() << p->key() << "=" << p->value(); | ||
}); | ||
} | ||
return app.exec(); | ||
} |