Example #1
0
/** This function inserts a high priority request to quit into the request
 *  queue of the network thead, and also aborts any ongoing download.
 *  Separating this allows more time for the thread to finish cleanly, 
 *  before it gets cancelled in the destructor.
 */
void NetworkHttp::stopNetworkThread()
{
#ifndef NO_CURL
    if(UserConfigParams::m_internet_status!=NetworkHttp::IPERM_ALLOWED)
        return;

    // If a download should be active (which means it was cancelled by the
    // user, in which case it will still be ongoing in the background)
    // we can't get the mutex, and would have to wait for a timeout,
    // and we couldn't finish STK. This way we request an abort of
    // a download, which mean we can get the mutex and ask the service
    // thread here to cancel properly.
    cancelAllDownloads();

    Request *r = new Request(Request::HC_QUIT, 9999);
    if(UserConfigParams::logAddons())
        printf("[addons] Inserting QUIT request.\n");
    insertRequest(r);
#endif
}   // stopNetworkThread
Example #2
0
HttpDownloader::~HttpDownloader()
{
    cancelAllDownloads();
}