INT_PTR CMimAPI::foldersPathChanged() { TCHAR szTemp[MAX_PATH + 2] = {'\0'}; if (m_hDataPath) { FoldersGetCustomPathT(m_hDataPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getDataPath())); mir_sntprintf(m_szProfilePath, MAX_PATH, _T("%s"), szTemp); FoldersGetCustomPathT(m_hSkinsPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getSkinPath())); mir_sntprintf(m_szSkinsPath, MAX_PATH - 1, _T("%s"), szTemp); Utils::ensureTralingBackslash(m_szSkinsPath); FoldersGetCustomPathT(m_hAvatarsPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getSavedAvatarPath())); mir_sntprintf(m_szSavedAvatarsPath, MAX_PATH, _T("%s"), szTemp); FoldersGetCustomPathT(m_hChatLogsPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getChatLogPath())); mir_sntprintf(m_szChatLogsPath, MAX_PATH, _T("%s"), szTemp); Utils::ensureTralingBackslash(m_szChatLogsPath); } CreateDirectoryTreeT(m_szProfilePath); CreateDirectoryTreeT(m_szSkinsPath); CreateDirectoryTreeT(m_szSavedAvatarsPath); Skin->extractSkinsAndLogo(true); Skin->setupAeroSkins(); return 0; }
TCHAR* GetHistoryFolder(TCHAR *fn) { if (fn == NULL) return NULL; FoldersGetCustomPathT(hFolder, fn, MAX_PATH, basedir); CreateDirectoryTreeT(fn); return fn; }
int ModulesLoaded(WPARAM wParam, LPARAM lParam) { InitFonts(); InitUpdaterSupport(); hAvChangeEvent = HookEvent(ME_AV_AVATARCHANGED, AvatarChanged); hShowTipEvent = HookEvent(ME_CLC_SHOWINFOTIP, ShowTipHook); hHideTipEvent = HookEvent(ME_CLC_HIDEINFOTIP, HideTipHook); hAckEvent = HookEvent(ME_PROTO_ACK, ProtoAck); hFramesSBShow = HookEvent(ME_CLIST_FRAMES_SB_SHOW_TOOLTIP, FramesShowSBTip); hFramesSBHide = HookEvent(ME_CLIST_FRAMES_SB_HIDE_TOOLTIP, FramesHideSBTip); hFolderChanged = HookEvent(ME_FOLDERS_PATH_CHANGED, ReloadSkinFolder); hSkinFolder = FoldersRegisterCustomPathT(MODULE, "Tipper skins", MIRANDA_PATHT _T("\\") _T(DEFAULT_SKIN_FOLDER)); FoldersGetCustomPathT(hSkinFolder, SKIN_FOLDER, SIZEOF(SKIN_FOLDER), _T(DEFAULT_SKIN_FOLDER)); InitTipperSmileys(); LoadOptions(); ReloadFont(0, 0); ParseSkinFile(opt.szSkinName, true, false); // set 'time-in' CallService(MS_CLC_SETINFOTIPHOVERTIME, opt.iTimeIn, 0); // set Miranda start timestamp DBWriteContactSettingDword(0, MODULE, "MirandaStartTS", (DWORD)time(0)); // get MetaContacts module name if (ServiceExists(MS_MC_GETPROTOCOLNAME)) strcpy(szMetaModuleName, (char *)CallService(MS_MC_GETPROTOCOLNAME, 0, 0)); return 0; }
int NewsAggrInit(WPARAM wParam, LPARAM lParam) { hNewsAggregatorFolder = FoldersRegisterCustomPathT(LPGEN("Avatars"), LPGEN("News Aggregator"), MIRANDA_USERDATAT _T("\\Avatars\\")_T(DEFAULT_AVATARS_FOLDER)); if (hNewsAggregatorFolder) FoldersGetCustomPathT(hNewsAggregatorFolder, tszRoot, MAX_PATH, _T("")); else lstrcpyn(tszRoot, VARST( _T("%miranda_userdata%\\Avatars\\"_T(DEFAULT_AVATARS_FOLDER))), SIZEOF(tszRoot)); for (MCONTACT hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) { if (!db_get_b(NULL, MODULE, "StartupRetrieve", 1)) db_set_dw(hContact, MODULE, "LastCheck", time(NULL)); SetContactStatus(hContact, ID_STATUS_ONLINE); } NetlibInit(); InitIcons(); InitMenu(); HookEvent(ME_TTB_MODULELOADED, OnToolbarLoaded); HookEvent(ME_FOLDERS_PATH_CHANGED, OnFoldersChanged); // timer for the first update timerId = SetTimer(NULL, 0, 10000, timerProc2); // first update is 10 sec after load return 0; }
int SystemModulesLoaded(WPARAM, LPARAM) { //Insert "Check mail (YAMN)" item to Miranda's menu CMenuItem mi; SET_UID(mi, 0xa01ff3d9, 0x53cb, 0x4406, 0x85, 0xd9, 0xf1, 0x90, 0x3a, 0x94, 0xed, 0xf4); mi.position = 0xb0000000; mi.hIcolibItem = g_GetIconHandle(0); mi.name.a = LPGEN("Check &mail (All Account)"); mi.pszService = MS_YAMN_FORCECHECK; hMenuItemMain = Menu_AddMainMenuItem(&mi); SET_UID(mi, 0xfe22191f, 0x40c8, 0x479f, 0x93, 0x5d, 0xa5, 0x17, 0x1f, 0x57, 0x2f, 0xcb); mi.name.a = LPGEN("Check &mail (This Account)"); mi.pszService = MS_YAMN_CLISTCONTEXT; hMenuItemCont = Menu_AddContactMenuItem(&mi, YAMN_DBMODULE); SET_UID(mi, 0x147c7800, 0x12d0, 0x4209, 0xab, 0xcc, 0xfa, 0x64, 0xc6, 0xb0, 0xa6, 0xeb); mi.hIcolibItem = g_GetIconHandle(1); mi.name.a = LPGEN("Launch application"); mi.pszService = MS_YAMN_CLISTCONTEXTAPP; hMenuItemContApp = Menu_AddContactMenuItem(&mi, YAMN_DBMODULE); CheckMenuItems(); if (hAccountFolder = FoldersRegisterCustomPathT(LPGEN("YAMN"), LPGEN("YAMN Account Folder"), UserDirectory)) FoldersGetCustomPathT(hAccountFolder, UserDirectory, MAX_PATH, UserDirectory); RegisterPOP3Plugin(0, 0); return 0; }
int SystemModulesLoaded(WPARAM, LPARAM) { //Insert "Check mail (YAMN)" item to Miranda's menu CLISTMENUITEM mi = { sizeof(mi) }; mi.position = 0xb0000000; mi.icolibItem = g_GetIconHandle(0); mi.pszName = LPGEN("Check &mail (All Account)"); mi.pszPopupName = NULL;//YAMN_DBMODULE; mi.pszService = MS_YAMN_FORCECHECK; hMenuItemMain = Menu_AddMainMenuItem(&mi); mi.pszName = LPGEN("Check &mail (This Account)"); mi.pszContactOwner = YAMN_DBMODULE; mi.pszService = MS_YAMN_CLISTCONTEXT; hMenuItemCont = Menu_AddContactMenuItem(&mi); mi.icolibItem = g_GetIconHandle(1); mi.pszName = LPGEN("Launch application"); mi.pszContactOwner = YAMN_DBMODULE; mi.pszService = MS_YAMN_CLISTCONTEXTAPP; hMenuItemContApp = Menu_AddContactMenuItem(&mi); CheckMenuItems(); if (hAccountFolder = FoldersRegisterCustomPathT(LPGEN("YAMN"), LPGEN("YAMN Account Folder"), UserDirectory)) FoldersGetCustomPathT(hAccountFolder, UserDirectory, MAX_PATH, UserDirectory); RegisterPOP3Plugin(0, 0); return 0; }
void CMLuaOptions::OnInitDialog() { CDlgBase::OnInitDialog(); m_scripts.SetExtendedListViewStyle(LVS_EX_SUBITEMIMAGES | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES | LVS_EX_INFOTIP); HIMAGELIST hImageList = m_scripts.CreateImageList(LVSIL_SMALL); ImageList_AddIcon(hImageList, GetIcon(IDI_LOADED)); ImageList_AddIcon(hImageList, GetIcon(IDI_FAILED)); ImageList_AddIcon(hImageList, GetIcon(IDI_OPEN)); ImageList_AddIcon(hImageList, GetIcon(IDI_RELOAD)); TCHAR scriptDir[MAX_PATH], relativeScriptDir[MAX_PATH], header[MAX_PATH + 100]; FoldersGetCustomPathT(g_hScriptsFolder, scriptDir, _countof(scriptDir), VARST(MIRLUA_PATHT)); PathToRelativeT(scriptDir, relativeScriptDir, NULL); mir_sntprintf(header, _T("%s (%s)"), TranslateT("Common scripts"), relativeScriptDir); m_scripts.AddColumn(0, _T("Script"), 380); m_scripts.AddColumn(1, NULL, 32 - GetSystemMetrics(SM_CXVSCROLL)); m_scripts.AddColumn(2, NULL, 32 - GetSystemMetrics(SM_CXVSCROLL)); LoadScripts(); isScriptListInit = true; }
int CAimProto::get_avatar_filename(HANDLE hContact, TCHAR* pszDest, size_t cbLen, const TCHAR *ext) { size_t tPathLen; bool found = false; init_custom_folders(); TCHAR* path = (TCHAR*)_malloca(cbLen * sizeof(TCHAR)); if (hAvatarsFolder == NULL || FoldersGetCustomPathT(hAvatarsFolder, path, (int)cbLen, _T(""))) { TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_avatarcache%")); TCHAR *tszModuleName = mir_a2t(m_szModuleName); tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%s"), tmpPath, tszModuleName); mir_free(tszModuleName); mir_free(tmpPath); } else { _tcscpy(pszDest, path); tPathLen = _tcslen(pszDest); } if (ext && _taccess(pszDest, 0)) CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)pszDest); size_t tPathLen2 = tPathLen; DBVARIANT dbv; if (getTString(hContact, AIM_KEY_AH, &dbv)) return GAIR_NOAVATAR; tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s"), dbv.ptszVal); DBFreeVariant(&dbv); if (ext == NULL) { mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T(".*")); _tfinddata_t c_file; long hFile = _tfindfirst(pszDest, &c_file); if (hFile > -1L) { do { if (_tcsrchr(c_file.name, '.')) { mir_sntprintf(pszDest + tPathLen2, cbLen - tPathLen2, _T("\\%s"), c_file.name); found = true; } } while (_tfindnext(hFile, &c_file) == 0); _findclose( hFile ); } if (!found) pszDest[0] = 0; } else { mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, ext); found = _taccess(pszDest, 0) == 0; } return found ? GAIR_SUCCESS : GAIR_WAITFOR; }
int ModulesLoaded(WPARAM, LPARAM) { InitFonts(); hAvChangeEvent = HookEvent(ME_AV_AVATARCHANGED, AvatarChanged); hShowTipEvent = HookEvent(ME_CLC_SHOWINFOTIP, ShowTipHook); hHideTipEvent = HookEvent(ME_CLC_HIDEINFOTIP, HideTipHook); hAckEvent = HookEvent(ME_PROTO_ACK, ProtoAck); hFramesSBShow = HookEvent(ME_CLIST_FRAMES_SB_SHOW_TOOLTIP, FramesShowSBTip); hFramesSBHide = HookEvent(ME_CLIST_FRAMES_SB_HIDE_TOOLTIP, FramesHideSBTip); hFolderChanged = HookEvent(ME_FOLDERS_PATH_CHANGED, ReloadSkinFolder); hSkinFolder = FoldersRegisterCustomPathT(LPGEN("Skins"), LPGEN("Tipper"), MIRANDA_PATHT _T("\\") _T(DEFAULT_SKIN_FOLDER)); FoldersGetCustomPathT(hSkinFolder, SKIN_FOLDER, _countof(SKIN_FOLDER), _T(DEFAULT_SKIN_FOLDER)); InitTipperSmileys(); LoadOptions(); ReloadFont(0, 0); ParseSkinFile(opt.szSkinName, true, false); // set 'time-in' CallService(MS_CLC_SETINFOTIPHOVERTIME, opt.iTimeIn, 0); // set Miranda start timestamp db_set_dw(0, MODULE, "MirandaStartTS", (DWORD)time(0)); return 0; }
int OnFoldersChanged(WPARAM, LPARAM) { FoldersGetCustomPathT(hPluginUpdaterFolder, tszRoot, MAX_PATH, _T("")); size_t len = _tcslen(tszRoot); if (tszRoot[len-1] == '\\' || tszRoot[len-1] == '/') tszRoot[len-1] = 0; return 0; }
TCHAR* CToxProto::GetToxProfilePath(const TCHAR *accountName) { TCHAR *profilePath = (TCHAR*)mir_calloc(MAX_PATH * sizeof(TCHAR) + 1); TCHAR profileRootPath[MAX_PATH]; FoldersGetCustomPathT(hProfileFolderPath, profileRootPath, _countof(profileRootPath), VARST(_T("%miranda_userdata%"))); mir_sntprintf(profilePath, MAX_PATH, _T("%s\\%s.tox"), profileRootPath, accountName); return profilePath; }
void CLuaScriptLoader::Load(lua_State *L) { TCHAR scriptDir[MAX_PATH]; CLuaScriptLoader loader(L); FoldersGetCustomPathT(g_hCommonScriptFolder, scriptDir, _countof(scriptDir), VARST(COMMON_SCRIPTS_PATHT)); loader.LoadScripts(scriptDir, 0); }
static int OnFoldersChanged(WPARAM, LPARAM) { mir_sntprintf(tszAvatarRoot, _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName); TCHAR tmpVar[MAX_PATH]; if (!FoldersGetCustomPathT(hAvatarFolder, tmpVar, _countof(tmpVar), tszAvatarRoot)) _tcsncpy_s(tszAvatarRoot, tmpVar, _TRUNCATE); return 0; }
void GetSmileyCacheFolder(void) { hFolder = FoldersRegisterCustomPathT(LPGEN("SmileyAdd"), LPGEN("Smiley cache"), MIRANDA_USERDATAT _T("\\SmileyCache")); if (hFolder) { FoldersGetCustomPathT(hFolder, cachepath, MAX_PATH, _T("")); HookEvent(ME_FOLDERS_PATH_CHANGED, FolderChanged); } else mir_tstrncpy(cachepath, VARST( _T("%miranda_userdata%\\SmileyCache")), MAX_PATH); }
TCHAR * GetHistoryFolder(TCHAR *fn) { if (fn == NULL) return NULL; FoldersGetCustomPathT(hFolder, fn, MAX_PATH, basedir); if(!CreateDirectory(fn, NULL)) ErrorExit(NULL,_T("GetHistoryFolder")); return fn; }
INT_PTR CMimAPI::foldersPathChanged() { TCHAR szTemp[MAX_PATH + 2] = {'\0'}; if(m_hDataPath) { FoldersGetCustomPathT(m_hDataPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getDataPath())); mir_sntprintf(m_szProfilePath, MAX_PATH, _T("%s"), szTemp); FoldersGetCustomPathT(m_hSkinsPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getSkinPath())); mir_sntprintf(m_szSkinsPath, MAX_PATH - 1, _T("%s"), szTemp); /* * make sure skins root path always ends with a '\' - this is assumed by the skin * selection code. */ Utils::ensureTralingBackslash(m_szSkinsPath); FoldersGetCustomPathT(m_hAvatarsPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getSavedAvatarPath())); mir_sntprintf(m_szSavedAvatarsPath, MAX_PATH, _T("%s"), szTemp); FoldersGetCustomPathT(m_hChatLogsPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getChatLogPath())); mir_sntprintf(m_szChatLogsPath, MAX_PATH, _T("%s"), szTemp); Utils::ensureTralingBackslash(m_szChatLogsPath); } CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)m_szProfilePath); CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)m_szSkinsPath); CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)m_szSavedAvatarsPath); CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)m_szChatLogsPath); #if defined(_FOLDER_LOCKING) mir_sntprintf(szTemp, MAX_PATH, L"%sfolder.lck", m_szChatLogsPath); if(m_hChatLogLock != INVALID_HANDLE_VALUE) CloseHandle(m_hChatLogLock); m_hChatLogLock = CreateFile(szTemp, GENERIC_WRITE, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_HIDDEN, 0); #endif Skin->extractSkinsAndLogo(true); Skin->setupAeroSkins(); return 0; }
void InitPathVar() { mir_sntprintf(tszAvatarRoot, _T("%s\\%s\\AvatarCache"), g_profileDir, g_shortProfileName); if (hAvatarFolder = FoldersRegisterCustomPathT( LPGEN("Avatars"), LPGEN("Avatars root folder"), tszAvatarRoot)) { TCHAR tmpVar[MAX_PATH]; if (!FoldersGetCustomPathT(hAvatarFolder, tmpVar, _countof(tmpVar), tszAvatarRoot)) _tcsncpy_s(tszAvatarRoot, tmpVar, _TRUNCATE); HookEvent(ME_FOLDERS_PATH_CHANGED, OnFoldersChanged); } }
int FoldersChanged(WPARAM wParam, LPARAM lParam) { TCHAR path[MAX_PATH]; if ( FoldersGetCustomPathT(hPATH_MIROTR, path, _countof(path), _T(""))) SetFilenames( VARST(DATA_DIRECTORY)); else SetFilenames(path); ReadPrivkeyFiles(); return 0; }
void CMsnProto::MSN_GetCustomSmileyFileName(MCONTACT hContact, TCHAR* pszDest, size_t cbLen, const char* SmileyName, int type) { size_t tPathLen; InitCustomFolders(); TCHAR* path = (TCHAR*)alloca(cbLen * sizeof(TCHAR)); if (hCustomSmileyFolder == NULL || FoldersGetCustomPathT(hCustomSmileyFolder, path, (int)cbLen, _T(""))) { TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_userdata%")); TCHAR *tszModuleName = mir_a2t(m_szModuleName); tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%s\\CustomSmiley"), tmpPath, tszModuleName); mir_free(tszModuleName); mir_free(tmpPath); } else { _tcscpy(pszDest, path); tPathLen = _tcslen(pszDest); } if (hContact != NULL) { DBVARIANT dbv = {0}; if (getTString(hContact, "e-mail", &dbv)) { dbv.type = DBVT_ASCIIZ; dbv.ptszVal = (TCHAR*)mir_alloc(11); _ui64tot((UINT_PTR)hContact, dbv.ptszVal, 10); } tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s"), dbv.ptszVal); db_free(&dbv); } else { TCHAR *tszModuleName = mir_a2t(m_szModuleName); tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s"), tszModuleName); mir_free(tszModuleName); } bool exist = _taccess(pszDest, 0) == 0; if (type == 0) { if (!exist) pszDest[0] = 0; return; } if (!exist) CreateDirectoryTreeT(pszDest); TCHAR *sztSmileyName = mir_a2t(SmileyName); mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s.%s"), sztSmileyName, type == MSN_APPID_CUSTOMSMILEY ? _T("png") : _T("gif")); mir_free(sztSmileyName); }
int OnFoldersChanged(WPARAM, LPARAM) { FoldersGetCustomPathT(hBASSFolder, CurrBassPath, MAX_PATH, _T("")); mir_tstrcat(CurrBassPath, _T("\\bass.dll")); if (hBass != NULL) { BASS_Free(); FreeLibrary(hBass); UnhookEvent(hPlaySound); DeleteFrame(); } LoadBassLibrary(CurrBassPath); return 0; }
void CMLua::SetPaths() { TCHAR path[MAX_PATH]; FoldersGetCustomPathT(g_hScriptsFolder, path, _countof(path), VARST(MIRLUA_PATHT)); lua_getglobal(L, "package"); lua_pushfstring(L, "%s\\?.dll", ptrA(mir_utf8encodeT(path))); lua_setfield(L, -2, "cpath"); lua_pushfstring(L, "%s\\?.lua", ptrA(mir_utf8encodeT(path))); lua_setfield(L, -2, "path"); lua_pop(L, 1); }
extern "C" __declspec(dllexport) int Load(void) { mir_getLP(&pluginInfoEx); TCHAR* tszFolder = Utils_ReplaceVarsT(_T("%miranda_userdata%\\" DEFAULT_UPDATES_FOLDER)); mir_tstrncpy(tszRoot, tszFolder, _countof(tszRoot)); hPackUpdaterFolder = FoldersRegisterCustomPathT(MODULEA, LPGEN("Pack Updater"), MIRANDA_USERDATAT _T("\\")DEFAULT_UPDATES_FOLDER); if (hPackUpdaterFolder) FoldersGetCustomPathT(hPackUpdaterFolder, tszRoot, MAX_PATH, _T("")); mir_free(tszFolder); LoadOptions(); InitPopupList(); NetlibInit(); IcoLibInit(); // Add cheking update menu item CreateServiceFunction(MODNAME"/CheckUpdates", MenuCommand); CMenuItem mi; SET_UID(mi, 0x326495e8, 0xab0a, 0x47d2, 0xb2, 0x22, 0x2a, 0x8e, 0xa8, 0xae, 0x53, 0x1a); mi.position = -0x7FFFFFFF; mi.flags = CMIF_TCHAR; mi.hIcolibItem = IcoLib_GetIcon("check_update"); mi.name.t = LPGENT("Check for pack updates"); mi.pszService = MODNAME"/CheckUpdates"; Menu_AddMainMenuItem(&mi); // Add empty updates folder menu item CreateServiceFunction(MODNAME"/EmptyFolder", EmptyFolder); memset(&mi, 0, sizeof(mi)); SET_UID(mi, 0xc3eea590, 0xaba3, 0x454f, 0x93, 0x93, 0xbc, 0x97, 0x15, 0x2c, 0x3b, 0x3d); mi.position = -0x7FFFFFFF; mi.flags = CMIF_TCHAR; mi.hIcolibItem = IcoLib_GetIcon("empty_folder"); mi.name.t = LPGENT("Clear pack updates folder"); mi.pszService = MODNAME"/EmptyFolder"; Menu_AddMainMenuItem(&mi); // Add options hook HookEvent(ME_OPT_INITIALISE, OptInit); HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown); return 0; }
void LogSpamToFile(HANDLE hContact, tstring message) { if (!gbLogToFile) return; tstring LogStrW, LogTime, LogProtocol, LogContactId, LogContactName; tstring filename; std::fstream file; TCHAR pszName[MAX_PATH]; if (hStopSpamLogDirH) FoldersGetCustomPathT(hStopSpamLogDirH, pszName, MAX_PATH, _T("")); else lstrcpyn(pszName, VARST( _T("%miranda_logpath%")), SIZEOF(pszName)); filename = pszName; filename = filename + _T("\\stopspam_mod.log"); file.open(filename.c_str(),std::ios::out |std::ios::app); // Time Log line time_t time_now; tm *TimeNow; time(&time_now); TimeNow = localtime(&time_now); LogTime=_wasctime( TimeNow ); // Time Log line // Name, UID and Protocol Log line LogProtocol=DBGetContactSettingStringPAN(hContact,"Protocol","p",_T("")); LogContactName=(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR); LogContactId=(LogProtocol==_T(""))?_T(""):GetContactUid(hContact,LogProtocol); // Name, UID and Protocol Log line LogStrW=_T("[")+LogTime.substr(0,LogTime.length()-1)+_T("] ")+ LogContactId+_T(" - ")+ LogContactName+_T(" (")+ LogProtocol+_T("): ")+ message+_T("\n"); char * buf=mir_u2a(LogStrW.c_str()); file.write(buf,LogStrW.length()); mir_free(buf); file.close(); }
int OnModulesLoaded(WPARAM, LPARAM) { if (hBASSFolder = FoldersRegisterCustomPathT(LPGEN("Bass Interface"), LPGEN("Bass library"), PLUGINS_PATHT _T("\\Bass"))) { FoldersGetCustomPathT(hBASSFolder, CurrBassPath, MAX_PATH, _T("")); mir_tstrcat(CurrBassPath, _T("\\bass.dll")); } else { DBVARIANT dbv; if (db_get_ts(NULL, ModuleName, OPT_BASSPATH, &dbv)) { mir_tstrncpy(CurrBassPath, VARST(_T("Plugins\\Bass\\bass.dll")), _countof(CurrBassPath)); db_set_ts(NULL, ModuleName, OPT_BASSPATH, CurrBassPath); } else { mir_tstrcpy(CurrBassPath, dbv.ptszVal); db_free(&dbv); } } LoadBassLibrary(CurrBassPath); HookEvent(ME_OPT_INITIALISE, OptionsInit); HookEvent(ME_FOLDERS_PATH_CHANGED, OnFoldersChanged); return 0; }
int OnFoldersChanged(WPARAM, LPARAM) { FoldersGetCustomPathT(hNewsAggregatorFolder, tszRoot, MAX_PATH, _T("")); return 0; }
static int FoldersGetBackupPath(WPARAM, LPARAM) { FoldersGetCustomPathT(hFolder, options.folder, MAX_PATH, DIR SUB_DIR); return 0; }
// Called when all the modules are loaded static int ModulesLoaded(WPARAM, LPARAM) { variables_enabled = ServiceExists(MS_VARS_FORMATSTRING); // Folders plugin support if (hDictionariesFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Dictionaries"), DICTIONARIES_FOLDER)) { dictionariesFolder = (TCHAR *)mir_alloc(sizeof(TCHAR) * MAX_PATH); FoldersGetCustomPathT(hDictionariesFolder, dictionariesFolder, MAX_PATH, _T(".")); } else dictionariesFolder = Utils_ReplaceVarsT(DICTIONARIES_FOLDER); if (hCustomDictionariesFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Custom Dictionaries"), CUSTOM_DICTIONARIES_FOLDER)) { customDictionariesFolder = (TCHAR *)mir_alloc(sizeof(TCHAR) * MAX_PATH); FoldersGetCustomPathT(hCustomDictionariesFolder, customDictionariesFolder, MAX_PATH, _T(".")); } else customDictionariesFolder = Utils_ReplaceVarsT(CUSTOM_DICTIONARIES_FOLDER); if (hFlagsDllFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Flags DLL"), FLAGS_DLL_FOLDER)) { flagsDllFolder = (TCHAR *)mir_alloc(sizeof(TCHAR) * MAX_PATH); FoldersGetCustomPathT(hFlagsDllFolder, flagsDllFolder, MAX_PATH, _T(".")); } else flagsDllFolder = Utils_ReplaceVarsT(FLAGS_DLL_FOLDER); InitOptions(); GetAvaibleDictionaries(languages, dictionariesFolder, customDictionariesFolder); LoadOptions(); if (opts.use_flags) { // Load flags dll TCHAR flag_file[MAX_PATH]; mir_sntprintf(flag_file, _T("%s\\flags_icons.dll"), flagsDllFolder); HMODULE hFlagsDll = LoadLibraryEx(flag_file, NULL, LOAD_LIBRARY_AS_DATAFILE); TCHAR path[MAX_PATH]; GetModuleFileName(hInst, path, MAX_PATH); SKINICONDESC sid = { 0 }; sid.flags = SIDF_ALL_TCHAR | SIDF_SORTED; sid.section.t = LPGENT("Spell Checker") _T("/") LPGENT("Flags"); // Get language flags for (int i = 0; i < languages.getCount(); i++) { Dictionary *p = languages[i]; sid.description.t = p->full_name; char lang[32]; mir_snprintf(lang, "spell_lang_%d", i); sid.pszName = lang; HICON hFlag = NULL, hFlagIcoLib = NULL; if (hFlagsDll != NULL) hFlag = (HICON)LoadImage(hFlagsDll, p->language, IMAGE_ICON, 16, 16, 0); if (hFlag != NULL) { sid.hDefaultIcon = hFlag; sid.defaultFile.t = NULL; sid.iDefaultIndex = 0; } else { hFlagIcoLib = IcoLib_GetIcon("spellchecker_unknown"); sid.hDefaultIcon = hFlagIcoLib; sid.defaultFile.t = NULL; sid.iDefaultIndex = 0; } // Oki, lets add to IcoLib, then p->hIcolib = IcoLib_AddIcon(&sid); if (hFlag != NULL) DestroyIcon(hFlag); else IcoLib_ReleaseIcon(hFlagIcoLib); } FreeLibrary(hFlagsDll); } for (int j = 0; j < languages.getCount(); j++) { Dictionary *dict = languages[j]; TCHAR filename[MAX_PATH]; mir_sntprintf(filename, _T("%s\\%s.ar"), customDictionariesFolder, dict->language); dict->autoReplace = new AutoReplaceMap(filename, dict); if (mir_tstrcmp(dict->language, opts.default_language) == 0) dict->load(); } HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged); HookEvent(ME_MSG_WINDOWEVENT, MsgWindowEvent); HookEvent(ME_MSG_WINDOWPOPUP, MsgWindowPopup); HookEvent(ME_MSG_ICONPRESSED, IconPressed); StatusIconData sid = { sizeof(sid) }; sid.szModule = MODULE_NAME; sid.hIconDisabled = IcoLib_GetIcon("spellchecker_disabled"); sid.flags = MBF_TCHAR | MBF_HIDDEN; for (int i = 0; i < languages.getCount(); i++) { sid.dwId = i; TCHAR tmp[128]; mir_sntprintf(tmp, _T("%s - %s"), TranslateT("Spell Checker"), languages[i]->full_name); sid.tszTooltip = tmp; sid.hIcon = (opts.use_flags) ? IcoLib_GetIconByHandle(languages[i]->hIcolib) : IcoLib_GetIcon("spellchecker_enabled"); Srmm_AddIcon(&sid); } HOTKEYDESC hkd = { sizeof(hkd) }; hkd.pszName = "Spell Checker/Toggle"; hkd.pszSection = LPGEN("Spell Checker"); hkd.pszDescription = LPGEN("Enable/disable spell checker"); hkd.DefHotKey = HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_ALT, 'S'); hkd.lParam = HOTKEY_ACTION_TOGGLE; Hotkey_Register(&hkd); loaded = TRUE; return 0; }
int FolderChanged(WPARAM, LPARAM) { FoldersGetCustomPathT(hFolder, cachepath, MAX_PATH, _T("")); return 0; }
static int InternalSetMyAvatar(char *protocol, TCHAR *szFinalName, SetMyAvatarHookData &data, BOOL allAcceptXML, BOOL allAcceptSWF) { int format = ProtoGetAvatarFormat(szFinalName); if (format == PA_FORMAT_UNKNOWN || _taccess(szFinalName, 4) == -1) return -3; // file exists... HBITMAP hBmp = NULL; if (format == PA_FORMAT_SWF) { if (!allAcceptSWF) return -4; } else if (format == PA_FORMAT_XML) { if (!allAcceptXML) return -4; } else { // Try to open if is not a flash or XML hBmp = (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)szFinalName, IMGL_TCHAR); if (hBmp == NULL) return -4; } SetIgnoreNotify(protocol, TRUE); int ret = 0; if (protocol != NULL) { ret = SetProtoMyAvatar(protocol, hBmp, szFinalName, format, data.square, data.grow); if (ret == 0) { DeleteGlobalUserAvatar(); db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1); } } else { int count; PROTOACCOUNT **accs; ProtoEnumAccounts(&count, &accs); for (int i = 0; i < count; i++) { if (!ProtoServiceExists(accs[i]->szModuleName, PS_SETMYAVATAR)) continue; if (!Proto_IsAvatarsEnabled(accs[i]->szModuleName)) continue; int retTmp = SetProtoMyAvatar(accs[i]->szModuleName, hBmp, szFinalName, format, data.square, data.grow); if (retTmp != 0) ret = retTmp; } DeleteGlobalUserAvatar(); if (ret) db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1); else { // Copy avatar file to store as global one TCHAR globalFile[1024]; BOOL saved = TRUE; if (FoldersGetCustomPathT(hGlobalAvatarFolder, globalFile, SIZEOF(globalFile), _T(""))) { mir_sntprintf(globalFile, SIZEOF(globalFile), _T("%s%s"), g_szDataPath, _T("GlobalAvatar")); CreateDirectory(globalFile, NULL); } TCHAR *ext = _tcsrchr(szFinalName, _T('.')); // Can't be NULL here if (format == PA_FORMAT_XML || format == PA_FORMAT_SWF) { mir_sntprintf(globalFile, SIZEOF(globalFile), _T("%s\\my_global_avatar%s"), globalFile, ext); CopyFile(szFinalName, globalFile, FALSE); } else { // Resize (to avoid too big avatars) ResizeBitmap rb = { 0 }; rb.size = sizeof(ResizeBitmap); rb.hBmp = hBmp; rb.max_height = 300; rb.max_width = 300; rb.fit = (data.grow ? 0 : RESIZEBITMAP_FLAG_DONT_GROW) | (data.square ? RESIZEBITMAP_MAKE_SQUARE : RESIZEBITMAP_KEEP_PROPORTIONS); HBITMAP hBmpTmp = (HBITMAP)CallService(MS_IMG_RESIZE, WPARAM(&rb), 0); // Check if need to resize if (hBmpTmp == hBmp || hBmpTmp == NULL) { // Use original image mir_sntprintf(globalFile, SIZEOF(globalFile), _T("%s\\my_global_avatar%s"), globalFile, ext); CopyFile(szFinalName, globalFile, FALSE); } else { // Save as PNG mir_sntprintf(globalFile, SIZEOF(globalFile), _T("%s\\my_global_avatar.png"), globalFile); if (BmpFilterSaveBitmap(hBmpTmp, globalFile, 0)) saved = FALSE; DeleteObject(hBmpTmp); } } if (saved) { TCHAR relFile[1024]; if (PathToRelativeT(globalFile, relFile, g_szDataPath)) db_set_ts(NULL, AVS_MODULE, "GlobalUserAvatarFile", relFile); else db_set_ts(NULL, AVS_MODULE, "GlobalUserAvatarFile", globalFile); db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 0); } else db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1); } } DeleteObject(hBmp); SetIgnoreNotify(protocol, FALSE); ReportMyAvatarChanged(WPARAM((protocol == NULL) ? "" : protocol), 0); return ret; }
INT_PTR avSetMyAvatar(char* protocol, TCHAR* tszPath) { TCHAR FileName[MAX_PATH]; TCHAR *szFinalName = NULL; BOOL allAcceptXML; BOOL allAcceptSWF; // Protocol allow seting of avatar? if (protocol != NULL && !CanSetMyAvatar((WPARAM)protocol, 0)) return -1; if (tszPath == NULL && hwndSetMyAvatar != 0) { SetForegroundWindow(hwndSetMyAvatar); SetFocus(hwndSetMyAvatar); ShowWindow(hwndSetMyAvatar, SW_SHOW); return -2; } SetMyAvatarHookData data = { 0 }; // Check for XML and SWF if (protocol == NULL) { allAcceptXML = TRUE; allAcceptSWF = TRUE; int count; PROTOACCOUNT **accs; ProtoEnumAccounts(&count, &accs); for (int i = 0; i < count; i++) { if (!ProtoServiceExists(accs[i]->szModuleName, PS_SETMYAVATAR)) continue; if (!Proto_IsAvatarsEnabled(accs[i]->szModuleName)) continue; allAcceptXML = allAcceptXML && Proto_IsAvatarFormatSupported(accs[i]->szModuleName, PA_FORMAT_XML); allAcceptSWF = allAcceptSWF && Proto_IsAvatarFormatSupported(accs[i]->szModuleName, PA_FORMAT_SWF); } data.square = db_get_b(0, AVS_MODULE, "SetAllwaysMakeSquare", 0); } else { allAcceptXML = Proto_IsAvatarFormatSupported(protocol, PA_FORMAT_XML); allAcceptSWF = Proto_IsAvatarFormatSupported(protocol, PA_FORMAT_SWF); data.protocol = protocol; data.square = (Proto_AvatarImageProportion(protocol) & PIP_SQUARE) || db_get_b(0, AVS_MODULE, "SetAllwaysMakeSquare", 0); } if (tszPath == NULL) { data.protocol = protocol; CMString filter; FilterGetStrings(filter, allAcceptXML, allAcceptSWF); TCHAR inipath[1024]; FoldersGetCustomPathT(hMyAvatarsFolder, inipath, SIZEOF(inipath), _T(".")); OPENFILENAME ofn = { 0 }; ofn.lStructSize = sizeof(ofn); ofn.lpstrFile = FileName; ofn.lpstrFilter = filter; ofn.nMaxFile = MAX_PATH; ofn.nMaxFileTitle = MAX_PATH; ofn.Flags = OFN_FILEMUSTEXIST | OFN_ENABLETEMPLATE | OFN_EXPLORER | OFN_ENABLESIZING | OFN_ENABLEHOOK; ofn.lpstrInitialDir = inipath; ofn.lpTemplateName = MAKEINTRESOURCE(IDD_SET_OWN_SUBCLASS); ofn.lpfnHook = SetMyAvatarHookProc; ofn.lCustData = (LPARAM)&data; *FileName = '\0'; ofn.lpstrDefExt = _T(""); ofn.hInstance = g_hInst; TCHAR title[256]; if (protocol == NULL) mir_sntprintf(title, SIZEOF(title), TranslateT("Set My Avatar")); else { TCHAR* prototmp = mir_a2t(protocol); mir_sntprintf(title, SIZEOF(title), TranslateT("Set My Avatar for %s"), prototmp); mir_free(prototmp); } ofn.lpstrTitle = title; if (!GetOpenFileName(&ofn)) return 1; szFinalName = FileName; } else szFinalName = (TCHAR*)tszPath; // filename is now set, check it and perform all needed action if (szFinalName[0] == '\0') return InternalRemoveMyAvatar(protocol); return InternalSetMyAvatar(protocol, szFinalName, data, allAcceptXML, allAcceptSWF); }