diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/ExternalAPI/m_folders.h | 58 | ||||
-rw-r--r-- | plugins/Folders/folders_11.vcxproj | 1 | ||||
-rw-r--r-- | plugins/Folders/folders_11.vcxproj.filters | 3 | ||||
-rw-r--r-- | plugins/Folders/src/dlg_handlers.cpp | 29 | ||||
-rw-r--r-- | plugins/Folders/src/folderItem.cpp | 17 | ||||
-rw-r--r-- | plugins/Folders/src/folderItem.h | 10 | ||||
-rw-r--r-- | plugins/Folders/src/folders.cpp | 1 | ||||
-rw-r--r-- | plugins/Folders/src/foldersList.cpp | 22 | ||||
-rw-r--r-- | plugins/Folders/src/foldersList.h | 6 | ||||
-rw-r--r-- | plugins/Folders/src/services.cpp | 26 | ||||
-rw-r--r-- | plugins/Folders/src/services.h | 2 |
11 files changed, 87 insertions, 88 deletions
diff --git a/plugins/ExternalAPI/m_folders.h b/plugins/ExternalAPI/m_folders.h index 5d1471a1da..550f52f44c 100644 --- a/plugins/ExternalAPI/m_folders.h +++ b/plugins/ExternalAPI/m_folders.h @@ -77,17 +77,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define FF_TCHAR 0
#endif
-typedef struct{
- int cbSize; //size of struct
- LPCSTR szSection; //section name, if it doesn't exist it will be created otherwise it will just add this entry to it
- LPCSTR szName; //entry name - will be shown in options
+typedef struct
+{
+ int cbSize; //size of struct
+ LPCSTR szSection; //section name, if it doesn't exist it will be created otherwise it will just add this entry to it
+ LPCSTR szName; //entry name - will be shown in options
union {
- const char *szFormat; //default string format. Fallback string in case there's no entry in the database for this folder. This should be the initial value for the path, users will be able to change it later.
- const wchar_t *szFormatW; //String is dup()'d so you can free it later. If you set the unicode string don't forget to set the flag accordingly.
+ const char *szFormat; //default string format. Fallback string in case there's no entry in the database for this folder. This should be the initial value for the path, users will be able to change it later.
+ const wchar_t *szFormatW; //String is dup()'d so you can free it later. If you set the unicode string don't forget to set the flag accordingly.
const TCHAR *szFormatT;
};
- DWORD flags; //FF_* flags
-} FOLDERSDATA;
+ DWORD flags; //FF_* flags
+ union {
+ const char *szUserName; //for display purposes. if NULL, plugins gets it as the translated szName
+ const wchar_t *szUserNameW; //String is dup()'d so you can free it later. If you set the unicode string don't forget to set the flag accordingly.
+ const TCHAR *szUserNameT;
+ };
+}
+ FOLDERSDATA;
+
+#define FOLDERSDATA_SIZE_V1 FIELD_OFFSET(FOLDERSDATA,szUserName)
/*Folders/Register/Path service
wParam - not used, must be 0
@@ -140,9 +149,8 @@ typedef struct{ __inline static HANDLE FoldersRegisterCustomPath(const char *section, const char *name, const char *defaultPath)
{
- FOLDERSDATA fd = {0};
if (!ServiceExists(MS_FOLDERS_REGISTER_PATH)) return 0;
- fd.cbSize = sizeof(FOLDERSDATA);
+ FOLDERSDATA fd = { sizeof(fd) };
fd.szSection = section;
fd.szName = name;
fd.szFormat = defaultPath;
@@ -150,14 +158,14 @@ __inline static HANDLE FoldersRegisterCustomPath(const char *section, const char }
#ifdef _UNICODE
-__inline static HANDLE FoldersRegisterCustomPathW(const char *section, const char *name, const wchar_t *defaultPathW)
+__inline static HANDLE FoldersRegisterCustomPathW(const char *section, const char *name, const wchar_t *defaultPathW, const wchar_t *userNameW = NULL)
{
- FOLDERSDATA fd = {0};
if (!ServiceExists(MS_FOLDERS_REGISTER_PATH)) return 0;
- fd.cbSize = sizeof(FOLDERSDATA);
+ FOLDERSDATA fd = { sizeof(fd) };
fd.szSection = section;
fd.szName = name;
fd.szFormatW = defaultPathW;
+ fd.szUserNameW = userNameW;
fd.flags = FF_UNICODE;
return (HANDLE) CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM) &fd);
}
@@ -165,12 +173,10 @@ __inline static HANDLE FoldersRegisterCustomPathW(const char *section, const cha __inline static INT_PTR FoldersGetCustomPath(HANDLE hFolderEntry, char *path, const int size, const char *notFound)
{
- FOLDERSGETDATA fgd = {0};
- INT_PTR res;
- fgd.cbSize = sizeof(FOLDERSGETDATA);
+ FOLDERSGETDATA fgd = { sizeof(fgd) };
fgd.nMaxPathSize = size;
fgd.szPath = path;
- res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
+ INT_PTR res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
if (res) {
char buffer[MAX_PATH];
CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM) notFound, (LPARAM) buffer);
@@ -183,13 +189,11 @@ __inline static INT_PTR FoldersGetCustomPath(HANDLE hFolderEntry, char *path, co #ifdef _UNICODE
__inline static INT_PTR FoldersGetCustomPathW(HANDLE hFolderEntry, wchar_t *pathW, const int size, const wchar_t *notFoundW)
{
- FOLDERSGETDATA fgd = {0};
- INT_PTR res;
- fgd.cbSize = sizeof(FOLDERSGETDATA);
+ FOLDERSGETDATA fgd = { sizeof(fgd) };
fgd.nMaxPathSize = size;
fgd.szPathW = pathW;
fgd.flags = FF_UNICODE;
- res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
+ INT_PTR res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
if (res) {
wchar_t buffer[MAX_PATH];
CallService(MS_UTILS_PATHTOABSOLUTEW, (WPARAM) notFoundW, (LPARAM) buffer);
@@ -202,12 +206,10 @@ __inline static INT_PTR FoldersGetCustomPathW(HANDLE hFolderEntry, wchar_t *path __inline static INT_PTR FoldersGetCustomPathEx(HANDLE hFolderEntry, char *path, const int size, char *notFound, char *fileName)
{
- FOLDERSGETDATA fgd = {0};
- INT_PTR res;
- fgd.cbSize = sizeof(FOLDERSGETDATA);
+ FOLDERSGETDATA fgd = { sizeof(fgd) };
fgd.nMaxPathSize = size;
fgd.szPath = path;
- res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
+ INT_PTR res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
if (res) {
char buffer[MAX_PATH];
CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM) notFound, (LPARAM) buffer);
@@ -228,13 +230,11 @@ __inline static INT_PTR FoldersGetCustomPathEx(HANDLE hFolderEntry, char *path, #ifdef _UNICODE
__inline static INT_PTR FoldersGetCustomPathExW(HANDLE hFolderEntry, wchar_t *pathW, const int size, wchar_t *notFoundW, wchar_t *fileNameW)
{
- FOLDERSGETDATA fgd = {0};
- INT_PTR res;
- fgd.cbSize = sizeof(FOLDERSGETDATA);
+ FOLDERSGETDATA fgd = { sizeof(fgd) };
fgd.nMaxPathSize = size;
fgd.szPathW = pathW;
fgd.flags = FF_UNICODE;
- res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
+ INT_PTR res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
if (res) {
wchar_t buffer[MAX_PATH];
CallService(MS_UTILS_PATHTOABSOLUTEW, (WPARAM) notFoundW, (LPARAM) buffer);
diff --git a/plugins/Folders/folders_11.vcxproj b/plugins/Folders/folders_11.vcxproj index 861ea373d2..4c0858773e 100644 --- a/plugins/Folders/folders_11.vcxproj +++ b/plugins/Folders/folders_11.vcxproj @@ -196,6 +196,7 @@ <ClCompile Include="src\utils.cpp" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\ExternalAPI\m_folders.h" />
<ClInclude Include="src\commonheaders.h" />
<ClInclude Include="src\dlg_handlers.h" />
<ClInclude Include="src\events.h" />
diff --git a/plugins/Folders/folders_11.vcxproj.filters b/plugins/Folders/folders_11.vcxproj.filters index 2a6e8eea72..30086fbee5 100644 --- a/plugins/Folders/folders_11.vcxproj.filters +++ b/plugins/Folders/folders_11.vcxproj.filters @@ -74,6 +74,9 @@ <ClInclude Include="src\version.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\ExternalAPI\m_folders.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\folders.rc">
diff --git a/plugins/Folders/src/dlg_handlers.cpp b/plugins/Folders/src/dlg_handlers.cpp index d36a68ebc3..8bd851f207 100644 --- a/plugins/Folders/src/dlg_handlers.cpp +++ b/plugins/Folders/src/dlg_handlers.cpp @@ -14,19 +14,11 @@ int GetCurrentSectionSelection(HWND hWnd) return SendDlgItemMessage(hWnd, IDC_FOLDERS_SECTIONS_LIST, LB_GETCURSEL, 0, 0);
}
-PFolderItem GetSelectedItem(HWND hWnd)
-{
- char section[MAX_FOLDER_SIZE], item[MAX_FOLDER_SIZE];
- GetCurrentItemText(hWnd, item, MAX_FOLDER_SIZE);
- GetCurrentSectionText(hWnd, section, MAX_FOLDER_SIZE);
- return lstRegisteredFolders.GetTranslated(section, item);
-}
-
-int GetCurrentItemText(HWND hWnd, char *buffer, int count)
+int GetCurrentItemText(HWND hWnd, TCHAR *buffer, int count)
{
int index = GetCurrentItemSelection(hWnd);
if (index != LB_ERR) {
- SendDlgItemMessageA(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_GETTEXT, index, (LPARAM) buffer);
+ SendDlgItemMessage(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_GETTEXT, index, (LPARAM)buffer);
return 1;
}
@@ -38,12 +30,21 @@ int GetCurrentSectionText(HWND hWnd, char *buffer, int count) {
int index = GetCurrentSectionSelection(hWnd);
if (index != LB_ERR)
- SendDlgItemMessageA(hWnd, IDC_FOLDERS_SECTIONS_LIST, LB_GETTEXT, index, (LPARAM) buffer);
+ SendDlgItemMessageA(hWnd, IDC_FOLDERS_SECTIONS_LIST, LB_GETTEXT, index, (LPARAM)buffer);
else
buffer[0] = L'0';
return index;
}
+PFolderItem GetSelectedItem(HWND hWnd)
+{
+ char section[MAX_FOLDER_SIZE];
+ TCHAR item[MAX_FOLDER_SIZE];
+ GetCurrentItemText(hWnd, item, MAX_FOLDER_SIZE);
+ GetCurrentSectionText(hWnd, section, MAX_FOLDER_SIZE);
+ return lstRegisteredFolders.GetTranslated(section, item);
+}
+
static void GetEditText(HWND hWnd, TCHAR *buffer, int size)
{
GetWindowText( GetDlgItem(hWnd, IDC_FOLDER_EDIT), buffer, size);
@@ -87,10 +88,8 @@ void LoadRegisteredFolderItems(HWND hWnd) for (int i = 0; i < lstRegisteredFolders.Count(); i++) {
PFolderItem item = lstRegisteredFolders.Get(i + 1);
- if ( !strcmp(szSection, item->GetSection())) {
- mir_ptr<TCHAR> wide( mir_a2t( item->GetName()));
- SendDlgItemMessage(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_ADDSTRING, 0, (LPARAM)TranslateTS(wide));
- }
+ if ( !strcmp(szSection, item->GetSection()))
+ SendDlgItemMessage(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_ADDSTRING, 0, (LPARAM)TranslateTS(item->GetUserName()));
}
SendDlgItemMessage(hWnd, IDC_FOLDERS_ITEMS_LIST, LB_SETCURSEL, 0, 0); //select the first item
PostMessage(hWnd, WM_COMMAND, MAKEWPARAM(IDC_FOLDERS_ITEMS_LIST, LBN_SELCHANGE), 0); //tell the dialog to refresh the preview
diff --git a/plugins/Folders/src/folderItem.cpp b/plugins/Folders/src/folderItem.cpp index fe16f30d7a..4125d43d4a 100644 --- a/plugins/Folders/src/folderItem.cpp +++ b/plugins/Folders/src/folderItem.cpp @@ -20,13 +20,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h"
-CFolderItem::CFolderItem(const char *sectionName, const char *name, const TCHAR *format, const DWORD flags)
+CFolderItem::CFolderItem(const char *sectionName, const char *name, const TCHAR *format, const TCHAR *userName)
{
m_szSection = mir_strdup(sectionName);
m_szName = mir_strdup(name);
+ if (userName)
+ m_tszUserName = mir_tstrdup(userName);
+ else
+ m_tszUserName = mir_a2t(name);
m_tszFormat = NULL;
m_tszOldFormat = NULL;
- m_flags = flags;
GetDataFromDatabase(format);
FolderCreateDirectory();
}
@@ -48,17 +51,17 @@ void CFolderItem::SetFormat(const TCHAR *newFormat) int CFolderItem::IsEqual(const CFolderItem *other)
{
- return (IsEqual(other->GetSection(), other->GetName()));
+ return (IsEqual(other->GetSection(), other->GetUserName()));
}
-int CFolderItem::IsEqual(const char *section, const char *name)
+int CFolderItem::IsEqual(const char *section, const TCHAR *name)
{
- return ((strcmp(m_szName, name) == 0) && (strcmp(m_szSection, section) == 0));
+ return !_tcscmp(m_tszUserName, name) && !strcmp(m_szSection, section);
}
-int CFolderItem::IsEqualTranslated(const char *trSection, const char *trName)
+int CFolderItem::IsEqualTranslated(const char *trSection, const TCHAR *trName)
{
- return ((strcmp(Translate(m_szName), trName) == 0) && (strcmp(Translate(m_szSection), trSection) == 0));
+ return !_tcscmp( TranslateTS(m_tszUserName), trName) && !strcmp(Translate(m_szSection), trSection);
}
int CFolderItem::operator ==(const CFolderItem *other)
diff --git a/plugins/Folders/src/folderItem.h b/plugins/Folders/src/folderItem.h index 89731b32be..1883cad207 100644 --- a/plugins/Folders/src/folderItem.h +++ b/plugins/Folders/src/folderItem.h @@ -39,8 +39,7 @@ class CFolderItem {
char *m_szSection;
char *m_szName;
- TCHAR *m_tszFormat, *m_tszOldFormat;
- DWORD m_flags;
+ TCHAR *m_tszFormat, *m_tszOldFormat, *m_tszUserName;
void GetDataFromDatabase(const TCHAR *szNotFound);
void WriteDataToDatabase();
@@ -48,19 +47,20 @@ class CFolderItem int FolderCreateDirectory(int showFolder = 0);
int FolderDeleteOldDirectory(int showFolder = 0);
public:
- CFolderItem(const char *sectionName, const char *name, const TCHAR *format, const DWORD flags);
+ CFolderItem(const char *sectionName, const char *name, const TCHAR *format, const TCHAR *userName);
virtual ~CFolderItem();
void Expand(TCHAR *buffer, int size);
void Save();
int IsEqual(const CFolderItem *other);
- int IsEqual(const char *section, const char *name);
- int IsEqualTranslated(const char *trSection, const char *trName);
+ int IsEqual(const char *section, const TCHAR *name);
+ int IsEqualTranslated(const char *trSection, const TCHAR *trName);
int operator ==(const CFolderItem *other);
__inline const char* GetSection() const { return m_szSection; }
__inline const char* GetName() const { return m_szName; }
+ __inline const TCHAR* GetUserName() const { return m_tszUserName; }
__inline const TCHAR* GetFormat() const { return m_tszFormat; }
void SetFormat(const TCHAR *newFormat);
};
diff --git a/plugins/Folders/src/folders.cpp b/plugins/Folders/src/folders.cpp index 638f539143..d9e61f675f 100644 --- a/plugins/Folders/src/folders.cpp +++ b/plugins/Folders/src/folders.cpp @@ -57,7 +57,6 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload()
{
- DestroyServices();
DestroyEvents();
UnhookEvents();
return 0;
diff --git a/plugins/Folders/src/foldersList.cpp b/plugins/Folders/src/foldersList.cpp index e003ad81ab..1f7ab3aef5 100644 --- a/plugins/Folders/src/foldersList.cpp +++ b/plugins/Folders/src/foldersList.cpp @@ -67,7 +67,7 @@ PFolderItem CFoldersList::Get(int index) return list[index];
}
-PFolderItem CFoldersList::Get(const char *section, const char *name)
+PFolderItem CFoldersList::Get(const char *section, const TCHAR *name)
{
for (int i = 0; i < count; i++)
if (list[i]->IsEqual(section, name))
@@ -76,7 +76,7 @@ PFolderItem CFoldersList::Get(const char *section, const char *name) return NULL;
}
-PFolderItem CFoldersList::GetTranslated(const char *trSection, const char *trName)
+PFolderItem CFoldersList::GetTranslated(const char *trSection, const TCHAR *trName)
{
for (int i = 0; i < count; i++)
if (list[i]->IsEqualTranslated(trSection, trName))
@@ -112,13 +112,17 @@ int CFoldersList::Add(CFolderItem *item) int CFoldersList::Add(FOLDERSDATA* data)
{
- CFolderItem *item;
+ FOLDERSDATA tmp;
+ if (data->cbSize < sizeof(FOLDERSDATA)) {
+ memset(&tmp, 0, sizeof(FOLDERSDATA));
+ memcpy(&tmp, data, data->cbSize);
+ data = &tmp;
+ }
+
if (data->flags & FF_UNICODE)
- item = new CFolderItem(data->szSection, data->szName, data->szFormatW, data->flags);
- else
- item = new CFolderItem(data->szSection, data->szName, _A2T(data->szFormat), data->flags);
+ return Add( new CFolderItem(data->szSection, data->szName, data->szFormatW, data->szUserNameW));
- return Add(item);
+ return Add( new CFolderItem(data->szSection, data->szName, _A2T(data->szFormat), _A2T(data->szUserName)));
}
void CFoldersList::Remove(CFolderItem *item)
@@ -131,10 +135,10 @@ void CFoldersList::Remove(int uniqueID) int CFoldersList::Contains(CFolderItem *item)
{
- return Contains(item->GetSection(), item->GetName());
+ return Contains(item->GetSection(), item->GetUserName());
}
-int CFoldersList::Contains(const char *section, const char *name)
+int CFoldersList::Contains(const char *section, const TCHAR *name)
{
for (int i = 0; i < count; i++)
if (list[i]->IsEqual(section, name))
diff --git a/plugins/Folders/src/foldersList.h b/plugins/Folders/src/foldersList.h index 93ea38cc57..bbe789e5c5 100644 --- a/plugins/Folders/src/foldersList.h +++ b/plugins/Folders/src/foldersList.h @@ -51,14 +51,14 @@ class CFoldersList{ void Remove(CFolderItem *item);
void Remove(int uniqueID);
int Contains(CFolderItem *item);
- int Contains(const char *section, const char *name);
+ int Contains(const char *section, const TCHAR *name);
int Count();
int Capacity();
PFolderItem Get(int index);
- PFolderItem Get(const char *section, const char *name);
- PFolderItem GetTranslated(const char *trSection, const char *trName);
+ PFolderItem Get(const char *section, const TCHAR *name);
+ PFolderItem GetTranslated(const char *trSection, const TCHAR *trName);
int Expand(int index, TCHAR *szResult, int size);
void Save();
};
diff --git a/plugins/Folders/src/services.cpp b/plugins/Folders/src/services.cpp index 4178dd49e8..5fb4a404a8 100644 --- a/plugins/Folders/src/services.cpp +++ b/plugins/Folders/src/services.cpp @@ -27,11 +27,6 @@ TCHAR szCurrentProfile[MAX_FOLDERS_PATH]; TCHAR szMirandaPath[MAX_FOLDERS_PATH];
TCHAR szUserDataPath[MAX_FOLDERS_PATH];
-HANDLE hsFoldersGetPath;
-HANDLE hsFoldersGetSize;
-HANDLE hsFoldersGetPathAlloc;
-HANDLE hsFoldersRegisterPath;
-
INT_PTR ExpandPath(TCHAR *szResult, TCHAR *format, int size)
{
szResult[0] = '\0';
@@ -62,8 +57,11 @@ INT_PTR ExpandPath(TCHAR *szResult, TCHAR *format, int size) INT_PTR RegisterPathService(WPARAM wParam, LPARAM lParam)
{
- FOLDERSDATA *tmp = (FOLDERSDATA *) lParam;
- if (tmp == NULL || tmp->cbSize != sizeof(FOLDERSDATA))
+ FOLDERSDATA *tmp = (FOLDERSDATA*)lParam;
+ if (tmp == NULL)
+ return NULL;
+
+ if (tmp->cbSize != sizeof(FOLDERSDATA) && tmp->cbSize != FOLDERSDATA_SIZE_V1)
return NULL;
return lstRegisteredFolders.Add(tmp); //returns 1..n or 0 on error
@@ -113,16 +111,8 @@ int InitServices() mir_sntprintf(szUserDataPath, MAX_FOLDERS_PATH, szTemp);
mir_free(szTemp);
- hsFoldersGetPath = CreateServiceFunction(MS_FOLDERS_GET_PATH, GetPathService);
- hsFoldersGetSize = CreateServiceFunction(MS_FOLDERS_GET_SIZE, GetPathSizeService);
- hsFoldersRegisterPath = CreateServiceFunction(MS_FOLDERS_REGISTER_PATH, RegisterPathService);
- return 0;
-}
-
-int DestroyServices()
-{
- DestroyServiceFunction(hsFoldersGetPath);
- DestroyServiceFunction(hsFoldersGetSize);
- DestroyServiceFunction(hsFoldersRegisterPath);
+ CreateServiceFunction(MS_FOLDERS_GET_PATH, GetPathService);
+ CreateServiceFunction(MS_FOLDERS_GET_SIZE, GetPathSizeService);
+ CreateServiceFunction(MS_FOLDERS_REGISTER_PATH, RegisterPathService);
return 0;
}
diff --git a/plugins/Folders/src/services.h b/plugins/Folders/src/services.h index 2a96493193..b4fc3a8812 100644 --- a/plugins/Folders/src/services.h +++ b/plugins/Folders/src/services.h @@ -31,7 +31,7 @@ extern TCHAR szCurrentProfile[MAX_FOLDERS_PATH]; extern TCHAR szMirandaPath[MAX_FOLDERS_PATH];
int InitServices();
-int DestroyServices();
+
INT_PTR ExpandPath(TCHAR *szResult, TCHAR *format, int size);
INT_PTR GetPath(int hRegisteredFolder, TCHAR *szResult, int size);
|