summaryrefslogtreecommitdiff
path: root/plugins/ExternalAPI/m_ftpfile.h
blob: 6bf82bb469b85c72cd3f5110bd6de1c57fdbefbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
FTP File YM plugin
Copyright (C) 2007-2010 Jan Holub

This is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This 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.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this file; see the file license.txt.  If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  
*/


#ifndef __M_FTP_FILE_H__
#define __M_FTP_FILE_H__

#define FNUM_DEFAULT	0		// user's default FTP server
#define FNUM_FTP1		1		// first FTP server in setting
#define FNUM_FTP2		2		// second...
#define FNUM_FTP3		3
#define FNUM_FTP4		4
#define FNUM_FTP5		5

#define FMODE_RAWFILE	1		// Object list contains path(s) to file(s) which will be uploaded as they are
#define FMODE_ZIPFILE	2		// ... path(s) to file(s) which will be zipped and uploaded as one ZIP file 
#define FMODE_ZIPFOLDER	4		// ... path to folder which will be zipped and uploaded as one ZIP file (objectCount == 1)

#define FUPL_UNICODE	1		// Object list contains WCHAR* paths 

#if defined _UNICODE || defined UNICODE
#define FUPL_TCHAR		FUPL_UNICODE
#else
#define FUPL_TCHAR		0
#endif

typedef struct 
{
	int cbSize;				// size of the structure
	HCONTACT hContact;			// contact handle, can be NULL
	BYTE ftpNum;				// number of the FTP server which will be used for upload, can be one of FNUM_* values
	BYTE mode;				// upload mode, can be one of FMODE_* values
	DWORD flags;				// bitwise OR of the FUPL_* flags above

	union {
		TCHAR	**pstzObjects;	// pointer to the array of the object(s) to upload, content is determined by MODE value	
		char	**pszObjects;	
		wchar_t	**pswzObjects;	
	};	

	int objectCount;			// number of items in Object list
} FTPUPLOAD;

//
//  Send file(s) or folder in selected mode to the FTP server
//	wParam = 0; not used
//	lParam = (LPARAM)(FTPUPLOAD*)&ftpu; pointer to FTPUPLOAD
//  returns 0 if upload started with no errors, nonzero otherwise
//
#define MS_FTPFILE_UPLOAD		"FTPFile/Upload"

__inline static INT_PTR FTPFileUploadA(HCONTACT hContact, BYTE ftpNum, BYTE mode, char **pszObjects, int objCount)
{	
	FTPUPLOAD ftpu = {0};
	ftpu.cbSize = sizeof(ftpu);
	ftpu.hContact = hContact;
	ftpu.ftpNum = ftpNum;
	ftpu.mode = mode;
	ftpu.pszObjects = pszObjects;
	ftpu.objectCount = objCount;
	return CallService(MS_FTPFILE_UPLOAD, 0, (LPARAM)&ftpu);
}

__inline static INT_PTR FTPFileUploadW(HCONTACT hContact, BYTE ftpNum, BYTE mode, wchar_t **pswzObjects, int objCount)
{	
	FTPUPLOAD ftpu = {0};
	ftpu.cbSize = sizeof(ftpu);
	ftpu.hContact = hContact;
	ftpu.ftpNum = ftpNum;
	ftpu.mode = mode;
	ftpu.flags = FUPL_UNICODE;
	ftpu.pswzObjects = pswzObjects;
	ftpu.objectCount = objCount;
	return CallService(MS_FTPFILE_UPLOAD, 0, (LPARAM)&ftpu);
}

#if defined _UNICODE || defined UNICODE
#define FTPFileUpload	FTPFileUploadW
#else
#define FTPFileUpload	FTPFileUploadA
#endif

//
//  Show a simple file manager
//  wParam = 0; not used
//  lParam = 0; not used
//  returns 0 always
//
#define MS_FTPFILE_SHOWMANAGER	"FTPFile/ShowManager"

__inline static INT_PTR FTPFileShowManager()
{	
	return CallService(MS_FTPFILE_SHOWMANAGER, 0, 0);
}

//
// OBSOLOTE SERVICE (used by Send Screenshot plugin)
// Do NOT use it!
//
#define MS_FTPFILE_SHAREFILE	"FTPFile/ShareFiles"

#endif