The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
6.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. The code included in this file is provided under the terms of the ISC license
  8. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  9. To use, copy, modify, and/or distribute this software for any purpose with or
  10. without fee is hereby granted provided that the above copyright notice and
  11. this permission notice appear in all copies.
  12. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  13. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  14. DISCLAIMED.
  15. ==============================================================================
  16. */
  17. #pragma once
  18. //==============================================================================
  19. /** Represents the current executable's process.
  20. This contains methods for controlling the current application at the
  21. process-level.
  22. @see Thread, JUCEApplicationBase
  23. */
  24. class JUCE_API Process
  25. {
  26. public:
  27. //==============================================================================
  28. enum ProcessPriority
  29. {
  30. LowPriority = 0,
  31. NormalPriority = 1,
  32. HighPriority = 2,
  33. RealtimePriority = 3
  34. };
  35. /** Changes the current process's priority.
  36. @param priority the process priority, where
  37. 0=low, 1=normal, 2=high, 3=realtime
  38. */
  39. static void JUCE_CALLTYPE setPriority (const ProcessPriority priority);
  40. /** Kills the current process immediately.
  41. This is an emergency process terminator that kills the application
  42. immediately - it's intended only for use only when something goes
  43. horribly wrong.
  44. @see JUCEApplicationBase::quit
  45. */
  46. static void JUCE_CALLTYPE terminate();
  47. //==============================================================================
  48. /** Returns true if this application process is the one that the user is
  49. currently using.
  50. */
  51. static bool JUCE_CALLTYPE isForegroundProcess();
  52. /** Attempts to make the current process the active one.
  53. (This is not possible on some platforms).
  54. */
  55. static void JUCE_CALLTYPE makeForegroundProcess();
  56. /** Hides the application (on an OS that supports this, e.g. OSX) */
  57. static void JUCE_CALLTYPE hide();
  58. //==============================================================================
  59. /** Raises the current process's privilege level.
  60. Does nothing if this isn't supported by the current OS, or if process
  61. privilege level is fixed.
  62. */
  63. static void JUCE_CALLTYPE raisePrivilege();
  64. /** Lowers the current process's privilege level.
  65. Does nothing if this isn't supported by the current OS, or if process
  66. privilege level is fixed.
  67. */
  68. static void JUCE_CALLTYPE lowerPrivilege();
  69. //==============================================================================
  70. /** Returns true if this process is being hosted by a debugger. */
  71. static bool JUCE_CALLTYPE isRunningUnderDebugger() noexcept;
  72. //==============================================================================
  73. /** Tries to launch the OS's default reader application for a given file or URL. */
  74. static bool JUCE_CALLTYPE openDocument (const String& documentURL, const String& parameters);
  75. /** Tries to launch the OS's default email application to let the user create a message. */
  76. static bool JUCE_CALLTYPE openEmailWithAttachments (const String& targetEmailAddress,
  77. const String& emailSubject,
  78. const String& bodyText,
  79. const StringArray& filesToAttach);
  80. #if JUCE_WINDOWS || DOXYGEN
  81. //==============================================================================
  82. /** WINDOWS ONLY - This returns the HINSTANCE of the current module.
  83. The return type is a void* to avoid being dependent on windows.h - just cast
  84. it to a HINSTANCE to use it.
  85. In a normal JUCE application, this will be automatically set to the module
  86. handle of the executable.
  87. If you've built a DLL and plan to use any JUCE messaging or windowing classes,
  88. you'll need to make sure you call the setCurrentModuleInstanceHandle()
  89. to provide the correct module handle in your DllMain() function, because
  90. the system relies on the correct instance handle when opening windows.
  91. */
  92. static void* JUCE_CALLTYPE getCurrentModuleInstanceHandle() noexcept;
  93. /** WINDOWS ONLY - Sets a new module handle to be used by the library.
  94. The parameter type is a void* to avoid being dependent on windows.h, but it actually
  95. expects a HINSTANCE value.
  96. @see getCurrentModuleInstanceHandle()
  97. */
  98. static void JUCE_CALLTYPE setCurrentModuleInstanceHandle (void* newHandle) noexcept;
  99. #endif
  100. #if JUCE_MAC || DOXYGEN
  101. //==============================================================================
  102. /** OSX ONLY - Shows or hides the OSX dock icon for this app. */
  103. static void setDockIconVisible (bool isVisible);
  104. #endif
  105. #if JUCE_MAC || JUCE_LINUX || DOXYGEN
  106. //==============================================================================
  107. /** UNIX ONLY - Attempts to use setrlimit to change the maximum number of file
  108. handles that the app can open. Pass 0 or less as the parameter to mean
  109. 'infinite'. Returns true if it succeeds.
  110. */
  111. static bool setMaxNumberOfFileHandles (int maxNumberOfFiles) noexcept;
  112. #endif
  113. private:
  114. Process();
  115. JUCE_DECLARE_NON_COPYABLE (Process)
  116. };