コード例 #1
0
ファイル: Frontend.cpp プロジェクト: 0BruceWayne0/nzbget
void Frontend::UnlockMessages()
{
	if (!IsRemoteMode())
	{
		g_pLog->UnlockMessages();
	}
}
コード例 #2
0
ファイル: ColoredFrontend.cpp プロジェクト: Bootz/nzbm
void ColoredFrontend::BeforeExit()
{
	if (IsRemoteMode())
	{
		printf("\n");
	}
}
コード例 #3
0
ファイル: NCursesFrontend.cpp プロジェクト: sanderjo/nzbget
NCursesFrontend::NCursesFrontend()
{
	m_summary = true;
	m_fileList = true;

	m_showNzbname = g_Options->GetCursesNzbName();
	m_showTimestamp = g_Options->GetCursesTime();
	m_groupFiles = g_Options->GetCursesGroup();

	// Setup curses
#ifdef WIN32
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

	CONSOLE_CURSOR_INFO ConsoleCursorInfo;
	GetConsoleCursorInfo(hConsole, &ConsoleCursorInfo);
	ConsoleCursorInfo.bVisible = false;
	SetConsoleCursorInfo(hConsole, &ConsoleCursorInfo);
	if (IsRemoteMode())
	{
		SetConsoleTitle("NZBGet - remote mode");
	}
	else
	{
		SetConsoleTitle("NZBGet");
	}
#else
	m_window = initscr();
	if (m_window == nullptr)
	{
		printf("ERROR: m_pWindow == nullptr\n");
		exit(-1);
	}
	keypad(stdscr, true);
	nodelay((WINDOW*)m_window, true);
	noecho();
	curs_set(0);
	m_useColor = has_colors();
#endif

	if (m_useColor)
	{
#ifndef WIN32
		start_color();
#endif
		init_pair(0,							COLOR_WHITE,	COLOR_BLUE);
		init_pair(NCURSES_COLORPAIR_TEXT,		COLOR_WHITE,	COLOR_BLACK);
		init_pair(NCURSES_COLORPAIR_INFO,		COLOR_GREEN,	COLOR_BLACK);
		init_pair(NCURSES_COLORPAIR_WARNING,	COLOR_MAGENTA,	COLOR_BLACK);
		init_pair(NCURSES_COLORPAIR_ERROR,		COLOR_RED,		COLOR_BLACK);
		init_pair(NCURSES_COLORPAIR_DEBUG,		COLOR_WHITE,	COLOR_BLACK);
		init_pair(NCURSES_COLORPAIR_DETAIL,		COLOR_GREEN,	COLOR_BLACK);
		init_pair(NCURSES_COLORPAIR_STATUS,		COLOR_BLUE,		COLOR_WHITE);
		init_pair(NCURSES_COLORPAIR_KEYBAR,		COLOR_WHITE,	COLOR_BLUE);
		init_pair(NCURSES_COLORPAIR_INFOLINE,	COLOR_WHITE,	COLOR_BLUE);
		init_pair(NCURSES_COLORPAIR_TEXTHIGHL,	COLOR_BLACK,	COLOR_CYAN);
		init_pair(NCURSES_COLORPAIR_CURSOR,		COLOR_BLACK,	COLOR_YELLOW);
		init_pair(NCURSES_COLORPAIR_HINT,		COLOR_WHITE,	COLOR_RED);
	}
}
コード例 #4
0
ファイル: Frontend.cpp プロジェクト: outtahere/nzbget
void Frontend::FreeData()
{
	if (IsRemoteMode())
	{
		m_remoteMessages.clear();
		DownloadQueue::Guard()->GetQueue()->clear();
	}
}
コード例 #5
0
ファイル: Frontend.cpp プロジェクト: outtahere/nzbget
GuardedMessageList Frontend::GuardMessages()
{
	if (IsRemoteMode())
	{
		return GuardedMessageList(&m_remoteMessages, nullptr);
	}
	else
	{
		return g_Log->GuardMessages();
	}
}
コード例 #6
0
ファイル: Frontend.cpp プロジェクト: outtahere/nzbget
bool Frontend::ServerEditQueue(DownloadQueue::EEditAction action, int offset, int id)
{
	if (IsRemoteMode())
	{
		return RequestEditQueue(action, offset, id);
	}
	else
	{
		return DownloadQueue::Guard()->EditEntry(id, action, offset, nullptr);
	}
}
コード例 #7
0
ファイル: Frontend.cpp プロジェクト: outtahere/nzbget
void Frontend::ServerSetDownloadRate(int rate)
{
	if (IsRemoteMode())
	{
		RequestSetDownloadRate(rate);
	}
	else
	{
		g_Options->SetDownloadRate(rate);
	}
}
コード例 #8
0
ファイル: Frontend.cpp プロジェクト: 0BruceWayne0/nzbget
MessageList* Frontend::LockMessages()
{
	if (IsRemoteMode())
	{
		return &m_RemoteMessages;
	}
	else
	{
		return g_pLog->LockMessages();
	}
}
コード例 #9
0
ファイル: Frontend.cpp プロジェクト: 0BruceWayne0/nzbget
void Frontend::FreeData()
{
	if (IsRemoteMode())
	{
		m_RemoteMessages.Clear();

		DownloadQueue* pDownloadQueue = DownloadQueue::Lock();
		pDownloadQueue->GetQueue()->Clear();
		DownloadQueue::Unlock();
	}
}
コード例 #10
0
ファイル: Frontend.cpp プロジェクト: outtahere/nzbget
void Frontend::ServerPauseUnpause(bool pause)
{
	if (IsRemoteMode())
	{
		RequestPauseUnpause(pause);
	}
	else
	{
		g_Options->SetResumeTime(0);
		g_Options->SetPauseDownload(pause);
	}
}
コード例 #11
0
ファイル: Frontend.cpp プロジェクト: 0BruceWayne0/nzbget
bool Frontend::ServerEditQueue(DownloadQueue::EEditAction eAction, int iOffset, int iID)
{
	if (IsRemoteMode())
	{
		return RequestEditQueue(eAction, iOffset, iID);
	}
	else
	{
		DownloadQueue* pDownloadQueue = LockQueue();
		bool bOK = pDownloadQueue->EditEntry(iID, eAction, iOffset, NULL);
		UnlockQueue();
		return bOK;
	}
	return false;
}
コード例 #12
0
void ezEditorEngineProcessApp::CreateRemoteWindow()
{
  EZ_ASSERT_DEV(IsRemoteMode(), "Incorrect app mode");

  if (m_pRemoteWindow != nullptr)
    return;

  m_pRemoteWindow = EZ_DEFAULT_NEW(ezRemoteProcessWindow);

  ezWindowCreationDesc desc;
  desc.m_uiWindowNumber = 0;
  desc.m_bClipMouseCursor = false;
  desc.m_bShowMouseCursor = true;
  desc.m_Resolution = ezSizeU32(1024, 768);
  desc.m_WindowMode = ezWindowMode::WindowFixedResolution;
  desc.m_Title = "Engine View";

  m_pRemoteWindow->Initialize(desc);
}
コード例 #13
0
ファイル: Frontend.cpp プロジェクト: 0BruceWayne0/nzbget
bool Frontend::PrepareData()
{
	if (IsRemoteMode())
	{
		if (IsStopped())
		{
			return false;
		}
		if (!RequestMessages() || ((m_bSummary || m_bFileList) && !RequestFileList()))
		{
			const char* szControlIP = !strcmp(g_pOptions->GetControlIP(), "0.0.0.0") ? "127.0.0.1" : g_pOptions->GetControlIP();
			printf("\nUnable to send request to nzbget-server at %s (port %i)    \n", szControlIP, g_pOptions->GetControlPort());
			Stop();
			return false;
		}
	}
	else
	{
		if (m_bSummary)
		{
			m_iCurrentDownloadSpeed = g_pStatMeter->CalcCurrentDownloadSpeed();
			m_bPauseDownload = g_pOptions->GetPauseDownload();
			m_iDownloadLimit = g_pOptions->GetDownloadRate();
			m_iThreadCount = Thread::GetThreadCount();
			g_pStatMeter->CalcTotalStat(&m_iUpTimeSec, &m_iDnTimeSec, &m_iAllBytes, &m_bStandBy);

			DownloadQueue *pDownloadQueue = DownloadQueue::Lock();
			m_iPostJobCount = 0;
			for (NZBList::iterator it = pDownloadQueue->GetQueue()->begin(); it != pDownloadQueue->GetQueue()->end(); it++)
			{
				NZBInfo* pNZBInfo = *it;
				m_iPostJobCount += pNZBInfo->GetPostInfo() ? 1 : 0;
			}
			pDownloadQueue->CalcRemainingSize(&m_lRemainingSize, NULL);
			DownloadQueue::Unlock();

		}
	}
	return true;
}
コード例 #14
0
ezViewHandle ezEditorEngineProcessApp::CreateRemoteWindowAndView(ezCamera* pCamera)
{
  EZ_ASSERT_DEV(IsRemoteMode(), "Incorrect app mode");

  CreateRemoteWindow();

  if (m_hRemoteView.IsInvalidated())
  {
    ezGALDevice* pDevice = ezGALDevice::GetDefaultDevice();

    ezWindowOutputTargetGAL* pOutputTarget =
        static_cast<ezWindowOutputTargetGAL*>(ezGameApplicationBase::GetGameApplicationBaseInstance()->AddWindow(m_pRemoteWindow.Borrow()));
    const ezGALSwapChain* pPrimarySwapChain = pDevice->GetSwapChain(pOutputTarget->m_hSwapChain);
    EZ_ASSERT_DEV(pPrimarySwapChain != nullptr, "Failed to init swapchain");

    auto hSwapChainRTV = pDevice->GetDefaultRenderTargetView(pPrimarySwapChain->GetBackBufferTexture());

    ezGALRenderTagetSetup BackBufferRenderTargetSetup;
    BackBufferRenderTargetSetup.SetRenderTarget(0, hSwapChainRTV);

    // setup view
    {
      ezView* pView = nullptr;
      m_hRemoteView = ezRenderWorld::CreateView("Remote Process", pView);

      // EditorRenderPipeline.ezRenderPipelineAsset
      pView->SetRenderPipelineResource(
          ezResourceManager::LoadResource<ezRenderPipelineResource>("{ da463c4d-c984-4910-b0b7-a0b3891d0448 }"));

      pView->SetRenderTargetSetup(BackBufferRenderTargetSetup);
      pView->SetViewport(
          ezRectFloat(0.0f, 0.0f, (float)m_pRemoteWindow->GetClientAreaSize().width, (float)m_pRemoteWindow->GetClientAreaSize().height));
      pView->SetCamera(pCamera);
    }
  }

  return m_hRemoteView;
}
コード例 #15
0
ファイル: Frontend.cpp プロジェクト: outtahere/nzbget
bool Frontend::PrepareData()
{
	if (IsRemoteMode())
	{
		if (IsStopped())
		{
			return false;
		}
		if (!RequestMessages() || ((m_summary || m_fileList) && !RequestFileList()))
		{
			const char* controlIp = !strcmp(g_Options->GetControlIp(), "0.0.0.0") ? "127.0.0.1" : g_Options->GetControlIp();
			printf("\nUnable to send request to nzbget-server at %s (port %i)    \n", controlIp, g_Options->GetControlPort());
			Stop();
			return false;
		}
	}
	else
	{
		if (m_summary)
		{
			m_currentDownloadSpeed = g_StatMeter->CalcCurrentDownloadSpeed();
			m_pauseDownload = g_Options->GetPauseDownload();
			m_downloadLimit = g_Options->GetDownloadRate();
			m_threadCount = Thread::GetThreadCount();
			g_StatMeter->CalcTotalStat(&m_upTimeSec, &m_dnTimeSec, &m_allBytes, &m_standBy);

			GuardedDownloadQueue downloadQueue = DownloadQueue::Guard();
			m_postJobCount = 0;
			for (NzbInfo* nzbInfo : downloadQueue->GetQueue())
			{
				m_postJobCount += nzbInfo->GetPostInfo() ? 1 : 0;
			}
			downloadQueue->CalcRemainingSize(&m_remainingSize, nullptr);
		}
	}
	return true;
}
コード例 #16
0
ファイル: NCursesFrontend.cpp プロジェクト: sanderjo/nzbget
/*
 * Process keystrokes starting with the initialKey, which must not be
 * READKEY_EMPTY but has alread been set via ReadConsoleKey.
 */
