6 * Copyright (C) 2010 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "newpluginapi.h"
29 #include "m_protosvc.h"
30 #include "m_protoint.h"
32 #include "m_database.h"
33 #include "m_protomod.h"
35 #include "sipe-backend.h"
36 #include "sipe-core.h"
37 #include "miranda-private.h"
39 void sipe_backend_im_message(struct sipe_core_public
*sipe_public
,
43 SIPPROTO
*pr
= sipe_public
->backend_private
;
46 PROTORECVEVENT pre
= {0};
50 hContact
= sipe_backend_buddy_find( sipe_public
, from
, NULL
);
53 SIPE_DEBUG_INFO("Adding miranda contact for incoming talker <%s>", from
);
54 hContact
= ( HANDLE
)CallService( MS_DB_CONTACT_ADD
, 0, 0 );
55 CallService( MS_PROTO_ADDTOCONTACT
, ( WPARAM
)hContact
,( LPARAM
)pr
->proto
.m_szModuleName
);
56 DBWriteContactSettingByte( hContact
, "CList", "NotOnList", 1 );
57 sipe_miranda_setContactString( pr
, hContact
, SIP_UNIQUEID
, from
); // name
60 msg
= sipe_miranda_eliminate_html(html
, strlen(html
));
63 // pre.flags = PREF_UTF + (isRtl ? PREF_RTL : 0);
64 pre
.timestamp
= (DWORD
)time(NULL
);
67 ccs
.szProtoService
= PSR_MESSAGE
;
68 ccs
.hContact
= hContact
;
70 ccs
.lParam
= (LPARAM
)&pre
;
71 CallService(MS_PROTO_CHAINRECV
, 0, (LPARAM
)&ccs
);
77 int sipe_miranda_SendMsg(SIPPROTO
*pr
,
84 SIPE_DEBUG_INFO("SendMsg: flags <%x> msg <%s>", flags
, msg
);
86 if ( !DBGetContactSettingString( hContact
, pr
->proto
.m_szModuleName
, SIP_UNIQUEID
, &dbv
)) {
87 // SendProtoAck( pr, hContact, 1, ACKRESULT_SENTREQUEST, ACKTYPE_MESSAGE, NULL );
88 sipe_im_send(pr
->sip
, dbv
.pszVal
, msg
, SIPE_MESSAGE_SEND
);
89 SendProtoAck( pr
, hContact
, 1, ACKRESULT_SUCCESS
, ACKTYPE_MESSAGE
, NULL
);
92 SendProtoAck( pr
, hContact
, 1, ACKRESULT_FAILED
, ACKTYPE_MESSAGE
, NULL
);
97 int sipe_miranda_RecvMsg(SIPPROTO
*pr
,
101 // char *msg = EliminateHtml( pre->szMessage, strlen(pre->szMessage));
102 // mir_free(pre->szMessage);
103 // pre->szMessage = msg;
105 CCSDATA ccs
= { hContact
, PSR_MESSAGE
, 0, ( LPARAM
)pre
};
106 return CallService( MS_PROTO_RECVMSG
, 0, ( LPARAM
)&ccs
);