FileMenu->addAction(trUtf8("&Start..."), this, SLOT(start()),QKeySequence(trUtf8("Ctrl+S", "File|Start")));
FileMenu->addAction(trUtf8("&Back"), this, SLOT(back()),QKeySequence(trUtf8("Ctrl+B", "File|Back")));
FileMenu->addAction(trUtf8("&Download"), this, SLOT(updateUi()),QKeySequence(trUtf8("Ctrl+W", "File|Downlad")));
- FileMenu->addAction(trUtf8("Up&load"), this, SLOT(sendDB()),QKeySequence(trUtf8("Ctrl+L", "File|Upload")));
+ FileMenu->addAction(trUtf8("BackUp"), this, SLOT(sendDB()),QKeySequence(trUtf8("Ctrl+L", "File|Upload")));
+ FileMenu->addAction(trUtf8("Rest&ore"), this, SLOT(restoreDB()),QKeySequence(trUtf8("Ctrl+O", "File|Restore")));
FileMenu->addAction(trUtf8("Reset Ui"), this, SLOT(resetUi()), QKeySequence(trUtf8("Ctrl+Z", "File|ResetUi")));
FileMenu->addAction(trUtf8("&Quit..."), this, SLOT(quit()),QKeySequence(trUtf8("Ctrl+Q", "File|Quit")));
menuBar()->addMenu(FileMenu);
conf->setValue(QString("menu"), QVariant(1));
conf->setValue(QString("download"), QVariant("https://raw.github.com/Nothing2Do/diary-mobile-android/master/ui.sql"));
conf->setValue(QString("upload"), QVariant("ftp://<user>:<pass>@<hostname>/<file>"));
+ conf->setValue(QString("restore"), QVariant("http://www.xxx.com/db"));
conf->setValue(QString("start"), QVariant("begin"));
- conf->setValue(QString("db"), QVariant("/data/data/eu.nothing2do.diarymobile/db"));
+ conf->setValue(QString("db"), QVariant("/data/data/eu.nothing2do.diarymobile/files/db"));
}
QString &MainWindow::get(int row, int column){
q->seek(row);
connect(m, SIGNAL(downloaded()), SLOT(writeUpdate()));
}
void MainWindow::sendDB(){
+ system("su");
qDebug()<<"sendDB() : "<<conf->value(QString("upload")).toString();
QUrl upload(conf->value(QString("upload")).toString());
net=new QNetworkAccessManager(this);
QFile b(conf->value(QString("db")).toString());
b.open(QIODevice::ReadOnly);
- //QDataStream c(b.readAll());
- rep=net->put(QNetworkRequest(upload), b.readAll());
+ QByteArray c(b.readAll());
+ rep=net->put(QNetworkRequest(upload), c);
qDebug()<<"net->put : "<<rep<< " upload : "<<upload.url();
//rep=net->put(QNetworkRequest(upload),data);
connect(rep, SIGNAL(finished()), this, SLOT(datasend()));
+ system("exit");
}
void MainWindow::back(){
if(way.size()-1>0){
exec(QList<QString>({"delete from ui;"}));
}
+void MainWindow::restoreDB(){
+ system("su");
+ qDebug()<<"restoreDB() : "<<conf->value(QString("restore")).toString();
+ QUrl download(conf->value(QString("restore")).toString());
+ net=new QNetworkAccessManager(this);
+ QFile b(conf->value(QString("db")).toString());
+ b.open(QIODevice::WriteOnly);
+ rep=net->get(QNetworkRequest(download));
+ // to be finished ...
+ b.write(rep->readAll());
+ system("exit");
+}