summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-06-20 17:00:14 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-06-20 17:00:14 +0000
commit30ab6ceb71842f003f649b3d62b89af010cf40d1 (patch)
treeb1dae7a6d545cdf622a165ba4c576d3a41d71221 /src/modules
parent65461e7b4edb683cc09086fdaf49e0c2ef918bd4 (diff)
- direct call of MS_SKIN_ADDNEWSOUND replaced with Skin_AddSound() call;
- obsolete structure SKINSOUNDDESC removed - dynamically translated hot keys; - checked correct LPGEN'ing of the sounds creation; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@500 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/langpack/langpack.cpp1
-rw-r--r--src/modules/options/options.cpp2
-rw-r--r--src/modules/skin/hotkeys.cpp135
-rw-r--r--src/modules/skin/sounds.cpp377
-rw-r--r--src/modules/srauth/auth.cpp4
-rw-r--r--src/modules/srfile/file.cpp8
-rw-r--r--src/modules/srurl/url.cpp2
-rw-r--r--src/modules/useronline/useronline.cpp2
8 files changed, 260 insertions, 271 deletions
diff --git a/src/modules/langpack/langpack.cpp b/src/modules/langpack/langpack.cpp
index 3d20a4b85b..efa7e5da9b 100644
--- a/src/modules/langpack/langpack.cpp
+++ b/src/modules/langpack/langpack.cpp
@@ -398,6 +398,7 @@ static int LoadLangPack(const TCHAR *szLangPack)
LoadLangPackFile(fp, line, fileCp);
fclose(fp);
+ pCurrentMuuid = NULL;
qsort(langPack.entry, langPack.entryCount, sizeof(LangPackEntry), (int(*)(const void*, const void*))SortLangPackHashesProc);
return 0;
diff --git a/src/modules/options/options.cpp b/src/modules/options/options.cpp
index b603f93f25..aa6180a972 100644
--- a/src/modules/options/options.cpp
+++ b/src/modules/options/options.cpp
@@ -101,7 +101,7 @@ struct OptionsDlgData
HANDLE hPluginLoad, hPluginUnload;
};
-static HTREEITEM FindNamedTreeItemAtRoot(HWND hwndTree, const TCHAR* name)
+HTREEITEM FindNamedTreeItemAtRoot(HWND hwndTree, const TCHAR* name)
{
TVITEM tvi;
TCHAR str[128];
diff --git a/src/modules/skin/hotkeys.cpp b/src/modules/skin/hotkeys.cpp
index d535ad3769..6408bcda7d 100644
--- a/src/modules/skin/hotkeys.cpp
+++ b/src/modules/skin/hotkeys.cpp
@@ -568,6 +568,20 @@ static void sttOptionsDeleteHotkey(HWND hwndList, int idx, THotkeyItem *item)
item->rootHotkey->OptChanged = TRUE;
}
+static int sttAlphaSort(const THotkeyItem *p1, const THotkeyItem *p2)
+{
+ int res;
+ if (res = lstrcmp(p1->getSection(), p2->getSection()))
+ return res;
+ if (res = lstrcmp(p1->getDescr(), p2->getDescr()))
+ return res;
+ if (!p1->rootHotkey && p2->rootHotkey)
+ return -1;
+ if (p1->rootHotkey && !p2->rootHotkey)
+ return 1;
+ return 0;
+}
+
static int CALLBACK sttOptionsSortList(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
TCHAR title1[256] = {0}, title2[256] = {0};
@@ -593,7 +607,7 @@ static int CALLBACK sttOptionsSortList(LPARAM lParam1, LPARAM lParam2, LPARAM lP
return lstrcmp(title1, title2);
if ( !item1) {
- if (res = lstrcmp(title1, item1->getSection()))
+ if (res = lstrcmp(title1, item2->getSection()))
return res;
return -1;
}
@@ -603,7 +617,7 @@ static int CALLBACK sttOptionsSortList(LPARAM lParam1, LPARAM lParam2, LPARAM lP
return res;
return 1;
}
- return sttCompareHotkeys(item1, item2);
+ return sttAlphaSort(item1, item2);
}
static void sttOptionsAddHotkey(HWND hwndList, THotkeyItem *item)
@@ -684,19 +698,24 @@ static void sttOptionsSaveItem(THotkeyItem *item)
DBWriteContactSettingDword(NULL, DBMODULENAME, buf, item->nSubHotkeys);
}
-static void sttBuildHotkeyList(HWND hwndList, TCHAR *section)
+static void sttBuildHotkeyList(HWND hwndList)
{
int i, nItems=0;
ListView_DeleteAllItems(hwndList);
- for (i = 0; i < hotkeys.getCount(); i++) {
+ // create the temporary list with language-dependent sort order
+ LIST<THotkeyItem> tmpList(hotkeys.getCount(), sttAlphaSort);
+ for (i = 0; i < hotkeys.getCount(); i++)
+ tmpList.insert( hotkeys[i] );
+
+ for (i = 0; i < tmpList.getCount(); i++) {
LVITEM lvi = {0};
- THotkeyItem *item = hotkeys[i];
+ THotkeyItem *item = tmpList[i];
- if (item->OptDeleted) continue;
- if (section && lstrcmp(section, item->ptszSection)) continue;
+ if (item->OptDeleted)
+ continue;
- if ( !section && ( !i || lstrcmp(item->ptszSection, ((THotkeyItem *)hotkeys[i-1])->ptszSection))) {
+ if ( !i || lstrcmp(item->ptszSection, tmpList[i-1]->ptszSection)) {
lvi.mask = LVIF_TEXT|LVIF_PARAM;
lvi.iItem = nItems++;
lvi.iSubItem = 0;
@@ -713,11 +732,8 @@ static void sttBuildHotkeyList(HWND hwndList, TCHAR *section)
lvi.iSubItem = 0;
}
- lvi.mask = LVIF_PARAM;
- if ( !section) {
- lvi.mask |= LVIF_INDENT;
- lvi.iIndent = 1;
- }
+ lvi.mask = LVIF_PARAM | LVIF_INDENT;
+ lvi.iIndent = 1;
lvi.iItem = nItems++;
lvi.lParam = (LPARAM)item;
ListView_InsertItem(hwndList, &lvi);
@@ -769,66 +785,59 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
switch (msg) {
case WM_INITDIALOG:
- {
- int i;
- LVCOLUMN lvc;
- RECT rc;
- HIMAGELIST hIml;
-
initialized = FALSE;
TranslateDialogDefault(hwndDlg);
sttHotkeyEditCreate(GetDlgItem(hwndDlg, IDC_HOTKEY));
-
- hIml = ImageList_Create(16, 16, ILC_MASK + (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16), 3, 1);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_WINDOWS);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_MIRANDA);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_WINDOW);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_ADDCONTACT);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_DELETE);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNDO);
-
- // This is added to use for drawing operation only
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_GROUPOPEN);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_GROUPSHUT);
-
- ListView_SetImageList(hwndHotkey, hIml, LVSIL_SMALL);
-
+ {
+ HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK + (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16), 3, 1);
+ ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_WINDOWS);
+ ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_MIRANDA);
+ ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_WINDOW);
+ ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_ADDCONTACT);
+ ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_DELETE);
+ ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNDO);
+ ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_GROUPOPEN);
+ ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_GROUPSHUT);
+ ListView_SetImageList(hwndHotkey, hIml, LVSIL_SMALL);
+ }
ListView_SetExtendedListViewStyle(hwndHotkey, LVS_EX_CHECKBOXES|LVS_EX_SUBITEMIMAGES|LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER|LVS_EX_INFOTIP);
+ {
+ RECT rc;
+ GetClientRect(hwndHotkey, &rc);
+ colWidth = rc.right - GetSystemMetrics(SM_CXHTHUMB) - 3*GetSystemMetrics(SM_CXSMICON) - 5;
+
+ LVCOLUMN lvc;
+ lvc.mask = LVCF_WIDTH;
+ lvc.cx = colWidth * 2 / 3;
+ ListView_InsertColumn(hwndHotkey, COL_NAME, &lvc);
+ lvc.cx = GetSystemMetrics(SM_CXSMICON);
+ ListView_InsertColumn(hwndHotkey, COL_TYPE, &lvc);
+ lvc.cx = colWidth / 3;
+ ListView_InsertColumn(hwndHotkey, COL_KEY, &lvc);
+ lvc.cx = GetSystemMetrics(SM_CXSMICON);
+ ListView_InsertColumn(hwndHotkey, COL_RESET, &lvc);
+ lvc.cx = GetSystemMetrics(SM_CXSMICON);
+ ListView_InsertColumn(hwndHotkey, COL_ADDREMOVE, &lvc);
+
+ for (int i = 0; i < hotkeys.getCount(); i++) {
+ THotkeyItem *item = hotkeys[i];
- GetClientRect(hwndHotkey, &rc);
- colWidth = rc.right - GetSystemMetrics(SM_CXHTHUMB) - 3*GetSystemMetrics(SM_CXSMICON) - 5;
-
- lvc.mask = LVCF_WIDTH;
- lvc.cx = colWidth * 2 / 3;
- ListView_InsertColumn(hwndHotkey, COL_NAME, &lvc);
- lvc.cx = GetSystemMetrics(SM_CXSMICON);
- ListView_InsertColumn(hwndHotkey, COL_TYPE, &lvc);
- lvc.cx = colWidth / 3;
- ListView_InsertColumn(hwndHotkey, COL_KEY, &lvc);
- lvc.cx = GetSystemMetrics(SM_CXSMICON);
- ListView_InsertColumn(hwndHotkey, COL_RESET, &lvc);
- lvc.cx = GetSystemMetrics(SM_CXSMICON);
- ListView_InsertColumn(hwndHotkey, COL_ADDREMOVE, &lvc);
-
- for (i = 0; i < hotkeys.getCount(); i++) {
- THotkeyItem *item = hotkeys[i];
+ item->OptChanged = FALSE;
+ item->OptDeleted = item->OptNew = FALSE;
+ item->OptEnabled = item->Enabled;
+ item->OptHotkey = item->Hotkey;
+ item->OptType = item->type;
+ }
- item->OptChanged = FALSE;
- item->OptDeleted = item->OptNew = FALSE;
- item->OptEnabled = item->Enabled;
- item->OptHotkey = item->Hotkey;
- item->OptType = item->type;
+ currentLanguage = LOWORD(GetKeyboardLayout(0));
+ sttBuildHotkeyList(hwndHotkey);
}
-
- currentLanguage = LOWORD(GetKeyboardLayout(0));
- sttBuildHotkeyList(hwndHotkey, NULL);
SetTimer(hwndDlg, 1024, 1000, NULL);
-
initialized = TRUE;
-
- { /* load group states */
+ {
+ /* load group states */
int count = ListView_GetItemCount(hwndHotkey);
TCHAR buf[128];
LVITEM lvi = {0};
@@ -856,9 +865,7 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
}
g_hwndOptions = hwndDlg;
-
break;
- }
case WM_DESTROY:
{
diff --git a/src/modules/skin/sounds.cpp b/src/modules/skin/sounds.cpp
index 9dedbdf4d5..f499a39a4d 100644
--- a/src/modules/skin/sounds.cpp
+++ b/src/modules/skin/sounds.cpp
@@ -22,72 +22,75 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "..\..\core\commonheaders.h"
-#define SKINSOUNDDESC_SIZE_V1 (offsetof(SKINSOUNDDESCEX, pszSection))
-#define SKINSOUNDDESC_SIZE_V2 (offsetof(SKINSOUNDDESCEX, dwFlags))
-
struct SoundItem
{
char* name;
- TCHAR* section;
- TCHAR* description;
- char* tempFile;
+ TCHAR* ptszSection;
+ TCHAR* ptszDescription;
+ TCHAR* ptszTempFile;
+ int hLangpack;
+
+ __inline TCHAR* getSection() const { return LangPackTranslateStringT(hLangpack, ptszSection); }
+ __inline TCHAR* getDescr() const { return LangPackTranslateStringT(hLangpack, ptszDescription); }
+
+ __inline ~SoundItem()
+ {
+ mir_free(name);
+ mir_free(ptszSection);
+ mir_free(ptszDescription);
+ mir_free(ptszTempFile);
+ }
};
+static int CompareSounds(const SoundItem* p1, const SoundItem* p2)
+{
+ return lstrcmpA(p1->name, p2->name);
+}
+
+static OBJLIST<SoundItem> arSounds(10, CompareSounds);
+
static BOOL bModuleInitialized = FALSE;
-static struct SoundItem *soundList = NULL;
-static int soundCount;
static HANDLE hPlayEvent = NULL;
-static INT_PTR ServiceSkinAddNewSound(WPARAM, LPARAM lParam)
+static INT_PTR ServiceSkinAddNewSound(WPARAM wParam, LPARAM lParam)
{
SKINSOUNDDESCEX *ssd = (SKINSOUNDDESCEX*)lParam;
- switch(ssd->cbSize) {
- case sizeof(SKINSOUNDDESCEX):
- case SKINSOUNDDESC_SIZE_V1:
- case SKINSOUNDDESC_SIZE_V2:
- break;
-
- default:
+ if (ssd->cbSize != sizeof(SKINSOUNDDESCEX) || ssd->pszName == NULL || ssd->pszDescription == NULL)
return 1;
- }
- if (ssd->pszName == NULL || ssd->pszDescription == NULL)
- return 1;
-
- DBVARIANT dbv;
- DWORD dwFlags = (ssd->cbSize == sizeof(SKINSOUNDDESCEX)) ? ssd->dwFlags : 0;
-
- soundList=(struct SoundItem*)mir_realloc(soundList, sizeof(struct SoundItem)*(soundCount+1));
- SoundItem* item = &soundList[soundCount++];
+ SoundItem* item = new SoundItem; // due to OBJLIST
item->name = mir_strdup(ssd->pszName);
- item->tempFile = NULL;
+ item->ptszTempFile = NULL;
+ item->hLangpack = (int)wParam;
+ arSounds.insert(item);
- TCHAR* ptszDefaultFile;
- if (dwFlags & SSDF_UNICODE) {
- item->description = mir_tstrdup(TranslateTS(ssd->ptszDescription));
- item->section = mir_tstrdup(TranslateTS(ssd->cbSize != SKINSOUNDDESC_SIZE_V1 && ssd->pszSection != NULL ? ssd->ptszSection : _T("Other")));
- ptszDefaultFile = mir_tstrdup(ssd->ptszDefaultFile);
- }
- else {
- item->description = LangPackPcharToTchar(ssd->pszDescription);
- item->section = LangPackPcharToTchar(ssd->cbSize != SKINSOUNDDESC_SIZE_V1 && ssd->pszSection != NULL ? ssd->pszSection : "Other");
- ptszDefaultFile = mir_a2t(ssd->pszDefaultFile);
- }
+ TCHAR* ptszDefaultFile;
+ if (ssd->dwFlags & SSDF_UNICODE) {
+ item->ptszDescription = mir_tstrdup(ssd->ptszDescription);
+ item->ptszSection = mir_tstrdup((ssd->pszSection != NULL) ? ssd->ptszSection : _T("Other"));
+ ptszDefaultFile = mir_tstrdup(ssd->ptszDefaultFile);
+ }
+ else {
+ item->ptszDescription = mir_a2t(ssd->pszDescription);
+ item->ptszSection = mir_a2t((ssd->pszSection != NULL) ? ssd->pszSection : "Other");
+ ptszDefaultFile = mir_a2t(ssd->pszDefaultFile);
+ }
- if (ptszDefaultFile) {
- if (DBGetContactSettingString(NULL, "SkinSounds", item->name, &dbv))
- DBWriteContactSettingTString(NULL, "SkinSounds", item->name, ptszDefaultFile);
- else
- DBFreeVariant(&dbv);
- mir_free(ptszDefaultFile);
- }
+ if (ptszDefaultFile) {
+ DBVARIANT dbv;
+ if (DBGetContactSettingString(NULL, "SkinSounds", item->name, &dbv))
+ DBWriteContactSettingTString(NULL, "SkinSounds", item->name, ptszDefaultFile);
+ else
+ DBFreeVariant(&dbv);
+ mir_free(ptszDefaultFile);
+ }
return 0;
}
static int SkinPlaySoundDefault(WPARAM wParam, LPARAM lParam)
{
- char * pszFile = (char *) lParam;
+ char* pszFile = (char *) lParam;
if (pszFile && (DBGetContactSettingByte(NULL, "Skin", "UseSound", 0) || (int)wParam == 1))
PlaySoundA(pszFile, NULL, SND_ASYNC | SND_FILENAME | SND_NOWAIT);
@@ -97,57 +100,35 @@ static int SkinPlaySoundDefault(WPARAM wParam, LPARAM lParam)
static INT_PTR ServiceSkinPlaySound(WPARAM, LPARAM lParam)
{
char* pszSoundName = (char*)lParam;
- int j;
-
- for (j=0; j<soundCount; j++) {
- if (pszSoundName && strcmp(soundList[j].name, pszSoundName) == 0) {
- if (DBGetContactSettingByte(NULL, "SkinSoundsOff", pszSoundName, 0) == 0) {
- DBVARIANT dbv;
+ if (pszSoundName == NULL)
+ return 1;
- if (DBGetContactSettingString(NULL, "SkinSounds", pszSoundName, &dbv) == 0) {
- char szFull[MAX_PATH];
+ SoundItem tmp = { pszSoundName };
+ int idx = arSounds.getIndex( &tmp );
+ if (idx == -1)
+ return 1;
- pathToAbsolute(dbv.pszVal, szFull, NULL);
- NotifyEventHooks(hPlayEvent, 0, (LPARAM)szFull);
- DBFreeVariant(&dbv);
- }
- }
- return 0;
+ if ( DBGetContactSettingByte(NULL, "SkinSoundsOff", pszSoundName, 0) == 0) {
+ DBVARIANT dbv;
+ if ( DBGetContactSettingTString(NULL, "SkinSounds", pszSoundName, &dbv) == 0) {
+ TCHAR szFull[MAX_PATH];
+ pathToAbsoluteT(dbv.ptszVal, szFull, NULL);
+ NotifyEventHooks(hPlayEvent, 0, (LPARAM)szFull);
+ DBFreeVariant(&dbv);
}
}
return 1;
}
-static HTREEITEM FindNamedTreeItemAtRoot(HWND hwndTree, const TCHAR* name)
-{
- TVITEM tvi;
- TCHAR str[128];
-
- tvi.mask = TVIF_TEXT;
- tvi.pszText = str;
- tvi.cchTextMax = SIZEOF(str);
- tvi.hItem = TreeView_GetRoot(hwndTree);
- while (tvi.hItem != NULL) {
- TreeView_GetItem(hwndTree, &tvi);
- if ( !_tcsicmp(str, name))
- return tvi.hItem;
-
- tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem);
- }
- return NULL;
-}
-
#define DM_REBUILD_STREE (WM_USER+1)
#define DM_HIDEPANE (WM_USER+2)
#define DM_SHOWPANE (WM_USER+3)
#define DM_CHECKENABLED (WM_USER+4)
+
INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HWND hwndTree = NULL;
switch (msg) {
- case WM_DESTROY:
- ImageList_Destroy(TreeView_GetImageList(hwndTree, TVSIL_STATE));
- break;
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
hwndTree = GetDlgItem(hwndDlg, IDC_SOUNDTREE);
@@ -165,30 +146,30 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
TreeView_DeleteAllItems(hwndTree);
{
TVINSERTSTRUCT tvis;
- int i;
tvis.hParent = NULL;
tvis.hInsertAfter = TVI_SORT;
tvis.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM;
tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED;
- for (i=0; i < soundCount; i++) {
+ for (int i=0; i < arSounds.getCount(); i++) {
tvis.item.stateMask = TVIS_EXPANDED;
tvis.item.state = TVIS_EXPANDED;
- tvis.hParent = FindNamedTreeItemAtRoot(hwndTree, soundList[i].section);
+ tvis.hParent = FindNamedTreeItemAtRoot(hwndTree, arSounds[i].getSection());
if (tvis.hParent == NULL) {
tvis.item.lParam = -1;
- tvis.item.pszText = soundList[i].section;
+ tvis.item.pszText = arSounds[i].getSection();
tvis.hParent = tvis.item.hItem = TreeView_InsertItem(hwndTree, &tvis);
tvis.item.stateMask = TVIS_STATEIMAGEMASK;
tvis.item.state = INDEXTOSTATEIMAGEMASK(0);
TreeView_SetItem(hwndTree, &tvis.item);
}
tvis.item.stateMask = TVIS_STATEIMAGEMASK;
- tvis.item.state = INDEXTOSTATEIMAGEMASK( !DBGetContactSettingByte(NULL, "SkinSoundsOff", soundList[i].name, 0)?2:1);
+ tvis.item.state = INDEXTOSTATEIMAGEMASK( !DBGetContactSettingByte(NULL, "SkinSoundsOff", arSounds[i].name, 0)?2:1);
tvis.item.lParam = i;
- tvis.item.pszText = soundList[i].description;
+ tvis.item.pszText = arSounds[i].getDescr();
TreeView_InsertItem(hwndTree, &tvis);
} }
- { TVITEM tvi;
+ {
+ TVITEM tvi;
tvi.hItem = TreeView_GetRoot(hwndTree);
while (tvi.hItem != NULL) {
tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE;
@@ -237,125 +218,134 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
SendMessage(hwndDlg, DM_CHECKENABLED, 0, 0);
if (LOWORD(wParam) == IDC_PREVIEW) {
- TVITEM tvi;
- HTREEITEM hti;
+ HTREEITEM hti = TreeView_GetSelection(hwndTree);
+ if (hti == NULL)
+ break;
- ZeroMemory(&tvi, sizeof(tvi));
- ZeroMemory(&hti, sizeof(hti));
- hti=TreeView_GetSelection(hwndTree);
- if (hti == NULL) break;
- tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM|TVIF_TEXT;
+ TVITEM tvi = { 0 };
+ tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT;
tvi.hItem = hti;
- if (TreeView_GetItem(hwndTree, &tvi) == FALSE) break;
- if (tvi.lParam == -1) break;
- if (soundList[tvi.lParam].tempFile)
- NotifyEventHooks(hPlayEvent, 1, (LPARAM)soundList[tvi.lParam].tempFile);
+ if (TreeView_GetItem(hwndTree, &tvi) == FALSE)
+ break;
+ if (tvi.lParam == -1)
+ break;
+
+ if (arSounds[tvi.lParam].ptszTempFile)
+ NotifyEventHooks(hPlayEvent, 1, (LPARAM)arSounds[tvi.lParam].ptszTempFile);
else {
DBVARIANT dbv;
- if ( !DBGetContactSettingString(NULL, "SkinSounds", soundList[tvi.lParam].name, &dbv)) {
- char szPathFull[MAX_PATH];
-
- pathToAbsolute(dbv.pszVal, szPathFull, NULL);
+ if ( !DBGetContactSettingTString(NULL, "SkinSounds", arSounds[tvi.lParam].name, &dbv)) {
+ TCHAR szPathFull[MAX_PATH];
+ pathToAbsoluteT(dbv.ptszVal, szPathFull, NULL);
NotifyEventHooks(hPlayEvent, 1, (LPARAM)szPathFull);
DBFreeVariant(&dbv);
- } }
+ }
+ }
break;
}
+
if (LOWORD(wParam) == IDC_CHANGE) {
- char str[MAX_PATH] = "", strFull[MAX_PATH], strdir[MAX_PATH]="", filter[MAX_PATH];
- OPENFILENAMEA ofn;
- TVITEM tvi;
- HTREEITEM hti;
+ HTREEITEM hti = TreeView_GetSelection(hwndTree);
+ if (hti == NULL)
+ break;
- ZeroMemory(&tvi, sizeof(tvi));
- ZeroMemory(&hti, sizeof(hti));
- hti=TreeView_GetSelection(hwndTree);
- if (hti == NULL) break;
- tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM|TVIF_TEXT;
+ TVITEM tvi = { 0 };
+ tvi.mask = TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM|TVIF_TEXT;
tvi.hItem = hti;
- if (TreeView_GetItem(hwndTree, &tvi) == FALSE) break;
- if (tvi.lParam == -1) break;
- if (soundList[tvi.lParam].tempFile)
- mir_snprintf(strFull, SIZEOF(strFull), "%s", soundList[tvi.lParam].tempFile);
+ if (TreeView_GetItem(hwndTree, &tvi) == FALSE)
+ break;
+ if (tvi.lParam == -1)
+ break;
+
+ SoundItem& snd = arSounds[tvi.lParam];
+
+ TCHAR str[MAX_PATH], strFull[MAX_PATH], strdir[MAX_PATH], filter[MAX_PATH];
+ if (snd.ptszTempFile)
+ _tcsncpy(strFull, snd.ptszTempFile, SIZEOF(strFull));
else {
- if (DBGetContactSettingByte(NULL, "SkinSoundsOff", soundList[tvi.lParam].name, 0) == 0) {
+ if (DBGetContactSettingByte(NULL, "SkinSoundsOff", snd.name, 0) == 0) {
DBVARIANT dbv;
-
- if (DBGetContactSettingString(NULL, "SkinSounds", soundList[tvi.lParam].name, &dbv) == 0) {
- pathToAbsolute(dbv.pszVal, strdir, NULL);
+ if (DBGetContactSettingTString(NULL, "SkinSounds", snd.name, &dbv) == 0) {
+ pathToAbsoluteT(dbv.ptszVal, strdir, NULL);
DBFreeVariant(&dbv);
} } }
- mir_snprintf(strFull, SIZEOF(strFull), "%s", soundList[tvi.lParam].tempFile?soundList[tvi.lParam].tempFile:"");
- pathToAbsolute(strFull, strdir, NULL);
+ mir_sntprintf(strFull, SIZEOF(strFull), _T("%s"), snd.ptszTempFile ? snd.ptszTempFile : _T(""));
+ pathToAbsoluteT(strFull, strdir, NULL);
+
+ OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
- mir_snprintf(filter, SIZEOF(filter), "%s (*.wav; *.mp3; *.ogg; *.flac)%c*.WAV; *.MP3; *.OGG; *.FLAC%c%s (*)%c*%c", Translate("Sound Files"), 0, 0, Translate("All Files"), 0, 0);
+ mir_sntprintf(filter, SIZEOF(filter), _T("%s (*.wav; *.mp3; *.ogg; *.flac)%c*.WAV; *.MP3; *.OGG; *.FLAC%c%s (*)%c*%c"), TranslateT("Sound Files"), 0, 0, TranslateT("All Files"), 0, 0);
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = GetParent(hwndDlg);
ofn.hInstance = NULL;
ofn.lpstrFilter = filter;
- { char* slash = strrchr(strdir, '\\');
- if (slash) {
- *slash = 0;
- ofn.lpstrInitialDir = strdir;
- }
+
+ TCHAR* slash = _tcsrchr(strdir, '\\');
+ if (slash) {
+ *slash = 0;
+ ofn.lpstrInitialDir = strdir;
}
+
+ str[0] = 0;
ofn.lpstrFile = str;
ofn.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_EXPLORER|OFN_LONGNAMES|OFN_NOCHANGEDIR;
ofn.nMaxFile = SIZEOF(str);
ofn.nMaxFileTitle = MAX_PATH;
- ofn.lpstrDefExt = "wav";
- if ( !GetOpenFileNameA(&ofn)) break;
- CallService(MS_UTILS_PATHTORELATIVE, (WPARAM)str, (LPARAM)strFull);
- soundList[tvi.lParam].tempFile = mir_strdup(strFull);
- SetDlgItemTextA(hwndDlg, IDC_LOCATION, strFull);
+ ofn.lpstrDefExt = _T("wav");
+ if ( !GetOpenFileName(&ofn))
+ break;
+
+ CallService(MS_UTILS_PATHTORELATIVET, (WPARAM)str, (LPARAM)strFull);
+ snd.ptszTempFile = mir_tstrdup(strFull);
+ SetDlgItemText(hwndDlg, IDC_LOCATION, strFull);
}
if (LOWORD(wParam) == IDC_GETMORE) {
CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://addons.miranda-im.org/index.php?action=display&id=5");
break;
}
- if (LOWORD(wParam) == IDC_LOCATION) {
- break;
- }
+ if (LOWORD(wParam) == IDC_LOCATION)
+ break;
+
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
+
case WM_NOTIFY:
switch(((LPNMHDR)lParam)->idFrom) {
case 0:
- if (((LPNMHDR)lParam)->code == PSN_APPLY)
- {
- int i;
-
- DBWriteContactSettingByte(NULL, "Skin", "UseSound", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ENABLESOUNDS));
- for (i=0; i < soundCount; i++)
- if (soundList[i].tempFile)
- DBWriteContactSettingString(NULL, "SkinSounds", soundList[i].name, soundList[i].tempFile);
- {
- TVITEM tvi, tvic;
- tvi.hItem = TreeView_GetRoot(hwndTree);
- while (tvi.hItem != NULL) {
- tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE;
- TreeView_GetItem(hwndTree, &tvi);
- if (tvi.lParam == -1) {
- tvic.hItem = TreeView_GetChild(hwndTree, tvi.hItem);
- while (tvic.hItem != NULL) {
- tvic.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE;
- TreeView_GetItem(hwndTree, &tvic);
- if (((tvic.state & TVIS_STATEIMAGEMASK) >> 12 == 2)) {
- DBCONTACTGETSETTING cgs;
- cgs.szModule = "SkinSoundsOff";
- cgs.szSetting = soundList[tvic.lParam].name;
- CallService(MS_DB_CONTACT_DELETESETTING, (WPARAM)(HANDLE)NULL, (LPARAM)&cgs);
- }
- else DBWriteContactSettingByte(NULL, "SkinSoundsOff", soundList[tvic.lParam].name, 1);
- tvic.hItem=TreeView_GetNextSibling(hwndTree, tvic.hItem);
- } }
-
- tvi.hItem=TreeView_GetNextSibling(hwndTree, tvi.hItem);
- } }
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
+ DBWriteContactSettingByte(NULL, "Skin", "UseSound", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ENABLESOUNDS));
+
+ for (int i=0; i < arSounds.getCount(); i++)
+ if (arSounds[i].ptszTempFile)
+ DBWriteContactSettingTString(NULL, "SkinSounds", arSounds[i].name, arSounds[i].ptszTempFile);
+
+ TVITEM tvi, tvic;
+ tvi.hItem = TreeView_GetRoot(hwndTree);
+ while (tvi.hItem != NULL) {
+ tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE;
+ TreeView_GetItem(hwndTree, &tvi);
+ if (tvi.lParam == -1) {
+ tvic.hItem = TreeView_GetChild(hwndTree, tvi.hItem);
+ while (tvic.hItem != NULL) {
+ tvic.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE;
+ TreeView_GetItem(hwndTree, &tvic);
+ if (((tvic.state & TVIS_STATEIMAGEMASK) >> 12 == 2)) {
+ DBCONTACTGETSETTING cgs;
+ cgs.szModule = "SkinSoundsOff";
+ cgs.szSetting = arSounds[tvic.lParam].name;
+ CallService(MS_DB_CONTACT_DELETESETTING, (WPARAM)(HANDLE)NULL, (LPARAM)&cgs);
+ }
+ else DBWriteContactSettingByte(NULL, "SkinSoundsOff", arSounds[tvic.lParam].name, 1);
+ tvic.hItem = TreeView_GetNextSibling(hwndTree, tvic.hItem);
+ } }
+
+ tvi.hItem=TreeView_GetNextSibling(hwndTree, tvi.hItem);
+ }
return TRUE;
}
break;
+
case IDC_SOUNDTREE:
switch(((NMHDR*)lParam)->code) {
case TVN_SELCHANGEDA:
@@ -363,22 +353,22 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
NMTREEVIEW *pnmtv = (NMTREEVIEW*)lParam;
TVITEM tvi = pnmtv->itemNew;
- if (tvi.lParam == -1) {
+ if (tvi.lParam == -1)
SendMessage(hwndDlg, DM_HIDEPANE, 0, 0);
- }
else {
TCHAR buf[256];
- DBVARIANT dbv;
-
- mir_sntprintf(buf, SIZEOF(buf), _T("%s: %s"), soundList[tvi.lParam].section, soundList[tvi.lParam].description);
+ mir_sntprintf(buf, SIZEOF(buf), _T("%s: %s"), arSounds[tvi.lParam].ptszSection, arSounds[tvi.lParam].ptszDescription);
SetDlgItemText(hwndDlg, IDC_NAMEVAL, buf);
- if (soundList[tvi.lParam].tempFile)
- SetDlgItemTextA(hwndDlg, IDC_LOCATION, soundList[tvi.lParam].tempFile);
- else if ( !DBGetContactSettingString(NULL, "SkinSounds", soundList[tvi.lParam].name, &dbv)) {
- SetDlgItemTextA(hwndDlg, IDC_LOCATION, dbv.pszVal);
- DBFreeVariant(&dbv);
+ if (arSounds[tvi.lParam].ptszTempFile)
+ SetDlgItemText(hwndDlg, IDC_LOCATION, arSounds[tvi.lParam].ptszTempFile);
+ else {
+ DBVARIANT dbv;
+ if ( !DBGetContactSettingTString(NULL, "SkinSounds", arSounds[tvi.lParam].name, &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_LOCATION, dbv.ptszVal);
+ DBFreeVariant(&dbv);
+ }
+ else SetDlgItemText(hwndDlg, IDC_LOCATION, TranslateT("<not specified>"));
}
- else SetDlgItemText(hwndDlg, IDC_LOCATION, TranslateT("<not specified>"));
SendMessage(hwndDlg, DM_SHOWPANE, 0, 0);
}
}
@@ -398,15 +388,18 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
hti.pt.y=(short)HIWORD(GetMessagePos());
ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt);
if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti))
- if (hti.flags&TVHT_ONITEM)
- if (hti.flags&TVHT_ONITEMSTATEICON)
- if (TreeView_GetParent(hwndTree, hti.hItem) != NULL)
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMSTATEICON))
+ if (TreeView_GetParent(hwndTree, hti.hItem) != NULL)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
} }
break;
}
break;
+
+ case WM_DESTROY:
+ ImageList_Destroy(TreeView_GetImageList(hwndTree, TVSIL_STATE));
+ break;
}
return FALSE;
}
@@ -438,27 +431,15 @@ int LoadSkinSounds(void)
{
bModuleInitialized = TRUE;
- soundList=NULL;
- soundCount=0;
- CreateServiceFunction(MS_SKIN_ADDNEWSOUND, ServiceSkinAddNewSound);
+ CreateServiceFunction("Skin/Sounds/AddNew", ServiceSkinAddNewSound);
CreateServiceFunction(MS_SKIN_PLAYSOUND, ServiceSkinPlaySound);
HookEvent(ME_SYSTEM_MODULESLOADED, SkinSystemModulesLoaded);
- hPlayEvent=CreateHookableEvent(ME_SKIN_PLAYINGSOUND);
+ hPlayEvent = CreateHookableEvent(ME_SKIN_PLAYINGSOUND);
SetHookDefaultForHookableEvent(hPlayEvent, SkinPlaySoundDefault);
return 0;
}
void UnloadSkinSounds(void)
{
- int i;
-
- if ( !bModuleInitialized) return;
-
- for (i=0;i<soundCount;i++) {
- mir_free(soundList[i].name);
- mir_free(soundList[i].section);
- mir_free(soundList[i].description);
- if (soundList[i].tempFile) mir_free(soundList[i].tempFile);
- }
- if (soundCount) mir_free(soundList);
+ arSounds.destroy();
}
diff --git a/src/modules/srauth/auth.cpp b/src/modules/srauth/auth.cpp
index d0fbe24de5..c8257c3e20 100644
--- a/src/modules/srauth/auth.cpp
+++ b/src/modules/srauth/auth.cpp
@@ -122,8 +122,8 @@ int LoadSendRecvAuthModule(void)
CreateServiceFunction(MS_AUTH_SHOWADDED, ShowAddedWindow);
HookEvent(ME_DB_EVENT_ADDED, AuthEventAdded);
- SkinAddNewSoundEx("AuthRequest", "Alerts", "Authorization request");
- SkinAddNewSoundEx("AddedEvent", "Alerts", "Added event");
+ SkinAddNewSoundEx("AuthRequest", LPGEN("Alerts"), LPGEN("Authorization request"));
+ SkinAddNewSoundEx("AddedEvent", LPGEN("Alerts"), LPGEN("Added event"));
return 0;
}
diff --git a/src/modules/srfile/file.cpp b/src/modules/srfile/file.cpp
index 9d142fcdbe..6f3b3e0ddf 100644
--- a/src/modules/srfile/file.cpp
+++ b/src/modules/srfile/file.cpp
@@ -360,9 +360,9 @@ int LoadSendRecvFileModule(void)
CreateServiceFunction("SRFile/OpenContRecDir", openContRecDir);
CreateServiceFunction("SRFile/OpenRecDir", openRecDir);
- SkinAddNewSoundEx("RecvFile", "File", "Incoming");
- SkinAddNewSoundEx("FileDone", "File", "Complete");
- SkinAddNewSoundEx("FileFailed", "File", "Error");
- SkinAddNewSoundEx("FileDenied", "File", "Denied");
+ SkinAddNewSoundEx("RecvFile", LPGEN("File"), LPGEN("Incoming"));
+ SkinAddNewSoundEx("FileDone", LPGEN("File"), LPGEN("Complete"));
+ SkinAddNewSoundEx("FileFailed", LPGEN("File"), LPGEN("Error"));
+ SkinAddNewSoundEx("FileDenied", LPGEN("File"), LPGEN("Denied"));
return 0;
}
diff --git a/src/modules/srurl/url.cpp b/src/modules/srurl/url.cpp
index 9a7c6b3c32..4eafff94a2 100644
--- a/src/modules/srurl/url.cpp
+++ b/src/modules/srurl/url.cpp
@@ -177,6 +177,6 @@ int LoadSendRecvUrlModule(void)
HookEvent(ME_SYSTEM_PRESHUTDOWN, SRUrlShutdown);
CreateServiceFunction(MS_URL_SENDURL, SendUrlCommand);
CreateServiceFunction("SRUrl/ReadUrl", ReadUrlCommand);
- SkinAddNewSoundEx("RecvUrl", "URL", "Incoming");
+ SkinAddNewSoundEx("RecvUrl", LPGEN("URL"), LPGEN("Incoming"));
return 0;
}
diff --git a/src/modules/useronline/useronline.cpp b/src/modules/useronline/useronline.cpp
index bc41bb2a69..d89dddb2ac 100644
--- a/src/modules/useronline/useronline.cpp
+++ b/src/modules/useronline/useronline.cpp
@@ -112,6 +112,6 @@ int LoadUserOnlineModule(void)
HookEvent(ME_PROTO_ACK, UserOnlineAck);
HookEvent(ME_SYSTEM_MODULESLOADED, UserOnlineModulesLoaded);
HookEvent(ME_PROTO_ACCLISTCHANGED, UserOnlineAccountsChanged);
- SkinAddNewSoundEx("UserOnline", "Alerts", "Online");
+ SkinAddNewSoundEx("UserOnline", LPGEN("Alerts"), LPGEN("Online"));
return 0;
}