I attached an easy example app(you have to compile unsigned because of caps)
Do you miss APIs in QtQuick?
Well so let's use Qt and native C++ via a nice QtQuick UI
1. add to your .pro file:
QT += declarative
CONFIG += qtestlib #if you want to get a process sleep function
HEADERS += \
helper.h
into your Symbian part:
TARGET.CAPABILITY += PowerMgmt #to kill processes and reboot the phone
LIBS += -apgrfx.lib\ #to kill processes
-lavkon #to lock the phone
2. add to your main.cpp:
#include <QDeclarativeView>
#include <QDeclarativeContext>
#include "helper.h"
after you created your view/viewer:
Helper helper;
viewer.rootContext()->setContextProperty("Helper", &helper);
3. now create a file named helper.h in the folder of your .pro:
#ifndef HELPER_H
#define HELPER_H
#include <QObject>
#include <QString>
#include <QUrl>
#include <QDir>
#include <QFile>
#include <QtCore>
#include <QProcess>
#include <apgtask.h>
#include <eikenv.h>
#include <QApplication>
#include <QTest>
#include <QClipboard>
#include "aknkeylock.h"
class Helper : public QObject
{
Q_OBJECT
public:
Helper(QObject *parent = 0) : QObject(parent){ }
Q_INVOKABLE void launch(QString n)
{
RProcess proc;
TPtrC16 tdesc(reinterpret_cast<const TText*>(n.constData()));
User::LeaveIfError(proc.Create(tdesc,KNullDesC));
proc.Resume();
proc.Close();
}
Q_INVOKABLE void reboot()
{
TFullName res;
TFindProcess find(_L("*[100058F3]*"));
while(find2.Next(res) == KErrNone)
{
RProcess ph;
ph2.Open(find);
ph.Kill(KErrNone);
ph.Close();
}
}
Q_INVOKABLE void del(QString file)
{
QDir *myDir = new QDir;
myDir->remove(file); //e.g. C://data/test.txt
myDir->deleteLater();
}
Q_INVOKABLE void copy(QString source, QString target)
{
QFile::copy(source, target);
}
Q_INVOKABLE void restartApp()
{
QProcess::startDetached(QApplication::applicationFilePath());
exit(12);
}
Q_INVOKABLE void kill(QString process)
{
TPtrC16 symprocess(reinterpret_cast<const TUint16*>(process.utf16()));
TFullName res;
//TFindProcess find(_L("*[E11274FF]*"));
//TFindProcess find(_L("sysap.exe*"));
TFindProcess find(symprocess);
while(find.Next(res) == KErrNone)
{
RProcess ph;
ph.Open(find);
ph.Kill(KErrNone);
ph.Close();
}
}
Q_INVOKABLE void cboard(QString clip)
{
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(clip);
clipboard->deleteLater();
}
Q_INVOKABLE void sleep(QString ms)
{
QString num=ms;
int n = num.toInt();
QTest::qSleep(n);
}
Q_INVOKABLE void lock()
{
RAknKeyLock aKeyLock;
aKeyLock.Connect();
aKeyLock.EnableWithoutNote();
//aKeyLock.DisableWithoutNote();
aKeyLock.Close();
}
};
#endif // HELPER_H
4. now you can access all this methods from QtQuick via:
onClicked:
Helper.lock() //does lock the phone
Helper.sleep("1000") //this sleep the thread for 1000 ms = 1s, you can use every number
Helper.cboard("text") //copy "text" into clipboard
Helper.kill() // here put the app UID (without 0x) in "*[UID]*" or the .exe name in "NAME.exe*"
Helper.restartApp() //does restart the app
Helper.del("C://data/Test.txt") //removes the file C://data/Test.txt
Helper.reboot() //does reboot the phone
Helper.launch("app.exe") //does launch an external .exe file via filename
Helper.copy("C://data/Test.txt", "C://data/Test2.txt)" //copy file1 to same path with name file2
i will try to extend this from time to time
have fun with it in your project
Credits: Dickson, qooApps, Allstar12345, Lucas
I attached an easy example app:(you have to compile unsigned because of caps)
[attachment deleted by admin]