From 366f71877c14fe9b452f435b1b8ed2ed1caf5115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Tue, 29 Oct 2013 20:28:55 +0000 Subject: Adopted RPS plugin First compilable version. git-svn-id: http://svn.miranda-ng.org/main/trunk@6687 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/rps/Docs/rps_changelog.txt | 22 + plugins/rps/Docs/rps_readme.txt | 22 + plugins/rps/Docs/rps_version.txt | 1 + plugins/rps/RemovePersonalSettings.ini | 247 ++++++++++ plugins/rps/rps.cpp | 826 +++++++++++++++++++++++++++++++++ plugins/rps/rps.vcxproj | 271 +++++++++++ plugins/rps/rps.vcxproj.filters | 39 ++ 7 files changed, 1428 insertions(+) create mode 100644 plugins/rps/Docs/rps_changelog.txt create mode 100644 plugins/rps/Docs/rps_readme.txt create mode 100644 plugins/rps/Docs/rps_version.txt create mode 100644 plugins/rps/RemovePersonalSettings.ini create mode 100644 plugins/rps/rps.cpp create mode 100644 plugins/rps/rps.vcxproj create mode 100644 plugins/rps/rps.vcxproj.filters diff --git a/plugins/rps/Docs/rps_changelog.txt b/plugins/rps/Docs/rps_changelog.txt new file mode 100644 index 0000000000..1b1091452b --- /dev/null +++ b/plugins/rps/Docs/rps_changelog.txt @@ -0,0 +1,22 @@ +Remove Personal Settings + +Changelog: + +. 0.1.0.4 + + Added * to delete module names + + Added miranda 0.8 support + + Updated ini file + +. 0.1.0.3 + + Added option to delete modules based on a sufix of the protocol name + + Added * to delete settings names + + Added config to delete alarms and sent files + +. 0.1.0.2 + + Added SetProtocolsOffline + * Bugfixes + +. 0.1.0.1 + + Added RemoveWholeProtocolModule + + Added DisabledProtocols to delete settings from these + + Added deletion of events from DB \ No newline at end of file diff --git a/plugins/rps/Docs/rps_readme.txt b/plugins/rps/Docs/rps_readme.txt new file mode 100644 index 0000000000..f6aed13a06 --- /dev/null +++ b/plugins/rps/Docs/rps_readme.txt @@ -0,0 +1,22 @@ +Remove Personal Settings plugin +------------------------------- + +WARNING: THIS PLUGIN DELETE SETTINGS FROM MIRANDA DB AND FROM THE HD. THIS CAN'T BE UNDONE. IT CAN DELETE ALL FILES IN YOUR COMPUTER (ALTOUGHT IT NEVER HAPPENED TO ME :P ). USE IT AT YOUR OWN RISK. + +This is a plugin that removes personal settings from database. + +It can remove all users, remove some files and directories from miranda dir (but only if these aren't beeing used), call services and disable plugins. To do that it is based in a configuration .ini file. If you need some especial configuration (and probabily you will need, because I just put some settings there, but I bet I forgot some), just edit the file RemovePersonalSettings.ini + +The idea for using this plugin is to allow sending a copy of you miranda with your actual configuration, but without your personal settings. To use it, you should: +1) Copy the hole miranda dir to other location +2) Enable the plugin (if it isn't enabled) +4) Set global status to offline +3) Run the menu option "Remove personal settings..." +4) Exit miranda +4) Run DBTOOL.EXE to compact sweeped database file +5) Pack and send to your friend + +I made this based on the discussion in the thread: +http://forums.miranda-im.org/showthread.php?t=5224. I asked the source from nullbie and made my version of the plugin. + +To report bugs/make suggestions, go to the forum thread: http://forums.miranda-im.org/showthread.php?t=5451 diff --git a/plugins/rps/Docs/rps_version.txt b/plugins/rps/Docs/rps_version.txt new file mode 100644 index 0000000000..affe4aa1c3 --- /dev/null +++ b/plugins/rps/Docs/rps_version.txt @@ -0,0 +1 @@ +Remove Personal Settings 0.1.0.4 \ No newline at end of file diff --git a/plugins/rps/RemovePersonalSettings.ini b/plugins/rps/RemovePersonalSettings.ini new file mode 100644 index 0000000000..789803de56 --- /dev/null +++ b/plugins/rps/RemovePersonalSettings.ini @@ -0,0 +1,247 @@ +[GlobalSettings] +; Set protocol status to offline before any other action +; true or false +; default=true +SetProtocolsOffline=true + +; Remove all folders that have protocol names inside miranda folder +; true or false +; default=true +RemoveProtocolFolders=true + +; Remove all miranda users +; true or false +; default=true +RemoveAllUsers=true + +; Remove some default settings for all enabled protocols +; The name of the module has to be the same name as the name of the protocol +; These are the ones under ProtocolSettings +; true or false +; default=true +RemoveProtocolSettings=true + +; Remove all settings inside the protocol module +; (and not only the ones at ProtocolSettings) +; true or false +; default=false +RemoveWholeProtocolModule=false + +[DisabledProtocols] +; Names of protocols that are disabled, but have to has its settings deleted +; The case must be correct! +YAHOO +YAHOO1 +YAHOO2 +YAHOO3 +YAHOO4 +MSN +MSN1 +MSN2 +MSN3 +MSN4 +ICQ +ICQ1 +ICQ2 +ICQ3 +ICQ4 +GG +GG1 +GG2 +GG3 +GG4 +JABBER +JABBER1 +JABBER2 +JABBER3 +JABBER4 +JGMAIL +JGMAIL1 +JGMAIL2 +JGMAIL3 +JGMAIL4 +MEEBO +MEEBO1 +MEEBO2 +MEEBO3 +MEEBO4 +AIM +AIM1 +AIM2 +AIM3 +AIM4 +SKYPE +MYSPACE + +[ProtocolSettings] +; Settings that will be erased for all enabled protocols if RemoveProtocolSettings == true +; Names with spaces or strange chars must be surrounded by " +Password +"Nick" +LoginName +DisplayName +PNick +SN +Name +FirstName +LastName +Username +UserName +User +UID +Timezone +e-mail +Email +email +UIN +IdleTS +InfoTS +LogonTS +MemberTS +LastSyncTime +PictObject +YourHost +AvatarFile +AvatarFilename +AvatarHash +AvatarSaved +ImageURL +BirthDay +BirthMonth +BirthYear +MaritalStatus +Gender +Age +CompanyOccupation +Country +OriginCountry +Location +InfoCP +PublishPrimaryEmail +SrvAvatarID +SrvDefGroupId +SrvLastUpdate +SrvRecordCount +SrvVisibility +SrvVisibilityID +XStatusMsg +XStatusMessage +AlernativeNick +Status +ServerComboSelection +UserID +Resource +FirstRun +WebAvare +FullName +LoginName +"First Name" +"Last Name" +jid +Profile +NLProxyPort +NLProxyServer +City +Language1 +Language2 +Language3 +Past0 +IP +RealIP +State +QuitMessage +UserInfo +GenderString +GoogleToken +Override +yahoo_id +AvatarURL +AvatarInv + +[ProtocolModuleSufixes] +; Strings here will be appended to each protocol name and the module with this name +; will be deleted (the whole module) +; Names with spaces or strange chars must be surrounded by " +Groups +SrvGroups +P2P +:HotmailNotify + +[RemoveSettings] +; Settings that should be removed +; Only from hContact == NULL +; To remove a module, use ModuleName +; To remove a setting, use ModuleName/SettingName +; To remove all settings that start with a name, use * as last char +; Ex: Test/Test* +; To remove all settings that end with a name, use * as first key char +; Ex: Test/*Test +; Settings are case sensitive +; Names with spaces or strange chars must be surrounded by " +"Gmail Notifier/name" +"Gmail Notifier/pass" +POP3 +pattern +Options +ContactPhoto/File +MIMImport +*/Password +*/password +FTPFile/password +FTPFile/user +FTPFile/url +FTPFile/server +SMSPlugin +SRFile/MruDir* +SRFile/RecvFilesDirAdv +UserOnline +WebSMS-Plugin/LastNumber* +WebSMS-Plugin/LastPrefix* +"WinPopup Protocol/Nick" +"WinPopup Protocol/User" +"WinPopup Protocol/Workgroup" +NET_SEND/loging_name +Alarm/ActionFlags* +Alarm/Desc* +Alarm/Hidden* +Alarm/Occ* +Alarm/NoStartup* +Alarm/Snoozer* +Alarm/SoundNum* +Alarm/STDay* +Alarm/STHour* +Alarm/STMinute* +Alarm/STMonth* +Alarm/STSecond* +Alarm/STYear* +Alarm/Suspended* +Alarm/Title* +*/NLProxyPort +*/NLProxyServer +QuickContacts/LastSentTo +VersionInfo/UploadPassword +VersionInfo/UploadUser + +[ExecuteServices] +; Always calls passing 0 as wParam and lParam +; Names with spaces or strange chars must be surrounded by " +DB3XS/RemovePassword + +[RemoveFilesOrFolders] +; This should be names inside miranda folder +; Names with spaces or strange chars must be surrounded by " +; * and ? can be used +Avatars +"Avatars History" +Logs +"Received Files" +tabSRMM +Updates +UpdateData +UpdateBackups +yamn-accounts.pop3.*.book + +[DisablePlugins] +; Plugins dlls to be disabled +; Names with spaces or strange chars must be surrounded by " +RemovePersonalSettings.dll diff --git a/plugins/rps/rps.cpp b/plugins/rps/rps.cpp new file mode 100644 index 0000000000..1d0f801e41 --- /dev/null +++ b/plugins/rps/rps.cpp @@ -0,0 +1,826 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2005 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Created by Pescuma +Based on work by nullbie + +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MIID_REMOVEPERSONALSETTINGS { 0x5eaec989, 0x8ff, 0x4820, { 0xb8, 0x6c, 0x2b, 0x6e, 0xf0, 0x8e, 0x33, 0x73 } } + +#define INI_FILE_NAME "RemovePersonalSettings.ini" + +#define PLUGINDISABLELIST "PluginDisable" + +#define METACONTACTS_PROTOCOL_NAME "MetaContacts" + + +HINSTANCE hInst; +char gIniFile[MAX_PATH]; +char gMirandaDir[MAX_PATH]; + +int hLangpack; + + +PLUGININFOEX pluginInfo={ + sizeof(PLUGININFOEX), + "Remove Personal Settings", + PLUGIN_MAKE_VERSION(0,1,0,4), + "Remove personal settings to allow to send a profile to other user(s) without sending personal data.", + "Ricardo Pescuma Domenecci", + "", + "© 2007-2009 Ricardo Pescuma Domenecci", + "http://pescuma.org/miranda/rps", + 0, //not transient + { 0x60e94b84, 0xa799, 0x4021, { 0x94, 0x49, 0x5b, 0x83, 0x8f, 0xc0, 0x6a, 0x7c } } // {60E94B84-A799-4021-9449-5B838FC06A7C} +}; + + +INT_PTR RemoveAllService(WPARAM wParam,LPARAM lParam); +void SetProtocolsOffline(); +void RemoveUsers(); +void RemoveSettings(); +void ExecuteServices(); +void RemoveDirectories(); +void DisablePlugins(); + +// Ini access functions +BOOL GetSettingBool(const char *section, const char *key, BOOL defaultValue); +BOOL GetSettings(const char *section, char *buffer, size_t bufferSize); + + +// Utils +void DeleteFileOrFolder(const char *name); +void DeleteSetting(const char *setting); +void DeleteSettingEx(const char *szModule, const char *szSetting); +BOOL isMetaContact(HANDLE hContact); + + + +BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + hInst=hinstDLL; + return TRUE; +} + + +__declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + // Are we running under Unicode Windows version ? + if ((GetVersion() & 0x80000000) == 0) + pluginInfo.flags = 1; // UNICODE_AWARE + + pluginInfo.cbSize = sizeof(PLUGININFOEX); + return &pluginInfo; +} + + +static const MUUID interfaces[] = { MIID_REMOVEPERSONALSETTINGS, MIID_LAST }; +__declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + + +int __declspec(dllexport) Load() +{ + CLISTMENUITEM mi; + char *strTmp; + + CreateServiceFunction("RemovePersonalSettings/RemoveAll",RemoveAllService); + ZeroMemory(&mi,sizeof(mi)); + mi.cbSize=sizeof(mi); + mi.position=-0x7FFFFFFF; + mi.flags=0; + mi.hIcon=LoadSkinnedIcon(SKINICON_OTHER_MIRANDA); + mi.pszName="Remove Personal Settings..."; + mi.pszService="RemovePersonalSettings/RemoveAll"; + Menu_AddMainMenuItem(&mi); + + // Get ini file name + gMirandaDir[0] = '\0'; + GetModuleFileName(GetModuleHandle(NULL),gMirandaDir,sizeof(gMirandaDir)); + + // Remove last name + strTmp = strrchr(gMirandaDir,'\\'); + if(strTmp != NULL) + *strTmp = '\0'; + + // Set vars + strcat(gMirandaDir, "\\"); + strcpy(gIniFile, gMirandaDir); + + // Store last pos + strTmp = &gIniFile[strlen(gIniFile)]; + + // Lets try fist name + strcpy(strTmp, INI_FILE_NAME); + + if (_access(gIniFile, 4) != 0) + { + // Not found, lets try the other aproach + strcpy(strTmp, "plugins\\" INI_FILE_NAME); + + if (_access(gIniFile, 4) != 0) + { + // Not found :( + gIniFile[0] = '\0'; + } + } + + return 0; +} + + +int __declspec(dllexport) Unload(void) +{ + return 0; +} + + +INT_PTR RemoveAllService(WPARAM wParam,LPARAM lParam) +{ + if (gIniFile[0] == '\0') + { + MessageBox(NULL, Translate("Configuration file could not be found!"), Translate("Remove Personal Settings"), MB_OK | MB_ICONERROR); + return -1; + } + + if (MessageBox(NULL,Translate("All your personal settings will be erased!\n" + "Make sure you are running this from a copy of your profile (and not over the original one).\n" + "Running this will erase files/folders under Miranda main folder.\n" + "\n" + "Are you sure you want to remove all your personal settings?\n" + "\n" + "(You cannot say that I don't told you about the risks :P )"), Translate("Remove Personal Settings"),MB_YESNO) + == IDYES) + { + SetProtocolsOffline(); + RemoveUsers(); + RemoveSettings(); + ExecuteServices(); + RemoveDirectories(); + DisablePlugins(); + + MessageBox(NULL,Translate("Settings are deleted now."), Translate("Remove Personal Settings"),MB_OK | MB_ICONINFORMATION); + } + + return 0; +} + +void SetProtocolsOffline() +{ + if ( GetSettingBool("GlobalSettings", "SetProtocolsOffline", TRUE) ) + { + PROTOACCOUNT **accounts; + int i,count; + + CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&count, (LPARAM)&accounts); + + for (i = 0; i < count; i++) + { + /*if (protos[i]->type != PROTOTYPE_PROTOCOL) + continue;*/ + if (!accounts[i]->bIsEnabled) + continue; + + if (accounts[i]->szModuleName == NULL || accounts[i]->szModuleName[0] == '\0') + continue; + + CallProtoService(accounts[i]->szModuleName, PS_SETSTATUS, ID_STATUS_OFFLINE, 0); + } + + // Give some time to make it really offline + Sleep(2000); + } +} + +void RemoveUsers() +{ + if ( GetSettingBool("GlobalSettings", "RemoveAllUsers", TRUE) ) + { + HANDLE hContact; + HANDLE hDbEvent; + HANDLE hContactOld; + + // To be faster, remove first all metacontacts (because it syncs histories) + hContact = db_find_first(); + while(hContact != NULL) + { + hContactOld = hContact; + hContact = db_find_next(hContact); + + if ( isMetaContact(hContactOld) ) + CallService(MS_DB_CONTACT_DELETE, (WPARAM) hContactOld, 0); + } + + // Now delete all left-overs + hContact = db_find_first(); + while(hContact != NULL) + { + CallService(MS_DB_CONTACT_DELETE, (WPARAM) hContact, 0); + + hContact = db_find_first(); + } + + // Delete events for contacts not in list + hDbEvent = db_event_first(0); + + while(hDbEvent != NULL) + { + int ret = db_event_delete(0, hDbEvent); + + hDbEvent = db_event_first(0); + } + + // Now delete groups + DeleteSettingEx("CListGroups", NULL); + } +} + +void RemoveProtocolSettings(const char * protocolName) +{ + char buffer[10000]; + + // Remove protocol module settings + if ( GetSettingBool("GlobalSettings", "RemoveWholeProtocolModule", FALSE) ) + { + DeleteSettingEx(protocolName, NULL); + } + else if ( GetSettings("ProtocolSettings", buffer, sizeof(buffer)) ) + { + char *name; + char *value; + + name = buffer; + while(name[0] != '\0') + { + value = strchr(name, '='); + if (value == NULL) + value = &name[strlen(name)]; + + // Has " ? + if (*name == '"' && *(value-1) == '"') + { + name++; + *(value-1) = '\0'; + } + + // Disable it + if (name[0] != '\0') + DeleteSettingEx(protocolName, name); + + // Get next one + name = value + strlen(value) + 1; + } + } + + // Remove modules by protocol sufixes + if ( GetSettings("ProtocolModuleSufixes", buffer, sizeof(buffer)) ) + { + char *name; + char *value; + char moduleName[256]; + + name = buffer; + while(name[0] != '\0') + { + value = strchr(name, '='); + if (value == NULL) + value = &name[strlen(name)]; + + // Has " ? + if (*name == '"' && *(value-1) == '"') + { + name++; + *(value-1) = '\0'; + } + + // Delete it + if (name[0] != '\0') + { + mir_snprintf(moduleName, sizeof(moduleName), "%s%s", protocolName, name); + DeleteSettingEx(moduleName, NULL); + } + + // Get next one + name = value + strlen(value) + 1; + } + } +} + +void RemoveSettings() +{ + char buffer[10000]; + + // Delete protocol settings + if ( GetSettingBool("GlobalSettings", "RemoveProtocolSettings", TRUE) ) + { + PROTOACCOUNT **accounts; + int i,count; + + // TODO MS_PROTO_ENUMACCOUNTS + CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&count, (LPARAM)&accounts); + + for (i = 0; i < count; i++) + { + /*if (protos[i]->type != PROTOTYPE_PROTOCOL) + continue;*/ + if (!accounts[i]->bIsEnabled) + continue; + + if (accounts[i]->szModuleName == NULL || accounts[i]->szModuleName[0] == '\0') + continue; + + RemoveProtocolSettings(accounts[i]->szModuleName); + } + + // Get disabled protocols + if ( GetSettings("DisabledProtocols", buffer, sizeof(buffer)) ) + { + char *name; + char *value; + + name = buffer; + while(name[0] != '\0') + { + value = strchr(name, '='); + if (value == NULL) + value = &name[strlen(name)]; + + // Has " ? + if (*name == '"' && *(value-1) == '"') + { + name++; + *(value-1) = '\0'; + } + + // Disable it + if (name[0] != '\0') + RemoveProtocolSettings(name); + + // Get next one + name = value + strlen(value) + 1; + } + } + } + + + // Delete other settings + if ( GetSettings("RemoveSettings", buffer, sizeof(buffer)) ) + { + char *name; + char *value; + + name = buffer; + while(name[0] != '\0') + { + value = strchr(name, '='); + if (value == NULL) + value = &name[strlen(name)]; + + // Has " ? + if (*name == '"' && *(value-1) == '"') + { + name++; + *(value-1) = '\0'; + } + + // Delete it + if (name[0] != '\0') + DeleteSetting(name); + + // Get next one + name = value + strlen(value) + 1; + } + } +} + +void ExecuteServices() +{ + char buffer[10000]; + + if ( GetSettings("ExecuteServices", buffer, sizeof(buffer)) ) + { + char *name; + char *value; + + name = buffer; + while(name[0] != '\0') + { + value = strchr(name, '='); + if (value == NULL) + value = &name[strlen(name)]; + + // Has " ? + if (*name == '"' && *(value-1) == '"') + { + name++; + *(value-1) = '\0'; + } + + // Disable it + if (name[0] != '\0') + if (ServiceExists(name)) + CallService(name,0,0); + + // Get next one + name = value + strlen(value) + 1; + } + } +} + +void RemoveDirectories() +{ + char buffer[10000]; + char dir[MAX_PATH]; + + // Remove protocol folders + if (GetSettingBool("GlobalSettings", "RemoveProtocolFolders", TRUE)) + { + PROTOACCOUNT **accounts; + int i,count; + + CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&count, (LPARAM)&accounts); + + for (i = 0; i < count; i++) + { + /*if (protos[i]->type != PROTOTYPE_PROTOCOL) + continue;*/ + if (!accounts[i]->bIsEnabled) + continue; + + if (accounts[i]->szModuleName == NULL || accounts[i]->szModuleName[0] == '\0') + continue; + + mir_snprintf(dir, sizeof(dir), "%s%s", gMirandaDir, accounts[i]->szModuleName); + DeleteFileOrFolder(dir); + } + } + + // Remove other folders + if ( GetSettings("RemoveFilesOrFolders", buffer, sizeof(buffer)) ) + { + char *name; + char *value; + + name = buffer; + while(name[0] != '\0') + { + value = strchr(name, '='); + if (value == NULL) + value = &name[strlen(name)]; + + // Has " ? + if (*name == '"' && *(value-1) == '"') + { + name++; + *(value-1) = '\0'; + } + + // Delete it + if (name[0] != '\0') + { + mir_snprintf(dir, sizeof(dir), "%s%s", gMirandaDir, name); + DeleteFileOrFolder(dir); + } + + // Get next one + name = value + strlen(value) + 1; + } + } +} + +void DisablePlugins() +{ + char buffer[10000]; + + if ( GetSettings("DisablePlugins", buffer, sizeof(buffer)) ) + { + char *name; + char *value; + + name = buffer; + while(name[0] != '\0') + { + value = strchr(name, '='); + if (value == NULL) + value = &name[strlen(name)]; + + // Has " ? + if (*name == '"' && *(value-1) == '"') + { + name++; + *(value-1) = '\0'; + } + + // Disable it + if (name[0] != '\0') + { + CharLower(name); + if (db_get_b(NULL, PLUGINDISABLELIST, name, 0) != 1) + { + db_set_b(NULL, PLUGINDISABLELIST, name, 1); + } + } + + // Get next one + name = value + strlen(value) + 1; + } + } +} + + + +// Ini access functions + +BOOL GetSettingBool(const char *section, const char *key, BOOL defaultValue) +{ + char tmp[16]; + + if ( GetPrivateProfileString(section, key, defaultValue ? "true" : "false", tmp, sizeof(tmp), gIniFile) == 0 ) + { + return defaultValue; + } + else + { + return stricmp(tmp, "true") == 0; + } +} + + +BOOL GetSettings(const char *section, char *buffer, size_t bufferSize) +{ + buffer[0] = '\0\0'; + + return GetPrivateProfileSection(section, buffer, bufferSize, gIniFile) != 0; +} + + + +// Utils + +void DeleteFileOrFolder(const char *name) +{ + int attibs = GetFileAttributes(name); + + if (attibs == 0xFFFFFFFF) // Not exists + { + // Try to find it + WIN32_FIND_DATA findData; + HANDLE hwnd; + char tmp[MAX_PATH]; + char *strTmp; + + // Delete files + hwnd = FindFirstFile(name, &findData); + if (hwnd != INVALID_HANDLE_VALUE) + { + strcpy(tmp, name); + strTmp = strrchr(tmp,'\\'); + if(strTmp != NULL) + { + strTmp++; + *strTmp = '\0'; + } + else + { + strcat(tmp, "\\"); + strTmp = &tmp[strlen(tmp)]; + } + + do + { + if (strcmp(findData.cFileName, ".") && strcmp(findData.cFileName, "..")) + { + strcpy(strTmp, findData.cFileName); + DeleteFileOrFolder(tmp); + } + } + while(FindNextFile(hwnd, &findData) != 0); + + FindClose(hwnd); + } + } + else if (attibs & FILE_ATTRIBUTE_DIRECTORY) // Is a directory + { + // Get all files and delete then + WIN32_FIND_DATA findData; + HANDLE hwnd; + char tmp[MAX_PATH]; + + mir_snprintf(tmp, sizeof(tmp), "%s\\*.*", name); + + // Delete files + hwnd = FindFirstFile(tmp, &findData); + if (hwnd != INVALID_HANDLE_VALUE) + { + do + { + if (strcmp(findData.cFileName, ".") && strcmp(findData.cFileName, "..")) + { + mir_snprintf(tmp, sizeof(tmp), "%s\\%s", name, findData.cFileName); + DeleteFileOrFolder(tmp); + } + } + while(FindNextFile(hwnd, &findData) != 0); + + FindClose(hwnd); + } + + // Delete directory + RemoveDirectory(name); + } + else // Is a File + { + SetFileAttributes(name, FILE_ATTRIBUTE_ARCHIVE); + DeleteFile(name); + } +} + + +BOOL isMetaContact(HANDLE hContact) +{ + DBVARIANT dbv; + DBCONTACTGETSETTING dbcgs; + char name[32]; + + dbv.type=DBVT_ASCIIZ; + dbv.pszVal=name; + dbv.cchVal=sizeof(name); + dbcgs.pValue=&dbv; + dbcgs.szModule="Protocol"; + dbcgs.szSetting="p"; + + if(CallService(MS_DB_CONTACT_GETSETTINGSTATIC,(WPARAM)hContact,(LPARAM)&dbcgs)) + return FALSE; + + return strcmp(dbcgs.pValue->pszVal, METACONTACTS_PROTOCOL_NAME) == 0; +} + + + +typedef struct { + char buffer[10000]; + int pos; + const char *filter; + size_t lenFilterMinusOne; +} DeleteModuleStruct; + + +int EnumProc(const char *szName, LPARAM lParam) +{ + DeleteModuleStruct *dms = (DeleteModuleStruct *) lParam; + size_t len = strlen(szName); + + if (dms->filter != NULL && dms->lenFilterMinusOne > 0) + { + if (len >= dms->lenFilterMinusOne) + { + if (dms->filter[0] == '*') + { + if (strcmp(&dms->filter[1], &szName[len - dms->lenFilterMinusOne]) != 0) + return 0; + } + else // if (dms->filter[dms->lenFilterMinusOne] == '*') + { + if (strncmp(dms->filter, szName, dms->lenFilterMinusOne) != 0) + return 0; + } + } + } + + // Add to the struct + if (len > 0 && len < sizeof(dms->buffer) - dms->pos - 2) + { + strcpy(&dms->buffer[dms->pos], szName); + dms->pos += len + 1; + } + + return 0; +} + +int ModuleEnumProc(const char *szName, DWORD ofsModuleName, LPARAM lParam) +{ + return EnumProc(szName, lParam); +} + +void DeleteSettingEx(const char *szModule, const char *szSetting) +{ + size_t lenModule; + + if (szModule == NULL) + return; + + lenModule = strlen(szModule); + if (szModule[0] == '*' || szModule[lenModule-1] == '*') + { + DeleteModuleStruct dms; + ZeroMemory(&dms, sizeof(dms)); + + dms.filter = szModule; + dms.lenFilterMinusOne = lenModule-1; + + CallService(MS_DB_MODULES_ENUM, (WPARAM) &dms, (LPARAM) &ModuleEnumProc); + + // Delete then + szModule = dms.buffer; + while(szModule[0] != '\0') + { + DeleteSettingEx(szModule, szSetting); + + // Get next one + szModule += strlen(szModule) + 1; + } + } + else + { + size_t lenSetting = szSetting == NULL ? 0 : strlen(szSetting); + if (szSetting == NULL || szSetting[0] == '*' || szSetting[lenSetting-1] == '*') + { + DeleteModuleStruct dms; + DBCONTACTENUMSETTINGS dbces; + + ZeroMemory(&dms, sizeof(dms)); + + dms.filter = szSetting; + dms.lenFilterMinusOne = lenSetting-1; + + dbces.pfnEnumProc = EnumProc; + dbces.lParam = (LPARAM) &dms; + dbces.szModule = szModule; + dbces.ofsSettings = 0; + + CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM) &dbces); + + // Delete then + szSetting = dms.buffer; + while(szSetting[0] != '\0') + { + db_unset(NULL, szModule, szSetting); + + // Get next one + szSetting += strlen(szSetting) + 1; + } + } + else + { + db_unset(NULL, szModule, szSetting); + } + } +} + +void DeleteSetting(const char *setting) +{ + char *szModule; + char *szSetting; + + if (setting == NULL || setting[0] == '\0') + { + return; + } + + // Split setting + szModule = strdup(setting); + szSetting = strrchr(szModule, '/'); + if (szSetting != NULL) + { + *szSetting = '\0'; + szSetting ++; + } + + DeleteSettingEx(szModule, szSetting); + + free(szModule); +} + diff --git a/plugins/rps/rps.vcxproj b/plugins/rps/rps.vcxproj new file mode 100644 index 0000000000..ee32b1e4a0 --- /dev/null +++ b/plugins/rps/rps.vcxproj @@ -0,0 +1,271 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + DynamicLibrary + false + MultiByte + + + DynamicLibrary + false + MultiByte + + + DynamicLibrary + false + MultiByte + + + DynamicLibrary + false + MultiByte + + + + + + + + + + + + + + + + + + + + + + + .\Debug\ + .\Debug\ + true + + + .\Debug\ + .\Debug\ + true + + + .\Release\ + .\Release\ + false + + + .\Release\ + .\Release\ + false + + + + MultiThreadedDebug + Default + false + Disabled + true + Level3 + true + EditAndContinue + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;RPS_EXPORTS;%(PreprocessorDefinitions) + .\Debug\ + true + .\Debug\rps.pch + .\Debug\ + .\Debug\ + EnableFastChecks + + + true + _DEBUG;%(PreprocessorDefinitions) + .\Debug\rps.tlb + true + Win32 + + + 0x0809 + _DEBUG;%(PreprocessorDefinitions) + + + true + .\Debug\rps.bsc + + + true + true + true + Console + ../../bin/debug/plugins/RemovePersonalSettings.dll + .\Debug\RemovePersonalSettings.lib + odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + ../../bin10/lib + + + + + MultiThreadedDebug + Default + false + Disabled + true + Level3 + ProgramDatabase + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;RPS_EXPORTS;%(PreprocessorDefinitions) + .\Debug\ + true + .\Debug\rps.pch + .\Debug\ + .\Debug\ + EnableFastChecks + + + true + _DEBUG;%(PreprocessorDefinitions) + .\Debug\rps.tlb + true + + + 0x0809 + _DEBUG;%(PreprocessorDefinitions) + + + true + .\Debug\rps.bsc + + + true + true + true + Console + ../../bin/debug/plugins/RemovePersonalSettings.dll + .\Debug\RemovePersonalSettings.lib + odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + ../../bin10/lib + + + + + MultiThreaded + OnlyExplicitInline + true + true + MaxSpeed + true + Level3 + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;RPS_EXPORTS;%(PreprocessorDefinitions) + .\Release\ + .\Release\rps.pch + .\Release\ + .\Release\ + + + true + NDEBUG;%(PreprocessorDefinitions) + .\Release\rps.tlb + true + Win32 + + + 0x0809 + NDEBUG;%(PreprocessorDefinitions) + + + true + .\Release\rps.bsc + + + true + true + Console + ../../bin/release/plugins/RemovePersonalSettings.dll + .\Release\RemovePersonalSettings.lib + odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + ../../bin10/lib + + + + + MultiThreaded + OnlyExplicitInline + true + true + MaxSpeed + true + Level3 + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;RPS_EXPORTS;%(PreprocessorDefinitions) + .\Release\ + .\Release\rps.pch + .\Release\ + .\Release\ + + + true + NDEBUG;%(PreprocessorDefinitions) + .\Release\rps.tlb + true + + + 0x0809 + NDEBUG;%(PreprocessorDefinitions) + + + true + .\Release\rps.bsc + + + true + true + Console + ../../bin/release/plugins/RemovePersonalSettings.dll + .\Release\RemovePersonalSettings.lib + odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + ../../bin10/lib + + + + + + + + Document + + + + + + + + + \ No newline at end of file diff --git a/plugins/rps/rps.vcxproj.filters b/plugins/rps/rps.vcxproj.filters new file mode 100644 index 0000000000..271b828923 --- /dev/null +++ b/plugins/rps/rps.vcxproj.filters @@ -0,0 +1,39 @@ + + + + + {debf756a-9ff8-4610-b321-7d997392b427} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {a6f79057-283d-4403-9d4d-871cee8a7b5f} + + + {74725d2b-50dc-460f-8a63-a35e47956ce3} + h;hpp;hxx;hm;inl + + + {0bc87fb5-4fcc-420a-a2b4-512b340e65d3} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Docs + + + Docs + + + Docs + + + Docs + + + + + Source Files + + + \ No newline at end of file -- cgit v1.2.3