From cb4a46e7fbe62d788e66ed6121c717a2d22a4d7c Mon Sep 17 00:00:00 2001 From: watcherhd Date: Thu, 21 Apr 2011 14:14:52 +0000 Subject: svn.miranda.im is moving to a new home! git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@7 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- dbeditorpp/modules.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 dbeditorpp/modules.c (limited to 'dbeditorpp/modules.c') diff --git a/dbeditorpp/modules.c b/dbeditorpp/modules.c new file mode 100644 index 0000000..bfaff6e --- /dev/null +++ b/dbeditorpp/modules.c @@ -0,0 +1,109 @@ +#include "headers.h" + + +void renameModule(char* oldName, char* newName, HANDLE hContact) +{ + DBVARIANT dbv; + ModuleSettingLL settinglist; + struct ModSetLinkLinkItem *setting; + + if (!EnumSettings(hContact,oldName,&settinglist)) { msg(Translate("Error Loading Setting List"),modFullname); return;} + + setting = settinglist.first; + while (setting) + { + if (!GetSetting(hContact,oldName,setting->name,&dbv)) + { + switch (dbv.type) + { + case DBVT_BYTE: + DBWriteContactSettingByte(hContact, newName, setting->name, dbv.bVal); + break; + case DBVT_WORD: + DBWriteContactSettingWord(hContact, newName, setting->name, dbv.wVal); + break; + case DBVT_DWORD: + DBWriteContactSettingDword(hContact, newName, setting->name, dbv.dVal); + break; + case DBVT_ASCIIZ: + DBWriteContactSettingString(hContact, newName, setting->name, dbv.pszVal); + break; + case DBVT_UTF8: + DBWriteContactSettingStringUtf(hContact, newName, setting->name, dbv.pszVal); + break; + case DBVT_BLOB: + DBWriteContactSettingBlob(hContact, newName, setting->name, dbv.pbVal, dbv.cpbVal); + break; + + } + DBDeleteContactSetting(hContact, oldName, setting->name); + } + DBFreeVariant(&dbv); + setting = (struct ModSetLinkLinkItem *)setting->next; + } + FreeModuleSettingLL(&settinglist); +} + +BOOL CALLBACK AddModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + if (msg == WM_INITDIALOG) + { + SetWindowLong(hwnd,GWL_USERDATA,lParam); + TranslateDialogDefault(hwnd); + } + if (msg == WM_COMMAND) + { + switch(LOWORD(wParam)) + { + case IDOK: + { + if (GetWindowTextLength(GetDlgItem(hwnd, IDC_MODNAME))) + { + char modulename[256]; + GetDlgItemText(hwnd, IDC_MODNAME, modulename, 256); + if (IsDlgButtonChecked(hwnd,CHK_ADD2ALL)) + { + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + // null contact + DBWriteContactSettingByte(NULL, modulename, "(Default)", 0); + while (hContact) + { + DBWriteContactSettingByte(hContact, modulename, "(Default)", 0); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)(HANDLE)hContact, 0); + } + } + else + { + DBWriteContactSettingByte((HANDLE)GetWindowLong(hwnd,GWL_USERDATA), modulename, "(Default)", 0); + } + refreshTree(1); + } + } + // fall through + case IDCANCEL: + DestroyWindow(hwnd); + break; + } + } + return 0; +} + +int CloneContact(HANDLE hContact) +{ + HANDLE newContact = (HANDLE)CallService(MS_DB_CONTACT_ADD,0,0); + + ModuleSettingLL modlist; + struct ModSetLinkLinkItem *mod; + if (!newContact) return 0; + // enum all the modules + if (!EnumModules(&modlist)) { msg(Translate("Error Loading Module List"),modFullname); return 0;} + + mod = modlist.first; + while (mod) + { + copyModule(mod->name,hContact,newContact); + mod = (struct ModSetLinkLinkItem *)mod->next; + } + FreeModuleSettingLL(&modlist); + return 1; +} \ No newline at end of file -- cgit v1.2.3