bool Frontend::RequestEditQueue(DownloadQueue::EEditAction action, int offset, int id) { RemoteClient client; client.SetVerbose(false); IdList ids = { id }; return client.RequestServerEditQueue(action, offset, nullptr, &ids, nullptr, rmId); }
bool Frontend::RequestSetDownloadRate(int rate) { RemoteClient client; client.SetVerbose(false); return client.RequestServerSetDownloadRate(rate); }
bool Frontend::RequestPauseUnpause(bool pause) { RemoteClient client; client.SetVerbose(false); return client.RequestServerPauseUnpause(pause, rpDownload); }
bool Frontend::RequestFileList() { const char* controlIp = !strcmp(g_Options->GetControlIp(), "0.0.0.0") ? "127.0.0.1" : g_Options->GetControlIp(); Connection connection(controlIp, g_Options->GetControlPort(), false); bool OK = connection.Connect(); if (!OK) { return false; } SNzbListRequest ListRequest; InitMessageBase(&ListRequest.m_messageBase, rrList, sizeof(ListRequest)); ListRequest.m_fileList = htonl(m_fileList); ListRequest.m_serverState = htonl(m_summary); if (!connection.Send((char*)(&ListRequest), sizeof(ListRequest))) { return false; } // Now listen for the returned list SNzbListResponse ListResponse; bool read = connection.Recv((char*) &ListResponse, sizeof(ListResponse)); if (!read || (int)ntohl(ListResponse.m_messageBase.m_signature) != (int)NZBMESSAGE_SIGNATURE || ntohl(ListResponse.m_messageBase.m_structSize) != sizeof(ListResponse)) { return false; } CharBuffer buf; if (ntohl(ListResponse.m_trailingDataLength) > 0) { buf.Reserve(ntohl(ListResponse.m_trailingDataLength)); if (!connection.Recv(buf, buf.Size())) { return false; } } connection.Disconnect(); if (m_summary) { m_pauseDownload = ntohl(ListResponse.m_downloadPaused); m_remainingSize = Util::JoinInt64(ntohl(ListResponse.m_remainingSizeHi), ntohl(ListResponse.m_remainingSizeLo)); m_currentDownloadSpeed = ntohl(ListResponse.m_downloadRate); m_downloadLimit = ntohl(ListResponse.m_downloadLimit); m_threadCount = ntohl(ListResponse.m_threadCount); m_postJobCount = ntohl(ListResponse.m_postJobCount); m_upTimeSec = ntohl(ListResponse.m_upTimeSec); m_dnTimeSec = ntohl(ListResponse.m_downloadTimeSec); m_standBy = ntohl(ListResponse.m_downloadStandBy); m_allBytes = Util::JoinInt64(ntohl(ListResponse.m_downloadedBytesHi), ntohl(ListResponse.m_downloadedBytesLo)); } if (m_fileList && ntohl(ListResponse.m_trailingDataLength) > 0) { RemoteClient client; client.SetVerbose(false); client.BuildFileList(&ListResponse, buf, DownloadQueue::Guard()); } return true; }
bool Frontend::RequestEditQueue(DownloadQueue::EEditAction eAction, int iOffset, int iID) { RemoteClient client; client.SetVerbose(false); return client.RequestServerEditQueue(eAction, iOffset, NULL, &iID, 1, NULL, eRemoteMatchModeID); }
bool Frontend::RequestPauseUnpause(bool bPause) { RemoteClient client; client.SetVerbose(false); return client.RequestServerPauseUnpause(bPause, eRemotePauseUnpauseActionDownload); }
bool Frontend::RequestFileList() { const char* szControlIP = !strcmp(g_pOptions->GetControlIP(), "0.0.0.0") ? "127.0.0.1" : g_pOptions->GetControlIP(); Connection connection(szControlIP, g_pOptions->GetControlPort(), false); bool OK = connection.Connect(); if (!OK) { return false; } SNZBListRequest ListRequest; InitMessageBase(&ListRequest.m_MessageBase, eRemoteRequestList, sizeof(ListRequest)); ListRequest.m_bFileList = htonl(m_bFileList); ListRequest.m_bServerState = htonl(m_bSummary); if (!connection.Send((char*)(&ListRequest), sizeof(ListRequest))) { return false; } // Now listen for the returned list SNZBListResponse ListResponse; bool bRead = connection.Recv((char*) &ListResponse, sizeof(ListResponse)); if (!bRead || (int)ntohl(ListResponse.m_MessageBase.m_iSignature) != (int)NZBMESSAGE_SIGNATURE || ntohl(ListResponse.m_MessageBase.m_iStructSize) != sizeof(ListResponse)) { return false; } char* pBuf = NULL; if (ntohl(ListResponse.m_iTrailingDataLength) > 0) { pBuf = (char*)malloc(ntohl(ListResponse.m_iTrailingDataLength)); if (!connection.Recv(pBuf, ntohl(ListResponse.m_iTrailingDataLength))) { free(pBuf); return false; } } connection.Disconnect(); if (m_bSummary) { m_bPauseDownload = ntohl(ListResponse.m_bDownloadPaused); m_lRemainingSize = Util::JoinInt64(ntohl(ListResponse.m_iRemainingSizeHi), ntohl(ListResponse.m_iRemainingSizeLo)); m_iCurrentDownloadSpeed = ntohl(ListResponse.m_iDownloadRate); m_iDownloadLimit = ntohl(ListResponse.m_iDownloadLimit); m_iThreadCount = ntohl(ListResponse.m_iThreadCount); m_iPostJobCount = ntohl(ListResponse.m_iPostJobCount); m_iUpTimeSec = ntohl(ListResponse.m_iUpTimeSec); m_iDnTimeSec = ntohl(ListResponse.m_iDownloadTimeSec); m_bStandBy = ntohl(ListResponse.m_bDownloadStandBy); m_iAllBytes = Util::JoinInt64(ntohl(ListResponse.m_iDownloadedBytesHi), ntohl(ListResponse.m_iDownloadedBytesLo)); } if (m_bFileList && ntohl(ListResponse.m_iTrailingDataLength) > 0) { RemoteClient client; client.SetVerbose(false); DownloadQueue* pDownloadQueue = LockQueue(); client.BuildFileList(&ListResponse, pBuf, pDownloadQueue); UnlockQueue(); } if (pBuf) { free(pBuf); } return true; }