summaryrefslogtreecommitdiff
path: root/plugins/DbEditorPP/src/renamemodule.cpp
diff options
context:
space:
mode:
authorDmitry Kuzkin <bio@ktaspb.ru>2015-06-18 12:36:07 +0000
committerDmitry Kuzkin <bio@ktaspb.ru>2015-06-18 12:36:07 +0000
commit1bb9a86b26d3a9964844d42fa25690ce0a028258 (patch)
tree6c0645ade07ec6b4d36e38a1ba77e457e8cf6ade /plugins/DbEditorPP/src/renamemodule.cpp
parenta27ae3e0c1f1f17596db3abeae16ec3fc4b4ba80 (diff)
true unicode build (ansi build is possible but useless)
new search/replace dialog edit improvements (type check) resident settings support (fully resident modules are still invisible) remove obsolete things code cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@14243 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/DbEditorPP/src/renamemodule.cpp')
-rw-r--r--plugins/DbEditorPP/src/renamemodule.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/plugins/DbEditorPP/src/renamemodule.cpp b/plugins/DbEditorPP/src/renamemodule.cpp
new file mode 100644
index 0000000000..fca6c7d3cc
--- /dev/null
+++ b/plugins/DbEditorPP/src/renamemodule.cpp
@@ -0,0 +1,70 @@
+#include "headers.h"
+
+
+int renameModule(MCONTACT hContact, const char *oldName, const char *newName)
+{
+ DBVARIANT dbv;
+ ModuleSettingLL settinglist;
+
+ if (IsModuleEmpty(hContact, oldName) || !EnumSettings(hContact, oldName, &settinglist))
+ return 0;
+
+ int cnt = 0;
+
+ for(ModSetLinkLinkItem *setting = settinglist.first; setting; setting = setting->next) {
+ if (!db_get_s(hContact, oldName, setting->name, &dbv, 0)) {
+ db_set(hContact, newName, setting->name, &dbv);
+ db_unset(hContact, oldName, setting->name);
+ db_free(&dbv);
+ cnt++;
+ }
+ }
+ FreeModuleSettingLL(&settinglist);
+ return cnt;
+}
+
+INT_PTR CALLBACK AddModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg) {
+ case WM_INITDIALOG:
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
+ TranslateDialogDefault(hwnd);
+
+ TCHAR msg[MSG_SIZE], name[NAME_SIZE];
+ GetContactName((MCONTACT)lParam, NULL, name, SIZEOF(name));
+
+ mir_sntprintf(msg, TranslateT("Add module to \"%s\""), name);
+ SetWindowText(hwnd, msg);
+
+ break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ if (GetWindowTextLength(GetDlgItem(hwnd, IDC_MODNAME))) {
+ char modulename[FLD_SIZE];
+ GetDlgItemTextA(hwnd, IDC_MODNAME, modulename, SIZEOF(modulename));
+ if (IsDlgButtonChecked(hwnd, CHK_ADD2ALL)) {
+ // null contact
+ db_set_b(NULL, modulename, "(Default)", 0);
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ db_set_b(hContact, modulename, "(Default)", 0);
+ }
+ else
+ db_set_b((MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA), modulename, "(Default)", 0);
+
+ refreshTree(1);
+ }
+ // fall through
+ case IDCANCEL:
+ DestroyWindow(hwnd);
+ break;
+ }
+ }
+ return 0;
+}
+
+
+void addModuleDlg(MCONTACT hContact)
+{
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd2mainWindow, AddModDlgProc, hContact);
+}