Пример #1
0
// Initializes the services provided and the link to those needed
// Called when the plugin is loaded into Miranda
int LoadMetacontacts(void)
{
	Icon_Register(g_hInst, LPGEN("MetaContacts"), iconList, _countof(iconList), "mc");

	db_set_resident(META_PROTO, "Status");
	db_set_resident(META_PROTO, "IdleTS");

	//set all contacts to 'offline', and initialize subcontact counter for db consistency check
	for (MCONTACT hContact = db_find_first(META_PROTO); hContact; hContact = db_find_next(hContact, META_PROTO)) {
		db_set_w(hContact, META_PROTO, "Status", ID_STATUS_OFFLINE);
		db_set_dw(hContact, META_PROTO, "IdleTS", 0);
	}	

	Meta_ReadOptions();

	PROTOCOLDESCRIPTOR pd = { 0 };
	pd.cbSize = sizeof(pd);
	pd.szName = META_FILTER;
	pd.type = PROTOTYPE_FILTER;
	Proto_RegisterModule(&pd);

	pd.szName = META_PROTO;
	pd.type = PROTOTYPE_VIRTUAL;
	Proto_RegisterModule(&pd);

	// further db setup done in modules loaded (nick [protocol string required] & clist display name)
	Meta_InitServices();
	return 0;
}
Пример #2
0
/** 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;
}