From a68efd9f17a4255a22d7e63741d723f986b23d0e Mon Sep 17 00:00:00 2001 From: sje Date: Sat, 30 Jun 2007 15:07:52 +0000 Subject: download buddies set status on server added away and invisible status git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@221 4f64403b-2f21-0410-a795-97e2b3489a10 --- MySpace/proto.cpp | 104 ++++++++---------------------------------------------- 1 file changed, 15 insertions(+), 89 deletions(-) (limited to 'MySpace/proto.cpp') diff --git a/MySpace/proto.cpp b/MySpace/proto.cpp index 60577b1..15bc91f 100644 --- a/MySpace/proto.cpp +++ b/MySpace/proto.cpp @@ -12,14 +12,16 @@ int GetCaps(WPARAM wParam,LPARAM lParam) { ret = PF1_NUMERICUSERID | PF1_IM | PF1_BASICSEARCH | PF1_SEARCHBYEMAIL | PF1_SEARCHBYNAME | PF1_ADDSEARCHRES | PF1_SERVERCLIST; break; case PFLAGNUM_2: - ret = PF2_ONLINE;// | PF2_SHORTAWAY | PF2_HEAVYDND; + ret = PF2_ONLINE | PF2_SHORTAWAY | PF2_INVISIBLE; break; case PFLAGNUM_3: - //ret = PF2_ONLINE;// | PF2_SHORTAWAY | PF2_HEAVYDND; break; case PFLAGNUM_4: //ret = PF4_SUPPORTTYPING; break; + case PFLAGNUM_5: + //ret = PF2_INVISIBLE; + break; case PFLAG_UNIQUEIDTEXT: ret = (int) Translate("UserID"); break; @@ -69,10 +71,7 @@ int GetInfo(WPARAM wParam,LPARAM lParam) { int SetStatus(WPARAM wParam,LPARAM lParam) { if(wParam == status) return 0; - if(wParam != ID_STATUS_OFFLINE) - InitServerConnection(); - else - DeinitServerConnection(); + SetServerStatus(wParam); return 0; } @@ -192,96 +191,21 @@ int SearchByName(WPARAM wParam, LPARAM lParam) { return req; } -HANDLE FindContact(int uid) { - char *proto; - DBVARIANT dbv; - int cuid; - HANDLE hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 ); - while ( hContact != NULL ) - { - proto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM )hContact,0 ); - if ( proto && !strcmp( MODULE, proto)) { - cuid = DBGetContactSettingDword(hContact, MODULE, "UID", (DWORD)-1); - if(cuid != (DWORD)-1) { - return hContact; - } - } - hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 ); - } - - return 0; -} - int AddToList(WPARAM wParam, LPARAM lParam) { MYPROTOSEARCHRESULT *mpsr = (MYPROTOSEARCHRESULT *)lParam; bool temp = (wParam & PALF_TEMPORARY) != 0; HANDLE hContact = FindContact(mpsr->uid); - bool new_contact = (hContact == 0); if(!hContact) { - hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0); - } else if(!temp) { - DBDeleteContactSetting(hContact, "CList", "NotOnList"); - DBDeleteContactSetting(hContact, "CList", "Hidden"); + hContact = CreateContact(mpsr->uid, mpsr->psr.nick, mpsr->psr.email); } - if(hContact) { - // add to miranda - if(new_contact) { - DBWriteContactSettingDword(hContact, MODULE, "UID", mpsr->uid); - - ClientNetMessage msg_add; - msg_add.add_string("addbuddy", ""); - msg_add.add_int("sesskey", sesskey); - msg_add.add_int("newprofileid", mpsr->uid); - msg_add.add_string("reason", ""); - - SendMessage(msg_add); - - ClientNetMessage msg_block; - msg_block.add_string("blocklist", ""); - msg_block.add_int("sesskey", sesskey); - - char idlist[1024]; - mir_snprintf(idlist, 1024, "b-|%d|a+|%d", mpsr->uid, mpsr->uid); - msg_block.add_string("idlist", idlist); - - SendMessage(msg_block); - - // update contact details? - ClientNetMessage msg_persist; - msg_persist.add_int("persist", 1); - msg_persist.add_int("sesskey", sesskey); - - msg_persist.add_int("cmd", 514); - msg_persist.add_int("dsn", 0); - msg_persist.add_int("uid", DBGetContactSettingDword(0, MODULE, "UID", 0)); - msg_persist.add_int("lid", 9); - msg_persist.add_int("rid", req_id++); - char body[4096]; - mir_snprintf(body, 4096, "ContactID=%d\x1cGroupName=\x1cPosition=1000\x1cVisibility=1\x1cNickName=\x1cNameSelect=0", mpsr->uid); - msg_persist.add_string("body", body); - SendMessage(msg_persist); - } - - if(mpsr->psr.nick && strlen(mpsr->psr.nick)) { - DBWriteContactSettingStringUtf(hContact, MODULE, "Nick", mpsr->psr.nick); - } - if(mpsr->psr.email && strlen(mpsr->psr.email)) { - DBWriteContactSettingStringUtf(hContact, MODULE, "email", mpsr->psr.email); - } - - if(new_contact) { - CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)MODULE); - } - - if(temp) { - DBWriteContactSettingByte(hContact, "CList", "NotOnList", 1); - DBWriteContactSettingByte(hContact, "CList", "Hidden", 1); - } else { - DBDeleteContactSetting(hContact, "CList", "NotOnList"); - DBDeleteContactSetting(hContact, "CList", "Hidden"); - } + if(temp) { + DBWriteContactSettingByte(hContact, "CList", "NotOnList", 1); + DBWriteContactSettingByte(hContact, "CList", "Hidden", 1); + } else { + DBDeleteContactSetting(hContact, "CList", "NotOnList"); + DBDeleteContactSetting(hContact, "CList", "Hidden"); } return (int)hContact; @@ -331,7 +255,7 @@ void RegisterProto() { CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd); } -#define NUM_FILTER_SERVICES 12 +#define NUM_FILTER_SERVICES 13 HANDLE hServices[NUM_FILTER_SERVICES]; HANDLE hEventContactDeleted; @@ -356,6 +280,8 @@ void CreateProtoServices() { // remember to modify the NUM_FILTER_SERVICES #define above if you add more services! hEventContactDeleted = HookEvent(ME_DB_CONTACT_DELETED, ContactDeleted); + + //my_space_server_running = false; } void DeinitProto() { -- cgit v1.2.3