1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version, but always including the *additional*
9 // restrictions defined in the "License.txt" file.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
28 //Forward declarations
41 extern const char* LAMEXP_DEFAULT_LANGID;
42 extern const char* LAMEXP_DEFAULT_TRANSLATION;
44 ///////////////////////////////////////////////////////////////////////////////
46 ///////////////////////////////////////////////////////////////////////////////
52 lamexp_beep_warning = 1,
57 //Network connection types
60 lamexp_network_err = 0, /*unknown*/
61 lamexp_network_non = 1, /*not connected*/
62 lamexp_network_yes = 2 /*connected*/
69 lamexp_syscolor_text = 0,
70 lamexp_syscolor_background = 1,
71 lamexp_syscolor_caption = 2
78 ///////////////////////////////////////////////////////////////////////////////
80 ///////////////////////////////////////////////////////////////////////////////
82 const QIcon &lamexp_app_icon(void);
83 bool lamexp_append_sysmenu(const QWidget *win, const unsigned int identifier, const QString &text);
84 QStringList lamexp_available_codepages(bool noAliases = true);
85 bool lamexp_beep(int beepType);
86 void lamexp_blink_window(QWidget *poWindow, unsigned int count = 10, unsigned int delay = 150);
87 bool lamexp_block_window_move(void *message);
88 bool lamexp_bring_process_to_front(const unsigned long pid);
89 bool lamexp_bring_to_front(const QWidget *win);
90 bool lamexp_change_process_priority(const int priority);
91 bool lamexp_change_process_priority(void *hProcess, const int priority);
92 bool lamexp_change_process_priority(const QProcess *proc, const int priority);
93 bool lamexp_check_escape_state(void);
94 bool lamexp_check_sysmenu_msg(void *message, const unsigned int identifier);
95 bool lamexp_check_tool(const QString &toolName);
96 const QString lamexp_clean_filename(const QString &str);
97 const QString lamexp_clean_filepath(const QString &str);
98 unsigned __int64 lamexp_current_file_time(void);
99 void lamexp_dbg_dbg_output_string(const char* format, ...);
100 unsigned long lamexp_dbg_private_bytes(void);
101 bool lamexp_enable_close_button(const QWidget *win, const bool bEnable = true);
102 bool lamexp_exec_shell(const QWidget *win, const QString &url, const bool explore = false);
103 bool lamexp_exec_shell(const QWidget *win, const QString &url, const QString ¶meters, const QString &directory, const bool explore = false);
104 void lamexp_finalization(void);
105 unsigned __int64 lamexp_free_diskspace(const QString &path, bool *ok = NULL);
106 void lamexp_free_window_icon(lamexp_icon_t *icon);
107 int lamexp_init_ipc(void);
108 bool lamexp_install_translator(const QString &language);
109 bool lamexp_install_translator_from_file(const QString &qmFile);
110 void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize);
111 void lamexp_ipc_send(unsigned int command, const char* message);
112 bool lamexp_is_executable(const QString &path);
113 bool lamexp_is_hibernation_supported(void);
114 const QString lamexp_lookup_tool(const QString &toolName);
115 const char *lamexp_mulders_url(void);
116 void lamexp_natural_string_sort(QStringList &list, const bool bIgnoreCase);
117 int lamexp_network_status(void);
118 bool lamexp_open_media_file(const QString &mediaFilePath);
119 QString lamexp_path_to_short(const QString &longPath);
120 __int64 lamexp_perfcounter_frequ(void);
121 __int64 lamexp_perfcounter_value(void);
122 bool lamexp_play_sound(const QString &name, const bool bAsync);
123 bool lamexp_play_sound_file(const QString &library, const unsigned short uiSoundIdx, const bool bAsync);
124 bool lamexp_play_sound_alias(const QString &alias, const bool bAsync);
125 bool lamexp_portable_mode(void);
126 unsigned long lamexp_process_id(const QProcess *proc);
127 QStringList lamexp_query_translations(void);
128 void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version = 0, const QString *tag = NULL);
129 lamexp_icon_t *lamexp_set_window_icon(QWidget *window, const QIcon &icon, const bool bIsBigIcon);
130 bool lamexp_sheet_of_glass(QWidget *window);
131 bool lamexp_sheet_of_glass_update(QWidget *window);
132 bool lamexp_shutdown_computer(const QString &message, const unsigned long timeout = 30, const bool forceShutdown = true, const bool hibernate = false);
133 void lamexp_sleep(const unsigned int delay);
134 QColor lamexp_system_color(const int color_id);
135 const char *lamexp_support_url(void);
136 bool lamexp_themes_enabled(void);
137 unsigned int lamexp_tool_version(const QString &toolName, QString *tag = NULL);
138 unsigned int lamexp_toolver_coreaudio(void);
139 unsigned int lamexp_toolver_fhgaacenc(void);
140 unsigned int lamexp_toolver_neroaac(void);
141 unsigned int lamexp_toolver_qaacenc(void);
142 const char *lamexp_tracker_url(void);
143 unsigned int lamexp_translation_country(const QString &langId);
144 bool lamexp_translation_init(void);
145 QString lamexp_translation_name(const QString &language);
146 bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId, unsigned int &country);
147 unsigned int lamexp_translation_sysid(const QString &langId);
148 bool lamexp_update_sysmenu(const QWidget *win, const unsigned int identifier, const QString &text);
149 bool lamexp_user_is_admin(void);
150 const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText, const QString *tag = NULL);
151 unsigned int lamexp_version_build(void);
152 unsigned int lamexp_version_confg(void);
153 bool lamexp_version_demo(void);
154 QDate lamexp_version_expires(void);
155 unsigned int lamexp_version_major(void);
156 unsigned int lamexp_version_minor(void);
157 const char *lamexp_version_release(void);
158 const char *lamexp_website_url(void);
160 ///////////////////////////////////////////////////////////////////////////////
162 ///////////////////////////////////////////////////////////////////////////////
164 #define LAMEXP_CLOSE(HANDLE) do { if(HANDLE != NULL && HANDLE != INVALID_HANDLE_VALUE) { CloseHandle(HANDLE); HANDLE = NULL; } } while(0)
165 #define LAMEXP_MAKE_STRING_EX(X) #X
166 #define LAMEXP_MAKE_STRING(X) LAMEXP_MAKE_STRING_EX(X)
167 #define LAMEXP_SAFE_FREE(PTR) do { if(PTR) { free((void*) PTR); PTR = NULL; } } while(0)
168 #define LAMEXP_ZERO_MEMORY(X) memset(&(X), 0, sizeof((X)))
169 #define NOBR(STR) (QString("<nobr>%1</nobr>").arg((STR)).replace("-", "−"))
171 //Helper macro for throwing exceptions
172 #define THROW(MESSAGE) do \
174 throw std::runtime_error((MESSAGE)); \
177 #define THROW_FMT(FORMAT, ...) do \
179 char _error_msg[512]; \
180 _snprintf_s(_error_msg, 512, _TRUNCATE, (FORMAT), __VA_ARGS__); \
181 throw std::runtime_error(_error_msg); \
184 #define PRINT_ERROR(X, ...) do \
187 fprintf(stderr, (X), __VA_ARGS__); \
194 #define LAMEXP_MEMORY_CHECK(FUNC, RETV, ...) do \
196 size_t _privateBytesBefore = lamexp_dbg_private_bytes(); \
197 RETV = FUNC(__VA_ARGS__); \
198 size_t _privateBytesLeak = (lamexp_dbg_private_bytes() - _privateBytesBefore) / 1024; \
199 if(_privateBytesLeak > 0) { \
200 lamexp_dbg_dbg_output_string("\nMemory leak: Lost %u KiloBytes of PrivateUsage memory!\n\n", _privateBytesLeak); \
205 #define LAMEXP_MEMORY_CHECK(FUNC, RETV, ...) do \
207 RETV = __noop(__VA_ARGS__); \