purple: make it compile against 3.0.x API
[siplcs.git] / src / miranda / miranda-ft.c
blobc7d88c2e1f920f0a24721f209bc515d87503a203
1 /**
2 * @file miranda-ft.c
4 * pidgin-sipe
6 * Copyright (C) 2010-11 SIPE Project <http://sipe.sourceforge.net/>
7 * Copyright (C) 2010 Jakub Adam <jakub.adam@ktknet.cz>
8 * Copyright (C) 2010 Tomáš Hrabčík <tomas.hrabcik@tieto.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <windows.h>
26 #include <stdio.h>
28 #include <glib.h>
30 #include "newpluginapi.h"
31 #include "m_protosvc.h"
32 #include "m_protoint.h"
33 #include "m_database.h"
34 #include "m_protomod.h"
36 #include "sipe-common.h"
37 #include "sipe-backend.h"
38 #include "sipe-core.h"
39 #include "sipe-nls.h"
40 #include "miranda-private.h"
42 struct sipe_backend_file_transfer {
43 gboolean incoming;
46 void sipe_backend_ft_error(struct sipe_file_transfer *ft,
47 const gchar *errmsg)
49 _NIF();
52 const gchar *sipe_backend_ft_get_error(SIPE_UNUSED_PARAMETER struct sipe_file_transfer *ft)
54 _NIF();
55 return NULL;
58 void sipe_backend_ft_deallocate(struct sipe_file_transfer *ft)
60 g_free(ft->backend_private);
63 gssize sipe_backend_ft_read(struct sipe_file_transfer *ft,
64 guchar *data,
65 gsize size)
67 _NIF();
68 return 0;
71 gssize sipe_backend_ft_write(struct sipe_file_transfer *ft,
72 const guchar *data,
73 gsize size)
75 _NIF();
76 return 0;
79 void sipe_backend_ft_cancel_local(struct sipe_file_transfer *ft)
81 _NIF();
84 void sipe_backend_ft_cancel_remote(struct sipe_file_transfer *ft)
86 _NIF();
89 void sipe_backend_ft_incoming(struct sipe_core_public *sipe_public,
90 struct sipe_file_transfer *ft,
91 const gchar *who,
92 const gchar *file_name,
93 gsize file_size)
95 SIPPROTO *pr = sipe_public->backend_private;
96 PROTORECVFILET pre = {0};
97 CCSDATA ccs;
98 HANDLE hContact;
100 hContact = sipe_backend_buddy_find( sipe_public, who, NULL );
101 if (!hContact)
103 SIPE_DEBUG_INFO("Adding miranda contact for incoming transfer from <%s>", who);
104 hContact = ( HANDLE )CallService( MS_DB_CONTACT_ADD, 0, 0 );
105 CallService( MS_PROTO_ADDTOCONTACT, ( WPARAM )hContact,( LPARAM )pr->proto.m_szModuleName );
106 DBWriteContactSettingByte( hContact, "CList", "NotOnList", 1 );
107 sipe_miranda_setContactString( pr, hContact, SIP_UNIQUEID, who ); // name
110 ft->backend_private = g_new0(struct sipe_backend_file_transfer, 1);
111 ft->backend_private->incoming = TRUE;
113 pre.flags = PREF_TCHAR;
114 pre.timestamp = time(NULL);
115 pre.tszDescription = mir_a2t(file_name);
116 pre.fileCount = 1;
117 pre.ptszFiles = &pre.tszDescription;
118 pre.lParam = (LPARAM)ft;
120 ccs.szProtoService = PSR_FILE;
121 ccs.hContact = hContact;
122 ccs.wParam = 0;
123 ccs.lParam = (LPARAM)&pre;
124 CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
128 gboolean
129 sipe_backend_ft_incoming_accept(struct sipe_file_transfer *ft,
130 const gchar *ip,
131 unsigned short port_min,
132 unsigned short port_max)
134 _NIF();
135 return FALSE;
138 void
139 sipe_backend_ft_start(struct sipe_file_transfer *ft, struct sipe_backend_fd *fd,
140 const char* ip, unsigned port)
142 _NIF();
145 gboolean
146 sipe_backend_ft_is_incoming(struct sipe_file_transfer *ft)
148 return ft->backend_private->incoming;
151 HANDLE
152 sipe_miranda_SendFile( SIPPROTO *pr, HANDLE hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles )
154 struct sipe_file_transfer *ft = sipe_core_ft_allocate(pr->sip);
155 DBVARIANT dbv;
157 if ( !DBGetContactSettingString( hContact, pr->proto.m_szModuleName, SIP_UNIQUEID, &dbv )) {
158 LOCK;
159 ft->backend_private = g_new0(struct sipe_backend_file_transfer, 1);
160 ft->backend_private->incoming = FALSE;
161 sipe_core_ft_outgoing_init(ft, TCHAR2CHAR(ppszFiles[0]), 10, dbv.pszVal);
162 UNLOCK;
164 SIPE_DEBUG_INFO("SendFile: desc <%ls> name <%s> to <%s>", szDescription, TCHAR2CHAR(ppszFiles[0]), dbv.pszVal);
165 DBFreeVariant( &dbv );
168 return NULL;
172 sipe_miranda_RecvFile( SIPPROTO *pr, HANDLE hContact, PROTOFILEEVENT* evt )
174 CCSDATA ccs = { hContact, PSR_FILE, 0, (LPARAM)evt };
175 return CallService(MS_PROTO_RECVFILET, 0, (LPARAM)&ccs);
178 HANDLE
179 sipe_miranda_FileAllow( SIPPROTO *pr, HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szPath )
181 struct sipe_file_transfer *ft = (struct sipe_file_transfer *)hTransfer;
182 sipe_core_ft_incoming_init(ft);
183 return ft;
188 Local Variables:
189 mode: c
190 c-file-style: "bsd"
191 indent-tabs-mode: t
192 tab-width: 8
193 End: