diff options
author | George Hazan <george.hazan@gmail.com> | 2015-08-11 14:47:34 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-08-11 14:47:34 +0000 |
commit | eb031473db62a4fac910f7cb2d13765a753df92d (patch) | |
tree | fe35fc5ba40891644ede85b58cf7ef4b6e87f9c1 /plugins | |
parent | a15cd68f0412e1b211e746a2e4d5682e96f5a113 (diff) |
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@14912 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/ListeningTo/listeningto.vcxproj | 5 | ||||
-rw-r--r-- | plugins/ListeningTo/src/listeningto.cpp | 297 | ||||
-rw-r--r-- | plugins/ListeningTo/src/music.cpp | 49 | ||||
-rw-r--r-- | plugins/ListeningTo/src/options.cpp | 96 | ||||
-rw-r--r-- | plugins/ListeningTo/src/players/foobar.cpp | 10 | ||||
-rw-r--r-- | plugins/ListeningTo/src/players/generic.cpp | 328 | ||||
-rw-r--r-- | plugins/ListeningTo/src/players/itunes.cpp | 55 | ||||
-rw-r--r-- | plugins/ListeningTo/src/players/mradio.cpp | 14 | ||||
-rw-r--r-- | plugins/ListeningTo/src/players/player.cpp | 65 | ||||
-rw-r--r-- | plugins/ListeningTo/src/players/player.h | 10 | ||||
-rw-r--r-- | plugins/ListeningTo/src/players/watrack.cpp | 54 | ||||
-rw-r--r-- | plugins/ListeningTo/src/players/winamp.cpp | 4 | ||||
-rw-r--r-- | plugins/ListeningTo/src/players/wmp.cpp | 147 | ||||
-rw-r--r-- | plugins/ListeningTo/src/stdafx.h | 2 |
14 files changed, 435 insertions, 701 deletions
diff --git a/plugins/ListeningTo/listeningto.vcxproj b/plugins/ListeningTo/listeningto.vcxproj index 177acb87e2..ebcdceda4e 100644 --- a/plugins/ListeningTo/listeningto.vcxproj +++ b/plugins/ListeningTo/listeningto.vcxproj @@ -25,6 +25,11 @@ <ImportGroup Label="PropertySheets">
<Import Project="$(ProjectDir)..\..\build\vc.common\plugin.props" />
</ImportGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ </ClCompile>
+ </ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\utils\mir_buffer.h" />
<ClInclude Include="..\utils\mir_options.h" />
diff --git a/plugins/ListeningTo/src/listeningto.cpp b/plugins/ListeningTo/src/listeningto.cpp index 6c6007e8fe..d409406370 100644 --- a/plugins/ListeningTo/src/listeningto.cpp +++ b/plugins/ListeningTo/src/listeningto.cpp @@ -22,7 +22,7 @@ Boston, MA 02111-1307, USA. CLIST_INTERFACE *pcli;
int hLangpack;
-PLUGININFOEX pluginInfo={
+PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -33,7 +33,7 @@ PLUGININFOEX pluginInfo={ __AUTHORWEB,
UNICODE_AWARE,
// {F981F3F5-035A-444F-9892-CA722C195ADA}
- {0xf981f3f5, 0x35a, 0x444f, {0x98, 0x92, 0xca, 0x72, 0x2c, 0x19, 0x5a, 0xda}}
+ { 0xf981f3f5, 0x35a, 0x444f, { 0x98, 0x92, 0xca, 0x72, 0x2c, 0x19, 0x5a, 0xda } }
};
HINSTANCE hInst;
@@ -52,26 +52,26 @@ std::vector<ProtocolInfo> proto_items; int ModulesLoaded(WPARAM wParam, LPARAM lParam);
int PreShutdown(WPARAM wParam, LPARAM lParam);
-int PreBuildContactMenu(WPARAM wParam,LPARAM lParam);
+int PreBuildContactMenu(WPARAM wParam, LPARAM lParam);
int TopToolBarLoaded(WPARAM wParam, LPARAM lParam);
-int SettingChanged(WPARAM wParam,LPARAM lParam);
+int SettingChanged(WPARAM wParam, LPARAM lParam);
INT_PTR MainMenuClicked(WPARAM wParam, LPARAM lParam);
bool ListeningToEnabled(char *proto, bool ignoreGlobal = false);
INT_PTR ListeningToEnabled(WPARAM wParam, LPARAM lParam);
-INT_PTR EnableListeningTo(WPARAM wParam,LPARAM lParam);
+INT_PTR EnableListeningTo(WPARAM wParam, LPARAM lParam);
INT_PTR EnableListeningTo(char *proto = NULL, bool enabled = false);
-INT_PTR GetTextFormat(WPARAM wParam,LPARAM lParam);
+INT_PTR GetTextFormat(WPARAM wParam, LPARAM lParam);
TCHAR* GetParsedFormat(LISTENINGTOINFO *lti);
-INT_PTR GetParsedFormat(WPARAM wParam,LPARAM lParam);
-INT_PTR GetOverrideContactOption(WPARAM wParam,LPARAM lParam);
-INT_PTR GetUnknownText(WPARAM wParam,LPARAM lParam);
-INT_PTR SetNewSong(WPARAM wParam,LPARAM lParam);
+INT_PTR GetParsedFormat(WPARAM wParam, LPARAM lParam);
+INT_PTR GetOverrideContactOption(WPARAM wParam, LPARAM lParam);
+INT_PTR GetUnknownText(WPARAM wParam, LPARAM lParam);
+INT_PTR SetNewSong(WPARAM wParam, LPARAM lParam);
void SetExtraIcon(MCONTACT hContact, BOOL set);
void SetListeningInfos(LISTENINGTOINFO *lti = NULL);
-INT_PTR HotkeysEnable(WPARAM wParam,LPARAM lParam);
-INT_PTR HotkeysDisable(WPARAM wParam,LPARAM lParam);
-INT_PTR HotkeysToggle(WPARAM wParam,LPARAM lParam);
+INT_PTR HotkeysEnable(WPARAM wParam, LPARAM lParam);
+INT_PTR HotkeysDisable(WPARAM wParam, LPARAM lParam);
+INT_PTR HotkeysToggle(WPARAM wParam, LPARAM lParam);
TCHAR* VariablesParseInfo(ARGUMENTSINFO *ai);
TCHAR* VariablesParseType(ARGUMENTSINFO *ai);
@@ -93,13 +93,13 @@ TCHAR* VariablesParsePlayer(ARGUMENTSINFO *ai); // Functions ////////////////////////////////////////////////////////////////////////////
-extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
{
hInst = hinstDLL;
return TRUE;
}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
@@ -164,7 +164,7 @@ void UpdateGlobalStatusMenus() Menu_EnableItem(proto_items[0].hMenu, opts.enable_sending);
if (hTTB != NULL)
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM) hTTB, (LPARAM) (enabled ? TTBST_PUSHED : 0));
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTTB, (LPARAM)(enabled ? TTBST_PUSHED : 0));
}
@@ -181,8 +181,7 @@ void RebuildMenu() {
std::sort(proto_items.begin(), proto_items.end(), compareFunc());
- for (unsigned int i = 1; i < proto_items.size(); i++)
- {
+ for (unsigned int i = 1; i < proto_items.size(); i++) {
ProtocolInfo *info = &proto_items[i];
if (info->hMenu != NULL)
@@ -197,9 +196,9 @@ void RebuildMenu() mi.position = 500080000 + i;
mi.pszService = MS_LISTENINGTO_MAINMENU;
mi.name.t = text;
- mi.flags = CMIF_TCHAR
- | (ListeningToEnabled(info->proto, TRUE) ? CMIF_CHECKED : 0)
- | (opts.enable_sending ? 0 : CMIF_GRAYED);
+ mi.flags = CMIF_TCHAR
+ | (ListeningToEnabled(info->proto, TRUE) ? CMIF_CHECKED : 0)
+ | (opts.enable_sending ? 0 : CMIF_GRAYED);
info->hMenu = Menu_AddMainMenuItem(&mi);
}
@@ -213,10 +212,10 @@ void RegisterProtocol(char *proto, TCHAR *account) return;
size_t id = proto_items.size();
- proto_items.resize(id+1);
+ proto_items.resize(id + 1);
strncpy(proto_items[id].proto, proto, _countof(proto_items[id].proto));
- proto_items[id].proto[_countof(proto_items[id].proto)-1] = 0;
+ proto_items[id].proto[_countof(proto_items[id].proto) - 1] = 0;
mir_tstrncpy(proto_items[id].account, account, _countof(proto_items[id].account));
@@ -229,29 +228,24 @@ void RegisterProtocol(char *proto, TCHAR *account) int AccListChanged(WPARAM wParam, LPARAM lParam)
{
- PROTOACCOUNT *proto = (PROTOACCOUNT *) lParam;
+ PROTOACCOUNT *proto = (PROTOACCOUNT *)lParam;
if (proto == NULL)
return 0;
ProtocolInfo *info = GetProtoInfo(proto->szModuleName);
- if (info != NULL)
- {
- if (wParam == PRAC_UPGRADED || wParam == PRAC_CHANGED)
- {
+ if (info != NULL) {
+ if (wParam == PRAC_UPGRADED || wParam == PRAC_CHANGED) {
mir_tstrncpy(info->account, proto->tszAccountName, _countof(info->account));
TCHAR text[512];
mir_sntprintf(text, TranslateT("Send to %s"), info->account);
Menu_ModifyItem(info->hMenu, text);
}
- else if (wParam == PRAC_REMOVED || (wParam == PRAC_CHECKED && !proto->bIsEnabled))
- {
+ else if (wParam == PRAC_REMOVED || (wParam == PRAC_CHECKED && !proto->bIsEnabled)) {
Menu_RemoveItem(info->hMenu);
- for(std::vector<ProtocolInfo>::iterator it = proto_items.begin(); it != proto_items.end(); ++it)
- {
- if (&(*it) == info)
- {
+ for (std::vector<ProtocolInfo>::iterator it = proto_items.begin(); it != proto_items.end(); ++it) {
+ if (&(*it) == info) {
proto_items.erase(it);
break;
}
@@ -260,10 +254,8 @@ int AccListChanged(WPARAM wParam, LPARAM lParam) RebuildMenu();
}
}
- else
- {
- if (wParam == PRAC_ADDED || (wParam == PRAC_CHECKED && proto->bIsEnabled))
- {
+ else {
+ if (wParam == PRAC_ADDED || (wParam == PRAC_CHECKED && proto->bIsEnabled)) {
RegisterProtocol(proto->szModuleName, proto->tszAccountName);
RebuildMenu();
}
@@ -295,7 +287,7 @@ int ModulesLoaded(WPARAM, LPARAM) CMenuItem mi;
mi.position = 500080000;
mi.name.t = LPGENT("Listening to");
- mi.flags = CMIF_TCHAR;
+ mi.flags = CMIF_TCHAR;
mi.hIcolibItem = iconList[0].hIcolib;
hMainMenuGroup = Menu_AddMainMenuItem(&mi);
@@ -307,8 +299,8 @@ int ModulesLoaded(WPARAM, LPARAM) // Add all protos
mi.name.t = LPGENT("Send to all protocols");
mi.flags = CMIF_TCHAR
- | (ListeningToEnabled(NULL, true) ? CMIF_CHECKED : 0)
- | (opts.enable_sending ? 0 : CMIF_GRAYED);
+ | (ListeningToEnabled(NULL, true) ? CMIF_CHECKED : 0)
+ | (opts.enable_sending ? 0 : CMIF_GRAYED);
proto_items.resize(1);
proto_items[0].hMenu = Menu_AddMainMenuItem(&mi);
proto_items[0].proto[0] = 0;
@@ -320,7 +312,7 @@ int ModulesLoaded(WPARAM, LPARAM) // Add each proto
PROTOACCOUNT **protos;
int count;
- Proto_EnumAccounts(&count,&protos);
+ Proto_EnumAccounts(&count, &protos);
for (int i = 0; i < count; i++)
if (protos[i]->bIsEnabled)
@@ -334,7 +326,7 @@ int ModulesLoaded(WPARAM, LPARAM) // Variables support
if (ServiceExists(MS_VARS_REGISTERTOKEN)) {
- TOKENREGISTER tr = {0};
+ TOKENREGISTER tr = { 0 };
tr.cbSize = sizeof(TOKENREGISTER);
tr.memType = TR_MEM_MIRANDA;
tr.flags = TRF_FREEMEM | TRF_PARSEFUNC | TRF_FIELD | TRF_TCHAR;
@@ -342,56 +334,56 @@ int ModulesLoaded(WPARAM, LPARAM) tr.tszTokenString = _T("listening_info");
tr.parseFunctionT = VariablesParseInfo;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Listening info as set in the options");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.tszTokenString = _T("listening_type");
tr.parseFunctionT = VariablesParseType;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Media type: Music, Video, etc.");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.tszTokenString = _T("listening_artist");
tr.parseFunctionT = VariablesParseArtist;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Artist name");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.tszTokenString = _T("listening_album");
tr.parseFunctionT = VariablesParseAlbum;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Album name");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.tszTokenString = _T("listening_title");
tr.parseFunctionT = VariablesParseTitle;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Song name");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.tszTokenString = _T("listening_track");
tr.parseFunctionT = VariablesParseTrack;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Track number");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.tszTokenString = _T("listening_year");
tr.parseFunctionT = VariablesParseYear;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Song year");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.tszTokenString = _T("listening_genre");
tr.parseFunctionT = VariablesParseGenre;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Song genre");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.tszTokenString = _T("listening_length");
tr.parseFunctionT = VariablesParseLength;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Song length");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.tszTokenString = _T("listening_player");
tr.parseFunctionT = VariablesParsePlayer;
tr.szHelpText = LPGEN("Listening info") "\t" LPGEN("Player name");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
}
// Hotkeys support
- HOTKEYDESC hkd = {0};
+ HOTKEYDESC hkd = { 0 };
hkd.cbSize = sizeof(hkd);
hkd.pszSection = LPGEN("Listening to");
@@ -424,8 +416,7 @@ int PreShutdown(WPARAM, LPARAM) {
loaded = FALSE;
- if (hTimer != NULL)
- {
+ if (hTimer != NULL) {
KillTimer(NULL, hTimer);
hTimer = NULL;
}
@@ -464,7 +455,7 @@ int TopToolBarLoaded(WPARAM, LPARAM) return 0;
}
-INT_PTR MainMenuClicked(WPARAM wParam, LPARAM lParam)
+INT_PTR MainMenuClicked(WPARAM wParam, LPARAM)
{
if (!loaded)
return -1;
@@ -482,32 +473,28 @@ bool ListeningToEnabled(char *proto, bool ignoreGlobal) if (!ignoreGlobal && !opts.enable_sending)
return FALSE;
- if (proto == NULL || proto[0] == 0)
- {
+ if (proto == NULL || proto[0] == 0) {
// Check all protocols
- for (unsigned int i = 1; i < proto_items.size(); ++i)
- {
- if (!ListeningToEnabled(proto_items[i].proto, TRUE))
- {
+ for (unsigned int i = 1; i < proto_items.size(); ++i) {
+ if (!ListeningToEnabled(proto_items[i].proto, TRUE)) {
return FALSE;
}
}
return TRUE;
}
- else
- {
+ else {
char setting[256];
mir_snprintf(setting, "%sEnabled", proto);
return db_get_b(NULL, MODULE_NAME, setting, false) != 0;
}
}
-INT_PTR ListeningToEnabled(WPARAM wParam, LPARAM lParam)
+INT_PTR ListeningToEnabled(WPARAM wParam, LPARAM)
{
if (!loaded)
return -1;
- return ListeningToEnabled((char *)wParam) ;
+ return ListeningToEnabled((char *)wParam);
}
ProtocolInfo *GetProtoInfo(char *proto)
@@ -525,29 +512,25 @@ void SetListeningInfo(char *proto, LISTENINGTOINFO *lti = NULL) return;
if (ProtoServiceExists(proto, PS_SET_LISTENINGTO))
- CallProtoService(proto, PS_SET_LISTENINGTO, 0, (LPARAM) lti);
+ CallProtoService(proto, PS_SET_LISTENINGTO, 0, (LPARAM)lti);
else if (ProtoServiceExists(proto, PS_SETCUSTOMSTATUSEX)) {
if (opts.xstatus_set == IGNORE_XSTATUS)
return;
int status;
- CUSTOM_STATUS ics = {0};
+ CUSTOM_STATUS ics = { 0 };
ics.cbSize = sizeof(CUSTOM_STATUS);
ics.status = &status;
// Set or reset?
- if (lti == NULL)
- {
+ if (lti == NULL) {
// Reset -> only if is still in music xstatus
ics.flags = CSSF_MASK_STATUS;
- if (CallProtoService(proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM) &ics) || status != XSTATUS_MUSIC)
- {
- if (opts.xstatus_set == SET_XSTATUS)
- {
+ if (CallProtoService(proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&ics) || status != XSTATUS_MUSIC) {
+ if (opts.xstatus_set == SET_XSTATUS) {
ProtocolInfo *pi = GetProtoInfo(proto);
- if (pi != NULL)
- {
+ if (pi != NULL) {
pi->old_xstatus = 0;
pi->old_xstatus_name[0] = _T('\0');
pi->old_xstatus_message[0] = _T('\0');
@@ -556,8 +539,7 @@ void SetListeningInfo(char *proto, LISTENINGTOINFO *lti = NULL) return;
}
- if (opts.xstatus_set == CHECK_XSTATUS_MUSIC)
- {
+ if (opts.xstatus_set == CHECK_XSTATUS_MUSIC) {
// Set text to nothing
TCHAR *fr[] = {
_T("listening"), opts.nothing
@@ -568,76 +550,65 @@ void SetListeningInfo(char *proto, LISTENINGTOINFO *lti = NULL) Buffer<TCHAR> msg;
ReplaceTemplate(&msg, NULL, opts.xstatus_message, fr, _countof(fr));
- ics.flags = CSSF_TCHAR | CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE;
+ ics.flags = CSSF_TCHAR | CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE;
ics.ptszName = name.str;
ics.ptszMessage = msg.str;
- CallProtoService(proto, PS_SETCUSTOMSTATUSEX, 0, (LPARAM) &ics);
+ CallProtoService(proto, PS_SETCUSTOMSTATUSEX, 0, (LPARAM)&ics);
}
- else if (opts.xstatus_set == CHECK_XSTATUS)
- {
+ else if (opts.xstatus_set == CHECK_XSTATUS) {
status = 0;
ics.flags = CSSF_MASK_STATUS;
- CallProtoService(proto, PS_SETCUSTOMSTATUSEX, 0, (LPARAM) &ics);
+ CallProtoService(proto, PS_SETCUSTOMSTATUSEX, 0, (LPARAM)&ics);
}
- else
- {
+ else {
// Set to old text
ProtocolInfo *pi = GetProtoInfo(proto);
- if (pi != NULL)
- {
- ics.flags = CSSF_TCHAR | CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE;
+ if (pi != NULL) {
+ ics.flags = CSSF_TCHAR | CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE;
ics.status = &pi->old_xstatus;
ics.ptszName = pi->old_xstatus_name;
ics.ptszMessage = pi->old_xstatus_message;
}
- else
- {
+ else {
status = 0;
ics.flags = CSSF_MASK_STATUS;
}
- CallProtoService(proto, PS_SETCUSTOMSTATUSEX, 0, (LPARAM) &ics);
+ CallProtoService(proto, PS_SETCUSTOMSTATUSEX, 0, (LPARAM)&ics);
- if (pi != NULL)
- {
+ if (pi != NULL) {
pi->old_xstatus = 0;
pi->old_xstatus_name[0] = _T('\0');
pi->old_xstatus_message[0] = _T('\0');
}
}
}
- else
- {
+ else {
// Set it
- if (opts.xstatus_set == CHECK_XSTATUS_MUSIC)
- {
+ if (opts.xstatus_set == CHECK_XSTATUS_MUSIC) {
ics.flags = CSSF_MASK_STATUS;
- if (CallProtoService(proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM) &ics) || status != XSTATUS_MUSIC)
+ if (CallProtoService(proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&ics) || status != XSTATUS_MUSIC)
return;
}
- else if (opts.xstatus_set == CHECK_XSTATUS)
- {
+ else if (opts.xstatus_set == CHECK_XSTATUS) {
ics.flags = CSSF_MASK_STATUS;
- if (!CallProtoService(proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM) &ics) && status != XSTATUS_MUSIC && status != 0)
+ if (!CallProtoService(proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&ics) && status != XSTATUS_MUSIC && status != 0)
return;
}
- else
- {
+ else {
// Store old data
ics.flags = CSSF_MASK_STATUS;
- if (!CallProtoService(proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM) &ics) && status != XSTATUS_MUSIC)
- {
+ if (!CallProtoService(proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&ics) && status != XSTATUS_MUSIC) {
ProtocolInfo *pi = GetProtoInfo(proto);
- if (pi != NULL)
- {
- ics.flags = CSSF_TCHAR | CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE;
+ if (pi != NULL) {
+ ics.flags = CSSF_TCHAR | CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE;
ics.status = &pi->old_xstatus;
ics.ptszName = pi->old_xstatus_name;
ics.ptszMessage = pi->old_xstatus_message;
- CallProtoService(proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM) &ics);
+ CallProtoService(proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&ics);
}
}
}
@@ -661,23 +632,21 @@ void SetListeningInfo(char *proto, LISTENINGTOINFO *lti = NULL) ReplaceTemplate(&msg, NULL, opts.xstatus_message, fr, _countof(fr));
status = XSTATUS_MUSIC;
- ics.flags = CSSF_TCHAR | CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE;
+ ics.flags = CSSF_TCHAR | CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE;
ics.status = &status;
ics.ptszName = name.str;
ics.ptszMessage = msg.str;
- CallProtoService(proto, PS_SETCUSTOMSTATUSEX, 0, (LPARAM) &ics);
+ CallProtoService(proto, PS_SETCUSTOMSTATUSEX, 0, (LPARAM)&ics);
mir_free(fr[1]);
}
}
- else if (db_get_b(0,MODULE_NAME,"UseStatusMessage",1) && ProtoServiceExists(proto, PS_SETAWAYMSG))
- {
+ else if (db_get_b(0, MODULE_NAME, "UseStatusMessage", 1) && ProtoServiceExists(proto, PS_SETAWAYMSG)) {
int status = CallProtoService(proto, PS_GETSTATUS, 0, 0);
if (lti == NULL)
CallProtoService(proto, PS_SETAWAYMSG, status, 0);
- else
- {
+ else {
ptrT fr(GetParsedFormat(lti));
CallProtoService(proto, PS_SETAWAYMSG, status, fr);
}
@@ -689,14 +658,12 @@ INT_PTR EnableListeningTo(char *proto, bool enabled) if (!loaded)
return -1;
- if (proto == NULL || proto[0] == 0)
- {
+ if (proto == NULL || proto[0] == 0) {
// For all protocols
for (unsigned int i = 1; i < proto_items.size(); ++i)
EnableListeningTo(proto_items[i].proto, enabled);
}
- else
- {
+ else {
if (!ProtoServiceExists(proto, PS_SET_LISTENINGTO) && !ProtoServiceExists(proto, PS_SETCUSTOMSTATUSEX) && !ProtoServiceExists(proto, PS_SETAWAYMSG))
return 0;
@@ -706,12 +673,11 @@ INT_PTR EnableListeningTo(char *proto, bool enabled) // Modify menu info
ProtocolInfo *info = GetProtoInfo(proto);
- if (info != NULL)
- {
+ if (info != NULL) {
Menu_EnableItem(info->hMenu, opts.enable_sending);
Menu_SetChecked(info->hMenu, enabled);
- SetListeningInfo(proto,(opts.enable_sending && enabled) ? GetListeningInfo() : NULL);
+ SetListeningInfo(proto, (opts.enable_sending && enabled) ? GetListeningInfo() : NULL);
}
// Set all protos info
@@ -720,37 +686,37 @@ INT_PTR EnableListeningTo(char *proto, bool enabled) StartTimer();
- NotifyEventHooks(hEnableStateChangedEvent, (WPARAM) proto, (LPARAM) enabled);
+ NotifyEventHooks(hEnableStateChangedEvent, (WPARAM)proto, (LPARAM)enabled);
return 0;
}
-INT_PTR EnableListeningTo(WPARAM wParam,LPARAM lParam)
+INT_PTR EnableListeningTo(WPARAM wParam, LPARAM lParam)
{
return EnableListeningTo((char*)wParam, lParam != 0);
}
-INT_PTR HotkeysEnable(WPARAM,LPARAM lParam)
+INT_PTR HotkeysEnable(WPARAM, LPARAM lParam)
{
return EnableListeningTo(lParam, true);
}
-INT_PTR HotkeysDisable(WPARAM wParam,LPARAM lParam)
+INT_PTR HotkeysDisable(WPARAM, LPARAM lParam)
{
return EnableListeningTo(lParam, FALSE);
}
-INT_PTR HotkeysToggle(WPARAM,LPARAM lParam)
+INT_PTR HotkeysToggle(WPARAM, LPARAM lParam)
{
return EnableListeningTo(lParam, !ListeningToEnabled((char *)lParam, TRUE));
}
-INT_PTR GetTextFormat(WPARAM,LPARAM)
+INT_PTR GetTextFormat(WPARAM, LPARAM)
{
if (!loaded)
return NULL;
- return ( INT_PTR )mir_tstrdup(opts.templ);
+ return (INT_PTR)mir_tstrdup(opts.templ);
}
TCHAR *GetParsedFormat(LISTENINGTOINFO *lti)
@@ -775,20 +741,20 @@ TCHAR *GetParsedFormat(LISTENINGTOINFO *lti) return ret.detach();
}
-INT_PTR GetParsedFormat(WPARAM,LPARAM lParam)
+INT_PTR GetParsedFormat(WPARAM, LPARAM lParam)
{
- return ( INT_PTR )GetParsedFormat((LISTENINGTOINFO *) lParam);
+ return (INT_PTR)GetParsedFormat((LISTENINGTOINFO *)lParam);
}
-INT_PTR GetOverrideContactOption(WPARAM,LPARAM)
+INT_PTR GetOverrideContactOption(WPARAM, LPARAM)
{
- return ( INT_PTR )opts.override_contact_template;
+ return (INT_PTR)opts.override_contact_template;
}
-INT_PTR GetUnknownText(WPARAM,LPARAM)
+INT_PTR GetUnknownText(WPARAM, LPARAM)
{
- return ( INT_PTR )opts.unknown;
+ return (INT_PTR)opts.unknown;
}
void SetListeningInfos(LISTENINGTOINFO *lti)
@@ -812,7 +778,7 @@ void SetListeningInfos(LISTENINGTOINFO *lti) }
}
-static void CALLBACK GetInfoTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
+static void CALLBACK GetInfoTimer(HWND, UINT, UINT_PTR, DWORD)
{
if (hTimer != NULL) {
KillTimer(NULL, hTimer);
@@ -847,28 +813,21 @@ void StartTimer() // See if any protocol want Listening info
BOOL want = FALSE;
- if (opts.enable_sending)
- {
- if (!players[WATRACK]->enabled)
- {
+ if (opts.enable_sending) {
+ if (!players[WATRACK]->enabled) {
// See if any player needs it
BOOL needPoll = FALSE;
- for (int i = FIRST_PLAYER; i < NUM_PLAYERS; i++)
- {
- if (players[i]->needPoll)
- {
+ for (int i = FIRST_PLAYER; i < NUM_PLAYERS; i++) {
+ if (players[i]->needPoll) {
needPoll = TRUE;
break;
}
}
- if (needPoll)
- {
+ if (needPoll) {
// Now see protocols
- for (unsigned int i = 1; i < proto_items.size(); ++i)
- {
- if (ListeningToEnabled(proto_items[i].proto))
- {
+ for (unsigned int i = 1; i < proto_items.size(); ++i) {
+ if (ListeningToEnabled(proto_items[i].proto)) {
want = TRUE;
break;
}
@@ -877,20 +836,16 @@ void StartTimer() }
}
- if (want)
- {
+ if (want) {
if (hTimer == NULL)
hTimer = SetTimer(NULL, NULL, opts.time_to_pool * 1000, GetInfoTimer);
}
- else
- {
- if (hTimer != NULL)
- {
+ else {
+ if (hTimer != NULL) {
KillTimer(NULL, hTimer);
hTimer = NULL;
// To be sure that no one was left behind
-// m_log(_T("StartTimer"), _T("To be sure that no one was left behind"));
SetListeningInfos();
}
}
@@ -898,8 +853,7 @@ void StartTimer() void HasNewListeningInfo()
{
- if (hTimer != NULL)
- {
+ if (hTimer != NULL) {
KillTimer(NULL, hTimer);
hTimer = NULL;
}
@@ -913,7 +867,7 @@ void SetExtraIcon(MCONTACT hContact, BOOL set) ExtraIcon_SetIconByName(hExtraIcon, hContact, set ? "listening_to_icon" : NULL);
}
-int SettingChanged(WPARAM hContact,LPARAM lParam)
+int SettingChanged(WPARAM hContact, LPARAM lParam)
{
if (hContact == NULL)
return 0;
@@ -934,18 +888,18 @@ int SettingChanged(WPARAM hContact,LPARAM lParam) return 0;
}
-INT_PTR SetNewSong(WPARAM wParam,LPARAM lParam)
+INT_PTR SetNewSong(WPARAM wParam, LPARAM lParam)
{
if (lParam == NULL)
return -1;
if (lParam == LISTENINGTO_ANSI) {
- CharToWchar data((char *) wParam);
- ((GenericPlayer *) players[GENERIC])->NewData(data, mir_wstrlen(data));
+ CharToWchar data((char *)wParam);
+ ((GenericPlayer *)players[GENERIC])->NewData(data, mir_wstrlen(data));
}
else {
- WCHAR *data = (WCHAR *) wParam;
- ((GenericPlayer *) players[GENERIC])->NewData(data, mir_wstrlen(data));
+ WCHAR *data = (WCHAR *)wParam;
+ ((GenericPlayer *)players[GENERIC])->NewData(data, mir_wstrlen(data));
}
return 0;
@@ -957,8 +911,7 @@ TCHAR* VariablesParseInfo(ARGUMENTSINFO *ai) return NULL;
LISTENINGTOINFO *lti = GetListeningInfo();
- if (lti == NULL)
- {
+ if (lti == NULL) {
ai->flags = AIF_FALSE;
return mir_tstrdup(_T(""));
}
@@ -986,16 +939,16 @@ TCHAR* VariablesParseInfo(ARGUMENTSINFO *ai) \
LISTENINGTOINFO *lti = GetListeningInfo(); \
if (lti == NULL) \
- { \
+ { \
ai->flags = AIF_FALSE; \
return mir_tstrdup(_T("")); \
- } \
- else if (IsEmpty(lti->__field__)) \
+ } \
+ else if (IsEmpty(lti->__field__)) \
{ \
ai->flags = AIF_FALSE; \
return mir_tstrdup(opts.unknown); \
} \
- else \
+ else \
{ \
ai->flags = AIF_DONTPARSE; \
TCHAR *ret = mir_tstrdup(lti->__field__); \
diff --git a/plugins/ListeningTo/src/music.cpp b/plugins/ListeningTo/src/music.cpp index ca630a8a8c..2cc709e025 100644 --- a/plugins/ListeningTo/src/music.cpp +++ b/plugins/ListeningTo/src/music.cpp @@ -22,7 +22,7 @@ Boston, MA 02111-1307, USA. Player *players[NUM_PLAYERS];
static LISTENINGTOINFO current = {0};
-void InitMusic()
+void InitMusic()
{
players[WATRACK] = new WATrack();
players[GENERIC] = new GenericPlayer();
@@ -33,24 +33,20 @@ void InitMusic() players[MRADIO] = new MRadio();
}
-
void FreeMusic()
{
- for(int i = 0; i < NUM_PLAYERS; i++)
- {
+ for (int i = 0; i < NUM_PLAYERS; i++) {
delete players[i];
players[i] = NULL;
}
}
-
void EnableDisablePlayers()
{
- for(int i = 0; i < NUM_PLAYERS; i++)
+ for (int i = 0; i < NUM_PLAYERS; i++)
players[i]->EnableDisable();
}
-
void FreeListeningInfo(LISTENINGTOINFO *lti)
{
lti->cbSize = 0;
@@ -88,55 +84,43 @@ BOOL Equals(const LISTENINGTOINFO *lti1, const LISTENINGTOINFO *lti2) if (lti1->cbSize != lti2->cbSize)
return FALSE;
- return mir_tstrcmpi(lti1->ptszArtist, lti2->ptszArtist) == 0
- && mir_tstrcmpi(lti1->ptszAlbum, lti2->ptszAlbum) == 0
- && mir_tstrcmpi(lti1->ptszTitle, lti2->ptszTitle) == 0
- && mir_tstrcmpi(lti1->ptszTrack, lti2->ptszTrack) == 0
- && mir_tstrcmpi(lti1->ptszYear, lti2->ptszYear) == 0
- && mir_tstrcmpi(lti1->ptszGenre, lti2->ptszGenre) == 0
- && mir_tstrcmpi(lti1->ptszLength, lti2->ptszLength) == 0
- && mir_tstrcmpi(lti1->ptszPlayer, lti2->ptszPlayer) == 0
+ return mir_tstrcmpi(lti1->ptszArtist, lti2->ptszArtist) == 0
+ && mir_tstrcmpi(lti1->ptszAlbum, lti2->ptszAlbum) == 0
+ && mir_tstrcmpi(lti1->ptszTitle, lti2->ptszTitle) == 0
+ && mir_tstrcmpi(lti1->ptszTrack, lti2->ptszTrack) == 0
+ && mir_tstrcmpi(lti1->ptszYear, lti2->ptszYear) == 0
+ && mir_tstrcmpi(lti1->ptszGenre, lti2->ptszGenre) == 0
+ && mir_tstrcmpi(lti1->ptszLength, lti2->ptszLength) == 0
+ && mir_tstrcmpi(lti1->ptszPlayer, lti2->ptszPlayer) == 0
&& mir_tstrcmpi(lti1->ptszType, lti2->ptszType) == 0;
}
int ChangedListeningInfo()
{
-// m_log(_T("ChangedListeningInfo"), _T("Start"));
-
BOOL changed = FALSE;
BOOL playing = FALSE;
int first = (players[WATRACK]->enabled ? WATRACK : GENERIC);
int last = (players[WATRACK]->enabled ? WATRACK + 1 : NUM_PLAYERS);
- for (int i = first; i < last; i++)
- {
+ for (int i = first; i < last; i++) {
if (!players[i]->enabled)
continue;
- LISTENINGTOINFO lti = {0};
+ LISTENINGTOINFO lti = { 0 };
if (!players[i]->GetListeningInfo(<i))
continue;
- if (!IsTypeEnabled(<i))
- {
+ if (!IsTypeEnabled(<i)) {
FreeListeningInfo(<i);
continue;
}
playing = TRUE;
-// m_log(_T("ChangedListeningInfo"), _T("Has : %s : %d"), players[i]->name, lti.cbSize);
-
if (Equals(¤t, <i))
- {
-// m_log(_T("ChangedListeningInfo"), _T("Is equals"));
FreeListeningInfo(<i);
- }
- else
- {
-// m_log(_T("ChangedListeningInfo"), _T("Is different"));
-
+ else {
FreeListeningInfo(¤t);
memcpy(¤t, <i, sizeof(current));
@@ -147,8 +131,7 @@ int ChangedListeningInfo() break;
}
- if (!playing && current.cbSize != 0)
- {
+ if (!playing && current.cbSize != 0) {
FreeListeningInfo(¤t);
changed = 1;
}
diff --git a/plugins/ListeningTo/src/options.cpp b/plugins/ListeningTo/src/options.cpp index 722300ee90..dce4ddc50c 100644 --- a/plugins/ListeningTo/src/options.cpp +++ b/plugins/ListeningTo/src/options.cpp @@ -35,44 +35,44 @@ static INT_PTR CALLBACK PlayersDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP static INT_PTR CALLBACK FormatDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-static OptPageControl optionsControls[] = {
- { &opts.enable_sending, CONTROL_CHECKBOX, IDC_ENABLE_SEND, "EnableSend", TRUE },
- { &opts.enable_music, CONTROL_CHECKBOX, IDC_ENABLE_MUSIC, "EnableMusic", TRUE },
- { &opts.enable_radio, CONTROL_CHECKBOX, IDC_ENABLE_RADIO, "EnableRadio", TRUE },
- { &opts.enable_video, CONTROL_CHECKBOX, IDC_ENABLE_VIDEO, "EnableVideo", TRUE },
- { &opts.enable_others, CONTROL_CHECKBOX, IDC_ENABLE_OTHERS, "EnableOthers", TRUE },
- { &opts.xstatus_set, CONTROL_RADIO, IDC_SET_XSTATUS, "XStatusSet", 0, SET_XSTATUS },
- { &opts.xstatus_set, CONTROL_RADIO, IDC_CHECK_XSTATUS, "XStatusSet", 0, CHECK_XSTATUS },
- { &opts.xstatus_set, CONTROL_RADIO, IDC_CHECK_XSTATUS_MUSIC, "XStatusSet", 0, CHECK_XSTATUS_MUSIC },
- { &opts.xstatus_set, CONTROL_RADIO, IDC_IGNORE_XSTATUS, "XStatusSet", 0, IGNORE_XSTATUS },
- { &opts.override_contact_template, CONTROL_CHECKBOX, IDC_OVERRIDE_CONTACTS_TEMPLATE, "OverrideContactsTemplate", FALSE},
- { &opts.show_adv_icon, CONTROL_CHECKBOX, IDC_SHOW_ADV_ICON, "ShowAdvancedIcon", FALSE},
- { &opts.adv_icon_slot, CONTROL_COMBO, IDC_ADV_ICON, "AdvancedIconSlot", 1}
+static OptPageControl optionsControls[] = {
+ { &opts.enable_sending, CONTROL_CHECKBOX, IDC_ENABLE_SEND, "EnableSend", TRUE },
+ { &opts.enable_music, CONTROL_CHECKBOX, IDC_ENABLE_MUSIC, "EnableMusic", TRUE },
+ { &opts.enable_radio, CONTROL_CHECKBOX, IDC_ENABLE_RADIO, "EnableRadio", TRUE },
+ { &opts.enable_video, CONTROL_CHECKBOX, IDC_ENABLE_VIDEO, "EnableVideo", TRUE },
+ { &opts.enable_others, CONTROL_CHECKBOX, IDC_ENABLE_OTHERS, "EnableOthers", TRUE },
+ { &opts.xstatus_set, CONTROL_RADIO, IDC_SET_XSTATUS, "XStatusSet", 0, SET_XSTATUS },
+ { &opts.xstatus_set, CONTROL_RADIO, IDC_CHECK_XSTATUS, "XStatusSet", 0, CHECK_XSTATUS },
+ { &opts.xstatus_set, CONTROL_RADIO, IDC_CHECK_XSTATUS_MUSIC, "XStatusSet", 0, CHECK_XSTATUS_MUSIC },
+ { &opts.xstatus_set, CONTROL_RADIO, IDC_IGNORE_XSTATUS, "XStatusSet", 0, IGNORE_XSTATUS },
+ { &opts.override_contact_template, CONTROL_CHECKBOX, IDC_OVERRIDE_CONTACTS_TEMPLATE, "OverrideContactsTemplate", FALSE },
+ { &opts.show_adv_icon, CONTROL_CHECKBOX, IDC_SHOW_ADV_ICON, "ShowAdvancedIcon", FALSE },
+ { &opts.adv_icon_slot, CONTROL_COMBO, IDC_ADV_ICON, "AdvancedIconSlot", 1 }
};
-static OptPageControl formatControls[] = {
- { &opts.templ, CONTROL_TEXT, IDC_TEMPLATE, "Template", (DWORD) _T("%artist% - %title%") },
- { &opts.unknown, CONTROL_TEXT, IDC_UNKNOWN, "Unknown", (DWORD) LPGENT("<Unknown>"), 0, 0, 128 },
- { &opts.xstatus_name, CONTROL_TEXT, IDC_XSTATUS_NAME, "XStatusName", (DWORD) LPGENT("Listening to") },
- { &opts.xstatus_message, CONTROL_TEXT, IDC_XSTATUS_MESSAGE, "XStatusMessage", (DWORD) _T("%listening%") },
- { &opts.nothing, CONTROL_TEXT, IDC_NOTHING, "Nothing", (DWORD) LPGENT("<Nothing is playing now>"), 0, 0, 128 }
+static OptPageControl formatControls[] = {
+ { &opts.templ, CONTROL_TEXT, IDC_TEMPLATE, "Template", (DWORD)_T("%artist% - %title%") },
+ { &opts.unknown, CONTROL_TEXT, IDC_UNKNOWN, "Unknown", (DWORD)LPGENT("<Unknown>"), 0, 0, 128 },
+ { &opts.xstatus_name, CONTROL_TEXT, IDC_XSTATUS_NAME, "XStatusName", (DWORD)LPGENT("Listening to") },
+ { &opts.xstatus_message, CONTROL_TEXT, IDC_XSTATUS_MESSAGE, "XStatusMessage", (DWORD)_T("%listening%") },
+ { &opts.nothing, CONTROL_TEXT, IDC_NOTHING, "Nothing", (DWORD)LPGENT("<Nothing is playing now>"), 0, 0, 128 }
};
-static OptPageControl playersControls[] = {
- { NULL, CONTROL_CHECKBOX, IDC_WATRACK, "GetInfoFromWATrack", FALSE },
- { &opts.time_to_pool, CONTROL_SPIN, IDC_POLL_TIMER, "TimeToPool", (WORD) 5, IDC_POLL_TIMER_SPIN, (WORD) 1, (WORD) 255 },
- { NULL, CONTROL_CHECKBOX, IDC_WINAMP, "EnableWinamp", TRUE },
- { NULL, CONTROL_CHECKBOX, IDC_ITUNES, "EnableITunes", TRUE },
- { NULL, CONTROL_CHECKBOX, IDC_WMP, "EnableWMP", TRUE },
- { NULL, CONTROL_CHECKBOX, IDC_FOOBAR, "EnableFoobar", TRUE },
- { NULL, CONTROL_CHECKBOX, IDC_MRADIO, "EnableMRadio", TRUE },
- { &opts.enable_other_players, CONTROL_CHECKBOX, IDC_OTHER, "EnableOtherPlayers", TRUE },
- { &opts.enable_code_injection, CONTROL_CHECKBOX, IDC_CODE_INJECTION, "EnableCodeInjection", TRUE }
+static OptPageControl playersControls[] = {
+ { NULL, CONTROL_CHECKBOX, IDC_WATRACK, "GetInfoFromWATrack", FALSE },
+ { &opts.time_to_pool, CONTROL_SPIN, IDC_POLL_TIMER, "TimeToPool", (WORD)5, IDC_POLL_TIMER_SPIN, (WORD)1, (WORD)255 },
+ { NULL, CONTROL_CHECKBOX, IDC_WINAMP, "EnableWinamp", TRUE },
+ { NULL, CONTROL_CHECKBOX, IDC_ITUNES, "EnableITunes", TRUE },
+ { NULL, CONTROL_CHECKBOX, IDC_WMP, "EnableWMP", TRUE },
+ { NULL, CONTROL_CHECKBOX, IDC_FOOBAR, "EnableFoobar", TRUE },
+ { NULL, CONTROL_CHECKBOX, IDC_MRADIO, "EnableMRadio", TRUE },
+ { &opts.enable_other_players, CONTROL_CHECKBOX, IDC_OTHER, "EnableOtherPlayers", TRUE },
+ { &opts.enable_code_injection, CONTROL_CHECKBOX, IDC_CODE_INJECTION, "EnableCodeInjection", TRUE }
};
// Functions //////////////////////////////////////////////////////////////////////////////////////
-int InitOptionsCallback(WPARAM wParam,LPARAM lParam)
+int InitOptionsCallback(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.hInstance = hInst;
@@ -113,13 +113,11 @@ void InitOptions() hOptHook = HookEvent(ME_OPT_INITIALISE, InitOptionsCallback);
}
-
void DeInitOptions()
{
UnhookEvent(hOptHook);
}
-
void LoadOptions()
{
LoadOpts(optionsControls, _countof(optionsControls), MODULE_NAME);
@@ -127,13 +125,11 @@ void LoadOptions() LoadOpts(playersControls, _countof(playersControls), MODULE_NAME);
}
-
BOOL IsTypeEnabled(LISTENINGTOINFO *lti)
{
if (lti == NULL)
return TRUE;
-
if (lti->dwFlags & LTI_UNICODE) {
if (mir_tstrcmpi(lti->ptszType, LPGENT("Music")) == 0)
return opts.enable_music;
@@ -143,9 +139,7 @@ BOOL IsTypeEnabled(LISTENINGTOINFO *lti) return opts.enable_video;
return opts.enable_others;
}
- else
-
- {
+ else {
if (strcmpi(lti->pszType, "Music") == 0)
return opts.enable_music;
if (strcmpi(lti->pszType, "Radio") == 0)
@@ -178,9 +172,9 @@ static void OptionsEnableDisableCtrls(HWND hwndDlg) }
-static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- BOOL ret;
+ BOOL ret = FALSE;
if (msg != WM_INITDIALOG)
ret = SaveOptsDlgProc(optionsControls, _countof(optionsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
@@ -194,19 +188,19 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP // Init combo
int total = EXTRA_ICON_COUNT, first = 0;
- SendDlgItemMessage(hwndDlg, IDC_ADV_ICON, CB_ADDSTRING, 0, (LPARAM) _T("1"));
- SendDlgItemMessage(hwndDlg, IDC_ADV_ICON, CB_ADDSTRING, 0, (LPARAM) _T("2"));
+ SendDlgItemMessage(hwndDlg, IDC_ADV_ICON, CB_ADDSTRING, 0, (LPARAM)_T("1"));
+ SendDlgItemMessage(hwndDlg, IDC_ADV_ICON, CB_ADDSTRING, 0, (LPARAM)_T("2"));
if (total > 0) {
TCHAR tmp[10];
for (int i = first; i <= total; i++)
- SendDlgItemMessage(hwndDlg, IDC_ADV_ICON, CB_ADDSTRING, 0, (LPARAM) _itot(i - first + 3, tmp, 10));
+ SendDlgItemMessage(hwndDlg, IDC_ADV_ICON, CB_ADDSTRING, 0, (LPARAM)_itot(i - first + 3, tmp, 10));
}
}
ret = SaveOptsDlgProc(optionsControls, _countof(optionsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
OptionsEnableDisableCtrls(hwndDlg);
- break;
+ return TRUE;
case WM_NOTIFY:
{
@@ -215,7 +209,6 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP RebuildMenu();
StartTimer();
}
-
}
break;
@@ -233,16 +226,14 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP return ret;
}
-
int playerDlgs[] = {
- WINAMP, IDC_WINAMP,
- WMP, IDC_WMP,
+ WINAMP, IDC_WINAMP,
+ WMP, IDC_WMP,
ITUNES, IDC_ITUNES,
FOOBAR, IDC_FOOBAR,
MRADIO, IDC_MRADIO
};
-
static void PlayersEnableDisableCtrls(HWND hwndDlg)
{
BOOL watrack_found = ServiceExists(MS_WAT_GETMUSICINFO);
@@ -253,8 +244,8 @@ static void PlayersEnableDisableCtrls(HWND hwndDlg) BOOL needPoll = FALSE;
for (int i = 0; i < _countof(playerDlgs); i += 2) {
- EnableWindow(GetDlgItem(hwndDlg, playerDlgs[i+1]), enabled);
- if (players[playerDlgs[i]]->needPoll && IsDlgButtonChecked(hwndDlg, playerDlgs[i+1]))
+ EnableWindow(GetDlgItem(hwndDlg, playerDlgs[i + 1]), enabled);
+ if (players[playerDlgs[i]]->needPoll && IsDlgButtonChecked(hwndDlg, playerDlgs[i + 1]))
needPoll = TRUE;
}
@@ -267,7 +258,7 @@ static void PlayersEnableDisableCtrls(HWND hwndDlg) EnableWindow(GetDlgItem(hwndDlg, IDC_CODE_INJECTION), enabled);
}
-static INT_PTR CALLBACK PlayersDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK PlayersDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
BOOL ret = SaveOptsDlgProc(playersControls, _countof(playersControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
@@ -295,8 +286,7 @@ static INT_PTR CALLBACK PlayersDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP return ret;
}
-static INT_PTR CALLBACK FormatDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK FormatDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
return SaveOptsDlgProc(formatControls, _countof(formatControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
}
-
diff --git a/plugins/ListeningTo/src/players/foobar.cpp b/plugins/ListeningTo/src/players/foobar.cpp index 2b27f8d7a7..a0198f18fa 100644 --- a/plugins/ListeningTo/src/players/foobar.cpp +++ b/plugins/ListeningTo/src/players/foobar.cpp @@ -20,14 +20,14 @@ Boston, MA 02111-1307, USA. #include "..\stdafx.h"
static TCHAR *wcs[] = {
- _T("{DA7CD0DE-1602-45e6-89A1-C2CA151E008E}/1"), // Foobar 0.9.1
- _T("{DA7CD0DE-1602-45e6-89A1-C2CA151E008E}"),
- _T("{97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}"), // Foobar 0.9.5.3
- _T("{E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8}"), // Foobar Columns UI
+ _T("{DA7CD0DE-1602-45e6-89A1-C2CA151E008E}/1"), // Foobar 0.9.1
+ _T("{DA7CD0DE-1602-45e6-89A1-C2CA151E008E}"),
+ _T("{97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}"), // Foobar 0.9.5.3
+ _T("{E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8}"), // Foobar Columns UI
};
Foobar::Foobar()
-{
+{
name = _T("foobar2000");
window_classes = wcs;
num_window_classes = _countof(wcs);
diff --git a/plugins/ListeningTo/src/players/generic.cpp b/plugins/ListeningTo/src/players/generic.cpp index cc0ecae708..dcf7ba02df 100644 --- a/plugins/ListeningTo/src/players/generic.cpp +++ b/plugins/ListeningTo/src/players/generic.cpp @@ -19,51 +19,52 @@ Boston, MA 02111-1307, USA. #include "..\stdafx.h"
-static LRESULT CALLBACK ReceiverWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
-
static UINT hTimer = NULL;
+static HANDLE hLog = NULL;
GenericPlayer *singleton = NULL;
-int m_log(const TCHAR *function, const TCHAR *fmt, ...)
+void m_log(const TCHAR *function, const TCHAR *fmt, ...)
{
-#if 0
- va_list va;
- TCHAR text[1024];
- size_t len;
-
- len = mir_sntprintf(text, _T("[%08u - %08u] [%s] "),
- GetCurrentThreadId(), GetTickCount(), function);
+ if (hLog == NULL) {
+ hLog = mir_createLog(MODULE_NAME, _T("ListeningTo log"), _T("c:\\temp\\listeningto.txt"), 0);
+ if (hLog == NULL)
+ return;
+ }
- va_start(va, fmt);
- mir_vsntprintf(&text[len], _countof(text) - len, fmt, va);
- va_end(va);
+ mir_writeLogT(hLog, _T("%s: "), function);
- BOOL writeBOM = (GetFileAttributes(_T("c:\\miranda_listeningto.log.txt")) == INVALID_FILE_ATTRIBUTES);
+ va_list args;
+ va_start(args, fmt);
+ mir_writeLogVT(hLog, fmt, args);
+}
- FILE *fp = _tfopen(_T("c:\\miranda_listeningto.log.txt"), _T("ab"));
+static LRESULT CALLBACK ReceiverWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message) {
+ case WM_COPYDATA:
+ if (loaded) {
+ COPYDATASTRUCT *pData = (PCOPYDATASTRUCT)lParam;
+ if (pData == NULL || pData->dwData != MIRANDA_DW_PROTECTION || pData->cbData == 0 || pData->lpData == NULL)
+ return FALSE;
- if (fp != NULL)
- {
+ if (singleton != NULL)
+ singleton->NewData((WCHAR *)pData->lpData, pData->cbData / 2);
- if (writeBOM)
- fwprintf(fp, L"\xFEFF");
+ return TRUE;
+ }
+ break;
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
- _ftprintf(fp, _T("%s\r\n"), text);
- fclose(fp);
- return 0;
+ default:
+ return DefWindowProc(hWnd, message, wParam, lParam);
}
- else
- {
- return -1;
- }
-#else
return 0;
-#endif
}
-
GenericPlayer::GenericPlayer()
{
name = _T("GenericPlayer");
@@ -72,23 +73,22 @@ GenericPlayer::GenericPlayer() received[0] = L'\0';
singleton = this;
- WNDCLASS wc = {0};
- wc.lpfnWndProc = ReceiverWndProc;
- wc.hInstance = hInst;
- wc.lpszClassName = MIRANDA_WINDOWCLASS;
+ WNDCLASS wc = { 0 };
+ wc.lpfnWndProc = ReceiverWndProc;
+ wc.hInstance = hInst;
+ wc.lpszClassName = MIRANDA_WINDOWCLASS;
RegisterClass(&wc);
- hWnd = CreateWindow(MIRANDA_WINDOWCLASS, LPGENT("Miranda ListeningTo receiver"),
- 0, 0, 0, 0, 0, NULL, NULL, hInst, NULL);
+ hWnd = CreateWindow(MIRANDA_WINDOWCLASS, LPGENT("Miranda ListeningTo receiver"),
+ 0, 0, 0, 0, 0, NULL, NULL, hInst, NULL);
}
GenericPlayer::~GenericPlayer()
{
- if (hTimer != NULL)
- {
+ if (hTimer != NULL) {
KillTimer(NULL, hTimer);
hTimer = NULL;
}
@@ -104,133 +104,101 @@ GenericPlayer::~GenericPlayer() void GenericPlayer::ProcessReceived()
{
- EnterCriticalSection(&cs);
-
- // Do the processing
- // L"<Status 0-stoped 1-playing>\\0<Player>\\0<Type>\\0<Title>\\0<Artist>\\0<Album>\\0<Track>\\0<Year>\\0<Genre>\\0<Length (secs)>\\0\\0"
-
- WCHAR *p1 = wcsstr(received, L"\\0");
-
- if (IsEmpty(received) || p1 == NULL)
{
-// if (received[0] == L'\0')
-// m_log(_T("ProcessReceived"), _T("ERROR: Empty text"));
-// else
-// m_log(_T("ProcessReceived"), _T("ERROR: No \\0 found"));
-
- // Ignore
- LeaveCriticalSection(&cs);
- return;
- }
-
- // Process string
- WCHAR *parts[11] = {0};
- int pCount = 0;
- WCHAR *p = received;
- do {
- *p1 = _T('\0');
+ mir_cslock lck(cs);
+
+ // Do the processing
+ // L"<Status 0-stoped 1-playing>\\0<Player>\\0<Type>\\0<Title>\\0<Artist>\\0<Album>\\0<Track>\\0<Year>\\0<Genre>\\0<Length (secs)>\\0\\0"
+
+ WCHAR *p1 = wcsstr(received, L"\\0");
+ if (IsEmpty(received) || p1 == NULL)
+ return;
+
+ // Process string
+ WCHAR *parts[11] = { 0 };
+ int pCount = 0;
+ WCHAR *p = received;
+ do {
+ *p1 = _T('\0');
+ parts[pCount] = p;
+ pCount++;
+ p = p1 + 2;
+ p1 = wcsstr(p, _T("\\0"));
+ } while (p1 != NULL && pCount < 10);
+ if (p1 != NULL)
+ *p1 = _T('\0');
parts[pCount] = p;
- pCount ++;
- p = p1 + 2;
- p1 = wcsstr(p, _T("\\0"));
- } while( p1 != NULL && pCount < 10 );
- if (p1 != NULL)
- *p1 = _T('\0');
- parts[pCount] = p;
-
- if (pCount < 5)
- {
-// m_log(_T("ProcessReceived"), _T("ERROR: Too little pieces"));
- // Ignore
- LeaveCriticalSection(&cs);
- return;
- }
+ if (pCount < 5)
+ return;
- // See if player is enabled
- Player *player = this;
- for (int i = FIRST_PLAYER; i < NUM_PLAYERS; i++)
- {
+ // See if player is enabled
+ Player *player = this;
+ for (int i = FIRST_PLAYER; i < NUM_PLAYERS; i++) {
- WCHAR *player_name = players[i]->name;
+ WCHAR *player_name = players[i]->name;
- if (_wcsicmp(parts[1], player_name) == 0)
- {
- player = players[i];
- break;
+ if (_wcsicmp(parts[1], player_name) == 0) {
+ player = players[i];
+ break;
+ }
}
- }
-
-
- player->FreeData();
-
- if (wcscmp(L"1", parts[0]) != 0 || IsEmpty(parts[1]) || (IsEmpty(parts[3]) && IsEmpty(parts[4])))
- {
- // Stoped playing or not enought info
+ player->FreeData();
-// if (wcscmp(L"1", parts[0]) != 0)
-// m_log(_T("ProcessReceived"), _T("END: Stoped playing"));
-// else
-// m_log(_T("ProcessReceived"), _T("ERROR: not enought info"));
- }
- else
- {
- LISTENINGTOINFO *li = player->LockListeningInfo();
-
- li->cbSize = sizeof(listening_info);
- li->dwFlags = LTI_TCHAR;
- li->ptszType = U2TD(parts[2], _T("Music"));
- li->ptszTitle = U2T(parts[3]);
- li->ptszArtist = U2T(parts[4]);
- li->ptszAlbum = U2T(parts[5]);
- li->ptszTrack = U2T(parts[6]);
- li->ptszYear = U2T(parts[7]);
- li->ptszGenre = U2T(parts[8]);
-
- if (player == this)
- li->ptszPlayer = mir_u2t(parts[1]);
- else
- li->ptszPlayer = mir_tstrdup(player->name);
-
- if (parts[9] != NULL)
- {
- long length = _wtoi(parts[9]);
- if (length > 0)
- {
- li->ptszLength = (TCHAR*) mir_alloc(10 * sizeof(TCHAR));
-
- int s = length % 60;
- int m = (length / 60) % 60;
- int h = (length / 60) / 60;
-
- if (h > 0)
- mir_sntprintf(li->ptszLength, 9, _T("%d:%02d:%02d"), h, m, s);
- else
- mir_sntprintf(li->ptszLength, 9, _T("%d:%02d"), m, s);
+ if (wcscmp(L"1", parts[0]) != 0 || IsEmpty(parts[1]) || (IsEmpty(parts[3]) && IsEmpty(parts[4]))) {
+ // Stoped playing or not enought info
+ }
+ else {
+ mir_cslock lck(player->GetLock());
+ LISTENINGTOINFO *li = player->GetInfo();
+
+ li->cbSize = sizeof(listening_info);
+ li->dwFlags = LTI_TCHAR;
+ li->ptszType = U2TD(parts[2], _T("Music"));
+ li->ptszTitle = U2T(parts[3]);
+ li->ptszArtist = U2T(parts[4]);
+ li->ptszAlbum = U2T(parts[5]);
+ li->ptszTrack = U2T(parts[6]);
+ li->ptszYear = U2T(parts[7]);
+ li->ptszGenre = U2T(parts[8]);
+
+ if (player == this)
+ li->ptszPlayer = mir_u2t(parts[1]);
+ else
+ li->ptszPlayer = mir_tstrdup(player->name);
+
+ if (parts[9] != NULL) {
+ long length = _wtoi(parts[9]);
+ if (length > 0) {
+ li->ptszLength = (TCHAR*)mir_alloc(10 * sizeof(TCHAR));
+
+ int s = length % 60;
+ int m = (length / 60) % 60;
+ int h = (length / 60) / 60;
+
+ if (h > 0)
+ mir_sntprintf(li->ptszLength, 9, _T("%d:%02d:%02d"), h, m, s);
+ else
+ mir_sntprintf(li->ptszLength, 9, _T("%d:%02d"), m, s);
+ }
}
}
- player->ReleaseListeningInfo();
- }
-
- // Put back the '\\'s
- for(int i = 1; i <= pCount; i++)
- *(parts[i] - 2) = L'\\';
- if (p1 != NULL)
- *p1 = L'\\';
-
- wcscpy(last_received, received);
+ // Put back the '\\'s
+ for (int i = 1; i <= pCount; i++)
+ *(parts[i] - 2) = L'\\';
+ if (p1 != NULL)
+ *p1 = L'\\';
- LeaveCriticalSection(&cs);
+ wcscpy(last_received, received);
+ }
NotifyInfoChanged();
-
-// m_log(_T("ProcessReceived"), _T("END: Success"));
}
-static VOID CALLBACK SendTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
+static VOID CALLBACK SendTimerProc(HWND, UINT, UINT_PTR, DWORD)
{
KillTimer(NULL, hTimer);
hTimer = NULL;
@@ -238,8 +206,6 @@ static VOID CALLBACK SendTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD if (!loaded)
return;
-// m_log(_T("SendTimerProc"), _T("It's time to process"));
-
if (singleton != NULL)
singleton->ProcessReceived();
}
@@ -247,80 +213,18 @@ static VOID CALLBACK SendTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD void GenericPlayer::NewData(const WCHAR *data, size_t len)
{
-// m_log(_T("NewData"), _T("Processing"));
-
if (data[0] == _T('\0'))
- {
-// m_log(_T("NewData"), _T("ERROR: Text is empty"));
return;
- }
- EnterCriticalSection(&cs);
+ mir_cslock lck(cs);
len = min(len, 1023);
- if (wcsncmp(received, data, len) != 0)
- {
-// m_log(_T("NewData"), _T("Got new text, scheduling update"));
-
+ if (wcsncmp(received, data, len) != 0) {
wcsncpy(received, data, len);
received[len] = L'\0';
-
-// m_log(_T("NewData"), _T("Text: %s"), received);
-
-
if (hTimer)
KillTimer(NULL, hTimer);
hTimer = SetTimer(NULL, NULL, 300, SendTimerProc); // Do the processing after we return true
}
-// else
-// {
-// m_log(_T("NewData"), _T("END: Text is the same as last time"));
-// }
-
- LeaveCriticalSection(&cs);
-}
-
-
-static LRESULT CALLBACK ReceiverWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch (message)
- {
- case WM_COPYDATA:
- {
- if (!loaded)
- return FALSE;
-
-// m_log(_T("ReceiverWndProc"), _T("START: Received message"));
-
- COPYDATASTRUCT* pData = (PCOPYDATASTRUCT) lParam;
- if (pData == NULL || pData->dwData != MIRANDA_DW_PROTECTION
- || pData->cbData == 0 || pData->lpData == NULL)
- {
-/* if (pData == NULL)
- m_log(_T("ReceiverWndProc"), _T("ERROR: COPYDATASTRUCT* is NULL"));
- else if (pData->dwData != MIRANDA_DW_PROTECTION)
- m_log(_T("ReceiverWndProc"), _T("ERROR: pData->dwData is incorrect"));
- else if (pData->cbData == 0)
- m_log(_T("ReceiverWndProc"), _T("ERROR: pData->cbData is 0"));
- else if (pData->lpData == NULL)
- m_log(_T("ReceiverWndProc"), _T("ERROR: pData->lpData is NULL"));
-*/
- return FALSE;
- }
-
-// m_log(_T("ReceiverWndProc"), _T("Going to process"));
- if (singleton != NULL)
- singleton->NewData((WCHAR *) pData->lpData, pData->cbData / 2);
-
- return TRUE;
- }
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
-
- default :
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
- return 0;
}
diff --git a/plugins/ListeningTo/src/players/itunes.cpp b/plugins/ListeningTo/src/players/itunes.cpp index af479f22c8..fa444bc10d 100644 --- a/plugins/ListeningTo/src/players/itunes.cpp +++ b/plugins/ListeningTo/src/players/itunes.cpp @@ -38,13 +38,11 @@ ITunes::ITunes() ret = NULL;
}
-
void ITunes::FindWindow()
{
hwnd = ::FindWindow(_T("iTunes"), _T("iTunes"));
}
-
void ITunes::FreeTempData()
{
#define RELEASE(_x_) if (_x_ != NULL) { _x_->Release(); _x_ = NULL; }
@@ -53,14 +51,12 @@ void ITunes::FreeTempData() RELEASE(track);
RELEASE(iTunesApp);
- if (ret != NULL)
- {
+ if (ret != NULL) {
SysFreeString(ret);
ret = NULL;
}
}
-
#define CALL(_F_) hr = _F_; if (FAILED(hr)) return FALSE
// Init data and put filename playing in ret and ->fi.filename
@@ -73,60 +69,56 @@ BOOL ITunes::InitAndGetFilename() if (hwnd == NULL)
return FALSE;
- CALL( CoCreateInstance(CLSID_iTunesApp, NULL, CLSCTX_LOCAL_SERVER, __uuidof(iTunesApp), (void **)&iTunesApp));
+ CALL(CoCreateInstance(CLSID_iTunesApp, NULL, CLSCTX_LOCAL_SERVER, __uuidof(iTunesApp), (void **)&iTunesApp));
ITPlayerState state;
- CALL( iTunesApp->get_PlayerState(&state));
+ CALL(iTunesApp->get_PlayerState(&state));
if (state == ITPlayerStateStopped)
return FALSE;
- CALL( iTunesApp->get_CurrentTrack(&track));
+ CALL(iTunesApp->get_CurrentTrack(&track));
if (track == NULL)
return FALSE;
- CALL( track->QueryInterface(__uuidof(file), (void **)&file));
+ CALL(track->QueryInterface(__uuidof(file), (void **)&file));
- CALL( file->get_Location(&ret));
+ CALL(file->get_Location(&ret));
return !IsEmpty(ret);
}
-
BOOL ITunes::FillCache()
{
HRESULT hr;
long lret;
- CALL( track->get_Album(&ret));
+ CALL(track->get_Album(&ret));
listening_info.ptszAlbum = U2T(ret);
- CALL( track->get_Artist(&ret));
+ CALL(track->get_Artist(&ret));
listening_info.ptszArtist = U2T(ret);
- CALL( track->get_Name(&ret));
+ CALL(track->get_Name(&ret));
listening_info.ptszTitle = U2T(ret);
- CALL( track->get_Year(&lret));
- if (lret > 0)
- {
- listening_info.ptszYear = (TCHAR*) mir_alloc(10 * sizeof(TCHAR));
+ CALL(track->get_Year(&lret));
+ if (lret > 0) {
+ listening_info.ptszYear = (TCHAR*)mir_alloc(10 * sizeof(TCHAR));
_itot(lret, listening_info.ptszYear, 10);
}
- CALL( track->get_TrackNumber(&lret));
- if (lret > 0)
- {
- listening_info.ptszTrack = (TCHAR*) mir_alloc(10 * sizeof(TCHAR));
+ CALL(track->get_TrackNumber(&lret));
+ if (lret > 0) {
+ listening_info.ptszTrack = (TCHAR*)mir_alloc(10 * sizeof(TCHAR));
_itot(lret, listening_info.ptszTrack, 10);
}
- CALL( track->get_Genre(&ret));
+ CALL(track->get_Genre(&ret));
listening_info.ptszGenre = U2T(ret);
- CALL( track->get_Duration(&lret));
- if (lret > 0)
- {
- listening_info.ptszLength = (TCHAR*) mir_alloc(10 * sizeof(TCHAR));
+ CALL(track->get_Duration(&lret));
+ if (lret > 0) {
+ listening_info.ptszLength = (TCHAR*)mir_alloc(10 * sizeof(TCHAR));
int s = lret % 60;
int m = (lret / 60) % 60;
@@ -140,15 +132,14 @@ BOOL ITunes::FillCache() listening_info.ptszType = mir_tstrdup(_T("Music"));
- if (listening_info.ptszTitle == NULL)
- {
+ if (listening_info.ptszTitle == NULL) {
// Get from filename
WCHAR *p = wcsrchr(filename, '\\');
if (p != NULL)
p++;
else
p = filename;
-
+
listening_info.ptszTitle = mir_u2t(p);
TCHAR *pt = _tcsrchr(listening_info.ptszTitle, '.');
@@ -164,13 +155,11 @@ BOOL ITunes::FillCache() return TRUE;
}
-
BOOL ITunes::GetListeningInfo(LISTENINGTOINFO *lti)
{
FreeData();
- if (InitAndGetFilename() && lstrcmp(filename, ret) != 0)
- {
+ if (InitAndGetFilename() && lstrcmp(filename, ret) != 0) {
// Fill the data cache
wcscpy(filename, ret);
diff --git a/plugins/ListeningTo/src/players/mradio.cpp b/plugins/ListeningTo/src/players/mradio.cpp index 54dd45a8d1..1b99945902 100644 --- a/plugins/ListeningTo/src/players/mradio.cpp +++ b/plugins/ListeningTo/src/players/mradio.cpp @@ -35,12 +35,12 @@ void MRadio::EnableDisable() int MRadio::GetData()
{
for (MCONTACT hContact = db_find_first("mRadio"); hContact; hContact = db_find_next(hContact, "mRadio")) {
- WORD status = db_get_w(hContact, "mRadio", "Status", ID_STATUS_OFFLINE);
+ WORD status = db_get_w(hContact, "mRadio", "Status", ID_STATUS_OFFLINE);
if (status != ID_STATUS_ONLINE)
continue;
DBVARIANT dbv;
- if (!db_get_s(hContact, "mRadio", "Nick", &dbv)) {
+ if (!db_get_s(hContact, "mRadio", "Nick", &dbv)) {
listening_info.cbSize = sizeof(listening_info);
listening_info.dwFlags = LTI_TCHAR;
listening_info.ptszArtist = mir_tstrdup(_T("Radio"));
@@ -58,16 +58,14 @@ int MRadio::GetData() BOOL MRadio::GetListeningInfo(LISTENINGTOINFO *lti)
{
- FreeData();
+ FreeData();
- if (enabled)
- {
- if (CallService(MS_RADIO_COMMAND, MRC_STATUS, RD_STATUS_GET) == RD_STATUS_PLAYING)
- {
+ if (enabled) {
+ if (CallService(MS_RADIO_COMMAND, MRC_STATUS, RD_STATUS_GET) == RD_STATUS_PLAYING) {
if (!GetData())
FreeData();
}
}
return Player::GetListeningInfo(lti);
-}
\ No newline at end of file +}
diff --git a/plugins/ListeningTo/src/players/player.cpp b/plugins/ListeningTo/src/players/player.cpp index f87818a90b..d7834f3e83 100644 --- a/plugins/ListeningTo/src/players/player.cpp +++ b/plugins/ListeningTo/src/players/player.cpp @@ -24,13 +24,11 @@ extern void HasNewListeningInfo(); Player::Player() : name(_T("Player")), enabled(FALSE), needPoll(FALSE)
{
memset(&listening_info, 0, sizeof(listening_info));
- InitializeCriticalSection(&cs);
}
Player::~Player()
{
FreeData();
- DeleteCriticalSection(&cs);
}
void Player::NotifyInfoChanged()
@@ -41,49 +39,24 @@ void Player::NotifyInfoChanged() BOOL Player::GetListeningInfo(LISTENINGTOINFO *lti)
{
- EnterCriticalSection(&cs);
+ mir_cslock lck(cs);
- BOOL ret;
if (listening_info.cbSize == 0)
- {
- ret = FALSE;
- }
- else
- {
- if (lti != NULL)
- CopyListeningInfo(lti, &listening_info);
- ret = TRUE;
- }
+ return false;
- LeaveCriticalSection(&cs);
-
- return ret;
+ if (lti != NULL)
+ CopyListeningInfo(lti, &listening_info);
+ return true;
}
void Player::FreeData()
{
- EnterCriticalSection(&cs);
+ mir_cslock lck(cs);
if (listening_info.cbSize != 0)
FreeListeningInfo(&listening_info);
-
- LeaveCriticalSection(&cs);
}
-LISTENINGTOINFO * Player::LockListeningInfo()
-{
- EnterCriticalSection(&cs);
-
- return &listening_info;
-}
-
-void Player::ReleaseListeningInfo()
-{
- LeaveCriticalSection(&cs);
-}
-
-
-
ExternalPlayer::ExternalPlayer()
{
name = _T("ExternalPlayer");
@@ -101,8 +74,7 @@ ExternalPlayer::~ExternalPlayer() HWND ExternalPlayer::FindWindow()
{
HWND hwnd = NULL;
- for(int i = 0; i < num_window_classes; i++)
- {
+ for (int i = 0; i < num_window_classes; i++) {
hwnd = ::FindWindow(window_classes[i], NULL);
if (hwnd != NULL)
break;
@@ -154,7 +126,7 @@ void CodeInjectionPlayer::InjectCode() // Get the dll path
- char dll_path[1024] = {0};
+ char dll_path[1024] = { 0 };
if (!GetModuleFileNameA(hInst, dll_path, _countof(dll_path)))
return;
@@ -179,33 +151,30 @@ void CodeInjectionPlayer::InjectCode() // Do the code injection
unsigned long pid;
GetWindowThreadProcessId(hwnd, &pid);
- HANDLE hProcess = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION
- | PROCESS_VM_WRITE | PROCESS_VM_READ, FALSE, pid);
+ HANDLE hProcess = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION
+ | PROCESS_VM_WRITE | PROCESS_VM_READ, FALSE, pid);
if (hProcess == NULL)
return;
- char *_dll = (char *) VirtualAllocEx(hProcess, NULL, len+1, MEM_COMMIT, PAGE_READWRITE );
- if (_dll == NULL)
- {
+ char *_dll = (char *)VirtualAllocEx(hProcess, NULL, len + 1, MEM_COMMIT, PAGE_READWRITE);
+ if (_dll == NULL) {
CloseHandle(hProcess);
return;
}
- WriteProcessMemory(hProcess, _dll, dll_path, len+1, NULL);
+ WriteProcessMemory(hProcess, _dll, dll_path, len + 1, NULL);
HMODULE hKernel32 = GetModuleHandleA("kernel32");
HANDLE hLoadLibraryA = GetProcAddress(hKernel32, "LoadLibraryA");
DWORD threadId;
- HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE) hLoadLibraryA,
- _dll, 0, &threadId);
- if (hThread == NULL)
- {
- VirtualFreeEx(hProcess, _dll, len+1, MEM_RELEASE);
+ HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)hLoadLibraryA, _dll, 0, &threadId);
+ if (hThread == NULL) {
+ VirtualFreeEx(hProcess, _dll, len + 1, MEM_RELEASE);
CloseHandle(hProcess);
return;
}
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
- VirtualFreeEx(hProcess, _dll, len+1, MEM_RELEASE);
+ VirtualFreeEx(hProcess, _dll, len + 1, MEM_RELEASE);
CloseHandle(hProcess);
}
diff --git a/plugins/ListeningTo/src/players/player.h b/plugins/ListeningTo/src/players/player.h index 45396ad261..83a14e3a69 100644 --- a/plugins/ListeningTo/src/players/player.h +++ b/plugins/ListeningTo/src/players/player.h @@ -22,7 +22,7 @@ class Player {
protected:
LISTENINGTOINFO listening_info;
- CRITICAL_SECTION cs;
+ mir_cs cs;
void NotifyInfoChanged();
@@ -34,14 +34,12 @@ public: Player();
virtual ~Player();
- virtual BOOL GetListeningInfo(LISTENINGTOINFO *lti);
+ __forceinline mir_cs& GetLock() { return cs; }
+ __forceinline LISTENINGTOINFO* GetInfo() { return &listening_info; }
+ virtual BOOL GetListeningInfo(LISTENINGTOINFO *lti);
virtual void FreeData();
- // Helpers to write to this object's listening info
- virtual LISTENINGTOINFO * LockListeningInfo();
- virtual void ReleaseListeningInfo();
-
// Called everytime options change
virtual void EnableDisable() {}
};
diff --git a/plugins/ListeningTo/src/players/watrack.cpp b/plugins/ListeningTo/src/players/watrack.cpp index 4af891b39a..7f3a6a68cc 100644 --- a/plugins/ListeningTo/src/players/watrack.cpp +++ b/plugins/ListeningTo/src/players/watrack.cpp @@ -21,7 +21,7 @@ Boston, MA 02111-1307, USA. static WATrack *instance = NULL;
-int NewStatusCallback(WPARAM wParam, LPARAM lParam)
+int NewStatusCallback(WPARAM wParam, LPARAM lParam)
{
if (!loaded)
return 0;
@@ -30,7 +30,6 @@ int NewStatusCallback(WPARAM wParam, LPARAM lParam) return 0;
}
-
WATrack::WATrack()
{
name = _T("WATrack");
@@ -38,23 +37,18 @@ WATrack::WATrack() hNewStatusHook = NULL;
}
-
-
WATrack::~WATrack()
{
- if (hNewStatusHook != NULL)
- {
+ if (hNewStatusHook != NULL) {
UnhookEvent(hNewStatusHook);
hNewStatusHook = NULL;
}
instance = NULL;
}
-
void WATrack::EnableDisable()
{
- if (!ServiceExists(MS_WAT_GETMUSICINFO))
- {
+ if (!ServiceExists(MS_WAT_GETMUSICINFO)) {
enabled = FALSE;
return;
}
@@ -63,65 +57,45 @@ void WATrack::EnableDisable() hNewStatusHook = HookEvent(ME_WAT_NEWSTATUS, NewStatusCallback);
}
-
void WATrack::NewStatus(int event, int value)
{
- EnterCriticalSection(&cs);
-
- if (event == WAT_EVENT_PLUGINSTATUS && value != 0)
- {
- FreeData();
- }
- else
{
- GetData();
+ mir_cslock lck(cs);
+ if (event == WAT_EVENT_PLUGINSTATUS && value != 0)
+ FreeData();
+ else
+ GetData();
}
- LeaveCriticalSection(&cs);
-
NotifyInfoChanged();
}
-
void WATrack::GetData()
{
-
-
SONGINFO *si = NULL;
-
- int playing = CallService(MS_WAT_GETMUSICINFO, WAT_INF_UNICODE, (LPARAM) &si);
-
-
+ int playing = CallService(MS_WAT_GETMUSICINFO, WAT_INF_UNICODE, (LPARAM)&si);
FreeData();
// See if something is playing
- if (playing == WAT_RES_NOTFOUND
- || si == NULL
- || si->status != 1
- || ( IsEmpty(si->artist) && IsEmpty(si->title)) )
- {
+ if (playing == WAT_RES_NOTFOUND || si == NULL || si->status != 1 || (IsEmpty(si->artist) && IsEmpty(si->title)))
return;
- }
// Copy new data
-
listening_info.ptszAlbum = DUP(si->album);
listening_info.ptszArtist = DUP(si->artist);
listening_info.ptszTitle = DUP(si->title);
listening_info.ptszYear = DUP(si->year);
- if (si->track > 0)
- {
- listening_info.ptszTrack = (TCHAR*) mir_alloc(10 * sizeof(TCHAR));
+ if (si->track > 0) {
+ listening_info.ptszTrack = (TCHAR*)mir_alloc(10 * sizeof(TCHAR));
_itot(si->track, listening_info.ptszTrack, 10);
}
listening_info.ptszGenre = DUP(si->genre);
- if (si->total > 0)
- {
- listening_info.ptszLength = (TCHAR*) mir_alloc(10 * sizeof(TCHAR));
+ if (si->total > 0) {
+ listening_info.ptszLength = (TCHAR*)mir_alloc(10 * sizeof(TCHAR));
int s = si->total % 60;
int m = (si->total / 60) % 60;
diff --git a/plugins/ListeningTo/src/players/winamp.cpp b/plugins/ListeningTo/src/players/winamp.cpp index c3e08a02af..1dcaea4e98 100644 --- a/plugins/ListeningTo/src/players/winamp.cpp +++ b/plugins/ListeningTo/src/players/winamp.cpp @@ -20,11 +20,11 @@ Boston, MA 02111-1307, USA. #include "..\stdafx.h"
static TCHAR *wcs[] = {
- _T("Winamp v1.x")
+ _T("Winamp v1.x")
};
Winamp::Winamp()
-{
+{
name = _T("Winamp");
window_classes = wcs;
num_window_classes = _countof(wcs);
diff --git a/plugins/ListeningTo/src/players/wmp.cpp b/plugins/ListeningTo/src/players/wmp.cpp index 7dc2c6fff0..2b46ba6195 100644 --- a/plugins/ListeningTo/src/players/wmp.cpp +++ b/plugins/ListeningTo/src/players/wmp.cpp @@ -23,37 +23,30 @@ Boston, MA 02111-1307, USA. static LRESULT CALLBACK ReceiverWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
-
static UINT hTimer = NULL;
-
WindowsMediaPlayer *singleton = NULL;
-
-
WindowsMediaPlayer::WindowsMediaPlayer()
{
name = _T("WindowsMediaPlayer");
received[0] = _T('\0');
singleton = this;
- WNDCLASS wc = {0};
- wc.lpfnWndProc = ReceiverWndProc;
- wc.hInstance = hInst;
- wc.lpszClassName = WMP_WINDOWCLASS;
+ WNDCLASS wc = { 0 };
+ wc.lpfnWndProc = ReceiverWndProc;
+ wc.hInstance = hInst;
+ wc.lpszClassName = WMP_WINDOWCLASS;
RegisterClass(&wc);
- hWnd = CreateWindow(WMP_WINDOWCLASS, LPGENT("Miranda ListeningTo WMP receiver"),
- 0, 0, 0, 0, 0, NULL, NULL, hInst, NULL);
+ hWnd = CreateWindow(WMP_WINDOWCLASS, LPGENT("Miranda ListeningTo WMP receiver"),
+ 0, 0, 0, 0, 0, NULL, NULL, hInst, NULL);
}
-
-
WindowsMediaPlayer::~WindowsMediaPlayer()
{
- if (hTimer != NULL)
- {
+ if (hTimer != NULL) {
KillTimer(NULL, hTimer);
hTimer = NULL;
}
@@ -65,70 +58,62 @@ WindowsMediaPlayer::~WindowsMediaPlayer() singleton = NULL;
}
-
-
void WindowsMediaPlayer::ProcessReceived()
{
- EnterCriticalSection(&cs);
-
- FreeData();
+ {
+ mir_cslock lck(cs);
+ FreeData();
- // Do the processing
- // MSNMusicString = L"\\0Music\\0%d\\0%s\\0%s\\0%s\\0%s\\0%s\\0\\0"
- // MSNMusicString, msn->msncommand, strMSNFormat, msn->title, msn->artist, msn->album, msn->wmcontentid);
+ // Do the processing
+ // MSNMusicString = L"\\0Music\\0%d\\0%s\\0%s\\0%s\\0%s\\0%s\\0\\0"
+ // MSNMusicString, msn->msncommand, strMSNFormat, msn->title, msn->artist, msn->album, msn->wmcontentid);
- WCHAR *p1 = wcsstr(received, L"\\0");
+ WCHAR *p1 = wcsstr(received, L"\\0");
- if (received[0] == L'\0' || p1 == NULL)
- {
- LeaveCriticalSection(&cs);
- NotifyInfoChanged();
- return;
- }
+ if (received[0] == L'\0' || p1 == NULL) {
+ NotifyInfoChanged();
+ return;
+ }
- // Process string
- WCHAR *parts[8] = {0};
- int pCount = 0;
- WCHAR *p = received;
- do {
- *p1 = L'\0';
+ // Process string
+ WCHAR *parts[8] = { 0 };
+ int pCount = 0;
+ WCHAR *p = received;
+ do {
+ *p1 = L'\0';
+ parts[pCount] = p;
+ pCount++;
+ p = p1 + 2;
+ p1 = wcsstr(p, L"\\0");
+ } while (p1 != NULL && pCount < 7);
+ if (p1 != NULL)
+ *p1 = L'\0';
parts[pCount] = p;
- pCount ++;
- p = p1 + 2;
- p1 = wcsstr(p, L"\\0");
- } while( p1 != NULL && pCount < 7 );
- if (p1 != NULL)
- *p1 = L'\0';
- parts[pCount] = p;
-
- // Fill cache
- if (pCount > 4 && !IsEmpty(parts[1]) && (!IsEmpty(parts[4]) || !IsEmpty(parts[5])))
- {
- listening_info.cbSize = sizeof(listening_info);
- listening_info.dwFlags = LTI_TCHAR;
- listening_info.ptszType = U2T(parts[1]);
- listening_info.ptszTitle = U2T(parts[4]);
- listening_info.ptszArtist = U2T(parts[5]);
- listening_info.ptszAlbum = U2T(parts[6]);
+ // Fill cache
+ if (pCount > 4 && !IsEmpty(parts[1]) && (!IsEmpty(parts[4]) || !IsEmpty(parts[5]))) {
+ listening_info.cbSize = sizeof(listening_info);
+ listening_info.dwFlags = LTI_TCHAR;
- listening_info.ptszPlayer = mir_tstrdup(name);
- }
+ listening_info.ptszType = U2T(parts[1]);
+ listening_info.ptszTitle = U2T(parts[4]);
+ listening_info.ptszArtist = U2T(parts[5]);
+ listening_info.ptszAlbum = U2T(parts[6]);
- // Put back the '\\'s
- for(int i = 1; i <= pCount; i++)
- *(parts[i] - 2) = L'\\';
- if (p1 != NULL)
- *p1 = L'\\';
+ listening_info.ptszPlayer = mir_tstrdup(name);
+ }
- LeaveCriticalSection(&cs);
+ // Put back the '\\'s
+ for (int i = 1; i <= pCount; i++)
+ *(parts[i] - 2) = L'\\';
+ if (p1 != NULL)
+ *p1 = L'\\';
+ }
NotifyInfoChanged();
}
-
-
-static VOID CALLBACK SendTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
+static VOID CALLBACK SendTimerProc(HWND, UINT, UINT_PTR, DWORD)
{
KillTimer(NULL, hTimer);
hTimer = NULL;
@@ -140,40 +125,25 @@ static VOID CALLBACK SendTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD singleton->ProcessReceived();
}
-
void WindowsMediaPlayer::NewData(const WCHAR *data, size_t len)
{
- EnterCriticalSection(&cs);
+ mir_cslock lck(cs);
len = min(len, 1023);
- if (wcsncmp(received, data, len) != 0)
- {
+ if (wcsncmp(received, data, len) != 0) {
wcsncpy(received, data, len);
received[len] = _T('\0');
-/*
- m_log(_T("ReceiverWndProc"), _T("WMP : New data: [%d] %s"), len, received);
-
-*/
if (hTimer)
KillTimer(NULL, hTimer);
hTimer = SetTimer(NULL, NULL, 300, SendTimerProc); // Do the processing after we return true
}
-/* else
- {
- m_log(_T("NewData"), _T("END: Text is the same as last time"));
- }
-*/
- LeaveCriticalSection(&cs);
}
-
-
static LRESULT CALLBACK ReceiverWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch (message)
- {
- case WM_COPYDATA :
+ switch (message) {
+ case WM_COPYDATA:
{
if (!loaded)
return FALSE;
@@ -181,19 +151,20 @@ static LRESULT CALLBACK ReceiverWndProc(HWND hWnd, UINT message, WPARAM wParam, if (singleton == NULL || !singleton->enabled)
return FALSE;
- COPYDATASTRUCT* pData = (PCOPYDATASTRUCT) lParam;
+ COPYDATASTRUCT* pData = (PCOPYDATASTRUCT)lParam;
if (pData->dwData != 0x547 || pData->cbData == 0 || pData->lpData == NULL)
return FALSE;
if (singleton != NULL)
- singleton->NewData((WCHAR *) pData->lpData, pData->cbData / 2);
+ singleton->NewData((WCHAR *)pData->lpData, pData->cbData / 2);
return TRUE;
}
- case WM_DESTROY :
- PostQuitMessage(0);
- break;
+
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
-}
\ No newline at end of file +}
diff --git a/plugins/ListeningTo/src/stdafx.h b/plugins/ListeningTo/src/stdafx.h index 1c6181875b..e6f55b7eb3 100644 --- a/plugins/ListeningTo/src/stdafx.h +++ b/plugins/ListeningTo/src/stdafx.h @@ -96,7 +96,7 @@ struct ProtocolInfo };
ProtocolInfo *GetProtoInfo(char *proto);
-int m_log(const TCHAR *function, const TCHAR *fmt, ...);
+void m_log(const TCHAR *function, const TCHAR *fmt, ...);
static bool IsEmpty(const char *str)
|