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.

157 lines
6.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  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. namespace juce
  18. {
  19. //==============================================================================
  20. /** Represents the current executable's process.
  21. This contains methods for controlling the current application at the
  22. process-level.
  23. @see Thread, JUCEApplicationBase
  24. @tags{Core}
  25. */
  26. class JUCE_API Process
  27. {
  28. public:
  29. //==============================================================================
  30. enum ProcessPriority
  31. {
  32. LowPriority = 0,
  33. NormalPriority = 1,
  34. HighPriority = 2,
  35. RealtimePriority = 3
  36. };
  37. /** Changes the current process's priority.
  38. @param priority the process priority, where
  39. 0=low, 1=normal, 2=high, 3=realtime
  40. */
  41. static void JUCE_CALLTYPE setPriority (ProcessPriority priority);
  42. /** Kills the current process immediately.
  43. This is an emergency process terminator that kills the application
  44. immediately - it's intended only for use only when something goes
  45. horribly wrong.
  46. @see JUCEApplicationBase::quit
  47. */
  48. static void JUCE_CALLTYPE terminate();
  49. //==============================================================================
  50. /** Returns true if this application process is the one that the user is
  51. currently using.
  52. */
  53. static bool JUCE_CALLTYPE isForegroundProcess();
  54. /** Attempts to make the current process the active one.
  55. (This is not possible on some platforms).
  56. */
  57. static void JUCE_CALLTYPE makeForegroundProcess();
  58. /** Hides the application (on an OS that supports this, e.g. OSX, iOS, Android) */
  59. static void JUCE_CALLTYPE hide();
  60. //==============================================================================
  61. /** Raises the current process's privilege level.
  62. Does nothing if this isn't supported by the current OS, or if process
  63. privilege level is fixed.
  64. */
  65. static void JUCE_CALLTYPE raisePrivilege();
  66. /** Lowers the current process's privilege level.
  67. Does nothing if this isn't supported by the current OS, or if process
  68. privilege level is fixed.
  69. */
  70. static void JUCE_CALLTYPE lowerPrivilege();
  71. //==============================================================================
  72. /** Returns true if this process is being hosted by a debugger. */
  73. static bool JUCE_CALLTYPE isRunningUnderDebugger() noexcept;
  74. //==============================================================================
  75. /** Tries to launch the OS's default reader application for a given file or URL. */
  76. static bool JUCE_CALLTYPE openDocument (const String& documentURL, const String& parameters);
  77. /** Tries to launch the OS's default email application to let the user create a message. */
  78. static bool JUCE_CALLTYPE openEmailWithAttachments (const String& targetEmailAddress,
  79. const String& emailSubject,
  80. const String& bodyText,
  81. const StringArray& filesToAttach);
  82. //==============================================================================
  83. #if JUCE_WINDOWS || DOXYGEN
  84. /** WINDOWS ONLY - This returns the HINSTANCE of the current module.
  85. The return type is a void* to avoid being dependent on windows.h - just cast
  86. it to a HINSTANCE to use it.
  87. In a normal JUCE application, this will be automatically set to the module
  88. handle of the executable.
  89. If you've built a DLL and plan to use any JUCE messaging or windowing classes,
  90. you'll need to make sure you call the setCurrentModuleInstanceHandle()
  91. to provide the correct module handle in your DllMain() function, because
  92. the system relies on the correct instance handle when opening windows.
  93. */
  94. static void* JUCE_CALLTYPE getCurrentModuleInstanceHandle() noexcept;
  95. /** WINDOWS ONLY - Sets a new module handle to be used by the library.
  96. The parameter type is a void* to avoid being dependent on windows.h, but it actually
  97. expects a HINSTANCE value.
  98. @see getCurrentModuleInstanceHandle()
  99. */
  100. static void JUCE_CALLTYPE setCurrentModuleInstanceHandle (void* newHandle) noexcept;
  101. #endif
  102. //==============================================================================
  103. #if JUCE_MAC || DOXYGEN
  104. /** OSX ONLY - Shows or hides the OSX dock icon for this app. */
  105. static void setDockIconVisible (bool isVisible);
  106. #endif
  107. //==============================================================================
  108. #if JUCE_MAC || JUCE_LINUX || JUCE_BSD || DOXYGEN
  109. /** UNIX ONLY - Attempts to use setrlimit to change the maximum number of file
  110. handles that the app can open. Pass 0 or less as the parameter to mean
  111. 'infinite'. Returns true if it succeeds.
  112. */
  113. static bool setMaxNumberOfFileHandles (int maxNumberOfFiles) noexcept;
  114. #endif
  115. private:
  116. Process();
  117. JUCE_DECLARE_NON_COPYABLE (Process)
  118. };
  119. } // namespace juce