Esempio n. 1
0
void UploadToMegaDialog::on_bOK_clicked()
{
    MegaNode *node = megaApi->getNodeByPath(ui->eFolderPath->text().toUtf8().constData());
    if (node && node->isFolder())
    {
        selectedHandle = node->getHandle();
        delete node;
        accept();
        return;
    }
    delete node;
    if (!ui->eFolderPath->text().compare(QString::fromUtf8("/MEGAsync Uploads")))
    {
        ui->bChange->setEnabled(false);
        ui->bOK->setEnabled(false);
        MegaNode *rootNode = megaApi->getRootNode();
        if (!rootNode)
        {
            return;
        }

        megaApi->createFolder(tr("MEGAsync Uploads").toUtf8().constData(), rootNode, delegateListener);
        delete rootNode;
        return;
    }

    MegaApi::log(MegaApi::LOG_LEVEL_ERROR, QString::fromUtf8("Folder not found: %1").arg(ui->eFolderPath->text()).toUtf8().constData());
    ui->eFolderPath->setText(QString::fromUtf8("/MEGAsync Uploads"));
    return;
}
Esempio n. 2
0
void SdkTest::purgeTree(MegaNode *p)
{
    MegaNodeList *children;
    children = megaApi->getChildren(p);

    for (int i = 0; i < children->size(); i++)
    {
        MegaNode *n = children->get(i);
        if (n->isFolder())
            purgeTree(n);

        megaApi->remove(n);
    }
}
Esempio n. 3
0
void NodeSelector::on_bOk_clicked()
{
    MegaNode *node = megaApi->getNodeByHandle(selectedFolder);
    if (!node)
    {
        reject();
        return;
    }

    int access = megaApi->getAccess(node);
    if ((selectMode == NodeSelector::UPLOAD_SELECT) && ((access < MegaShare::ACCESS_READWRITE)))
    {
        QMessageBox::warning(this, tr("Error"), tr("You need Read & Write or Full access rights to be able to upload to the selected folder."), QMessageBox::Ok);
        delete node;
        return;

    }
    else if ((selectMode == NodeSelector::SYNC_SELECT) && (access < MegaShare::ACCESS_FULL))
    {
        QMessageBox::warning(this, tr("Error"), tr("You need Full access right to be able to sync the selected folder."), QMessageBox::Ok);
        delete node;
        return;
    }
    else if ((selectMode == NodeSelector::STREAM_SELECT) && node->isFolder())
    {
        QMessageBox::warning(this, tr("Error"), tr("Only files can be used for streaming."), QMessageBox::Ok);
        delete node;
        return;
    }

    if (selectMode == NodeSelector::SYNC_SELECT)
    {
        const char* path = megaApi->getNodePath(node);
        MegaNode *check = megaApi->getNodeByPath(path);
        delete [] path;
        if (!check)
        {
            QMessageBox::warning(this, tr("Warning"), tr("Invalid folder for synchronization.\n"
                                                         "Please, ensure that you don't use characters like '\\' '/' or ':' in your folder names."),
                                 QMessageBox::Ok);
            delete node;
            return;
        }
        delete check;
    }

    delete node;
    accept();
}