void NCursesFrontend::UpdateInput(int initialKey)
{
	int key = initialKey;
	while (key != READKEY_EMPTY)
	{
		int queueSize = CalcQueueSize();

		// Normal or edit queue mode
		if (m_inputMode == normal || m_inputMode == editQueue)
		{
			switch (key)
			{
			case 'q':
				// Key 'q' for quit
				ExitProc();
				break;
			case 'z':
				// show/hide NZBFilename
				m_showNzbname = !m_showNzbname;
				break;
			case 'w':
				// swicth window sizes
				if (m_queueWindowPercentage == 50)
				{
					m_queueWindowPercentage = 100;
				}
				else if (m_queueWindowPercentage == 100 && m_inputMode != editQueue)
				{
					m_queueWindowPercentage = 0;
				}
				else
				{
					m_queueWindowPercentage = 50;
				}
				CalcWindowSizes();
				SetCurrentQueueEntry(m_selectedQueueEntry);
				break;
			case 'g':
				// group/ungroup files
				m_groupFiles = !m_groupFiles;
				SetCurrentQueueEntry(m_selectedQueueEntry);
				NeedUpdateData();
				break;
			}
		}

		// Normal mode
		if (m_inputMode == normal)
		{
			switch (key)
			{
			case 'p':
				// Key 'p' for pause
				if (!IsRemoteMode())
				{
					info(m_pauseDownload ? "Unpausing download" : "Pausing download");
				}
				ServerPauseUnpause(!m_pauseDownload);
				break;
			case 'e':
			case 10: // return
			case 13: // enter
				if (queueSize > 0)
				{
					m_inputMode = editQueue;
					if (m_queueWindowPercentage == 0)
					{
						m_queueWindowPercentage = 50;
					}
					return;
				}
				break;
			case 'r':
				// Download rate
				m_inputMode = downloadRate;
				m_inputNumberIndex = 0;
				m_inputValue = 0;
				return;
			case 't':
				// show/hide Timestamps
				m_showTimestamp = !m_showTimestamp;
				break;
			}
		}

		// Edit Queue mode
		if (m_inputMode == editQueue)
		{
			switch (key)
			{
			case 'e':
			case 10: // return
			case 13: // enter
				m_inputMode = normal;
				return;
			case KEY_DOWN:
				if (m_selectedQueueEntry < queueSize - 1)
				{
					SetCurrentQueueEntry(m_selectedQueueEntry + 1);
				}
				break;
			case KEY_UP:
				if (m_selectedQueueEntry > 0)
				{
					SetCurrentQueueEntry(m_selectedQueueEntry - 1);
				}
				break;
			case KEY_PPAGE:
				if (m_selectedQueueEntry > 0)
				{
					if (m_selectedQueueEntry == m_queueScrollOffset)
					{
						m_queueScrollOffset -= m_queueWinClientHeight;
						SetCurrentQueueEntry(m_selectedQueueEntry - m_queueWinClientHeight);
					}
					else
					{
						SetCurrentQueueEntry(m_queueScrollOffset);
					}
				}
				break;
			case KEY_NPAGE:
				if (m_selectedQueueEntry < queueSize - 1)
				{
					if (m_selectedQueueEntry == m_queueScrollOffset + m_queueWinClientHeight - 1)
					{
						m_queueScrollOffset += m_queueWinClientHeight;
						SetCurrentQueueEntry(m_selectedQueueEntry + m_queueWinClientHeight);
					}
					else
					{
						SetCurrentQueueEntry(m_queueScrollOffset + m_queueWinClientHeight - 1);
					}
				}
				break;
			case KEY_HOME:
				SetCurrentQueueEntry(0);
				break;
			case KEY_END:
				SetCurrentQueueEntry(queueSize > 0 ? queueSize - 1 : 0);
				break;
			case 'p':
				// Key 'p' for pause
				EditQueue(DownloadQueue::eaFilePause, 0);
				break;
			case 'd':
				SetHint(" Use Uppercase \"D\" for delete");
				break;
			case 'D':
				// Delete entry
				if (EditQueue(DownloadQueue::eaFileDelete, 0))
				{
					SetCurrentQueueEntry(m_selectedQueueEntry);
				}
				break;
			case 'u':
				if (EditQueue(DownloadQueue::eaFileMoveOffset, -1))
				{
					SetCurrentQueueEntry(m_selectedQueueEntry - 1);
				}
				break;
			case 'n':
				if (EditQueue(DownloadQueue::eaFileMoveOffset, +1))
				{
					SetCurrentQueueEntry(m_selectedQueueEntry + 1);
				}
				break;
			case 't':
				if (EditQueue(DownloadQueue::eaFileMoveTop, 0))
				{
					SetCurrentQueueEntry(0);
				}
				break;
			case 'b':
				if (EditQueue(DownloadQueue::eaFileMoveBottom, 0))
				{
					SetCurrentQueueEntry(queueSize > 0 ? queueSize - 1 : 0);
				}
				break;
			}
		}

		// Edit download rate input mode
		if (m_inputMode == downloadRate)
		{
			// Numbers
			if (m_inputNumberIndex < 5 && key >= '0' && key <= '9')
			{
				m_inputValue = (m_inputValue * 10) + (key - '0');
				m_inputNumberIndex++;
			}
			// Enter
			else if (key == 10 || key == 13)
			{
				ServerSetDownloadRate(m_inputValue * 1024);
				m_inputMode = normal;
				return;
			}
			// Escape
			else if (key == 27)
			{
				m_inputMode = normal;
				return;
			}
			// Backspace
			else if (m_inputNumberIndex > 0 && key == KEY_BACKSPACE)
			{
				int remain = m_inputValue % 10;

				m_inputValue = (m_inputValue - remain) / 10;
				m_inputNumberIndex--;
			}
		}

		key = ReadConsoleKey();
	}
}