/*

MAgen.dll: Miranda plugin for mail.ru message exchange.

Copyright 2005-2010 Lenik.
Project home at http://www.lenik.ru/win32/magent
Author contact: lenik@lenik.ru

This program is free software.

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.

*/

void MAgent_OfflineAllContacts(void)
{
HANDLE hContact;
char* szProto;

hContact= (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
while(hContact)
    {
    szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
    if((szProto != NULL)&&(strcmp(szProto,ProtoName) == 0))
        {
        if(DBGetContactSettingWord(hContact,ProtoName,"Status",ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
            {
            DBWriteContactSettingWord(hContact,ProtoName,"Status",ID_STATUS_OFFLINE);
            }
        }
    hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
    }
}
