extern "C" SAMETIME_API int Load(PLUGINLINK *link) { pluginLink=link; if(!IsUnicodeOS()) { MessageBox(0, TranslateT("This plugin requires a Unicode capable Windows installation."), TranslateT("Sametime Error"), MB_OK | MB_ICONERROR); return 1; } if ( !ServiceExists( MS_DB_CONTACT_GETSETTING_STR )) { MessageBox( 0, TranslateT( "This plugin requires db3x plugin version 0.5.1.0 or later." ), TranslateT("Sametime Error"), MB_OK ); return 1; } DuplicateHandle( GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, THREAD_SET_CONTEXT, FALSE, 0 ); mainThreadId = GetCurrentThreadId(); previous_status = current_status = ID_STATUS_OFFLINE; if(ServiceExists(MS_LANGPACK_GETCODEPAGE)) code_page = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0); mir_getMMI(&mmi); mir_getUTFI(&utfi); if(ServiceExists(MS_DB_SETSETTINGRESIDENT)) { // 0.6+ char buff[256]; mir_snprintf(buff, 256, "%s/%s", PROTO, "Status"); CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)buff); mir_snprintf(buff, 256, "%s/%s", PROTO, "IdleTS"); CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)buff); } InitAwayMsg(); InitCritSection(); // Get module name from DLL file name { char* str1; char str2[MAX_PATH]; GetModuleFileNameA(hInst, str2, MAX_PATH); str1 = strrchr(str2, '\\'); if (str1 != NULL && strlen(str1+1) > 4) { strncpy(PROTO, str1+1, strlen(str1+1)-4); PROTO[strlen(str1+1)-3] = 0; } CharUpperA(PROTO); strcpy(PROTO_GROUPS, PROTO); strcat(PROTO_GROUPS, "_GROUPS"); } PROTOCOLDESCRIPTOR pd = {0}; pd.cbSize = sizeof(pd); pd.szName = PROTO; pd.type = PROTOTYPE_PROTOCOL; CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd); InitUtils(); CreatePluginServices(); LoadOptions(); //DeleteAllContacts(); //!!! SetAllOffline(); HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); HookEvent(ME_OPT_INITIALISE, OptInit ); HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown); HookEvent(ME_SYSTEM_SHUTDOWN, OnShutdown); return 0; }
HRESULT CFileStream::OpenFile(WCHAR* pwszFile, WCHAR* pwszMode) { if(IsUnicodeOS()) { _wfopen_s(&m_pFile, pwszFile, pwszMode); } else { CHAR szFileName[MAX_NAME_LEN]; ConvertToMBCS(pwszFile, szFileName, MAX_NAME_LEN); CHAR szMode[MAX_NAME_LEN]; ConvertToMBCS(pwszMode, szMode, MAX_NAME_LEN); fopen_s(&m_pFile, szFileName, szMode); } return m_pFile ? S_OK : STG_E_ACCESSDENIED; }
/** Initializes the services provided and the link to those needed * Called when the plugin is loaded into Miranda */ int __declspec(dllexport)Load(PLUGINLINK *link) { PROTOCOLDESCRIPTOR pd; DBVARIANT dbv; pluginLink=link; mir_getMMI(&mmi); mir_getLP(&pluginInfo); os_unicode_enabled = IsUnicodeOS(); if(ServiceExists(MS_DB_SETSETTINGRESIDENT)) { // 0.6+ CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)(META_PROTO "/Status")); CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)(META_PROTO "/IdleTS")); CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)(META_PROTO "/ContactCountCheck")); CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)(META_PROTO "/Handle")); CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)(META_PROTO "/WindowOpen")); } //set all contacts to 'offline', and initialize subcontact counter for db consistency check { HANDLE hContact = (HANDLE)CallService( MS_DB_CONTACT_FINDFIRST, 0, 0); char *proto; while(hContact != NULL) { //proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); if(!DBGetContactSetting(hContact, "Protocol", "p", &dbv)) { proto = dbv.pszVal; if (proto && !lstrcmp( META_PROTO, proto)) { DBWriteContactSettingWord(hContact, META_PROTO, "Status", ID_STATUS_OFFLINE); DBWriteContactSettingDword(hContact, META_PROTO, "IdleTS", 0); DBWriteContactSettingByte(hContact, META_PROTO, "ContactCountCheck", 0); // restore any saved defaults that might have remained if miranda was closed or crashed while a convo was happening if(DBGetContactSettingDword(hContact, META_PROTO, "SavedDefault", (DWORD)-1) != (DWORD)-1) { DBWriteContactSettingDword(hContact, META_PROTO, "Default", DBGetContactSettingDword(hContact, META_PROTO, "SavedDefault", 0)); DBWriteContactSettingDword(hContact, META_PROTO, "SavedDefault", (DWORD)-1); } } DBFreeVariant(&dbv); } hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 ); } } Meta_ReadOptions(&options); // sets subcontact handles to metacontacts, and metacontact handles to subcontacts // (since these handles are not necessarily the same from run to run of miranda) // also verifies that subcontacts: have metacontacts, and that contact numbers are reasonable, // that metacontacts: have the correct number of subcontacts, and have reasonable defaults if(Meta_SetHandles()) { // error - db corruption if(!DBGetContactSettingByte(0, META_PROTO, "DisabledMessageShown", 0)) { MessageBox(0, Translate("Error - Database corruption.\nPlugin disabled."), Translate("MetaContacts"), MB_OK | MB_ICONERROR); DBWriteContactSettingByte(0, META_PROTO, "DisabledMessageShown", 1); } //Meta_HideMetaContacts(TRUE); return 1; } DBDeleteContactSetting(0, META_PROTO, "DisabledMessageShown"); // add our modules to the KnownModules list { DBVARIANT dbv; if (DBGetContactSetting(NULL, "KnownModules", META_PROTO, &dbv)) DBWriteContactSettingString(NULL, "KnownModules", META_PROTO, META_PROTO); else DBFreeVariant(&dbv); } ZeroMemory(&pd,sizeof(pd)); pd.cbSize=PROTOCOLDESCRIPTOR_V3_SIZE;//sizeof(pd); pd.szName=META_FILTER; pd.type=PROTOTYPE_FILTER; CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd); ZeroMemory(&pd,sizeof(pd)); pd.cbSize=PROTOCOLDESCRIPTOR_V3_SIZE;//sizeof(pd); pd.szName=META_PROTO; pd.type = PROTOTYPE_PROTOCOL; CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd); // further db setup done in modules loaded (nick [protocol string required] & clist display name) Meta_InitServices(); // moved to 'modules loaded' event handler (in meta_services.c) because we need to // check protocol for jabber hack, and the proto modules must be loaded //Meta_HideLinkedContactsAndSetHandles(); if(ServiceExists(MS_MSG_GETWINDOWAPI)) { message_window_api_enabled = TRUE; } // for clist_meta_mw - write hidden group name to DB DBWriteContactSettingString(0, META_PROTO, "HiddenGroupName", META_HIDDEN_GROUP); return 0; }