Example #1
0
OCStackResult OCResource::deleteResource(DeleteCallback deleteHandler)
{
    QualityOfService defaultQos = OC::QualityOfService::NaQos;
    checked_guard(m_clientWrapper.lock(), &IClientWrapper::GetDefaultQos, defaultQos);

    return result_guard(deleteResource(deleteHandler, defaultQos));
}
void SeafileApiClient::resendRequest(const QUrl& url)
{
    switch (reply_->operation()) {
    case QNetworkAccessManager::GetOperation:
        reply_->deleteLater();
        get(url);
        break;
    case QNetworkAccessManager::PostOperation:
        post(url, body_, false);
        break;
    case QNetworkAccessManager::PutOperation:
        post(url, body_, true);
        break;
    case QNetworkAccessManager::DeleteOperation:
        reply_->deleteLater();
        deleteResource(url);
        break;
    default:
        reply_->deleteLater();
        qWarning() << "unsupported operation" << reply_->operation()
          << "to" << url.toString()
          << "from" << reply_->url().toString();
        break;
    }
}
Example #3
0
void CCResourceProvider::deleteOwnedResources(int pool)
{
    ASSERT(CCProxy::isImplThread());
    Vector<ResourceId> toDelete;
    for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.end(); ++it) {
        if (it->second.pool == pool && !it->second.external)
            toDelete.append(it->first);
    }
    for (Vector<ResourceId>::iterator it = toDelete.begin(); it != toDelete.end(); ++it)
        deleteResource(*it);
}
/*!
    \brief Deletes the cuteRadio resource at \a resourcePath.
    
    For example, to delete a favourite station on behalf of the authenticated user:
    
    \code
    ResourcesRequest request;
    request.setAccessToken(USER_ACCESS_TOKEN);
    request.del("/favourites/EXISTING_STATION_ID");
    \endcode
*/
void ResourcesRequest::del(const QString &resourcePath) {
    if (status() == Loading) {
        return;
    }
    
    QUrl u(QString("%1%2%3").arg(API_URL).arg(resourcePath.startsWith("/") ? QString() : QString("/"))
                            .arg(resourcePath));
    setUrl(u);
    setData(QVariant());
    deleteResource();
}
void ResourcesSynchronizationLibrary::deleteResourcesSelection( UserID userID )
{
    log()->debug( "(User: "******") Deleting Selection\n" );
    std::map< ResourceID, ResourceSyncDataPtr >::iterator currentElement;

    currentElement = resourcesSyncData_.begin();
    while( currentElement != resourcesSyncData_.end() ){
        if( currentElement->second->resourceOwner() == userID ){
            deleteResource( currentElement->first );

            // deleteResource() removes resources recursively, so this
            // iterator could end invalidated. Start again from the
            // begining.
            // TODO: Optimize this!.
            currentElement = resourcesSyncData_.begin();
        }else{
            currentElement++;
        }
    }
}
void NetworkAccessManager::onRequestFinished(QNetworkReply *reply)
{
    // http://stackoverflow.com/questions/4330274/qtwebkit-how-to-check-http-status-code
    if(reply->error() > 0) {
        qDebug() << "Response Error " << reply->error() << "\n" << reply->errorString();
        if (reply->error() == QNetworkReply::ContentReSendError) {
            if (d->DataMap.contains(reply))  {
                RequestInfo* ri = d->DataMap.value(reply);
                qWarning() << "Hit with  205! Going to re-process the request for which this error is."
                           << " The request url is " << reply->request().url().toString()
                           << " and the request op-type is " << ri->Operation << ". FYI(head=1,get=2,put=3,post=4,del=5).";

                switch (ri->Operation) {
                case HeadOperation:
                    head(reply->request()); break;
                case GetOperation:
                    get(reply->request()); break;
                case PutOperation:
                    put(reply->request(), ri->Data); break;
                case PostOperation:
                    post(reply->request(), ri->Data); break;
                case DeleteOperation:
                    deleteResource(reply->request()); break;
                default:
                    qWarning() << "Alas! Unknown operation :("; break;
                }
            }
            else {
                qWarning()  << "Hit with  205! But no cached data found in the network-manager data map associated with this request to process the request!";
            }
        }
    }
    else {
        qDebug() << "Request processed successfully# " << reply->request().url().toString();
    }

    d->removeRequestInfo(reply);
}
void ResourcesSynchronizationLibrary::deleteResource( const ResourceID &resourceID )
{
    ResourceSyncData& resourceSyncData =
            *( resourcesSyncData_.at( resourceID ) );

    if( !undeletableResources_.count( resourceID ) ){
        // Delete first the children of the resource.
        for( const ResourceID& childResourceID : resourceSyncData.childResourceIDs() ){
            deleteResource( childResourceID );
        }

        // If the deleted resource is a light, remove it from the container
        // of lights first.
        if( lights_.count( resourceID ) ){
            lights_.erase( resourceID );
        }

        //notifyElementDeletion( currentElement->first );
        resourcesSyncData_.erase( resourceID );
    }else{
        //notifyElementUpdate( currentElement->first );
        resourceSyncData.setResourceOwner( NO_USER );
    }
}
void ResourceManager::deleteTexture(const sf::Texture& texture) {
    deleteResource(texture, this -> textures);
}
Example #9
0
void AnimeListWidget::customContextMenuRequested(const QPoint &t_pos) {
    auto model = m_ui->table->indexAt(t_pos);
    auto row = model.row();

    if (row < 0) return;

    QPoint position = t_pos;
    position.setY(t_pos.y() + 20);

    QAction *pAnimePanel = new QAction(tr("Open Anime Panel"), m_ui->table);
    QAction *pEpisodeIncrement =
        new QAction(tr("Increment Progress by 1"), m_ui->table);
    QMenu *pStatusUpdate = new QMenu(tr("Status"), m_ui->table);
    QAction *pDeleteEntry = new QAction(tr("Delete Entry"), m_ui->table);
    QMenu *pCustomLists = new QMenu(tr("Custom Lists"), m_ui->table);

    QAction *pWatching = new QAction(tr("Watching"), pStatusUpdate);
    QAction *pOnHold = new QAction(tr("On Hold"), pStatusUpdate);
    QAction *pPlanToWatch = new QAction(tr("Plan to Watch"), pStatusUpdate);
    QAction *pCompleted = new QAction(tr("Completed"), pStatusUpdate);
    QAction *pDropped = new QAction(tr("Dropped"), pStatusUpdate);

    QAction *pHideDefault = new QAction(tr("Hide Default"), pCustomLists);

    QAction *pRuleAction = new QAction(tr("Create rule"), m_ui->table);
    QAction *pSearch = new QAction(tr("Search For Torrents"), m_ui->table);

    auto index = m_proxy_model->index(model.row(), ListRoles::Title);
    auto title = m_proxy_model->data(index, Qt::DisplayRole).toString();
    AnimePtr anime = User::sharedUser()->getAnimeByTitle(title);

    for (int i = 0; i < User::sharedUser()->customListNames().count(); i++) {
        QString list = User::sharedUser()->customListNames().at(i);
        if (list.isEmpty()) continue;

        QAction *temp = new QAction(list, m_ui->table);
        temp->setCheckable(true);

        if (anime->customLists().at(i) == 1) {
            temp->setChecked(true);
        } else {
            temp->setChecked(false);
        }

        connect(temp, &QAction::toggled, [this, anime, i](bool selected) {
            QList<int> custom = anime->customLists();
            custom.replace(i, selected ? 1 : 0);
            anime->setCustomLists(custom);

            QMap<QString, QString> data;
            data.insert("id", anime->id());
            QString d;
            for (int i = 0; i < custom.length(); i++) {
                d += QString::number(custom.at(i)) +
                     ((i == custom.length() - 1) ? "" : ",");
            }

            data.insert("custom_lists", d);

            auto api = API::sharedAPI()->sharedAniListAPI();

            api->put(api->API_EDIT_LIST, data);

            emit refreshLists();
        });

        pCustomLists->addAction(temp);
    }

    pHideDefault->setCheckable(true);
    pHideDefault->setChecked(anime->hiddenDefault());

    pCustomLists->addAction(pHideDefault);

    connect(pHideDefault, &QAction::toggled, [this, anime](bool selected) {
        QMap<QString, QString> data;
        data.insert("id", anime->id());
        data.insert("hidden_default", selected ? "1" : "0");

        if (selected) {
            User::sharedUser()->removeFromList(anime->listStatus(), anime);
        }

        emit animePayloadChanged(anime, data);
    });

    pStatusUpdate->addAction(pWatching);
    pStatusUpdate->addAction(pOnHold);
    pStatusUpdate->addAction(pPlanToWatch);
    pStatusUpdate->addAction(pCompleted);
    pStatusUpdate->addAction(pDropped);

    connect(pAnimePanel, &QAction::triggered,
    [this, row, anime]() {
        emit animePanelRequested(anime);
    });

    connect(pEpisodeIncrement, &QAction::triggered, [&anime, this]() {
        if (anime->episodesWatched() >= anime->totalEpisodes() &&
                anime->totalEpisodes() != 0) {
            return;
        }
        anime->setEpisodesWatched(anime->episodesWatched() + 1);

        if (anime->episodesWatched() == anime->totalEpisodes() &&
                anime->totalEpisodes() != 0) {
            anime->setListStatus("completed");
        }

        m_proxy_model->invalidate();
        emit animeChanged(anime);
    });

    connect(pWatching, &QAction::triggered,
    [this, anime]() {
        updateStatus(anime, "watching");
    });

    connect(pPlanToWatch, &QAction::triggered,
    [this, anime]() {
        updateStatus(anime, "plan to watch");
    });

    connect(pOnHold, &QAction::triggered,
    [this, anime]() {
        updateStatus(anime, "on-hold");
    });

    connect(pDropped, &QAction::triggered,
    [this, anime]() {
        updateStatus(anime, "dropped");
    });

    connect(pCompleted, &QAction::triggered,
    [this, anime]() {
        updateStatus(anime, "completed");
    });

    connect(pDeleteEntry, &QAction::triggered, [this, anime]() {
        auto api = API::sharedAPI()->sharedAniListAPI();
        auto url = api->API_DELETE_ANIME(anime->id());

        api->deleteResource(url);

        User::sharedUser()->removeAll(anime);
        emit refreshLists();
    });

    connect(pRuleAction, &QAction::triggered,
    [this, anime]() {
        emit createAndShowRule(anime, "");
    });

    connect(pSearch, &QAction::triggered,
    [this, anime]() {
        emit searchTorrents(anime);
    });

    QMenu *pContextMenu = new QMenu(this);

    pContextMenu->addAction(pAnimePanel);
    pContextMenu->addAction(pEpisodeIncrement);
    pContextMenu->addMenu(pStatusUpdate);

    if (User::sharedUser()->customListNames().length() > 0) {
        pContextMenu->addMenu(pCustomLists);
    } else {
        delete pCustomLists;
    }

    pContextMenu->addAction(pDeleteEntry);
    pContextMenu->addAction(pRuleAction);
    pContextMenu->addAction(pSearch);

    pContextMenu->exec(mapToGlobal(position));

    delete pContextMenu;
    pContextMenu = nullptr;
}
Example #10
0
// delete resource
void HttpIOChain::deleteResource(IOChainContext & iocontext){
    CHAIN_FORWARD(deleteResource(iocontext));
}
Example #11
0
		/**
		 * Private method is used to release resource from manager container. It can be called from Lua script.
		 * @param	name is resource name id.
		 */
		void TextureManager::releaseResource(const string& name)
		{
			deleteResource(name);
		}
Example #12
0
void console_start() {
	char **parameters;
	char command[512];
	int exit = 0;

	strcpy(currentDirPrompt, "/");
	strcpy(currentDirId, ROOT_DIR_ID);

	do {
		printf("%s > ", currentDirPrompt);
		readCommand(command);
		// El trim de las commons tira error a veces.. string_trim(&command);

		// Ignore empty enter
		if (command[0] != '\0') {
			parameters = string_split(command, " ");

			if (string_equals_ignore_case(parameters[0], "format")) {
				format();
			} else if (string_equals_ignore_case(parameters[0], "df")) {
				diskFree();
			} else if (string_equals_ignore_case(parameters[0], "rm")) {
				deleteResource(parameters);
			} else if (string_equals_ignore_case(parameters[0], "mv")) {
				moveResource(parameters[1], parameters[2]);
			} else if (string_equals_ignore_case(parameters[0], "rename")) {
				renameResource(parameters[1], parameters[2]);
			} else if (string_equals_ignore_case(parameters[0], "mkdir")) {
				makeDir(parameters[1]);
			} else if (string_equals_ignore_case(parameters[0], "cd")) {
				changeDir(parameters[1]);
			} else if (string_equals_ignore_case(parameters[0], "ll")) {
				listResources();
			} else if (string_equals_ignore_case(parameters[0], "md5sum")) {
				md5sum(parameters[1]);
			} else if (string_equals_ignore_case(parameters[0], "cp")) {
				copyFile(parameters);
			} else if (string_equals_ignore_case(parameters[0], "blocks")) {
				printFileBlocks(parameters[1]);
			} else if (string_equals_ignore_case(parameters[0], "catb")) {
				saveBlockContents(parameters);
			} else if (string_equals_ignore_case(parameters[0], "cpb")) {
				copyBlock(parameters);
			} else if (string_equals_ignore_case(parameters[0], "rmb")) {
				deleteBlock(parameters);
			} else if (string_equals_ignore_case(parameters[0], "nodestat")) {
				printNodeStatus(parameters[1]);
			} else if (string_equals_ignore_case(parameters[0], "enablen")) {
				enableNode(parameters[1]);
			} else if (string_equals_ignore_case(parameters[0], "disablen")) {
				disableNode(parameters[1]);
			} else if (string_equals_ignore_case(parameters[0], "help")) {
				help();
			} else if (string_equals_ignore_case(parameters[0], "exit")) {
				exit = 1;
			} else if (string_equals_ignore_case(parameters[0], "\n")) {
				// ignore enter
			} else {
				printf("Invalid command \n");
			}
			freeSplits(parameters);
		}
	} while (!exit);

	printf("bye\n");
}